qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] fdc: always compile-check debug prints
@ 2016-02-08 22:45 John Snow
  2016-02-08 23:11 ` Eric Blake
  0 siblings, 1 reply; 3+ messages in thread
From: John Snow @ 2016-02-08 22:45 UTC (permalink / raw)
  To: qemu-block; +Cc: John Snow, qemu-devel

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.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 hw/block/fdc.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index a6f22ef..9838d21 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -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]);
-- 
2.4.3

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] fdc: always compile-check debug prints
  2016-02-08 22:45 [Qemu-devel] [PATCH] fdc: always compile-check debug prints John Snow
@ 2016-02-08 23:11 ` Eric Blake
  2016-02-08 23:16   ` John Snow
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Blake @ 2016-02-08 23:11 UTC (permalink / raw)
  To: John Snow, qemu-block; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1102 bytes --]

On 02/08/2016 03:45 PM, John Snow wrote:
> 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.

> 
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>  hw/block/fdc.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 

>  #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__);   \

The switch from stdout to stderr doesn't hurt, either, if you want to
mention it in the commit as intentional.

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] fdc: always compile-check debug prints
  2016-02-08 23:11 ` Eric Blake
@ 2016-02-08 23:16   ` John Snow
  0 siblings, 0 replies; 3+ messages in thread
From: John Snow @ 2016-02-08 23:16 UTC (permalink / raw)
  To: Eric Blake, qemu-block; +Cc: qemu-devel



On 02/08/2016 06:11 PM, Eric Blake wrote:
> On 02/08/2016 03:45 PM, John Snow wrote:
>> 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.

>>
>> Signed-off-by: John Snow <jsnow@redhat.com>
>> ---
>>  hw/block/fdc.c | 15 ++++++++-------
>>  1 file changed, 8 insertions(+), 7 deletions(-)
>>
> 
>>  #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__);   \
> 
> The switch from stdout to stderr doesn't hurt, either, if you want to
> mention it in the commit as intentional.
> 

Sure 2x combo

> Reviewed-by: Eric Blake <eblake@redhat.com>
> 

Thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-02-08 23:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-08 22:45 [Qemu-devel] [PATCH] fdc: always compile-check debug prints John Snow
2016-02-08 23:11 ` Eric Blake
2016-02-08 23:16   ` John Snow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).