Skip to contentSkip to conversation

arch: x86: entry: vdso: fix type conversion on printf() call

PATCH In review Enrico Weigelt, metux IT consult 4 participants 7 messages Dec 15, 2020

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

PATCH 1/1 arch: x86: entry: vdso: fix type conversion on printf() call

Fixing the following compiler warning by explicit conversion to long:

In file included from /home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.c:162:0:
/home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.h: In function 'extract64':
/home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.h:38:52: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t {aka unsigned int}' [-Wformat=]
fprintf(outfile, "static const unsigned char %s[%lu] = {", name, len);

                                                    ^

CC mm/filemap.o
In file included from /home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.c:166:0:
/home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.h: In function 'extract32':
/home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.h:38:52: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t {aka unsigned int}' [-Wformat=]
fprintf(outfile, "static const unsigned char %s[%lu] = {", name, len);

---
 arch/x86/entry/vdso/vdso2c.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/entry/vdso/vdso2c.h +2 -1
index 1c7cfac7e64a..5c6a4bbc63f9 100644
@@ -35,7 +35,8 @@ static void BITSFUNC(extract)(const unsigned char *data, size_t data_len,
 	if (offset + len > data_len)
 		fail("section to extract overruns input data");
 
-	fprintf(outfile, "static const unsigned char %s[%lu] = {", name, len);
+	fprintf(outfile, "static const unsigned char %s[%lu] = {", name,
+		(unsigned long)len);
 	BITSFUNC(copy)(outfile, data + offset, len);
 	fprintf(outfile, "\n};\n\n");
 }
Signature · 1 line
2.11.0
maintainer
#1 lore raw
Quoted 24 lines · metux IT consult

Fixing the following compiler warning by explicit conversion to long:

In file included from /home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.c:162:0:
/home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.h: In function 'extract64':
/home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.h:38:52: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t {aka unsigned int}' [-Wformat=]
fprintf(outfile, "static const unsigned char %s[%lu] = {", name, len);

                                                    ^

CC mm/filemap.o
In file included from /home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.c:166:0:
/home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.h: In function 'extract32':
/home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.h:38:52: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t {aka unsigned int}' [-Wformat=]
fprintf(outfile, "static const unsigned char %s[%lu] = {", name, len);

---
 arch/x86/entry/vdso/vdso2c.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/entry/vdso/vdso2c.h +0 -0
index 1c7cfac7e64a..5c6a4bbc63f9 100644

