Anastasia Klimchuk has submitted this change. ( https://review.coreboot.org/c/flashrom/+/67700 )
(
4 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: stlinkv3_spi: work around false-positive compiler error ......................................................................
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 --- M stlinkv3_spi.c 1 file changed, 30 insertions(+), 1 deletion(-)
Approvals: build bot (Jenkins): Verified Felix Singer: Looks good to me, but someone else must approve Thomas Heijligen: Looks good to me, approved Angel Pons: Looks good to me, approved Anastasia Klimchuk: Looks good to me, approved
diff --git a/stlinkv3_spi.c b/stlinkv3_spi.c index 9ae3df5..1d5763b 100644 --- a/stlinkv3_spi.c +++ b/stlinkv3_spi.c @@ -482,7 +482,8 @@ 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)) {