- if (!(read_resp = device_read_1(&read_parms, vxi->client))
- || read_resp->error) {
- sr_err("Device read failed for %s with error %d",
- vxi->address, read_resp->error);
+ read_resp = device_read_1(&read_parms, vxi->client);
+ if (!read_resp || read_resp->error) {
+ sr_err("Device read failed for %s with error %ld",
+ vxi->address, read_resp ? read_resp->error : 0);
+ if (read_resp) {
+ g_free(read_resp->data.data_val);
+ read_resp->data.data_val = NULL;
+ }