qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Miao Yan <yanmiaobest@gmail.com>,
	dmitry@daynix.com, qemu-devel@nongnu.org, eblake@redhat.com,
	armbru@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 2/3] net/vmxnet3: fix debug macro pattern for vmxnet3
Date: Mon, 7 Dec 2015 10:47:46 +0800	[thread overview]
Message-ID: <5664F352.3010305@redhat.com> (raw)
In-Reply-To: <1449305702-2122-3-git-send-email-yanmiaobest@gmail.com>



On 12/05/2015 04:55 PM, Miao Yan wrote:
> Vmxnet3 uses the following debug macro style:
>
>  #ifdef SOME_DEBUG
>  #  define debug(...) do{ printf(...); } while (0)
>  # else
>  #  define debug(...) do{ } while (0)
>  #endif
>
> If SOME_DEBUG is undefined, then format string inside the
> debug macro will never be checked by compiler. Code is
> likely to break in the future when SOME_DEBUG is enabled
>  because of lack of testing. This patch changes this
> to the following:
>
>  #define debug(...) \
>   do { if (SOME_DEBUG_ENABLED) printf(...); } while (0)
>
> Signed-off-by: Miao Yan <yanmiaobest@gmail.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> ---
> Changes in v2:
>   - Fix grammar error in commit log

Applied in my -net for 2.5. Thanks

