Skip to contentSkip to conversation

lib: Change bluetooth.h to compile using strict C

PATCH Superseded Gabriel Souza Franco 3 participants 5 messages Oct 28, 2014 – Nov 11, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: Change bluetooth.h to compile using strict C

---

This change enables programs writen with strict C syntax (e.g. "-std=c11 -pedantic") to compile when including bluetooth.h. Also changed src/shared/util.h to match.

 lib/bluetooth.h   | 10 +++++-----
 src/shared/util.h | 10 +++++-----
 2 files changed, 10 insertions(+), 10 deletions(-)
lib/bluetooth.h +5 -5
index 61c1f9a..f214d81 100644
@@ -156,18 +156,18 @@ enum {
 
 /* Bluetooth unaligned access */
 #define bt_get_unaligned(ptr)			\
-({						\
+__extension__ ({				\
 	struct __attribute__((packed)) {	\
-		typeof(*(ptr)) __v;		\
-	} *__p = (typeof(__p)) (ptr);		\
+		__typeof__(*(ptr)) __v;		\
+	} *__p = (__typeof__(__p)) (ptr);	\
 	__p->__v;				\
 })
 
 #define bt_put_unaligned(val, ptr)		\
 do {						\
 	struct __attribute__((packed)) {	\
-		typeof(*(ptr)) __v;		\
-	} *__p = (typeof(__p)) (ptr);		\
+		__typeof__(*(ptr)) __v;		\
+	} *__p = (__typeof__(__p)) (ptr);	\
 	__p->__v = (val);			\
 } while(0)
 
src/shared/util.h +5 -5
index 04c600f..8437662 100644
@@ -57,18 +57,18 @@
 #endif
 
 #define get_unaligned(ptr)			\
-({						\
+__extension__ ({				\
 	struct __attribute__((packed)) {	\
-		typeof(*(ptr)) __v;		\
-	} *__p = (typeof(__p)) (ptr);		\
+		__typeof__(*(ptr)) __v;		\
+	} *__p = (__typeof__(__p)) (ptr);	\
 	__p->__v;				\
 })
 
 #define put_unaligned(val, ptr)			\
 do {						\
 	struct __attribute__((packed)) {	\
-		typeof(*(ptr)) __v;		\
-	} *__p = (typeof(__p)) (ptr);		\
+		__typeof__(*(ptr)) __v;		\
+	} *__p = (__typeof__(__p)) (ptr);	\
 	__p->__v = (val);			\
 } while (0)
 
Signature · 1 line
2.1.2
maintainer
#1 lore raw

Hi Gabriel,

Quoted 2 lines

no signed-off-by for userspace patches please.

Quoted 9 lines

---

This change enables programs writen with strict C syntax (e.g. "-std=c11 -pedantic") to compile when including bluetooth.h. Also changed src/shared/util.h to match.

lib/bluetooth.h | 10 +++++-----
src/shared/util.h | 10 +++++-----

2 files changed, 10 insertions(+), 10 deletions(-)

Split this into two patches. lib/ and src/shared/ should always be patched independently.

Quoted 46 lines
lib/bluetooth.h +5 -5
index 61c1f9a..f214d81 100644
@@ -156,18 +156,18 @@ enum {
 
 /* Bluetooth unaligned access */
 #define bt_get_unaligned(ptr)			\
-({						\
+__extension__ ({				\
 	struct __attribute__((packed)) {	\
-		typeof(*(ptr)) __v;		\
-	} *__p = (typeof(__p)) (ptr);		\
+		__typeof__(*(ptr)) __v;		\
+	} *__p = (__typeof__(__p)) (ptr);	\
 	__p->__v;				\
 })
 
 #define bt_put_unaligned(val, ptr)		\
 do {						\
 	struct __attribute__((packed)) {	\
-		typeof(*(ptr)) __v;		\
-	} *__p = (typeof(__p)) (ptr);		\
+		__typeof__(*(ptr)) __v;		\
+	} *__p = (__typeof__(__p)) (ptr);	\
 	__p->__v = (val);			\
 } while(0)
 
src/shared/util.h +3 -3
index 04c600f..8437662 100644
@@ -57,18 +57,18 @@
 #endif
 
 #define get_unaligned(ptr)			\
-({						\
+__extension__ ({				\
 	struct __attribute__((packed)) {	\
-		typeof(*(ptr)) __v;		\
-	} *__p = (typeof(__p)) (ptr);		\
+		__typeof__(*(ptr)) __v;		\
+	} *__p = (__typeof__(__p)) (ptr);	\
 	__p->__v;				\
 })

src/shared/util.h line 73

Quoted 10 lines
src/shared/util.h +2 -2
 
 #define put_unaligned(val, ptr)			\
 do {						\
 	struct __attribute__((packed)) {	\
-		typeof(*(ptr)) __v;		\
-	} *__p = (typeof(__p)) (ptr);		\
+		__typeof__(*(ptr)) __v;		\
+	} *__p = (__typeof__(__p)) (ptr);	\
 	__p->__v = (val);			\
 } while (0)

Regards

Marcel

#2 lore raw

PATCH v2 1/2 lib: Change bluetooth.h to compile in strict C

---

This change enables programs writen with strict C syntax (e.g. "-std=c11 -pedantic") to compile when including bluetooth.h.

v2: Resend with fixed commits.

 lib/bluetooth.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
lib/bluetooth.h +5 -5
index 61c1f9a..f214d81 100644
@@ -156,18 +156,18 @@ enum {
 
 /* Bluetooth unaligned access */
 #define bt_get_unaligned(ptr)			\
-({						\
+__extension__ ({				\
 	struct __attribute__((packed)) {	\
-		typeof(*(ptr)) __v;		\
-	} *__p = (typeof(__p)) (ptr);		\
+		__typeof__(*(ptr)) __v;		\
+	} *__p = (__typeof__(__p)) (ptr);	\
 	__p->__v;				\
 })
 
 #define bt_put_unaligned(val, ptr)		\
 do {						\
 	struct __attribute__((packed)) {	\
-		typeof(*(ptr)) __v;		\
-	} *__p = (typeof(__p)) (ptr);		\
+		__typeof__(*(ptr)) __v;		\
+	} *__p = (__typeof__(__p)) (ptr);	\
 	__p->__v = (val);			\
 } while(0)
 
Signature · 1 line
2.1.2
#3 lore raw

PATCH v2 2/2 shared: Change util.h to compile in strict C

---
 src/shared/util.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
src/shared/util.h +5 -5
index 04c600f..8437662 100644
@@ -57,18 +57,18 @@
 #endif
 
 #define get_unaligned(ptr)			\
-({						\
+__extension__ ({				\
 	struct __attribute__((packed)) {	\
-		typeof(*(ptr)) __v;		\
-	} *__p = (typeof(__p)) (ptr);		\
+		__typeof__(*(ptr)) __v;		\
+	} *__p = (__typeof__(__p)) (ptr);	\
 	__p->__v;				\
 })
 
 #define put_unaligned(val, ptr)			\
 do {						\
 	struct __attribute__((packed)) {	\
-		typeof(*(ptr)) __v;		\
-	} *__p = (typeof(__p)) (ptr);		\
+		__typeof__(*(ptr)) __v;		\
+	} *__p = (__typeof__(__p)) (ptr);	\
 	__p->__v = (val);			\
 } while (0)
 
Signature · 1 line
2.1.2
#4 lore raw

Re: [PATCH BlueZ v2 1/2] lib: Change bluetooth.h to compile in strict C

In reply to Gabriel Souza Franco

Hi Gabriel,

Quoted 10 lines · Gabriel Souza Franco

---

This change enables programs writen with strict C syntax (e.g. "-std=c11 -pedantic") to compile when including bluetooth.h.

v2: Resend with fixed commits.

 lib/bluetooth.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Both of these patches have been applied. Thanks.

Johan