Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/ifconfig C99 says that offsetof() expands to a constant...



details:   https://anonhg.NetBSD.org/src/rev/8fbca26f47b6
branches:  trunk
changeset: 754114:8fbca26f47b6
user:      plunky <plunky%NetBSD.org@localhost>
date:      Tue Apr 20 21:25:25 2010 +0000

description:
C99 says that offsetof() expands to a constant expresssion, so we
can't use variable array index in there. Do the calculation manually
for C99 compilers (pcc)

diffstat:

 sbin/ifconfig/parse.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (29 lines):

diff -r 8f6cd26f1d88 -r 8fbca26f47b6 sbin/ifconfig/parse.c
--- a/sbin/ifconfig/parse.c     Tue Apr 20 18:08:08 2010 +0000
+++ b/sbin/ifconfig/parse.c     Tue Apr 20 21:25:25 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.14 2009/07/28 18:21:06 dyoung Exp $        */
+/*     $NetBSD: parse.c,v 1.15 2010/04/20 21:25:25 plunky Exp $        */
 
 /*-
  * Copyright (c) 2008 David Young.  All rights reserved.
@@ -27,7 +27,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: parse.c,v 1.14 2009/07/28 18:21:06 dyoung Exp $");
+__RCSID("$NetBSD: parse.c,v 1.15 2010/04/20 21:25:25 plunky Exp $");
 #endif /* not lint */
 
 #include <err.h>
@@ -252,8 +252,8 @@
                                return -1;
                        dbg_warnx("%s.%d", __func__, __LINE__);
                        sdl->sdl_data[i++] = octet;
-                       sdl->sdl_len =
-                           offsetof(struct sockaddr_dl, sdl_data[i]);
+                       sdl->sdl_len = offsetof(struct sockaddr_dl, sdl_data)
+                           + i * sizeof(sdl->sdl_data[0]);
                        sdl->sdl_alen = i;
                        return 0;
                }



Home | Main Index | Thread Index | Old Index