chiark / gitweb /
scan-build: silence some warnings
authorThomas Hindoe Paaboel Andersen <phomes@gmail.com>
Thu, 12 Dec 2013 22:08:47 +0000 (23:08 +0100)
committerThomas Hindoe Paaboel Andersen <phomes@gmail.com>
Thu, 12 Dec 2013 22:08:47 +0000 (23:08 +0100)
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

src/libsystemd-dhcp/test-dhcp-option.c
src/test/test-fileio.c
src/test/test-strv.c

index e2a6800..ac0b0a4 100644 (file)
@@ -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];
index b005f3b..eb4fbc9 100644 (file)
@@ -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);
index 068e421..d58d99c 100644 (file)
@@ -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--]));
         }
 }