Skip to contentSkip to conversation

dynamic_debug: Use address-of operator on section symbols

PATCH Applied Nathan Chancellor 2 participants 4 messages Feb 20, 2020 – Mar 19, 2020

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

PATCH v2 1/1 dynamic_debug: Use address-of operator on section symbols

Clang warns:

../lib/dynamic_debug.c:1034:24: warning: array comparison always evaluates to false [-Wtautological-compare]

        if (__start___verbose == __stop___verbose) {
                              ^

1 warning generated.

These are not true arrays, they are linker defined symbols, which are just addresses. Using the address of operator silences the warning and does not change the resulting assembly with either clang/ld.lld or gcc/ld (tested with diff + objdump -Dr).

---
v1 -> v2: https://lore.kernel.org/lkml/[email protected]/

* No longer a series because there is no prerequisite patch.
* Use address-of operator instead of casting to unsigned long.

 lib/dynamic_debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/dynamic_debug.c +1 -1
index aae17d9522e5..8f199f403ab5 100644
@@ -1031,7 +1031,7 @@ static int __init dynamic_debug_init(void)
 	int n = 0, entries = 0, modct = 0;
 	int verbose_bytes = 0;
 
-	if (__start___verbose == __stop___verbose) {
+	if (&__start___verbose == &__stop___verbose) {
 		pr_warn("_ddebug table is empty in a CONFIG_DYNAMIC_DEBUG build\n");
 		return 1;
 	}
Signature · 1 line
2.25.1
#1 lore raw
Quoted 41 lines · Nathan Chancellor

Clang warns:

../lib/dynamic_debug.c:1034:24: warning: array comparison always evaluates to false [-Wtautological-compare]

        if (__start___verbose == __stop___verbose) {
                              ^

1 warning generated.

These are not true arrays, they are linker defined symbols, which are just addresses. Using the address of operator silences the warning and does not change the resulting assembly with either clang/ld.lld or gcc/ld (tested with diff + objdump -Dr).

---
v1 -> v2: https://lore.kernel.org/lkml/[email protected]/

* No longer a series because there is no prerequisite patch.
* Use address-of operator instead of casting to unsigned long.

 lib/dynamic_debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/dynamic_debug.c +1 -1
index aae17d9522e5..8f199f403ab5 100644
@@ -1031,7 +1031,7 @@ static int __init dynamic_debug_init(void)
 	int n = 0, entries = 0, modct = 0;
 	int verbose_bytes = 0;
 
-	if (__start___verbose == __stop___verbose) {
+	if (&__start___verbose == &__stop___verbose) {
 		pr_warn("_ddebug table is empty in a CONFIG_DYNAMIC_DEBUG build\n");
 		return 1;
 	}
Signature · 1 line
2.25.1

Gentle ping for review/acceptance.

Cheers,
Nathan

maintainer Acked-by
#2 lore raw
Quoted 45 lines · Nathan Chancellor
Quoted 41 lines · Nathan Chancellor

Clang warns:

../lib/dynamic_debug.c:1034:24: warning: array comparison always evaluates to false [-Wtautological-compare]

        if (__start___verbose == __stop___verbose) {
                              ^

1 warning generated.

These are not true arrays, they are linker defined symbols, which are just addresses. Using the address of operator silences the warning and does not change the resulting assembly with either clang/ld.lld or gcc/ld (tested with diff + objdump -Dr).

---
v1 -> v2: https://lore.kernel.org/lkml/[email protected]/

* No longer a series because there is no prerequisite patch.
* Use address-of operator instead of casting to unsigned long.

 lib/dynamic_debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/dynamic_debug.c +1 -1
index aae17d9522e5..8f199f403ab5 100644
@@ -1031,7 +1031,7 @@ static int __init dynamic_debug_init(void)
 	int n = 0, entries = 0, modct = 0;
 	int verbose_bytes = 0;
 
-	if (__start___verbose == __stop___verbose) {
+	if (&__start___verbose == &__stop___verbose) {
 		pr_warn("_ddebug table is empty in a CONFIG_DYNAMIC_DEBUG build\n");
 		return 1;
 	}
Signature · 1 line
2.25.1

Gentle ping for review/acceptance.

Quoted 2 lines

Cheers,
Nathan

Works for me.

#3 lore raw
Quoted 48 lines · Jason Baron
Quoted 45 lines · Nathan Chancellor
Quoted 41 lines · Nathan Chancellor

Clang warns:

../lib/dynamic_debug.c:1034:24: warning: array comparison always evaluates to false [-Wtautological-compare]

        if (__start___verbose == __stop___verbose) {
                              ^

1 warning generated.

These are not true arrays, they are linker defined symbols, which are just addresses. Using the address of operator silences the warning and does not change the resulting assembly with either clang/ld.lld or gcc/ld (tested with diff + objdump -Dr).

---
v1 -> v2: https://lore.kernel.org/lkml/[email protected]/

* No longer a series because there is no prerequisite patch.
* Use address-of operator instead of casting to unsigned long.

 lib/dynamic_debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/dynamic_debug.c +1 -1
index aae17d9522e5..8f199f403ab5 100644
@@ -1031,7 +1031,7 @@ static int __init dynamic_debug_init(void)
 	int n = 0, entries = 0, modct = 0;
 	int verbose_bytes = 0;
 
-	if (__start___verbose == __stop___verbose) {
+	if (&__start___verbose == &__stop___verbose) {
 		pr_warn("_ddebug table is empty in a CONFIG_DYNAMIC_DEBUG build\n");
 		return 1;
 	}
Signature · 1 line
2.25.1

Gentle ping for review/acceptance.

Quoted 6 lines
Quoted 2 lines

Cheers,
Nathan

Works for me.

Thank you!

Andrew, I assume you'll pick this up?

Cheers,
Nathan