From: Ken Cox Date: Wed, 19 Mar 2014 18:06:19 +0000 (-0500) Subject: Staging: unisys: Cleanup macros to get rid of goto statements X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=9f8d0e8bac8c74706b698dedd8ce307395091508;p=linux-beck.git Staging: unisys: Cleanup macros to get rid of goto statements Remove the following macros: TRY CHKFD CHKDD CHKFDX CHKDDX ADDPROCLINE TRY_WPOSTCODE_1 TRY_WPOSTCODE_2 FAIL_WPOSTCODE_2 FAIL_WPOSTCODE_3 Part of a series to get rid of goto statements embedded in macros. I'm breaking this up into a series of smaller patches for easier review. The later patches in the series will actually remove the goto statements. Signed-off-by: Ken Cox Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/unisys/include/timskmod.h b/drivers/staging/unisys/include/timskmod.h index c4262ab2cac3..413a3673772d 100644 --- a/drivers/staging/unisys/include/timskmod.h +++ b/drivers/staging/unisys/include/timskmod.h @@ -155,44 +155,10 @@ typedef long VMMIO32;/**< #VMMIO pointing to 32-bit data */ POSTCODE_LINUX_2(EVENT_PC, DIAG_SEVERITY_ERR); \ RETINT(status); \ } while (0) -#define FAIL_WPOSTCODE_2(msg, status, EVENT_PC, pcval32bit) do { \ - ERRDRV("'%s'" \ - ": error (status=%d)\n", \ - msg, status); \ - POSTCODE_LINUX_3(EVENT_PC, pcval32bit, DIAG_SEVERITY_ERR); \ - RETINT(status); \ - } while (0) -#define FAIL_WPOSTCODE_3(msg, status, EVENT_PC, pcval16bit1, pcval16bit2) \ - do { \ - ERRDRV("'%s'" \ - ": error (status=%d)\n", \ - msg, status); \ - POSTCODE_LINUX_4(EVENT_PC, pcval16bit1, pcval16bit2, \ - DIAG_SEVERITY_ERR); \ - RETINT(status); \ - } while (0) /** Try to evaulate the provided expression, and do a RETINT(x) iff * the expression evaluates to < 0. * @param x the expression to try */ -#define TRY(x) do { int status = (x); \ - if (status < 0) \ - FAIL(__stringify(x), status); \ - } while (0) - -#define TRY_WPOSTCODE_1(x, EVENT_PC) do { \ - int status = (x); \ - if (status < 0) \ - FAIL_WPOSTCODE_1(__stringify(x), status, EVENT_PC); \ - } while (0) - -#define TRY_WPOSTCODE_2(x, EVENT_PC, pcval32bit) do { \ - int status = (x); \ - if (status < 0) \ - FAIL_WPOSTCODE_2(__stringify(x), status, EVENT_PC, \ - pcval32bit); \ - } while (0) - #define ASSERT(cond) \ do { if (!(cond)) \ HUHDRV("ASSERT failed - %s", \ @@ -237,19 +203,6 @@ typedef long VMMIO32;/**< #VMMIO pointing to 32-bit data */ /* @} */ -/** Used to add a single line to the /proc filesystem buffer */ -#define ADDPROCLINE(buf, bufsize, line, linelen, totallen) \ - { \ - if ((totallen) + (linelen) >= bufsize) \ - RETINT(totallen); \ - if (linelen > 0) { \ - strcat(buf, line); \ - totallen += linelen; \ - } \ - } - - - /** Verifies the consistency of your PRIVATEDEVICEDATA structure using * conventional "signature" fields: *

@@ -272,42 +225,6 @@ typedef long VMMIO32;/**< #VMMIO pointing to 32-bit data */ ((fd)->sig1 == sizeof(PRIVATEFILEDATA)) && \ ((fd)->sig2 == fd)) -/** Verifies the consistency of a PRIVATEDEVICEDATA structure and reacts - * if necessary - */ -#define CHKDDX(dd, x) ( \ - if (!DDLOOKSVALID((dd))) { \ - PRINTKDRV("bad device structure"); \ - RETINT(x); \ - }) - -/** Verifies the consistency of a PRIVATEDEVICEDATA structure and reacts - * if necessary - */ -#define CHKDD(dd) ( \ - if (!DDLOOKSVALID(dd)) { \ - PRINTKDRV("bad device structure"); \ - RETVOID; \ - }) - -/** Verifies the consistency of a PRIVATEFILEDATA structure and reacts - * if necessary - */ -#define CHKFDX(fd, x) ( \ - if (!FDLOOKSVALID(fd)) { \ - PRINTKDRV("bad file structure"); \ - RETINT(x); \ - }) - -/** Verifies the consistency of a PRIVATEFILEDATA structure and reacts - * if necessary - */ -#define CHKFD(fd) ( \ - if (!FDLOOKSVALID(fd)) { \ - PRINTKDRV("bad file structure"); \ - RETVOID; \ - }) - /** Locks dd->lockDev if you havn't already locked it */ #define LOCKDEV(dd) \ { \ diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index e58b136d65e6..b0f97db2645e 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -2684,14 +2684,21 @@ visorchipset_init(void) memset(&LiveDump_info, 0, sizeof(LiveDump_info)); atomic_set(&LiveDump_info.buffers_in_use, 0); - if (visorchipset_testvnic) - FAIL_WPOSTCODE_2("testvnic option no longer supported", x, - CHIPSET_INIT_FAILURE_PC, x); + if (visorchipset_testvnic) { + ERRDRV("testvnic option no longer supported: (status = %d)\n", + x); + POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, x, DIAG_SEVERITY_ERR); + rc = x; + goto Away; + } controlvm_init(); MajorDev = MKDEV(visorchipset_major, 0); - TRY_WPOSTCODE_1(visorchipset_file_init(MajorDev, &ControlVm_channel), - CHIPSET_INIT_FAILURE_PC); + rc = visorchipset_file_init(MajorDev, &ControlVm_channel); + if (rc < 0) + FAIL_WPOSTCODE_1("visorchipset_file_init(MajorDev, &ControlVm_channel)", + rc, CHIPSET_INIT_FAILURE_PC); + proc_Init(); memset(PartitionPropertyNames, 0, sizeof(PartitionPropertyNames)); memset(ControlVmPropertyNames, 0, sizeof(ControlVmPropertyNames)); @@ -2760,10 +2767,12 @@ visorchipset_init(void) -ENOMEM, CREATE_WORKQUEUE_FAILED_PC); Most_recent_message_jiffies = jiffies; Poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST; - TRY_WPOSTCODE_1(queue_delayed_work - (Periodic_controlvm_workqueue, - &Periodic_controlvm_work, Poll_jiffies), - QUEUE_DELAYED_WORK_PC); + rc = queue_delayed_work(Periodic_controlvm_workqueue, + &Periodic_controlvm_work, Poll_jiffies); + if (rc < 0) + FAIL_WPOSTCODE_1("queue_delayed_work(Periodic_controlvm_workqueue, &Periodic_controlvm_work, Poll_jiffies);", + rc, QUEUE_DELAYED_WORK_PC); + } Visorchipset_platform_device.dev.devt = MajorDev;