]> sigrok.org Git - libsigrok.git/commitdiff
Consistently use g_malloc0() for allocating devc.
authorUwe Hermann <redacted>
Fri, 21 Nov 2014 01:26:24 +0000 (02:26 +0100)
committerUwe Hermann <redacted>
Fri, 21 Nov 2014 11:09:01 +0000 (12:09 +0100)
We assume the allocation will always succeed, hence no need for
checking the returned value.

34 files changed:
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/fluke-dmm/api.c
src/hardware/fx2lafw/protocol.c
src/hardware/gmc-mh-1x-2x/api.c
src/hardware/hameg-hmo/api.c
src/hardware/ikalogic-scanalogic2/api.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/mic-985xx/api.c
src/hardware/norma-dmm/api.c
src/hardware/openbench-logic-sniffer/protocol.c
src/hardware/pipistrello-ols/api.c
src/hardware/rigol-ds/api.c
src/hardware/saleae-logic16/api.c
src/hardware/serial-dmm/api.c
src/hardware/sysclk-lwla/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/zeroplus-logic-cube/api.c
src/lcr/es51919.c

index e8767a61ae7c2c2451ec1ae9c7aff999121492c5..a41e730a4a1c675b63bac76d972b38a02fab98bd 100644 (file)
@@ -144,10 +144,7 @@ static GSList *scan(GSList *options)
                        sdi->vendor = g_strdup("Agilent");
                        sdi->model = g_strdup(tokens[1]);
                        sdi->version = g_strdup(tokens[3]);
-                       if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-                               sr_err("Device context malloc failed.");
-                               return NULL;
-                       }
+                       devc = g_malloc0(sizeof(struct dev_context));
                        devc->profile = &supported_agdmm[i];
                        devc->cur_mq = -1;
                        sdi->inst_type = SR_INST_SERIAL;
index 6598757b67d8a6b23ec24f6c5f5f9d34a958255d..9cdf9447fc5b68d48263c067557b9097aea78818 100644 (file)
@@ -103,14 +103,8 @@ static GSList *scan(GSList *options)
        sdi->status = SR_ST_INACTIVE;
        sdi->vendor = g_strdup("APPA");
        sdi->model = g_strdup("55II");
-
-       if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-               sr_err("Device context malloc failed.");
-               goto scan_cleanup;
-       }
-
+       devc = g_malloc0(sizeof(struct dev_context));
        devc->data_source = DEFAULT_DATA_SOURCE;
-
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
        sdi->priv = devc;
index 53e35816374614babce2568978c7e844750b3303..c02827461214329deae2c411d9fbe8657ff06bbe 100644 (file)
@@ -341,10 +341,7 @@ static GSList *scan(GSList *options)
 
        devices = NULL;
 
-       if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
-               sr_err("%s: devc malloc failed", __func__);
-               return NULL;
-       }
+       devc = g_malloc0(sizeof(struct dev_context));
 
        ftdi_init(&devc->ftdic);
 
index 9a39e1de9487ec735f82231f5e25bf7866725eb0..a703adf351cd2e1a1e875dc93d90b646f77ec7fe 100644 (file)
@@ -65,12 +65,11 @@ static int init(struct sr_context *sr_ctx)
        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;
 
-       /* Allocate zeroed structure */
-       devc = g_try_malloc0(sizeof(*devc));
+       devc = g_malloc0(sizeof(struct dev_context));
 
        /* Default non-zero values (if any) */
        devc->fd = -1;
index 38c130d290a44e1eebf5dd26364e06debbf89b81..c67aba18e8f3ea3f357bcfd018236e30c0c70bb8 100644 (file)
@@ -77,12 +77,7 @@ static GSList *scan(GSList *options)
                sdi->status = SR_ST_INACTIVE;
                sdi->vendor = g_strdup("Brymen");
                sdi->model = g_strdup("BM869");
-
-               if (!(devc = g_try_malloc0(sizeof(*devc)))) {
-                       sr_err("Device context malloc failed.");
-                       return NULL;
-               }
-
+               devc = g_malloc0(sizeof(struct dev_context));
                sdi->priv = devc;
                sdi->driver = di;
                if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
