mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
maint: Fix macros with broken 'do/while(0); ' usage
The point of writing a macro embedded in a 'do { ... } while (0)'
loop (particularly if the macro has multiple statements or would
otherwise end with an 'if' statement) is so that the macro can be
used as a drop-in statement with the caller supplying the
trailing ';'. Although our coding style frowns on brace-less 'if':
if (cond)
statement;
else
something else;
that is the classic case where failure to use do/while(0) wrapping
would cause the 'else' to pair with any embedded 'if' in the macro
rather than the intended outer 'if'. But conversely, if the macro
includes an embedded ';', then the same brace-less coding style
would now have two statements, making the 'else' a syntax error
rather than pairing with the outer 'if'. Thus, even though our
coding style with required braces is not impacted, ending a macro
with ';' makes our code harder to port to projects that use
brace-less styles.
The change should have no semantic impact. I was not able to
fully compile-test all of the changes (as some of them are
examples of the ugly bit-rotting debug print statements that are
completely elided by default, and I didn't want to recompile
with the necessary -D witnesses - cleaning those up is left as a
bite-sized task for another day); I did, however, audit that for
all files touched, all callers of the changed macros DID supply
a trailing ';' at the callsite, and did not appear to be used
as part of a brace-less conditional.
Found mechanically via: $ git grep -B1 'while (0);' | grep -A1 \\\\
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20171201232433.25193-7-eblake@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
committed by
Paolo Bonzini
parent
241187c118
commit
2562755ee7
+2
-2
@@ -89,7 +89,7 @@ static inline int PA_STREAM_IS_GOOD(pa_stream_state_t x)
|
||||
} \
|
||||
goto label; \
|
||||
} \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
#define CHECK_DEAD_GOTO(c, stream, rerror, label) \
|
||||
do { \
|
||||
@@ -107,7 +107,7 @@ static inline int PA_STREAM_IS_GOOD(pa_stream_state_t x)
|
||||
} \
|
||||
goto label; \
|
||||
} \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
static int qpa_simple_read (PAVoiceIn *p, void *data, size_t length, int *rerror)
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
if (STM_ADC_ERR_DEBUG >= lvl) { \
|
||||
qemu_log("%s: " fmt, __func__, ## args); \
|
||||
} \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
#define DB_PRINT(fmt, args...) DB_PRINT_L(1, fmt, ## args)
|
||||
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@
|
||||
fprintf(stderr, ": %s: ", __func__); \
|
||||
fprintf(stderr, ## __VA_ARGS__); \
|
||||
} \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
/* Fields for FlashPartInfo->flags */
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#define DB_PRINT(...) do { \
|
||||
fprintf(stderr, ": %s: ", __func__); \
|
||||
fprintf(stderr, ## __VA_ARGS__); \
|
||||
} while (0);
|
||||
} while (0)
|
||||
#else
|
||||
#define DB_PRINT(...)
|
||||
#endif
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
if (STM_USART_ERR_DEBUG >= lvl) { \
|
||||
qemu_log("%s: " fmt, __func__, ## args); \
|
||||
} \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
#define DB_PRINT(fmt, args...) DB_PRINT_L(1, fmt, ## args)
|
||||
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@
|
||||
if (DEBUG_CG3) { \
|
||||
printf("CG3: " fmt , ## __VA_ARGS__); \
|
||||
} \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
#define TYPE_CG3 "cgthree"
|
||||
#define CG3(obj) OBJECT_CHECK(CG3State, (obj), TYPE_CG3)
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@
|
||||
if (DEBUG_DPCD) { \
|
||||
qemu_log("dpcd: " fmt, ## __VA_ARGS__); \
|
||||
} \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
#define DPCD_READABLE_AREA 0x600
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
if (DEBUG_DP) { \
|
||||
qemu_log("xlnx_dp: " fmt , ## __VA_ARGS__); \
|
||||
} \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Register offset for DP.
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@
|
||||
if (PL330_ERR_DEBUG >= lvl) {\
|
||||
fprintf(stderr, "PL330: %s:" fmt, __func__, ## args);\
|
||||
} \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
#define DB_PRINT(fmt, args...) DB_PRINT_L(1, fmt, ## args)
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
if (XLNX_ZYNQ_DEVCFG_ERR_DEBUG) { \
|
||||
qemu_log("%s: " fmt, __func__, ## args); \
|
||||
} \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
REG32(CTRL, 0x00)
|
||||
FIELD(CTRL, FORCE_RST, 31, 1) /* Not supported, wr ignored */
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@
|
||||
if (DEBUG_DPDMA) { \
|
||||
qemu_log("xlnx_dpdma: " fmt , ## __VA_ARGS__); \
|
||||
} \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Registers offset for DPDMA.
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@
|
||||
if (DEBUG_I2CDDC) { \
|
||||
qemu_log("i2c-ddc: " fmt , ## __VA_ARGS__); \
|
||||
} \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
/* Structure defining a monitor's characteristics in a
|
||||
* readable format: this should be passed to build_edid_blob()
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@
|
||||
if (DEBUG_AUX) { \
|
||||
qemu_log("aux: " fmt , ## __VA_ARGS__); \
|
||||
} \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
#define TYPE_AUXTOI2C "aux-to-i2c-bridge"
|
||||
#define AUXTOI2C(obj) OBJECT_CHECK(AUXTOI2CState, (obj), TYPE_AUXTOI2C)
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
if (DEBUG_DBDMA) { \
|
||||
printf("DBDMA: " fmt , ## __VA_ARGS__); \
|
||||
} \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
#define DBDMA_DPRINTFCH(ch, fmt, ...) do { \
|
||||
if (DEBUG_DBDMA) { \
|
||||
@@ -60,7 +60,7 @@
|
||||
printf("DBDMA[%02x]: " fmt , (ch)->channel, ## __VA_ARGS__); \
|
||||
} \
|
||||
} \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
@@ -39,7 +39,7 @@ static uint64_t mmio_interface_counter;
|
||||
if (DEBUG_MMIO_INTERFACE) { \
|
||||
qemu_log("mmio_interface: 0x%" PRIX64 ": " fmt, s->id, ## __VA_ARGS__);\
|
||||
} \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
static void mmio_interface_init(Object *obj)
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
if (STM_SYSCFG_ERR_DEBUG >= lvl) { \
|
||||
qemu_log("%s: " fmt, __func__, ## args); \
|
||||
} \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
#define DB_PRINT(fmt, args...) DB_PRINT_L(1, fmt, ## args)
|
||||
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@
|
||||
fprintf(stderr, ": %s: ", __func__); \
|
||||
fprintf(stderr, ## __VA_ARGS__); \
|
||||
} \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
#define XILINX_LOCK_KEY 0x767b
|
||||
#define XILINX_UNLOCK_KEY 0xdf0d
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#define DB_PRINT(...) do { \
|
||||
fprintf(stderr, ": %s: ", __func__); \
|
||||
fprintf(stderr, ## __VA_ARGS__); \
|
||||
} while (0);
|
||||
} while (0)
|
||||
#else
|
||||
#define DB_PRINT(...)
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@
|
||||
if (MSS_SPI_ERR_DEBUG >= lvl) { \
|
||||
qemu_log("%s: " fmt "\n", __func__, ## args); \
|
||||
} \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
#define DB_PRINT(fmt, args...) DB_PRINT_L(1, fmt, ## args)
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
if (STM_SPI_ERR_DEBUG >= lvl) { \
|
||||
qemu_log("%s: " fmt, __func__, ## args); \
|
||||
} \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
#define DB_PRINT(fmt, args...) DB_PRINT_L(1, fmt, ## args)
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user