diff options
author | Martin Roth <martinroth@chromium.org> | 2016-10-26 11:15:04 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-12-16 15:42:18 -0800 |
commit | 2584ccb1d21e5cd3c20a78c1b121a60887b7276f (patch) | |
tree | c7a7c8e79f13b1050f8567c2ec7eba12b8cce865 /common/spi_nor.c | |
parent | ec5c396b470ef8781738b008bfa86e10d0f5f924 (diff) | |
download | chrome-ec-2584ccb1d21e5cd3c20a78c1b121a60887b7276f.tar.gz |
spi_nor.c: Initialize variables to fix GCC warnings
Looking at these warnings, none of these are real issues, so just
initialize the variables to make GCC happy. There might be a way to
rewrite the functions to make GCC be less confused, but I haven't
figured it out yet, and the solutions I tried generally ended up
increasing the binary size.
The function spi_nor_read_jedec_id() will initialize the variables or
return an error, so there isn't a path where they would be used without
initialization.
common/spi_nor.c: In function 'command_spi_nor_info':
common/spi_nor.c:771:3: error: 'mfn_id' may be used uninitialized in
this function [-Werror=maybe-uninitialized]
common/spi_nor.c:771:3: error: 'mfn_bank' may be used uninitialized
in this function [-Werror=maybe-uninitialized]
The function spi_nor_device_discover_sfdp_page_size() will either set
these variables or return an error, so these should never actually be
uninitialized when they get used.
common/spi_nor.c: In function 'spi_nor_init':
common/spi_nor.c:449:30: error: 'capacity' may be used uninitialized
in this function [-Werror=maybe-uninitialized]
common/spi_nor.c:450:31: error: 'page_size' may be used uninitialized
in this function [-Werror=maybe-uninitialized]
This does not change the size of any ec.*.flat file.
BRANCH=none
BUG=none
TEST=build succeeds under GCC 4.9.2, 5.3, and 6.2
Change-Id: I6bbe73b4acf3dcbbaa03d9cbf1dcdfeb883c0a6d
Signed-off-by: Martin Roth <martinroth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/403503
Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'common/spi_nor.c')
-rw-r--r-- | common/spi_nor.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/common/spi_nor.c b/common/spi_nor.c index dd775242d3..ebd45d4964 100644 --- a/common/spi_nor.c +++ b/common/spi_nor.c @@ -434,8 +434,8 @@ int spi_nor_init(void) * table, use the default capacity, page size, and addressing * mode values. */ if (rv == EC_SUCCESS) { - size_t page_size; - uint32_t capacity; + size_t page_size = 0; + uint32_t capacity = 0; rv |= spi_nor_device_discover_sfdp_page_size( spi_nor_device, @@ -769,7 +769,7 @@ static int command_spi_nor_info(int argc, char **argv) uint8_t sfdp_major_rev, sfdp_minor_rev; uint8_t table_major_rev, table_minor_rev; uint32_t table_offset; - uint8_t mfn_bank, mfn_id; + uint8_t mfn_bank = 0, mfn_id = 0; size_t table_size; const struct spi_nor_device_t *spi_nor_device = 0; int spi_nor_device_index = 0; |