rigol-ds: improve robustness in samplerate getting code path
The rigol-ds driver's acquisition start routine tries to determine the
samplerate, which depends on devices' protocol version and communication
of SCPI requests. The logic potentially used an uninitialized variable
(for protocol versions below V3).
Rephrase the samplerate getting code path, apply stricter checks and
extend diagnostics. Make sure the XINC retrieval did yield a non-zero
value, to also avoid a division by zero.
Address style issues while we are here. Use braces for all branches when
one of them is complex. Eliminate trailing whitespace at ends of lines.
src/hardware/rigol-ds/api.c:1029:7: warning: variable 'xinc' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
if (devc->model->series->protocol >= PROTOCOL_V3 &&
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/hardware/rigol-ds/api.c:1034:28: note: uninitialized use occurs here
devc->sample_rate = 1. / xinc;
^~~~
src/hardware/rigol-ds/api.c:1029:7: note: remove the '&&' if its condition is always true
if (devc->model->series->protocol >= PROTOCOL_V3 &&
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/hardware/rigol-ds/api.c:1028:13: note: initialize the variable 'xinc' to silence this warning
float xinc;
^
= 0.0