* [Qemu-devel] [PATCH v3 0/4] fix debug macro pattern for vmxnet3
@ 2015-12-08 5:28 Miao Yan
2015-12-08 5:28 ` [Qemu-devel] [PATCH v3 1/4] net/vmxnet3: fix a build error when enabling debug output Miao Yan
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Miao Yan @ 2015-12-08 5:28 UTC (permalink / raw)
To: jasowang, dmitry, qemu-devel, eblake
This patchset fixes debug macro pattern for vmxnet3. The old style uses
#ifdef...#else...#endif to define debug macros, as a result
the format string inside the macro will never be checked
(debug not turned on by default) and is likely to cause build
errors in the future when enabled.
Changes in v3:
- fix a build error on 32 bit platforms
Changes in v2:
- fix grammar errors in commit log
Miao Yan (4):
net/vmxnet3: fix a build error when enabling debug output
net/vmxnet3: use %zu for size_t in printf
net/vmxnet3: fix debug macro pattern for vmxnet3
net/vmxnet3: remove redundant VMW_SHPRN(...) definition
hw/net/vmware_utils.h | 5 +-
hw/net/vmxnet3.c | 8 +--
hw/net/vmxnet_debug.h | 139 +++++++++++++++++++++++++++++++-------------------
3 files changed, 91 insertions(+), 61 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v3 1/4] net/vmxnet3: fix a build error when enabling debug output
2015-12-08 5:28 [Qemu-devel] [PATCH v3 0/4] fix debug macro pattern for vmxnet3 Miao Yan
@ 2015-12-08 5:28 ` Miao Yan
2015-12-08 5:28 ` [Qemu-devel] [PATCH v3 2/4] net/vmxnet3: use %zu for size_t in printf Miao Yan
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Miao Yan @ 2015-12-08 5:28 UTC (permalink / raw)
To: jasowang, dmitry, qemu-devel, eblake
Macro MAC_FMT and MAC_ARG are not defined, but used in vmxnet3_net_init().
This will cause build error when debug level is raised in
vmxnet3_debug.h (enable all VMXNET3_DEBUG_xxx).
Use VMXNET_MF and VXMNET_MA instead.
Signed-off-by: Miao Yan <yanmiaobest@gmail.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
Changes in v3:
- add Reviewed-by tag
- align subject line with others
hw/net/vmxnet3.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index 5e3a233..ea3d9b7 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -2044,7 +2044,7 @@ static void vmxnet3_net_init(VMXNET3State *s)
s->link_status_and_speed = VMXNET3_LINK_SPEED | VMXNET3_LINK_STATUS_UP;
- VMW_CFPRN("Permanent MAC: " MAC_FMT, MAC_ARG(s->perm_mac.a));
+ VMW_CFPRN("Permanent MAC: " VMXNET_MF, VMXNET_MA(s->perm_mac.a));
s->nic = qemu_new_nic(&net_vmxnet3_info, &s->conf,
object_get_typename(OBJECT(s)),
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v3 2/4] net/vmxnet3: use %zu for size_t in printf
2015-12-08 5:28 [Qemu-devel] [PATCH v3 0/4] fix debug macro pattern for vmxnet3 Miao Yan
2015-12-08 5:28 ` [Qemu-devel] [PATCH v3 1/4] net/vmxnet3: fix a build error when enabling debug output Miao Yan
@ 2015-12-08 5:28 ` Miao Yan
2015-12-08 5:28 ` [Qemu-devel] [PATCH v3 3/4] net/vmxnet3: fix debug macro pattern for vmxnet3 Miao Yan
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Miao Yan @ 2015-12-08 5:28 UTC (permalink / raw)
To: jasowang, dmitry, qemu-devel, eblake
Use %zu specifier for size_t in printf, otherwise build would fail
on platforms where size_t is not unsigned long
Signed-off-by: Miao Yan <yanmiaobest@gmail.com>
---
hw/net/vmxnet3.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index ea3d9b7..e168285 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -138,7 +138,7 @@ static inline void vmxnet3_ring_init(Vmxnet3Ring *ring,
}
#define VMXNET3_RING_DUMP(macro, ring_name, ridx, r) \
- macro("%s#%d: base %" PRIx64 " size %lu cell_size %lu gen %d next %lu", \
+ macro("%s#%d: base %" PRIx64 " size %zu cell_size %zu gen %d next %zu", \
(ring_name), (ridx), \
(r)->pa, (r)->size, (r)->cell_size, (r)->gen, (r)->next)
@@ -925,7 +925,7 @@ static void vmxnet3_rx_need_csum_calculate(struct VmxnetRxPkt *pkt,
/* Validate packet len: csum_start + scum_offset + length of csum field */
if (pkt_len < (vhdr->csum_start + vhdr->csum_offset + 2)) {
- VMW_PKPRN("packet len:%lu < csum_start(%d) + csum_offset(%d) + 2, "
+ VMW_PKPRN("packet len:%zu < csum_start(%d) + csum_offset(%d) + 2, "
"cannot calculate checksum",
pkt_len, vhdr->csum_start, vhdr->csum_offset);
return;
@@ -1974,7 +1974,7 @@ vmxnet3_receive(NetClientState *nc, const uint8_t *buf, size_t size)
vmxnet_rx_pkt_attach_data(s->rx_pkt, buf, size, s->rx_vlan_stripping);
bytes_indicated = vmxnet3_indicate_packet(s) ? size : -1;
if (bytes_indicated < size) {
- VMW_PKPRN("RX: %lu of %lu bytes indicated", bytes_indicated, size);
+ VMW_PKPRN("RX: %zu of %zu bytes indicated", bytes_indicated, size);
}
} else {
VMW_PKPRN("Packet dropped by RX filter");
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v3 3/4] net/vmxnet3: fix debug macro pattern for vmxnet3
2015-12-08 5:28 [Qemu-devel] [PATCH v3 0/4] fix debug macro pattern for vmxnet3 Miao Yan
2015-12-08 5:28 ` [Qemu-devel] [PATCH v3 1/4] net/vmxnet3: fix a build error when enabling debug output Miao Yan
2015-12-08 5:28 ` [Qemu-devel] [PATCH v3 2/4] net/vmxnet3: use %zu for size_t in printf Miao Yan
@ 2015-12-08 5:28 ` Miao Yan
2015-12-08 5:28 ` [Qemu-devel] [PATCH v3 4/4] net/vmxnet3: remove redundant VMW_SHPRN(...) definition Miao Yan
2015-12-08 6:29 ` [Qemu-devel] [PATCH v3 0/4] fix debug macro pattern for vmxnet3 Dmitry Fleytman
4 siblings, 0 replies; 7+ messages in thread
From: Miao Yan @ 2015-12-08 5:28 UTC (permalink / raw)
To: jasowang, dmitry, qemu-devel, eblake
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>
---
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]
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v3 4/4] net/vmxnet3: remove redundant VMW_SHPRN(...) definition
2015-12-08 5:28 [Qemu-devel] [PATCH v3 0/4] fix debug macro pattern for vmxnet3 Miao Yan
` (2 preceding siblings ...)
2015-12-08 5:28 ` [Qemu-devel] [PATCH v3 3/4] net/vmxnet3: fix debug macro pattern for vmxnet3 Miao Yan
@ 2015-12-08 5:28 ` Miao Yan
2015-12-08 6:29 ` [Qemu-devel] [PATCH v3 0/4] fix debug macro pattern for vmxnet3 Dmitry Fleytman
4 siblings, 0 replies; 7+ messages in thread
From: Miao Yan @ 2015-12-08 5:28 UTC (permalink / raw)
To: jasowang, dmitry, qemu-devel, eblake
Macro VMW_SHPRN(...) is already defined vmxnet3_debug.h,
so remove the duplication
Signed-off-by: Miao Yan <yanmiaobest@gmail.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
hw/net/vmware_utils.h | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/hw/net/vmware_utils.h b/hw/net/vmware_utils.h
index 1099df6..c2c2f90 100644
--- a/hw/net/vmware_utils.h
+++ b/hw/net/vmware_utils.h
@@ -18,10 +18,7 @@
#define VMWARE_UTILS_H
#include "qemu/range.h"
-
-#ifndef VMW_SHPRN
-#define VMW_SHPRN(fmt, ...) do {} while (0)
-#endif
+#include "vmxnet_debug.h"
/*
* Shared memory access functions with byte swap support
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v3 0/4] fix debug macro pattern for vmxnet3
2015-12-08 5:28 [Qemu-devel] [PATCH v3 0/4] fix debug macro pattern for vmxnet3 Miao Yan
` (3 preceding siblings ...)
2015-12-08 5:28 ` [Qemu-devel] [PATCH v3 4/4] net/vmxnet3: remove redundant VMW_SHPRN(...) definition Miao Yan
@ 2015-12-08 6:29 ` Dmitry Fleytman
2015-12-14 5:49 ` Jason Wang
4 siblings, 1 reply; 7+ messages in thread
From: Dmitry Fleytman @ 2015-12-08 6:29 UTC (permalink / raw)
To: Miao Yan; +Cc: jasowang, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1059 bytes --]
Reviewed-by: Dmitry Fleytman <dmitry@daynix.com <mailto:dmitry@daynix.com>>
> On 8 Dec 2015, at 07:28 AM, Miao Yan <yanmiaobest@gmail.com> wrote:
>
> This patchset fixes debug macro pattern for vmxnet3. The old style uses
> #ifdef...#else...#endif to define debug macros, as a result
> the format string inside the macro will never be checked
> (debug not turned on by default) and is likely to cause build
> errors in the future when enabled.
>
> Changes in v3:
> - fix a build error on 32 bit platforms
>
> Changes in v2:
> - fix grammar errors in commit log
>
> Miao Yan (4):
> net/vmxnet3: fix a build error when enabling debug output
> net/vmxnet3: use %zu for size_t in printf
> net/vmxnet3: fix debug macro pattern for vmxnet3
> net/vmxnet3: remove redundant VMW_SHPRN(...) definition
>
> hw/net/vmware_utils.h | 5 +-
> hw/net/vmxnet3.c | 8 +--
> hw/net/vmxnet_debug.h | 139 +++++++++++++++++++++++++++++++-------------------
> 3 files changed, 91 insertions(+), 61 deletions(-)
>
> --
> 1.9.1
>
[-- Attachment #2: Type: text/html, Size: 2368 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v3 0/4] fix debug macro pattern for vmxnet3
2015-12-08 6:29 ` [Qemu-devel] [PATCH v3 0/4] fix debug macro pattern for vmxnet3 Dmitry Fleytman
@ 2015-12-14 5:49 ` Jason Wang
0 siblings, 0 replies; 7+ messages in thread
From: Jason Wang @ 2015-12-14 5:49 UTC (permalink / raw)
To: Dmitry Fleytman, Miao Yan; +Cc: qemu-devel
On 12/08/2015 02:29 PM, Dmitry Fleytman wrote:
>
> Reviewed-by: Dmitry Fleytman <dmitry@daynix.com
> <mailto:dmitry@daynix.com>>
>
>> On 8 Dec 2015, at 07:28 AM, Miao Yan <yanmiaobest@gmail.com
>> <mailto:yanmiaobest@gmail.com>> wrote:
>>
>> This patchset fixes debug macro pattern for vmxnet3. The old style uses
>> #ifdef...#else...#endif to define debug macros, as a result
>> the format string inside the macro will never be checked
>> (debug not turned on by default) and is likely to cause build
>> errors in the future when enabled.
>>
>> Changes in v3:
>> - fix a build error on 32 bit platforms
>>
>> Changes in v2:
>> - fix grammar errors in commit log
>>
>> Miao Yan (4):
>> net/vmxnet3: fix a build error when enabling debug output
>> net/vmxnet3: use %zu for size_t in printf
>> net/vmxnet3: fix debug macro pattern for vmxnet3
>> net/vmxnet3: remove redundant VMW_SHPRN(...) definition
>>
>> hw/net/vmware_utils.h | 5 +-
>> hw/net/vmxnet3.c | 8 +--
>> hw/net/vmxnet_debug.h | 139
>> +++++++++++++++++++++++++++++++-------------------
>> 3 files changed, 91 insertions(+), 61 deletions(-)
>>
>> --
>> 1.9.1
>>
>
Queued for 2.6.
Thanks
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-12-14 5:49 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-08 5:28 [Qemu-devel] [PATCH v3 0/4] fix debug macro pattern for vmxnet3 Miao Yan
2015-12-08 5:28 ` [Qemu-devel] [PATCH v3 1/4] net/vmxnet3: fix a build error when enabling debug output Miao Yan
2015-12-08 5:28 ` [Qemu-devel] [PATCH v3 2/4] net/vmxnet3: use %zu for size_t in printf Miao Yan
2015-12-08 5:28 ` [Qemu-devel] [PATCH v3 3/4] net/vmxnet3: fix debug macro pattern for vmxnet3 Miao Yan
2015-12-08 5:28 ` [Qemu-devel] [PATCH v3 4/4] net/vmxnet3: remove redundant VMW_SHPRN(...) definition Miao Yan
2015-12-08 6:29 ` [Qemu-devel] [PATCH v3 0/4] fix debug macro pattern for vmxnet3 Dmitry Fleytman
2015-12-14 5:49 ` Jason Wang
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).