X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Frigol-ds%2Fapi.c;h=7a195bb70c6c9e24eb8868aa57975919697c732d;hb=65e0036635a54b3273436b4ea7918aea25bad788;hp=111eff067d6734a73883ca957fd26bc18761a7c7;hpb=0c5f2abc6697504b5d760dfa56cc90bea180198f;p=libsigrok.git diff --git a/src/hardware/rigol-ds/api.c b/src/hardware/rigol-ds/api.c index 111eff06..7a195bb7 100644 --- a/src/hardware/rigol-ds/api.c +++ b/src/hardware/rigol-ds/api.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include "libsigrok.h" @@ -353,8 +354,7 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) model->analog_channels); for (i = 0; i < model->analog_channels; i++) { - if (!(channel_name = g_strdup_printf("CH%d", i + 1))) - return NULL; + channel_name = g_strdup_printf("CH%d", i + 1); ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel_name); devc->analog_groups[i] = g_malloc0(sizeof(struct sr_channel_group)); @@ -369,8 +369,7 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) devc->digital_group = g_malloc0(sizeof(struct sr_channel_group)); for (i = 0; i < ARRAY_SIZE(devc->digital_channels); i++) { - if (!(channel_name = g_strdup_printf("D%d", i))) - return NULL; + channel_name = g_strdup_printf("D%d", i); ch = sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_name); g_free(channel_name); devc->digital_group->channels = g_slist_append( @@ -388,16 +387,16 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) devc->num_timebases = &timebases[i] - devc->timebases + 1; } - for (i = 0; i < NUM_VDIV; i++) - if (!memcmp(&devc->model->series->min_vdiv, &vdivs[i], sizeof(uint64_t[2]))) { + for (i = 0; i < NUM_VDIV; i++) { + if (!memcmp(&devc->model->series->min_vdiv, + &vdivs[i], sizeof(uint64_t[2]))) { devc->vdivs = &vdivs[i]; devc->num_vdivs = NUM_VDIV - i; } + } - if (!(devc->buffer = g_try_malloc(ACQ_BUFFER_SIZE))) - return NULL; - if (!(devc->data = g_try_malloc(ACQ_BUFFER_SIZE * sizeof(float)))) - return NULL; + devc->buffer = g_malloc(ACQ_BUFFER_SIZE); + devc->data = g_malloc(ACQ_BUFFER_SIZE * sizeof(float)); devc->data_source = DATA_SOURCE_LIVE;