arch/x86/entry/vdso/vdso2c.h static void BITSFUNC(extract)(const unsigned char *data, size_t data_len, · line 39

Quoted 6 lines
arch/x86/entry/vdso/vdso2c.h +2 -1
@@ -35,7 +35,8 @@ static void BITSFUNC(extract)(const unsigned char *data, size_t data_len,
        if (offset + len > data_len)
                fail("section to extract overruns input data");
 
-       fprintf(outfile, "static const unsigned char %s[%lu] = {", name, len);
+       fprintf(outfile, "static const unsigned char %s[%lu] = {", name,
+               (unsigned long)len);

This would be nicer if you put the line break after the equal sign and before the {.

--Andy

#2 lore raw
In reply to Enrico Weigelt, metux IT consult
Quoted 13 lines · metux IT consult

Fixing the following compiler warning by explicit conversion to long:

In file included from /home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.c:162:0:
/home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.h: In function 'extract64':
/home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.h:38:52: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t {aka unsigned int}' [-Wformat=]
fprintf(outfile, "static const unsigned char %s[%lu] = {", name, len);

                                                    ^

CC mm/filemap.o
In file included from /home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.c:166:0:
/home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.h: In function 'extract32':
/home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.h:38:52: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t {aka unsigned int}' [-Wformat=]
fprintf(outfile, "static const unsigned char %s[%lu] = {", name, len);

Quoted 4 lines
---
 arch/x86/entry/vdso/vdso2c.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Hi,

size_t is normally printed with %zu.
Is there some reason that isn't being used here?

Quoted 6 lines
arch/x86/entry/vdso/vdso2c.h +0 -0
index 1c7cfac7e64a..5c6a4bbc63f9 100644

arch/x86/entry/vdso/vdso2c.h static void BITSFUNC(extract)(const unsigned char *data, size_t data_len, · line 42

Quoted 9 lines
arch/x86/entry/vdso/vdso2c.h +2 -1
@@ -35,7 +35,8 @@ static void BITSFUNC(extract)(const unsigned char *data, size_t data_len,
 	if (offset + len > data_len)
 		fail("section to extract overruns input data");
 
-	fprintf(outfile, "static const unsigned char %s[%lu] = {", name, len);
+	fprintf(outfile, "static const unsigned char %s[%lu] = {", name,
+		(unsigned long)len);
 	BITSFUNC(copy)(outfile, data + offset, len);
 	fprintf(outfile, "\n};\n\n");
 }

thanks.

Signature · 1 line
~Randy
maintainer
#3 lore raw
Quoted 20 lines · Randy Dunlap
Quoted 13 lines · metux IT consult

Fixing the following compiler warning by explicit conversion to long:

In file included from /home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.c:162:0:
/home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.h: In function 'extract64':
/home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.h:38:52: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t {aka unsigned int}' [-Wformat=]
fprintf(outfile, "static const unsigned char %s[%lu] = {", name, len);

                                                    ^

CC mm/filemap.o
In file included from /home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.c:166:0:
/home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.h: In function 'extract32':
/home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.h:38:52: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t {aka unsigned int}' [-Wformat=]
fprintf(outfile, "static const unsigned char %s[%lu] = {", name, len);

Quoted 4 lines
---
 arch/x86/entry/vdso/vdso2c.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 4 lines

Hi,

size_t is normally printed with %zu.
Is there some reason that isn't being used here?

No. Want to send a patch?

#4 lore raw
Quoted 21 lines · Andy Lutomirski
Quoted 20 lines · Randy Dunlap
Quoted 17 lines · metux IT consult

Fixing the following compiler warning by explicit conversion to long:

In file included from /home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.c:162:0:
/home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.h: In function 'extract64':
/home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.h:38:52: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t {aka unsigned int}' [-Wformat=]
fprintf(outfile, "static const unsigned char %s[%lu] = {", name, len);

                                                    ^

CC mm/filemap.o
In file included from /home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.c:166:0:
/home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.h: In function 'extract32':
/home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.h:38:52: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t {aka unsigned int}' [-Wformat=]
fprintf(outfile, "static const unsigned char %s[%lu] = {", name, len);

---
 arch/x86/entry/vdso/vdso2c.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 7 lines
Quoted 4 lines

Hi,

size_t is normally printed with %zu.
Is there some reason that isn't being used here?

No. Want to send a patch?

I was hoping that Enrico would fix this and maybe address your other comment, although I'm not so sure that I agree with it.

Signature · 1 line
~Randy
maintainer
#5 lore raw
Quoted 25 lines · Randy Dunlap
Quoted 23 lines · Andy Lutomirski
Quoted 22 lines · Randy Dunlap
Quoted 13 lines · metux IT consult

Fixing the following compiler warning by explicit conversion to long:

In file included from /home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.c:162:0:
/home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.h: In function 'extract64':
/home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.h:38:52: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t {aka unsigned int}' [-Wformat=]
fprintf(outfile, "static const unsigned char %s[%lu] = {", name, len);

                                                    ^

CC mm/filemap.o
In file included from /home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.c:166:0:
/home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.h: In function 'extract32':
/home/nekrad/src/apu2-dev/pkg/kernel.apu2.git/arch/x86/entry/vdso/vdso2c.h:38:52: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t {aka unsigned int}' [-Wformat=]
fprintf(outfile, "static const unsigned char %s[%lu] = {", name, len);

Quoted 4 lines
---
 arch/x86/entry/vdso/vdso2c.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Hi,

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

size_t is normally printed with %zu.
Is there some reason that isn't being used here?

No. Want to send a patch?

I was hoping that Enrico would fix this and maybe address your other comment, although I'm not so sure that I agree with it.

Using %zu would get rid of the line break entirely. Enrico?

Quoted 4 lines

--
~Randy

#6 lore raw
Quoted 10 lines · Andy Lutomirski
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

size_t is normally printed with %zu.
Is there some reason that isn't being used here?

No. Want to send a patch?

I was hoping that Enrico would fix this and maybe address your other comment, although I'm not so sure that I agree with it.

Using %zu would get rid of the line break entirely. Enrico?

you're both rigth. I'll send a v2 of the patch

--mtx

Signature · 8 lines
---
Hinweis: unverschlüsselte E-Mails können leicht abgehört und manipuliert
werden ! Für eine vertrauliche Kommunikation senden Sie bitte ihren
GPG/PGP-Schlüssel zu.
---
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
[email protected] -- +49-151-27565287