Skip to contentSkip to conversation

selftests: vDSO: parse: warning: fix assignment as a condition

PATCH Superseded Anders Roxell 3 participants 3 messages Nov 5, 2021 – Nov 20, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: vDSO: parse: warning: fix assignment as a condition

When building selftests/vDSO with clang the following warning shows up:

clang -std=gnu99 -Wno-pointer-sign vdso_test_gettimeofday.c parse_vdso.c -o /home/anders/.cache/tuxmake/builds/current/kselftest/vDSO/vdso_test_gettimeofday
parse_vdso.c:65:9: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]

                if (g = h & 0xf0000000)
                    ~~^~~~~~~~~~~~~~~~

Rework to a parentheses before doing the check.

---
 tools/testing/selftests/vDSO/parse_vdso.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/vDSO/parse_vdso.c +1 -1
index 413f75620a35..b47b721a4ea4 100644
@@ -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.33.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Anders Roxell

When building selftests/vDSO with clang the following warning shows up:

clang -std=gnu99 -Wno-pointer-sign vdso_test_gettimeofday.c parse_vdso.c -o /home/anders/.cache/tuxmake/builds/current/kselftest/vDSO/vdso_test_gettimeofday
parse_vdso.c:65:9: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]

                if (g = h & 0xf0000000)
                    ~~^~~~~~~~~~~~~~~~

Rework to a parentheses before doing the check.

Thanks for the patch!

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 -2
index 413f75620a35..b47b721a4ea4 100644
@@ -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;
        }
--

2.33.0

Signature · 2 lines
Thanks,
~Nick Desaulniers
maintainer
#2 lore raw
Quoted 9 lines · Nick Desaulniers
Quoted 8 lines · Anders Roxell

When building selftests/vDSO with clang the following warning shows up:

clang -std=gnu99 -Wno-pointer-sign vdso_test_gettimeofday.c parse_vdso.c -o /home/anders/.cache/tuxmake/builds/current/kselftest/vDSO/vdso_test_gettimeofday
parse_vdso.c:65:9: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]

                 if (g = h & 0xf0000000)
                     ~~^~~~~~~~~~~~~~~~
Quoted 7 lines
Quoted 3 lines

Rework to a parentheses before doing the check.

Thanks for the patch!

My commit script failed due to checkpatch warns. Run checkpatchp.l --strict to find the problems and send me the fixed version.

thanks,
-- Shuah