]> sigrok.org Git - libsigrok.git/commitdiff
Don't check sr_channel_new() return value (always succeeds).
authorUwe Hermann <redacted>
Fri, 21 Nov 2014 08:07:04 +0000 (09:07 +0100)
committerUwe Hermann <redacted>
Fri, 21 Nov 2014 11:10:05 +0000 (12:10 +0100)
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.

39 files changed:
src/device.c
src/hardware/agilent-dmm/api.c
src/hardware/appa-55ii/api.c
src/hardware/asix-sigma/asix-sigma.c
src/hardware/beaglelogic/api.c
src/hardware/brymen-bm86x/api.c
src/hardware/brymen-dmm/api.c
src/hardware/cem-dt-885x/api.c
src/hardware/center-3xx/api.c
src/hardware/chronovu-la/api.c
src/hardware/colead-slm/api.c
src/hardware/conrad-digi-35-cpu/api.c
src/hardware/demo/demo.c
src/hardware/fluke-dmm/api.c
src/hardware/fx2lafw/api.c
src/hardware/gmc-mh-1x-2x/api.c
src/hardware/hameg-hmo/protocol.c
src/hardware/ikalogic-scanaplus/api.c
src/hardware/kecheng-kc-330b/api.c
src/hardware/lascar-el-usb/protocol.c
src/hardware/link-mso19/api.c
src/hardware/manson-hcs-3xxx/api.c
src/hardware/mic-985xx/api.c
src/hardware/norma-dmm/api.c
src/hardware/openbench-logic-sniffer/api.c
src/hardware/openbench-logic-sniffer/protocol.c
src/hardware/pipistrello-ols/protocol.c
src/hardware/rigol-ds/api.c
src/hardware/saleae-logic16/api.c
src/hardware/serial-dmm/api.c
src/hardware/teleinfo/api.c
src/hardware/tondaj-sl-814/api.c
src/hardware/uni-t-dmm/api.c
src/hardware/uni-t-ut32x/api.c
src/hardware/victor-dmm/api.c
src/hardware/yokogawa-dlm/protocol.c
src/hardware/zeroplus-logic-cube/api.c
src/lcr/es51919.c
src/session_file.c

index 8367ec28c40b9ab67312c762843fb4665dade92a..1945f01a9fb4a2ad0b8c5989677abc46bab6cf58 100644 (file)
  *  @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;
index a41e730a4a1c675b63bac76d972b38a02fab98bd..eb723bfad045177137c43ccfe75ef069b6b662c5 100644 (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);
index 9cdf9447fc5b68d48263c067557b9097aea78818..c36e72c8217896fa8fc94da3f7f5e31a8787b07c 100644 (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);
index c02827461214329deae2c411d9fbe8657ff06bbe..c577ca74686ca58268829c7c457efa35c339b08e 100644 (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);
        }
 
index a703adf351cd2e1a1e875dc93d90b646f77ec7fe..46abde3d881aa8e16a89e8272e7fb58efe5c9c19 100644 (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);
        }
 
index c67aba18e8f3ea3f357bcfd018236e30c0c70bb8..65fcb428ef078af0817dad445e9c4fecfd14b8d5 100644 (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;
index 0db5c2d83a7f8b9fba78eed01cab5eba673f6ccb..797d05a94a8f942775c88deaa6205285d99cf7e1 100644 (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);
index 62f580c5d8a583dae0250018b4113a87a1decd9e..29db2451bde727a1456df44a901f7c3f5d0b7943 100644 (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);
index 8118a2b1f5ef099b49e066fe1ce97cac170079e9..25df2eb040a2bcd040c0f78744fba16c525224d3 100644 (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;
index d9e3cc3914edad598d79d45847afa66d17f2abce..c9d7ec11cbd1aca58d38544ad67adcfd91831f54 100644 (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);
 
index c7d36678601b485ba1f55fa6e2c847a4f455d3a2..4c35f0fbc1b831ff27f5f76b0ee3aa697b93ba69 100644 (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);
index 850e29b04c9165733dfca37dcbd075de6afcd8e1..7f061fbbfc82599e52730208a702187c7b510d9a 100644 (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);
 
index c93542efeebbf87904339c25933e8d4dadfcc12d..26e49ca98b4c857419beb19aa41d8d08cf647425 100644 (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);
        }
index 4519d3a5ac8f7126b5ad634cfac826e46bf94dd6..fc3355c2f28a4eb6339e10b25ac2b6237053fc47 100644 (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);
index 64d3bfea574fc4a40129a2866acdd211f0b81565..7559f437b5da0282209bd9f8280f5768e7e03c37 100644 (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);
                }
 
