]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-tables: make the assert more readable
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 18 Jan 2019 16:31:32 +0000 (17:31 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 10 Feb 2021 13:43:10 +0000 (14:43 +0100)
Doing it all in one line and with negation in front seemed like a good
idea at some point, but I think it is vastly easier to understand when
it is split out a bit.

src/shared/test-tables.h

index 120dc7f2e9f1f350c83e62491df935ef8595250a..e68ec6049749db0dd9a99d007398a76b3ca1efb0 100644 (file)
@@ -31,9 +31,13 @@ static inline void _test_table(const char *name,
                 else if (boring == 1)
                         printf("%*s  ...\n", (int) strlen(name), "");
 
-                assert_se(!(i >= 0 && i < size ?
-                            sparse ? rev != i && rev != -1 : val == NULL || rev != i :
-                            val != NULL || rev != -1));
+                if (i >= 0 && i < size) {
+                        if (sparse)
+                                assert_se(rev == i || rev == -1);
+                        else
+                                assert_se(val != NULL && rev == i);
+                } else
+                        assert_se(val == NULL && rev == -1);
         }
 }