]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-radv: remove unnecessary check
authorLuca Boccassi <bluca@debian.org>
Thu, 25 Apr 2024 15:18:08 +0000 (16:18 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 25 Apr 2024 22:03:27 +0000 (07:03 +0900)
in6_addr_prefix_intersect() returns a bool, so the check < 0 is
dead code. Flagged by codeql.

Follow-up for c7c56724a5d7cc2b6b0d9d5f95b1055811014843

src/libsystemd-network/sd-radv.c

index b8c5d1fbfd19d473ea1484240ca97347df70b549..c384d4e6275c0f9068ab2fec228087846137d1ba 100644 (file)
@@ -614,7 +614,6 @@ int sd_radv_set_home_agent_lifetime(sd_radv *ra, uint64_t lifetime_usec) {
 
 int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p) {
         sd_radv_prefix *found = NULL;
-        int r;
 
         assert_return(ra, -EINVAL);
         assert_return(p, -EINVAL);
@@ -626,11 +625,8 @@ int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p) {
         const char *addr_p = IN6_ADDR_PREFIX_TO_STRING(&p->opt.in6_addr, p->opt.prefixlen);
 
         LIST_FOREACH(prefix, cur, ra->prefixes) {
-                r = in6_addr_prefix_intersect(&cur->opt.in6_addr, cur->opt.prefixlen,
-                                              &p->opt.in6_addr, p->opt.prefixlen);
-                if (r < 0)
-                        return r;
-                if (r == 0)
+                if (!in6_addr_prefix_intersect(&cur->opt.in6_addr, cur->opt.prefixlen,
+                                               &p->opt.in6_addr, p->opt.prefixlen))
                         continue; /* no intersection */
 
                 if (cur->opt.prefixlen == p->opt.prefixlen) {