summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Kwan <dougkwan@google.com>2011-10-17 02:31:29 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2011-10-17 02:31:29 -0700
commit17a8801bd71b3d67730a5a9db1ae4101673c69b3 (patch)
tree03805668ba4893f93020c84ed4829dc56c826f8c
parent502a674a22c535f6d5885caca107913f244f7b6b (diff)
parent8c3968245a0d0f015dcc0fb6b39fbec42c608ea1 (diff)
downloadhardware_broadcom_wlan-17a8801bd71b3d67730a5a9db1ae4101673c69b3.zip
hardware_broadcom_wlan-17a8801bd71b3d67730a5a9db1ae4101673c69b3.tar.gz
hardware_broadcom_wlan-17a8801bd71b3d67730a5a9db1ae4101673c69b3.tar.bz2
am 8c396824: 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.
* commit '8c3968245a0d0f015dcc0fb6b39fbec42c608ea1': 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.
-rw-r--r--bcm4329/dhdutil/include/bcmutils.h4
-rw-r--r--bcmdhd/dhdutil/include/bcmutils.h4
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]))