The ut181a driver's acquisition start routine may face a previously
unknown data source value, which is potentially unhandled when the
source code becomes inconsistent during maintenance. Add a default
case to handle the condition, which silences a compiler warning.
src/hardware/uni-t-ut181a/api.c:505:13: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
} else if (devc->data_source >= DATA_SOURCE_REC_FIRST) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/hardware/uni-t-ut181a/api.c:536:6: note: uninitialized use occurs here
if (ret < 0)
^~~
src/hardware/uni-t-ut181a/api.c:505:9: note: remove the 'if' if its condition is always true
} else if (devc->data_source >= DATA_SOURCE_REC_FIRST) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/hardware/uni-t-ut181a/api.c:467:9: note: initialize the variable 'ret' to silence this warning
int ret;
^
= 0
devc->info.rec_data.samples_total = devc->wait_state.data_value;
devc->info.rec_data.samples_curr = 0;
ret = ut181a_send_cmd_get_rec_samples(serial, rec_idx, 0);
+ } else {
+ sr_err("Unhandled data source %d, programming error?",
+ (int)devc->data_source);
+ ret = SR_ERR_BUG;
}
if (ret < 0)
return ret;