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:
parent
a7891d203c
commit
f20db19954
54
coccinelle/redundant-if.cocci
Normal file
54
coccinelle/redundant-if.cocci
Normal 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;
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user