Skip to contentSkip to conversation

init/version.c: Silenced sparse warning by declaring the version string.

PATCH In review Daniel Guilak 4 participants 10 messages Jul 8, 2008 – Jul 14, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 init/version.c: Silenced sparse warning by declaring the version string.

---
 init/version.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
init/version.c +1 -0
index 9d17d70..041fd82 100644
@@ -16,6 +16,7 @@
 #define version(a) Version_ ## a
 #define version_string(a) version(a)
 
+extern int version_string(LINUX_VERSION_CODE);
 int version_string(LINUX_VERSION_CODE);
 
 struct uts_namespace init_uts_ns = {
Signature · 1 line
1.5.4.3
Acked-by on v1 1/1
#1 lore raw
Quoted 1 line · Daniel Guilak

Looks reasonable.

Quoted 16 lines
---
 init/version.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
init/version.c +1 -0
index 9d17d70..041fd82 100644
@@ -16,6 +16,7 @@
 #define version(a) Version_ ## a
 #define version_string(a) version(a)
 
+extern int version_string(LINUX_VERSION_CODE);
 int version_string(LINUX_VERSION_CODE);
 
 struct uts_namespace init_uts_ns = {
#2 lore raw
In reply to Daniel Guilak
Quoted 1 line · On Tue, 08 Jul 2008 14:21:09 -0700 Daniel Guilak <[email protected]>…

Please always quote the warning or error message in the changelog when fixing it. Although it's pretty obvious in this case.

Quoted 8 lines
 init/version.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
init/version.c +0 -0
index 9d17d70..041fd82 100644

init/version.c line 22

Quoted 7 lines
init/version.c +1 -0
@@ -16,6 +16,7 @@
 #define version(a) Version_ ## a
 #define version_string(a) version(a)
 
+extern int version_string(LINUX_VERSION_CODE);
 int version_string(LINUX_VERSION_CODE);
 
 struct uts_namespace init_uts_ns = {

hrm, what does this thing do? Seems to define

int Version_132634;

Then sticks that in the symbol table (and wastes a bit of bss).

Does anything use it?

Could it be made static?

#3 lore raw
Quoted 25 lines · Andrew Morton
Quoted 1 line · On Tue, 08 Jul 2008 14:21:09 -0700 Daniel Guilak <[email protected]>…

Please always quote the warning or error message in the changelog when fixing it. Although it's pretty obvious in this case.

Quoted 8 lines
 init/version.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
init/version.c +0 -0
index 9d17d70..041fd82 100644

init/version.c line 22

Quoted 7 lines
init/version.c +1 -0
@@ -16,6 +16,7 @@
 #define version(a) Version_ ## a
 #define version_string(a) version(a)
 
+extern int version_string(LINUX_VERSION_CODE);
 int version_string(LINUX_VERSION_CODE);
 
 struct uts_namespace init_uts_ns = {

hrm, what does this thing do? Seems to define

Quoted 9 lines

int Version_132634;

Then sticks that in the symbol table (and wastes a bit of bss).

Does anything use it?

Could it be made static?

Apparently it's only used by the ksymoops tool, which is not needed if (according to README) the kernel is configured with CONFIG_KALLSYMS.

So I will submit a patch depending on this one that will define version_string only if CONFIG_KALLSYMS is not defined, and hopefully that will deal with the problem.

--Daniel Guilak

#4 lore raw

PATCH 1/1 init/version.c: Define version_string only if CONFIG_KALLSYMS is not defined.

In reply to Daniel Guilak

int Version_* is only used with ksymoops, which is only needed (according to README and Documentation/Changes) if CONFIG_KALLSYMS is NOT defined. Therefore this patch defines version_string only if CONFIG_KALLSYMS is not defined.

---
 init/version.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Depends on "[PATCH] init/version.c: Silenced sparse warning by declaring the version string."

init/version.c +2 -0
index 041fd82..52a8b98 100644
@@ -13,11 +13,13 @@
 #include <linux/utsrelease.h>
 #include <linux/version.h>
 
+#ifndef CONFIG_KALLSYMS
 #define version(a) Version_ ## a
 #define version_string(a) version(a)
 
 extern int version_string(LINUX_VERSION_CODE);
 int version_string(LINUX_VERSION_CODE);
+#endif
 
 struct uts_namespace init_uts_ns = {
 	.kref = {
Signature · 1 line
1.5.4.3
#5 lore raw

Re: [PATCH] init/version.c: Define version_string only if CONFIG_KALLSYMS is not defined.

Quoted 20 lines · On Mon, 14 Jul 2008 12:04:46 -0700 Daniel Guilak wrote:

int Version_* is only used with ksymoops, which is only needed (according to README and Documentation/Changes) if CONFIG_KALLSYMS is NOT defined. Therefore this patch defines version_string only if CONFIG_KALLSYMS is not defined.

---
 init/version.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Depends on "[PATCH] init/version.c: Silenced sparse warning by declaring the version string."

init/version.c +0 -0
index 041fd82..52a8b98 100644
@@ -13,11 +13,13 @@
 #include <linux/utsrelease.h>
 #include <linux/version.h>
 

init/version.c line 25

Quoted 10 lines
init/version.c +2 -0
+#ifndef CONFIG_KALLSYMS
 #define version(a) Version_ ## a
 #define version_string(a) version(a)
 
 extern int version_string(LINUX_VERSION_CODE);
 int version_string(LINUX_VERSION_CODE);
+#endif
 
 struct uts_namespace init_uts_ns = {
 	.kref = {

Does not apply cleanly to linux-2.6.26, linux-next-20080714, or Linus-git-head.

and why do we ned both extern int version_string() and int version_string() ?

---
~Randy
Linux Plumbers Conference, 17-19 September 2008, Portland, Oregon USA
http://linuxplumbersconf.org/

#6 lore raw

Re: [PATCH] init/version.c: Define version_string only if CONFIG_KALLSYMS is not defined.

Quoted 29 lines · Randy Dunlap
Quoted 27 lines · On Mon, 14 Jul 2008 12:04:46 -0700 Daniel Guilak wrote:

int Version_* is only used with ksymoops, which is only needed (according to README and Documentation/Changes) if CONFIG_KALLSYMS is NOT defined. Therefore this patch defines version_string only if CONFIG_KALLSYMS is not defined.

---
 init/version.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Depends on "[PATCH] init/version.c: Silenced sparse warning by declaring the version string."

init/version.c +2 -0
index 041fd82..52a8b98 100644
@@ -13,11 +13,13 @@
 #include <linux/utsrelease.h>
 #include <linux/version.h>
 
+#ifndef CONFIG_KALLSYMS
 #define version(a) Version_ ## a
 #define version_string(a) version(a)
 
 extern int version_string(LINUX_VERSION_CODE);
 int version_string(LINUX_VERSION_CODE);
+#endif
 
Quoted 6 lines

init/version.c line 25

Quoted 3 lines
init/version.c +0 -0
 struct uts_namespace init_uts_ns = {
 	.kref = {

Does not apply cleanly to linux-2.6.26, linux-next-20080714, or Linus-git-head.

Did you apply "[PATCH] init/version.c: Silenced sparse warning by declaring the version string." beforehand? I just applied it on the most recent tree and I didn't have any issues.

Quoted 2 lines

and why do we ned both extern int version_string() and int version_string() ?

Because sparse was complaining that it wasn't prototyped or static. There isn't a header file to put it in since it only exists to be a kernel.

Quoted 4 lines

---
~Randy
Linux Plumbers Conference, 17-19 September 2008, Portland, Oregon USA
http://linuxplumbersconf.org/

--Daniel

#7 lore raw

Re: [PATCH] init/version.c: Define version_string only if CONFIG_KALLSYMS is not defined.

Quoted 41 lines · Daniel Guilak
Quoted 29 lines · Randy Dunlap
Quoted 27 lines · On Mon, 14 Jul 2008 12:04:46 -0700 Daniel Guilak wrote:

int Version_* is only used with ksymoops, which is only needed (according to README and Documentation/Changes) if CONFIG_KALLSYMS is NOT defined. Therefore this patch defines version_string only if CONFIG_KALLSYMS is not defined.

---
 init/version.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Depends on "[PATCH] init/version.c: Silenced sparse warning by declaring the version string."

init/version.c +2 -0
index 041fd82..52a8b98 100644
@@ -13,11 +13,13 @@
 #include <linux/utsrelease.h>
 #include <linux/version.h>
 
+#ifndef CONFIG_KALLSYMS
 #define version(a) Version_ ## a
 #define version_string(a) version(a)
 
 extern int version_string(LINUX_VERSION_CODE);
 int version_string(LINUX_VERSION_CODE);
+#endif
 
Quoted 6 lines

init/version.c line 25

Quoted 3 lines
init/version.c +0 -0
 struct uts_namespace init_uts_ns = {
 	.kref = {

Does not apply cleanly to linux-2.6.26, linux-next-20080714, or Linus-git-head.

Did you apply "[PATCH] init/version.c: Silenced sparse warning by declaring the version string." beforehand? I just applied it on the most recent tree and I didn't have any issues.

Quoted 5 lines
Quoted 2 lines

and why do we ned both extern int version_string() and int version_string() ?

Because sparse was complaining that it wasn't prototyped or static. There isn't a header file to put it in since it only exists to be a kernel.

"Symbol", not "kernel", sorry.

Quoted 6 lines
Quoted 4 lines

---
~Randy
Linux Plumbers Conference, 17-19 September 2008, Portland, Oregon USA
http://linuxplumbersconf.org/

--Daniel

#8 lore raw

Re: [PATCH] init/version.c: Define version_string only if CONFIG_KALLSYMS is not defined.

In reply to Daniel Guilak
Quoted 37 lines · On Mon, 14 Jul 2008 14:20:38 -0700 Daniel Guilak wrote:
Quoted 29 lines · Randy Dunlap
Quoted 27 lines · On Mon, 14 Jul 2008 12:04:46 -0700 Daniel Guilak wrote:

int Version_* is only used with ksymoops, which is only needed (according to README and Documentation/Changes) if CONFIG_KALLSYMS is NOT defined. Therefore this patch defines version_string only if CONFIG_KALLSYMS is not defined.

---
 init/version.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Depends on "[PATCH] init/version.c: Silenced sparse warning by declaring the version string."

init/version.c +2 -0
index 041fd82..52a8b98 100644
@@ -13,11 +13,13 @@
 #include <linux/utsrelease.h>
 #include <linux/version.h>
 
+#ifndef CONFIG_KALLSYMS
 #define version(a) Version_ ## a
 #define version_string(a) version(a)
 
 extern int version_string(LINUX_VERSION_CODE);
 int version_string(LINUX_VERSION_CODE);
+#endif
 
Quoted 6 lines

init/version.c line 25

Quoted 3 lines
init/version.c +0 -0
 struct uts_namespace init_uts_ns = {
 	.kref = {

Does not apply cleanly to linux-2.6.26, linux-next-20080714, or Linus-git-head.

Quoted 3 lines

Did you apply "[PATCH] init/version.c: Silenced sparse warning by declaring the version string." beforehand? I just applied it on the most recent tree and I didn't have any issues.

Clearly I didn't apply that patch. I missed anything saying that this was patch 2/2 in a dependent series.

Quoted 5 lines
Quoted 2 lines

and why do we ned both extern int version_string() and int version_string() ?

Because sparse was complaining that it wasn't prototyped or static. There isn't a header file to put it in since it only exists to be a kernel.

so the extern makes it be published in the symbol table, whereas a static would keep it private. Is that correct?

and the second line (int version_string(LINUX_VERSION_CODE)) actually defines it.

---
~Randy
Linux Plumbers Conference, 17-19 September 2008, Portland, Oregon USA
http://linuxplumbersconf.org/

#9 lore raw

Re: [PATCH] init/version.c: Define version_string only if CONFIG_KALLSYMS is not defined.

Quoted 39 lines · Randy Dunlap
Quoted 37 lines · On Mon, 14 Jul 2008 14:20:38 -0700 Daniel Guilak wrote:
Quoted 35 lines · Randy Dunlap
Quoted 20 lines · On Mon, 14 Jul 2008 12:04:46 -0700 Daniel Guilak wrote:

int Version_* is only used with ksymoops, which is only needed (according to README and Documentation/Changes) if CONFIG_KALLSYMS is NOT defined. Therefore this patch defines version_string only if CONFIG_KALLSYMS is not defined.

---
 init/version.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Depends on "[PATCH] init/version.c: Silenced sparse warning by declaring the version string."

init/version.c +0 -0
index 041fd82..52a8b98 100644
@@ -13,11 +13,13 @@
 #include <linux/utsrelease.h>
 #include <linux/version.h>
 

init/version.c line 25

Quoted 10 lines
init/version.c +2 -0
+#ifndef CONFIG_KALLSYMS
 #define version(a) Version_ ## a
 #define version_string(a) version(a)
 
 extern int version_string(LINUX_VERSION_CODE);
 int version_string(LINUX_VERSION_CODE);
+#endif
 
 struct uts_namespace init_uts_ns = {
 	.kref = {

Does not apply cleanly to linux-2.6.26, linux-next-20080714, or Linus-git-head.

Quoted 6 lines
Quoted 3 lines

Did you apply "[PATCH] init/version.c: Silenced sparse warning by declaring the version string." beforehand? I just applied it on the most recent tree and I didn't have any issues.

Clearly I didn't apply that patch. I missed anything saying that this was patch 2/2 in a dependent series.

Sorry about that, I should have been a bit more clear with it. Next time I'll make sure to state that in the subject line. I stated the dependency right before the diff message.

Quoted 11 lines
Quoted 5 lines
Quoted 2 lines

and why do we ned both extern int version_string() and int version_string() ?

Because sparse was complaining that it wasn't prototyped or static. There isn't a header file to put it in since it only exists to be a kernel.

so the extern makes it be published in the symbol table, whereas a static would keep it private. Is that correct?

and the second line (int version_string(LINUX_VERSION_CODE)) actually defines it.

Yes, that's exactly the idea behind it.

--Daniel