Don't check sr_channel_new() return value (always succeeds).

We now use g_malloc0() for the allocation and assume the allocation
will always succeed, thus sr_channel_new() will always return a
valid new channel.
This commit is contained in:
Uwe Hermann 2014-11-21 09:07:04 +01:00
parent f57d8ffe66
commit c368e6f3d2
39 changed files with 80 additions and 179 deletions

View File

@ -48,18 +48,14 @@
* @param[in] enabled @copydoc sr_channel::enabled
* @param[in] name @copydoc sr_channel::name
*
* @return NULL (failure) or new struct sr_channel*.
* @return A new struct sr_channel*.
*/
SR_PRIV struct sr_channel *sr_channel_new(int index, int type,
gboolean enabled, const char *name)
{
struct sr_channel *ch;
if (!(ch = g_try_malloc0(sizeof(struct sr_channel)))) {
sr_err("Channel malloc failed.");
return NULL;
}
ch = g_malloc0(sizeof(struct sr_channel));
ch->index = index;
ch->type = type;
ch->enabled = enabled;
@ -237,9 +233,6 @@ SR_API int sr_dev_inst_channel_add(struct sr_dev_inst *sdi, int index, int type,
return SR_ERR_ARG;
ch = sr_channel_new(index, type, TRUE, name);
if (!ch)
return SR_ERR;
sdi->channels = g_slist_append(sdi->channels, ch);
return SR_OK;

View File

@ -151,8 +151,7 @@ static GSList *scan(GSList *options)
sdi->conn = serial;
sdi->priv = devc;
sdi->driver = di;
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
return NULL;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);

View File

@ -110,11 +110,9 @@ static GSList *scan(GSList *options)
sdi->priv = devc;
sdi->driver = di;
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "T1")))
goto scan_cleanup;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "T1");
sdi->channels = g_slist_append(sdi->channels, ch);
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "T2")))
goto scan_cleanup;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "T2");
sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi);

View File

@ -386,8 +386,6 @@ static GSList *scan(GSList *options)
for (i = 0; i < ARRAY_SIZE(channel_names); i++) {
ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
channel_names[i]);
if (!ch)
return NULL;
sdi->channels = g_slist_append(sdi->channels, ch);
}

View File

@ -136,9 +136,8 @@ static GSList *scan(GSList *options)
/* Fill the channels */
for (i = 0; i < maxch; i++) {
if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
beaglelogic_channel_names[i])))
return NULL;
ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
beaglelogic_channel_names[i]);
sdi->channels = g_slist_append(sdi->channels, ch);
}

View File

@ -80,11 +80,9 @@ static GSList *scan(GSList *options)
devc = g_malloc0(sizeof(struct dev_context));
sdi->priv = devc;
sdi->driver = di;
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
return NULL;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
sdi->channels = g_slist_append(sdi->channels, ch);
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P2")))
return NULL;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P2");
sdi->channels = g_slist_append(sdi->channels, ch);
sdi->inst_type = SR_INST_USB;

View File

@ -85,10 +85,7 @@ static GSList *brymen_scan(const char *conn, const char *serialcomm)
drvc = di->priv;
sdi->priv = devc;
sdi->driver = di;
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
goto scan_cleanup;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);

View File

@ -126,8 +126,7 @@ static GSList *scan(GSList *options)
sdi->inst_type = SR_INST_SERIAL;
sdi->priv = devc;
sdi->driver = di;
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "SPL")))
return NULL;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "SPL");
sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);

View File

@ -99,16 +99,14 @@ static GSList *center_scan(const char *conn, const char *serialcomm, int idx)
sdi->driver = center_devs[idx].di;
for (i = 0; i < center_devs[idx].num_channels; i++) {
if (!(ch = sr_channel_new(i, SR_CHANNEL_ANALOG,
TRUE, channel_names[i])))
goto scan_cleanup;
ch = sr_channel_new(i, SR_CHANNEL_ANALOG,
TRUE, channel_names[i]);
sdi->channels = g_slist_append(sdi->channels, ch);
}
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
scan_cleanup:
serial_close(serial);
return devices;

View File