index 937135c6c1b77657ec7125beb785105aae519f39..0db5c2d83a7f8b9fba78eed01cab5eba673f6ccb 100644 (file)
@@ -79,12 +79,7 @@ static GSList *brymen_scan(const char *conn, const char *serialcomm)
        sdi->status = SR_ST_INACTIVE;
        sdi->vendor = g_strdup("Brymen");
        sdi->model = g_strdup("BM85x");
-
-       if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-               sr_err("Device context malloc failed.");
-               goto scan_cleanup;
-       }
-
+       devc = g_malloc0(sizeof(struct dev_context));
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
        drvc = di->priv;
index c8ca2b8f7a648b9003aa1eb9aee05052a6961ae2..62f580c5d8a583dae0250018b4113a87a1decd9e 100644 (file)
@@ -113,11 +113,7 @@ static GSList *scan(GSList *options)
                        sdi->status = SR_ST_INACTIVE;
                        sdi->vendor = g_strdup("CEM");
                        sdi->model = g_strdup("DT-885x");
-
-                       if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-                               sr_dbg("Device context malloc failed.");
-                               return NULL;
-                       }
+                       devc = g_malloc0(sizeof(struct dev_context));
                        devc->cur_mqflags = 0;
                        devc->recording = -1;
                        devc->cur_meas_range = 0;
index 13831c05a9af4b7b90e4771a31e2587e5bd78d61..8118a2b1f5ef099b49e066fe1ce97cac170079e9 100644 (file)
@@ -92,15 +92,9 @@ static GSList *center_scan(const char *conn, const char *serialcomm, int idx)
        sdi->status = SR_ST_INACTIVE;
        sdi->vendor = g_strdup(center_devs[idx].vendor);
        sdi->model = g_strdup(center_devs[idx].device);
-
-       if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-               sr_err("Device context malloc failed.");
-               goto scan_cleanup;
-       }
-
+       devc = g_malloc0(sizeof(struct dev_context));
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
-
        sdi->priv = devc;
        sdi->driver = center_devs[idx].di;
 
index b31db039b0f18420e8336349572f22096f41e652..d9e3cc3914edad598d79d45847afa66d17f2abce 100644 (file)
@@ -87,7 +87,7 @@ static int add_device(int idx, int model, GSList **devices)
        drvc = di->priv;
 
        /* 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. */
        devc->prof = &cv_profiles[model];
index e879a102189c19ad4f7c8df2091c34c27514d3ff..c7d36678601b485ba1f55fa6e2c847a4f455d3a2 100644 (file)
@@ -86,15 +86,9 @@ static GSList *scan(GSList *options)
        sdi->status = SR_ST_INACTIVE;
        sdi->vendor = g_strdup("Colead");
        sdi->model = g_strdup("SL-5868P");
-
-       if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-               sr_dbg("Device context malloc failed.");
-               return NULL;
-       }
-
+       devc = g_malloc0(sizeof(struct dev_context));
        if (!(sdi->conn = sr_serial_dev_inst_new(conn, serialcomm)))
                return NULL;
-
        sdi->inst_type = SR_INST_SERIAL;
        sdi->priv = devc;
        sdi->driver = di;
index a2208049094648aa5146aacf2d6e5ec0023c9377..4519d3a5ac8f7126b5ad634cfac826e46bf94dd6 100644 (file)
@@ -127,10 +127,7 @@ static GSList *fluke_scan(const char *conn, const char *serialcomm)
                                sdi->vendor = g_strdup("Fluke");
                                sdi->model = g_strdup(tokens[0] + 6);
                                sdi->version = g_strdup(tokens[1] + s);
-                               if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-                                       sr_err("Device context malloc failed.");
-                                       return NULL;
-                               }
+                               devc = g_malloc0(sizeof(struct dev_context));
                                devc->profile = &supported_flukedmm[i];
                                sdi->inst_type = SR_INST_SERIAL;
                                sdi->conn = serial;
