From: Uwe Hermann Date: Fri, 21 Nov 2014 01:26:24 +0000 (+0100) Subject: Consistently use g_malloc0() for allocating devc. X-Git-Tag: libsigrok-0.4.0~729 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=f57d8ffe66612a1fdc20ed09c222f8ea59bd84d4;p=libsigrok.git Consistently use g_malloc0() for allocating devc. We assume the allocation will always succeed, hence no need for checking the returned value. --- diff --git a/src/hardware/agilent-dmm/api.c b/src/hardware/agilent-dmm/api.c index e8767a61..a41e730a 100644 --- a/src/hardware/agilent-dmm/api.c +++ b/src/hardware/agilent-dmm/api.c @@ -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; diff --git a/src/hardware/appa-55ii/api.c b/src/hardware/appa-55ii/api.c index 6598757b..9cdf9447 100644 --- a/src/hardware/appa-55ii/api.c +++ b/src/hardware/appa-55ii/api.c @@ -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; diff --git a/src/hardware/asix-sigma/asix-sigma.c b/src/hardware/asix-sigma/asix-sigma.c index 53e35816..c0282746 100644 --- a/src/hardware/asix-sigma/asix-sigma.c +++ b/src/hardware/asix-sigma/asix-sigma.c @@ -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); diff --git a/src/hardware/beaglelogic/api.c b/src/hardware/beaglelogic/api.c index 9a39e1de..a703adf3 100644 --- a/src/hardware/beaglelogic/api.c +++ b/src/hardware/beaglelogic/api.c @@ -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; diff --git a/src/hardware/brymen-bm86x/api.c b/src/hardware/brymen-bm86x/api.c index 38c130d2..c67aba18 100644 --- a/src/hardware/brymen-bm86x/api.c +++ b/src/hardware/brymen-bm86x/api.c @@ -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"))) diff --git a/src/hardware/brymen-dmm/api.c b/src/hardware/brymen-dmm/api.c index 937135c6..0db5c2d8 100644 --- a/src/hardware/brymen-dmm/api.c +++ b/src/hardware/brymen-dmm/api.c @@ -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; diff --git a/src/hardware/cem-dt-885x/api.c b/src/hardware/cem-dt-885x/api.c index c8ca2b8f..62f580c5 100644 --- a/src/hardware/cem-dt-885x/api.c +++ b/src/hardware/cem-dt-885x/api.c @@ -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; diff --git a/src/hardware/center-3xx/api.c b/src/hardware/center-3xx/api.c index 13831c05..8118a2b1 100644 --- a/src/hardware/center-3xx/api.c +++ b/src/hardware/center-3xx/api.c @@ -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; diff --git a/src/hardware/chronovu-la/api.c b/src/hardware/chronovu-la/api.c index b31db039..d9e3cc39 100644 --- a/src/hardware/chronovu-la/api.c +++ b/src/hardware/chronovu-la/api.c @@ -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]; diff --git a/src/hardware/colead-slm/api.c b/src/hardware/colead-slm/api.c index e879a102..c7d36678 100644 --- a/src/hardware/colead-slm/api.c +++ b/src/hardware/colead-slm/api.c @@ -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; diff --git a/src/hardware/fluke-dmm/api.c b/src/hardware/fluke-dmm/api.c index a2208049..4519d3a5 100644 --- a/src/hardware/fluke-dmm/api.c +++ b/src/hardware/fluke-dmm/api.c @@ -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; diff --git a/src/hardware/fx2lafw/protocol.c b/src/hardware/fx2lafw/protocol.c index 7e7b1891..1a623ec6 100644 --- a/src/hardware/fx2lafw/protocol.c +++ b/src/hardware/fx2lafw/protocol.c @@ -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; diff --git a/src/hardware/gmc-mh-1x-2x/api.c b/src/hardware/gmc-mh-1x-2x/api.c index 32a471af..02eb6d6e 100644 --- a/src/hardware/gmc-mh-1x-2x/api.c +++ b/src/hardware/gmc-mh-1x-2x/api.c @@ -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; diff --git a/src/hardware/hameg-hmo/api.c b/src/hardware/hameg-hmo/api.c index d8a0f902..8f27669f 100644 --- a/src/hardware/hameg-hmo/api.c +++ b/src/hardware/hameg-hmo/api.c @@ -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; diff --git a/src/hardware/ikalogic-scanalogic2/api.c b/src/hardware/ikalogic-scanalogic2/api.c index 380443c4..798ae8bd 100644 --- a/src/hardware/ikalogic-scanalogic2/api.c +++ b/src/hardware/ikalogic-scanalogic2/api.c @@ -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."); diff --git a/src/hardware/ikalogic-scanaplus/api.c b/src/hardware/ikalogic-scanaplus/api.c index d8165c7d..f3cd8120 100644 --- a/src/hardware/ikalogic-scanaplus/api.c +++ b/src/hardware/ikalogic-scanaplus/api.c @@ -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; } diff --git a/src/hardware/kecheng-kc-330b/api.c b/src/hardware/kecheng-kc-330b/api.c index 1e5480ac..04cfb247 100644 --- a/src/hardware/kecheng-kc-330b/api.c +++ b/src/hardware/kecheng-kc-330b/api.c @@ -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 diff --git a/src/hardware/lascar-el-usb/protocol.c b/src/hardware/lascar-el-usb/protocol.c index 49ed649b..c18357b3 100644 --- a/src/hardware/lascar-el-usb/protocol.c +++ b/src/hardware/lascar-el-usb/protocol.c @@ -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; } diff --git a/src/hardware/link-mso19/api.c b/src/hardware/link-mso19/api.c index c1162c98..5112fe28 100644 --- a/src/hardware/link-mso19/api.c +++ b/src/hardware/link-mso19/api.c @@ -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); diff --git a/src/hardware/mic-985xx/api.c b/src/hardware/mic-985xx/api.c index ae48fb6e..ea665046 100644 --- a/src/hardware/mic-985xx/api.c +++ b/src/hardware/mic-985xx/api.c @@ -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; diff --git a/src/hardware/norma-dmm/api.c b/src/hardware/norma-dmm/api.c index 2f56441a..a0e53fc4 100644 --- a/src/hardware/norma-dmm/api.c +++ b/src/hardware/norma-dmm/api.c @@ -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; diff --git a/src/hardware/openbench-logic-sniffer/protocol.c b/src/hardware/openbench-logic-sniffer/protocol.c index c998c295..584164e7 100644 --- a/src/hardware/openbench-logic-sniffer/protocol.c +++ b/src/hardware/openbench-logic-sniffer/protocol.c @@ -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; diff --git a/src/hardware/pipistrello-ols/api.c b/src/hardware/pipistrello-ols/api.c index 2db23fd0..acbfcda0 100644 --- a/src/hardware/pipistrello-ols/api.c +++ b/src/hardware/pipistrello-ols/api.c @@ -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; } diff --git a/src/hardware/rigol-ds/api.c b/src/hardware/rigol-ds/api.c index e1773997..e988741e 100644 --- a/src/hardware/rigol-ds/api.c +++ b/src/hardware/rigol-ds/api.c @@ -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; diff --git a/src/hardware/saleae-logic16/api.c b/src/hardware/saleae-logic16/api.c index c3aaacc5..21ccd557 100644 --- a/src/hardware/saleae-logic16/api.c +++ b/src/hardware/saleae-logic16/api.c @@ -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); diff --git a/src/hardware/serial-dmm/api.c b/src/hardware/serial-dmm/api.c index 2b300d4b..268805b0 100644 --- a/src/hardware/serial-dmm/api.c +++ b/src/hardware/serial-dmm/api.c @@ -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"))) diff --git a/src/hardware/sysclk-lwla/api.c b/src/hardware/sysclk-lwla/api.c index 90d7897d..1e3dd1d2 100644 --- a/src/hardware/sysclk-lwla/api.c +++ b/src/hardware/sysclk-lwla/api.c @@ -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)); diff --git a/src/hardware/teleinfo/api.c b/src/hardware/teleinfo/api.c index 0f099c21..00d058aa 100644 --- a/src/hardware/teleinfo/api.c +++ b/src/hardware/teleinfo/api.c @@ -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; diff --git a/src/hardware/tondaj-sl-814/api.c b/src/hardware/tondaj-sl-814/api.c index 69aa30e9..12026c35 100644 --- a/src/hardware/tondaj-sl-814/api.c +++ b/src/hardware/tondaj-sl-814/api.c @@ -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; diff --git a/src/hardware/uni-t-dmm/api.c b/src/hardware/uni-t-dmm/api.c index cf918510..6feefed1 100644 --- a/src/hardware/uni-t-dmm/api.c +++ b/src/hardware/uni-t-dmm/api.c @@ -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; diff --git a/src/hardware/uni-t-ut32x/api.c b/src/hardware/uni-t-ut32x/api.c index 95096c0b..8c04e64a 100644 --- a/src/hardware/uni-t-ut32x/api.c +++ b/src/hardware/uni-t-ut32x/api.c @@ -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; diff --git a/src/hardware/victor-dmm/api.c b/src/hardware/victor-dmm/api.c index 65e73d8a..c1620161 100644 --- a/src/hardware/victor-dmm/api.c +++ b/src/hardware/victor-dmm/api.c @@ -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"))) diff --git a/src/hardware/zeroplus-logic-cube/api.c b/src/hardware/zeroplus-logic-cube/api.c index b2e7b7f3..2cf5aaf1 100644 --- a/src/hardware/zeroplus-logic-cube/api.c +++ b/src/hardware/zeroplus-logic-cube/api.c @@ -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; diff --git a/src/lcr/es51919.c b/src/lcr/es51919.c index ecfcd0ed..d15c4d38 100644 --- a/src/lcr/es51919.c +++ b/src/lcr/es51919.c @@ -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;