From b1184024fed838ec67d3cb2de097b66b6c48d9c7 Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Sun, 20 Sep 2020 09:38:45 +0200 Subject: [PATCH] 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. --- src/serial.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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); } /**