sbsigntool: fix compile error when enable DEBUG_BUILD

Fixes the following errors when set DEBUG_BUILD = "1":
fileio.c: In function ‘__fileio_read_file’:
fileio.c:179:12: error: ‘len’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  179 |   *out_len = len;
      |   ~~~~~~~~~^~~~~
fileio.c:178:12: error: ‘buf’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  178 |   *out_buf = buf;
      |   ~~~~~~~~~^~~~~

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
This commit is contained in:
Yi Zhao
2021-06-22 11:44:12 +08:00
committed by Jia Zhang
parent 551137d4eb
commit 31502fb8f2
2 changed files with 44 additions and 2 deletions

View File

@@ -0,0 +1,43 @@
From 8a2dfef2fbb68d72ee8b5a542cfb22817050ebdb Mon Sep 17 00:00:00 2001
From: Yi Zhao <yi.zhao@windriver.com>
Date: Tue, 22 Jun 2021 11:20:17 +0800
Subject: [PATCH] fileio.c: initialize local variables before use in function
__fileio_read_file
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fixes:
fileio.c: In function __fileio_read_file:
fileio.c:179:26: error: len may be used uninitialized in this function [-Werror=maybe-uninitialized]
179 | *out_len = len;
| ~~~~~~~~~^~~~~
fileio.c:178:26: error: buf may be used uninitialized in this function [-Werror=maybe-uninitialized]
178 | *out_buf = buf;
| ~~~~~~~~~^~~~~
Upstream-Status: Pending
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
---
src/fileio.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/fileio.c b/src/fileio.c
index 032eb1e..929bb00 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -142,8 +142,8 @@ static int __fileio_read_file(void *ctx, const char *filename,
uint8_t **out_buf, size_t *out_len, int flags)
{
struct stat statbuf;
- uint8_t *buf;
- size_t len;
+ uint8_t *buf = NULL;
+ size_t len = 0;
int fd, rc;
rc = -1;
--
2.17.1

View File

@@ -17,6 +17,7 @@ SRC_URI = " \
file://0002-docs-Don-t-build-man-pages.patch \
file://0003-sbsign-add-x-option-to-avoid-overwrite-existing-sign.patch \
file://0001-src-Makefile.am-Add-read_write_all.c-to-common_SOURC.patch \
file://0001-fileio.c-initialize-local-variables-before-use-in-fu.patch \
"
SRCREV_sbsigntools ?= "f12484869c9590682ac3253d583bf59b890bb826"
SRCREV_ccan ?= "b1f28e17227f2320d07fe052a8a48942fe17caa5"
@@ -42,8 +43,6 @@ def efi_arch(d):
# --with-libtool-sysroot \
#"
CFLAGS += "-Wno-error=maybe-uninitialized"
HOST_EXTRACFLAGS += "\
INCLUDES+='-I${S}/lib/ccan.git/ \
-I${STAGING_INCDIR_NATIVE}/efi \