Fix warnings/errors reported by clang
authorDamjan Marion <[email protected]>
Fri, 18 Dec 2015 09:26:56 +0000 (10:26 +0100)
committerDamjan Marion <[email protected]>
Fri, 18 Dec 2015 12:31:56 +0000 (13:31 +0100)
Change-Id: Ifb2de64347526e3218e22067452f249ff878fd32
Signed-off-by: Damjan Marion <[email protected]>
23 files changed:
svm/svm.c
vlib/Makefile.am
vlib/vlib/dpdk_buffer.c
vlib/vlib/main.c
vlib/vlib/threads.c
vnet/vnet/classify/input_acl.c
vnet/vnet/ethernet/arp.c
vnet/vnet/ip/icmp4.c
vnet/vnet/ip/icmp6.c
vnet/vnet/ip/ip4_hop_by_hop.c
vnet/vnet/ip/ip4_packet.h
vnet/vnet/ipsec/ipsec_output.c
vnet/vnet/l2tp/l2tp.c
vnet/vnet/map/ip4_map.c
vnet/vnet/map/ip6_map_t.c
vnet/vnet/policer/xlate.c
vnet/vnet/srp/node.c
vppinfra/tools/elftool.c
vppinfra/vppinfra/elog.h
vppinfra/vppinfra/heap.c
vppinfra/vppinfra/md5.c
vppinfra/vppinfra/mheap.c
vppinfra/vppinfra/test_vec.c

index 4d45b29..ab74913 100644 (file)
--- 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);
index 1275798..b38c843 100644 (file)
@@ -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
index dbbd580..68c1fcd 100644 (file)
@@ -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;
index 64bd3c0..f541ed3 100644 (file)
@@ -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,
index 405a4d6..73abba8 100644 (file)
@@ -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");
     }
index 2c533d1..7e835a6 100644 (file)
@@ -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)
index 4f94840..79ff44f 100644 (file)
@@ -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);
index e21f3bf..4ee8f15 100644 (file)
@@ -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);
 }
index 2d265d2..4e4bb8e 100644 (file)
@@ -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);
 }
index ee2bcc0..db6a50f 100644 (file)
@@ -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", 
index 69467eb..ba00eed 100644 (file)
@@ -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);
 }
 
index 77b39fa..ac5968b 100644 (file)
@@ -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;
index da28487..36567f9 100644 (file)
@@ -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;
index cf53ef4..559275e 100644 (file)
@@ -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));
 }
index 7720e06..b2c102a 100644 (file)
@@ -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;
index 761e821..6e8c324 100644 (file)
@@ -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
index a44f108..42143ef 100644 (file)
@@ -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. */
index c0184b5..b8acd05 100644 (file)
@@ -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))
index b49618b..8c5482a 100644 (file)
@@ -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.
index 01df54a..5f44cd4 100644 (file)
@@ -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;
 
index ed0342b..e6558d9 100644 (file)
@@ -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)
 {
index 60ecdc0..cd8672e 100644 (file)
@@ -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);
index ea66ac1..12c0603 100644 (file)
@@ -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;