From 2c29d75021d684559146e656aac85f0c14ffb5ab Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Fri, 18 Dec 2015 10:26:56 +0100 Subject: Fix warnings/errors reported by clang Change-Id: Ifb2de64347526e3218e22067452f249ff878fd32 Signed-off-by: Damjan Marion --- svm/svm.c | 4 ++-- vlib/Makefile.am | 2 ++ vlib/vlib/dpdk_buffer.c | 2 +- vlib/vlib/main.c | 2 +- vlib/vlib/threads.c | 2 +- vnet/vnet/classify/input_acl.c | 2 +- vnet/vnet/ethernet/arp.c | 2 +- vnet/vnet/ip/icmp4.c | 2 +- vnet/vnet/ip/icmp6.c | 2 +- vnet/vnet/ip/ip4_hop_by_hop.c | 1 - vnet/vnet/ip/ip4_packet.h | 2 +- vnet/vnet/ipsec/ipsec_output.c | 2 +- vnet/vnet/l2tp/l2tp.c | 2 +- vnet/vnet/map/ip4_map.c | 2 +- vnet/vnet/map/ip6_map_t.c | 4 ++-- vnet/vnet/policer/xlate.c | 4 +--- vnet/vnet/srp/node.c | 2 +- vppinfra/tools/elftool.c | 2 +- vppinfra/vppinfra/elog.h | 2 +- vppinfra/vppinfra/heap.c | 2 +- vppinfra/vppinfra/md5.c | 2 +- vppinfra/vppinfra/mheap.c | 2 +- vppinfra/vppinfra/test_vec.c | 3 ++- 23 files changed, 26 insertions(+), 26 deletions(-) diff --git a/svm/svm.c b/svm/svm.c index 4d45b29785d..ab749137424 100644 --- a/svm/svm.c +++ b/svm/svm.c @@ -117,9 +117,9 @@ static u8 * format_svm_size (u8 * s, va_list * args) { uword size = va_arg (*args, uword); - if (size >= (1>>20)) { + if (size >= (1<<20)) { s = format (s, "(%d mb)", size >> 20); - } else if (size >= (1>>10)) { + } else if (size >= (1<<10)) { s = format (s, "(%d kb)", size >> 10); } else { s = format (s, "(%d bytes)", size); diff --git a/vlib/Makefile.am b/vlib/Makefile.am index 1275798532e..b38c843fc5f 100644 --- a/vlib/Makefile.am +++ b/vlib/Makefile.am @@ -90,6 +90,7 @@ nobase_include_HEADERS += \ vlib/unix/plugin.h \ vlib/unix/unix.h +if !WITH_DPDK noinst_PROGRAMS = vlib_unix vlib_unix_SOURCES = \ @@ -98,3 +99,4 @@ vlib_unix_SOURCES = \ vlib_unix_LDADD = libvlib_unix.la libvlib.la \ -lvppinfra -lpthread -lm -ldl -lrt +endif diff --git a/vlib/vlib/dpdk_buffer.c b/vlib/vlib/dpdk_buffer.c index dbbd5806fd2..68c1fcdb4b6 100644 --- a/vlib/vlib/dpdk_buffer.c +++ b/vlib/vlib/dpdk_buffer.c @@ -446,7 +446,7 @@ fill_free_list (vlib_main_t * vm, vlib_buffer_t * b; int n, i; u32 bi; - u32 n_remaining, n_alloc; + u32 n_remaining = 0, n_alloc = 0; unsigned socket_id = rte_socket_id ? rte_socket_id() : 0; struct rte_mempool *rmp = vm->buffer_main->pktmbuf_pools[socket_id]; struct rte_mbuf *mb; diff --git a/vlib/vlib/main.c b/vlib/vlib/main.c index 64bd3c02b60..f541ed3d57e 100644 --- a/vlib/vlib/main.c +++ b/vlib/vlib/main.c @@ -563,7 +563,7 @@ vlib_node_runtime_sync_stats (vlib_main_t * vm, r->clocks_since_last_overflow = 0; } -always_inline void +always_inline void __attribute__((unused)) vlib_process_sync_stats (vlib_main_t * vm, vlib_process_t * p, uword n_calls, diff --git a/vlib/vlib/threads.c b/vlib/vlib/threads.c index 405a4d644bc..73abba83f70 100644 --- a/vlib/vlib/threads.c +++ b/vlib/vlib/threads.c @@ -159,7 +159,7 @@ vlib_thread_init (vlib_main_t * vm) if (!tm->main_lcore) { tm->main_lcore = clib_bitmap_first_set(avail_cpu); - if (tm->main_lcore == ~0) + if (tm->main_lcore == (u8) ~0) return clib_error_return (0, "no available cpus to be used for the" " main thread"); } diff --git a/vnet/vnet/classify/input_acl.c b/vnet/vnet/classify/input_acl.c index 2c533d1170c..7e835a697f8 100644 --- a/vnet/vnet/classify/input_acl.c +++ b/vnet/vnet/classify/input_acl.c @@ -35,7 +35,7 @@ vnet_inacl_ip_feature_enable (vlib_main_t * vnm, { /* IP[46] */ ip_lookup_main_t * lm; ip_config_main_t * ipcm; - ip4_rx_feature_type_t ftype; + u32 ftype; u32 ci; if (tid == INPUT_ACL_TABLE_IP4) diff --git a/vnet/vnet/ethernet/arp.c b/vnet/vnet/ethernet/arp.c index 4f948407055..79ff44fd050 100644 --- a/vnet/vnet/ethernet/arp.c +++ b/vnet/vnet/ethernet/arp.c @@ -1746,7 +1746,7 @@ arp_term_l2bd (vlib_main_t * vm, ip0 = arp0->ip4_over_ethernet[1].ip4.as_u32; bd_index0 = vnet_buffer(p0)->l2.bd_index; if (PREDICT_FALSE ( - (bd_index0 != last_bd_index) || (last_bd_index == ~0))) + (bd_index0 != last_bd_index) || (last_bd_index == (u16) ~0))) { last_bd_index = bd_index0; last_bd_config = vec_elt_at_index(l2im->bd_configs, bd_index0); diff --git a/vnet/vnet/ip/icmp4.c b/vnet/vnet/ip/icmp4.c index e21f3bf047b..4ee8f15df1f 100644 --- a/vnet/vnet/ip/icmp4.c +++ b/vnet/vnet/ip/icmp4.c @@ -690,7 +690,7 @@ void ip4_icmp_register_type (vlib_main_t * vm, icmp4_type_t type, { icmp4_main_t * im = &icmp4_main; - ASSERT (type < ARRAY_LEN (im->ip4_input_next_index_by_type)); + ASSERT ((int)type < ARRAY_LEN (im->ip4_input_next_index_by_type)); im->ip4_input_next_index_by_type[type] = vlib_node_add_next (vm, ip4_icmp_input_node.index, node_index); } diff --git a/vnet/vnet/ip/icmp6.c b/vnet/vnet/ip/icmp6.c index 2d265d2b5b2..4e4bb8ece81 100644 --- a/vnet/vnet/ip/icmp6.c +++ b/vnet/vnet/ip/icmp6.c @@ -749,7 +749,7 @@ void icmp6_register_type (vlib_main_t * vm, icmp6_type_t type, u32 node_index) { icmp6_main_t * im = &icmp6_main; - ASSERT (type < ARRAY_LEN (im->input_next_index_by_type)); + ASSERT ((int) type < ARRAY_LEN (im->input_next_index_by_type)); im->input_next_index_by_type[type] = vlib_node_add_next (vm, ip6_icmp_input_node.index, node_index); } diff --git a/vnet/vnet/ip/ip4_hop_by_hop.c b/vnet/vnet/ip/ip4_hop_by_hop.c index ee2bcc0ae75..db6a50f271f 100644 --- a/vnet/vnet/ip/ip4_hop_by_hop.c +++ b/vnet/vnet/ip/ip4_hop_by_hop.c @@ -299,7 +299,6 @@ VLIB_REGISTER_NODE (ip4_pop_hop_by_hop_node) = { [IP_LOOKUP_NEXT_MAP] = "ip4-map", [IP_LOOKUP_NEXT_MAP_T] = "ip4-map-t", [IP_LOOKUP_NEXT_SIXRD] = "ip4-sixrd", - [IP_LOOKUP_NEXT_SIXRD] = "ip4-sixrd", [IP_LOOKUP_NEXT_HOP_BY_HOP] = "ip4-hop-by-hop", /* probably not */ [IP_LOOKUP_NEXT_ADD_HOP_BY_HOP] = "ip4-add-hop-by-hop", [IP_LOOKUP_NEXT_POP_HOP_BY_HOP] = "ip4-pop-hop-by-hop", diff --git a/vnet/vnet/ip/ip4_packet.h b/vnet/vnet/ip/ip4_packet.h index 69467eb4e03..ba00eedbb74 100644 --- a/vnet/vnet/ip/ip4_packet.h +++ b/vnet/vnet/ip/ip4_packet.h @@ -266,7 +266,7 @@ ip4_address_is_multicast (ip4_address_t * a) always_inline void ip4_multicast_address_set_for_group (ip4_address_t * a, ip_multicast_group_t g) { - ASSERT (g < (1 << 28)); + ASSERT ((u32) g < (1 << 28)); a->as_u32 = clib_host_to_net_u32 ((0xe << 28) + g); } diff --git a/vnet/vnet/ipsec/ipsec_output.c b/vnet/vnet/ipsec/ipsec_output.c index 77b39fa9ee4..ac5968b906d 100644 --- a/vnet/vnet/ipsec/ipsec_output.c +++ b/vnet/vnet/ipsec/ipsec_output.c @@ -81,7 +81,7 @@ static u8 * format_ipsec_output_trace (u8 * s, va_list * args) return s; } -always_inline intf_output_feat_t +always_inline intf_output_feat_t __attribute__((unused)) get_next_intf_output_feature_and_reset_bit(vlib_buffer_t *b) { u32 next_feature; diff --git a/vnet/vnet/l2tp/l2tp.c b/vnet/vnet/l2tp/l2tp.c index da28487dd7f..36567f96ea7 100644 --- a/vnet/vnet/l2tp/l2tp.c +++ b/vnet/vnet/l2tp/l2tp.c @@ -576,7 +576,7 @@ int l2tpv3_interface_enable_disable (vnet_main_t * vnm, ip_config_main_t * rx_cm = &lm->rx_config_mains[VNET_UNICAST]; u32 ci; ip6_l2tpv3_config_t config; - ip4_rx_feature_type_t type; + ip6_rx_feature_type_t type; if (pool_is_free_index (vnm->interface_main.sw_interfaces, sw_if_index)) return VNET_API_ERROR_INVALID_SW_IF_INDEX; diff --git a/vnet/vnet/map/ip4_map.c b/vnet/vnet/map/ip4_map.c index cf53ef4918c..559275eb586 100644 --- a/vnet/vnet/map/ip4_map.c +++ b/vnet/vnet/map/ip4_map.c @@ -130,7 +130,7 @@ ip4_map_vtcfl (ip4_header_t *ip4, vlib_buffer_t *p) u8 tc = mm->tc_copy ? ip4->tos : mm->tc; u32 vtcfl = 0x6 << 28; vtcfl |= tc << 20; - vtcfl |= vnet_buffer(p)->ip.flow_hash && 0x000fffff; + vtcfl |= vnet_buffer(p)->ip.flow_hash & 0x000fffff; return (clib_host_to_net_u32(vtcfl)); } diff --git a/vnet/vnet/map/ip6_map_t.c b/vnet/vnet/map/ip6_map_t.c index 7720e06fba4..b2c102ac3e7 100644 --- a/vnet/vnet/map/ip6_map_t.c +++ b/vnet/vnet/map/ip6_map_t.c @@ -451,7 +451,7 @@ ip6_map_t_fragmented (vlib_main_t *vm, u16 frag_id0, frag_offset0, frag_id1, frag_offset1; u8 frag_more0, frag_more1; - ip6_mapt_fragmented_next_t next0, next1; + u32 next0, next1; pi0 = to_next[0] = from[0]; pi1 = to_next[1] = from[1]; @@ -536,7 +536,7 @@ ip6_map_t_fragmented (vlib_main_t *vm, u16 frag_id0; u8 frag_more0; u16 frag_offset0; - ip6_mapt_fragmented_next_t next0; + u32 next0; pi0 = to_next[0] = from[0]; from += 1; diff --git a/vnet/vnet/policer/xlate.c b/vnet/vnet/policer/xlate.c index 761e8214413..6e8c324a5d3 100644 --- a/vnet/vnet/policer/xlate.c +++ b/vnet/vnet/policer/xlate.c @@ -894,7 +894,7 @@ compute_policer_params (uint64_t hz, // CPU speed in clocks per uint32_t max; uint32_t scale_shift; uint32_t scale_amount; - uint32_t orig_current_limit = *current_limit; + uint32_t __attribute__((unused)) orig_current_limit = *current_limit; // Compute period. For 1Ghz-to-8Ghz CPUs, the period will be in // the range of 16 to 116 usec. @@ -969,8 +969,6 @@ compute_policer_params (uint64_t hz, // CPU speed in clocks per (unsigned long long)effective_BPS, (double)cir_rate / (double)effective_BPS); } -#else - orig_current_limit = orig_current_limit; // Make compiler happy #endif return 0; // ok diff --git a/vnet/vnet/srp/node.c b/vnet/vnet/srp/node.c index a44f108326e..42143ef6e9d 100644 --- a/vnet/vnet/srp/node.c +++ b/vnet/vnet/srp/node.c @@ -703,7 +703,7 @@ static int requests_switch (srp_ips_request_type_t r) [SRP_IPS_REQUEST_signal_fail] = 1, [SRP_IPS_REQUEST_signal_degrade] = 1, }; - return r < ARRAY_LEN (t) ? t[r] : 0; + return (int) r < ARRAY_LEN (t) ? t[r] : 0; } /* Called when an IPS control packet is received on given interface. */ diff --git a/vppinfra/tools/elftool.c b/vppinfra/tools/elftool.c index c0184b5c7e7..b8acd055602 100644 --- a/vppinfra/tools/elftool.c +++ b/vppinfra/tools/elftool.c @@ -227,7 +227,7 @@ set_interpreter_rpath (elf_tool_main_t * tm) u32 run_length; u8 in_run; u64 offset0 = 0, offset1 = 0; - clib_error_t * error; + clib_error_t * error = 0; int fix_in_place = 0; if (!strcmp (tm->input_file, tm->output_file)) diff --git a/vppinfra/vppinfra/elog.h b/vppinfra/vppinfra/elog.h index b49618bf038..8c5482ae284 100644 --- a/vppinfra/vppinfra/elog.h +++ b/vppinfra/vppinfra/elog.h @@ -182,7 +182,7 @@ always_inline void elog_enable_disable (elog_main_t * em, int is_enabled) { em->n_total_events = 0; - em->n_total_events_disable_limit = is_enabled ? ~0ULL : 0ULL; + em->n_total_events_disable_limit = is_enabled ? ~0 : 0; } /* Disable logging after specified number of ievents have been logged. diff --git a/vppinfra/vppinfra/heap.c b/vppinfra/vppinfra/heap.c index 01df54a3aac..5f44cd40534 100644 --- a/vppinfra/vppinfra/heap.c +++ b/vppinfra/vppinfra/heap.c @@ -85,7 +85,7 @@ always_inline uword size_to_bin (uword size) } /* Convert bin to size. */ -always_inline uword bin_to_size (uword bin) +always_inline __attribute__((unused)) uword bin_to_size (uword bin) { uword size; diff --git a/vppinfra/vppinfra/md5.c b/vppinfra/vppinfra/md5.c index ed0342b07e5..e6558d99e93 100644 --- a/vppinfra/vppinfra/md5.c +++ b/vppinfra/vppinfra/md5.c @@ -220,7 +220,7 @@ void md5_init (md5_context_t * c) c->state[3] = 0x10325476; } -always_inline void +always_inline void __attribute__((unused)) md5_fill_buffer_aligned (md5_context_t * c, u32 * d32) { diff --git a/vppinfra/vppinfra/mheap.c b/vppinfra/vppinfra/mheap.c index 60ecdc0a0a4..cd8672e7ef4 100644 --- a/vppinfra/vppinfra/mheap.c +++ b/vppinfra/vppinfra/mheap.c @@ -115,7 +115,7 @@ mheap_elt_size_to_user_n_bytes (uword n_bytes) return (n_bytes - STRUCT_OFFSET_OF (mheap_elt_t, user_data)); } -always_inline uword +always_inline uword __attribute__((unused)) mheap_elt_size_to_user_n_words (uword n_bytes) { ASSERT (n_bytes % MHEAP_USER_DATA_WORD_BYTES == 0); diff --git a/vppinfra/vppinfra/test_vec.c b/vppinfra/vppinfra/test_vec.c index ea66ac1bb4e..12c0603ec8d 100644 --- a/vppinfra/vppinfra/test_vec.c +++ b/vppinfra/vppinfra/test_vec.c @@ -1049,7 +1049,8 @@ int test_vec_main (unformat_input_t * input) { u8 * bigboy = 0; u64 one_gig = (1<<30); - u64 size, index; + u64 size; + i64 index; fformat (stdout, "giant vector test..."); size = 5ULL * one_gig; -- cgit 1.2.3-korg