>
>  hw/net/vmxnet_debug.h | 139 +++++++++++++++++++++++++++++++-------------------
>  1 file changed, 86 insertions(+), 53 deletions(-)
>
> diff --git a/hw/net/vmxnet_debug.h b/hw/net/vmxnet_debug.h
> index 96dae0f..96495db 100644
> --- a/hw/net/vmxnet_debug.h
> +++ b/hw/net/vmxnet_debug.h
> @@ -20,94 +20,127 @@
>  
>  #define VMXNET_DEVICE_NAME "vmxnet3"
>  
> -/* #define VMXNET_DEBUG_CB */
>  #define VMXNET_DEBUG_WARNINGS
>  #define VMXNET_DEBUG_ERRORS
> -/* #define VMXNET_DEBUG_INTERRUPTS */
> -/* #define VMXNET_DEBUG_CONFIG */
> -/* #define VMXNET_DEBUG_RINGS */
> -/* #define VMXNET_DEBUG_PACKETS */
> -/* #define VMXNET_DEBUG_SHMEM_ACCESS */
> +
> +#undef VMXNET_DEBUG_CB
> +#undef VMXNET_DEBUG_INTERRUPTS
> +#undef VMXNET_DEBUG_CONFIG
> +#undef VMXNET_DEBUG_RINGS
> +#undef VMXNET_DEBUG_PACKETS
> +#undef VMXNET_DEBUG_SHMEM_ACCESS
> +
> +#ifdef VMXNET_DEBUG_CB
> +#  define VMXNET_DEBUG_CB_ENABLED 1
> +#else
> +#  define VMXNET_DEBUG_CB_ENABLED 0
> +#endif
> +
> +#ifdef VMXNET_DEBUG_WARNINGS
> +#  define VMXNET_DEBUG_WARNINGS_ENABLED 1
> +#else
> +#  define VMXNET_DEBUG_WARNINGS_ENABLED 0
> +#endif
> +
> +#ifdef VMXNET_DEBUG_ERRORS
> +#  define VMXNET_DEBUG_ERRORS_ENABLED 1
> +#else
> +#  define VMXNET_DEBUG_ERRORS_ENABLED 0
> +#endif
> +
> +#ifdef VMXNET_DEBUG_CONFIG
> +#  define VMXNET_DEBUG_CONFIG_ENABLED 1
> +#else
> +#  define VMXNET_DEBUG_CONFIG_ENABLED 0
> +#endif
> +
> +#ifdef VMXNET_DEBUG_RINGS
> +#  define VMXNET_DEBUG_RINGS_ENABLED 1
> +#else
> +#  define VMXNET_DEBUG_RINGS_ENABLED 0
> +#endif
> +
> +#ifdef VMXNET_DEBUG_PACKETS
> +#  define VMXNET_DEBUG_PACKETS_ENABLED 1
> +#else
> +#  define VMXNET_DEBUG_PACKETS_ENABLED 0
> +#endif
> +
> +#ifdef VMXNET_DEBUG_INTERRUPTS
> +#  define VMXNET_DEBUG_INTERRUPTS_ENABLED 1
> +#else
> +#  define VMXNET_DEBUG_INTERRUPTS_ENABLED 0
> +#endif
>  
>  #ifdef VMXNET_DEBUG_SHMEM_ACCESS
> +#  define VMXNET_DEBUG_SHMEM_ACCESS_ENABLED 1
> +#else
> +#  define VMXNET_DEBUG_SHMEM_ACCESS_ENABLED 0
> +#endif
> +
>  #define VMW_SHPRN(fmt, ...)                                                   \
>      do {                                                                      \
> -        printf("[%s][SH][%s]: " fmt "\n", VMXNET_DEVICE_NAME, __func__,       \
> -            ## __VA_ARGS__);                                                  \
> +        if (VMXNET_DEBUG_SHMEM_ACCESS_ENABLED) {                              \
> +            printf("[%s][SH][%s]: " fmt "\n", VMXNET_DEVICE_NAME, __func__,   \
> +                ## __VA_ARGS__);                                              \
> +       }                                                                      \
>      } while (0)
> -#else
> -#define VMW_SHPRN(fmt, ...) do {} while (0)
> -#endif
>  
> -#ifdef VMXNET_DEBUG_CB
>  #define VMW_CBPRN(fmt, ...)                                                   \
>      do {                                                                      \
> -        printf("[%s][CB][%s]: " fmt "\n", VMXNET_DEVICE_NAME, __func__,       \
> -            ## __VA_ARGS__);                                                  \
> +        if (VMXNET_DEBUG_CB_ENABLED) {                                        \
> +            printf("[%s][CB][%s]: " fmt "\n", VMXNET_DEVICE_NAME, __func__,   \
> +                ## __VA_ARGS__);                                              \
> +        }                                                                     \
>      } while (0)
> -#else
> -#define VMW_CBPRN(fmt, ...) do {} while (0)
> -#endif
>  
> -#ifdef VMXNET_DEBUG_PACKETS
>  #define VMW_PKPRN(fmt, ...)                                                   \
>      do {                                                                      \
> -        printf("[%s][PK][%s]: " fmt "\n", VMXNET_DEVICE_NAME, __func__,       \
> -            ## __VA_ARGS__);                                                  \
> +        if (VMXNET_DEBUG_PACKETS_ENABLED) {                                   \
> +            printf("[%s][PK][%s]: " fmt "\n", VMXNET_DEVICE_NAME, __func__,   \
> +                ## __VA_ARGS__);                                              \
> +        }                                                                     \
>      } while (0)
> -#else
> -#define VMW_PKPRN(fmt, ...) do {} while (0)
> -#endif
>  
> -#ifdef VMXNET_DEBUG_WARNINGS
>  #define VMW_WRPRN(fmt, ...)                                                   \
>      do {                                                                      \
> -        printf("[%s][WR][%s]: " fmt "\n", VMXNET_DEVICE_NAME, __func__,       \
> -            ## __VA_ARGS__);                                                  \
> +        if (VMXNET_DEBUG_WARNINGS_ENABLED) {                                  \
> +            printf("[%s][WR][%s]: " fmt "\n", VMXNET_DEVICE_NAME, __func__,   \
> +                ## __VA_ARGS__);                                              \
> +        }                                                                     \
>      } while (0)
> -#else
> -#define VMW_WRPRN(fmt, ...) do {} while (0)
> -#endif
>  
> -#ifdef VMXNET_DEBUG_ERRORS
>  #define VMW_ERPRN(fmt, ...)                                                   \
>      do {                                                                      \
> -        printf("[%s][ER][%s]: " fmt "\n", VMXNET_DEVICE_NAME, __func__,       \
> -            ## __VA_ARGS__);                                                  \
> +        if (VMXNET_DEBUG_ERRORS_ENABLED) {                                    \
> +            printf("[%s][ER][%s]: " fmt "\n", VMXNET_DEVICE_NAME, __func__,   \
> +                ## __VA_ARGS__);                                              \
> +        }                                                                     \
>      } while (0)
> -#else
> -#define VMW_ERPRN(fmt, ...) do {} while (0)
> -#endif
>  
> -#ifdef VMXNET_DEBUG_INTERRUPTS
>  #define VMW_IRPRN(fmt, ...)                                                   \
>      do {                                                                      \
> -        printf("[%s][IR][%s]: " fmt "\n", VMXNET_DEVICE_NAME, __func__,       \
> -            ## __VA_ARGS__);                                                  \
> +        if (VMXNET_DEBUG_INTERRUPTS_ENABLED) {                                \
> +            printf("[%s][IR][%s]: " fmt "\n", VMXNET_DEVICE_NAME, __func__,   \
> +                ## __VA_ARGS__);                                              \
> +        }                                                                     \
>      } while (0)
> -#else
> -#define VMW_IRPRN(fmt, ...) do {} while (0)
> -#endif
>  
> -#ifdef VMXNET_DEBUG_CONFIG
>  #define VMW_CFPRN(fmt, ...)                                                   \
>      do {                                                                      \
> -        printf("[%s][CF][%s]: " fmt "\n", VMXNET_DEVICE_NAME, __func__,       \
> -            ## __VA_ARGS__);                                                  \
> +        if (VMXNET_DEBUG_CONFIG_ENABLED) {                                    \
> +            printf("[%s][CF][%s]: " fmt "\n", VMXNET_DEVICE_NAME, __func__,   \
> +                ## __VA_ARGS__);                                              \
> +        }                                                                     \
>      } while (0)
> -#else
> -#define VMW_CFPRN(fmt, ...) do {} while (0)
> -#endif
>  
> -#ifdef VMXNET_DEBUG_RINGS
>  #define VMW_RIPRN(fmt, ...)                                                   \
>      do {                                                                      \
> -        printf("[%s][RI][%s]: " fmt "\n", VMXNET_DEVICE_NAME, __func__,       \
> -            ## __VA_ARGS__);                                                  \
> +        if (VMXNET_DEBUG_RINGS_ENABLED) {                                     \
> +            printf("[%s][RI][%s]: " fmt "\n", VMXNET_DEVICE_NAME, __func__,   \
> +                ## __VA_ARGS__);                                              \
> +        }                                                                     \
>      } while (0)
> -#else
> -#define VMW_RIPRN(fmt, ...) do {} while (0)
> -#endif
>  
>  #define VMXNET_MF       "%02X:%02X:%02X:%02X:%02X:%02X"
>  #define VMXNET_MA(a)    (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]

  reply	other threads:[~2015-12-07  2:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-05  8:54 [Qemu-devel] [PATCH v2 0/3] fix debug macro pattern for vmxnet3 Miao Yan
2015-12-05  8:55 ` [Qemu-devel] [PATCH v2 1/3] net/vmxnet3.c: fix a build error when enabling debug output Miao Yan
2015-12-05 16:32   ` Eric Blake
2015-12-05  8:55 ` [Qemu-devel] [PATCH v2 2/3] net/vmxnet3: fix debug macro pattern for vmxnet3 Miao Yan
2015-12-07  2:47   ` Jason Wang [this message]
2015-12-07 22:04     ` Eric Blake
2015-12-08  2:53       ` Miao Yan
2015-12-11  3:12       ` Jason Wang
2015-12-05  8:55 ` [Qemu-devel] [PATCH v2 3/3] net/vmxnet3: remove redundant VMW_SHPRN(...) definition Miao Yan

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=5664F352.3010305@redhat.com \
    --to=jasowang@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dmitry@daynix.com \
    --cc=eblake@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yanmiaobest@gmail.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).