@ -128,11 +128,8 @@ static int add_device(int idx, int model, GSList **devices)
sdi->priv = devc;
for (i = 0; i < devc->prof->num_channels; i++) {
if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
cv_channel_names[i]))) {
ret = SR_ERR;
goto err_free_dev_inst;
}
ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
cv_channel_names[i]);
sdi->channels = g_slist_append(sdi->channels, ch);
}
@ -142,9 +139,6 @@ static int add_device(int idx, int model, GSList **devices)
if (ret == SR_OK)
return SR_OK;
err_free_dev_inst:
sr_dev_inst_free(sdi);
g_free(devc->final_buf);
err_free_devc:
g_free(devc);

View File

@ -92,8 +92,7 @@ static GSList *scan(GSList *options)
sdi->inst_type = SR_INST_SERIAL;
sdi->priv = devc;
sdi->driver = di;
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
return NULL;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);

View File

@ -101,10 +101,8 @@ static GSList *scan(GSList *options)
sdi->conn = serial;
sdi->priv = NULL;
sdi->driver = di;
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "CH1")))
return NULL;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "CH1");
sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);

View File

@ -311,8 +311,7 @@ static GSList *scan(GSList *options)
cg->name = g_strdup("Logic");
for (i = 0; i < num_logic_channels; i++) {
sprintf(channel_name, "D%d", i);
if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, channel_name)))
return NULL;
ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, channel_name);
sdi->channels = g_slist_append(sdi->channels, ch);
cg->channels = g_slist_append(cg->channels, ch);
}

View File

@ -133,8 +133,7 @@ static GSList *fluke_scan(const char *conn, const char *serialcomm)
sdi->conn = serial;
sdi->priv = devc;
sdi->driver = di;
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
return NULL;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);

View File

@ -253,9 +253,8 @@ static GSList *scan(GSList *options)
/* Fill in channellist according to this device's profile. */
num_logic_channels = prof->dev_caps & DEV_CAPS_16BIT ? 16 : 8;
for (j = 0; j < num_logic_channels; j++) {
if (!(ch = sr_channel_new(j, SR_CHANNEL_LOGIC, TRUE,
channel_names[j])))
return NULL;
ch = sr_channel_new(j, SR_CHANNEL_LOGIC, TRUE,
channel_names[j]);
sdi->channels = g_slist_append(sdi->channels, ch);
}

View File

@ -237,8 +237,7 @@ static GSList *scan_1x_2x_rs232(GSList *options)
sdi->conn = serial;
sdi->priv = devc;
sdi->driver = &gmc_mh_1x_2x_rs232_driver_info;
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
return NULL;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
@ -329,22 +328,17 @@ static GSList *scan_2x_bd232(GSList *options)
if (devc->model != METRAHIT_NONE) {
sr_spew("%s %s detected!", VENDOR_GMC, gmc_model_str(devc->model));
devc->elapsed_msec = g_timer_new();
sdi->model = g_strdup(gmc_model_str(devc->model));
sdi->version = g_strdup_printf("Firmware %d.%d", devc->fw_ver_maj, devc->fw_ver_min);
sdi->conn = serial;
sdi->priv = devc;
sdi->driver = &gmc_mh_2x_bd232_driver_info;
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
goto exit_err;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
devc = g_malloc0(sizeof(struct dev_context));
sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(VENDOR_GMC);

View File

@ -616,9 +616,8 @@ SR_PRIV int hmo_init_device(struct sr_dev_inst *sdi)
/* Add analog channels. */
for (i = 0; i < scope_models[model_index].analog_channels; i++) {
if (!(ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE,
(*scope_models[model_index].analog_names)[i])))
return SR_ERR_MALLOC;
ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE,
(*scope_models[model_index].analog_names)[i]);
sdi->channels = g_slist_append(sdi->channels, ch);
devc->analog_groups[i] = g_malloc0(sizeof(struct sr_channel_group));
@ -644,9 +643,8 @@ SR_PRIV int hmo_init_device(struct sr_dev_inst *sdi)
/* Add digital channels. */
for (i = 0; i < scope_models[model_index].digital_channels; i++) {
if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
(*scope_models[model_index].digital_names)[i])))
return SR_ERR_MALLOC;
ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
(*scope_models[model_index].digital_names)[i]);
sdi->channels = g_slist_append(sdi->channels, ch);
devc->digital_groups[i < 8 ? 0 : 1]->channels = g_slist_append(

View File

@ -128,9 +128,8 @@ static GSList *scan(GSList *options)
sdi->priv = devc;
for (i = 0; channel_names[i]; i++) {
if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
channel_names[i])))
return NULL;
ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
channel_names[i]);
sdi->channels = g_slist_append(sdi->channels, ch);
}

