diff options
author | Jack Rosenthal <jrosenth@chromium.org> | 2020-01-10 13:46:36 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-01-11 03:26:50 +0000 |
commit | 5b8bfef11631e625be1a50be5e1e7f38da01ab5a (patch) | |
tree | 9de3d66672cf1bef748114b4eb31928fa94f4592 /util/stm32mon.c | |
parent | 947267c4fdc20ed2270c3ad72cb642b496de16c2 (diff) | |
download | chrome-ec-5b8bfef11631e625be1a50be5e1e7f38da01ab5a.tar.gz |
utils: fix uninitialized variable in newer versions of gcc
If we ever decide to upgrade GCC (or, for example, someone comes along
wanting to build EC outside of the chroot) we are going to hit a snag
where newer versions of GCC will consider certain variables to never
be initialized.
util/ectool.c: In function ‘cmd_mkbp_get’:
util/ectool.c:8147:3: error: ‘supported’ may be used uninitialized in
this function [-Werror=maybe-uninitialized]
printf("MKBP switches state: 0x%04x (supported: 0x%04x)\n",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
r.switches, supported);
~~~~~~~~~~~~~~~~~~~~~~
Adding an else in ectool fixes it with no effect to compiled output.
In stm32mon, res may not be initialized:
util/stm32mon.c: In function ‘init_monitor’:
util/stm32mon.c:826:5: error: ‘res’ may be used uninitialized in
this function [-Werror=maybe-uninitialized]
if (IS_STM32_ERROR(res)) {
^
So fix by using success as an identity.
BUG=none
BRANCH=none
TEST="make utils" outside of chroot
Change-Id: Ib57479894111a1e7626999ecc3a150daef4b124d
Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1995722
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'util/stm32mon.c')
-rw-r--r-- | util/stm32mon.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/util/stm32mon.c b/util/stm32mon.c index 1b642e96d1..7a10ceef10 100644 --- a/util/stm32mon.c +++ b/util/stm32mon.c @@ -787,7 +787,7 @@ struct stm32_def *command_get_id(int fd) int init_monitor(int fd) { - int res; + int res = 0; int attempts = connect_retries + 1; uint8_t init = mode == MODE_SPI ? SOF : CMD_INIT; |