]> sigrok.org Git - libsigrok.git/commitdiff
dmm/metex14: unbreak packet request helper return code
authorGerhard Sittig <redacted>
Tue, 6 Oct 2020 18:59:27 +0000 (20:59 +0200)
committerGerhard Sittig <redacted>
Tue, 6 Oct 2020 18:59:27 +0000 (20:59 +0200)
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.

src/dmm/metex14.c

index 5c4ed0858c2816c8278ac0bfaad2d74c584422a1..d93052a85b84bc7cbfbe50b5b3c266df50dbf665 100644 (file)
@@ -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