aboutsummaryrefslogtreecommitdiffstats
path: root/stlinkv3_spi.c
diff options
context:
space:
mode:
authorAlexander Goncharov <chat@joursoir.net>2022-09-16 17:26:33 +0300
committerAnastasia Klimchuk <aklm@chromium.org>2022-11-18 07:51:27 +0000
commited351cc602e5f21a47ad3f06696a7fe72e82c198 (patch)
treeeaf06f324da9107c9725867d9fd51bb11b0b6a51 /stlinkv3_spi.c
parent0f4767fd1e1eff8e20f82778e340b534af7ab190 (diff)
downloadflashrom-ed351cc602e5f21a47ad3f06696a7fe72e82c198.tar.gz
flashrom-ed351cc602e5f21a47ad3f06696a7fe72e82c198.tar.bz2
flashrom-ed351cc602e5f21a47ad3f06696a7fe72e82c198.zip
stlinkv3_spi: work around false-positive compiler error
`stlinkv3_handle` is declared without an initial value. The variable is initialized in a branch which can only be accessed if `devs_stlinkv3_spi[0].vendor_id != 0`. Otherwise, the variable contains a garbage value. We can consider this case as a false positive because `devs_stlinkv3_spi` holds as a minimum one device entry (otherwise we wouldn't need a driver). This issue was found by setting compiler flag `-Og`, which optimizes debugging experience, and running scan-build. So, we have to work around it to allow the compiler to use the flag and remove the warning from the scan-build list. Change-Id: Ibaf25f67186724d9045ade849026782c3eac4952 Signed-off-by: Alexander Goncharov <chat@joursoir.net> Reviewed-on: https://review.coreboot.org/c/flashrom/+/67700 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Thomas Heijligen <src@posteo.de> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-by: Felix Singer <felixsinger@posteo.net> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Diffstat (limited to 'stlinkv3_spi.c')
-rw-r--r--stlinkv3_spi.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/stlinkv3_spi.c b/stlinkv3_spi.c
index 9ae3df5f..1d5763b4 100644
--- a/stlinkv3_spi.c
+++ b/stlinkv3_spi.c
@@ -482,7 +482,8 @@ static int stlinkv3_spi_init(const struct programmer_cfg *cfg)
int ret = 1;
int devIndex = 0;
struct libusb_context *usb_ctx;
- libusb_device_handle *stlinkv3_handle;
+ /* Initialize stlinkv3_handle to NULL for suppressing scan-build false positive core.uninitialized.Branch */
+ libusb_device_handle *stlinkv3_handle = NULL;
struct stlinkv3_spi_data *stlinkv3_data;
if (libusb_init(&usb_ctx)) {