index 02eb6d6e18e7bcb21778f9879336e71ea42bc00e..8e7d2c1b961f106440c8fae4a1a9706173f73721 100644 (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);
index c97658ea441990a5563ff582861349d3a180e7c6..8f39ba112b40f1955fe924a07a9db66c035b4e8f 100644 (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(
index f3cd81201ab2e0d8a226d136bc76cddedcca8696..ea508c0935c21e3b5323b66eb642ae0b94f66c00 100644 (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);
        }
 
index 04cfb247c92b4c09ff1dd53de7a344078ad5e8da..0f8304fc9d1ddc56adbf59bd61951219cd00733d 100644 (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;
index c18357b35278068f72f078ef9a0b81f8954308f7..801f83b024ad714f5e7a358d9ffcf929812e6199 100644 (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);
                }
 
index 5112fe285d2d0103b41e9c1b5f4f4421ce1c63f4..46270ffeb7fed89836e65cd3d295f8f6123b33d8 100644 (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);
                }
 
index d287067b195db92b1745274d5368859b91199c19..6355d004fc2eb2565f19d2d27a5923d142b4bf5b 100644 (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));
index ea6650463bc520e6f31d021a78c3ec7d64904c69..6e834bd4b23d866a3f3e8ce3c19ec37bf8d55447 100644 (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;
index a0e53fc4d1b2983e729b9e3f2bc80ae6c74fc364..34d7de145e58af9a7804c993b819fb8b3f13e583 100644 (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);
index 02cc02b52a53762bd8a8f812f23b00b46ab02276..cb55bf19a6f891b0cc3abe24c4bbf8c4f7215cec 100644 (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();
index 584164e7ba412e02382b257ebc73a0339f4cebed..b732da59c19e5a271b553a9be7288186e6cb6530 100644 (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;
index 7eddec0dac456adf43c589dc538403389203731e..272c8a8c3baa6f34206a9552cb12b3146de00f58 100644 (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;
index e988741eeaab6d8b17414fcc171577eee2e4fe5c..1c2a2ba18b0b3489c703475a30a4dd27bd5f79ae 100644 (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);
index 21ccd557b69a6865e8d1a6962f221d41cf9c647a..c30900b2ccdea4abe111d61c8bee27de0aa763dc 100644 (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);
                }
 
index 268805b04f7cef9f354f0e2d60d617b31090210e..f240266f1a0d3eccf91f301c088b32626dde31b7 100644 (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);
index 00d058aa26f87d16f0c7360f5841b26bfac93bfe..6089f3a5a918ac46b4cb65ac05de60f087772641 100644 (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);
index 12026c35ca82983ba604d3eaa3b7b389c0e23285..1b40b9f6f593d23d280517f070a7fd5bbf1d6d8d 100644 (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);
index 6feefed1b182a3afec5f0475f2a22fe494d13df1..e1580b998df3914c4f260c58370dd8f04c175ce8 100644 (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);
        }
index 8c04e64a842c6fe96f656d21f5fb46cab6316d9b..aa38cf5fb7bd04bb11be8c00b39bdc1d00ce4456 100644 (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));
index c1620161c953eb38acd5dc82eb05fb5c8b322d6d..de7e94b2fac8f3acef8f6d1bf35d657779a6ddb6 100644 (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]),
index 09d3c9b8faf86512054482ef544f1a4ed23d3175..5dc03194af2ca207773f31d4d73ec564bd6c00d1 100644 (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(
index 2cf5aaf117bb924e6bbcb62758802a9351b057ed..fa6ef1dc3c76a58ea02c47fb5d3cf412dbe5d999 100644 (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);
                }
 
index d15c4d3820e18756b0ae0353ab58fcbd8172d214..0c9054a8670467c6e8476fa9fd0caa1e0b85bc36 100644 (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;
index 6433998a202ad3cb11e4aa163767a93e63ea3d9c..8b4f60b592dfcc893600aa80f816a914710765a1 100644 (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)) {