View File

@ -136,8 +136,7 @@ static GSList *scan(GSList *options)
sdi->driver = di;
sdi->inst_type = SR_INST_USB;
sdi->conn = l->data;
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "SPL")))
return NULL;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "SPL");
sdi->channels = g_slist_append(sdi->channels, ch);
devc = g_malloc0(sizeof(struct dev_context));
sdi->priv = devc;

View File

@ -332,19 +332,15 @@ static struct sr_dev_inst *lascar_identify(unsigned char *config)
if (profile->logformat == LOG_TEMP_RH) {
/* Model this as two channels: temperature and humidity. */
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "Temp")))
return NULL;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "Temp");
sdi->channels = g_slist_append(NULL, ch);
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "Hum")))
return NULL;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "Hum");
sdi->channels = g_slist_append(sdi->channels, ch);
} else if (profile->logformat == LOG_CO) {
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "CO")))
return NULL;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "CO");
sdi->channels = g_slist_append(NULL, ch);
} else {
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
return NULL;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
sdi->channels = g_slist_append(NULL, ch);
}

View File

@ -220,9 +220,8 @@ static GSList *scan(GSList *options)
for (i = 0; i < NUM_CHANNELS; i++) {
struct sr_channel *ch;
chtype = (i == 0) ? SR_CHANNEL_ANALOG : SR_CHANNEL_LOGIC;
if (!(ch = sr_channel_new(i, chtype, TRUE,
mso19_channel_names[i])))
return 0;
ch = sr_channel_new(i, chtype, TRUE,
mso19_channel_names[i]);
sdi->channels = g_slist_append(sdi->channels, ch);
}

View File

@ -163,10 +163,7 @@ static GSList *scan(GSList *options)
sdi->conn = serial;
sdi->driver = di;
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "CH1"))) {
sr_err("Failed to create channel.");
goto exit_err;
}
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "CH1");
sdi->channels = g_slist_append(sdi->channels, ch);
devc = g_malloc0(sizeof(struct dev_context));

View File

@ -101,20 +101,17 @@ static GSList *mic_scan(const char *conn, const char *serialcomm, int idx)
sdi->priv = devc;
sdi->driver = mic_devs[idx].di;
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "Temperature")))
goto scan_cleanup;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "Temperature");
sdi->channels = g_slist_append(sdi->channels, ch);
if (mic_devs[idx].has_humidity) {
if (!(ch = sr_channel_new(1, SR_CHANNEL_ANALOG, TRUE, "Humidity")))
goto scan_cleanup;
ch = sr_channel_new(1, SR_CHANNEL_ANALOG, TRUE, "Humidity");
sdi->channels = g_slist_append(sdi->channels, ch);
}
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
scan_cleanup:
serial_close(serial);
return devices;

View File

@ -156,9 +156,7 @@ static GSList *do_scan(struct sr_dev_driver* drv, GSList *options)
sdi->conn = serial;
sdi->priv = devc;
sdi->driver = drv;
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE,
"P1")))
return NULL;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);

View File

@ -187,9 +187,8 @@ static GSList *scan(GSList *options)
sdi->version = g_strdup("v1.0");
sdi->driver = di;
for (i = 0; i < 32; i++) {
if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
ols_channel_names[i])))
return 0;
ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
ols_channel_names[i]);
sdi->channels = g_slist_append(sdi->channels, ch);
}
devc = ols_dev_new();

View File

@ -216,9 +216,8 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial)
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;
@ -255,9 +254,8 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial)
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;

View File

