]> sigrok.org Git - libsigrok.git/blobdiff - src/device.c
output/csv: use intermediate time_t var, silence compiler warning
[libsigrok.git] / src / device.c
index 7973d1e53629e0ccba5d4bf76b1e5f1fa8e37034..5c681378fab01a99a33befa74dc0df3754e0a1ae 100644 (file)
@@ -67,7 +67,7 @@ SR_PRIV struct sr_channel *sr_channel_new(struct sr_dev_inst *sdi,
        ch->index = index;
        ch->type = type;
        ch->enabled = enabled;
-       if (name)
+       if (name && *name)
                ch->name = g_strdup(name);
 
        sdi->channels = g_slist_append(sdi->channels, ch);
@@ -120,6 +120,8 @@ SR_API int sr_dev_channel_name_set(struct sr_channel *channel,
 {
        if (!channel)
                return SR_ERR_ARG;
+       if (!name || !*name)
+               return SR_ERR_ARG;
 
        g_free(channel->name);
        channel->name = g_strdup(name);
@@ -489,7 +491,8 @@ SR_API int sr_dev_inst_channel_add(struct sr_dev_inst *sdi, int index, int type,
        if (!sdi || sdi->inst_type != SR_INST_USER || index < 0)
                return SR_ERR_ARG;
 
-       sr_channel_new(sdi, index, type, TRUE, name);
+       if (!sr_channel_new(sdi, index, type, TRUE, name))
+               return SR_ERR_DATA;
 
        return SR_OK;
 }