fdc: always compile-check debug prints
PATCH 1/1 fdc: always compile-check debug prints
Coverity noticed that some variables are only used by debug prints, and called them unused. Always compile the print statements.
Bonus: Fix a printf I broke.
--- hw/block/fdc.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
hw/block/fdc.c +8 -7
@@ -41,14 +41,15 @@/********************************************************/ /* debug Floppy devices */ -//#define DEBUG_FLOPPY -#ifdef DEBUG_FLOPPY +#define DEBUG_FLOPPY 0 +#define FLOPPY_DPRINTF (fmt, ...) \ - do { printf("FLOPPY: " fmt , ## __VA_ARGS__); } while (0) -#else -#define FLOPPY_DPRINTF (fmt, ...) -#endif + do { \ + if (DEBUG_FLOPPY) { \ + fprintf(stderr, "FLOPPY: " fmt , ## __VA_ARGS__); \ + } \ + } while (0)/********************************************************/ /* Floppy drive emulation */
@@ -353,7 +354,7 @@ static int pick_geometry(FDrive *drv) parse = &fd_formats[size_match];FLOPPY_DPRINTF ("User requested floppy drive type '%s', " "but inserted medium appears to be a " -"%d sector '%s' type\n" , +"%" PRId64" sector '%s' type\n" , FloppyDriveType_lookup[drv->drive], nb_sectors, FloppyDriveType_lookup[parse->drive]);
Signature · 1 line
2.4.3
Quoted 4 lines · John Snow
Coverity noticed that some variables are only used by debug prints, and called them unused. Always compile the print statements.
Bonus: Fix a printf I broke.
Might be nice to mention the commit that broke it.
Quoted 8 lines
Signed-off-by John Snow <[email protected]>--- hw/block/fdc.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)#define
FLOPPY_DPRINTF(fmt, ...)\
hw/block/fdc.c line 50
Quoted 7 lines
hw/block/fdc.c +3
-4- do { printf("FLOPPY: " fmt , ## __VA_ARGS__); } while (0) -#else -#define FLOPPY_DPRINTF (fmt, ...) -#endif + do { \ + if (DEBUG_FLOPPY) { \ + fprintf(stderr, "FLOPPY: " fmt , ## __VA_ARGS__); \
The switch from stdout to stderr doesn't hurt, either, if you want to mention it in the commit as intentional.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 8 lines · Eric Blake
Quoted 4 lines · John Snow
Coverity noticed that some variables are only used by debug prints, and called them unused. Always compile the print statements.
Bonus: Fix a printf I broke.
Might be nice to mention the commit that broke it.
Sure.
Quoted 7 lines
Quoted 6 lines
Signed-off-by John Snow <[email protected]>--- hw/block/fdc.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
Quoted 12 lines
hw/block/fdc.c line 50
Quoted 8 lines
#define
FLOPPY_DPRINTF(fmt, ...)\hw/block/fdc.c +3
-4- do { printf("FLOPPY: " fmt , ## __VA_ARGS__); } while (0) -#else -#define FLOPPY_DPRINTF (fmt, ...) -#endif + do { \ + if (DEBUG_FLOPPY) { \ + fprintf(stderr, "FLOPPY: " fmt , ## __VA_ARGS__); \The switch from stdout to stderr doesn't hurt, either, if you want to mention it in the commit as intentional.
Sure 2x combo
Quoted 2 lines
Reviewed-by Eric Blake <[email protected]>
Thanks!