From: Gerhard Sittig Date: Tue, 6 Oct 2020 18:59:27 +0000 (+0200) Subject: dmm/metex14: unbreak packet request helper return code X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=d7838e48046aa9c46966df2e3ee3bfba3d43a2e3;p=libsigrok.git dmm/metex14: unbreak packet request helper return code Return SR_OK in case of successful transmission of a packet request. The previous implementation passed the serial layer's verbatim return value, which was non-negative non-null (read: above zero) in case of success, which is none of the expected return codes of a packet request routine. This amends commit 379e95c587e1d and completes the adjustment which was started in commit a4be2b327be8. The issue has gone unnoticed in the past since it took not effect. The serial-dmm caller only tested for negative return values. --- diff --git a/src/dmm/metex14.c b/src/dmm/metex14.c index 5c4ed085..d93052a8 100644 --- a/src/dmm/metex14.c +++ b/src/dmm/metex14.c @@ -332,10 +332,19 @@ static gboolean flags_valid(const struct metex14_info *info) SR_PRIV int sr_metex14_packet_request(struct sr_serial_dev_inst *serial) { const uint8_t wbuf = 'D'; + size_t wrlen; + int ret; sr_spew("Requesting DMM packet."); - return serial_write_blocking(serial, &wbuf, 1, 0); + wrlen = sizeof(wbuf); + ret = serial_write_blocking(serial, &wbuf, wrlen, 0); + if (ret < 0) + return ret; + if ((size_t)ret != wrlen) + return SR_ERR_IO; + + return SR_OK; } #endif