Consistently use g_malloc0() for allocating devc.
We assume the allocation will always succeed, hence no need for checking the returned value.
This commit is contained in:
parent
aac29cc192
commit
f57d8ffe66
|
@ -144,10 +144,7 @@ static GSList *scan(GSList *options)
|
||||||
sdi->vendor = g_strdup("Agilent");
|
sdi->vendor = g_strdup("Agilent");
|
||||||
sdi->model = g_strdup(tokens[1]);
|
sdi->model = g_strdup(tokens[1]);
|
||||||
sdi->version = g_strdup(tokens[3]);
|
sdi->version = g_strdup(tokens[3]);
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
sr_err("Device context malloc failed.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
devc->profile = &supported_agdmm[i];
|
devc->profile = &supported_agdmm[i];
|
||||||
devc->cur_mq = -1;
|
devc->cur_mq = -1;
|
||||||
sdi->inst_type = SR_INST_SERIAL;
|
sdi->inst_type = SR_INST_SERIAL;
|
||||||
|
|
|
@ -103,14 +103,8 @@ static GSList *scan(GSList *options)
|
||||||
sdi->status = SR_ST_INACTIVE;
|
sdi->status = SR_ST_INACTIVE;
|
||||||
sdi->vendor = g_strdup("APPA");
|
sdi->vendor = g_strdup("APPA");
|
||||||
sdi->model = g_strdup("55II");
|
sdi->model = g_strdup("55II");
|
||||||
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
|
|
||||||
sr_err("Device context malloc failed.");
|
|
||||||
goto scan_cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
devc->data_source = DEFAULT_DATA_SOURCE;
|
devc->data_source = DEFAULT_DATA_SOURCE;
|
||||||
|
|
||||||
sdi->inst_type = SR_INST_SERIAL;
|
sdi->inst_type = SR_INST_SERIAL;
|
||||||
sdi->conn = serial;
|
sdi->conn = serial;
|
||||||
sdi->priv = devc;
|
sdi->priv = devc;
|
||||||
|
|
|
@ -341,10 +341,7 @@ static GSList *scan(GSList *options)
|
||||||
|
|
||||||
devices = NULL;
|
devices = NULL;
|
||||||
|
|
||||||
if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
sr_err("%s: devc malloc failed", __func__);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ftdi_init(&devc->ftdic);
|
ftdi_init(&devc->ftdic);
|
||||||
|
|
||||||
|
|
|
@ -65,12 +65,11 @@ static int init(struct sr_context *sr_ctx)
|
||||||
return std_init(sr_ctx, di, LOG_PREFIX);
|
return std_init(sr_ctx, di, LOG_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct dev_context * beaglelogic_devc_alloc(void)
|
static struct dev_context *beaglelogic_devc_alloc(void)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
/* Allocate zeroed structure */
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
devc = g_try_malloc0(sizeof(*devc));
|
|
||||||
|
|
||||||
/* Default non-zero values (if any) */
|
/* Default non-zero values (if any) */
|
||||||
devc->fd = -1;
|
devc->fd = -1;
|
||||||
|
|
|
@ -77,12 +77,7 @@ static GSList *scan(GSList *options)
|
||||||
sdi->status = SR_ST_INACTIVE;
|
sdi->status = SR_ST_INACTIVE;
|
||||||
sdi->vendor = g_strdup("Brymen");
|
sdi->vendor = g_strdup("Brymen");
|
||||||
sdi->model = g_strdup("BM869");
|
sdi->model = g_strdup("BM869");
|
||||||
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
if (!(devc = g_try_malloc0(sizeof(*devc)))) {
|
|
||||||
sr_err("Device context malloc failed.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
sdi->priv = devc;
|
sdi->priv = devc;
|
||||||
sdi->driver = di;
|
sdi->driver = di;
|
||||||
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
|
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
|
||||||
|
|
|
@ -79,12 +79,7 @@ static GSList *brymen_scan(const char *conn, const char *serialcomm)
|
||||||
sdi->status = SR_ST_INACTIVE;
|
sdi->status = SR_ST_INACTIVE;
|
||||||
sdi->vendor = g_strdup("Brymen");
|
sdi->vendor = g_strdup("Brymen");
|
||||||
sdi->model = g_strdup("BM85x");
|
sdi->model = g_strdup("BM85x");
|
||||||
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
|
|
||||||
sr_err("Device context malloc failed.");
|
|
||||||
goto scan_cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
sdi->inst_type = SR_INST_SERIAL;
|
sdi->inst_type = SR_INST_SERIAL;
|
||||||
sdi->conn = serial;
|
sdi->conn = serial;
|
||||||
drvc = di->priv;
|
drvc = di->priv;
|
||||||
|
|
|
@ -113,11 +113,7 @@ static GSList *scan(GSList *options)
|
||||||
sdi->status = SR_ST_INACTIVE;
|
sdi->status = SR_ST_INACTIVE;
|
||||||
sdi->vendor = g_strdup("CEM");
|
sdi->vendor = g_strdup("CEM");
|
||||||
sdi->model = g_strdup("DT-885x");
|
sdi->model = g_strdup("DT-885x");
|
||||||
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
|
|
||||||
sr_dbg("Device context malloc failed.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
devc->cur_mqflags = 0;
|
devc->cur_mqflags = 0;
|
||||||
devc->recording = -1;
|
devc->recording = -1;
|
||||||
devc->cur_meas_range = 0;
|
devc->cur_meas_range = 0;
|
||||||
|
|
|
@ -92,15 +92,9 @@ static GSList *center_scan(const char *conn, const char *serialcomm, int idx)
|
||||||
sdi->status = SR_ST_INACTIVE;
|
sdi->status = SR_ST_INACTIVE;
|
||||||
sdi->vendor = g_strdup(center_devs[idx].vendor);
|
sdi->vendor = g_strdup(center_devs[idx].vendor);
|
||||||
sdi->model = g_strdup(center_devs[idx].device);
|
sdi->model = g_strdup(center_devs[idx].device);
|
||||||
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
|
|
||||||
sr_err("Device context malloc failed.");
|
|
||||||
goto scan_cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
sdi->inst_type = SR_INST_SERIAL;
|
sdi->inst_type = SR_INST_SERIAL;
|
||||||
sdi->conn = serial;
|
sdi->conn = serial;
|
||||||
|
|
||||||
sdi->priv = devc;
|
sdi->priv = devc;
|
||||||
sdi->driver = center_devs[idx].di;
|
sdi->driver = center_devs[idx].di;
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ static int add_device(int idx, int model, GSList **devices)
|
||||||
drvc = di->priv;
|
drvc = di->priv;
|
||||||
|
|
||||||
/* Allocate memory for our private device context. */
|
/* Allocate memory for our private device context. */
|
||||||
devc = g_try_malloc(sizeof(struct dev_context));
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
|
|
||||||
/* Set some sane defaults. */
|
/* Set some sane defaults. */
|
||||||
devc->prof = &cv_profiles[model];
|
devc->prof = &cv_profiles[model];
|
||||||
|
|
|
@ -86,15 +86,9 @@ static GSList *scan(GSList *options)
|
||||||
sdi->status = SR_ST_INACTIVE;
|
sdi->status = SR_ST_INACTIVE;
|
||||||
sdi->vendor = g_strdup("Colead");
|
sdi->vendor = g_strdup("Colead");
|
||||||
sdi->model = g_strdup("SL-5868P");
|
sdi->model = g_strdup("SL-5868P");
|
||||||
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
|
|
||||||
sr_dbg("Device context malloc failed.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(sdi->conn = sr_serial_dev_inst_new(conn, serialcomm)))
|
if (!(sdi->conn = sr_serial_dev_inst_new(conn, serialcomm)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
sdi->inst_type = SR_INST_SERIAL;
|
sdi->inst_type = SR_INST_SERIAL;
|
||||||
sdi->priv = devc;
|
sdi->priv = devc;
|
||||||
sdi->driver = di;
|
sdi->driver = di;
|
||||||
|
|
|
@ -127,10 +127,7 @@ static GSList *fluke_scan(const char *conn, const char *serialcomm)
|
||||||
sdi->vendor = g_strdup("Fluke");
|
sdi->vendor = g_strdup("Fluke");
|
||||||
sdi->model = g_strdup(tokens[0] + 6);
|
sdi->model = g_strdup(tokens[0] + 6);
|
||||||
sdi->version = g_strdup(tokens[1] + s);
|
sdi->version = g_strdup(tokens[1] + s);
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
sr_err("Device context malloc failed.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
devc->profile = &supported_flukedmm[i];
|
devc->profile = &supported_flukedmm[i];
|
||||||
sdi->inst_type = SR_INST_SERIAL;
|
sdi->inst_type = SR_INST_SERIAL;
|
||||||
sdi->conn = serial;
|
sdi->conn = serial;
|
||||||
|
|
|
@ -299,11 +299,7 @@ SR_PRIV struct dev_context *fx2lafw_dev_new(void)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
sr_err("Device context malloc failed.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
devc->profile = NULL;
|
devc->profile = NULL;
|
||||||
devc->fw_updated = 0;
|
devc->fw_updated = 0;
|
||||||
devc->cur_samplerate = 0;
|
devc->cur_samplerate = 0;
|
||||||
|
|
|
@ -227,17 +227,13 @@ static GSList *scan_1x_2x_rs232(GSList *options)
|
||||||
sdi->status = SR_ST_INACTIVE;
|
sdi->status = SR_ST_INACTIVE;
|
||||||
sdi->vendor = g_strdup(VENDOR_GMC);
|
sdi->vendor = g_strdup(VENDOR_GMC);
|
||||||
sdi->model = g_strdup(gmc_model_str(model));
|
sdi->model = g_strdup(gmc_model_str(model));
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
sr_err("Device context malloc failed.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
devc->model = model;
|
devc->model = model;
|
||||||
devc->limit_samples = 0;
|
devc->limit_samples = 0;
|
||||||
devc->limit_msec = 0;
|
devc->limit_msec = 0;
|
||||||
devc->num_samples = 0;
|
devc->num_samples = 0;
|
||||||
devc->elapsed_msec = g_timer_new();
|
devc->elapsed_msec = g_timer_new();
|
||||||
devc->settings_ok = FALSE;
|
devc->settings_ok = FALSE;
|
||||||
|
|
||||||
sdi->conn = serial;
|
sdi->conn = serial;
|
||||||
sdi->priv = devc;
|
sdi->priv = devc;
|
||||||
sdi->driver = &gmc_mh_1x_2x_rs232_driver_info;
|
sdi->driver = &gmc_mh_1x_2x_rs232_driver_info;
|
||||||
|
@ -299,10 +295,7 @@ static GSList *scan_2x_bd232(GSList *options)
|
||||||
if (serial_open(serial, SERIAL_RDWR) != SR_OK)
|
if (serial_open(serial, SERIAL_RDWR) != SR_OK)
|
||||||
goto exit_err;
|
goto exit_err;
|
||||||
|
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
sr_err("Device context malloc failed.");
|
|
||||||
goto exit_err;
|
|
||||||
}
|
|
||||||
|
|
||||||
sdi = g_malloc0(sizeof(struct sr_dev_inst));
|
sdi = g_malloc0(sizeof(struct sr_dev_inst));
|
||||||
sdi->status = SR_ST_INACTIVE;
|
sdi->status = SR_ST_INACTIVE;
|
||||||
|
@ -350,10 +343,7 @@ static GSList *scan_2x_bd232(GSList *options)
|
||||||
drvc->instances = g_slist_append(drvc->instances, sdi);
|
drvc->instances = g_slist_append(drvc->instances, sdi);
|
||||||
devices = g_slist_append(devices, sdi);
|
devices = g_slist_append(devices, sdi);
|
||||||
|
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
sr_err("Device context malloc failed.");
|
|
||||||
goto exit_err;
|
|
||||||
}
|
|
||||||
|
|
||||||
sdi = g_malloc0(sizeof(struct sr_dev_inst));
|
sdi = g_malloc0(sizeof(struct sr_dev_inst));
|
||||||
sdi->status = SR_ST_INACTIVE;
|
sdi->status = SR_ST_INACTIVE;
|
||||||
|
|
|
@ -92,8 +92,7 @@ static struct sr_dev_inst *hmo_probe_serial_device(struct sr_scpi_dev_inst *scpi
|
||||||
sr_scpi_hw_info_free(hw_info);
|
sr_scpi_hw_info_free(hw_info);
|
||||||
hw_info = NULL;
|
hw_info = NULL;
|
||||||
|
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context))))
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
goto fail;
|
|
||||||
|
|
||||||
sdi->priv = devc;
|
sdi->priv = devc;
|
||||||
|
|
||||||
|
|
|
@ -91,11 +91,7 @@ static GSList *scan(GSList *options)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
sr_err("Device instance malloc failed.");
|
|
||||||
sr_usb_dev_inst_free(usb);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(devc->xfer_in = libusb_alloc_transfer(0))) {
|
if (!(devc->xfer_in = libusb_alloc_transfer(0))) {
|
||||||
sr_err("Transfer malloc failed.");
|
sr_err("Transfer malloc failed.");
|
||||||
|
|
|
@ -88,10 +88,7 @@ static GSList *scan(GSList *options)
|
||||||
devices = NULL;
|
devices = NULL;
|
||||||
|
|
||||||
/* Allocate memory for our private device context. */
|
/* Allocate memory for our private device context. */
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
sr_err("Device context malloc failed.");
|
|
||||||
goto err_free_nothing;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate memory for the incoming compressed samples. */
|
/* Allocate memory for the incoming compressed samples. */
|
||||||
if (!(devc->compressed_buf = g_try_malloc0(COMPRESSED_BUF_SIZE))) {
|
if (!(devc->compressed_buf = g_try_malloc0(COMPRESSED_BUF_SIZE))) {
|
||||||
|
@ -154,7 +151,6 @@ err_free_compressed_buf:
|
||||||
g_free(devc->compressed_buf);
|
g_free(devc->compressed_buf);
|
||||||
err_free_devc:
|
err_free_devc:
|
||||||
g_free(devc);
|
g_free(devc);
|
||||||
err_free_nothing:
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,11 +139,7 @@ static GSList *scan(GSList *options)
|
||||||
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "SPL")))
|
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "SPL")))
|
||||||
return NULL;
|
return NULL;
|
||||||
sdi->channels = g_slist_append(sdi->channels, ch);
|
sdi->channels = g_slist_append(sdi->channels, ch);
|
||||||
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
|
|
||||||
sr_dbg("Device context malloc failed.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
sdi->priv = devc;
|
sdi->priv = devc;
|
||||||
devc->limit_samples = 0;
|
devc->limit_samples = 0;
|
||||||
/* The protocol provides no way to read the current
|
/* The protocol provides no way to read the current
|
||||||
|
|
|
@ -348,8 +348,7 @@ static struct sr_dev_inst *lascar_identify(unsigned char *config)
|
||||||
sdi->channels = g_slist_append(NULL, ch);
|
sdi->channels = g_slist_append(NULL, ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context))))
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
return NULL;
|
|
||||||
sdi->priv = devc;
|
sdi->priv = devc;
|
||||||
devc->profile = profile;
|
devc->profile = profile;
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,10 +178,7 @@ static GSList *scan(GSList *options)
|
||||||
|
|
||||||
//Create the device context and set its params
|
//Create the device context and set its params
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
sr_err("Device context malloc failed.");
|
|
||||||
return devices;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mso_parse_serial(iSerial, iProduct, devc) != SR_OK) {
|
if (mso_parse_serial(iSerial, iProduct, devc) != SR_OK) {
|
||||||
sr_err("Invalid iSerial: %s.", iSerial);
|
sr_err("Invalid iSerial: %s.", iSerial);
|
||||||
|
|
|
@ -95,15 +95,9 @@ static GSList *mic_scan(const char *conn, const char *serialcomm, int idx)
|
||||||
sdi->status = SR_ST_INACTIVE;
|
sdi->status = SR_ST_INACTIVE;
|
||||||
sdi->vendor = g_strdup(mic_devs[idx].vendor);
|
sdi->vendor = g_strdup(mic_devs[idx].vendor);
|
||||||
sdi->model = g_strdup(mic_devs[idx].device);
|
sdi->model = g_strdup(mic_devs[idx].device);
|
||||||
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
|
|
||||||
sr_err("Device context malloc failed.");
|
|
||||||
goto scan_cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
sdi->inst_type = SR_INST_SERIAL;
|
sdi->inst_type = SR_INST_SERIAL;
|
||||||
sdi->conn = serial;
|
sdi->conn = serial;
|
||||||
|
|
||||||
sdi->priv = devc;
|
sdi->priv = devc;
|
||||||
sdi->driver = mic_devs[idx].di;
|
sdi->driver = mic_devs[idx].di;
|
||||||
|
|
||||||
|
|
|
@ -149,14 +149,10 @@ static GSList *do_scan(struct sr_dev_driver* drv, GSList *options)
|
||||||
sdi->vendor = g_strdup(get_brandstr(drv));
|
sdi->vendor = g_strdup(get_brandstr(drv));
|
||||||
sdi->model = g_strdup(get_typestr(auxtype, drv));
|
sdi->model = g_strdup(get_typestr(auxtype, drv));
|
||||||
sdi->version = g_strdup(buf + 9);
|
sdi->version = g_strdup(buf + 9);
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
sr_err("Device context malloc failed.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
devc->type = auxtype;
|
devc->type = auxtype;
|
||||||
devc->version = g_strdup(&buf[9]);
|
devc->version = g_strdup(&buf[9]);
|
||||||
devc->elapsed_msec = g_timer_new();
|
devc->elapsed_msec = g_timer_new();
|
||||||
|
|
||||||
sdi->conn = serial;
|
sdi->conn = serial;
|
||||||
sdi->priv = devc;
|
sdi->priv = devc;
|
||||||
sdi->driver = drv;
|
sdi->driver = drv;
|
||||||
|
|
|
@ -124,10 +124,7 @@ SR_PRIV struct dev_context *ols_dev_new(void)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
sr_err("Device context malloc failed.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Device-specific settings */
|
/* Device-specific settings */
|
||||||
devc->max_samples = devc->max_samplerate = devc->protocol_version = 0;
|
devc->max_samples = devc->max_samplerate = devc->protocol_version = 0;
|
||||||
|
|
|
@ -100,10 +100,7 @@ static GSList *scan(GSList *options)
|
||||||
devices = NULL;
|
devices = NULL;
|
||||||
|
|
||||||
/* Allocate memory for our private device context. */
|
/* Allocate memory for our private device context. */
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
sr_err("Device context malloc failed.");
|
|
||||||
goto err_free_nothing;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Device-specific settings */
|
/* Device-specific settings */
|
||||||
devc->max_samplebytes = devc->max_samplerate = devc->protocol_version = 0;
|
devc->max_samplebytes = devc->max_samplerate = devc->protocol_version = 0;
|
||||||
|
@ -204,7 +201,6 @@ err_free_ftdi_buf:
|
||||||
g_free(devc->ftdi_buf);
|
g_free(devc->ftdi_buf);
|
||||||
err_free_devc:
|
err_free_devc:
|
||||||
g_free(devc);
|
g_free(devc);
|
||||||
err_free_nothing:
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -305,10 +305,7 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
|
||||||
sdi->driver = di;
|
sdi->driver = di;
|
||||||
sdi->inst_type = SR_INST_SCPI;
|
sdi->inst_type = SR_INST_SCPI;
|
||||||
sdi->serial_num = g_strdup(hw_info->serial_number);
|
sdi->serial_num = g_strdup(hw_info->serial_number);
|
||||||
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context))))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
devc->limit_frames = 0;
|
devc->limit_frames = 0;
|
||||||
devc->model = model;
|
devc->model = model;
|
||||||
devc->format = model->series->format;
|
devc->format = model->series->format;
|
||||||
|
|
|
@ -212,8 +212,7 @@ static GSList *scan(GSList *options)
|
||||||
sdi->channels = g_slist_append(sdi->channels, ch);
|
sdi->channels = g_slist_append(sdi->channels, ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context))))
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
return NULL;
|
|
||||||
devc->selected_voltage_range = VOLTAGE_RANGE_18_33_V;
|
devc->selected_voltage_range = VOLTAGE_RANGE_18_33_V;
|
||||||
sdi->priv = devc;
|
sdi->priv = devc;
|
||||||
drvc->instances = g_slist_append(drvc->instances, sdi);
|
drvc->instances = g_slist_append(drvc->instances, sdi);
|
||||||
|
|
|
@ -460,15 +460,9 @@ static GSList *sdmm_scan(const char *conn, const char *serialcomm, int dmm)
|
||||||
sdi->status = SR_ST_INACTIVE;
|
sdi->status = SR_ST_INACTIVE;
|
||||||
sdi->vendor = g_strdup(dmms[dmm].vendor);
|
sdi->vendor = g_strdup(dmms[dmm].vendor);
|
||||||
sdi->model = g_strdup(dmms[dmm].device);
|
sdi->model = g_strdup(dmms[dmm].device);
|
||||||
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
|
|
||||||
sr_err("Device context malloc failed.");
|
|
||||||
goto scan_cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
sdi->inst_type = SR_INST_SERIAL;
|
sdi->inst_type = SR_INST_SERIAL;
|
||||||
sdi->conn = serial;
|
sdi->conn = serial;
|
||||||
|
|
||||||
sdi->priv = devc;
|
sdi->priv = devc;
|
||||||
sdi->driver = dmms[dmm].di;
|
sdi->driver = dmms[dmm].di;
|
||||||
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
|
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
|
||||||
|
|
|
@ -105,11 +105,7 @@ static struct sr_dev_inst *dev_inst_new(void)
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
/* Allocate memory for our private driver context. */
|
/* Allocate memory for our private driver context. */
|
||||||
devc = g_try_new0(struct dev_context, 1);
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
if (!devc) {
|
|
||||||
sr_err("Device context malloc failed.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Register the device with libsigrok. */
|
/* Register the device with libsigrok. */
|
||||||
sdi = g_malloc0(sizeof(struct sr_dev_inst));
|
sdi = g_malloc0(sizeof(struct sr_dev_inst));
|
||||||
|
|
|
@ -96,14 +96,8 @@ static GSList *scan(GSList *options)
|
||||||
sdi->status = SR_ST_INACTIVE;
|
sdi->status = SR_ST_INACTIVE;
|
||||||
sdi->vendor = g_strdup("EDF");
|
sdi->vendor = g_strdup("EDF");
|
||||||
sdi->model = g_strdup("Teleinfo");
|
sdi->model = g_strdup("Teleinfo");
|
||||||
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
|
|
||||||
sr_err("Device context malloc failed.");
|
|
||||||
goto scan_cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
devc->optarif = teleinfo_get_optarif(buf);
|
devc->optarif = teleinfo_get_optarif(buf);
|
||||||
|
|
||||||
sdi->inst_type = SR_INST_SERIAL;
|
sdi->inst_type = SR_INST_SERIAL;
|
||||||
sdi->conn = serial;
|
sdi->conn = serial;
|
||||||
sdi->priv = devc;
|
sdi->priv = devc;
|
||||||
|
|
|
@ -88,11 +88,7 @@ static GSList *scan(GSList *options)
|
||||||
sdi->status = SR_ST_INACTIVE;
|
sdi->status = SR_ST_INACTIVE;
|
||||||
sdi->vendor = g_strdup("Tondaj");
|
sdi->vendor = g_strdup("Tondaj");
|
||||||
sdi->model = g_strdup("SL-814");
|
sdi->model = g_strdup("SL-814");
|
||||||
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
|
|
||||||
sr_err("Device context malloc failed.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(serial = sr_serial_dev_inst_new(conn, serialcomm)))
|
if (!(serial = sr_serial_dev_inst_new(conn, serialcomm)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -253,10 +253,7 @@ static GSList *scan(GSList *options, int dmm)
|
||||||
for (l = usb_devices; l; l = l->next) {
|
for (l = usb_devices; l; l = l->next) {
|
||||||
usb = l->data;
|
usb = l->data;
|
||||||
|
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
sr_err("Device context malloc failed.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
devc->first_run = TRUE;
|
devc->first_run = TRUE;
|
||||||
|
|
||||||
|
|
|
@ -94,11 +94,7 @@ static GSList *scan(GSList *options)
|
||||||
}
|
}
|
||||||
sdi->channels = g_slist_append(sdi->channels, ch);
|
sdi->channels = g_slist_append(sdi->channels, ch);
|
||||||
}
|
}
|
||||||
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
|
|
||||||
sr_dbg("Device context malloc failed.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
sdi->priv = devc;
|
sdi->priv = devc;
|
||||||
devc->limit_samples = 0;
|
devc->limit_samples = 0;
|
||||||
devc->data_source = DEFAULT_DATA_SOURCE;
|
devc->data_source = DEFAULT_DATA_SOURCE;
|
||||||
|
|
|
@ -89,9 +89,7 @@ static GSList *scan(GSList *options)
|
||||||
sdi->vendor = g_strdup(VICTOR_VENDOR);
|
sdi->vendor = g_strdup(VICTOR_VENDOR);
|
||||||
sdi->driver = di;
|
sdi->driver = di;
|
||||||
sdi->connection_id = g_strdup(connection_id);
|
sdi->connection_id = g_strdup(connection_id);
|
||||||
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context))))
|
|
||||||
return NULL;
|
|
||||||
sdi->priv = devc;
|
sdi->priv = devc;
|
||||||
|
|
||||||
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
|
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
|
||||||
|
|
|
@ -231,11 +231,7 @@ static GSList *scan(GSList *options)
|
||||||
sdi->connection_id = g_strdup(connection_id);
|
sdi->connection_id = g_strdup(connection_id);
|
||||||
|
|
||||||
/* Allocate memory for our private driver context. */
|
/* Allocate memory for our private driver context. */
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
sr_err("Device context malloc failed.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
sdi->priv = devc;
|
sdi->priv = devc;
|
||||||
devc->prof = prof;
|
devc->prof = prof;
|
||||||
devc->num_channels = prof->channels;
|
devc->num_channels = prof->channels;
|
||||||
|
|
|
@ -847,11 +847,7 @@ SR_PRIV struct sr_dev_inst *es51919_serial_scan(GSList *options,
|
||||||
sdi->status = SR_ST_INACTIVE;
|
sdi->status = SR_ST_INACTIVE;
|
||||||
sdi->vendor = g_strdup(vendor);
|
sdi->vendor = g_strdup(vendor);
|
||||||
sdi->model = g_strdup(model);
|
sdi->model = g_strdup(model);
|
||||||
|
devc = g_malloc0(sizeof(struct dev_context));
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
|
|
||||||
sr_err("Device context malloc failed.");
|
|
||||||
goto scan_cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(devc->buf = dev_buffer_new(PACKET_SIZE * 8)))
|
if (!(devc->buf = dev_buffer_new(PACKET_SIZE * 8)))
|
||||||
goto scan_cleanup;
|
goto scan_cleanup;
|
||||||
|
|
Loading…
Reference in New Issue