diff options
author | Thomas Hindoe Paaboel Andersen <phomes@gmail.com> | 2013-12-12 23:08:47 +0100 |
---|---|---|
committer | Thomas Hindoe Paaboel Andersen <phomes@gmail.com> | 2013-12-12 23:08:47 +0100 |
commit | 5fba7bbfa47ef5c03a28000252d06ec82405d461 (patch) | |
tree | 0eb31cb025d794fc999aeebb92c93b5e00b18b8d /src | |
parent | e4bb80a07610e6559aa6d2d763fd0b78634a4b12 (diff) |
scan-build: silence some warnings
test-fileio/test-strv:
Use the streq_ptr to make build-scan not worry about passing in a null
to a nonnull function.
test-dhcp-option:
Prevent a theoretical null pointer dereference
Diffstat (limited to 'src')
-rw-r--r-- | src/libsystemd-dhcp/test-dhcp-option.c | 1 | ||||
-rw-r--r-- | src/test/test-fileio.c | 26 | ||||
-rw-r--r-- | src/test/test-strv.c | 2 |
3 files changed, 15 insertions, 14 deletions
diff --git a/src/libsystemd-dhcp/test-dhcp-option.c b/src/libsystemd-dhcp/test-dhcp-option.c index e2a680064c..ac0b0a435a 100644 --- a/src/libsystemd-dhcp/test-dhcp-option.c +++ b/src/libsystemd-dhcp/test-dhcp-option.c @@ -198,6 +198,7 @@ static int test_options_cb(uint8_t code, uint8_t len, const uint8_t *option, *descpos = -1; } + assert(descpos); assert(*descpos != -1); optcode = descoption[*descpos]; diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c index b005f3b4e6..eb4fbc91d2 100644 --- a/src/test/test-fileio.c +++ b/src/test/test-fileio.c @@ -78,16 +78,16 @@ static void test_parse_env_file(void) { STRV_FOREACH(i, a) log_info("Got: <%s>", *i); - assert_se(streq(a[0], "one=BAR")); - assert_se(streq(a[1], "two=bar")); - assert_se(streq(a[2], "three=333\nxxxx")); - assert_se(streq(a[3], "four=44\"44")); - assert_se(streq(a[4], "five=55\'55FIVEcinco")); - assert_se(streq(a[5], "six=seis sechs sis")); - assert_se(streq(a[6], "seven=sevenval#nocomment")); - assert_se(streq(a[7], "eight=eightval #nocomment")); - assert_se(streq(a[8], "export nine=nineval")); - assert_se(streq(a[9], "ten=")); + assert_se(streq_ptr(a[0], "one=BAR")); + assert_se(streq_ptr(a[1], "two=bar")); + assert_se(streq_ptr(a[2], "three=333\nxxxx")); + assert_se(streq_ptr(a[3], "four=44\"44")); + assert_se(streq_ptr(a[4], "five=55\'55FIVEcinco")); + assert_se(streq_ptr(a[5], "six=seis sechs sis")); + assert_se(streq_ptr(a[6], "seven=sevenval#nocomment")); + assert_se(streq_ptr(a[7], "eight=eightval #nocomment")); + assert_se(streq_ptr(a[8], "export nine=nineval")); + assert_se(streq_ptr(a[9], "ten=")); assert_se(a[10] == NULL); strv_env_clean_log(a, "test"); @@ -185,9 +185,9 @@ static void test_parse_multiline_env_file(void) { STRV_FOREACH(i, a) log_info("Got: <%s>", *i); - assert_se(streq(a[0], "one=BAR VAR\tGAR")); - assert_se(streq(a[1], "two=bar var\tgar")); - assert_se(streq(a[2], "tri=bar var \tgar ")); + assert_se(streq_ptr(a[0], "one=BAR VAR\tGAR")); + assert_se(streq_ptr(a[1], "two=bar var\tgar")); + assert_se(streq_ptr(a[2], "tri=bar var \tgar ")); assert_se(a[3] == NULL); r = write_env_file(p, a); diff --git a/src/test/test-strv.c b/src/test/test-strv.c index 068e421097..d58d99c99f 100644 --- a/src/test/test-strv.c +++ b/src/test/test-strv.c @@ -367,7 +367,7 @@ static void test_strv_foreach_backwards(void) { assert_se(a); STRV_FOREACH_BACKWARDS(check, a) { - assert_se(streq(*check, input_table_multiple[i--])); + assert_se(streq_ptr(*check, input_table_multiple[i--])); } } |