tree-wide: drop !! casts to booleans

They are not needed, because anything that is non-zero is converted
to true.

C11:
> 6.3.1.2: When any scalar value is converted to _Bool, the result is 0 if the
> value compares equal to 0; otherwise, the result is 1.

https://stackoverflow.com/questions/31551888/casting-int-to-bool-in-c-c
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2018-06-13 10:52:40 +02:00
parent 37e744e866
commit 5d904a6aaa
18 changed files with 40 additions and 28 deletions
+3 -3
View File
@@ -1090,9 +1090,9 @@ static int map_basic(sd_bus *bus, const char *member, sd_bus_message *m, unsigne
return r;
if (flags & BUS_MAP_BOOLEAN_AS_BOOL)
* (bool*) userdata = !!b;
*(bool*) userdata = b;
else
* (int*) userdata = b;
*(int*) userdata = b;
return 0;
}
@@ -1403,7 +1403,7 @@ int bus_property_set_bool(
if (r < 0)
return r;
*(bool *) userdata = !!b;
*(bool*) userdata = b;
return 0;
}
+1 -1
View File
@@ -103,7 +103,7 @@ static int condition_test_kernel_command_line(Condition *c) {
if (r < 0)
return r;
equal = !!strchr(c->parameter, '=');
equal = strchr(c->parameter, '=');
for (p = line;;) {
_cleanup_free_ char *word = NULL;
+1 -1
View File
@@ -632,7 +632,7 @@ int config_parse_bool(const char* unit,
return fatal ? -ENOEXEC : 0;
}
*b = !!k;
*b = k;
return 0;
}