From: Gerhard Sittig Date: Tue, 17 Oct 2023 19:25:00 +0000 (+0200) Subject: yokogawa-dlm: silence compiler warning (passing an empty array) X-Git-Url: http://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=ad7b0c173557b456353d965f91a728bed2c47fa2 yokogawa-dlm: silence compiler warning (passing an empty array) 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. --- diff --git a/src/hardware/yokogawa-dlm/api.c b/src/hardware/yokogawa-dlm/api.c index f80e83dc..c1fe1b01 100644 --- a/src/hardware/yokogawa-dlm/api.c +++ b/src/hardware/yokogawa-dlm/api.c @@ -53,6 +53,7 @@ static const uint32_t devopts_cg_analog[] = { }; static const uint32_t devopts_cg_digital[] = { + /* EMPTY */ }; enum { @@ -423,12 +424,19 @@ static int config_list(uint32_t key, GVariant **data, 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)