[SSSD] [PATCH] Fix warning: for loop has empty body

Lukas Slebodnik lslebodn at redhat.com
Wed Jan 14 13:24:53 UTC 2015


On (12/01/15 13:17), Pavel Březina wrote:
>On 01/10/2015 06:08 PM, Lukas Slebodnik wrote:
>>ehlo,
>>
>>The attached patch fixes clang warning -Wempty-body.
>>The other alternative is to put put the semicolon on a separate line to silence
>>this warning as it was suggested by compiler.
>>
>>LS
>
>If we are going to fix this warning, I would prefer this way:
>
>for (...) {
>    /* no op */
It is inside of macro but I don't mind.

attached is fixed version.

LS
-------------- next part --------------
>From 8baffd56691cd8c2a3bac2905e2637062b21effa Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Tue, 14 Oct 2014 10:57:28 +0200
Subject: [PATCH] Fix warning: for loop has empty body

Example of warning:
src/ldb_modules/memberof.c:4203:536: error: for loop has empty body [-Werror,-Wempty-body]
src/ldb_modules/memberof.c:4203:536: note: put the semicolon on a separate line to silence this warning
---
 src/util/dlinklist.h | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/util/dlinklist.h b/src/util/dlinklist.h
index fa4b722559185ab2eb35c57cd84c9cb61a30fdb9..413084888b8dbdb9faef4b0011d030766b8a2965 100644
--- a/src/util/dlinklist.h
+++ b/src/util/dlinklist.h
@@ -66,7 +66,9 @@ do { \
 			(p)->next = (p)->prev = NULL; \
 		} else { \
 			type tmp; \
-			for (tmp = (list); tmp->next; tmp = tmp->next) ; \
+			for (tmp = (list); tmp->next; tmp = tmp->next) { \
+				/* no op */ \
+			} \
 			tmp->next = (p); \
 			(p)->next = NULL; \
 			(p)->prev = tmp; \
@@ -102,7 +104,9 @@ do { \
 			(list1) = (list2); \
 		} else { \
 			type tmp; \
-			for (tmp = (list1); tmp->next; tmp = tmp->next) ; \
+			for (tmp = (list1); tmp->next; tmp = tmp->next) { \
+				/* no op */ \
+			} \
 			tmp->next = (list2); \
 			if (list2) { \
 				(list2)->prev = tmp;	\
@@ -118,7 +122,9 @@ do { \
                     DLIST_CONCATENATE(list1, list2, type); \
                 } else { \
                     type tmp; \
-                    for (tmp = (list2); tmp->next; tmp = tmp->next) ; \
+                    for (tmp = (list2); tmp->next; tmp = tmp->next) { \
+                        /* no op */ \
+                    } \
                     (list2)->prev = (el); \
                     tmp->next = (el)->next; \
                     (el)->next = (list2); \
-- 
2.1.0



More information about the sssd-devel mailing list