[PATCH] types: Add global ARRAY_SIZE macro

Daniel Wagner wagi at monom.org
Thu Nov 29 00:20:56 PST 2012


From: Daniel Wagner <daniel.wagner at bmw-carit.de>

There is no need to redefine this macro everywere.
---
 include/types.h       | 2 ++
 plugins/iwmx.h        | 1 -
 vpn/plugins/l2tp.c    | 2 --
 vpn/plugins/openvpn.c | 2 --
 vpn/plugins/pptp.c    | 2 --
 vpn/plugins/vpnc.c    | 2 --
 6 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/include/types.h b/include/types.h
index 0f671ec..079571d 100644
--- a/include/types.h
+++ b/include/types.h
@@ -38,6 +38,8 @@ typedef int		connman_bool_t;
 typedef unsigned char	connman_uint8_t;
 typedef unsigned short	connman_uint16_t;
 
+#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/plugins/iwmx.h b/plugins/iwmx.h
index 2ff522c..cbab185 100644
--- a/plugins/iwmx.h
+++ b/plugins/iwmx.h
@@ -124,7 +124,6 @@ static inline void wmxsdk_init(struct wmxsdk *wmxsdk)
 }
 
 /* Misc utilities */
-#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
 #define container_of(pointer, type, member)				\
 ({									\
 	type *object = NULL;						\
diff --git a/vpn/plugins/l2tp.c b/vpn/plugins/l2tp.c
index 4cb4b6a..dd28799 100644
--- a/vpn/plugins/l2tp.c
+++ b/vpn/plugins/l2tp.c
@@ -47,8 +47,6 @@
 
 #include "vpn.h"
 
-#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
-
 enum {
 	OPT_STRING = 1,
 	OPT_BOOL = 2,
diff --git a/vpn/plugins/openvpn.c b/vpn/plugins/openvpn.c
index 84583cd..9a4d80c 100644
--- a/vpn/plugins/openvpn.c
+++ b/vpn/plugins/openvpn.c
@@ -42,8 +42,6 @@
 
 #include "vpn.h"
 
-#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
-
 static DBusConnection *connection;
 
 struct {
diff --git a/vpn/plugins/pptp.c b/vpn/plugins/pptp.c
index 6843793..1e2a946 100644
--- a/vpn/plugins/pptp.c
+++ b/vpn/plugins/pptp.c
@@ -43,8 +43,6 @@
 
 #include "vpn.h"
 
-#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
-
 enum {
 	OPT_STRING = 1,
 	OPT_BOOL = 2,
diff --git a/vpn/plugins/vpnc.c b/vpn/plugins/vpnc.c
index 9fd1dec..6d43534 100644
--- a/vpn/plugins/vpnc.c
+++ b/vpn/plugins/vpnc.c
@@ -43,8 +43,6 @@
 
 #include "vpn.h"
 
-#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
-
 static DBusConnection *connection;
 
 enum {
-- 
1.8.0.rc0




More information about the connman mailing list