1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

cocci: simplify some if checks

This commit is contained in:
Lennart Poettering 2018-11-16 14:42:14 +01:00 committed by Zbigniew Jędrzejewski-Szmek
parent a7891d203c
commit f20db19954
4 changed files with 59 additions and 15 deletions

View File

@ -0,0 +1,54 @@
@@
expression r;
@@
- if (r < 0)
- return r;
- if (r == 0)
- return 0;
+ if (r <= 0)
+ return r;
@@
expression r;
@@
- if (r == 0)
- return 0;
- if (r < 0)
- return r;
+ if (r <= 0)
+ return r;
@@
expression r;
@@
- if (r < 0)
- return r;
- if (r == 0)
- return r;
+ if (r <= 0)
+ return r;
@@
expression r;
@@
- if (r == 0)
- return r;
- if (r < 0)
- return r;
+ if (r <= 0)
+ return r;
@@
expression r;
@@
- if (r < 0)
- return r;
- if (r > 0)
- return r;
+ if (r != 0)
+ return r;
@@
expression r;
@@
- if (r > 0)
- return r;
- if (r < 0)
- return r;
+ if (r != 0)
+ return r;

View File

@ -199,10 +199,8 @@ int cg_rmdir(const char *controller, const char *path) {
return -errno;
r = cg_hybrid_unified();
if (r < 0)
if (r <= 0)
return r;
if (r == 0)
return 0;
if (streq(controller, SYSTEMD_CGROUP_CONTROLLER)) {
r = cg_rmdir(SYSTEMD_CGROUP_CONTROLLER_LEGACY, path);

View File

@ -2788,10 +2788,8 @@ static int manager_dispatch_timezone_change(
log_debug("inotify event for /etc/localtime");
changed = manager_read_timezone_stat(m);
if (changed < 0)
if (changed <= 0)
return changed;
if (!changed)
return 0;
/* Something changed, restart the watch, to ensure we watch the new /etc/localtime if it changed */
(void) manager_setup_timezone_change(m);

View File

@ -1378,17 +1378,13 @@ static int nsec3_is_good(DnsResourceRecord *rr, DnsResourceRecord *nsec3) {
a = dns_resource_key_name(rr->key);
r = dns_name_parent(&a); /* strip off hash */
if (r < 0)
if (r <= 0)
return r;
if (r == 0)
return 0;
b = dns_resource_key_name(nsec3->key);
r = dns_name_parent(&b); /* strip off hash */
if (r < 0)
if (r <= 0)
return r;
if (r == 0)
return 0;
/* Make sure both have the same parent */
return dns_name_equal(a, b);
@ -2096,10 +2092,8 @@ static int dnssec_test_positive_wildcard_nsec3(
for (;;) {
next_closer = name;
r = dns_name_parent(&name);
if (r < 0)
if (r <= 0)
return r;
if (r == 0)
return 0;
r = dns_name_equal(name, source);
if (r < 0)