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

Pavel Březina pbrezina at redhat.com
Wed Jan 14 21:54:08 UTC 2015


On 01/14/2015 10:02 PM, Lukas Slebodnik wrote:
> On (14/01/15 21:46), Pavel Březina wrote:
>> On 01/14/2015 02:24 PM, Lukas Slebodnik wrote:
>>> 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
>>
>> Ack.
>>
>> But out of curiosity, there are lots of for cycles with empty body.
> Where? Thry t find one :-)
>
>> Why those do not trigger this warning?
> It is possible that semicolon was not on the same line as keyword "for"
> You can easily overlook semicolon after closing brace.
>
> LS

[pbrezina: ~/workspace/sssd (master)]$ git grep ") ;"
Makefile.am:        $(MKDIR_P) $(DESTDIR)/$(krb5rcachedir) ; \
src/providers/ldap/sdap.c:    for (nextra = 0; extra_attrs[nextra]; 
nextra++) ;
src/providers/ldap/sdap_async.c:         state->nserverctrls++) ;
src/responder/nss/nsssrv_mmap_cache.c:        for (t = ((cur + 8) & ~7) 
; cur < t; cur++) {
src/tools/sss_groupshow.c:            for (count = 0; 
gi->user_members[count]; count++) ;
src/tools/sss_groupshow.c:            for (count = 0; 
user_members[count]; count++) ;
src/util/dlinklist.h:                   for (tmp = (list); tmp->next; 
tmp = tmp->next) ; \
src/util/dlinklist.h:                   for (tmp = (list1); tmp->next; 
tmp = tmp->next) ; \
src/util/dlinklist.h:                    for (tmp = (list2); tmp->next; 
tmp = tmp->next) ; \





More information about the sssd-devel mailing list