summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-06-11 16:02:03 +0200
committerSven Eden <yamakuzure@gmx.net>2018-08-24 16:47:08 +0200
commitd9537fde9944a03f48054e0f4b6a9aea7d3c2a9d (patch)
tree1f4d52653dea6867cba74e3c950d251646581822 /src
parent5794614c99bdb57a405f293923bf17f24dad25e9 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/basic/format-table.c2
-rw-r--r--src/basic/verbs.c2
-rw-r--r--src/basic/virt.c2
-rw-r--r--src/login/logind-dbus.c4
-rw-r--r--src/shared/bus-util.c6
-rw-r--r--src/shared/conf-parser.c3
6 files changed, 10 insertions, 9 deletions
diff --git a/src/basic/format-table.c b/src/basic/format-table.c
index 8340133be..c967642df 100644
--- a/src/basic/format-table.c
+++ b/src/basic/format-table.c
@@ -572,7 +572,7 @@ int table_add_many_internal(Table *t, TableDataType first_type, ...) {
break;
case TABLE_BOOLEAN:
- buffer.b = !!va_arg(ap, int);
+ buffer.b = va_arg(ap, int);
data = &buffer.b;
break;
diff --git a/src/basic/verbs.c b/src/basic/verbs.c
index 743aed5e4..a52cd2ad9 100644
--- a/src/basic/verbs.c
+++ b/src/basic/verbs.c
@@ -81,7 +81,7 @@ int dispatch_verb(int argc, char *argv[], const Verb verbs[], void *userdata) {
if (name)
found = streq(name, verbs[i].verb);
else
- found = !!(verbs[i].flags & VERB_DEFAULT);
+ found = verbs[i].flags & VERB_DEFAULT;
if (found) {
verb = &verbs[i];
diff --git a/src/basic/virt.c b/src/basic/virt.c
index 3b2f1b917..dfc384ede 100644
--- a/src/basic/virt.c
+++ b/src/basic/virt.c
@@ -57,7 +57,7 @@ static int detect_vm_cpuid(void) {
if (__get_cpuid(1, &eax, &ebx, &ecx, &edx) == 0)
return VIRTUALIZATION_NONE;
- hypervisor = !!(ecx & 0x80000000U);
+ hypervisor = ecx & 0x80000000U;
if (hypervisor) {
union {
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 507368604..26a4ed889 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -245,9 +245,9 @@ static int property_get_preparing(
assert(m);
if (streq(property, "PreparingForShutdown"))
- b = !!(m->action_what & INHIBIT_SHUTDOWN);
+ b = m->action_what & INHIBIT_SHUTDOWN;
else
- b = !!(m->action_what & INHIBIT_SLEEP);
+ b = m->action_what & INHIBIT_SLEEP;
return sd_bus_message_append(reply, "b", b);
}
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c
index 020fa885a..e69b53ea6 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -1094,9 +1094,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;
}
@@ -1413,7 +1413,7 @@ int bus_property_set_bool(
if (r < 0)
return r;
- *(bool *) userdata = !!b;
+ *(bool*) userdata = b;
return 0;
}
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index db74a7fdb..a150f8940 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -50,6 +50,7 @@
//#include "rlimit-util.h"
//#include "rlimit-util.h"
//#include "rlimit-util.h"
+//#include "rlimit-util.h"
int config_item_table_lookup(
const void *table,
@@ -656,7 +657,7 @@ int config_parse_bool(const char* unit,
return fatal ? -ENOEXEC : 0;
}
- *b = !!k;
+ *b = k;
return 0;
}