index 7e7b189116c565bd6b7f352de84e340bdb247fe6..1a623ec63de1698eb65e38193b6f1ca9d05c9855 100644 (file)
@@ -299,11 +299,7 @@ SR_PRIV struct dev_context *fx2lafw_dev_new(void)
 {
        struct dev_context *devc;
 
-       if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
-               sr_err("Device context malloc failed.");
-               return NULL;
-       }
-
+       devc = g_malloc0(sizeof(struct dev_context));
        devc->profile = NULL;
        devc->fw_updated = 0;
        devc->cur_samplerate = 0;
index 32a471afe4e3cdf10a2acce95ab77ec45b41678f..02eb6d6e18e7bcb21778f9879336e71ea42bc00e 100644 (file)
@@ -227,17 +227,13 @@ static GSList *scan_1x_2x_rs232(GSList *options)
                sdi->status = SR_ST_INACTIVE;
                sdi->vendor = g_strdup(VENDOR_GMC);
                sdi->model = g_strdup(gmc_model_str(model));
-               if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-                       sr_err("Device context malloc failed.");
-                       return NULL;
-               }
+               devc = g_malloc0(sizeof(struct dev_context));
                devc->model = model;
                devc->limit_samples = 0;
                devc->limit_msec = 0;
                devc->num_samples = 0;
                devc->elapsed_msec = g_timer_new();
                devc->settings_ok = FALSE;
-
                sdi->conn = serial;
                sdi->priv = devc;
                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)
                goto exit_err;
 
-       if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-               sr_err("Device context malloc failed.");
-               goto exit_err;
-       }
+       devc = g_malloc0(sizeof(struct dev_context));
 
        sdi = g_malloc0(sizeof(struct sr_dev_inst));
        sdi->status = SR_ST_INACTIVE;
@@ -350,10 +343,7 @@ static GSList *scan_2x_bd232(GSList *options)
                        drvc->instances = g_slist_append(drvc->instances, sdi);
                        devices = g_slist_append(devices, sdi);
 
-                       if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-                               sr_err("Device context malloc failed.");
-                               goto exit_err;
-                       }
+                       devc = g_malloc0(sizeof(struct dev_context));
 
                        sdi = g_malloc0(sizeof(struct sr_dev_inst));
                        sdi->status = SR_ST_INACTIVE;
index d8a0f902ca26a0c53bb53ff4507ced775ec85e8e..8f27669ffde1c509b80e5ea728c5dbe53bc8bcec 100644 (file)
@@ -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);
        hw_info = NULL;
 
-       if (!(devc = g_try_malloc0(sizeof(struct dev_context))))
-               goto fail;
+       devc = g_malloc0(sizeof(struct dev_context));
 
        sdi->priv = devc;
 
index 380443c48304091d3d07ad4ed3cfcf8c8e8e8ac2..798ae8bd9468d7414aed939ddd924ee308b48c08 100644 (file)
@@ -91,11 +91,7 @@ static GSList *scan(GSList *options)
                        continue;
                }
 
-               if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
-                       sr_err("Device instance malloc failed.");
-                       sr_usb_dev_inst_free(usb);
-                       continue;
-               }
+               devc = g_malloc0(sizeof(struct dev_context));
 
                if (!(devc->xfer_in = libusb_alloc_transfer(0))) {
                        sr_err("Transfer malloc failed.");
index d8165c7d855a33718d3d8ce676151f6c245eb9cc..f3cd81201ab2e0d8a226d136bc76cddedcca8696 100644 (file)
@@ -88,10 +88,7 @@ static GSList *scan(GSList *options)
        devices = NULL;
 
        /* Allocate memory for our private device context. */
-       if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-               sr_err("Device context malloc failed.");
-               goto err_free_nothing;
-       }
+       devc = g_malloc0(sizeof(struct dev_context));
 
        /* Allocate memory for the incoming compressed samples. */
        if (!(devc->compressed_buf = g_try_malloc0(COMPRESSED_BUF_SIZE))) {
@@ -154,7 +151,6 @@ err_free_compressed_buf:
        g_free(devc->compressed_buf);
 err_free_devc:
        g_free(devc);
-err_free_nothing:
 
        return NULL;
 }
