From: Anishka0107 <rimjhim0107@gmail.com>
To: jsnow@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org
Cc: Anishka0107 <rimjhim0107@gmail.com>
Subject: [Qemu-devel] [PATCH] puv3: always compile-check debug printf
Date: Thu, 16 Mar 2017 10:00:21 +0530 [thread overview]
Message-ID: <1489638621-31978-1-git-send-email-rimjhim0107@gmail.com> (raw)
To prevent bitrot of the format string of the debug statement, files with
conditional debug statements should ensure that printf is compiled always,
and enclosed within if(0) statements and not in #ifdef.
Signed-off-by: Anishka Gupta <rimjhim0107@gmail.com>
---
include/hw/unicore32/puv3.h | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/include/hw/unicore32/puv3.h b/include/hw/unicore32/puv3.h
index 5a4839f..e268484 100644
--- a/include/hw/unicore32/puv3.h
+++ b/include/hw/unicore32/puv3.h
@@ -41,10 +41,14 @@
#define PUV3_IRQS_OST0 (26)
/* All puv3_*.c use DPRINTF for debug. */
-#ifdef DEBUG_PUV3
-#define DPRINTF(fmt, ...) printf("%s: " fmt , __func__, ## __VA_ARGS__)
-#else
-#define DPRINTF(fmt, ...) do {} while (0)
-#endif
+#define DEBUG_PUV3 0
+
+#define DPRINTF(fmt, ...)
+ if (DEBUG_PUV3) {
+ fprintf(stderr, "%s: " fmt , __func__, ## __VA_ARGS__)
+ }
+ else {
+ do {} while (0)
+ }
#endif /* QEMU_HW_PUV3_H */
--
2.5.0
next reply other threads:[~2017-03-16 10:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-16 4:30 Anishka0107 [this message]
2017-03-16 10:37 ` [Qemu-devel] [PATCH] puv3: always compile-check debug printf no-reply
2017-03-16 12:04 ` Alex Bennée
2017-03-16 16:25 ` Wei Huang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1489638621-31978-1-git-send-email-rimjhim0107@gmail.com \
--to=rimjhim0107@gmail.com \
--cc=jsnow@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).