Skip to contentSkip to conversation

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

PATCH In review Anders Roxell 2 participants 2 messages Dec 6, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 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 /tmp/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.

---

v1 -> v2: fixed checkpatch warnings

 tools/testing/selftests/vDSO/parse_vdso.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/vDSO/parse_vdso.c +2 -1
index 413f75620a35..fdd38f7e0e43 100644
@@ -62,7 +62,8 @@ static unsigned long elf_hash(const unsigned char *name)
 	while (*name)
 	{
 		h = (h << 4) + *name++;
-		if (g = h & 0xf0000000)
+		g = h & 0xf0000000;
+		if (g)
 			h ^= g >> 24;
 		h &= ~g;
 	}
Signature · 1 line
2.33.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 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 /tmp/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.

This part of the commit message does not line up with what you are actually doing now.

Quoted 2 lines

With that fixed:

Quoted 24 lines

---

v1 -> v2: fixed checkpatch warnings

 tools/testing/selftests/vDSO/parse_vdso.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/vDSO/parse_vdso.c +2 -1
index 413f75620a35..fdd38f7e0e43 100644
@@ -62,7 +62,8 @@ static unsigned long elf_hash(const unsigned char *name)
 	while (*name)
 	{
 		h = (h << 4) + *name++;
-		if (g = h & 0xf0000000)
+		g = h & 0xf0000000;
+		if (g)
 			h ^= g >> 24;
 		h &= ~g;
 	}
Signature · 1 line
2.33.0