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

Submitted by Jesse Larrew on Feb. 7, 2013, 8:49 p.m.

Details

Message ID 1360270167-15385-2-git-send-email-jlarrew@linux.vnet.ibm.com
State New
Headers show

Commit Message

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 hide | download patch | download mbox

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;