@ -289,9 +289,8 @@ SR_PRIV struct sr_dev_inst *p_ols_get_metadata(uint8_t *buf, int bytes_read, str
case 0x00:
/* Number of usable channels */
for (ui = 0; ui < tmp_int; ui++) {
if (!(ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE,
p_ols_channel_names[ui])))
return 0;
ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE,
p_ols_channel_names[ui]);
sdi->channels = g_slist_append(sdi->channels, ch);
}
break;
@ -326,9 +325,8 @@ SR_PRIV struct sr_dev_inst *p_ols_get_metadata(uint8_t *buf, int bytes_read, str
case 0x00:
/* Number of usable channels */
for (ui = 0; ui < tmp_c; ui++) {
if (!(ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE,
p_ols_channel_names[ui])))
return 0;
ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE,
p_ols_channel_names[ui]);
sdi->channels = g_slist_append(sdi->channels, ch);
}
break;

View File

@ -361,8 +361,6 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
return NULL;
ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, channel_name);
g_free(channel_name);
if (!ch)
return NULL;
sdi->channels = g_slist_append(sdi->channels, ch);
devc->digital_group->channels = g_slist_append(
devc->digital_group->channels, ch);

View File

@ -206,9 +206,8 @@ static GSList *scan(GSList *options)
sdi->connection_id = g_strdup(connection_id);
for (j = 0; channel_names[j]; j++) {
if (!(ch = sr_channel_new(j, SR_CHANNEL_LOGIC, TRUE,
channel_names[j])))
return NULL;
ch = sr_channel_new(j, SR_CHANNEL_LOGIC, TRUE,
channel_names[j]);
sdi->channels = g_slist_append(sdi->channels, ch);
}

View File

@ -465,8 +465,7 @@ static GSList *sdmm_scan(const char *conn, const char *serialcomm, int dmm)
sdi->conn = serial;
sdi->priv = devc;
sdi->driver = dmms[dmm].di;
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
goto scan_cleanup;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);

View File

@ -103,55 +103,41 @@ static GSList *scan(GSList *options)
sdi->priv = devc;
sdi->driver = di;
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P")))
goto scan_cleanup;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P");
sdi->channels = g_slist_append(sdi->channels, ch);
if (devc->optarif == OPTARIF_BASE) {
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "BASE")))
goto scan_cleanup;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "BASE");
sdi->channels = g_slist_append(sdi->channels, ch);
} else if (devc->optarif == OPTARIF_HC) {
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HP")))
goto scan_cleanup;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HP");
sdi->channels = g_slist_append(sdi->channels, ch);
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HC")))
goto scan_cleanup;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HC");
sdi->channels = g_slist_append(sdi->channels, ch);
} else if (devc->optarif == OPTARIF_EJP) {
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HN")))
goto scan_cleanup;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HN");
sdi->channels = g_slist_append(sdi->channels, ch);
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPM")))
goto scan_cleanup;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPM");
sdi->channels = g_slist_append(sdi->channels, ch);
} else if (devc->optarif == OPTARIF_BBR) {
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPJB")))
goto scan_cleanup;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPJB");
sdi->channels = g_slist_append(sdi->channels, ch);
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPJW")))
goto scan_cleanup;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPJW");
sdi->channels = g_slist_append(sdi->channels, ch);
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPJR")))
goto scan_cleanup;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HPJR");
sdi->channels = g_slist_append(sdi->channels, ch);
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HCJB")))
goto scan_cleanup;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HCJB");
sdi->channels = g_slist_append(sdi->channels, ch);
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HCJW")))
goto scan_cleanup;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HCJW");
sdi->channels = g_slist_append(sdi->channels, ch);
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HCJR")))
goto scan_cleanup;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "HCJR");
sdi->channels = g_slist_append(sdi->channels, ch);
}
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "IINST")))
goto scan_cleanup;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "IINST");
sdi->channels = g_slist_append(sdi->channels, ch);
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "PAPP")))
goto scan_cleanup;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "PAPP");
sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi);

View File

@ -102,10 +102,6 @@ static GSList *scan(GSList *options)
sdi->priv = devc;
sdi->driver = di;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
if (!ch) {
sr_err("Failed to create channel.");
return NULL;
}
sdi->channels = g_slist_append(sdi->channels, ch);
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);