index 1e5480ac0581c35b3f47b33f54ccadb85f944717..04cfb247c92b4c09ff1dd53de7a344078ad5e8da 100644 (file)
@@ -139,11 +139,7 @@ static GSList *scan(GSList *options)
                        if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "SPL")))
                                return NULL;
                        sdi->channels = g_slist_append(sdi->channels, ch);
-
-                       if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
-                               sr_dbg("Device context malloc failed.");
-                               return NULL;
-                       }
+                       devc = g_malloc0(sizeof(struct dev_context));
                        sdi->priv = devc;
                        devc->limit_samples = 0;
                        /* The protocol provides no way to read the current
index 49ed649b2707f463260db29b23077902e250043e..c18357b35278068f72f078ef9a0b81f8954308f7 100644 (file)
@@ -348,8 +348,7 @@ static struct sr_dev_inst *lascar_identify(unsigned char *config)
                        sdi->channels = g_slist_append(NULL, ch);
                }
 
-               if (!(devc = g_try_malloc0(sizeof(struct dev_context))))
-                       return NULL;
+               devc = g_malloc0(sizeof(struct dev_context));
                sdi->priv = devc;
                devc->profile = profile;
        }
index c1162c982207f2c9f01317edc8b08a8563f343e9..5112fe285d2d0103b41e9c1b5f4f4421ce1c63f4 100644 (file)
@@ -178,10 +178,7 @@ static GSList *scan(GSList *options)
 
                //Create the device context and set its params
                struct dev_context *devc;
-               if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-                       sr_err("Device context malloc failed.");
-                       return devices;
-               }
+               devc = g_malloc0(sizeof(struct dev_context));
 
                if (mso_parse_serial(iSerial, iProduct, devc) != SR_OK) {
                        sr_err("Invalid iSerial: %s.", iSerial);
index ae48fb6e1122c4fbace3b5cfe44b0e36ae640980..ea6650463bc520e6f31d021a78c3ec7d64904c69 100644 (file)
@@ -95,15 +95,9 @@ static GSList *mic_scan(const char *conn, const char *serialcomm, int idx)
        sdi->status = SR_ST_INACTIVE;
        sdi->vendor = g_strdup(mic_devs[idx].vendor);
        sdi->model = g_strdup(mic_devs[idx].device);
-
-       if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-               sr_err("Device context malloc failed.");
-               goto scan_cleanup;
-       }
-
+       devc = g_malloc0(sizeof(struct dev_context));
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
-
        sdi->priv = devc;
        sdi->driver = mic_devs[idx].di;
 
index 2f56441af5f11da231141051bc75be152f7db17d..a0e53fc4d1b2983e729b9e3f2bc80ae6c74fc364 100644 (file)
@@ -149,14 +149,10 @@ static GSList *do_scan(struct sr_dev_driver* drv, GSList *options)
                        sdi->vendor = g_strdup(get_brandstr(drv));
                        sdi->model = g_strdup(get_typestr(auxtype, drv));
                        sdi->version = g_strdup(buf + 9);
-                       if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-                               sr_err("Device context malloc failed.");
-                               return NULL;
-                       }
+                       devc = g_malloc0(sizeof(struct dev_context));
                        devc->type = auxtype;
                        devc->version = g_strdup(&buf[9]);
                        devc->elapsed_msec = g_timer_new();
-
                        sdi->conn = serial;
                        sdi->priv = devc;
                        sdi->driver = drv;
index c998c29524e1ce8b2c6b8014c42f1de09641121a..584164e7ba412e02382b257ebc73a0339f4cebed 100644 (file)
@@ -124,10 +124,7 @@ SR_PRIV struct dev_context *ols_dev_new(void)
 {
        struct dev_context *devc;
 
-       if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
-               sr_err("Device context malloc failed.");
-               return NULL;
-       }
+       devc = g_malloc0(sizeof(struct dev_context));
 
        /* Device-specific settings */
        devc->max_samples = devc->max_samplerate = devc->protocol_version = 0;
