From: Gerhard Sittig Date: Sun, 20 Sep 2020 07:38:45 +0000 (+0200) Subject: serial: rephrase check for speed (bitrate) in parameter string routine X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=b1184024fed838ec67d3cb2de097b66b6c48d9c7;p=libsigrok.git serial: rephrase check for speed (bitrate) in parameter string routine Use positive logic, put the error path for an unavailable value where the check for its availability is. Do the regular activity on available values in the straight code path with lesser indentation. Also group the bitrate, frame format, and handshake params when breaking text lines. --- diff --git a/src/serial.c b/src/serial.c index 7f1f1eea..8ffba795 100644 --- a/src/serial.c +++ b/src/serial.c @@ -678,13 +678,14 @@ SR_PRIV int serial_set_paramstr(struct sr_serial_dev_inst *serial, sr_spew("Got params: rate %d, frame %d/%d/%d, flow %d, rts %d, dtr %d.", speed, databits, parity, stopbits, flow, rts, dtr); - if (speed) { - return serial_set_params(serial, speed, databits, parity, - stopbits, flow, rts, dtr); - } else { + if (!speed) { sr_dbg("Could not infer speed from parameter string."); return SR_ERR_ARG; } + + return serial_set_params(serial, speed, + databits, parity, stopbits, + flow, rts, dtr); } /**