[Qemu-devel] [PATCH v2] puv3: always compile-check debug printf

Anishka0107 posted 1 patch 7 years, 1 month ago
Failed in applying to current master (apply log)
include/hw/unicore32/puv3.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[Qemu-devel] [PATCH v2] puv3: always compile-check debug printf
Posted by Anishka0107 7 years, 1 month ago
     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 | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/hw/unicore32/puv3.h b/include/hw/unicore32/puv3.h
index e268484..9fdf0a1 100644
--- a/include/hw/unicore32/puv3.h
+++ b/include/hw/unicore32/puv3.h
@@ -46,8 +46,7 @@
 #define DPRINTF(fmt, ...)
     if (DEBUG_PUV3) {
         fprintf(stderr, "%s: " fmt , __func__, ## __VA_ARGS__)
-    }
-    else {
+    } else {
         do {} while (0)
     }
 
-- 
2.5.0


Re: [Qemu-devel] [PATCH v2] puv3: always compile-check debug printf
Posted by Stefan Hajnoczi 7 years, 1 month ago
On Thu, Mar 16, 2017 at 11:11:33AM +0530, Anishka0107 wrote:
>      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 | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/include/hw/unicore32/puv3.h b/include/hw/unicore32/puv3.h
> index e268484..9fdf0a1 100644
> --- a/include/hw/unicore32/puv3.h
> +++ b/include/hw/unicore32/puv3.h
> @@ -46,8 +46,7 @@
>  #define DPRINTF(fmt, ...)
>      if (DEBUG_PUV3) {
>          fprintf(stderr, "%s: " fmt , __func__, ## __VA_ARGS__)
> -    }
> -    else {
> +    } else {

Hi Anishka,
I think something went wrong with this patch submission.  The patch
seems to fix coding style but the surrounding code is not in qemu.git.
Please send another revision with your full code changes.

I also notice that the macro in the surrounding code will not work: you
need to use backslash ('\') so the preprocessor joins lines:

#define foo(x) \
    do { \
        printf("foo %d\n", x); \
    } while (0)

If you forget the backslashes there will be compilation errors.

Stefan