1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-27 15:12:36 +02:00

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>
This commit is contained in:
Alexander Goncharov 2022-09-16 17:26:33 +03:00 committed by Anastasia Klimchuk
parent 0f4767fd1e
commit ed351cc602

View File

@ -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)) {