Skip to contentSkip to conversation

virtio-net config_size cleanups

PATCH In review Jesse Larrew 2 participants 4 messages Feb 7, 2013 – Feb 8, 2013

lore
Share & tools
lore
#0 lore raw

cover virtio-net config_size cleanups

This patch set includes some minor cleanups requested by the community for the virtio-net config size solution.

[PATCH 1/2] hw/virtio-net: use existing macros to implement endof [PATCH 2/2] hw/virtio-net: fix config_size data type

#1 lore raw

PATCH 1/2 hw/virtio-net: use existing macros to implement endof

Clarify the definition of endof() by using the offsetof() and sizeof() macros to handle the pointer magic.

---
 hw/virtio-net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio-net.c +1 -1
index 8f521b3..663f33c 100644
@@ -81,7 +81,7 @@ typedef struct VirtIONet
  * 'container'.
  */
 #define endof(container, field) \
-    ((intptr_t)(&(((container *)0)->field)+1))
+    (offsetof(container, field) + sizeof(((container *)0)->field))
 
 typedef struct VirtIOFeature {
     uint32_t flags;
Signature · 1 line
1.7.11.7
#2 lore raw

PATCH 2/2 hw/virtio-net: fix config_size data type

In reply to Jesse Larrew

Since the new config_size member of struct VirtIONet specifies a size, it should be declared as size_t.

---
 hw/virtio-net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio-net.c +1 -1
index 663f33c..573c669 100644
@@ -73,7 +73,7 @@ typedef struct VirtIONet
     int multiqueue;
     uint16_t max_queues;
     uint16_t curr_queues;
-    int config_size;
+    size_t config_size;
 } VirtIONet;
 
 /*
Signature · 1 line
1.7.11.7
#3 lore raw
In reply to Jesse Larrew
Quoted 5 lines · Jesse Larrew

This patch set includes some minor cleanups requested by the community for the virtio-net config size solution.

[PATCH 1/2] hw/virtio-net: use existing macros to implement endof [PATCH 2/2] hw/virtio-net: fix config_size data type

Hi Jesse,
I can't apply these patches yet because the patches they depend on haven't appeared in qemu.git/master.

Anthony: Want to merge these patches for 1.4-rc2, we can skip the trivial-patches queue?

Stefan