aboutsummaryrefslogtreecommitdiffstats
path: root/vnet
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2016-08-05 10:10:18 -0400
committerDave Barach <dave@barachs.net>2016-08-05 10:10:38 -0400
commitf9c231ec12c2233557bfbb58feb87a1fcddf224a (patch)
tree6ee8846be9a6c79d68d0364c00cc58b2f3547ddd /vnet
parent56faee837281c7f9c28aa40dbf0f6e4620b76be8 (diff)
vpp-189 Clean up more coverity warnings
Time to make the donuts Change-Id: I528937800f7daefce19723dda0216e58d857942c Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'vnet')
-rw-r--r--vnet/vnet/ip/ip_input_acl.c2
-rw-r--r--vnet/vnet/ip/udp_local.c8
-rw-r--r--vnet/vnet/mpls-gre/mpls.c6
-rw-r--r--vnet/vnet/policer/node_funcs.c2
-rw-r--r--vnet/vnet/policer/xlate.c2
-rw-r--r--vnet/vnet/rewrite.c2
-rw-r--r--vnet/vnet/sr/sr.c11
-rw-r--r--vnet/vnet/sr/sr_replicate.c8
-rw-r--r--vnet/vnet/unix/tapcli.c3
-rw-r--r--vnet/vnet/unix/tuntap.c6
-rw-r--r--vnet/vnet/vxlan-gpe/decap.c5
-rw-r--r--vnet/vnet/vxlan/decap.c5
12 files changed, 36 insertions, 24 deletions
diff --git a/vnet/vnet/ip/ip_input_acl.c b/vnet/vnet/ip/ip_input_acl.c
index eaf7f34eec5..6331cf4fa6b 100644
--- a/vnet/vnet/ip/ip_input_acl.c
+++ b/vnet/vnet/ip/ip_input_acl.c
@@ -322,7 +322,7 @@ ip_inacl_inline (vlib_main_t * vm,
t->sw_if_index = vnet_buffer(b0)->sw_if_index[VLIB_RX];
t->next_index = next0;
t->table_index = t0 ? t0 - vcm->tables : ~0;
- t->offset = e0 ? vnet_classify_get_offset (t0, e0): ~0;
+ t->offset = (e0 && t0) ? vnet_classify_get_offset (t0, e0): ~0;
}
/* verify speculative enqueue, maybe switch current next frame */
diff --git a/vnet/vnet/ip/udp_local.c b/vnet/vnet/ip/udp_local.c
index 9b701470934..4928d5523e4 100644
--- a/vnet/vnet/ip/udp_local.c
+++ b/vnet/vnet/ip/udp_local.c
@@ -242,8 +242,8 @@ udp46_input_inline (vlib_main_t * vm,
b0, sizeof (*tr));
if (b0->error != node->errors[UDP_ERROR_LENGTH_ERROR])
{
- tr->src_port = h0->src_port;
- tr->dst_port = h0->dst_port;
+ tr->src_port = h0 ? h0->src_port : 0;
+ tr->dst_port = h0 ? h0->dst_port : 0;
tr->bound = (next0 != UDP_INPUT_NEXT_ICMP4_ERROR &&
next0 != UDP_INPUT_NEXT_ICMP6_ERROR);
}
@@ -254,8 +254,8 @@ udp46_input_inline (vlib_main_t * vm,
b1, sizeof (*tr));
if (b1->error != node->errors[UDP_ERROR_LENGTH_ERROR])
{
- tr->src_port = h1->src_port;
- tr->dst_port = h1->dst_port;
+ tr->src_port = h1 ? h1->src_port : 0;
+ tr->dst_port = h1 ? h1->dst_port : 0;
tr->bound = (next1 != UDP_INPUT_NEXT_ICMP4_ERROR &&
next1 != UDP_INPUT_NEXT_ICMP6_ERROR);
}
diff --git a/vnet/vnet/mpls-gre/mpls.c b/vnet/vnet/mpls-gre/mpls.c
index 4b36c5dc34d..d914b4c2b72 100644
--- a/vnet/vnet/mpls-gre/mpls.c
+++ b/vnet/vnet/mpls-gre/mpls.c
@@ -399,7 +399,7 @@ int vnet_mpls_add_del_decap (u32 rx_fib_id,
tx_fib_index_or_output_swif_index = tx_fib_id;
}
- key = ((u64)rx_fib_index<<32) | ((u64) (label_host_byte_order<<12))
+ key = ((u64) rx_fib_index<<32) | ((u64) label_host_byte_order<<12)
| ((u64) s_bit<<8);
p = hash_get (mm->mpls_decap_by_rx_fib_and_label, key);
@@ -748,8 +748,8 @@ int mpls_fib_reset_labels (u32 fib_id)
vec_foreach (s, records)
{
- key = ((u64)fib_index <<32) | ((u64)(s->dest<<12)) |
- ((u64)s->s_bit);
+ key = ((u64) fib_index <<32) | ((u64) s->dest<<12) |
+ ((u64) s->s_bit);
hash_unset (mm->mpls_decap_by_rx_fib_and_label, key);
pool_put_index (mm->decaps, s->entry_index);
diff --git a/vnet/vnet/policer/node_funcs.c b/vnet/vnet/policer/node_funcs.c
index 0858a86d2a2..61a29733117 100644
--- a/vnet/vnet/policer/node_funcs.c
+++ b/vnet/vnet/policer/node_funcs.c
@@ -804,7 +804,7 @@ policer_classify_inline (vlib_main_t * vm,
t->sw_if_index = vnet_buffer(b0)->sw_if_index[VLIB_RX];
t->next_index = next0;
t->table_index = t0 ? t0 - vcm->tables : ~0;
- t->offset = e0 ? vnet_classify_get_offset (t0, e0): ~0;
+ t->offset = (e0 && t0) ? vnet_classify_get_offset (t0, e0): ~0;
t->policer_index = e0 ? e0->next_index: ~0;
}
diff --git a/vnet/vnet/policer/xlate.c b/vnet/vnet/policer/xlate.c
index 934c488ccb8..61976b1cbde 100644
--- a/vnet/vnet/policer/xlate.c
+++ b/vnet/vnet/policer/xlate.c
@@ -468,7 +468,7 @@ sse2_pol_convert_cfg_rates_to_hw (sse2_qos_pol_cfg_params_st *cfg,
&exp, &hi_mant);
}
- denom = (1 << exp);
+ denom = (1ULL << exp);
if (hi_rate == eir_hw) {
hw->peak_rate_man = (uint16_t)hi_mant;
rc = sse2_qos_pol_round((uint64_t)cir_hw, denom, &rnd_value,
diff --git a/vnet/vnet/rewrite.c b/vnet/vnet/rewrite.c
index a538eef30f7..3435b0f2d18 100644
--- a/vnet/vnet/rewrite.c
+++ b/vnet/vnet/rewrite.c
@@ -209,7 +209,7 @@ void vnet_rewrite_for_sw_interface (vnet_main_t * vnm,
ASSERT (hc->set_rewrite);
n_rw_tmp = hc->set_rewrite (vnm, sw_if_index, packet_type, dst_address, rw_tmp, max_rewrite_bytes);
- ASSERT (n_rw_tmp >= 0 && n_rw_tmp < max_rewrite_bytes);
+ ASSERT (n_rw_tmp < max_rewrite_bytes);
vnet_rewrite_set_data_internal (rw, max_rewrite_bytes, rw_tmp, n_rw_tmp);
}
diff --git a/vnet/vnet/sr/sr.c b/vnet/vnet/sr/sr.c
index 05d8d8166da..d935b458ec9 100644
--- a/vnet/vnet/sr/sr.c
+++ b/vnet/vnet/sr/sr.c
@@ -724,8 +724,10 @@ find_or_add_shared_secret (ip6_sr_main_t * sm, u8 * secret, u32 * indexp)
for (i = 0; i < vec_len (sm->hmac_keys); i++)
{
if (sm->hmac_keys[i].shared_secret == 0)
- key = sm->hmac_keys + i;
- goto found;
+ {
+ key = sm->hmac_keys + i;
+ goto found;
+ }
}
vec_validate (sm->hmac_keys, i);
key = sm->hmac_keys + i;
@@ -970,7 +972,6 @@ int ip6_sr_add_del_tunnel (ip6_sr_add_del_tunnel_args_t * a)
memset(&adj, 0, sizeof (adj));
/* Create an adjacency and add to v6 fib */
- adj.lookup_next_index = IP_LOOKUP_NEXT_REWRITE;
adj.lookup_next_index = sm->ip6_lookup_sr_next_index;
adj.explicit_fib_index = ~0;
@@ -1020,7 +1021,9 @@ int ip6_sr_add_del_tunnel (ip6_sr_add_del_tunnel_args_t * a)
p=hash_get_mem (sm->policy_index_by_policy_name, a->policy_name);
}
vec_add1 (pt->tunnel_indices, t - sm->tunnels);
- t->policy_index = p[0]; /* equiv. to (pt - sm->policies) */
+ if (p == 0)
+ clib_warning ("p is NULL!");
+ t->policy_index = p ? p[0] : ~0; /* equiv. to (pt - sm->policies) */
}
if (a->name)
diff --git a/vnet/vnet/sr/sr_replicate.c b/vnet/vnet/sr/sr_replicate.c
index ccc01465f73..f059ce95fb3 100644
--- a/vnet/vnet/sr/sr_replicate.c
+++ b/vnet/vnet/sr/sr_replicate.c
@@ -304,17 +304,17 @@ sr_replicate_node_fn (vlib_main_t * vm,
sr_replicate_trace_t *tr = vlib_add_trace (vm, node,
b0, sizeof (*tr));
tr->tunnel_index = t0 - sm->tunnels;
+ tr->length = 0;
if (hdr_ip0)
{
memcpy (tr->src.as_u8, hdr_ip0->src_address.as_u8,
sizeof (tr->src.as_u8));
memcpy (tr->dst.as_u8, hdr_ip0->dst_address.as_u8,
sizeof (tr->dst.as_u8));
+ if (hdr_ip0->payload_length)
+ tr->length = clib_net_to_host_u16
+ (hdr_ip0->payload_length);
}
- if (hdr_ip0->payload_length)
- tr->length = clib_net_to_host_u16(hdr_ip0->payload_length);
- else
- tr->length = 0;
tr->next_index = next_index;
memcpy (tr->sr, hdr_sr0, sizeof (tr->sr));
}
diff --git a/vnet/vnet/unix/tapcli.c b/vnet/vnet/unix/tapcli.c
index 667e3e412de..7e2ee06330a 100644
--- a/vnet/vnet/unix/tapcli.c
+++ b/vnet/vnet/unix/tapcli.c
@@ -823,7 +823,8 @@ int vnet_tap_connect (vlib_main_t * vm, u8 * intfc_name, u8 *hwaddr_arg,
error:
close (dev_net_tun_fd);
- close (dev_tap_fd);
+ if (dev_tap_fd >= 0)
+ close (dev_tap_fd);
return rv;
}
diff --git a/vnet/vnet/unix/tuntap.c b/vnet/vnet/unix/tuntap.c
index 28b2584b3d3..f24d71eee8a 100644
--- a/vnet/vnet/unix/tuntap.c
+++ b/vnet/vnet/unix/tuntap.c
@@ -427,7 +427,8 @@ tuntap_exit (vlib_main_t * vm)
if (ioctl (tm->dev_net_tun_fd, TUNSETPERSIST, 0) < 0)
clib_unix_warning ("TUNSETPERSIST");
close(tm->dev_tap_fd);
- close(tm->dev_net_tun_fd);
+ if (tm->dev_net_tun_fd >= 0)
+ close(tm->dev_net_tun_fd);
close (sfd);
return 0;
@@ -809,7 +810,8 @@ tuntap_ip6_add_del_interface_address (ip6_main_t * im,
if (ioctl (sockfd, SIOCDIFADDR, &ifr6) < 0)
clib_unix_warning ("del address");
- close (sockfd);
+ if (sockfd >= 0)
+ close (sockfd);
mhash_unset (&tm->subif_mhash, &subif_addr, 0 /* old value ptr */);
pool_put (tm->subifs, ap);
diff --git a/vnet/vnet/vxlan-gpe/decap.c b/vnet/vnet/vxlan-gpe/decap.c
index 34bcccd9333..7f32cbd8a49 100644
--- a/vnet/vnet/vxlan-gpe/decap.c
+++ b/vnet/vnet/vxlan-gpe/decap.c
@@ -73,7 +73,10 @@ vxlan_gpe_input (vlib_main_t * vm,
u32 cpu_index = os_get_cpu_number ();
u32 stats_sw_if_index, stats_n_packets, stats_n_bytes;
- memset (&last_key4, 0xff, sizeof(last_key4));
+ if (is_ip4)
+ memset (&last_key4, 0xff, sizeof(last_key4));
+ else
+ memset (&last_key6, 0xff, sizeof(last_key6));
from = vlib_frame_vector_args (from_frame);
n_left_from = from_frame->n_vectors;
diff --git a/vnet/vnet/vxlan/decap.c b/vnet/vnet/vxlan/decap.c
index dc9a2ff7afa..899b3318bb1 100644
--- a/vnet/vnet/vxlan/decap.c
+++ b/vnet/vnet/vxlan/decap.c
@@ -64,7 +64,10 @@ vxlan_input (vlib_main_t * vm,
u32 cpu_index = os_get_cpu_number();
u32 stats_sw_if_index, stats_n_packets, stats_n_bytes;
- last_key4.as_u64 = ~0;
+ if (is_ip4)
+ last_key4.as_u64 = ~0;
+ else
+ memset (&last_key6, 0xff, sizeof (last_key6));
from = vlib_frame_vector_args (from_frame);
n_left_from = from_frame->n_vectors;