* [Buildroot] [PATCH 1/1] package/file: fix build with gcc 4.8
@ 2022-01-02 20:03 Fabrice Fontaine
2022-01-03 9:16 ` Yann E. MORIN
0 siblings, 1 reply; 2+ messages in thread
From: Fabrice Fontaine @ 2022-01-02 20:03 UTC (permalink / raw)
To: buildroot; +Cc: Fabrice Fontaine
Fix the following build failure raised since bump to version 5.41 in
commit d38b72bcd75392a88b5100839ac410859d0a6a79:
readelf.c: In function 'do_auxv_note':
readelf.c:1046:2: error: 'for' loop initial declarations are only allowed in C99 mode
for (size_t off = 0; off + elsize <= descsz; off += elsize) {
^
Fixes:
- http://autobuild.buildroot.org/results/31cbc313fceb84c0cbb1969fca5ac44244871dbc
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
.../file/0001-fix-build-with-gcc-4.8.patch | 97 +++++++++++++++++++
1 file changed, 97 insertions(+)
create mode 100644 package/file/0001-fix-build-with-gcc-4.8.patch
diff --git a/package/file/0001-fix-build-with-gcc-4.8.patch b/package/file/0001-fix-build-with-gcc-4.8.patch
new file mode 100644
index 0000000000..2494c6a7c0
--- /dev/null
+++ b/package/file/0001-fix-build-with-gcc-4.8.patch
@@ -0,0 +1,97 @@
+From e36455301a3757618381cb83bf17115dd386131e Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+Date: Sun, 2 Jan 2022 20:41:31 +0100
+Subject: [PATCH] fix build with gcc 4.8
+
+Fix the following build failure with gcc 4.8
+
+readelf.c: In function 'do_auxv_note':
+readelf.c:1046:2: error: 'for' loop initial declarations are only allowed in C99 mode
+ for (size_t off = 0; off + elsize <= descsz; off += elsize) {
+ ^
+
+funcs.c:93:2: error: 'for' loop initial declarations are only allowed in C99 mode
+ for (const char *p = fmt; *p; p++) {
+ ^
+
+Fixes:
+ - http://autobuild.buildroot.org/results/31cbc313fceb84c0cbb1969fca5ac44244871dbc
+
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+[Upstream status: https://bugs.astron.com/view.php?id=307]
+---
+ src/der.c | 6 ++++--
+ src/funcs.c | 3 ++-
+ src/readelf.c | 4 ++--
+ 3 files changed, 8 insertions(+), 5 deletions(-)
+
+diff --git a/src/der.c b/src/der.c
+index 4bee9f16..23b9a574 100644
+--- a/src/der.c
++++ b/src/der.c
+@@ -235,6 +235,7 @@ der_tag(char *buf, size_t len, uint32_t tag)
+ static int
+ der_data(char *buf, size_t blen, uint32_t tag, const void *q, uint32_t len)
+ {
++ uint32_t i;
+ const uint8_t *d = CAST(const uint8_t *, q);
+ switch (tag) {
+ case DER_TAG_PRINTABLE_STRING:
+@@ -251,7 +252,7 @@ der_data(char *buf, size_t blen, uint32_t tag, const void *q, uint32_t len)
+ break;
+ }
+
+- for (uint32_t i = 0; i < len; i++) {
++ for (i = 0; i < len; i++) {
+ uint32_t z = i << 1;
+ if (z < blen - 2)
+ snprintf(buf + z, blen - z, "%.2x", d[i]);
+@@ -283,7 +284,8 @@ der_offs(struct magic_set *ms, struct magic *m, size_t nbytes)
+ offs += ms->offset + m->offset;
+ DPRINTF(("cont_level = %d\n", m->cont_level));
+ #ifdef DEBUG_DER
+- for (size_t i = 0; i < m->cont_level; i++)
++ size_t i;
++ for (i = 0; i < m->cont_level; i++)
+ printf("cont_level[%" SIZE_T_FORMAT "u] = %u\n", i,
+ ms->c.li[i].off);
+ #endif
+diff --git a/src/funcs.c b/src/funcs.c
+index d968873d..08b565fb 100644
+--- a/src/funcs.c
++++ b/src/funcs.c
+@@ -90,7 +90,8 @@ file_checkfield(char *msg, size_t mlen, const char *what, const char **pp)
+ protected int
+ file_checkfmt(char *msg, size_t mlen, const char *fmt)
+ {
+- for (const char *p = fmt; *p; p++) {
++ const char *p;
++ for (p = fmt; *p; p++) {
+ if (*p != '%')
+ continue;
+ if (*++p == '%')
+diff --git a/src/readelf.c b/src/readelf.c
+index 01c60fe9..46421a2e 100644
+--- a/src/readelf.c
++++ b/src/readelf.c
+@@ -1015,7 +1015,7 @@ do_auxv_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type,
+ size_t elsize = xauxv_sizeof;
+ const char *tag;
+ int is_string;
+- size_t nval;
++ size_t nval, off;
+
+ if ((*flags & (FLAGS_IS_CORE|FLAGS_DID_CORE_STYLE)) !=
+ (FLAGS_IS_CORE|FLAGS_DID_CORE_STYLE))
+@@ -1043,7 +1043,7 @@ do_auxv_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type,
+ *flags |= FLAGS_DID_AUXV;
+
+ nval = 0;
+- for (size_t off = 0; off + elsize <= descsz; off += elsize) {
++ for (off = 0; off + elsize <= descsz; off += elsize) {
+ memcpy(xauxv_addr, &nbuf[doff + off], xauxv_sizeof);
+ /* Limit processing to 50 vector entries to prevent DoS */
+ if (nval++ >= 50) {
+--
+2.33.0
+
--
2.33.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Buildroot] [PATCH 1/1] package/file: fix build with gcc 4.8
2022-01-02 20:03 [Buildroot] [PATCH 1/1] package/file: fix build with gcc 4.8 Fabrice Fontaine
@ 2022-01-03 9:16 ` Yann E. MORIN
0 siblings, 0 replies; 2+ messages in thread
From: Yann E. MORIN @ 2022-01-03 9:16 UTC (permalink / raw)
To: Fabrice Fontaine; +Cc: buildroot
Fabrice, All,
On 2022-01-02 21:03 +0100, Fabrice Fontaine spake thusly:
> Fix the following build failure raised since bump to version 5.41 in
> commit d38b72bcd75392a88b5100839ac410859d0a6a79:
>
> readelf.c: In function 'do_auxv_note':
> readelf.c:1046:2: error: 'for' loop initial declarations are only allowed in C99 mode
> for (size_t off = 0; off + elsize <= descsz; off += elsize) {
> ^
>
> Fixes:
> - http://autobuild.buildroot.org/results/31cbc313fceb84c0cbb1969fca5ac44244871dbc
The error above explicitly states that C99 should be used to build those
files. C99 is supposedly complete in gcc 4.8, but was not the default,
hence the error.
And it seems that using C99 is what we attempted in da400ee5e1e (file:
bump to version 5.26), which added the following line:
FILE_CONF_ENV = ac_cv_prog_cc_c99='-std=gnu99'
So, why are those files not built with C99? Ha, because this is the host
variant... We should also use -std=gnu99 for the host variant.
Regards,
Yann E. MORIN.
> Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> ---
> .../file/0001-fix-build-with-gcc-4.8.patch | 97 +++++++++++++++++++
> 1 file changed, 97 insertions(+)
> create mode 100644 package/file/0001-fix-build-with-gcc-4.8.patch
>
> diff --git a/package/file/0001-fix-build-with-gcc-4.8.patch b/package/file/0001-fix-build-with-gcc-4.8.patch
> new file mode 100644
> index 0000000000..2494c6a7c0
> --- /dev/null
> +++ b/package/file/0001-fix-build-with-gcc-4.8.patch
> @@ -0,0 +1,97 @@
> +From e36455301a3757618381cb83bf17115dd386131e Mon Sep 17 00:00:00 2001
> +From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> +Date: Sun, 2 Jan 2022 20:41:31 +0100
> +Subject: [PATCH] fix build with gcc 4.8
> +
> +Fix the following build failure with gcc 4.8
> +
> +readelf.c: In function 'do_auxv_note':
> +readelf.c:1046:2: error: 'for' loop initial declarations are only allowed in C99 mode
> + for (size_t off = 0; off + elsize <= descsz; off += elsize) {
> + ^
> +
> +funcs.c:93:2: error: 'for' loop initial declarations are only allowed in C99 mode
> + for (const char *p = fmt; *p; p++) {
> + ^
> +
> +Fixes:
> + - http://autobuild.buildroot.org/results/31cbc313fceb84c0cbb1969fca5ac44244871dbc
> +
> +Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> +[Upstream status: https://bugs.astron.com/view.php?id=307]
> +---
> + src/der.c | 6 ++++--
> + src/funcs.c | 3 ++-
> + src/readelf.c | 4 ++--
> + 3 files changed, 8 insertions(+), 5 deletions(-)
> +
> +diff --git a/src/der.c b/src/der.c
> +index 4bee9f16..23b9a574 100644
> +--- a/src/der.c
> ++++ b/src/der.c
> +@@ -235,6 +235,7 @@ der_tag(char *buf, size_t len, uint32_t tag)
> + static int
> + der_data(char *buf, size_t blen, uint32_t tag, const void *q, uint32_t len)
> + {
> ++ uint32_t i;
> + const uint8_t *d = CAST(const uint8_t *, q);
> + switch (tag) {
> + case DER_TAG_PRINTABLE_STRING:
> +@@ -251,7 +252,7 @@ der_data(char *buf, size_t blen, uint32_t tag, const void *q, uint32_t len)
> + break;
> + }
> +
> +- for (uint32_t i = 0; i < len; i++) {
> ++ for (i = 0; i < len; i++) {
> + uint32_t z = i << 1;
> + if (z < blen - 2)
> + snprintf(buf + z, blen - z, "%.2x", d[i]);
> +@@ -283,7 +284,8 @@ der_offs(struct magic_set *ms, struct magic *m, size_t nbytes)
> + offs += ms->offset + m->offset;
> + DPRINTF(("cont_level = %d\n", m->cont_level));
> + #ifdef DEBUG_DER
> +- for (size_t i = 0; i < m->cont_level; i++)
> ++ size_t i;
> ++ for (i = 0; i < m->cont_level; i++)
> + printf("cont_level[%" SIZE_T_FORMAT "u] = %u\n", i,
> + ms->c.li[i].off);
> + #endif
> +diff --git a/src/funcs.c b/src/funcs.c
> +index d968873d..08b565fb 100644
> +--- a/src/funcs.c
> ++++ b/src/funcs.c
> +@@ -90,7 +90,8 @@ file_checkfield(char *msg, size_t mlen, const char *what, const char **pp)
> + protected int
> + file_checkfmt(char *msg, size_t mlen, const char *fmt)
> + {
> +- for (const char *p = fmt; *p; p++) {
> ++ const char *p;
> ++ for (p = fmt; *p; p++) {
> + if (*p != '%')
> + continue;
> + if (*++p == '%')
> +diff --git a/src/readelf.c b/src/readelf.c
> +index 01c60fe9..46421a2e 100644
> +--- a/src/readelf.c
> ++++ b/src/readelf.c
> +@@ -1015,7 +1015,7 @@ do_auxv_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type,
> + size_t elsize = xauxv_sizeof;
> + const char *tag;
> + int is_string;
> +- size_t nval;
> ++ size_t nval, off;
> +
> + if ((*flags & (FLAGS_IS_CORE|FLAGS_DID_CORE_STYLE)) !=
> + (FLAGS_IS_CORE|FLAGS_DID_CORE_STYLE))
> +@@ -1043,7 +1043,7 @@ do_auxv_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type,
> + *flags |= FLAGS_DID_AUXV;
> +
> + nval = 0;
> +- for (size_t off = 0; off + elsize <= descsz; off += elsize) {
> ++ for (off = 0; off + elsize <= descsz; off += elsize) {
> + memcpy(xauxv_addr, &nbuf[doff + off], xauxv_sizeof);
> + /* Limit processing to 50 vector entries to prevent DoS */
> + if (nval++ >= 50) {
> +--
> +2.33.0
> +
> --
> 2.33.0
>
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-03 9:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-02 20:03 [Buildroot] [PATCH 1/1] package/file: fix build with gcc 4.8 Fabrice Fontaine
2022-01-03 9:16 ` Yann E. MORIN
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox