diff mbox series

[ovs-dev,1/4] treewide: Remove dead code.

Message ID 20240626133007.694177-2-amusil@redhat.com
State Accepted
Headers show
Series Fix issues reported by coverity | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test fail github build: failed
ovsrobot/github-robot-_ovn-kubernetes fail github build: failed

Commit Message

Ales Musil June 26, 2024, 1:30 p.m. UTC
The coverity static analysis identified a few places with
extra checks and dead code that cannot be logically reached.
Remove this dead code from the codebase.

Signed-off-by: Ales Musil <amusil@redhat.com>
---
 controller/binding.c        | 2 +-
 controller/lflow.c          | 5 +----
 controller/lflow.h          | 3 +--
 controller/ovn-controller.c | 3 +--
 controller/pinctrl.c        | 8 +-------
 lib/inc-proc-eng.c          | 8 ++------
 lib/lex.c                   | 1 -
 northd/test-ipam.c          | 4 ----
 8 files changed, 7 insertions(+), 27 deletions(-)
diff mbox series

Patch

diff --git a/controller/binding.c b/controller/binding.c
index f467caf07..b7e7f4874 100644
--- a/controller/binding.c
+++ b/controller/binding.c
@@ -401,7 +401,7 @@  configure_qos(const struct sbrec_port_binding *pb,
                     q->queue_id = queue_id;
                 }
                 free(q->network);
-                q->network = network ? xstrdup(network) : NULL;
+                q->network = xstrdup(network);
                 q->min_rate = min_rate;
                 q->max_rate = max_rate;
                 q->burst = burst;
diff --git a/controller/lflow.c b/controller/lflow.c
index 1e05665a1..b4c379044 100644
--- a/controller/lflow.c
+++ b/controller/lflow.c
@@ -2388,15 +2388,12 @@  lflow_handle_changed_lbs(struct lflow_ctx_in *l_ctx_in,
                          struct lflow_ctx_out *l_ctx_out,
                          const struct uuidset *deleted_lbs,
                          const struct uuidset *updated_lbs,
-                         const struct uuidset *new_lbs,
-                         const struct hmap *old_lbs)
+                         const struct uuidset *new_lbs)
 {
     const struct ovn_controller_lb *lb;
 
     struct uuidset_node *uuid_node;
     UUIDSET_FOR_EACH (uuid_node, deleted_lbs) {
-        lb = ovn_controller_lb_find(old_lbs, &uuid_node->uuid);
-
         VLOG_DBG("Remove hairpin flows for deleted load balancer "UUID_FMT,
                  UUID_ARGS(&uuid_node->uuid));
         ofctrl_remove_flows(l_ctx_out->flow_table, &uuid_node->uuid);
diff --git a/controller/lflow.h b/controller/lflow.h
index 1d20cae35..7c947a909 100644
--- a/controller/lflow.h
+++ b/controller/lflow.h
@@ -178,8 +178,7 @@  bool lflow_handle_changed_lbs(struct lflow_ctx_in *l_ctx_in,
                               struct lflow_ctx_out *l_ctx_out,
                               const struct uuidset *deleted_lbs,
                               const struct uuidset *updated_lbs,
-                              const struct uuidset *new_lbs,
-                              const struct hmap *old_lbs);
+                              const struct uuidset *new_lbs);
 bool lflow_handle_changed_fdbs(struct lflow_ctx_in *, struct lflow_ctx_out *);
 void lflow_destroy(void);
 
diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c
index ed95818a0..0cbf6df58 100644
--- a/controller/ovn-controller.c
+++ b/controller/ovn-controller.c
@@ -4589,8 +4589,7 @@  lflow_output_lb_data_handler(struct engine_node *node, void *data)
     bool handled = lflow_handle_changed_lbs(&l_ctx_in, &l_ctx_out,
                                             &lb_data->deleted,
                                             &lb_data->updated,
-                                            &lb_data->new,
-                                            &lb_data->old_lbs);
+                                            &lb_data->new);
 
     engine_set_node_state(node, EN_UPDATED);
     return handled;
diff --git a/controller/pinctrl.c b/controller/pinctrl.c
index 8adec6179..f1f4cec58 100644
--- a/controller/pinctrl.c
+++ b/controller/pinctrl.c
@@ -4507,17 +4507,11 @@  ipv6_ra_send(struct rconn *swconn, struct ipv6_ra_state *ra)
 
     uint64_t packet_stub[128 / 8];
     struct dp_packet packet;
-    uint16_t router_lt = IPV6_ND_RA_LIFETIME;
-
-    if (!router_lt) {
-        /* Reset PRF to MEDIUM if router lifetime is not set */
-        ra->config->mo_flags &= ~IPV6_ND_RA_OPT_PRF_LOW;
-    }
 
     dp_packet_use_stub(&packet, packet_stub, sizeof packet_stub);
     compose_nd_ra(&packet, ra->config->eth_src, ra->config->eth_dst,
             &ra->config->ipv6_src, &ra->config->ipv6_dst,
-            255, ra->config->mo_flags, htons(router_lt), 0, 0,
+            255, ra->config->mo_flags, htons(IPV6_ND_RA_LIFETIME), 0, 0,
             ra->config->mtu);
 
     for (int i = 0; i < ra->config->prefixes.n_ipv6_addrs; i++) {
diff --git a/lib/inc-proc-eng.c b/lib/inc-proc-eng.c
index 4b379229e..a01440bb4 100644
--- a/lib/inc-proc-eng.c
+++ b/lib/inc-proc-eng.c
@@ -131,7 +131,6 @@  engine_dump_stats(struct unixctl_conn *conn, int argc,
     const char *dump_eng_node_name = (argc > 1 ? argv[1] : NULL);
     const char *dump_stat_type = (argc > 2 ? argv[2] : NULL);
 
-    bool success = true;
     for (size_t i = 0; i < engine_n_nodes; i++) {
         struct engine_node *node = engine_nodes[i];
 
@@ -163,11 +162,8 @@  engine_dump_stats(struct unixctl_conn *conn, int argc,
             break;
         }
     }
-    if (success) {
-        unixctl_command_reply(conn, ds_cstr(&dump));
-    } else {
-        unixctl_command_reply_error(conn, "Invalid stat type");
-    }
+
+    unixctl_command_reply(conn, ds_cstr(&dump));
 
     ds_destroy(&dump);
 }
diff --git a/lib/lex.c b/lib/lex.c
index a8b9812bb..06c40f7ae 100644
--- a/lib/lex.c
+++ b/lib/lex.c
@@ -644,7 +644,6 @@  next:
                     p++;
                 }
             }
-            goto next;
         } else {
             lex_error(token,
                       "`/' is only valid as part of `//' or `/*'.");
diff --git a/northd/test-ipam.c b/northd/test-ipam.c
index 62a4fd399..c449599e3 100644
--- a/northd/test-ipam.c
+++ b/northd/test-ipam.c
@@ -38,7 +38,6 @@  test_ipam_get_unused_ip(struct ovs_cmdl_context *ctx)
     }
     init_ipam_info(&info, &config, "Unused IP test");
 
-    bool fail = false;
     struct ds output = DS_EMPTY_INITIALIZER;
     struct ds err = DS_EMPTY_INITIALIZER;
     for (size_t i = 0; i < num_ips; i++) {
@@ -50,9 +49,6 @@  test_ipam_get_unused_ip(struct ovs_cmdl_context *ctx)
     }
 
     printf("%s", ds_cstr(&output));
-    if (fail) {
-        fprintf(stderr, "%s", ds_cstr(&err));
-    }
 
     smap_destroy(&config);
     destroy_ipam_info(&info);