summaryrefslogtreecommitdiffstats
path: root/recipes-extended/xen/files/0001-tools-xenpmd-Fix-gcc10-snprintf-warning.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-extended/xen/files/0001-tools-xenpmd-Fix-gcc10-snprintf-warning.patch')
-rw-r--r--recipes-extended/xen/files/0001-tools-xenpmd-Fix-gcc10-snprintf-warning.patch60
1 files changed, 0 insertions, 60 deletions
diff --git a/recipes-extended/xen/files/0001-tools-xenpmd-Fix-gcc10-snprintf-warning.patch b/recipes-extended/xen/files/0001-tools-xenpmd-Fix-gcc10-snprintf-warning.patch
deleted file mode 100644
index 0a136c90..00000000
--- a/recipes-extended/xen/files/0001-tools-xenpmd-Fix-gcc10-snprintf-warning.patch
+++ /dev/null
@@ -1,60 +0,0 @@
1From 0dfddb2116e3757f77a691a3fe335173088d69dc Mon Sep 17 00:00:00 2001
2Message-Id: <0dfddb2116e3757f77a691a3fe335173088d69dc.1604734077.git.bertrand.marquis@arm.com>
3From: Bertrand Marquis <bertrand.marquis@arm.com>
4Date: Thu, 15 Oct 2020 10:16:09 +0100
5Subject: [PATCH] tools/xenpmd: Fix gcc10 snprintf warning
6
7Add a check for snprintf return code and ignore the entry if we get an
8error. This should in fact never happen and is more a trick to make gcc
9happy and prevent compilation errors.
10
11This is solving the following gcc warning when compiling for arm32 host
12platforms with optimization activated:
13xenpmd.c:92:37: error: '%s' directive output may be truncated writing
14between 4 and 2147483645 bytes into a region of size 271
15[-Werror=format-truncation=]
16
17This is also solving the following Debian bug:
18https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=970802
19
20Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
21Acked-by: Wei Liu <wl@xen.org>
22---
23Upstream-status: Backport from 4.15
24---
25 tools/xenpmd/xenpmd.c | 9 +++++++--
26 1 file changed, 7 insertions(+), 2 deletions(-)
27
28diff --git a/tools/xenpmd/xenpmd.c b/tools/xenpmd/xenpmd.c
29index 35fd1c931a..12b82cf43e 100644
30--- a/tools/xenpmd/xenpmd.c
31+++ b/tools/xenpmd/xenpmd.c
32@@ -102,6 +102,7 @@ FILE *get_next_battery_file(DIR *battery_dir,
33 FILE *file = 0;
34 struct dirent *dir_entries;
35 char file_name[284];
36+ int ret;
37
38 do
39 {
40@@ -111,11 +112,15 @@ FILE *get_next_battery_file(DIR *battery_dir,
41 if ( strlen(dir_entries->d_name) < 4 )
42 continue;
43 if ( battery_info_type == BIF )
44- snprintf(file_name, sizeof(file_name), BATTERY_INFO_FILE_PATH,
45+ ret = snprintf(file_name, sizeof(file_name), BATTERY_INFO_FILE_PATH,
46 dir_entries->d_name);
47 else
48- snprintf(file_name, sizeof(file_name), BATTERY_STATE_FILE_PATH,
49+ ret = snprintf(file_name, sizeof(file_name), BATTERY_STATE_FILE_PATH,
50 dir_entries->d_name);
51+ /* This should not happen but is needed to pass gcc checks */
52+ if (ret < 0)
53+ continue;
54+ file_name[sizeof(file_name) - 1] = '\0';
55 file = fopen(file_name, "r");
56 } while ( !file );
57
58--
592.17.1
60