Tautological comparison in gcc 6.1.1

Michael Adam obnox at samba.org
Wed Jul 13 22:29:57 UTC 2016


On 2016-07-13 at 15:23 -0700, Jeremy Allison wrote:
> On Thu, Jul 14, 2016 at 12:17:52AM +0200, Michael Adam wrote:
> > On 2016-07-13 at 14:59 -0700, Jeremy Allison wrote:
> > > On Wed, Jul 13, 2016 at 02:08:18PM +0200, Michael Adam wrote:
> > > > updated patch using _Pragma in the macro, not #pragma around.
> > > > Again thaks to Ira for the hint!!
> > > 
> > > God that's horrible :-).
> > 
> > Yes! :-)
> > 
> > > Can't see any other solution, so pushed !
> > 
> > There was one follow-up posting where I
> > gave Ira more credit by having him
> > as author of 2 of the 3 patches. And
> > improved the commit msgs some.
> > 
> > Would you mind pushing that one over?
> 
> Sure, no problem. Can you send it to me ?

here it is

Thanks - Michael
-------------- next part --------------
From ee4fad2e6bad09c243ce96a7d2ac4b45b52e5eb1 Mon Sep 17 00:00:00 2001
From: Ira Cooper <ira at samba.org>
Date: Wed, 13 Jul 2016 12:35:13 +0200
Subject: [PATCH 1/3] lib:dlinklist: avoid -Wtautological-compare errors with
 gcc6

We expect these macros to generate tautological compares
intentionally, so disabling the warning is just fine.

This lets --picky-developer work with gcc6 and newer.

Pair-Programmed-With: Michael Adam <obnox at samba.org>

Signed-off-by: Michael Adam <obnox at samba.org>
Signed-off-by: Ira Cooper <ira at samba.org>
---
 lib/util/dlinklist.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/util/dlinklist.h b/lib/util/dlinklist.h
