Patchwork [1/2] hw/virtio-net: use existing macros to implement endof

login
register
mail settings
Submitter Jesse Larrew
Date Feb. 7, 2013, 8:49 p.m.
Message ID <1360270167-15385-2-git-send-email-jlarrew@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/218987/
State New
Headers show

Comments

Jesse Larrew - Feb. 7, 2013, 8:49 p.m.
Clarify the definition of endof() by using the offsetof() and sizeof()
macros to handle the pointer magic.

Signed-off-by: Jesse Larrew <jlarrew@linux.vnet.ibm.com>
---
 hw/virtio-net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch

diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 8f521b3..663f33c 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -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;