View File

@ -252,24 +252,18 @@ static GSList *scan(GSList *options, int dmm)
for (l = usb_devices; l; l = l->next) {
usb = l->data;
devc = g_malloc0(sizeof(struct dev_context));
devc->first_run = TRUE;
sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(udmms[dmm].vendor);
sdi->model = g_strdup(udmms[dmm].device);
sdi->priv = devc;
sdi->driver = udmms[dmm].di;
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
return NULL;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
sdi->channels = g_slist_append(sdi->channels, ch);
sdi->inst_type = SR_INST_USB;
sdi->conn = usb;
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
}

View File

@ -87,11 +87,8 @@ static GSList *scan(GSList *options)
sdi->inst_type = SR_INST_USB;
sdi->conn = l->data;
for (i = 0; i < 3; i++) {
if (!(ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE,
channels[i]))) {
sr_dbg("Channel malloc failed.");
return NULL;
}
ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE,
channels[i]);
sdi->channels = g_slist_append(sdi->channels, ch);
}
devc = g_malloc0(sizeof(struct dev_context));

View File

@ -92,8 +92,7 @@ static GSList *scan(GSList *options)
devc = g_malloc0(sizeof(struct dev_context));
sdi->priv = devc;
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
return NULL;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1");
sdi->channels = g_slist_append(NULL, ch);
if (!(sdi->conn = sr_usb_dev_inst_new(libusb_get_bus_number(devlist[i]),

View File

@ -669,9 +669,8 @@ SR_PRIV int dlm_device_init(struct sr_dev_inst *sdi, int model_index)
/* Add analog channels. */
for (i = 0; i < scope_models[model_index].analog_channels; i++) {
if (!(ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE,
(*scope_models[model_index].analog_names)[i])))
return SR_ERR_MALLOC;
ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE,
(*scope_models[model_index].analog_names)[i]);
sdi->channels = g_slist_append(sdi->channels, ch);
devc->analog_groups[i] = g_malloc0(sizeof(struct sr_channel_group));
@ -699,9 +698,8 @@ SR_PRIV int dlm_device_init(struct sr_dev_inst *sdi, int model_index)
/* Add digital channels. */
for (i = 0; i < scope_models[model_index].digital_channels; i++) {
if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
(*scope_models[model_index].digital_names)[i])))
return SR_ERR_MALLOC;
ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
(*scope_models[model_index].digital_names)[i]);
sdi->channels = g_slist_append(sdi->channels, ch);
devc->digital_groups[i / 8]->channels = g_slist_append(

View File

@ -248,9 +248,8 @@ static GSList *scan(GSList *options)
/* Fill in channellist according to this device's profile. */
for (j = 0; j < devc->num_channels; j++) {
if (!(ch = sr_channel_new(j, SR_CHANNEL_LOGIC, TRUE,
channel_names[j])))
return NULL;
ch = sr_channel_new(j, SR_CHANNEL_LOGIC, TRUE,
channel_names[j]);
sdi->channels = g_slist_append(sdi->channels, ch);
}

View File

@ -783,9 +783,7 @@ static int add_channel(struct sr_dev_inst *sdi, const char *name)
{
struct sr_channel *ch;
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, name)))
return SR_ERR;
ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, name);
sdi->channels = g_slist_append(sdi->channels, ch);
return SR_OK;

View File

@ -213,9 +213,8 @@ SR_API int sr_session_load(const char *filename, struct sr_session **session)
g_variant_new_uint64(total_channels), sdi, NULL);
for (p = 0; p < total_channels; p++) {
snprintf(channelname, SR_MAX_CHANNELNAME_LEN, "%" PRIu64, p);
if (!(ch = sr_channel_new(p, SR_CHANNEL_LOGIC, TRUE,
channelname)))
return SR_ERR;
ch = sr_channel_new(p, SR_CHANNEL_LOGIC, TRUE,
channelname);
sdi->channels = g_slist_append(sdi->channels, ch);
}
} else if (!strncmp(keys[j], "probe", 5)) {