selftests/vDSO: Fix assignment in condition without parentheses
Subsystems (2)
PATCH 1/1 selftests/vDSO: Fix assignment in condition without parentheses
Fixes clang compiler warnings by adding parentheses:
parse_vdso.c:65:9: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
if (g = h & 0xf0000000)
~~^~~~~~~~~~~~~~~~
parse_vdso.c:65:9: note: place parentheses around the assignment to silence this warning
if (g = h & 0xf0000000)
^
( )
parse_vdso.c:65:9: note: use '==' to turn this assignment into an equality comparison
if (g = h & 0xf0000000)
^
==Fixes 98eedc3a9dbf ("Document the vDSO and add a reference parser")
Signed-off-by Edward Liaw <[email protected]>
--- tools/testing/selftests/vDSO/parse_vdso.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/vDSO/parse_vdso.c +1 -1
@@ -62,7 +62,7 @@ static unsigned long elf_hash(const unsigned char *name)while (*name) { h = (h <<4 ) + *name++; -if (g = h &0xf0000000 ) +if ((g = h &0xf0000000 )) h ^= g >>24 ; h &= ~g; }
Signature · 1 line
2.44.0.769.g3c40516874-goog
Quoted 14 lines · Edward Liaw
Fixes clang compiler warnings by adding parentheses:
parse_vdso.c:65:9: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
if (g = h & 0xf0000000) ~~^~~~~~~~~~~~~~~~ parse_vdso.c:65:9: note: place parentheses around the assignment to silence this warning if (g = h & 0xf0000000) ^ ( ) parse_vdso.c:65:9: note: use '==' to turn this assignment into an equality comparison if (g = h & 0xf0000000) ^ ==
Quoted 2 lines
Fixes 98eedc3a9dbf ("Document the vDSO and add a reference parser")Signed-off-by Edward Liaw <[email protected]>
For readability's sake, I tend to prefer just taking the assignment out of the if statement:
g = h & 0xf0000000;
then testing it:
if (g) ...
but as it stands it's fine and the warning goes away.
Reviewed-by Justin Stitt <[email protected]>
Quoted 20 lines
--- tools/testing/selftests/vDSO/parse_vdso.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/vDSO/parse_vdso.c +1
-1@@ -62,7 +62,7 @@ static unsigned long elf_hash(const unsigned char *name)while (*name) { h = (h <<4 ) + *name++; -if (g = h &0xf0000000 ) +if ((g = h &0xf0000000 )) h ^= g >>24 ; h &= ~g; }Signature · 1 line
2.44.0.769.g3c40516874-goog