Check pointers for validity before dereferencing them. This silences the
following compiler warnings:
../src/hardware/microchip-pickit2/api.c:275:8: warning: Access to field 'conn' results in a dereference of a null pointer (loaded from variable 'sdi')
if (!sdi->conn)
../src/hardware/microchip-pickit2/api.c:281:10: warning: Access to field 'samplerates' results in a dereference of a null pointer (loaded from variable 'devc')
rate = devc->samplerates[devc->curr_samplerate_idx];
../src/hardware/microchip-pickit2/api.c:287:11: warning: Access to field 'captureratios' results in a dereference of a null pointer (loaded from variable 'devc')
ratio = devc->captureratios[devc->curr_captureratio_idx];
(void)cg;
devc = sdi ? sdi->priv : NULL;
+ usb = sdi ? sdi->conn : NULL;
switch (key) {
case SR_CONF_CONN:
- if (!sdi->conn)
+ if (!usb)
return SR_ERR_ARG;
- usb = sdi->conn;
*data = g_variant_new_printf("%d.%d", usb->bus, usb->address);
return SR_OK;
case SR_CONF_SAMPLERATE:
+ if (!devc)
+ return SR_ERR_ARG;
rate = devc->samplerates[devc->curr_samplerate_idx];
*data = g_variant_new_uint64(rate);
return SR_OK;
case SR_CONF_LIMIT_SAMPLES:
+ if (!devc)
+ return SR_ERR_ARG;
return sr_sw_limits_config_get(&devc->sw_limits, key, data);
case SR_CONF_CAPTURE_RATIO:
+ if (!devc)
+ return SR_ERR_ARG;
ratio = devc->captureratios[devc->curr_captureratio_idx];
*data = g_variant_new_uint64(ratio);
return SR_OK;