fix build failed with gcc 10
This commit is contained in:
parent
890d4bbeb5
commit
68652c90f3
35
backport-Fix-maybe-uninitialized-warning.patch
Normal file
35
backport-Fix-maybe-uninitialized-warning.patch
Normal file
@ -0,0 +1,35 @@
|
||||
From 99d10a31cee89eb45ac0743f484018d36500ce66 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Mon, 10 Feb 2020 20:08:42 +0100
|
||||
Subject: [PATCH] Fix maybe-uninitialized warning
|
||||
|
||||
GCC gives the following compile warning:
|
||||
|
||||
grubby.c: In function 'suseGrubConfGetBoot':
|
||||
grubby.c:2770:5: error: 'grubDevice' may be used uninitialized in this function [-Werror=maybe-uninitialized]
|
||||
2770 | free(grubDevice);
|
||||
| ^~~~~~~~~~~~~~~~
|
||||
cc1: all warnings being treated as errors
|
||||
make: *** [Makefile:38: grubby.o] Error 1
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
---
|
||||
grubby.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/grubby.c b/grubby.c
|
||||
index 5de935d..74befea 100644
|
||||
--- a/grubby.c
|
||||
+++ b/grubby.c
|
||||
@@ -2896,7 +2896,7 @@ int grubGetBootFromDeviceMap(const char * device,
|
||||
}
|
||||
|
||||
int suseGrubConfGetBoot(const char * path, char ** bootPtr) {
|
||||
- char * grubDevice;
|
||||
+ char * grubDevice = NULL;
|
||||
|
||||
if (suseGrubConfGetInstallDevice(path, &grubDevice))
|
||||
dbgPrintf("error looking for grub installation device\n");
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
73
backport-Fix-stringop-overflow-warning.patch
Normal file
73
backport-Fix-stringop-overflow-warning.patch
Normal file
@ -0,0 +1,73 @@
|
||||
From c693d9d1f7b0ee4d5fa5fbbeafce3a9fbacbce52 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Mon, 10 Feb 2020 18:15:26 +0100
|
||||
Subject: [PATCH] Fix stringop-overflow warning
|
||||
|
||||
GCC gives the following compile warning:
|
||||
|
||||
grubby.c: In function 'main':
|
||||
grubby.c:4508:27: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
|
||||
4508 | saved_command_line[0] = '\0';
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~
|
||||
grubby.c:4503:26: note: at offset 0 to an object with size 0 allocated by 'malloc' here
|
||||
4503 | saved_command_line = malloc(i);
|
||||
| ^~~~~~~~~
|
||||
cc1: all warnings being treated as errors
|
||||
make: *** [Makefile:38: grubby.o] Error 1
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
---
|
||||
grubby.c | 33 ++++++++++++++++++---------------
|
||||
1 file changed, 18 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/grubby.c b/grubby.c
|
||||
index b8115dd..5de935d 100644
|
||||
--- a/grubby.c
|
||||
+++ b/grubby.c
|
||||
@@ -4675,24 +4675,27 @@ int main(int argc, const char ** argv) {
|
||||
int i = 0;
|
||||
for (int j = 1; j < argc; j++)
|
||||
i += strlen(argv[j]) + 1;
|
||||
- saved_command_line = malloc(i);
|
||||
- if (!saved_command_line) {
|
||||
- fprintf(stderr, "grubby: %m\n");
|
||||
- exit(1);
|
||||
- }
|
||||
- saved_command_line[0] = '\0';
|
||||
- int cmdline_len = 0, arg_len;
|
||||
- for (int j = 1; j < argc; j++) {
|
||||
- arg_len = strlen(argv[j]);
|
||||
- memcpy(saved_command_line + cmdline_len, argv[j], arg_len);
|
||||
- cmdline_len += arg_len;
|
||||
- if (j != argc - 1) {
|
||||
- memcpy(saved_command_line + cmdline_len, " ", 1);
|
||||
- cmdline_len++;
|
||||
- }
|
||||
+ if (i > 0) {
|
||||
+ saved_command_line = malloc(i);
|
||||
+ if (!saved_command_line) {
|
||||
+ fprintf(stderr, "grubby: %m\n");
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
+ saved_command_line[0] = '\0';
|
||||
+ int cmdline_len = 0, arg_len;
|
||||
+ for (int j = 1; j < argc; j++) {
|
||||
+ arg_len = strlen(argv[j]);
|
||||
+ memcpy(saved_command_line + cmdline_len, argv[j], arg_len);
|
||||
+ cmdline_len += arg_len;
|
||||
+ if (j != argc - 1) {
|
||||
+ memcpy(saved_command_line + cmdline_len, " ", 1);
|
||||
+ cmdline_len++;
|
||||
+ }
|
||||
+ }
|
||||
+ saved_command_line[cmdline_len] = '\0';
|
||||
|
||||
}
|
||||
- saved_command_line[cmdline_len] = '\0';
|
||||
|
||||
optCon = poptGetContext("grubby", argc, argv, options, 0);
|
||||
poptReadDefaultConfig(optCon, 1);
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: grubby
|
||||
Version: 8.40
|
||||
Release: 27
|
||||
Release: 28
|
||||
Summary: Update and display information about the configuration files
|
||||
License: GPLv2+
|
||||
URL: https://github.com/rhinstaller/grubby
|
||||
@ -30,6 +30,8 @@ Patch6012: Fix-GCC-warnings-about-possible-string-truncations-a.patch
|
||||
Patch6013: Check-that-pointers-are-not-NULL-before-dereferencin.patch
|
||||
Patch6014: Print-default-image-even-if-isn-t-a-suitable-one.patch
|
||||
Patch6015: backport-Make-SET_VARIABLE-get-handled-individually-in-GetNex.patch
|
||||
Patch6016: backport-Fix-stringop-overflow-warning.patch
|
||||
Patch6017: backport-Fix-maybe-uninitialized-warning.patch
|
||||
|
||||
Patch9001: fix-make-test-fail-when-no-boot-partition.patch
|
||||
Patch9002: Fix-make-test-fail-for-g2-1.15.patch
|
||||
@ -107,6 +109,10 @@ sed -e "s,@@LIBEXECDIR@@,%{_libexecdir}/installkernel,g" %{SOURCE3} > %{buildroo
|
||||
%{_mandir}/man8/*.8*
|
||||
|
||||
%changelog
|
||||
* Fri Jul 30 2021 yangzhuangzhuang <yangzhuangzhuang1@huawei.com> - 8.40-28
|
||||
- Fix stringop-overflow warning
|
||||
- Fix maybe-uninitialized warning
|
||||
|
||||
* Thu Jul 22 2021 yangzhuangzhuang <yangzhuangzhuang1@huawei.com> - 8.40-27
|
||||
- Remove unnecessary buildrequires:gdb
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user