index 2db23fd042eaea1ea39a1de1c194576b5d1d0d78..acbfcda0289606b66be4086ae0ef8c62fc7a6215 100644 (file)
@@ -100,10 +100,7 @@ static GSList *scan(GSList *options)
        devices = NULL;
 
        /* Allocate memory for our private device context. */
-       if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-               sr_err("Device context malloc failed.");
-               goto err_free_nothing;
-       }
+       devc = g_malloc0(sizeof(struct dev_context));
 
        /* Device-specific settings */
        devc->max_samplebytes = devc->max_samplerate = devc->protocol_version = 0;
@@ -204,7 +201,6 @@ err_free_ftdi_buf:
        g_free(devc->ftdi_buf);
 err_free_devc:
        g_free(devc);
-err_free_nothing:
 
        return NULL;
 }
index e17739971c136890dae416f61b61209353bb61b7..e988741eeaab6d8b17414fcc171577eee2e4fe5c 100644 (file)
@@ -305,10 +305,7 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
        sdi->driver = di;
        sdi->inst_type = SR_INST_SCPI;
        sdi->serial_num = g_strdup(hw_info->serial_number);
-
-       if (!(devc = g_try_malloc0(sizeof(struct dev_context))))
-               return NULL;
-
+       devc = g_malloc0(sizeof(struct dev_context));
        devc->limit_frames = 0;
        devc->model = model;
        devc->format = model->series->format;
index c3aaacc52c0a83250848697b30298fa3cde1eabf..21ccd557b69a6865e8d1a6962f221d41cf9c647a 100644 (file)
@@ -212,8 +212,7 @@ static GSList *scan(GSList *options)
                        sdi->channels = g_slist_append(sdi->channels, ch);
                }
 
-               if (!(devc = g_try_malloc0(sizeof(struct dev_context))))
-                       return NULL;
+               devc = g_malloc0(sizeof(struct dev_context));
                devc->selected_voltage_range = VOLTAGE_RANGE_18_33_V;
                sdi->priv = devc;
                drvc->instances = g_slist_append(drvc->instances, sdi);
index 2b300d4bd9e6add08c35f24f9bbe905800e0e5e8..268805b04f7cef9f354f0e2d60d617b31090210e 100644 (file)
@@ -460,15 +460,9 @@ static GSList *sdmm_scan(const char *conn, const char *serialcomm, int dmm)
        sdi->status = SR_ST_INACTIVE;
        sdi->vendor = g_strdup(dmms[dmm].vendor);
        sdi->model = g_strdup(dmms[dmm].device);
-
-       if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-               sr_err("Device context malloc failed.");
-               goto scan_cleanup;
-       }
-
+       devc = g_malloc0(sizeof(struct dev_context));
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
-
        sdi->priv = devc;
        sdi->driver = dmms[dmm].di;
        if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
index 90d7897dda3dee2f025c07119be0261cea688a39..1e3dd1d28ff6f725aa2d6b7571f5ebc3e7605e08 100644 (file)
@@ -105,11 +105,7 @@ static struct sr_dev_inst *dev_inst_new(void)
        struct dev_context *devc;
 
        /* Allocate memory for our private driver context. */
-       devc = g_try_new0(struct dev_context, 1);
-       if (!devc) {
-               sr_err("Device context malloc failed.");
-               return NULL;
-       }
+       devc = g_malloc0(sizeof(struct dev_context));
 
        /* Register the device with libsigrok. */
        sdi = g_malloc0(sizeof(struct sr_dev_inst));
index 0f099c210411d8fdf55d380d3b8be6329e4823fa..00d058aa26f87d16f0c7360f5841b26bfac93bfe 100644 (file)
@@ -96,14 +96,8 @@ static GSList *scan(GSList *options)
        sdi->status = SR_ST_INACTIVE;
        sdi->vendor = g_strdup("EDF");
        sdi->model = g_strdup("Teleinfo");
