Add some TODOs.
if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) {
sr_err("Driver context malloc failed.");
- return SR_ERR;
+ return SR_ERR_MALLOC;
}
di->priv = drvc;
}
len = 128;
- buf = g_try_malloc(len);
+ if (!(buf = g_try_malloc(len))) {
+ sr_err("Serial buffer malloc failed.");
+ return NULL;
+ }
serial_readline2(fd, &buf, &len, 150);
if (!len)
return NULL;
tokens[1], tokens[3])))
return NULL;
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_dbg("failed to malloc devc");
+ sr_err("Device context malloc failed.");
return NULL;
}
devc->profile = &supported_agdmm[i];
if (!(ctx = g_try_malloc0(sizeof(struct context)))) {
sr_err("alsa: %s: ctx malloc failed", __func__);
- return 0;
+ return SR_ERR_MALLOC;
}
if (!(sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, "alsa", NULL, NULL))) {
if (ret < 0) {
sr_err("alsa: can't allocate hardware parameter structure (%s)",
snd_strerror(ret));
- return SR_ERR;
+ return SR_ERR_MALLOC;
}
ret = snd_pcm_hw_params_any(ctx->capture_handle, ctx->hw_params);
if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) {
sr_err("asix-sigma: driver context malloc failed.");
- return SR_ERR;
+ return SR_ERR_MALLOC;
}
adi->priv = drvc;
/* TODO: 'term' is never g_free()'d? */
if (!(term = g_try_malloc(sizeof(struct termios)))) {
sr_err("serial: %s: term malloc failed", __func__);
- return NULL;
+ return -1;
}
tcgetattr(fd, term);
struct drv_context *drvc;
if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) {
- sr_err("fx2lafw: driver context malloc failed.");
- return SR_ERR;
+ sr_err("demo: driver context malloc failed.");
+ return SR_ERR_MALLOC;
}
ddi->priv = drvc;
if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) {
sr_err("Driver context malloc failed.");
- return SR_ERR;
+ return SR_ERR_MALLOC;
}
di->priv = drvc;
while(*e && *e == ' ')
e++;
+ /* TODO: Check malloc return value. */
analog = g_try_malloc0(sizeof(struct sr_datafeed_analog));
analog->num_samples = 1;
+ /* TODO: Check malloc return value. */
analog->data = g_try_malloc(sizeof(float));
if (is_oor)
*analog->data = NAN;
return NULL;
}
+ /* TODO: Check malloc return value. */
analog = g_try_malloc0(sizeof(struct sr_datafeed_analog));
analog->num_samples = 1;
+ /* TODO: Check malloc return value. */
analog->data = g_try_malloc(sizeof(float));
*analog->data = fvalue;
analog->mq = -1;
if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) {
sr_err("fx2lafw: driver context malloc failed.");
- return SR_ERR;
+ return SR_ERR_MALLOC;
}
if (libusb_init(NULL) != 0) {
const size_t size = get_buffer_size(devc);
devc->transfers = g_try_malloc0(sizeof(*devc->transfers) * num_transfers);
- if (!devc->transfers)
- return SR_ERR;
+ if (!devc->transfers) {
+ sr_err("fx2lafw: USB transfers malloc failed.");
+ return SR_ERR_MALLOC;
+ }
devc->num_transfers = num_transfers;
/* Found one. */
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
sr_err("Device context malloc failed.");
- return 0;
+ return NULL;
}
devcnt = g_slist_length(drvc->instances);
if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) {
sr_err("Driver context malloc failed.");
- return SR_ERR;
+ return SR_ERR_MALLOC;
}
if (libusb_init(&genericdmm_usb_context) != 0) {
if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) {
sr_err("hantek-dso: driver context malloc failed.");
- return SR_ERR;
+ return SR_ERR_MALLOC;
}
if (libusb_init(NULL) != 0) {
analog.num_samples = num_samples;
analog.mq = SR_MQ_VOLTAGE;
analog.unit = SR_UNIT_VOLT;
+ /* TODO: Check malloc return value. */
analog.data = g_try_malloc(analog.num_samples * sizeof(float) * num_probes);
data_offset = 0;
for (i = 0; i < analog.num_samples; i++) {
devc->trigger_offset = trigger_offset;
num_probes = (devc->ch1_enabled && devc->ch2_enabled) ? 2 : 1;
+ /* TODO: Check malloc return value. */
devc->framebuf = g_try_malloc(devc->framesize * num_probes * 2);
devc->samp_buffered = devc->samp_received = 0;
if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) {
sr_err("ols: driver context malloc failed.");
- return SR_ERR;
+ return SR_ERR_MALLOC;
}
odi->priv = drvc;
*/
sr_source_remove(fd);
sr_source_add(fd, G_IO_IN, 30, receive_data, cb_data);
+ /* TODO: Check malloc return code. */
devc->raw_sample_buf = g_try_malloc(devc->limit_samples * 4);
if (!devc->raw_sample_buf) {
sr_err("ols: %s: devc->raw_sample_buf malloc failed",
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
void *cb_data)
{
-
/* Avoid compiler warnings. */
(void)cb_data;
if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) {
sr_err("Driver context malloc failed.");
- return SR_ERR;
+ return SR_ERR_MALLOC;
}
di->priv = drvc;
struct sr_datafeed_packet packet;
struct sr_datafeed_analog *analog;
+ /* TODO: Check malloc return value. */
analog = g_try_malloc0(sizeof(struct sr_datafeed_analog));
analog->num_samples = 1;
+ /* TODO: Check malloc return value. */
analog->data = g_try_malloc(sizeof(float));
*analog->data = (float)rawval;
analog->mq = -1;
if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) {
sr_err("zeroplus: driver context malloc failed.");
- return SR_ERR;
+ return SR_ERR_MALLOC;
}
zdi->priv = drvc;
/* Allocate memory for our private driver context. */
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
sr_err("zp: %s: devc malloc failed", __func__);
- return 0;
+ return NULL;
}
sdi->priv = devc;
devc->num_channels = prof->channels;
GString *out;
};
-
static int init(struct sr_output *o)
{
struct context *ctx;
if (!o || !o->sdi)
return SR_ERR_ARG;
- if (!(ctx = g_try_malloc0(sizeof(struct context))))
+ if (!(ctx = g_try_malloc0(sizeof(struct context)))) {
+ sr_err("output/analog: Context malloc failed.");
return SR_ERR_MALLOC;
+ }
o->internal = ctx;
/* Get the number of probes and their names. */
if (!o->sdi->driver)
return SR_ERR_ARG;
- if (!(ctx = g_try_malloc0(sizeof(struct context))))
+ if (!(ctx = g_try_malloc0(sizeof(struct context)))) {
+ sr_err("output/float: Context malloc failed.");
return SR_ERR_MALLOC;
+ }
o->internal = ctx;