Felix Singer submitted this change.

View Change



1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.

Approvals: build bot (Jenkins): Verified Elyes Haouas: Looks good to me, approved Felix Singer: Looks good to me, approved
pickit2_spi: Fix "dead" assignment

We never read the first 'ret'. Let's check the first 'ret'
and exit if it failed.

Also, print the version only when the command succeeded.

Backported to libusb-v0 version (checking for CMD_LENGTH
instead of 0 return value).

Found-by: scan-build 7.0.1-8
Change-Id: I4aac5e1f3bd0604b079e1fdd9b7f09f1f4fc2d7f
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/34403
Reviewed-on: https://review.coreboot.org/c/flashrom/+/67846
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
---
M pickit2_spi.c
1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/pickit2_spi.c b/pickit2_spi.c
index 4354025..1d1f08c 100644
--- a/pickit2_spi.c
+++ b/pickit2_spi.c
@@ -119,14 +119,20 @@
uint8_t command[CMD_LENGTH] = {CMD_GET_VERSION, CMD_END_OF_BUFFER};

ret = usb_interrupt_write(pickit2_handle, ENDPOINT_OUT, (char *)command, CMD_LENGTH, DFLT_TIMEOUT);
+
+ if (ret != CMD_LENGTH) {
+ msg_perr("Command Get Firmware Version failed!\n");
+ return 1;
+ }
+
ret = usb_interrupt_read(pickit2_handle, ENDPOINT_IN, (char *)command, CMD_LENGTH, DFLT_TIMEOUT);

- msg_pdbg("PICkit2 Firmware Version: %d.%d\n", (int)command[0], (int)command[1]);
if (ret != CMD_LENGTH) {
msg_perr("Command Get Firmware Version failed (%s)!\n", usb_strerror());
return 1;
}

+ msg_pdbg("PICkit2 Firmware Version: %d.%d\n", (int)command[0], (int)command[1]);
return 0;
}


To view, visit change 67846. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: 1.1.x
Gerrit-Change-Id: I4aac5e1f3bd0604b079e1fdd9b7f09f1f4fc2d7f
Gerrit-Change-Number: 67846
Gerrit-PatchSet: 3
Gerrit-Owner: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: Elyes Haouas <ehaouas@noos.fr>
Gerrit-Reviewer: Felix Singer <felixsinger@posteo.net>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-MessageType: merged