From ed351cc602e5f21a47ad3f06696a7fe72e82c198 Mon Sep 17 00:00:00 2001 From: Alexander Goncharov Date: Fri, 16 Sep 2022 17:26:33 +0300 Subject: [PATCH] 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 Reviewed-on: https://review.coreboot.org/c/flashrom/+/67700 Tested-by: build bot (Jenkins) Reviewed-by: Thomas Heijligen Reviewed-by: Anastasia Klimchuk Reviewed-by: Felix Singer Reviewed-by: Angel Pons --- stlinkv3_spi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stlinkv3_spi.c b/stlinkv3_spi.c index 9ae3df5fa..1d5763b49 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)) {