diff options
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.patch | 60 |
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 @@ | |||
1 | From 0dfddb2116e3757f77a691a3fe335173088d69dc Mon Sep 17 00:00:00 2001 | ||
2 | Message-Id: <0dfddb2116e3757f77a691a3fe335173088d69dc.1604734077.git.bertrand.marquis@arm.com> | ||
3 | From: Bertrand Marquis <bertrand.marquis@arm.com> | ||
4 | Date: Thu, 15 Oct 2020 10:16:09 +0100 | ||
5 | Subject: [PATCH] tools/xenpmd: Fix gcc10 snprintf warning | ||
6 | |||
7 | Add a check for snprintf return code and ignore the entry if we get an | ||
8 | error. This should in fact never happen and is more a trick to make gcc | ||
9 | happy and prevent compilation errors. | ||
10 | |||
11 | This is solving the following gcc warning when compiling for arm32 host | ||
12 | platforms with optimization activated: | ||
13 | xenpmd.c:92:37: error: '%s' directive output may be truncated writing | ||
14 | between 4 and 2147483645 bytes into a region of size 271 | ||
15 | [-Werror=format-truncation=] | ||
16 | |||
17 | This is also solving the following Debian bug: | ||
18 | https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=970802 | ||
19 | |||
20 | Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com> | ||
21 | Acked-by: Wei Liu <wl@xen.org> | ||
22 | --- | ||
23 | Upstream-status: Backport from 4.15 | ||
24 | --- | ||
25 | tools/xenpmd/xenpmd.c | 9 +++++++-- | ||
26 | 1 file changed, 7 insertions(+), 2 deletions(-) | ||
27 | |||
28 | diff --git a/tools/xenpmd/xenpmd.c b/tools/xenpmd/xenpmd.c | ||
29 | index 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 | -- | ||
59 | 2.17.1 | ||
60 | |||