Skip to contentSkip to conversation

zstd: fix g_debuglevel export warning

PATCH In review Ben Dooks 2 participants 2 messages Jun 16, 2023 – Nov 21, 2023 Zstd

lore
Share & tools
lore

Ben Dooks

author
#0 lore raw

PATCH 1/1 zstd: fix g_debuglevel export warning

The g_debuglevel variable in debug.c is only used when DEBUGLEVEL is defined to be above 2. This means by default there's no actual definition of this in the headers, so sparse is giving the following warning:

lib/zstd/common/debug.c:24:5: warning: symbol 'g_debuglevel' was not declared. Should it be static?

We can use the same check as in the header to remove this if it isn't going to be used, silencing the warning and removing a small bit of unused data.

---
 lib/zstd/common/debug.c | 2 ++
 1 file changed, 2 insertions(+)
lib/zstd/common/debug.c +2 -0
index bb863c9ea616..820520b93d2b 100644
@@ -21,4 +21,6 @@
 
 #include "debug.h"
 
+#if (DEBUGLEVEL>=2)
 int g_debuglevel = DEBUGLEVEL;
+#endif
Signature · 1 line
2.39.2
#1 lore raw
Quoted 9 lines · Ben Dooks
Quoted 2 lines

The g_debuglevel variable in debug.c is only used when DEBUGLEVEL is defined to be above 2. This means by default there's no actual definition of this in the headers, so sparse is giving the following warning:

Quoted 7 lines

lib/zstd/common/debug.c:24:5: warning: symbol 'g_debuglevel' was not declared. Should it be static?

We can use the same check as in the header to remove this if it isn't going to be used, silencing the warning and removing a small bit of unused data.

Thanks for the patch, I’ve applied it to my tree for v6.8.

Best,
Nick Terrell

Quoted 18 lines

---
lib/zstd/common/debug.c | 2 ++

1 file changed, 2 insertions(+)
lib/zstd/common/debug.c +2 -0
index bb863c9ea616..820520b93d2b 100644
@@ -21,4 +21,6 @@
 
 #include "debug.h"
 
+#if (DEBUGLEVEL>=2)
 int g_debuglevel = DEBUGLEVEL;
+#endif
Signature · 1 line
2.39.2