diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-08-26 19:18:15 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-10-07 20:14:38 +0200 |
commit | 4a39c774196f1a694477432f845e8bd62efee245 (patch) | |
tree | 7ebdfbdab40660fcf8087b967eaa5d6598d85584 /src/test/test-strv.c | |
parent | f767d3de652ec18c84ff0b99b1c4430269501e51 (diff) |
strv: fix STRV_FOREACH_BACKWARDS() to be a single statement only
Let's make sure people invoking STRV_FOREACH_BACKWARDS() as a single statement
of an if statement don't fall into a trap, and find the tail for the list via
strv_length().
Diffstat (limited to 'src/test/test-strv.c')
-rw-r--r-- | src/test/test-strv.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/test/test-strv.c b/src/test/test-strv.c index ce20f2dd5b..88da69e2d7 100644 --- a/src/test/test-strv.c +++ b/src/test/test-strv.c @@ -453,9 +453,14 @@ static void test_strv_foreach_backwards(void) { assert_se(a); - STRV_FOREACH_BACKWARDS(check, a) { + STRV_FOREACH_BACKWARDS(check, a) assert_se(streq_ptr(*check, input_table_multiple[i--])); - } + + STRV_FOREACH_BACKWARDS(check, (char**) NULL) + assert_not_reached("Let's see that we check empty strv right, too."); + + STRV_FOREACH_BACKWARDS(check, (char**) { NULL }) + assert_not_reached("Let's see that we check empty strv right, too."); } static void test_strv_foreach_pair(void) { |