Rephrase the config_list() routine such that it does not attempt to
access the first item in an empty array. Be explicit about the digital
channel group's devopts being empty by design, add a comment.
The compiler warning could have been a false positive, but phrasing the
source code differently doesn't harm either, eliminates uncertainty.
};
static const uint32_t devopts_cg_digital[] = {
+ /* EMPTY */
};
enum {
switch (key) {
case SR_CONF_DEVICE_OPTIONS:
- if (cg_type == CG_ANALOG)
+ if (cg_type == CG_ANALOG) {
*data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_analog));
- else if (cg_type == CG_DIGITAL)
+ break;
+ }
+ if (cg_type == CG_DIGITAL) {
+ if (!ARRAY_SIZE(devopts_cg_digital)) {
+ *data = std_gvar_array_u32(NULL, 0);
+ break;
+ }
*data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_digital));
- else
- *data = std_gvar_array_u32(NULL, 0);
+ break;
+ }
+ *data = std_gvar_array_u32(NULL, 0);
break;
case SR_CONF_COUPLING:
if (!cg)