From 98075b4a4fa50dc2fe284323e7254b86d8e5a73f Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Mon, 30 Jan 2023 11:38:26 +0800 Subject: [PATCH] Add assert line for dsl.c about get mode list --- lang/en/main.json | 10 ---------- libsigrok4DSL/hardware/DSL/dscope.c | 8 +++++--- libsigrok4DSL/hardware/DSL/dsl.c | 4 ++-- libsigrok4DSL/hardware/DSL/dslogic.c | 8 +++++--- 4 files changed, 12 insertions(+), 18 deletions(-) delete mode 100644 lang/en/main.json diff --git a/lang/en/main.json b/lang/en/main.json deleted file mode 100644 index b8e07c0b..00000000 --- a/lang/en/main.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "id": "vvv", - "text": "xxx" - }, - { - "id": "vvv1", - "text": "xxx1" - } -] \ No newline at end of file diff --git a/libsigrok4DSL/hardware/DSL/dscope.c b/libsigrok4DSL/hardware/DSL/dscope.c index e415d181..f137de28 100644 --- a/libsigrok4DSL/hardware/DSL/dscope.c +++ b/libsigrok4DSL/hardware/DSL/dscope.c @@ -120,6 +120,8 @@ static struct DSL_context *DSCope_dev_new(const struct DSL_profile *prof) struct DSL_context *devc; unsigned int i; + assert(prof); + if (!(devc = g_try_malloc(sizeof(struct DSL_context)))) { sr_err("Device context malloc failed."); return NULL; @@ -132,15 +134,15 @@ static struct DSL_context *DSCope_dev_new(const struct DSL_profile *prof) devc->channel = NULL; devc->profile = prof; devc->fw_updated = 0; - devc->cur_samplerate = devc->profile->dev_caps.default_samplerate; - devc->limit_samples = devc->profile->dev_caps.default_samplelimit; + devc->cur_samplerate = prof->dev_caps.default_samplerate; + devc->limit_samples = prof->dev_caps.default_samplelimit; devc->clock_type = FALSE; devc->clock_edge = FALSE; devc->instant = FALSE; devc->op_mode = OP_NORMAL; devc->test_mode = SR_TEST_NONE; devc->stream = FALSE; - devc->ch_mode = devc->profile->dev_caps.default_channelmode; + devc->ch_mode = prof->dev_caps.default_channelmode; devc->th_level = SR_TH_3V3; devc->filter = SR_FILTER_NONE; devc->timebase = 10000; diff --git a/libsigrok4DSL/hardware/DSL/dsl.c b/libsigrok4DSL/hardware/DSL/dsl.c index 7a393dc9..979851f2 100644 --- a/libsigrok4DSL/hardware/DSL/dsl.c +++ b/libsigrok4DSL/hardware/DSL/dsl.c @@ -196,12 +196,12 @@ SR_PRIV const GSList *dsl_mode_list(const struct sr_dev_inst *sdi) { struct DSL_context *devc; GSList *l = NULL; - unsigned int i; + unsigned int i; devc = sdi->priv; for (i = 0; i < ARRAY_SIZE(sr_mode_list); i++) { if (devc->profile->dev_caps.mode_caps & (1 << i)) - l = g_slist_append(l, &sr_mode_list[i]); + l = g_slist_append(l, &sr_mode_list[i]); } return l; diff --git a/libsigrok4DSL/hardware/DSL/dslogic.c b/libsigrok4DSL/hardware/DSL/dslogic.c index 580e3f04..617bd588 100644 --- a/libsigrok4DSL/hardware/DSL/dslogic.c +++ b/libsigrok4DSL/hardware/DSL/dslogic.c @@ -219,6 +219,8 @@ static struct DSL_context *DSLogic_dev_new(const struct DSL_profile *prof) struct DSL_context *devc; unsigned int i; + assert(prof); + if (!(devc = g_try_malloc(sizeof(struct DSL_context)))) { sr_err("Device context malloc failed."); return NULL; @@ -232,15 +234,15 @@ static struct DSL_context *DSLogic_dev_new(const struct DSL_profile *prof) devc->channel = NULL; devc->profile = prof; devc->fw_updated = 0; - devc->cur_samplerate = devc->profile->dev_caps.default_samplerate; - devc->limit_samples = devc->profile->dev_caps.default_samplelimit; + devc->cur_samplerate = prof->dev_caps.default_samplerate; + devc->limit_samples = prof->dev_caps.default_samplelimit; devc->clock_type = FALSE; devc->clock_edge = FALSE; devc->rle_mode = FALSE; devc->instant = FALSE; devc->op_mode = OP_STREAM; devc->test_mode = SR_TEST_NONE; - devc->ch_mode = devc->profile->dev_caps.default_channelmode; + devc->ch_mode = prof->dev_caps.default_channelmode; devc->stream = (devc->op_mode == OP_STREAM); devc->buf_options = SR_BUF_UPLOAD; devc->th_level = SR_TH_3V3;