]> sigrok.org Git - libsigrok.git/commit - src/hardware/korad-kaxxxxp/protocol.c
korad-kaxxxxp: rephrase how config setter transmits commands to device
authorGerhard Sittig <redacted>
Sat, 25 Feb 2023 15:20:48 +0000 (16:20 +0100)
committerGerhard Sittig <redacted>
Sun, 26 Feb 2023 06:41:07 +0000 (07:41 +0100)
commitc179e476dff3d29c33b7b1e5d1c2e071f88ecd83
tree6fed6ec768fbf40f9011bfe5e6c1b1861a45aaea
parent88276d9ddca418c724a7a35719185a92f747659c
korad-kaxxxxp: rephrase how config setter transmits commands to device

The korad_kaxxxxp_set_value() routine was phrased in redundant and hard
to read ways that were error prone during maintainance. A variables pair
for "command" and "value" variables was assigned to, depending on the
involved parameter of the config setter. And only later in another code
section the text message got combined and was sent to the device. Error
paths which handled unknown keys or non-settable parameters returned
early but had to balance resources on their way out.

This rephrased implementation immediately constructs the text message
when dispatching parameters and looking up their values. Can use more
appropriate printf(3) formats in the respective construction. Emits the
same amount of diagnostics. Releases resources upon exit which were
released during execution. Eliminates dynamic allocation of a 20 byte
buffer.

Tested-By: Pilatomic <redacted>
src/hardware/korad-kaxxxxp/protocol.c