From: Gerhard Sittig Date: Sun, 29 Oct 2023 16:37:59 +0000 (+0100) Subject: greatfet: don't print misleading "unknown" libusb error text X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=2c3fadf536f3747137b17fae0c743ec8752725fd;p=libsigrok.git greatfet: don't print misleading "unknown" libusb error text Only lookup libusb error messages for negative return values which communicate error codes. Positive return values are transmission counts and are not an error. The "UNKNOWN" messages only were seen at higher log levels. Users were not affected by the issue. --- diff --git a/src/hardware/greatfet/protocol.c b/src/hardware/greatfet/protocol.c index 913f981c..0c6c6c4e 100644 --- a/src/hardware/greatfet/protocol.c +++ b/src/hardware/greatfet/protocol.c @@ -169,7 +169,7 @@ static int greatfet_ctrl_out_in(const struct sr_dev_inst *sdi, flags, (void *)tx_data, tx_size, timeout_ms); if (sr_log_loglevel_get() >= SR_LOG_SPEW) { const char *msg; - msg = ret ? libusb_error_name(ret) : "-"; + msg = ret < 0 ? libusb_error_name(ret) : "-"; sr_spew("USB out, rc %d, %s", ret, msg); } if (ret < 0) { @@ -197,7 +197,7 @@ static int greatfet_ctrl_out_in(const struct sr_dev_inst *sdi, 0, rx_data, rx_size, timeout_ms); if (sr_log_loglevel_get() >= SR_LOG_SPEW) { const char *msg; - msg = ret ? libusb_error_name(ret) : "-"; + msg = ret < 0 ? libusb_error_name(ret) : "-"; sr_spew("USB in, rc %d, %s", ret, msg); } if (ret < 0) {