fundamental: rework IN_SET() to require at least three arguments

If less than three parameters are passed a simple comparison is the
better choice.

Lo and behold this found two pretty bad typos.
This commit is contained in:
Lennart Poettering
2023-01-02 17:16:50 +01:00
parent efa75d7022
commit 4f06325ce9
9 changed files with 15 additions and 15 deletions
+4 -4
View File
@@ -202,22 +202,22 @@ TEST(ptr_to_int) {
}
TEST(in_set) {
assert_se(IN_SET(1, 1));
assert_se(IN_SET(1, 1, 2));
assert_se(IN_SET(1, 1, 2, 3, 4));
assert_se(IN_SET(2, 1, 2, 3, 4));
assert_se(IN_SET(3, 1, 2, 3, 4));
assert_se(IN_SET(4, 1, 2, 3, 4));
assert_se(!IN_SET(0, 1));
assert_se(!IN_SET(0, 1, 2));
assert_se(!IN_SET(0, 1, 2, 3, 4));
struct {
unsigned x:3;
} t = { 1 };
assert_se(IN_SET(t.x, 1));
assert_se(IN_SET(t.x, 1, 2));
assert_se(IN_SET(t.x, 1, 2, 3, 4));
assert_se(IN_SET(t.x, 2, 3, 4, 1));
assert_se(!IN_SET(t.x, 0));
assert_se(!IN_SET(t.x, 0, 2));
assert_se(!IN_SET(t.x, 2, 3, 4));
}