]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: drop unnecessary conditions
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 10 Jul 2023 00:38:38 +0000 (09:38 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 29 Jul 2023 13:48:49 +0000 (22:48 +0900)
When link_get_by_index() succeeds, the result is always non-NULL.

src/network/networkd-address.c
src/network/networkd-neighbor.c
src/network/networkd-nexthop.c
src/network/networkd-route.c

index 276aad0989b28832f54411bb58a419ccaca4711c..7ddc58337ba10603c15d82d95d2b994f5bd3132d 100644 (file)
@@ -1403,7 +1403,7 @@ void address_cancel_request(Address *address) {
 int manager_rtnl_process_address(sd_netlink *rtnl, sd_netlink_message *message, Manager *m) {
         _cleanup_(address_freep) Address *tmp = NULL;
         struct ifa_cacheinfo cinfo;
-        Link *link = NULL;
+        Link *link;
         uint16_t type;
         Address *address = NULL;
         int ifindex, r;
@@ -1439,7 +1439,7 @@ int manager_rtnl_process_address(sd_netlink *rtnl, sd_netlink_message *message,
         }
 
         r = link_get_by_index(m, ifindex, &link);
-        if (r < 0 || !link) {
+        if (r < 0) {
                 /* when enumerating we might be out of sync, but we will get the address again, so just
                  * ignore it */
                 if (!m->enumerating)
index e3c332eadbf59496d894314b9ffbf878f88cf571..05ad0738e6b867eac47e0ca20567dee8fb61cbe7 100644 (file)
@@ -490,7 +490,7 @@ int manager_rtnl_process_neighbor(sd_netlink *rtnl, sd_netlink_message *message,
         }
 
         r = link_get_by_index(m, ifindex, &link);
-        if (r < 0 || !link) {
+        if (r < 0) {
                 /* when enumerating we might be out of sync, but we will get the neighbor again. Also,
                  * kernel sends messages about neighbors after a link is removed. So, just ignore it. */
                 log_debug("rtnl: received neighbor for link '%d' we don't know about, ignoring.", ifindex);
index eed28440c23646f1536e64d2274d9219157a19e6..3eda1f1b7d5afa39bfac8ed0dddffaf009892716 100644 (file)
@@ -835,7 +835,7 @@ int manager_rtnl_process_nexthop(sd_netlink *rtnl, sd_netlink_message *message,
                 }
 
                 r = link_get_by_index(m, ifindex, &link);
-                if (r < 0 || !link) {
+                if (r < 0) {
                         if (!m->enumerating)
                                 log_warning("rtnl: received nexthop message for link (%"PRIu32") we do not know about, ignoring", ifindex);
                         return 0;
index 44dc63b64223ab713e8cec4501c24087efb46320..283d515b819946f0c7c57e7263e7d1d5a85f3041 100644 (file)
@@ -1719,7 +1719,7 @@ int manager_rtnl_process_route(sd_netlink *rtnl, sd_netlink_message *message, Ma
                 }
 
                 r = link_get_by_index(m, ifindex, &link);
-                if (r < 0 || !link) {
+                if (r < 0) {
                         /* when enumerating we might be out of sync, but we will
                          * get the route again, so just ignore it */
                         if (!m->enumerating)