Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] package/xen: fix build with gcc 8.1
@ 2019-03-09  8:18 Fabrice Fontaine
  2019-03-09 14:15 ` Thomas Petazzoni
  2019-03-25 16:28 ` Peter Korsgaard
  0 siblings, 2 replies; 3+ messages in thread
From: Fabrice Fontaine @ 2019-03-09  8:18 UTC (permalink / raw)
  To: buildroot

Fixes:
 - http://autobuild.buildroot.org/results/df5abe6ca8b4c8935f3d5c257aef816190771200

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
 ...-32-bit-gcc-8-1-non-debug-build-work.patch | 79 +++++++++++++++++++
 1 file changed, 79 insertions(+)
 create mode 100644 package/xen/0004-xenpmd-make-32-bit-gcc-8-1-non-debug-build-work.patch

diff --git a/package/xen/0004-xenpmd-make-32-bit-gcc-8-1-non-debug-build-work.patch b/package/xen/0004-xenpmd-make-32-bit-gcc-8-1-non-debug-build-work.patch
new file mode 100644
index 0000000000..9c51c554cd
--- /dev/null
+++ b/package/xen/0004-xenpmd-make-32-bit-gcc-8-1-non-debug-build-work.patch
@@ -0,0 +1,79 @@
+From e75c9dc85fdeeeda0b98d8cd8d784e0508c3ffb8 Mon Sep 17 00:00:00 2001
+From: Wei Liu <wei.liu2@citrix.com>
+Date: Thu, 26 Jul 2018 15:58:54 +0100
+Subject: [PATCH] xenpmd: make 32 bit gcc 8.1 non-debug build work
+
+32 bit gcc 8.1 non-debug build yields:
+
+xenpmd.c:354:23: error: '%02x' directive output may be truncated writing between 2 and 8 bytes into a region of size 3 [-Werror=format-truncation=]
+     snprintf(val, 3, "%02x",
+                       ^~~~
+xenpmd.c:354:22: note: directive argument in the range [40, 2147483778]
+     snprintf(val, 3, "%02x",
+                      ^~~~~~
+xenpmd.c:354:5: note: 'snprintf' output between 3 and 9 bytes into a destination of size 3
+     snprintf(val, 3, "%02x",
+     ^~~~~~~~~~~~~~~~~~~~~~~~
+              (unsigned int)(9*4 +
+              ~~~~~~~~~~~~~~~~~~~~
+                             strlen(info->model_number) +
+                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+                             strlen(info->serial_number) +
+                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+                             strlen(info->battery_type) +
+                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+                             strlen(info->oem_info) + 4));
+                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+All info->* used in calculation are 32 bytes long, and the parsing
+code makes sure they are null-terminated, so the end result of the
+expression won't exceed 255, which should be able to be fit into 3
+bytes in hexadecimal format.
+
+Add an assertion to make gcc happy.
+
+Signed-off-by: Wei Liu <wei.liu2@citrix.com>
+Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+[Retrieved from:
+https://github.com/xen-project/xen/commit/e75c9dc85fdeeeda0b98d8cd8d784e0508c3ffb8]
+---
+ tools/xenpmd/xenpmd.c | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/tools/xenpmd/xenpmd.c b/tools/xenpmd/xenpmd.c
+index 56412a9a81c..1c801caa712 100644
+--- a/tools/xenpmd/xenpmd.c
++++ b/tools/xenpmd/xenpmd.c
+@@ -40,6 +40,7 @@
+ #include <unistd.h>
+ #include <sys/stat.h>
+ #include <xenstore.h>
++#include <assert.h>
+ 
+ /* #define RUN_STANDALONE */
+ #define RUN_IN_SIMULATE_MODE
+@@ -345,18 +346,17 @@ void write_ulong_lsb_first(char *temp_val, unsigned long val)
+ void write_battery_info_to_xenstore(struct battery_info *info)
+ {
+     char val[1024], string_info[256];
++    unsigned int len;
+ 
+     xs_mkdir(xs, XBT_NULL, "/pm");
+    
+     memset(val, 0, 1024);
+     memset(string_info, 0, 256);
+     /* write 9 dwords (so 9*4) + length of 4 strings + 4 null terminators */
+-    snprintf(val, 3, "%02x", 
+-             (unsigned int)(9*4 +
+-                            strlen(info->model_number) +
+-                            strlen(info->serial_number) +
+-                            strlen(info->battery_type) +
+-                            strlen(info->oem_info) + 4));
++    len = 9 * 4 + strlen(info->model_number) + strlen(info->serial_number) +
++          strlen(info->battery_type) + strlen(info->oem_info) + 4;
++    assert(len < 255);
++    snprintf(val, 3, "%02x", len);
+     write_ulong_lsb_first(val+2, info->present);
+     write_ulong_lsb_first(val+10, info->design_capacity);
+     write_ulong_lsb_first(val+18, info->last_full_capacity);
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH 1/1] package/xen: fix build with gcc 8.1
  2019-03-09  8:18 [Buildroot] [PATCH 1/1] package/xen: fix build with gcc 8.1 Fabrice Fontaine
@ 2019-03-09 14:15 ` Thomas Petazzoni
  2019-03-25 16:28 ` Peter Korsgaard
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Petazzoni @ 2019-03-09 14:15 UTC (permalink / raw)
  To: buildroot

On Sat,  9 Mar 2019 09:18:32 +0100
Fabrice Fontaine <fontaine.fabrice@gmail.com> wrote:

> Fixes:
>  - http://autobuild.buildroot.org/results/df5abe6ca8b4c8935f3d5c257aef816190771200
> 
> Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> ---
>  ...-32-bit-gcc-8-1-non-debug-build-work.patch | 79 +++++++++++++++++++
>  1 file changed, 79 insertions(+)
>  create mode 100644 package/xen/0004-xenpmd-make-32-bit-gcc-8-1-non-debug-build-work.patch

Applied to master, thanks.

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH 1/1] package/xen: fix build with gcc 8.1
  2019-03-09  8:18 [Buildroot] [PATCH 1/1] package/xen: fix build with gcc 8.1 Fabrice Fontaine
  2019-03-09 14:15 ` Thomas Petazzoni
@ 2019-03-25 16:28 ` Peter Korsgaard
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2019-03-25 16:28 UTC (permalink / raw)
  To: buildroot

>>>>> "Fabrice" == Fabrice Fontaine <fontaine.fabrice@gmail.com> writes:

 > Fixes:
 >  - http://autobuild.buildroot.org/results/df5abe6ca8b4c8935f3d5c257aef816190771200

 > Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

Committed to 2018.11.x and 2019.02.x, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-25 16:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-09  8:18 [Buildroot] [PATCH 1/1] package/xen: fix build with gcc 8.1 Fabrice Fontaine
2019-03-09 14:15 ` Thomas Petazzoni
2019-03-25 16:28 ` Peter Korsgaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox