Fix various gcc 8 compiler warnings related to ARRAY_SIZE.
Example: In file included from src/hardware/kecheng-kc-330b/protocol.h:26, from src/hardware/kecheng-kc-330b/api.c:22: src/hardware/kecheng-kc-330b/api.c: In function ‘config_list’: src/libsigrok-internal.h:51:34: warning: division ‘sizeof (void *) / sizeof (void)’ does not compute the number of array elements [-Wsizeof-pointer-div] #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) ^ src/libsigrok-internal.h:55:32: note: in expansion of macro ‘ARRAY_SIZE’ #define ARRAY_AND_SIZE(a) (a), ARRAY_SIZE(a) ^~~~~~~~~~ src/libsigrok-internal.h:964:43: note: in expansion of macro ‘ARRAY_AND_SIZE’ std_opts_config_list(key, data, sdi, cg, ARRAY_AND_SIZE(scanopts), \ ^~~~~~~~~~~~~~ src/hardware/kecheng-kc-330b/api.c:296:10: note: in expansion of macro ‘STD_CONFIG_LIST’ return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts); ^~~~~~~~~~~~~~~
This commit is contained in:
parent
af930bcf7b
commit
2377246220
|
@ -226,7 +226,7 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
{
|
||||
switch (key) {
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NO_OPTS, drvopts, devopts);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = std_gvar_samplerates(samplerates, samplerates_count);
|
||||
break;
|
||||
|
|
|
@ -216,7 +216,7 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
if (!cg) {
|
||||
switch (key) {
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NO_OPTS, drvopts, devopts);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates));
|
||||
break;
|
||||
|
|
|
@ -490,10 +490,10 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
|
||||
switch (key) {
|
||||
case SR_CONF_SCAN_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, NULL, NULL);
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, NO_OPTS, NO_OPTS);
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
if (!cg)
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NO_OPTS, drvopts, devopts);
|
||||
*data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg));
|
||||
break;
|
||||
case SR_CONF_SAMPLERATE:
|
||||
|
|
|
@ -299,7 +299,7 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
{
|
||||
switch (key) {
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NO_OPTS, drvopts, devopts);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = std_gvar_samplerates(ARRAY_AND_SIZE(sl2_samplerates));
|
||||
break;
|
||||
|
|
|
@ -253,7 +253,7 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
{
|
||||
switch (key) {
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NO_OPTS, drvopts, devopts);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = std_gvar_samplerates(ARRAY_AND_SIZE(samplerates));
|
||||
break;
|
||||
|
|
|
@ -293,7 +293,7 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
{
|
||||
switch (key) {
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NO_OPTS, drvopts, devopts);
|
||||
case SR_CONF_SAMPLE_INTERVAL:
|
||||
*data = std_gvar_tuple_array(ARRAY_AND_SIZE(kecheng_kc_330b_sample_intervals));
|
||||
break;
|
||||
|
|
|
@ -410,7 +410,7 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
{
|
||||
switch (key) {
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NO_OPTS, drvopts, devopts);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = std_gvar_samplerates(ARRAY_AND_SIZE(samplerates));
|
||||
break;
|
||||
|
|
|
@ -315,10 +315,10 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
|
||||
switch (key) {
|
||||
case SR_CONF_SCAN_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, NULL, NULL);
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, NO_OPTS, NO_OPTS);
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
if (!cg)
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NO_OPTS, drvopts, devopts);
|
||||
*data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_analog));
|
||||
break;
|
||||
case SR_CONF_COUPLING:
|
||||
|
|
|
@ -284,7 +284,7 @@ static int config_list(int key, GVariant **data,
|
|||
{
|
||||
switch (key) {
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NO_OPTS, drvopts, devopts);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates));
|
||||
break;
|
||||
|
|
|
@ -325,7 +325,7 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
|
||||
switch (key) {
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NO_OPTS, drvopts, devopts);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates));
|
||||
break;
|
||||
|
|
|
@ -395,7 +395,7 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
|
||||
switch (key) {
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NO_OPTS, drvopts, devopts);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
devc = sdi->priv;
|
||||
if (devc->prof->max_sampling_freq == 100)
|
||||
|
|
|
@ -960,6 +960,8 @@ SR_PRIV int std_opts_config_list(uint32_t key, GVariant **data,
|
|||
const uint32_t scanopts[], size_t scansize, const uint32_t drvopts[],
|
||||
size_t drvsize, const uint32_t devopts[], size_t devsize);
|
||||
|
||||
extern SR_PRIV const uint32_t NO_OPTS[1];
|
||||
|
||||
#define STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts) \
|
||||
std_opts_config_list(key, data, sdi, cg, ARRAY_AND_SIZE(scanopts), \
|
||||
ARRAY_AND_SIZE(drvopts), ARRAY_AND_SIZE(devopts))
|
||||
|
|
|
@ -328,7 +328,7 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
static int config_list(uint32_t key, GVariant **data,
|
||||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||
{
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, NULL, devopts);
|
||||
return STD_CONFIG_LIST(key, data, sdi, cg, NO_OPTS, NO_OPTS, devopts);
|
||||
}
|
||||
|
||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
|
||||
#define LOG_PREFIX "std"
|
||||
|
||||
SR_PRIV const uint32_t NO_OPTS[1] = {};
|
||||
|
||||
/**
|
||||
* Standard driver init() callback API helper.
|
||||
*
|
||||
|
@ -581,7 +583,7 @@ SR_PRIV int std_opts_config_list(uint32_t key, GVariant **data,
|
|||
switch (key) {
|
||||
case SR_CONF_SCAN_OPTIONS:
|
||||
/* Always return scanopts, regardless of sdi or cg. */
|
||||
if (!scanopts)
|
||||
if (!scanopts || scanopts == NO_OPTS)
|
||||
return SR_ERR_ARG;
|
||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
||||
scanopts, scansize, sizeof(uint32_t));
|
||||
|
@ -589,13 +591,13 @@ SR_PRIV int std_opts_config_list(uint32_t key, GVariant **data,
|
|||
case SR_CONF_DEVICE_OPTIONS:
|
||||
if (!sdi) {
|
||||
/* sdi == NULL: return drvopts. */
|
||||
if (!drvopts)
|
||||
if (!drvopts || drvopts == NO_OPTS)
|
||||
return SR_ERR_ARG;
|
||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
||||
drvopts, drvsize, sizeof(uint32_t));
|
||||
} else if (sdi && !cg) {
|
||||
/* sdi != NULL, cg == NULL: return devopts. */
|
||||
if (!devopts)
|
||||
if (!devopts || devopts == NO_OPTS)
|
||||
return SR_ERR_ARG;
|
||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
||||
devopts, devsize, sizeof(uint32_t));
|
||||
|
|
Loading…
Reference in New Issue