diff options
author | Doug Kwan <dougkwan@google.com> | 2011-08-08 22:08:35 -0700 |
---|---|---|
committer | Doug Kwan <dougkwan@google.com> | 2011-10-13 09:53:54 -0700 |
commit | 8c3968245a0d0f015dcc0fb6b39fbec42c608ea1 (patch) | |
tree | 03805668ba4893f93020c84ed4829dc56c826f8c | |
parent | f6ad682cfc4444f0d7d31613d9fe76d8f05a3fa4 (diff) | |
download | android_hardware_broadcom_wlan-8c3968245a0d0f015dcc0fb6b39fbec42c608ea1.tar.gz android_hardware_broadcom_wlan-8c3968245a0d0f015dcc0fb6b39fbec42c608ea1.tar.bz2 android_hardware_broadcom_wlan-8c3968245a0d0f015dcc0fb6b39fbec42c608ea1.zip |
Fix undefined behaviour in C. This patch uses offsetof() macro defined in
the C specs instead of using a macro which dereferences a null pointer.
The offsetof() macro is available since C89.
Change-Id: I62b9b1d726dd0c3a956bdc4ae4cdd5db3dc55040
-rw-r--r-- | bcm4329/dhdutil/include/bcmutils.h | 4 | ||||
-rw-r--r-- | bcmdhd/dhdutil/include/bcmutils.h | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/bcm4329/dhdutil/include/bcmutils.h b/bcm4329/dhdutil/include/bcmutils.h index f08fe56..3b823a1 100644 --- a/bcm4329/dhdutil/include/bcmutils.h +++ b/bcm4329/dhdutil/include/bcmutils.h @@ -22,6 +22,8 @@ #ifndef _bcmutils_h_ #define _bcmutils_h_ +#include <stddef.h> + #define bcm_strcpy_s(dst, noOfElements, src) strcpy((dst), (src)) #define bcm_strncpy_s(dst, noOfElements, src, count) strncpy((dst), (src), (count)) #define bcm_strcat_s(dst, noOfElements, src) strcat((dst), (src)) @@ -527,7 +529,7 @@ extern int bcm_format_ssid(char* buf, const uchar ssid[], uint ssid_len); #define ISPOWEROF2(x) ((((x)-1)&(x)) == 0) #define VALID_MASK(mask) !((mask) & ((mask) + 1)) #ifndef OFFSETOF -#define OFFSETOF(type, member) ((uint)(uintptr)&((type *)0)->member) +#define OFFSETOF(type, member) ((uint)offsetof(type, member)) #endif #ifndef ARRAYSIZE #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) diff --git a/bcmdhd/dhdutil/include/bcmutils.h b/bcmdhd/dhdutil/include/bcmutils.h index f08fe56..3b823a1 100644 --- a/bcmdhd/dhdutil/include/bcmutils.h +++ b/bcmdhd/dhdutil/include/bcmutils.h @@ -22,6 +22,8 @@ #ifndef _bcmutils_h_ #define _bcmutils_h_ +#include <stddef.h> + #define bcm_strcpy_s(dst, noOfElements, src) strcpy((dst), (src)) #define bcm_strncpy_s(dst, noOfElements, src, count) strncpy((dst), (src), (count)) #define bcm_strcat_s(dst, noOfElements, src) strcat((dst), (src)) @@ -527,7 +529,7 @@ extern int bcm_format_ssid(char* buf, const uchar ssid[], uint ssid_len); #define ISPOWEROF2(x) ((((x)-1)&(x)) == 0) #define VALID_MASK(mask) !((mask) & ((mask) + 1)) #ifndef OFFSETOF -#define OFFSETOF(type, member) ((uint)(uintptr)&((type *)0)->member) +#define OFFSETOF(type, member) ((uint)offsetof(type, member)) #endif #ifndef ARRAYSIZE #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) |