scpi-pps: silence potential NULL dereference compiler warning

Check pointers' validity before dereferencing them.

This was reported by clang's scan-build.
This commit is contained in:
Gerhard Sittig 2018-02-09 19:29:08 +01:00 committed by Uwe Hermann
parent 6a821db6f2
commit 08eba2d301
1 changed files with 6 additions and 2 deletions

View File

@ -525,10 +525,12 @@ static int config_list(uint32_t key, GVariant **data,
return std_opts_config_list(key, data, sdi, cg,
ARRAY_AND_SIZE(scanopts),
ARRAY_AND_SIZE(drvopts),
(devc) ? devc->device->devopts : NULL,
(devc) ? devc->device->num_devopts : 0);
(devc && devc->device) ? devc->device->devopts : NULL,
(devc && devc->device) ? devc->device->num_devopts : 0);
break;
case SR_CONF_CHANNEL_CONFIG:
if (!devc || !devc->device)
return SR_ERR_ARG;
/* Not used. */
i = 0;
if (devc->device->features & PPS_INDEPENDENT)
@ -557,6 +559,8 @@ static int config_list(uint32_t key, GVariant **data,
* specification for use in series or parallel mode.
*/
ch = cg->channels->data;
if (!devc || !devc->device)
return SR_ERR_ARG;
ch_spec = &(devc->device->channels[ch->index]);
switch (key) {