diff mbox

[v2,04/16] highbank: Convert conditional compilation of debug printfs to regular ifs

Message ID 1399964572-5376-5-git-send-email-marc.mari.barcelo@gmail.com
State New
Headers show

Commit Message

Marc Marí May 13, 2014, 7:02 a.m. UTC
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.

As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.

Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
---
 hw/net/xgmac.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Marc Marí May 13, 2014, 10:06 a.m. UTC | #1
El Tue, 13 May 2014 09:02:40 +0200
Marc Marí <marc.mari.barcelo@gmail.com> escribió:
> Modify debug macros to have the same format through the codebase and
> use regular ifs instead of ifdef.
> 
> As the debug printf is always put in code, some casting had to be
> added to avoid warnings treated as errors at compile time.
> 
> Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
> ---
>  hw/net/xgmac.c |   10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/net/xgmac.c b/hw/net/xgmac.c
> index 88349ac..734c2e5 100644
> --- a/hw/net/xgmac.c
> +++ b/hw/net/xgmac.c
> @@ -30,14 +30,16 @@
>  #include "net/net.h"
>  #include "net/checksum.h"
>  
> +//#define DEBUG_XGMAC
> +
>  #ifdef DEBUG_XGMAC
> -#define DEBUGF_BRK(message, args...) do { \
> -                                         fprintf(stderr, (message),
> ## args); \
> -                                     } while (0)
> +#define DEBUG_XGMAC_ENABLED 1
>  #else
> -#define DEBUGF_BRK(message, args...) do { } while (0)
> +#define DEBUG_XGMAC_ENABLED 0
>  #endif
>  
> +#define DEBUGF_BRK(message, args...)
> QEMU_DPRINTF(DEBUG_XGMAC_ENABLED, "xgmag", message, ## args) +
>  #define XGMAC_CONTROL           0x00000000   /* MAC Configuration */
>  #define XGMAC_FRAME_FILTER      0x00000001   /* MAC Frame Filter */
>  #define XGMAC_FLOW_CTRL         0x00000006   /* MAC Flow Control */

In this file, the function name is already written when the macros are
called, so now it will appear two times. The calls to the macro can be
changed to not add the function name, which, in my opinion, is a bit
nicer.

Marc
diff mbox

Patch

diff --git a/hw/net/xgmac.c b/hw/net/xgmac.c
index 88349ac..734c2e5 100644
--- a/hw/net/xgmac.c
+++ b/hw/net/xgmac.c
@@ -30,14 +30,16 @@ 
 #include "net/net.h"
 #include "net/checksum.h"
 
+//#define DEBUG_XGMAC
+
 #ifdef DEBUG_XGMAC
-#define DEBUGF_BRK(message, args...) do { \
-                                         fprintf(stderr, (message), ## args); \
-                                     } while (0)
+#define DEBUG_XGMAC_ENABLED 1
 #else
-#define DEBUGF_BRK(message, args...) do { } while (0)
+#define DEBUG_XGMAC_ENABLED 0
 #endif
 
+#define DEBUGF_BRK(message, args...) QEMU_DPRINTF(DEBUG_XGMAC_ENABLED, "xgmag", message, ## args)
+
 #define XGMAC_CONTROL           0x00000000   /* MAC Configuration */
 #define XGMAC_FRAME_FILTER      0x00000001   /* MAC Frame Filter */
 #define XGMAC_FLOW_CTRL         0x00000006   /* MAC Flow Control */