[exim-dev] Clang warnings for RC2 #5

Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Richard Clayton
Fecha:  
A: exim-dev
Asunto: [exim-dev] Clang warnings for RC2 #5

There's a number of warnings from clang in readconf.c

The dangling else at 3802 and this and the "|| &&" construct at 4311
don't need much further comment:

readconf.c:3802:7: warning: add explicit braces to avoid dangling else
[-Wdangling-else]
      else
      ^
readconf.c:4311:44: warning: '&&' within '||' [-Wlogical-op-parentheses]
             || Ustrncmp(current, "hide", 4) == 0 && isspace(current[4])



At line 4302 there's an issue with char / unsigned char ... since strlen
wants "const char *" but current is "const uschar *" I think the
correct change is from

else if (current[strlen(current)-1] == ':' && !Ustrchr(current, '='))
to
else if (current[Ustrlen(current)-1] == ':' && !Ustrchr(current, '='))

since Ustrlen exists for precisely this purpose!

Finally at line 4315 clang complains

readconf.c:4315:11: warning: using the result of an assignment as a
condition without parentheses [-Wparentheses]
    if (p = Ustrchr(current, '='))


that's because clang is concerned that the programmer might have
intended to write p ==

so the simplest fix is (inelegantly)

    if ((p = Ustrchr(current, '=')))


but I'd write it as two lines myself for clarity:

    p = Ustrchr(current, '=');
    if (p)


To avoid changes being missed, diff attached for this file

-- 
richard                                                   Richard Clayton


Those who would give up essential Liberty, to purchase a little temporary
Safety, deserve neither Liberty nor Safety. Benjamin Franklin 11 Nov 1755