if (serial_write_blocking(serial, buf, 1, serial_timeout(serial, 1)) != 1)
return SR_ERR;
+ if (serial_drain(serial) != 0)
+ return SR_ERR;
+
return SR_OK;
}
if (serial_write_blocking(serial, buf, 5, serial_timeout(serial, 1)) != 5)
return SR_ERR;
+ if (serial_drain(serial) != 0)
+ return SR_ERR;
+
return SR_OK;
}
{
struct dev_context *devc;
- if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
- sr_err("Device context malloc failed.");
- return NULL;
- }
+ devc = g_malloc0(sizeof(struct dev_context));
/* Device-specific settings */
devc->max_samples = devc->max_samplerate = devc->protocol_version = 0;
GString *tmp_str, *devname, *version;
guchar tmp_c;
- sdi = sr_dev_inst_new(SR_ST_INACTIVE, NULL, NULL, NULL);
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
+ sdi->status = SR_ST_INACTIVE;
sdi->driver = di;
devc = ols_dev_new();
sdi->priv = devc;
case 0x00:
/* Number of usable channels */
for (ui = 0; ui < tmp_int; ui++) {
- if (!(ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE,
- ols_channel_names[ui])))
- return 0;
+ ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE,
+ ols_channel_names[ui]);
sdi->channels = g_slist_append(sdi->channels, ch);
}
break;
case 0x00:
/* Number of usable channels */
for (ui = 0; ui < tmp_c; ui++) {
- if (!(ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE,
- ols_channel_names[ui])))
- return 0;
+ ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE,
+ ols_channel_names[ui]);
sdi->channels = g_slist_append(sdi->channels, ch);
}
break;