index 8a1b84d..bdd4f9c 100644
--- a/lib/util/dlinklist.h
+++ b/lib/util/dlinklist.h
@@ -79,6 +79,9 @@ do { \
 */
 #define DLIST_REMOVE(list, p) \
 do { \
+	_Pragma ("GCC diagnostic push") \
+	_Pragma ("GCC diagnostic ignored \"-Wpragmas\"") \
+	_Pragma ("GCC diagnostic ignored \"-Wtautological-compare\"") \
 	if ((p) == (list)) { \
 		if ((p)->next) (p)->next->prev = (p)->prev; \
 		(list) = (p)->next; \
@@ -90,6 +93,7 @@ do { \
 		if ((p)->next) (p)->next->prev = (p)->prev; \
 	} \
 	if ((p) != (list)) (p)->next = (p)->prev = NULL;	\
+	_Pragma ("GCC diagnostic pop") \
 } while (0)
 
 /*
@@ -120,7 +124,11 @@ do { \
 		(p)->next = (el)->next;		\
 		(el)->next = (p);		\
 		if ((p)->next) (p)->next->prev = (p);	\
+		_Pragma ("GCC diagnostic push") \
+		_Pragma ("GCC diagnostic ignored \"-Wpragmas\"") \
+		_Pragma ("GCC diagnostic ignored \"-Wtautological-compare\"") \
 		if ((list)->prev == (el)) (list)->prev = (p); \
+		_Pragma ("GCC diagnostic pop") \
 	}\
 } while (0)
 
-- 
2.5.5


From 7d8c36257d054f7d467c79aa09b986e2d267e56b Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 13 Jul 2016 12:36:21 +0200
Subject: [PATCH 2/3] tevent: avoid -Wtautological-compare errors with gcc6

We expect these macros to generate tautological compares
intentionally, so disabling the warning is just fine.

This lets --picky-developer work with gcc6 and newer.

Pair-Programmed-With: Ira Cooper <ira at samba.org>

Signed-off-by: Ira Cooper <ira at samba.org>
Signed-off-by: Michael Adam <obnox at samba.org>
---
 lib/tevent/tevent_util.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/tevent/tevent_util.h b/lib/tevent/tevent_util.h
index e2cdbb8..eb7586f 100644
--- a/lib/tevent/tevent_util.h
+++ b/lib/tevent/tevent_util.h
@@ -79,6 +79,9 @@ do { \
 */
 #define DLIST_REMOVE(list, p) \
 do { \
+	_Pragma ("GCC diagnostic push") \
+	_Pragma ("GCC diagnostic ignored \"-Wpragmas\"") \
+	_Pragma ("GCC diagnostic ignored \"-Wtautological-compare\"") \
 	if ((p) == (list)) { \
 		if ((p)->next) (p)->next->prev = (p)->prev; \
 		(list) = (p)->next; \
@@ -90,6 +93,7 @@ do { \
 		if ((p)->next) (p)->next->prev = (p)->prev; \
 	} \
 	if ((p) != (list)) (p)->next = (p)->prev = NULL;	\
+	_Pragma ("GCC diagnostic pop") \
 } while (0)
 
 /*
@@ -120,7 +124,11 @@ do { \
 		(p)->next = (el)->next;		\
 		(el)->next = (p);		\
 		if ((p)->next) (p)->next->prev = (p);	\
+		_Pragma ("GCC diagnostic push") \
+		_Pragma ("GCC diagnostic ignored \"-Wpragmas\"") \
+		_Pragma ("GCC diagnostic ignored \"-Wtautological-compare\"") \
 		if ((list)->prev == (el)) (list)->prev = (p); \
+		_Pragma ("GCC diagnostic pop") \
 	}\
 } while (0)
 
-- 
2.5.5


From c05a3cb23c936eb4376c402fd26bf099f62b48ee Mon Sep 17 00:00:00 2001
From: Ira Cooper <ira at samba.org>
Date: Wed, 13 Jul 2016 12:37:19 +0200
Subject: [PATCH 3/3] ldb:dlinklist: avoid -Wtautological-compare errors with
 gcc6

We expect these macros to generate tautological compares
intentionally, so disabling the warning is just fine.

This lets --pick-developer work with gcc6 and newer.

Pair-Programmed-With: Michael Adam <obnox at samba.org>

Signed-off-by: Michael Adam <obnox at samba.org>
Signed-off-by: Ira Cooper <ira at samba.org>
---
 lib/ldb/include/dlinklist.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/ldb/include/dlinklist.h b/lib/ldb/include/dlinklist.h
index ef01aec..ca76794 100644
--- a/lib/ldb/include/dlinklist.h
+++ b/lib/ldb/include/dlinklist.h
@@ -83,6 +83,9 @@ do { \
 */
 #define DLIST_REMOVE(list, p) \
 do { \
+	_Pragma ("GCC diagnostic push") \
+	_Pragma ("GCC diagnostic ignored \"-Wpragmas\"") \
+	_Pragma ("GCC diagnostic ignored \"-Wtautological-compare\"") \
 	if ((p) == (list)) { \
 		if ((p)->next) (p)->next->prev = (p)->prev; \
 		(list) = (p)->next; \
@@ -94,6 +97,7 @@ do { \
 		if ((p)->next) (p)->next->prev = (p)->prev; \
 	} \
 	if ((p) != (list)) (p)->next = (p)->prev = NULL;	\
+	_Pragma ("GCC diagnostic pop") \
 } while (0)
 
 /*
@@ -124,7 +128,11 @@ do { \
 		(p)->next = (el)->next;		\
 		(el)->next = (p);		\
 		if ((p)->next) (p)->next->prev = (p);	\
+		_Pragma ("GCC diagnostic push") \
+		_Pragma ("GCC diagnostic ignored \"-Wpragmas\"") \
+		_Pragma ("GCC diagnostic ignored \"-Wtautological-compare\"") \
 		if ((list)->prev == (el)) (list)->prev = (p); \
+		_Pragma ("GCC diagnostic pop") \
 	}\
 } while (0)
 
-- 
2.5.5

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20160714/9afd9d39/signature.sig>


More information about the samba-technical mailing list