-
-       if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-               sr_err("Device context malloc failed.");
-               goto scan_cleanup;
-       }
-
+       devc = g_malloc0(sizeof(struct dev_context));
        devc->optarif = teleinfo_get_optarif(buf);
-
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
        sdi->priv = devc;
index 69aa30e90eb6e2bbcc0f8d65d36d5894a20efffe..12026c35ca82983ba604d3eaa3b7b389c0e23285 100644 (file)
@@ -88,11 +88,7 @@ static GSList *scan(GSList *options)
        sdi->status = SR_ST_INACTIVE;
        sdi->vendor = g_strdup("Tondaj");
        sdi->model = g_strdup("SL-814");
-
-       if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-               sr_err("Device context malloc failed.");
-               return NULL;
-       }
+       devc = g_malloc0(sizeof(struct dev_context));
 
        if (!(serial = sr_serial_dev_inst_new(conn, serialcomm)))
                return NULL;
index cf9185109d0ca53f4449cd6fce075c37ecc7e0a6..6feefed1b182a3afec5f0475f2a22fe494d13df1 100644 (file)
@@ -253,10 +253,7 @@ static GSList *scan(GSList *options, int dmm)
        for (l = usb_devices; l; l = l->next) {
                usb = l->data;
 
-               if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-                       sr_err("Device context malloc failed.");
-                       return NULL;
-               }
+               devc = g_malloc0(sizeof(struct dev_context));
 
                devc->first_run = TRUE;
 
index 95096c0b60d8e0c8c776ef8e79037c0afbd0f444..8c04e64a842c6fe96f656d21f5fb46cab6316d9b 100644 (file)
@@ -94,11 +94,7 @@ static GSList *scan(GSList *options)
                                }
                                sdi->channels = g_slist_append(sdi->channels, ch);
                        }
-
-                       if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
-                               sr_dbg("Device context malloc failed.");
-                               return NULL;
-                       }
+                       devc = g_malloc0(sizeof(struct dev_context));
                        sdi->priv = devc;
                        devc->limit_samples = 0;
                        devc->data_source = DEFAULT_DATA_SOURCE;
index 65e73d8ac903a54a6b5a1bbadd69a31cb976b796..c1620161c953eb38acd5dc82eb05fb5c8b322d6d 100644 (file)
@@ -89,9 +89,7 @@ static GSList *scan(GSList *options)
                sdi->vendor = g_strdup(VICTOR_VENDOR);
                sdi->driver = di;
                sdi->connection_id = g_strdup(connection_id);
-
-               if (!(devc = g_try_malloc0(sizeof(struct dev_context))))
-                       return NULL;
+               devc = g_malloc0(sizeof(struct dev_context));
                sdi->priv = devc;
 
                if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
index b2e7b7f38ce47409bf2ac30bff537d59c6c4480c..2cf5aaf117bb924e6bbcb62758802a9351b057ed 100644 (file)
@@ -231,11 +231,7 @@ static GSList *scan(GSList *options)
                sdi->connection_id = g_strdup(connection_id);
 
                /* Allocate memory for our private driver context. */
-               if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-                       sr_err("Device context malloc failed.");
-                       return NULL;
-               }
-
+               devc = g_malloc0(sizeof(struct dev_context));
                sdi->priv = devc;
                devc->prof = prof;
                devc->num_channels = prof->channels;
index ecfcd0ed7a5a0f703f83a139e3f5420fcf9c2537..d15c4d3820e18756b0ae0353ab58fcbd8172d214 100644 (file)
@@ -847,11 +847,7 @@ SR_PRIV struct sr_dev_inst *es51919_serial_scan(GSList *options,
        sdi->status = SR_ST_INACTIVE;
        sdi->vendor = g_strdup(vendor);
        sdi->model = g_strdup(model);
-
-       if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-               sr_err("Device context malloc failed.");
-               goto scan_cleanup;
-       }
+       devc = g_malloc0(sizeof(struct dev_context));
 
        if (!(devc->buf = dev_buffer_new(PACKET_SIZE * 8)))
                goto scan_cleanup;