diff --git a/.gitignore b/.gitignore index 9d2ecd8f6b3b..7e2007a5b6ba 100644 --- a/.gitignore +++ b/.gitignore @@ -161,3 +161,4 @@ compile_commands.json /startup.vpp # log file archives /archives +/venv \ No newline at end of file diff --git a/extras/deprecated/plugins/gbp/gbp_learn_node.c b/extras/deprecated/plugins/gbp/gbp_learn_node.c index a6c549719563..e503abdcae25 100644 --- a/extras/deprecated/plugins/gbp/gbp_learn_node.c +++ b/extras/deprecated/plugins/gbp/gbp_learn_node.c @@ -154,7 +154,7 @@ typedef struct gbp_learn_l2_trace_t_ /* per-pkt trace data */ mac_address_t mac; u32 sw_if_index; - u32 new; + u32 _new; u32 throttled; u32 sclass; u32 d_bit; @@ -352,7 +352,7 @@ VLIB_NODE_FN (gbp_learn_l2_node) (vlib_main_t * vm, gbp_learn_l2_trace_t *t = vlib_add_trace (vm, node, b0, sizeof (*t)); clib_memcpy_fast (t->mac.bytes, eh0->src_address, 6); - t->new = (NULL == ge0); + t->_new = (NULL == ge0); t->throttled = t0; t->sw_if_index = sw_if_index0; t->sclass = sclass0; @@ -383,7 +383,7 @@ format_gbp_learn_l2_trace (u8 * s, va_list * args) s = format (s, "new:%d throttled:%d d-bit:%d mac:%U itf:%d sclass:%d" " gb-flags:%U", - t->new, t->throttled, t->d_bit, + t->_new, t->throttled, t->d_bit, format_mac_address_t, &t->mac, t->sw_if_index, t->sclass, format_gbp_bridge_domain_flags, t->gb_flags); @@ -489,7 +489,7 @@ typedef struct gbp_learn_l3_trace_t_ /* per-pkt trace data */ ip46_address_t ip; u32 sw_if_index; - u32 new; + u32 _new; u32 throttled; u32 sclass; } gbp_learn_l3_trace_t; @@ -633,7 +633,7 @@ gbp_learn_l3 (vlib_main_t * vm, ip46_address_set_ip6 (&t->ip, &ip6_0->src_address); if (FIB_PROTOCOL_IP4 == fproto && ip4_0) ip46_address_set_ip4 (&t->ip, &ip4_0->src_address); - t->new = (NULL == ge0); + t->_new = (NULL == ge0); t->throttled = t0; t->sw_if_index = sw_if_index0; t->sclass = sclass0; @@ -659,7 +659,7 @@ format_gbp_learn_l3_trace (u8 * s, va_list * args) gbp_learn_l3_trace_t *t = va_arg (*args, gbp_learn_l3_trace_t *); s = format (s, "new:%d throttled:%d ip:%U itf:%d sclass:%d", - t->new, t->throttled, + t->_new, t->throttled, format_ip46_address, &t->ip, IP46_TYPE_ANY, t->sw_if_index, t->sclass); diff --git a/extras/deprecated/vppinfra/cuckoo_template.c b/extras/deprecated/vppinfra/cuckoo_template.c index 8cd2a2be2b5f..bb81b7656840 100644 --- a/extras/deprecated/vppinfra/cuckoo_template.c +++ b/extras/deprecated/vppinfra/cuckoo_template.c @@ -723,16 +723,16 @@ static void CV (clib_cuckoo_rehash) (CVT (clib_cuckoo) * h) CVT (clib_cuckoo_bucket) * old = h->buckets; uword old_nbuckets = vec_len (old); uword new_nbuckets = 2 * old_nbuckets; - CVT (clib_cuckoo_bucket) * new = + CVT (clib_cuckoo_bucket) * _new = vec_dup_aligned (old, CLIB_CACHE_LINE_BYTES); /* allocate space */ - vec_validate_aligned (new, new_nbuckets - 1, CLIB_CACHE_LINE_BYTES); - ASSERT (new_nbuckets == vec_len (new)); + vec_validate_aligned (_new, new_nbuckets - 1, CLIB_CACHE_LINE_BYTES); + ASSERT (new_nbuckets == vec_len (_new)); /* store old pointer in to-be-freed list */ vec_add1 (h->to_be_freed, old); /* mark new elements as free */ CVT (clib_cuckoo_bucket) * bucket; - for (bucket = new + old_nbuckets; bucket < vec_end (new); ++bucket) + for (bucket = _new + old_nbuckets; bucket < vec_end (_new); ++bucket) { clib_memset (bucket->elts, 0xff, sizeof (bucket->elts)); } @@ -745,8 +745,8 @@ static void CV (clib_cuckoo_rehash) (CVT (clib_cuckoo) * h) { /* items in old bucket might be moved to new bucket */ uword new_bucket_idx = old_bucket_idx + old_nbuckets; - CVT (clib_cuckoo_bucket) * old_bucket = new + old_bucket_idx; - CVT (clib_cuckoo_bucket) * new_bucket = new + new_bucket_idx; + CVT (clib_cuckoo_bucket) * old_bucket = _new + old_bucket_idx; + CVT (clib_cuckoo_bucket) * new_bucket = _new + new_bucket_idx; int i = 0; int moved = 0; clib_cuckoo_bucket_aux_t aux = old_bucket->aux; @@ -757,7 +757,7 @@ static void CV (clib_cuckoo_rehash) (CVT (clib_cuckoo) * h) clib_cuckoo_lookup_info_t old_lookup = CV (clib_cuckoo_calc_lookup) (old, hash); clib_cuckoo_lookup_info_t new_lookup = - CV (clib_cuckoo_calc_lookup) (new, hash); + CV (clib_cuckoo_calc_lookup) (_new, hash); if ((old_bucket_idx == old_lookup.bucket1 && new_bucket_idx == new_lookup.bucket1) || (old_bucket_idx == old_lookup.bucket2 && @@ -788,7 +788,7 @@ static void CV (clib_cuckoo_rehash) (CVT (clib_cuckoo) * h) new_bucket->aux = aux; } } - h->buckets = new; + h->buckets = _new; #if CLIB_CUCKOO_DEBUG_COUNTERS ++h->rehashes; #endif diff --git a/extras/deprecated/vppinfra/vhash.c b/extras/deprecated/vppinfra/vhash.c index 9120f502c912..198bcd7dc096 100644 --- a/extras/deprecated/vppinfra/vhash.c +++ b/extras/deprecated/vppinfra/vhash.c @@ -653,8 +653,8 @@ vhash_resize_incremental (vhash_resize_t * vr, u32 vector_index, u32 n_keys_this_call) { vhash_t *old = vr->old; - vhash_main_t *vm = &vr->new; - vhash_t *new = vm->vhash; + vhash_main_t *vm = &vr->_new; + vhash_t *_new = vm->vhash; uword i, j, n_key_u32; n_key_u32 = old->n_key_u32; @@ -665,7 +665,7 @@ vhash_resize_incremental (vhash_resize_t * vr, u32 vector_index, hash_seeds[0] = old->hash_seeds[0].as_u32[0]; hash_seeds[1] = old->hash_seeds[1].as_u32[0]; hash_seeds[2] = old->hash_seeds[2].as_u32[0]; - vhash_init (new, old->log2_n_keys + 1, n_key_u32, hash_seeds); + vhash_init (_new, old->log2_n_keys + 1, n_key_u32, hash_seeds); } vec_reset_length (vm->keys); @@ -744,11 +744,11 @@ void vhash_resize (vhash_t * old, u32 log2_n_keys) { static vhash_resize_t vr; - vhash_t new; + vhash_t _new; u32 i = 0; vr.old = old; - vr.new.vhash = &new; + vr._new.vhash = &_new; while (1) { @@ -758,7 +758,7 @@ vhash_resize (vhash_t * old, u32 log2_n_keys) } vhash_free (old); - *old = new; + *old = _new; } #endif /* CLIB_HAVE_VEC128 */ diff --git a/extras/deprecated/vppinfra/vhash.h b/extras/deprecated/vppinfra/vhash.h index 85dfb788308b..fbb1bfb6dadf 100644 --- a/extras/deprecated/vppinfra/vhash.h +++ b/extras/deprecated/vppinfra/vhash.h @@ -829,7 +829,7 @@ void vhash_main_unset (vhash_main_t * vm); typedef struct { - vhash_main_t new; + vhash_main_t _new; vhash_t *old; } vhash_resize_t; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index de1ee713d5cb..6e5068378252 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -19,7 +19,11 @@ else() set(CMAKE_C_COMPILER_NAMES clang gcc cc) endif() -project(vpp C) +set(CXX_STANDARD 20) +set(CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS ON) + +project(vpp LANGUAGES C CXX) if(NOT DEFINED CMAKE_INSTALL_LIBDIR AND EXISTS "/etc/debian_version") set(CMAKE_INSTALL_LIBDIR "lib/${CMAKE_LIBRARY_ARCHITECTURE}") diff --git a/src/plugins/af_packet/af_packet.c b/src/plugins/af_packet/af_packet.c index 8cb2af27d7fc..e4a20d737f0c 100644 --- a/src/plugins/af_packet/af_packet.c +++ b/src/plugins/af_packet/af_packet.c @@ -251,15 +251,15 @@ af_packet_set_rx_queues (vlib_main_t *vm, af_packet_if_t *apif) vnm, apif->hw_if_index, rx_queue->queue_id, VNET_HW_IF_RXQ_THREAD_ANY); { - clib_file_t template = { 0 }; - template.read_function = af_packet_fd_read_ready; - template.error_function = af_packet_fd_error; - template.file_descriptor = rx_queue->fd; - template.private_data = rx_queue->queue_index; - template.description = + clib_file_t _template = { 0 }; + _template.read_function = af_packet_fd_read_ready; + _template.error_function = af_packet_fd_error; + _template.file_descriptor = rx_queue->fd; + _template.private_data = rx_queue->queue_index; + _template.description = format (0, "%U queue %u", format_af_packet_device_name, apif->dev_instance, rx_queue->queue_id); - rx_queue->clib_file_index = clib_file_add (&file_main, &template); + rx_queue->clib_file_index = clib_file_add (&file_main, &_template); } vnet_hw_if_set_rx_queue_file_index (vnm, rx_queue->queue_index, rx_queue->clib_file_index); diff --git a/src/plugins/af_xdp/device.c b/src/plugins/af_xdp/device.c index 63a276ce51e7..3242598f1b0c 100644 --- a/src/plugins/af_xdp/device.c +++ b/src/plugins/af_xdp/device.c @@ -61,11 +61,11 @@ gdb_af_xdp_get_cons (const struct xsk_ring_cons * cons) } static clib_error_t * -af_xdp_mac_change (vnet_hw_interface_t * hw, const u8 * old, const u8 * new) +af_xdp_mac_change (vnet_hw_interface_t * hw, const u8 * old, const u8 * _new) { af_xdp_main_t *am = &af_xdp_main; af_xdp_device_t *ad = vec_elt_at_index (am->devices, hw->dev_instance); - errno_t err = memcpy_s (ad->hwaddr, sizeof (ad->hwaddr), new, 6); + errno_t err = memcpy_s (ad->hwaddr, sizeof (ad->hwaddr), _new, 6); if (err) return clib_error_return_code (0, -err, CLIB_ERROR_ERRNO_VALID, "mac change failed"); diff --git a/src/plugins/auto_sdl/auto_sdl.c b/src/plugins/auto_sdl/auto_sdl.c index 91e469bb9f0b..22f723b71e69 100644 --- a/src/plugins/auto_sdl/auto_sdl.c +++ b/src/plugins/auto_sdl/auto_sdl.c @@ -16,9 +16,9 @@ VLIB_REGISTER_LOG_CLASS (auto_sdl_log, static) = { .class_name = "auto", .subclass_name = "sdl" }; #define log_debug(fmt, ...) \ - vlib_log_debug (auto_sdl_log.class, "%s: " fmt, __func__, __VA_ARGS__) -#define log_warn(fmt, ...) vlib_log_warn (auto_sdl_log.class, fmt, __VA_ARGS__) -#define log_err(fmt, ...) vlib_log_err (auto_sdl_log.class, fmt, __VA_ARGS__) + vlib_log_debug (auto_sdl_log._class, "%s: " fmt, __func__, __VA_ARGS__) +#define log_warn(fmt, ...) vlib_log_warn (auto_sdl_log._class, fmt, __VA_ARGS__) +#define log_err(fmt, ...) vlib_log_err (auto_sdl_log._class, fmt, __VA_ARGS__) static auto_sdl_per_fib_t * auto_sdlb_get_for_fib_index (u32 fib_proto, u32 fib_index, int alloc) diff --git a/src/plugins/avf/avf.h b/src/plugins/avf/avf.h index 774aac0151b4..ef9a4a23dc8f 100644 --- a/src/plugins/avf/avf.h +++ b/src/plugins/avf/avf.h @@ -90,22 +90,22 @@ extern vlib_log_class_registration_t avf_log; extern vlib_log_class_registration_t avf_stats_log; #define avf_log_err(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_ERR, avf_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_ERR, avf_log._class, "%U: " f, \ format_vlib_pci_addr, &dev->pci_addr, \ ## __VA_ARGS__) #define avf_log_warn(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_WARNING, avf_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_WARNING, avf_log._class, "%U: " f, \ format_vlib_pci_addr, &dev->pci_addr, \ ## __VA_ARGS__) #define avf_log_debug(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_DEBUG, avf_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_DEBUG, avf_log._class, "%U: " f, \ format_vlib_pci_addr, &dev->pci_addr, \ ## __VA_ARGS__) #define avf_stats_log_debug(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_DEBUG, avf_stats_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_DEBUG, avf_stats_log._class, "%U: " f, \ format_vlib_pci_addr, &dev->pci_addr, ##__VA_ARGS__) #define foreach_avf_device_flags \ diff --git a/src/plugins/avf/device.c b/src/plugins/avf/device.c index 98169f0bcfea..14826dbf7a9d 100644 --- a/src/plugins/avf/device.c +++ b/src/plugins/avf/device.c @@ -1237,7 +1237,7 @@ avf_process_one_device (vlib_main_t * vm, avf_device_t * ad, int is_irq) error: ad->flags |= AVF_DEVICE_F_ERROR; ASSERT (ad->error != 0); - vlib_log_err (avf_log.class, "%U", format_clib_error, ad->error); + vlib_log_err (avf_log._class, "%U", format_clib_error, ad->error); } clib_error_t * diff --git a/src/plugins/dev_armada/pp2/pp2.h b/src/plugins/dev_armada/pp2/pp2.h index 160bfd20c5c0..73d84cfa69cc 100644 --- a/src/plugins/dev_armada/pp2/pp2.h +++ b/src/plugins/dev_armada/pp2/pp2.h @@ -165,20 +165,20 @@ vnet_dev_tx_queue_op_no_rv_t mvpp2_txq_free; /* inline funcs */ #define log_debug(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_DEBUG, mvpp2_log.class, "%U" f, \ + vlib_log (VLIB_LOG_LEVEL_DEBUG, mvpp2_log._class, "%U" f, \ format_vnet_dev_log, (dev), \ clib_string_skip_prefix (__func__, "mvpp2_"), ##__VA_ARGS__) #define log_info(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_INFO, mvpp2_log.class, "%U" f, \ + vlib_log (VLIB_LOG_LEVEL_INFO, mvpp2_log._class, "%U" f, \ format_vnet_dev_log, (dev), 0, ##__VA_ARGS__) #define log_notice(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_NOTICE, mvpp2_log.class, "%U" f, \ + vlib_log (VLIB_LOG_LEVEL_NOTICE, mvpp2_log._class, "%U" f, \ format_vnet_dev_log, (dev), 0, ##__VA_ARGS__) #define log_warn(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_WARNING, mvpp2_log.class, "%U" f, \ + vlib_log (VLIB_LOG_LEVEL_WARNING, mvpp2_log._class, "%U" f, \ format_vnet_dev_log, (dev), 0, ##__VA_ARGS__) #define log_err(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_ERR, mvpp2_log.class, "%U" f, format_vnet_dev_log, \ + vlib_log (VLIB_LOG_LEVEL_ERR, mvpp2_log._class, "%U" f, format_vnet_dev_log, \ (dev), 0, ##__VA_ARGS__) #define foreach_mvpp2_tx_node_counter \ diff --git a/src/plugins/dev_armada/pp2/rx.c b/src/plugins/dev_armada/pp2/rx.c index 4e73882e3d86..cf2f26ea8eea 100644 --- a/src/plugins/dev_armada/pp2/rx.c +++ b/src/plugins/dev_armada/pp2/rx.c @@ -43,8 +43,8 @@ mrvl_pp2_rx_one_if (vlib_main_t *vm, vlib_node_runtime_t *node, b1 = desc_to_vlib_buffer (vm, dp[1]); bi[0] = pp2_ppio_inq_desc_get_cookie (dp[0]); bi[1] = pp2_ppio_inq_desc_get_cookie (dp[1]); - b0->template = bt; - b1->template = bt; + b0->_template = bt; + b1->_template = bt; n_rx_bytes += b0->current_length = pp2_ppio_inq_desc_get_pkt_len (dp[0]) + len_adj; @@ -56,7 +56,7 @@ mrvl_pp2_rx_one_if (vlib_main_t *vm, vlib_node_runtime_t *node, { b0 = desc_to_vlib_buffer (vm, dp[0]); bi[0] = pp2_ppio_inq_desc_get_cookie (dp[0]); - b0->template = bt; + b0->_template = bt; n_rx_bytes += b0->current_length = pp2_ppio_inq_desc_get_pkt_len (dp[0]) + len_adj; diff --git a/src/plugins/dev_ena/ena.h b/src/plugins/dev_ena/ena.h index 4acb8d9625ab..e3f030f810e3 100644 --- a/src/plugins/dev_ena/ena.h +++ b/src/plugins/dev_ena/ena.h @@ -216,19 +216,19 @@ typedef enum } ena_tx_node_ctr_t; #define log_debug(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_DEBUG, ena_log.class, "%U" f, format_vnet_dev_log, \ + vlib_log (VLIB_LOG_LEVEL_DEBUG, ena_log._class, "%U" f, format_vnet_dev_log, \ (dev), clib_string_skip_prefix (__func__, "ena_"), ##__VA_ARGS__) #define log_info(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_INFO, ena_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_INFO, ena_log._class, "%U: " f, \ format_vnet_dev_addr, (dev), ##__VA_ARGS__) #define log_notice(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_NOTICE, ena_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_NOTICE, ena_log._class, "%U: " f, \ format_vnet_dev_addr, (dev), ##__VA_ARGS__) #define log_warn(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_WARNING, ena_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_WARNING, ena_log._class, "%U: " f, \ format_vnet_dev_addr, (dev), ##__VA_ARGS__) #define log_err(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_ERR, ena_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_ERR, ena_log._class, "%U: " f, \ format_vnet_dev_addr, (dev), ##__VA_ARGS__) #endif /* _ENA_H_ */ diff --git a/src/plugins/dev_ena/ena_inlines.h b/src/plugins/dev_ena/ena_inlines.h index 106bd5eaa21e..a5712095cfbc 100644 --- a/src/plugins/dev_ena/ena_inlines.h +++ b/src/plugins/dev_ena/ena_inlines.h @@ -10,18 +10,18 @@ #include #define ena_log_is_debug() \ - vlib_log_is_enabled (VLIB_LOG_LEVEL_DEBUG, ena_log.class) + vlib_log_is_enabled (VLIB_LOG_LEVEL_DEBUG, ena_log._class) #define ena_stats_log_err(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_ERR, ena_stats_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_ERR, ena_stats_log._class, "%U: " f, \ format_vnet_dev_addr, dev, ##__VA_ARGS__) #define ena_stats_log_debug(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_DEBUG, ena_stats_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_DEBUG, ena_stats_log._class, "%U: " f, \ format_vnet_dev_addr, dev, ##__VA_ARGS__) #define ena_stats_log_is_debug() \ - vlib_log_is_enabled (VLIB_LOG_LEVEL_DEBUG, ena_stats_log.class) + vlib_log_is_enabled (VLIB_LOG_LEVEL_DEBUG, ena_stats_log._class) static_always_inline void ena_set_mem_addr (vlib_main_t *vm, vnet_dev_t *dev, ena_mem_addr_t *m, void *p) diff --git a/src/plugins/dev_ena/rx_node.c b/src/plugins/dev_ena/rx_node.c index 51c6dbce84cb..e460cc6eaedb 100644 --- a/src/plugins/dev_ena/rx_node.c +++ b/src/plugins/dev_ena/rx_node.c @@ -317,23 +317,23 @@ ena_device_input_inline (vlib_main_t *vm, vlib_node_runtime_t *node, clib_prefetch_store (b[5]); clib_prefetch_store (b[6]); clib_prefetch_store (b[7]); - b[0]->template = bt; + b[0]->_template = bt; n_rx_bytes += b[0]->current_length = l[0]; b[0]->flags = f[0]; - b[1]->template = bt; + b[1]->_template = bt; n_rx_bytes += b[1]->current_length = l[1]; b[1]->flags = f[1]; - b[2]->template = bt; + b[2]->_template = bt; n_rx_bytes += b[2]->current_length = l[2]; b[2]->flags = f[2]; - b[3]->template = bt; + b[3]->_template = bt; n_rx_bytes += b[3]->current_length = l[3]; b[3]->flags = f[3]; } for (; n_left > 0; b += 1, f += 1, l += 1, n_left -= 1) { - b[0]->template = bt; + b[0]->_template = bt; n_rx_bytes += b[0]->current_length = l[0]; b[0]->flags = f[0]; } diff --git a/src/plugins/dev_iavf/iavf.h b/src/plugins/dev_iavf/iavf.h index 39f92741a637..80672bb05f8b 100644 --- a/src/plugins/dev_iavf/iavf.h +++ b/src/plugins/dev_iavf/iavf.h @@ -159,20 +159,20 @@ iavf_reg_flush (iavf_device_t *ad) } #define log_debug(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_DEBUG, iavf_log.class, "%U" f, \ + vlib_log (VLIB_LOG_LEVEL_DEBUG, iavf_log._class, "%U" f, \ format_vnet_dev_log, (dev), \ clib_string_skip_prefix (__func__, "iavf_"), ##__VA_ARGS__) #define log_info(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_INFO, iavf_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_INFO, iavf_log._class, "%U: " f, \ format_vnet_dev_addr, (dev), ##__VA_ARGS__) #define log_notice(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_NOTICE, iavf_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_NOTICE, iavf_log._class, "%U: " f, \ format_vnet_dev_addr, (dev), ##__VA_ARGS__) #define log_warn(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_WARNING, iavf_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_WARNING, iavf_log._class, "%U: " f, \ format_vnet_dev_addr, (dev), ##__VA_ARGS__) #define log_err(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_ERR, iavf_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_ERR, iavf_log._class, "%U: " f, \ format_vnet_dev_addr, (dev), ##__VA_ARGS__) /* temp */ diff --git a/src/plugins/dev_iavf/port.c b/src/plugins/dev_iavf/port.c index a05308226881..e8d4d44cb90d 100644 --- a/src/plugins/dev_iavf/port.c +++ b/src/plugins/dev_iavf/port.c @@ -450,7 +450,7 @@ iavf_port_cfg_rxq_int_mode_change (vlib_main_t *vm, vnet_dev_port_t *port, vnet_dev_t *dev = port->dev; char *ed = state ? "ena" : "disa"; char qstr[16]; - u64 old, new = 0; + u64 old, _new = 0; state = state != 0; old = ap->intr_mode_per_rxq_bitmap; @@ -460,22 +460,22 @@ iavf_port_cfg_rxq_int_mode_change (vlib_main_t *vm, vnet_dev_port_t *port, snprintf (qstr, sizeof (qstr), "all queues"); if (state) foreach_vnet_dev_port_rx_queue (q, port) - u64_bit_set (&new, q->queue_id, 1); + u64_bit_set (&_new, q->queue_id, 1); } else { snprintf (qstr, sizeof (qstr), "queue %u", qid); - new = old; - u64_bit_set (&new, qid, state); + _new = old; + u64_bit_set (&_new, qid, state); } - if (new == old) + if (_new == old) { log_warn (dev, "interrupt mode already %sbled on %s", ed, qstr); return rv; } - ap->intr_mode_per_rxq_bitmap = new; + ap->intr_mode_per_rxq_bitmap = _new; if (port->started) { @@ -487,8 +487,7 @@ iavf_port_cfg_rxq_int_mode_change (vlib_main_t *vm, vnet_dev_port_t *port, } } - log_debug (dev, "interrupt mode %sbled on %s, new bitmap is 0x%x", ed, qstr, - new); + log_debug (dev, "interrupt mode %sbled on %s, new bitmap is 0x%x", ed, qstr, _new); return rv; } diff --git a/src/plugins/dev_iavf/rx_node.c b/src/plugins/dev_iavf/rx_node.c index bf650f9bfb96..e460e183459f 100644 --- a/src/plugins/dev_iavf/rx_node.c +++ b/src/plugins/dev_iavf/rx_node.c @@ -135,7 +135,7 @@ iavf_rx_attach_tail (vlib_main_t *vm, vlib_buffer_template_t *bt, b->next_buffer = t->buffers[i]; b->flags |= VLIB_BUFFER_NEXT_PRESENT; b = vlib_get_buffer (vm, b->next_buffer); - b->template = *bt; + b->_template = *bt; tlnifb += b->current_length = ((iavf_rx_desc_qw1_t) qw1).length; i++; } @@ -192,10 +192,10 @@ iavf_process_rx_burst (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_prefetch_buffer_header (b[11], LOAD); } - b[0]->template = *bt; - b[1]->template = *bt; - b[2]->template = *bt; - b[3]->template = *bt; + b[0]->_template = *bt; + b[1]->_template = *bt; + b[2]->_template = *bt; + b[3]->_template = *bt; n_rx_bytes += b[0]->current_length = ((iavf_rx_desc_qw1_t) qw1[0]).length; @@ -223,7 +223,7 @@ iavf_process_rx_burst (vlib_main_t *vm, vlib_node_runtime_t *node, while (n_left) { - b[0]->template = *bt; + b[0]->_template = *bt; n_rx_bytes += b[0]->current_length = ((iavf_rx_desc_qw1_t) qw1[0]).length; diff --git a/src/plugins/dev_octeon/init.c b/src/plugins/dev_octeon/init.c index 561cbe94fedd..f576b53b6603 100644 --- a/src/plugins/dev_octeon/init.c +++ b/src/plugins/dev_octeon/init.c @@ -332,7 +332,7 @@ oct_init (vlib_main_t *vm, vnet_dev_t *dev) cd->plt_pci_dev = (struct plt_pci_device){ .id.vendor_id = pci_hdr.vendor_id, .id.device_id = pci_hdr.device_id, - .id.class_id = pci_hdr.class << 16 | pci_hdr.subclass, + .id.class_id = pci_hdr._class << 16 | pci_hdr.subclass, .pci_handle = vnet_dev_get_pci_handle (dev), }; diff --git a/src/plugins/dev_octeon/octeon.h b/src/plugins/dev_octeon/octeon.h index ccf8f62880d8..85ce097a7ed5 100644 --- a/src/plugins/dev_octeon/octeon.h +++ b/src/plugins/dev_octeon/octeon.h @@ -158,19 +158,19 @@ vnet_dev_rv_t oct_txq_get_stats (vlib_main_t *, vnet_dev_port_t *, vnet_dev_tx_queue_t *); #define log_debug(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_DEBUG, oct_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_DEBUG, oct_log._class, "%U: " f, \ format_vnet_dev_addr, (dev), ##__VA_ARGS__) #define log_info(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_INFO, oct_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_INFO, oct_log._class, "%U: " f, \ format_vnet_dev_addr, (dev), ##__VA_ARGS__) #define log_notice(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_NOTICE, oct_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_NOTICE, oct_log._class, "%U: " f, \ format_vnet_dev_addr, (dev), ##__VA_ARGS__) #define log_warn(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_WARNING, oct_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_WARNING, oct_log._class, "%U: " f, \ format_vnet_dev_addr, (dev), ##__VA_ARGS__) #define log_err(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_ERR, oct_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_ERR, oct_log._class, "%U: " f, \ format_vnet_dev_addr, (dev), ##__VA_ARGS__) #define foreach_oct_tx_node_counter \ diff --git a/src/plugins/dev_octeon/rx_node.c b/src/plugins/dev_octeon/rx_node.c index 833227eeea8f..91ee695f2957 100644 --- a/src/plugins/dev_octeon/rx_node.c +++ b/src/plugins/dev_octeon/rx_node.c @@ -125,10 +125,10 @@ oct_rx_batch (vlib_main_t *vm, oct_rx_node_ctx_t *ctx, ctx->to_next[1] = vlib_get_buffer_index (vm, b[1]); ctx->to_next[2] = vlib_get_buffer_index (vm, b[2]); ctx->to_next[3] = vlib_get_buffer_index (vm, b[3]); - b[0]->template = bt; - b[1]->template = bt; - b[2]->template = bt; - b[3]->template = bt; + b[0]->_template = bt; + b[1]->_template = bt; + b[2]->_template = bt; + b[3]->_template = bt; ctx->n_rx_bytes += b[0]->current_length = d[0].sg0.seg1_size; ctx->n_rx_bytes += b[1]->current_length = d[1].sg0.seg1_size; ctx->n_rx_bytes += b[2]->current_length = d[2].sg0.seg1_size; @@ -160,7 +160,7 @@ oct_rx_batch (vlib_main_t *vm, oct_rx_node_ctx_t *ctx, { b[0] = (vlib_buffer_t *) d->segs0[0] - 1; ctx->to_next[0] = vlib_get_buffer_index (vm, b[0]); - b[0]->template = bt; + b[0]->_template = bt; ctx->n_rx_bytes += b[0]->current_length = d[0].sg0.seg1_size; b[0]->flow_id = d[0].parse.w[3] >> 48; ctx->n_segs += 1; diff --git a/src/plugins/dhcp/dhcp6_proxy_node.c b/src/plugins/dhcp/dhcp6_proxy_node.c index a1d41e83b0fc..abcc3fee7081 100644 --- a/src/plugins/dhcp/dhcp6_proxy_node.c +++ b/src/plugins/dhcp/dhcp6_proxy_node.c @@ -108,7 +108,7 @@ ip6_interface_first_global_or_site_address (ip6_main_t * im, u32 sw_if_index) foreach_ip_interface_address (lm, ia, sw_if_index, 1 /* honor unnumbered */, ({ - ip6_address_t * a = ip_interface_address_get_address (lm, ia); + ip6_address_t *a = (ip6_address_t *) ip_interface_address_get_address (lm, ia); if ((a->as_u8[0] & 0xe0) == 0x20 || (a->as_u8[0] & 0xfe) == 0xfc) { result = a; diff --git a/src/plugins/dhcp/dhcp_proxy.c b/src/plugins/dhcp/dhcp_proxy.c index 1890c874b614..87342f044627 100644 --- a/src/plugins/dhcp/dhcp_proxy.c +++ b/src/plugins/dhcp/dhcp_proxy.c @@ -188,7 +188,7 @@ dhcp_proxy_server_add (fib_protocol_t proto, { dhcp_proxy_main_t *dpm = &dhcp_proxy_main; dhcp_proxy_t *proxy = 0; - int new = 0; + int _new = 0; proxy = dhcp_get_proxy (dpm, rx_fib_index, proto); @@ -199,7 +199,7 @@ dhcp_proxy_server_add (fib_protocol_t proto, pool_get (dpm->dhcp_servers[proto], proxy); clib_memset (proxy, 0, sizeof (*proxy)); - new = 1; + _new = 1; dpm->dhcp_server_index_by_rx_fib_index[proto][rx_fib_index] = proxy - dpm->dhcp_servers[proto]; @@ -211,7 +211,7 @@ dhcp_proxy_server_add (fib_protocol_t proto, { if (~0 != dhcp_proxy_server_find (proxy, proto, addr, server_table_id)) { - return (new); + return (_new); } } @@ -224,7 +224,7 @@ dhcp_proxy_server_add (fib_protocol_t proto, vec_add1 (proxy->dhcp_servers, server); - return (new); + return (_new); } typedef struct dhcp4_proxy_dump_walk_ctx_t_ diff --git a/src/plugins/dma_intel/dsa_intel.h b/src/plugins/dma_intel/dsa_intel.h index a52d4bff323f..d74fb000d675 100644 --- a/src/plugins/dma_intel/dsa_intel.h +++ b/src/plugins/dma_intel/dsa_intel.h @@ -146,15 +146,15 @@ extern vlib_dma_backend_t intel_dsa_backend; format_function_t format_intel_dsa_addr; #define dsa_log_debug(f, ...) \ - vlib_log (VLIB_LOG_LEVEL_DEBUG, intel_dsa_log.class, "%s: " f, __func__, \ + vlib_log (VLIB_LOG_LEVEL_DEBUG, intel_dsa_log._class, "%s: " f, __func__, \ ##__VA_ARGS__) #define dsa_log_info(f, ...) \ - vlib_log (VLIB_LOG_LEVEL_INFO, intel_dsa_log.class, "%s: " f, __func__, \ + vlib_log (VLIB_LOG_LEVEL_INFO, intel_dsa_log._class, "%s: " f, __func__, \ ##__VA_ARGS__) #define dsa_log_error(f, ...) \ - vlib_log (VLIB_LOG_LEVEL_ERR, intel_dsa_log.class, "%s: " f, __func__, \ + vlib_log (VLIB_LOG_LEVEL_ERR, intel_dsa_log._class, "%s: " f, __func__, \ ##__VA_ARGS__) #endif diff --git a/src/plugins/dns/dns.c b/src/plugins/dns/dns.c index de01474703b9..38a493c19f60 100644 --- a/src/plugins/dns/dns.c +++ b/src/plugins/dns/dns.c @@ -491,14 +491,14 @@ vnet_send_dns_request (vlib_main_t * vm, dns_main_t * dm, qp = (dns_query_t *) (request + qp_offset); qp->type = clib_host_to_net_u16 (DNS_TYPE_A); - qp->class = clib_host_to_net_u16 (DNS_CLASS_IN); + qp->_class = clib_host_to_net_u16 (DNS_CLASS_IN); qp++; clib_memcpy (qp, name_copy, vec_len (name_copy)); qp = (dns_query_t *) (((u8 *) qp) + vec_len (name_copy)); vec_free (name_copy); qp->type = clib_host_to_net_u16 (DNS_TYPE_AAAA); - qp->class = clib_host_to_net_u16 (DNS_CLASS_IN); + qp->_class = clib_host_to_net_u16 (DNS_CLASS_IN); /* Punch in space for the dns_header_t */ vec_insert (request, sizeof (dns_header_t), 0); @@ -1039,13 +1039,13 @@ vnet_dns_cname_indirection_nolock (vlib_main_t * vm, dns_main_t * dm, qp = (dns_query_t *) (request + qp_offset); qp->type = clib_host_to_net_u16 (DNS_TYPE_A); - qp->class = clib_host_to_net_u16 (DNS_CLASS_IN); + qp->_class = clib_host_to_net_u16 (DNS_CLASS_IN); clib_memcpy (qp, name_copy, vec_len (name_copy)); qp = (dns_query_t *) (((u8 *) qp) + vec_len (name_copy)); vec_free (name_copy); qp->type = clib_host_to_net_u16 (DNS_TYPE_AAAA); - qp->class = clib_host_to_net_u16 (DNS_CLASS_IN); + qp->_class = clib_host_to_net_u16 (DNS_CLASS_IN); /* Punch in space for the dns_header_t */ vec_insert (request, sizeof (dns_header_t), 0); @@ -1555,7 +1555,7 @@ unformat_dns_reply (unformat_input_t * input, va_list * args) qp = (dns_query_t *) (ce + qp_offset); qp->type = clib_host_to_net_u16 (DNS_TYPE_ALL); - qp->class = clib_host_to_net_u16 (DNS_CLASS_IN); + qp->_class = clib_host_to_net_u16 (DNS_CLASS_IN); /* Punch in space for the dns_header_t */ vec_insert (ce, sizeof (dns_header_t), 0); @@ -1580,7 +1580,7 @@ unformat_dns_reply (unformat_input_t * input, va_list * args) vec_add2 (ce, rru8, sizeof (*rr) + 4); rr = (void *) rru8; rr->type = clib_host_to_net_u16 (DNS_TYPE_A); - rr->class = clib_host_to_net_u16 (DNS_CLASS_IN); + rr->_class = clib_host_to_net_u16 (DNS_CLASS_IN); rr->ttl = clib_host_to_net_u32 (86400); rr->rdlength = clib_host_to_net_u16 (4); memcpy (rr->rdata, &a4, sizeof (a4)); @@ -1593,7 +1593,7 @@ unformat_dns_reply (unformat_input_t * input, va_list * args) vec_add2 (ce, rru8, sizeof (*rr) + 16); rr = (void *) rru8; rr->type = clib_host_to_net_u16 (DNS_TYPE_AAAA); - rr->class = clib_host_to_net_u16 (DNS_CLASS_IN); + rr->_class = clib_host_to_net_u16 (DNS_CLASS_IN); rr->ttl = clib_host_to_net_u32 (86400); rr->rdlength = clib_host_to_net_u16 (16); memcpy (rr->rdata, &a6, sizeof (a6)); @@ -2839,7 +2839,7 @@ vnet_send_dns4_reply (vlib_main_t * vm, dns_main_t * dm, else qp->type = clib_host_to_net_u16 (DNS_TYPE_PTR); - qp->class = clib_host_to_net_u16 (DNS_CLASS_IN); + qp->_class = clib_host_to_net_u16 (DNS_CLASS_IN); /* Punch in space for the dns_header_t */ vec_insert (reply, sizeof (dns_header_t), 0); @@ -2873,7 +2873,7 @@ vnet_send_dns4_reply (vlib_main_t * vm, dns_main_t * dm, rr = (dns_rr_t *) rrptr; rr->type = clib_host_to_net_u16 (DNS_TYPE_A); - rr->class = clib_host_to_net_u16 (1 /* internet */ ); + rr->_class = clib_host_to_net_u16 (1 /* internet */ ); rr->ttl = clib_host_to_net_u32 (ttl); rr->rdlength = clib_host_to_net_u16 (sizeof (ip4_address_t)); ip_address_copy_addr (rr->rdata, &rn->address); @@ -2888,7 +2888,7 @@ vnet_send_dns4_reply (vlib_main_t * vm, dns_main_t * dm, vec_add2 (reply, rrptr, sizeof (dns_rr_t) + vec_len (label_vec)); rr = (dns_rr_t *) rrptr; rr->type = clib_host_to_net_u16 (DNS_TYPE_PTR); - rr->class = clib_host_to_net_u16 (1 /* internet */ ); + rr->_class = clib_host_to_net_u16 (1 /* internet */ ); rr->ttl = clib_host_to_net_u32 (ttl); rr->rdlength = clib_host_to_net_u16 (vec_len (label_vec)); clib_memcpy (rr->rdata, label_vec, vec_len (label_vec)); diff --git a/src/plugins/dns/dns_packet.h b/src/plugins/dns/dns_packet.h index 13daf7849dec..a8f821926b4d 100644 --- a/src/plugins/dns/dns_packet.h +++ b/src/plugins/dns/dns_packet.h @@ -99,7 +99,7 @@ typedef CLIB_PACKED (struct { */ typedef CLIB_PACKED (struct { u16 type; /**< record type requested */ - u16 class; /**< class, 1 = internet */ + u16 _class; /**< class, 1 = internet */ }) dns_query_t; /** @@ -107,7 +107,7 @@ typedef CLIB_PACKED (struct { */ typedef CLIB_PACKED (struct { u16 type; /**< record type */ - u16 class; /**< class, 1 = internet */ + u16 _class; /**< class, 1 = internet */ u32 ttl; /**< time to live, in seconds */ u16 rdlength; /**< length of r */ diff --git a/src/plugins/dpdk/buffer.c b/src/plugins/dpdk/buffer.c index f3137a996d66..08eb2f93cd75 100644 --- a/src/plugins/dpdk/buffer.c +++ b/src/plugins/dpdk/buffer.c @@ -135,7 +135,7 @@ dpdk_buffer_pool_init (vlib_main_t * vm, vlib_buffer_pool_t * bp) { vlib_buffer_t *b; b = vlib_buffer_ptr_from_index (buffer_mem_start, bp->buffers[i], 0); - b->template = bp->buffer_template; + b->_template = bp->buffer_template; } /* map DMA pages if at least one physical device exists */ @@ -205,7 +205,7 @@ dpdk_ops_vpp_enqueue_one (vlib_buffer_template_t *bt, void *obj) vlib_buffer_t *b = vlib_buffer_from_rte_mbuf (mb); ASSERT (b->ref_count == 1); ASSERT (b->buffer_pool_index == bt->buffer_pool_index); - b->template = *bt; + b->_template = *bt; } int @@ -264,7 +264,7 @@ CLIB_MARCH_FN_REGISTRATION (dpdk_ops_vpp_enqueue); static_always_inline void dpdk_ops_vpp_enqueue_no_cache_one (vlib_main_t *vm, struct rte_mempool *old, - struct rte_mempool *new, void *obj, + struct rte_mempool *_new, void *obj, vlib_buffer_template_t *bt) { struct rte_mbuf *mb = obj; @@ -273,7 +273,7 @@ dpdk_ops_vpp_enqueue_no_cache_one (vlib_main_t *vm, struct rte_mempool *old, if (clib_atomic_sub_fetch (&b->ref_count, 1) == 0) { u32 bi = vlib_get_buffer_index (vm, b); - b->template = *bt; + b->_template = *bt; vlib_buffer_pool_put (vm, bt->buffer_pool_index, &bi, 1); return; } diff --git a/src/plugins/hs_apps/http_cli.c b/src/plugins/hs_apps/http_cli.c index 531e2750c1e1..84e79ecde33d 100644 --- a/src/plugins/hs_apps/http_cli.c +++ b/src/plugins/hs_apps/http_cli.c @@ -656,7 +656,7 @@ hcs_listen () { hcs_uri_map_t *map; pool_get_zero (hcm->uri_map_pool, map); - map->uri = vec_dup (uri); + map->uri = (u8 *) vec_dup (uri); map->handle = a->handle; hash_set_mem (hcm->index_by_uri, map->uri, map - hcm->uri_map_pool); } diff --git a/src/plugins/hs_apps/vcl/vcl_test.h b/src/plugins/hs_apps/vcl/vcl_test.h index 11667fb144a8..8f2026849720 100644 --- a/src/plugins/hs_apps/vcl/vcl_test.h +++ b/src/plugins/hs_apps/vcl/vcl_test.h @@ -257,18 +257,18 @@ vcl_test_stats_dump (char *header, vcl_test_stats_t * stats, } static inline double -vcl_test_time_diff (struct timespec *old, struct timespec *new) +vcl_test_time_diff (struct timespec *old, struct timespec *_new) { uint64_t sec, nsec; - if ((new->tv_nsec - old->tv_nsec) < 0) + if ((_new->tv_nsec - old->tv_nsec) < 0) { - sec = new->tv_sec - old->tv_sec - 1; - nsec = new->tv_nsec - old->tv_nsec + 1e9; + sec = _new->tv_sec - old->tv_sec - 1; + nsec = _new->tv_nsec - old->tv_nsec + 1e9; } else { - sec = new->tv_sec - old->tv_sec; - nsec = new->tv_nsec - old->tv_nsec; + sec = _new->tv_sec - old->tv_sec; + nsec = _new->tv_nsec - old->tv_nsec; } return (double) sec + (1e-9 * nsec); } @@ -276,23 +276,23 @@ vcl_test_time_diff (struct timespec *old, struct timespec *new) static inline void vcl_test_stats_dump_inc (vcl_test_session_t *ts, int is_rx) { - vcl_test_stats_t *old, *new; + vcl_test_stats_t *old, *_new; double duration, rate; uint64_t total_bytes; char *dir_str; old = &ts->old_stats; - new = &ts->stats; - duration = vcl_test_time_diff (&old->stop, &new->stop); + _new = &ts->stats; + duration = vcl_test_time_diff (&old->stop, &_new->stop); if (is_rx) { - total_bytes = new->rx_bytes - old->rx_bytes; + total_bytes = _new->rx_bytes - old->rx_bytes; dir_str = "Received"; } else { - total_bytes = new->tx_bytes - old->tx_bytes; + total_bytes = _new->tx_bytes - old->tx_bytes; dir_str = "Sent"; } diff --git a/src/plugins/idpf/idpf.h b/src/plugins/idpf/idpf.h index 0bac575d4b42..03cd74fb37ca 100644 --- a/src/plugins/idpf/idpf.h +++ b/src/plugins/idpf/idpf.h @@ -174,19 +174,19 @@ extern vlib_log_class_registration_t idpf_log; extern vlib_log_class_registration_t idpf_stats_log; #define idpf_log_err(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_ERR, idpf_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_ERR, idpf_log._class, "%U: " f, \ format_vlib_pci_addr, &dev->pci_addr, ##__VA_ARGS__) #define idpf_log_warn(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_WARNING, idpf_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_WARNING, idpf_log._class, "%U: " f, \ format_vlib_pci_addr, &dev->pci_addr, ##__VA_ARGS__) #define idpf_log_debug(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_DEBUG, idpf_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_DEBUG, idpf_log._class, "%U: " f, \ format_vlib_pci_addr, &dev->pci_addr, ##__VA_ARGS__) #define idpf_stats_log_debug(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_DEBUG, idpf_stats_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_DEBUG, idpf_stats_log._class, "%U: " f, \ format_vlib_pci_addr, &dev->pci_addr, ##__VA_ARGS__) /* List handler */ diff --git a/src/plugins/ioam/lib-pot/pot_util.c b/src/plugins/ioam/lib-pot/pot_util.c index 2fe9ce97f4e1..37d425638959 100644 --- a/src/plugins/ioam/lib-pot/pot_util.c +++ b/src/plugins/ioam/lib-pot/pot_util.c @@ -46,12 +46,12 @@ int pot_util_init (void) return(0); } -static void pot_profile_init(pot_profile * new, u8 id) +static void pot_profile_init(pot_profile * _new, u8 id) { - if (new) + if (_new) { - clib_memset(new, 0, sizeof(pot_profile)); - new->id = id; + clib_memset(_new, 0, sizeof(pot_profile)); + _new->id = id; } } diff --git a/src/plugins/ip_session_redirect/redirect.c b/src/plugins/ip_session_redirect/redirect.c index ea18182e3099..64814719f92d 100644 --- a/src/plugins/ip_session_redirect/redirect.c +++ b/src/plugins/ip_session_redirect/redirect.c @@ -70,7 +70,7 @@ ip_session_redirect_find (ip_session_redirect_main_t *im, u32 table_index, /* we are adding the table index at the end of the match string so we * can disambiguiate identical matches in different tables in * im->session_by_match_and_table_index */ - u8 *match_and_table_index = vec_dup (match); + const u8 *match_and_table_index = vec_dup (match); vec_add (match_and_table_index, (void *) &table_index, 4); uword *p = hash_get_mem (im->session_by_match_and_table_index, match_and_table_index); diff --git a/src/plugins/linux-cp/lcp_router.c b/src/plugins/linux-cp/lcp_router.c index 0efd53e64ef8..c57e59472644 100644 --- a/src/plugins/linux-cp/lcp_router.c +++ b/src/plugins/linux-cp/lcp_router.c @@ -1299,18 +1299,18 @@ lcp_router_fib_route_path_dup (fib_route_path_t *old) int idx; fib_route_path_t *p; - fib_route_path_t *new = vec_dup (old); - if (!new) + fib_route_path_t *_new = vec_dup (old); + if (!_new) return NULL; - for (idx = 0; idx < vec_len (new); idx++) + for (idx = 0; idx < vec_len (_new); idx++) { - p = &new[idx]; + p = &_new[idx]; if (p->frp_label_stack) p->frp_label_stack = vec_dup (p->frp_label_stack); } - return new; + return _new; } static void diff --git a/src/plugins/lisp/lisp-cp/control.c b/src/plugins/lisp/lisp-cp/control.c index 692048ebd218..2ae55dd71fb2 100644 --- a/src/plugins/lisp/lisp-cp/control.c +++ b/src/plugins/lisp/lisp-cp/control.c @@ -2612,10 +2612,10 @@ add_locators (lisp_cp_main_t * lcm, mapping_t * m, u32 locator_set_index, ip_address_t * probed_loc) { u32 *li; - locator_t *loc, new; + locator_t *loc, _new; ip_interface_address_t *ia = 0; void *addr; - ip_address_t *new_ip = &gid_address_ip (&new.address); + ip_address_t *new_ip = &gid_address_ip (&_new.address); m->locators = 0; locator_set_t *ls = pool_elt_at_index (lcm->locator_set_pool, @@ -2623,7 +2623,7 @@ add_locators (lisp_cp_main_t * lcm, mapping_t * m, u32 locator_set_index, vec_foreach (li, ls->locator_indices) { loc = pool_elt_at_index (lcm->locator_pool, li[0]); - new = loc[0]; + _new = loc[0]; if (loc->local) { foreach_ip_interface_address (&lcm->im4->lookup_main, ia, @@ -2644,9 +2644,9 @@ add_locators (lisp_cp_main_t * lcm, mapping_t * m, u32 locator_set_index, })); if (probed_loc && ip_address_cmp (probed_loc, new_ip) == 0) - new.probed = 1; + _new.probed = 1; } - vec_add1 (m->locators, new); + vec_add1 (m->locators, _new); } } diff --git a/src/plugins/memif/memif.c b/src/plugins/memif/memif.c index 7e3dd44db2cb..912f90f45267 100644 --- a/src/plugins/memif/memif.c +++ b/src/plugins/memif/memif.c @@ -249,7 +249,7 @@ memif_connect (memif_if_t * mif) memif_main_t *mm = &memif_main; vlib_main_t *vm = vlib_get_main (); vnet_main_t *vnm = vnet_get_main (); - clib_file_t template = { 0 }; + clib_file_t _template = { 0 }; memif_region_t *mr; int i, j; u32 n_txqs = 0, n_threads = vlib_get_n_threads (); @@ -281,8 +281,8 @@ memif_connect (memif_if_t * mif) } } - template.read_function = memif_int_fd_read_ready; - template.write_function = memif_int_fd_write_ready; + _template.read_function = memif_int_fd_read_ready; + _template.write_function = memif_int_fd_write_ready; with_barrier = 1; if (vlib_worker_thread_barrier_held ()) @@ -399,12 +399,12 @@ memif_connect (memif_if_t * mif) if (mq->int_fd > -1) { - template.file_descriptor = mq->int_fd; - template.private_data = (mif->dev_instance << 16) | (i & 0xFFFF); - template.description = format (0, "%U rx %u int", + _template.file_descriptor = mq->int_fd; + _template.private_data = (mif->dev_instance << 16) | (i & 0xFFFF); + _template.description = format (0, "%U rx %u int", format_memif_device_name, mif->dev_instance, i); - memif_file_add (&mq->int_clib_file_index, &template); + memif_file_add (&mq->int_clib_file_index, &_template); vnet_hw_if_set_rx_queue_file_index (vnm, qi, mq->int_clib_file_index); } @@ -1137,12 +1137,12 @@ memif_create_if (vlib_main_t *vm, memif_create_if_args_t *args) goto error; } - clib_file_t template = { 0 }; - template.read_function = memif_conn_fd_accept_ready; - template.file_descriptor = msf->sock->fd; - template.private_data = mif->socket_file_index; - template.description = format (0, "memif listener %s", msf->filename); - memif_file_add (&msf->sock->private_data, &template); + clib_file_t _template = { 0 }; + _template.read_function = memif_conn_fd_accept_ready; + _template.file_descriptor = msf->sock->fd; + _template.private_data = mif->socket_file_index; + _template.description = format (0, "memif listener %s", msf->filename); + memif_file_add (&msf->sock->private_data, &_template); } msf->ref_cnt++; diff --git a/src/plugins/memif/socket.c b/src/plugins/memif/socket.c index 001f26f13efa..0b2b632f45d0 100644 --- a/src/plugins/memif/socket.c +++ b/src/plugins/memif/socket.c @@ -657,7 +657,7 @@ memif_conn_fd_accept_ready (clib_file_t * uf) memif_main_t *mm = &memif_main; memif_socket_file_t *msf = pool_elt_at_index (mm->socket_files, uf->private_data); - clib_file_t template = { 0 }; + clib_file_t _template = { 0 }; clib_error_t *err; clib_socket_t *client; @@ -667,14 +667,14 @@ memif_conn_fd_accept_ready (clib_file_t * uf) if (err) goto error; - template.read_function = memif_master_conn_fd_read_ready; - template.write_function = memif_master_conn_fd_write_ready; - template.error_function = memif_master_conn_fd_error; - template.file_descriptor = client->fd; - template.private_data = uf->private_data; - template.description = format (0, "memif in conn on %s", msf->filename); + _template.read_function = memif_master_conn_fd_read_ready; + _template.write_function = memif_master_conn_fd_write_ready; + _template.error_function = memif_master_conn_fd_error; + _template.file_descriptor = client->fd; + _template.private_data = uf->private_data; + _template.description = format (0, "memif in conn on %s", msf->filename); - memif_file_add (&client->private_data, &template); + memif_file_add (&client->private_data, &_template); err = memif_msg_enq_hello (client); if (err) diff --git a/src/plugins/netmap/netmap.c b/src/plugins/netmap/netmap.c index ebef215eb3bc..7818be942bdf 100644 --- a/src/plugins/netmap/netmap.c +++ b/src/plugins/netmap/netmap.c @@ -212,12 +212,12 @@ netmap_create_if (vlib_main_t * vm, u8 * if_name, u8 * hw_addr_set, clib_spinlock_init (&nif->lockp); { - clib_file_t template = { 0 }; - template.read_function = netmap_fd_read_ready; - template.file_descriptor = nif->fd; - template.private_data = nif->if_index; - template.description = format (0, "netmap socket"); - nif->clib_file_index = clib_file_add (&file_main, &template); + clib_file_t _template = { 0 }; + _template.read_function = netmap_fd_read_ready; + _template.file_descriptor = nif->fd; + _template.private_data = nif->if_index; + _template.description = format (0, "netmap socket"); + nif->clib_file_index = clib_file_add (&file_main, &_template); } /*use configured or generate random MAC address */ diff --git a/src/plugins/nsh/nsh-md2-ioam/nsh_md2_ioam_trace.c b/src/plugins/nsh/nsh-md2-ioam/nsh_md2_ioam_trace.c index 2c553b39e45a..77e3955d9129 100644 --- a/src/plugins/nsh/nsh-md2-ioam/nsh_md2_ioam_trace.c +++ b/src/plugins/nsh/nsh-md2-ioam/nsh_md2_ioam_trace.c @@ -39,7 +39,7 @@ typedef union typedef CLIB_PACKED(struct { - u16 class; + u16 _class; u8 type; u8 length; u8 data_list_elts_left; @@ -171,7 +171,7 @@ nsh_md2_ioam_trace_rewrite_handler (u8 * rewrite_string, u8 * rewrite_size) trace_data_size = fetch_trace_data_size (profile->trace_type); trace_option = (nsh_md2_ioam_trace_option_t *) rewrite_string; - trace_option->class = clib_host_to_net_u16 (0x9); + trace_option->_class = clib_host_to_net_u16 (0x9); trace_option->type = NSH_MD2_IOAM_OPTION_TYPE_TRACE; trace_option->length = (trace_option_elts * trace_data_size) + 4; trace_option->data_list_elts_left = trace_option_elts; diff --git a/src/plugins/nsh/nsh-md2-ioam/nsh_md2_ioam_util.h b/src/plugins/nsh/nsh-md2-ioam/nsh_md2_ioam_util.h index cdb06dab9964..ecf0de078f9e 100644 --- a/src/plugins/nsh/nsh-md2-ioam/nsh_md2_ioam_util.h +++ b/src/plugins/nsh/nsh-md2-ioam/nsh_md2_ioam_util.h @@ -22,7 +22,7 @@ #include -extern nsh_option_map_t *nsh_md2_lookup_option (u16 class, u8 type); +extern nsh_option_map_t *nsh_md2_lookup_option (u16 _class, u8 type); typedef struct @@ -84,7 +84,7 @@ nsh_md2_ioam_encap_decap_ioam_v4_one_inline (vlib_main_t * vm, case 1: /* PadN */ break; default: - nsh_option = nsh_md2_lookup_option (opt0->class, opt0->type); + nsh_option = nsh_md2_lookup_option (opt0->_class, opt0->type); if ((nsh_option != NULL) && (hm->options[nsh_option->option_id])) { if ((*hm->options[nsh_option->option_id]) (b0, opt0) < 0) diff --git a/src/plugins/nsh/nsh.c b/src/plugins/nsh/nsh.c index a2c24e27b26e..b8113b3b98a7 100644 --- a/src/plugins/nsh/nsh.c +++ b/src/plugins/nsh/nsh.c @@ -29,7 +29,7 @@ nsh_main_t nsh_main; /* Uses network order's class and type to register */ int -nsh_md2_register_option (u16 class, +nsh_md2_register_option (u16 _class, u8 type, u8 option_size, int add_options (u8 * opt, @@ -48,7 +48,7 @@ nsh_md2_register_option (u16 class, uword *p; nsh_option_map_t *nsh_option; - key.class = class; + key._class = _class; key.type = type; key.pad = 0; @@ -85,13 +85,13 @@ nsh_md2_register_option (u16 class, /* Uses network order's class and type to lookup */ nsh_option_map_t * -nsh_md2_lookup_option (u16 class, u8 type) +nsh_md2_lookup_option (u16 _class, u8 type) { nsh_main_t *nm = &nsh_main; nsh_option_map_by_key_t key; uword *p; - key.class = class; + key._class = _class; key.type = type; key.pad = 0; @@ -108,7 +108,7 @@ nsh_md2_lookup_option (u16 class, u8 type) /* Uses network order's class and type to unregister */ int -nsh_md2_unregister_option (u16 class, +nsh_md2_unregister_option (u16 _class, u8 type, int options (vlib_buffer_t * b, nsh_tlv_header_t * opt), @@ -120,7 +120,7 @@ nsh_md2_unregister_option (u16 class, hash_pair_t *hp; nsh_option_map_t *nsh_option; - key.class = class; + key._class = _class; key.type = type; key.pad = 0; diff --git a/src/plugins/nsh/nsh.h b/src/plugins/nsh/nsh.h index 86a9a7e95c3b..baaf79461768 100644 --- a/src/plugins/nsh/nsh.h +++ b/src/plugins/nsh/nsh.h @@ -20,7 +20,7 @@ #include typedef struct { - u16 class; + u16 _class; u8 type; u8 pad; } nsh_option_map_by_key_t; @@ -251,7 +251,7 @@ typedef enum { #define MAX_NSH_OPTION_LEN 128 int -nsh_md2_register_option (u16 class, +nsh_md2_register_option (u16 _class, u8 type, u8 option_size, int add_options (u8 * opt, @@ -278,7 +278,7 @@ int nsh_add_del_proxy_session (nsh_add_del_map_args_t * a); nsh_option_map_t * -nsh_md2_lookup_option (u16 class, u8 type); +nsh_md2_lookup_option (u16 _class, u8 type); int nsh_add_del_entry (nsh_add_del_entry_args_t * a, u32 * entry_indexp); diff --git a/src/plugins/nsh/nsh_api.c b/src/plugins/nsh/nsh_api.c index c7a686c8b83b..f60117aaaebe 100644 --- a/src/plugins/nsh/nsh_api.c +++ b/src/plugins/nsh/nsh_api.c @@ -252,7 +252,7 @@ nsh_header_rewrite (nsh_entry_t * nsh_entry) /* round to 4-byte */ old_option_size = ((old_option_size + 3) >> 2) << 2; - nsh_option = nsh_md2_lookup_option (opt0->class, opt0->type); + nsh_option = nsh_md2_lookup_option (opt0->_class, opt0->type); if (nsh_option == NULL) { goto next_tlv_md2; diff --git a/src/plugins/nsh/nsh_cli.c b/src/plugins/nsh/nsh_cli.c index 4288a9654c59..9b4d7c0aa547 100644 --- a/src/plugins/nsh/nsh_cli.c +++ b/src/plugins/nsh/nsh_cli.c @@ -439,11 +439,11 @@ nsh_add_del_entry_command_fn (vlib_main_t * vm, if (has_ioam_trace_option) { - tlv_header.class = clib_host_to_net_u16 (NSH_MD2_IOAM_CLASS); + tlv_header._class = clib_host_to_net_u16 (NSH_MD2_IOAM_CLASS); tlv_header.type = NSH_MD2_IOAM_OPTION_TYPE_TRACE; /* Uses network order's class and type to lookup */ nsh_option = - nsh_md2_lookup_option (tlv_header.class, tlv_header.type); + nsh_md2_lookup_option (tlv_header._class, tlv_header.type); if (nsh_option == NULL) return clib_error_return (0, "iOAM Trace not registered"); @@ -550,7 +550,7 @@ format_nsh_header (u8 * s, va_list * args) /* Scan the set of variable metadata, network order */ while (opt0 < limit0) { - nsh_option = nsh_md2_lookup_option (opt0->class, opt0->type); + nsh_option = nsh_md2_lookup_option (opt0->_class, opt0->type); if (nsh_option != NULL) { if (nm->trace[nsh_option->option_id] != NULL) diff --git a/src/plugins/nsh/nsh_node.c b/src/plugins/nsh/nsh_node.c index 5c084985948b..d95d76894260 100644 --- a/src/plugins/nsh/nsh_node.c +++ b/src/plugins/nsh/nsh_node.c @@ -47,7 +47,7 @@ nsh_md2_encap (vlib_buffer_t * b, nsh_base_header_t * hdr, /* round to 4-byte */ old_option_size = ((old_option_size + 3) >> 2) << 2; - nsh_option = nsh_md2_lookup_option (opt0->class, opt0->type); + nsh_option = nsh_md2_lookup_option (opt0->_class, opt0->type); if (nsh_option == NULL) { goto next_tlv_md2; @@ -114,7 +114,7 @@ nsh_md2_swap (vlib_buffer_t * b, /* round to 4-byte */ old_option_size = ((old_option_size + 3) >> 2) << 2; - nsh_option = nsh_md2_lookup_option (opt0->class, opt0->type); + nsh_option = nsh_md2_lookup_option (opt0->_class, opt0->type); if (nsh_option == NULL) { goto next_tlv_md2; @@ -169,7 +169,7 @@ nsh_md2_decap (vlib_buffer_t * b, /* Scan the set of variable metadata, process ones that we understand */ while (opt0 < limit0) { - nsh_option = nsh_md2_lookup_option (opt0->class, opt0->type); + nsh_option = nsh_md2_lookup_option (opt0->_class, opt0->type); if (nsh_option == NULL) { *next = drop_node_val; diff --git a/src/plugins/nsh/nsh_packet.h b/src/plugins/nsh/nsh_packet.h index 9d6237af551f..5a6e95a06c0a 100644 --- a/src/plugins/nsh/nsh_packet.h +++ b/src/plugins/nsh/nsh_packet.h @@ -85,7 +85,7 @@ typedef CLIB_PACKED(struct { }) nsh_md1_data_t; typedef CLIB_PACKED(struct { - u16 class; + u16 _class; u8 type; u8 length; }) nsh_tlv_header_t; diff --git a/src/plugins/nsh/nsh_pop.c b/src/plugins/nsh/nsh_pop.c index 8de319e158b9..790f811503fb 100644 --- a/src/plugins/nsh/nsh_pop.c +++ b/src/plugins/nsh/nsh_pop.c @@ -25,7 +25,7 @@ #include #include -extern nsh_option_map_t * nsh_md2_lookup_option (u16 class, u8 type); +extern nsh_option_map_t * nsh_md2_lookup_option (u16 _class, u8 type); extern u8 * format_nsh_header (u8 * s, va_list * args); extern u8 * format_nsh_node_map_trace (u8 * s, va_list * args); diff --git a/src/plugins/perfmon/arm/events.c b/src/plugins/perfmon/arm/events.c index f2406b3ea05a..274f6c72f173 100644 --- a/src/plugins/perfmon/arm/events.c +++ b/src/plugins/perfmon/arm/events.c @@ -26,10 +26,10 @@ VLIB_REGISTER_LOG_CLASS (if_default_log, static) = { }; #define log_debug(fmt, ...) \ - vlib_log_debug (if_default_log.class, fmt, __VA_ARGS__) + vlib_log_debug (if_default_log._class, fmt, __VA_ARGS__) #define log_warn(fmt, ...) \ - vlib_log_warn (if_default_log.class, fmt, __VA_ARGS__) -#define log_err(fmt, ...) vlib_log_err (if_default_log.class, fmt, __VA_ARGS__) + vlib_log_warn (if_default_log._class, fmt, __VA_ARGS__) +#define log_err(fmt, ...) vlib_log_err (if_default_log._class, fmt, __VA_ARGS__) /* * config1 = 2 : user access enabled and always 32-bit diff --git a/src/plugins/perfmon/intel/uncore.c b/src/plugins/perfmon/intel/uncore.c index 316ebb13571a..fd5afc8d3e30 100644 --- a/src/plugins/perfmon/intel/uncore.c +++ b/src/plugins/perfmon/intel/uncore.c @@ -27,11 +27,11 @@ VLIB_REGISTER_LOG_CLASS (if_intel_uncore_log, static) = { }; #define log_debug(fmt, ...) \ - vlib_log_debug (if_intel_uncore_log.class, fmt, __VA_ARGS__) + vlib_log_debug (if_intel_uncore_log._class, fmt, __VA_ARGS__) #define log_warn(fmt, ...) \ - vlib_log_warn (if_intel_uncore_log.class, fmt, __VA_ARGS__) + vlib_log_warn (if_intel_uncore_log._class, fmt, __VA_ARGS__) #define log_err(fmt, ...) \ - vlib_log_err (if_intel_uncore_log.class, fmt, __VA_ARGS__) + vlib_log_err (if_intel_uncore_log._class, fmt, __VA_ARGS__) #define PERF_INTEL_CODE(event, umask, edge, any, inv, cmask) \ ((event) | (umask) << 8 | (edge) << 18 | (any) << 21 | (inv) << 23 | \ diff --git a/src/plugins/perfmon/perfmon.c b/src/plugins/perfmon/perfmon.c index e618f9b314ae..f49491cf7152 100644 --- a/src/plugins/perfmon/perfmon.c +++ b/src/plugins/perfmon/perfmon.c @@ -36,10 +36,10 @@ VLIB_REGISTER_LOG_CLASS (if_default_log, static) = { }; #define log_debug(fmt, ...) \ - vlib_log_debug (if_default_log.class, fmt, __VA_ARGS__) + vlib_log_debug (if_default_log._class, fmt, __VA_ARGS__) #define log_warn(fmt, ...) \ - vlib_log_warn (if_default_log.class, fmt, __VA_ARGS__) -#define log_err(fmt, ...) vlib_log_err (if_default_log.class, fmt, __VA_ARGS__) + vlib_log_warn (if_default_log._class, fmt, __VA_ARGS__) +#define log_err(fmt, ...) vlib_log_err (if_default_log._class, fmt, __VA_ARGS__) void perfmon_reset (vlib_main_t *vm) diff --git a/src/plugins/pppoe/pppoe.h b/src/plugins/pppoe/pppoe.h index 444de42f4a55..e80966207365 100644 --- a/src/plugins/pppoe/pppoe.h +++ b/src/plugins/pppoe/pppoe.h @@ -249,7 +249,7 @@ pppoe_learn_process (BVT (clib_bihash) * table, */ return; } - else if (result0->fields.sw_if_index == ~0) + else if (result0->fields.sw_if_index == ~0U) { /* The entry was not in table, so add it */ result0->fields.sw_if_index = sw_if_index0; diff --git a/src/plugins/rdma/device.c b/src/plugins/rdma/device.c index 8aeb586a42d6..233e5f721747 100644 --- a/src/plugins/rdma/device.c +++ b/src/plugins/rdma/device.c @@ -170,11 +170,11 @@ rdma_dev_set_ucast (rdma_device_t * rd) } static clib_error_t * -rdma_mac_change (vnet_hw_interface_t * hw, const u8 * old, const u8 * new) +rdma_mac_change (vnet_hw_interface_t * hw, const u8 * old, const u8 * _new) { rdma_main_t *rm = &rdma_main; rdma_device_t *rd = vec_elt_at_index (rm->devices, hw->dev_instance); - mac_address_from_bytes (&rd->hwaddr, new); + mac_address_from_bytes (&rd->hwaddr, _new); if (!(rd->flags & RDMA_DEVICE_F_PROMISC) && rdma_dev_set_ucast (rd)) { mac_address_from_bytes (&rd->hwaddr, old); diff --git a/src/plugins/snort/main.c b/src/plugins/snort/main.c index 9bab1185b602..b9d4133b75cb 100644 --- a/src/plugins/snort/main.c +++ b/src/plugins/snort/main.c @@ -30,8 +30,8 @@ VLIB_REGISTER_LOG_CLASS (snort_log, static) = { .class_name = "snort", }; -#define log_debug(fmt, ...) vlib_log_debug (snort_log.class, fmt, __VA_ARGS__) -#define log_err(fmt, ...) vlib_log_err (snort_log.class, fmt, __VA_ARGS__) +#define log_debug(fmt, ...) vlib_log_debug (snort_log._class, fmt, __VA_ARGS__) +#define log_err(fmt, ...) vlib_log_err (snort_log._class, fmt, __VA_ARGS__) snort_main_t * snort_get_main () @@ -521,7 +521,7 @@ snort_vnet_feature_enable_disable (snort_attach_dir_t snort_dir, is_enable, &fa_data, sizeof (fa_data)); break; default: - vlib_log_err (snort_log.class, + vlib_log_err (snort_log._class, "Invalid direction given to enable/disable snort"); break; } @@ -601,7 +601,7 @@ snort_interface_enable_disable (vlib_main_t *vm, char *instance_name, if (snort_dir == SNORT_INVALID) { rv = VNET_API_ERROR_INVALID_ARGUMENT; - vlib_log_err (snort_log.class, + vlib_log_err (snort_log._class, "cannot attach/detach with invalid direction "); goto done; } diff --git a/src/plugins/snort/snort_api.c b/src/plugins/snort/snort_api.c index 00b3c3ace674..0afc6db574c1 100644 --- a/src/plugins/snort/snort_api.c +++ b/src/plugins/snort/snort_api.c @@ -31,8 +31,8 @@ VLIB_REGISTER_LOG_CLASS (snort_log, static) = { .class_name = "snort", }; -#define log_debug(fmt, ...) vlib_log_debug (snort_log.class, fmt, __VA_ARGS__) -#define log_err(fmt, ...) vlib_log_err (snort_log.class, fmt, __VA_ARGS__) +#define log_debug(fmt, ...) vlib_log_debug (snort_log._class, fmt, __VA_ARGS__) +#define log_err(fmt, ...) vlib_log_err (snort_log._class, fmt, __VA_ARGS__) static void vl_api_snort_instance_create_t_handler (vl_api_snort_instance_create_t *mp) diff --git a/src/plugins/vhost/vhost_user.c b/src/plugins/vhost/vhost_user.c index fdee984f97bf..7e5f24a96853 100644 --- a/src/plugins/vhost/vhost_user.c +++ b/src/plugins/vhost/vhost_user.c @@ -418,7 +418,7 @@ vhost_user_socket_read (clib_file_t * uf) vhost_user_intf_t *vui; struct cmsghdr *cmsg; u8 q; - clib_file_t template = { 0 }; + clib_file_t _template = { 0 }; vnet_main_t *vnm = vnet_get_main (); vlib_main_t *vm = vlib_get_main (); @@ -798,12 +798,12 @@ vhost_user_socket_read (clib_file_t * uf) goto close_socket; } - template.read_function = vhost_user_callfd_read_ready; - template.file_descriptor = fds[0]; - template.private_data = + _template.read_function = vhost_user_callfd_read_ready; + _template.file_descriptor = fds[0]; + _template.private_data = ((vui - vhost_user_main.vhost_user_interfaces) << 8) + q; - template.description = format (0, "vhost user"); - vui->vrings[q].callfd_idx = clib_file_add (&file_main, &template); + _template.description = format (0, "vhost user"); + vui->vrings[q].callfd_idx = clib_file_add (&file_main, &_template); } else vui->vrings[q].callfd_idx = ~0; @@ -837,12 +837,12 @@ vhost_user_socket_read (clib_file_t * uf) goto close_socket; } - template.read_function = vhost_user_kickfd_read_ready; - template.file_descriptor = fds[0]; - template.private_data = + _template.read_function = vhost_user_kickfd_read_ready; + _template.file_descriptor = fds[0]; + _template.private_data = (((uword) (vui - vhost_user_main.vhost_user_interfaces)) << 8) + q; - vui->vrings[q].kickfd_idx = clib_file_add (&file_main, &template); + vui->vrings[q].kickfd_idx = clib_file_add (&file_main, &_template); } else { @@ -1130,7 +1130,7 @@ vhost_user_socksvr_accept_ready (clib_file_t * uf) { int client_fd, client_len; struct sockaddr_un client; - clib_file_t template = { 0 }; + clib_file_t _template = { 0 }; vhost_user_main_t *vum = &vhost_user_main; vhost_user_intf_t *vui; @@ -1153,12 +1153,12 @@ vhost_user_socksvr_accept_ready (clib_file_t * uf) vu_log_debug (vui, "New client socket for vhost interface %d, fd %d", vui->sw_if_index, client_fd); - template.read_function = vhost_user_socket_read; - template.error_function = vhost_user_socket_error; - template.file_descriptor = client_fd; - template.private_data = vui - vhost_user_main.vhost_user_interfaces; - template.description = format (0, "vhost interface %d", vui->sw_if_index); - vui->clib_file_index = clib_file_add (&file_main, &template); + _template.read_function = vhost_user_socket_read; + _template.error_function = vhost_user_socket_error; + _template.file_descriptor = client_fd; + _template.private_data = vui - vhost_user_main.vhost_user_interfaces; + _template.description = format (0, "vhost interface %d", vui->sw_if_index); + vui->clib_file_index = clib_file_add (&file_main, &_template); vui->num_qid = 2; return 0; } @@ -1289,14 +1289,14 @@ vhost_user_process (vlib_main_t * vm, vhost_user_intf_t *vui; struct sockaddr_un sun; int sockfd; - clib_file_t template = { 0 }; + clib_file_t _template = { 0 }; f64 timeout = 3153600000.0 /* 100 years */ ; uword *event_data = 0; sockfd = -1; sun.sun_family = AF_UNIX; - template.read_function = vhost_user_socket_read; - template.error_function = vhost_user_socket_error; + _template.read_function = vhost_user_socket_read; + _template.error_function = vhost_user_socket_error; while (1) { @@ -1345,11 +1345,11 @@ vhost_user_process (vlib_main_t * vm, clib_unix_warning ("fcntl2"); vui->sock_errno = 0; - template.file_descriptor = sockfd; - template.private_data = + _template.file_descriptor = sockfd; + _template.private_data = vui - vhost_user_main.vhost_user_interfaces; - template.description = format (0, "vhost user process"); - vui->clib_file_index = clib_file_add (&file_main, &template); + _template.description = format (0, "vhost user process"); + vui->clib_file_index = clib_file_add (&file_main, &_template); vui->num_qid = 2; /* This sockfd is considered consumed */ @@ -1590,12 +1590,12 @@ vhost_user_vui_init (vnet_main_t * vnm, vhost_user_intf_t * vui, sw = vnet_get_hw_sw_interface (vnm, vui->hw_if_index); if (server_sock_fd != -1) { - clib_file_t template = { 0 }; - template.read_function = vhost_user_socksvr_accept_ready; - template.file_descriptor = server_sock_fd; - template.private_data = vui - vum->vhost_user_interfaces; //hw index - template.description = format (0, "vhost user %d", sw); - vui->unix_server_index = clib_file_add (&file_main, &template); + clib_file_t _template = { 0 }; + _template.read_function = vhost_user_socksvr_accept_ready; + _template.file_descriptor = server_sock_fd; + _template.private_data = vui - vum->vhost_user_interfaces; //hw index + _template.description = format (0, "vhost user %d", sw); + vui->unix_server_index = clib_file_add (&file_main, &_template); } else { diff --git a/src/plugins/wireguard/wireguard_send.h b/src/plugins/wireguard/wireguard_send.h index 419783a5db2b..951bf4bce92a 100644 --- a/src/plugins/wireguard/wireguard_send.h +++ b/src/plugins/wireguard/wireguard_send.h @@ -36,11 +36,11 @@ ip4_header_set_len_w_chksum (ip4_header_t * ip4, u16 len) { ip_csum_t sum = ip4->checksum; u16 old = ip4->length; - u16 new = len; + u16 _new = len; - sum = ip_csum_update (sum, old, new, ip4_header_t, length); + sum = ip_csum_update (sum, old, _new, ip4_header_t, length); ip4->checksum = ip_csum_fold (sum); - ip4->length = new; + ip4->length = _new; } #endif /* __included_wg_send_h__ */ diff --git a/src/svm/ssvm.h b/src/svm/ssvm.h index ef982a1b3049..26cb05e828e7 100644 --- a/src/svm/ssvm.h +++ b/src/svm/ssvm.h @@ -143,14 +143,14 @@ static inline void * ssvm_push_heap (ssvm_shared_header_t * sh) { clib_mem_heap_t *oldheap; - oldheap = clib_mem_set_heap (sh->heap); + oldheap = clib_mem_set_heap ((clib_mem_heap_t *) sh->heap); return ((void *) oldheap); } static inline void ssvm_pop_heap (void *oldheap) { - clib_mem_set_heap (oldheap); + clib_mem_set_heap ((clib_mem_heap_t *) oldheap); } static inline void * @@ -159,7 +159,7 @@ ssvm_mem_alloc (ssvm_private_t * ssvm, uword size) clib_mem_heap_t *oldheap; void *rv; - oldheap = clib_mem_set_heap (ssvm->sh->heap); + oldheap = clib_mem_set_heap ((clib_mem_heap_t *) ssvm->sh->heap); rv = clib_mem_alloc (size); clib_mem_set_heap (oldheap); return (rv); diff --git a/src/svm/svm_fifo.h b/src/svm/svm_fifo.h index 7ea114f8702e..8b3306916603 100644 --- a/src/svm/svm_fifo.h +++ b/src/svm/svm_fifo.h @@ -702,7 +702,7 @@ svm_fifo_size (svm_fifo_t * f) static inline void svm_fifo_set_size (svm_fifo_t * f, u32 size) { - if (size > (1 << f->fs_hdr->max_log2_fifo_size)) + if (size > (1U << f->fs_hdr->max_log2_fifo_size)) return; fsh_virtual_mem_update (f->fs_hdr, f->shr->slice_index, (int) f->shr->size - size); diff --git a/src/tools/g2/view1.c b/src/tools/g2/view1.c index 7a6ae714e3fb..a3748396af3e 100644 --- a/src/tools/g2/view1.c +++ b/src/tools/g2/view1.c @@ -476,26 +476,26 @@ void format_popbox_string (char *tmpbuf, int len, event_t *ep, event_def_t *edp) static void add_snapshot(void) { int i; - snapshot_t *new = g_malloc(sizeof(snapshot_t)); + snapshot_t *_new = g_malloc(sizeof(snapshot_t)); - memcpy(&new->geometry, s_v1, sizeof(new->geometry)); + memcpy(&_new->geometry, s_v1, sizeof(_new->geometry)); for (i = 0; i < NEVENTS; i++) { - new->show_event[i] = g_eventdefs[i].selected; + _new->show_event[i] = g_eventdefs[i].selected; } - new->pidvec = g_malloc(sizeof(pid_sort_t)*g_npids); - memcpy(new->pidvec, g_pids, sizeof(pid_sort_t)*g_npids); - new->vscroll_value = GTK_ADJUSTMENT(s_view1_vsadj)->value; - new->summary_mode = summary_mode; - new->color_mode = color_mode; + _new->pidvec = g_malloc(sizeof(pid_sort_t)*g_npids); + memcpy(_new->pidvec, g_pids, sizeof(pid_sort_t)*g_npids); + _new->vscroll_value = GTK_ADJUSTMENT(s_view1_vsadj)->value; + _new->summary_mode = summary_mode; + _new->color_mode = color_mode; if (s_snapshots) { - new->next = s_snapshots; - s_snapshots = new; + _new->next = s_snapshots; + s_snapshots = _new; } else { - new->next = 0; - s_snapshots = new; + _new->next = 0; + s_snapshots = _new; } - s_cursnap = new; + s_cursnap = _new; } /**************************************************************************** diff --git a/src/vat2/main.c b/src/vat2/main.c index bf415854db1e..d657b964f252 100644 --- a/src/vat2/main.c +++ b/src/vat2/main.c @@ -271,7 +271,7 @@ main (int argc, char **argv) { /* Create a heap of 64MB */ clib_mem_init (0, 64 << 20); - char *filename = 0, *prefix = 0, *template = 0, *pluginpath = 0; + char *filename = 0, *prefix = 0, *_template = 0, *pluginpath = 0; int index; int c; opterr = 0; @@ -302,7 +302,7 @@ main (int argc, char **argv) vat2_debug = true; break; case 't': - template = optarg; + _template = optarg; break; case 's': prefix = optarg; @@ -320,8 +320,8 @@ main (int argc, char **argv) abort (); } } - DBG ("debug = %d, filename = %s, template = %s, shared memory prefix: %s\n", - vat2_debug, filename, template, prefix); + DBG ("debug = %d, filename = %s, _template = %s, shared memory prefix: %s\n", + vat2_debug, filename, _template, prefix); for (index = optind; index < argc; index++) DBG ("Non-option argument %s\n", argv[index]); @@ -343,9 +343,9 @@ main (int argc, char **argv) exit (-1); } - if (template) + if (_template) { - print_template (template); + print_template (_template); exit (0); } diff --git a/src/vlib/buffer.c b/src/vlib/buffer.c index a7952d93c218..e6c89a9e70fd 100644 --- a/src/vlib/buffer.c +++ b/src/vlib/buffer.c @@ -575,7 +575,7 @@ vlib_buffer_pool_create (vlib_main_t *vm, u32 data_size, u32 physmem_map_index, continue; b = (vlib_buffer_t *) (p + bm->ext_hdr_size); - b->template = bp->buffer_template; + b->_template = bp->buffer_template; bi = vlib_get_buffer_index (vm, b); bp->buffers[bp->n_avail++] = bi; vlib_get_buffer (vm, bi); diff --git a/src/vlib/buffer.h b/src/vlib/buffer.h index aad9701080e0..4159ea639e3b 100644 --- a/src/vlib/buffer.h +++ b/src/vlib/buffer.h @@ -162,7 +162,7 @@ typedef struct STATIC_ASSERT_SIZEOF (vlib_buffer_template_t, 64); /** VLIB buffer representation. */ -typedef union +typedef union vlib_buffer_t { CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); struct @@ -173,7 +173,7 @@ typedef union { vlib_buffer_template_fields }; - vlib_buffer_template_t template; + vlib_buffer_template_t _template; }; /* Data above is initialized or zeroed on alloc, data bellow is not diff --git a/src/vlib/buffer_funcs.h b/src/vlib/buffer_funcs.h index 010289ce2bef..649adc4c42ee 100644 --- a/src/vlib/buffer_funcs.h +++ b/src/vlib/buffer_funcs.h @@ -128,7 +128,7 @@ vlib_get_buffer (vlib_main_t * vm, u32 buffer_index) vlib_buffer_main_t *bm = vm->buffer_main; vlib_buffer_t *b; - b = vlib_buffer_ptr_from_index (bm->buffer_mem_start, buffer_index, 0); + b = (vlib_buffer_t *) vlib_buffer_ptr_from_index (bm->buffer_mem_start, buffer_index, 0); vlib_buffer_validate (vm, b); return b; } @@ -220,7 +220,7 @@ vlib_get_buffers_with_offset (vlib_main_t *vm, u32 *bi, void **b, u32 count, { uword buffer_mem_start = vm->buffer_main->buffer_mem_start; void *base = (void *) (buffer_mem_start + offset); - int objsize = __builtin_object_size (b, 0); + uword objsize = __builtin_object_size (b, 0); const int sh = CLIB_LOG2_CACHE_LINE_BYTES; if (COMPILE_TIME_CONST (count) == 0 && objsize >= 64 * sizeof (b[0]) && @@ -483,7 +483,7 @@ vlib_buffer_is_known (vlib_main_t * vm, u32 buffer_index) clib_spinlock_lock (&bm->buffer_known_hash_lockp); uword *p = hash_get (bm->buffer_known_hash, buffer_index); clib_spinlock_unlock (&bm->buffer_known_hash_lockp); - return p ? p[0] : VLIB_BUFFER_UNKNOWN; + return (vlib_buffer_known_state_t) (p ? p[0] : VLIB_BUFFER_UNKNOWN); } /* Validates sanity of a single buffer. @@ -780,11 +780,11 @@ vlib_buffer_free_inline (vlib_main_t * vm, u32 * buffers, u32 n_buffers, u32 n_queue = 0, queue[queue_size + 8]; vlib_buffer_template_t bt = {}; #if defined(CLIB_HAVE_VEC128) - vlib_buffer_t bpi_mask = {.buffer_pool_index = ~0 }; + vlib_buffer_t bpi_mask = { .buffer_pool_index = (u8) ~0 }; vlib_buffer_t bpi_vec = {}; vlib_buffer_t flags_refs_mask = { .flags = VLIB_BUFFER_NEXT_PRESENT, - .ref_count = ~1 + .ref_count = (u8) ~1 }; #endif @@ -886,14 +886,14 @@ vlib_buffer_free_inline (vlib_main_t * vm, u32 * buffers, u32 n_buffers, #if defined(CLIB_HAVE_VEC512) vlib_buffer_copy_indices (queue + n_queue, buffers, 8); - b[0]->template = bt; - b[1]->template = bt; - b[2]->template = bt; - b[3]->template = bt; - b[4]->template = bt; - b[5]->template = bt; - b[6]->template = bt; - b[7]->template = bt; + b[0]->_template = bt; + b[1]->_template = bt; + b[2]->_template = bt; + b[3]->_template = bt; + b[4]->_template = bt; + b[5]->_template = bt; + b[6]->_template = bt; + b[7]->_template = bt; n_queue += 8; vlib_buffer_validate (vm, b[0]); @@ -915,10 +915,10 @@ vlib_buffer_free_inline (vlib_main_t * vm, u32 * buffers, u32 n_buffers, VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b[7]); #else vlib_buffer_copy_indices (queue + n_queue, buffers, 4); - b[0]->template = bt; - b[1]->template = bt; - b[2]->template = bt; - b[3]->template = bt; + b[0]->_template = bt; + b[1]->_template = bt; + b[2]->_template = bt; + b[3]->_template = bt; n_queue += 4; vlib_buffer_validate (vm, b[0]); @@ -977,7 +977,7 @@ vlib_buffer_free_inline (vlib_main_t * vm, u32 * buffers, u32 n_buffers, if (clib_atomic_sub_fetch (&b[0]->ref_count, 1) == 0) { - b[0]->template = bt; + b[0]->_template = bt; queue[n_queue++] = bi; } @@ -1115,7 +1115,6 @@ vlib_buffer_copy (vlib_main_t * vm, vlib_buffer_t * b) vlib_buffer_t *s, *d, *fd; uword n_alloc, n_buffers = 1; u32 flag_mask = VLIB_BUFFER_COPY_CLONE_FLAGS_MASK; - int i; s = b; while (s->flags & VLIB_BUFFER_NEXT_PRESENT) @@ -1150,7 +1149,7 @@ vlib_buffer_copy (vlib_main_t * vm, vlib_buffer_t * b) vlib_buffer_get_current (s), s->current_length); /* next segments */ - for (i = 1; i < n_buffers; i++) + for (uword i = 1; i < n_buffers; i++) { /* previous */ d->next_buffer = new_buffers[i]; @@ -1202,9 +1201,9 @@ vlib_buffer_move (vlib_main_t * vm, vlib_buffer_t * b, i16 offset) ASSERT (offset + b->current_length < vlib_buffer_get_default_data_size (vm)); - u8 *source = vlib_buffer_get_current (b); + u8 *source = (u8 *) vlib_buffer_get_current (b); b->current_data = offset; - u8 *destination = vlib_buffer_get_current (b); + u8 *destination = (u8 *) vlib_buffer_get_current (b); u16 length = b->current_length; if (source + length <= destination) /* no overlap */ @@ -1444,7 +1443,7 @@ vlib_buffer_chain_append_data (vlib_main_t * vm, u16 len = clib_min (data_len, n_buffer_bytes - last->current_length - last->current_data); - clib_memcpy_fast (vlib_buffer_get_current (last) + last->current_length, + clib_memcpy_fast ((u8 *) vlib_buffer_get_current (last) + last->current_length, data, len); vlib_buffer_chain_increase_length (first, last, len); return len; @@ -1537,7 +1536,7 @@ vlib_buffer_chain_linearize (vlib_main_t * vm, vlib_buffer_t * b) break; /* malformed chained buffer */ b = vlib_get_buffer (vm, b->next_buffer); - src = vlib_buffer_get_current (b); + src = (u8 *) vlib_buffer_get_current (b); src_len = b->current_length; } diff --git a/src/vlib/buffer_node.h b/src/vlib/buffer_node.h index c0268b215627..f28fb28937e8 100644 --- a/src/vlib/buffer_node.h +++ b/src/vlib/buffer_node.h @@ -304,7 +304,7 @@ generic_buffer_node_inline (vlib_main_t * vm, u32 n_left_from, *from, *to_next; u32 next_index; - from = vlib_frame_vector_args (frame); + from = (u32 *) vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; next_index = node->cached_next_index; diff --git a/src/vlib/counter.h b/src/vlib/counter.h index f9da576a5f20..aa95eaccbb8c 100644 --- a/src/vlib/counter.h +++ b/src/vlib/counter.h @@ -41,6 +41,7 @@ #define included_vlib_counter_h #include +#include /** \file @@ -144,13 +145,12 @@ vlib_get_simple_counter (vlib_simple_counter_main_t * cm, u32 index) { counter_t *my_counters; counter_t v; - int i; ASSERT (index < vlib_simple_counter_n_counters (cm)); v = 0; - for (i = 0; i < vec_len (cm->counters); i++) + for (uword i = 0; i < vec_len (cm->counters); i++) { my_counters = cm->counters[i]; v += my_counters[index]; @@ -169,11 +169,10 @@ always_inline void vlib_zero_simple_counter (vlib_simple_counter_main_t * cm, u32 index) { counter_t *my_counters; - int i; ASSERT (index < vlib_simple_counter_n_counters (cm)); - for (i = 0; i < vec_len (cm->counters); i++) + for (u32 i = 0; i < vec_len (cm->counters); i++) { my_counters = cm->counters[i]; my_counters[index] = 0; @@ -289,12 +288,11 @@ vlib_get_combined_counter (const vlib_combined_counter_main_t * cm, u32 index, vlib_counter_t * result) { vlib_counter_t *my_counters, *counter; - int i; result->packets = 0; result->bytes = 0; - for (i = 0; i < vec_len (cm->counters); i++) + for (u32 i = 0; i < vec_len (cm->counters); i++) { my_counters = cm->counters[i]; @@ -314,9 +312,8 @@ always_inline void vlib_zero_combined_counter (vlib_combined_counter_main_t * cm, u32 index) { vlib_counter_t *my_counters, *counter; - int i; - for (i = 0; i < vec_len (cm->counters); i++) + for (u32 i = 0; i < vec_len (cm->counters); i++) { my_counters = cm->counters[i]; diff --git a/src/vlib/dma/dma.h b/src/vlib/dma/dma.h index 62d04110aa61..2ed4e377a186 100644 --- a/src/vlib/dma/dma.h +++ b/src/vlib/dma/dma.h @@ -7,11 +7,11 @@ #include #define dma_log_debug(f, ...) \ - vlib_log (VLIB_LOG_LEVEL_DEBUG, dma_log.class, "%s: " f, __func__, \ + vlib_log (VLIB_LOG_LEVEL_DEBUG, dma_log._class, "%s: " f, __func__, \ ##__VA_ARGS__) #define dma_log_info(f, ...) \ - vlib_log (VLIB_LOG_LEVEL_INFO, dma_log.class, "%s: " f, __func__, \ + vlib_log (VLIB_LOG_LEVEL_INFO, dma_log._class, "%s: " f, __func__, \ ##__VA_ARGS__) struct vlib_dma_batch; diff --git a/src/vlib/linux/pci.c b/src/vlib/linux/pci.c index 29ca3d97523c..a39b2ae12de5 100644 --- a/src/vlib/linux/pci.c +++ b/src/vlib/linux/pci.c @@ -70,10 +70,10 @@ VLIB_REGISTER_LOG_CLASS (pci_log, static) = { }; #define log_debug(p, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_DEBUG, pci_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_DEBUG, pci_log._class, "%U: " f, \ format_vlib_pci_log, p->handle, ##__VA_ARGS__) #define log_err(p, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_ERR, pci_log.class, "%U: " f, format_vlib_pci_log, \ + vlib_log (VLIB_LOG_LEVEL_ERR, pci_log._class, "%U: " f, format_vlib_pci_log, \ p->handle, ##__VA_ARGS__) typedef struct diff --git a/src/vlib/log.c b/src/vlib/log.c index 60fb9fb5178d..da3f769335a5 100644 --- a/src/vlib/log.c +++ b/src/vlib/log.c @@ -109,12 +109,12 @@ log_level_is_enabled (vlib_log_level_t level, vlib_log_level_t configured) } void -vlib_log (vlib_log_level_t level, vlib_log_class_t class, char *fmt, ...) +vlib_log (vlib_log_level_t level, vlib_log_class_t _class, char *fmt, ...) { vlib_main_t *vm = vlib_get_main (); vlib_log_main_t *lm = &log_main; vlib_log_entry_t *e; - vlib_log_subclass_data_t *sc = vlib_log_get_subclass_data (class); + vlib_log_subclass_data_t *sc = vlib_log_get_subclass_data (_class); va_list va; f64 t = vlib_time_now (vm); f64 delta = t - sc->last_event_timestamp; @@ -173,7 +173,7 @@ vlib_log (vlib_log_level_t level, vlib_log_class_t class, char *fmt, ...) } fmt = format (0, "%%-%uU [%%-6U]: ", lm->max_class_name_length); vec_terminate_c_string (fmt); - l = format (l, (char *) fmt, format_vlib_log_class, class, + l = format (l, (char *) fmt, format_vlib_log_class, _class, format_vlib_log_level, level); vec_free (fmt); indent = vec_len (l) - indent; @@ -185,7 +185,7 @@ vlib_log (vlib_log_level_t level, vlib_log_class_t class, char *fmt, ...) } else { - l = format (l, "%U", format_vlib_log_class, class); + l = format (l, "%U", format_vlib_log_class, _class); int prio = log_level_to_syslog_priority[level]; int is_term = vec_c_string_is_terminated (l) ? 1 : 0; @@ -200,7 +200,7 @@ vlib_log (vlib_log_level_t level, vlib_log_class_t class, char *fmt, ...) e = vec_elt_at_index (lm->entries, lm->next); vec_free (e->string); e->level = level; - e->class = class; + e->_class = _class; e->string = s; e->timestamp = t; s = 0; @@ -245,7 +245,7 @@ vlib_log (vlib_log_level_t level, vlib_log_class_t class, char *fmt, ...) } static vlib_log_class_t -vlib_log_register_class_internal (char *class, char *subclass, u32 limit) +vlib_log_register_class_internal (char *_class, char *subclass, u32 limit) { vlib_log_main_t *lm = &log_main; vlib_log_class_data_t *c = NULL; @@ -256,19 +256,19 @@ vlib_log_register_class_internal (char *class, char *subclass, u32 limit) u8 *str; u32 length = 0; - if ((p = hash_get_mem (lm->config_index_by_name, class))) + if ((p = hash_get_mem (lm->config_index_by_name, _class))) cc = vec_elt_at_index (lm->configs, p[0]); - str = format (0, "%s/%s%c", class, subclass, 0); + str = format (0, "%s/%s%c", _class, subclass, 0); if ((p = hash_get_mem (lm->config_index_by_name, (char *) str))) scc = vec_elt_at_index (lm->configs, p[0]); vec_free (str); vec_foreach (tmp, lm->classes) { - if (vec_len (tmp->name) != strlen (class)) + if (vec_len (tmp->name) != strlen (_class)) continue; - if (!memcmp (class, tmp->name, vec_len (tmp->name))) + if (!memcmp (_class, tmp->name, vec_len (tmp->name))) { c = tmp; break; @@ -278,7 +278,7 @@ vlib_log_register_class_internal (char *class, char *subclass, u32 limit) { vec_add2 (lm->classes, c, 1); c->index = c - lm->classes; - c->name = format (0, "%s", class); + c->name = format (0, "%s", _class); } length = vec_len (c->name); @@ -317,16 +317,16 @@ vlib_log_register_class_internal (char *class, char *subclass, u32 limit) } vlib_log_class_t -vlib_log_register_class (char *class, char *subclass) +vlib_log_register_class (char *_class, char *subclass) { - return vlib_log_register_class_internal (class, subclass, + return vlib_log_register_class_internal (_class, subclass, 0 /* default rate limit */ ); } vlib_log_class_t -vlib_log_register_class_rate_limit (char *class, char *subclass, u32 limit) +vlib_log_register_class_rate_limit (char *_class, char *subclass, u32 limit) { - return vlib_log_register_class_internal (class, subclass, limit); + return vlib_log_register_class_internal (_class, subclass, limit); } @@ -360,11 +360,11 @@ vlib_log_init (vlib_main_t *vm) while (r) { - r->class = vlib_log_register_class (r->class_name, r->subclass_name); + r->_class = vlib_log_register_class (r->class_name, r->subclass_name); if (r->default_level) - vlib_log_get_subclass_data (r->class)->level = r->default_level; + vlib_log_get_subclass_data (r->_class)->level = r->default_level; if (r->default_syslog_level) - vlib_log_get_subclass_data (r->class)->syslog_level = + vlib_log_get_subclass_data (r->_class)->syslog_level = r->default_syslog_level; r = r->next; } @@ -372,7 +372,7 @@ vlib_log_init (vlib_main_t *vm) r = lm->registrations; while (r) { - vlib_log_debug (r->class, "initialized"); + vlib_log_debug (r->_class, "initialized"); r = r->next; } return 0; @@ -397,7 +397,7 @@ show_log (vlib_main_t * vm, e = vec_elt_at_index (lm->entries, i); vlib_cli_output (vm, "%U %-10U %-14U %v", format_time_float, NULL, e->timestamp + time_offset, format_vlib_log_level, - e->level, format_vlib_log_class, e->class, e->string); + e->level, format_vlib_log_class, e->_class, e->string); i = (i + 1) % lm->size; } @@ -475,7 +475,7 @@ clear_log (vlib_main_t * vm, lm->count = 0; lm->next = 0; - vlib_log_info (log_log.class, "log cleared"); + vlib_log_info (log_log._class, "log cleared"); return error; } @@ -513,7 +513,7 @@ unformat_vlib_log_level (unformat_input_t * input, va_list * args) static uword unformat_vlib_log_class (unformat_input_t * input, va_list * args) { - vlib_log_class_data_t **class = va_arg (*args, vlib_log_class_data_t **); + vlib_log_class_data_t **_class = va_arg (*args, vlib_log_class_data_t **); uword rv = 0; u8 *class_str = NULL; vlib_log_main_t *lm = &log_main; @@ -524,7 +524,7 @@ unformat_vlib_log_class (unformat_input_t * input, va_list * args) { if (vec_is_equal (cdata->name, class_str)) { - *class = cdata; + *_class = cdata; rv = 1; break; } @@ -551,8 +551,8 @@ set_log_class (vlib_main_t * vm, if (!unformat_user (input, unformat_line_input, line_input)) return 0; - vlib_log_class_data_t *class = NULL; - if (!unformat (line_input, "%U", unformat_vlib_log_class, &class)) + vlib_log_class_data_t *_class = NULL; + if (!unformat (line_input, "%U", unformat_vlib_log_class, &_class)) { return clib_error_return (0, "unknown log class `%U'", format_unformat_error, line_input); @@ -586,7 +586,7 @@ set_log_class (vlib_main_t * vm, if (set_level) { vlib_log_subclass_data_t *subclass; - vec_foreach (subclass, class->subclasses) + vec_foreach (subclass, _class->subclasses) { subclass->level = level; } @@ -594,7 +594,7 @@ set_log_class (vlib_main_t * vm, if (set_syslog_level) { vlib_log_subclass_data_t *subclass; - vec_foreach (subclass, class->subclasses) + vec_foreach (subclass, _class->subclasses) { subclass->syslog_level = syslog_level; } @@ -602,7 +602,7 @@ set_log_class (vlib_main_t * vm, if (set_rate_limit) { vlib_log_subclass_data_t *subclass; - vec_foreach (subclass, class->subclasses) + vec_foreach (subclass, _class->subclasses) { subclass->rate_limit = rate_limit; } @@ -686,7 +686,7 @@ VLIB_CLI_COMMAND (cli_set_log_size, static) = { static uword unformat_vlib_log_subclass (unformat_input_t * input, va_list * args) { - vlib_log_class_data_t *class = va_arg (*args, vlib_log_class_data_t *); + vlib_log_class_data_t *_class = va_arg (*args, vlib_log_class_data_t *); vlib_log_subclass_data_t **subclass = va_arg (*args, vlib_log_subclass_data_t **); uword rv = 0; @@ -694,7 +694,7 @@ unformat_vlib_log_subclass (unformat_input_t * input, va_list * args) if (unformat (input, "%v", &subclass_str)) { vlib_log_subclass_data_t *scdata; - vec_foreach (scdata, class->subclasses) + vec_foreach (scdata, _class->subclasses) { if (vec_is_equal (scdata->name, subclass_str)) { @@ -717,19 +717,19 @@ test_log_class_subclass (vlib_main_t * vm, if (!unformat_user (input, unformat_line_input, line_input)) return 0; - vlib_log_class_data_t *class = NULL; + vlib_log_class_data_t *_class = NULL; vlib_log_subclass_data_t *subclass = NULL; vlib_log_level_t level; if (unformat (line_input, "%U", unformat_vlib_log_level, &level)) { - if (unformat (line_input, "%U", unformat_vlib_log_class, &class)) + if (unformat (line_input, "%U", unformat_vlib_log_class, &_class)) { if (unformat - (line_input, "%U", unformat_vlib_log_subclass, class, + (line_input, "%U", unformat_vlib_log_subclass, _class, &subclass)) { vlib_log (level, - (class->index << 16) | (subclass->index), "%U", + (_class->index << 16) | (subclass->index), "%U", format_unformat_input, line_input); } else @@ -804,7 +804,7 @@ log_config (vlib_main_t * vm, unformat_input_t * input) { vlib_log_main_t *lm = &log_main; unformat_input_t sub_input; - u8 *class = 0; + u8 *_class = 0; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { @@ -821,12 +821,12 @@ log_config (vlib_main_t * vm, unformat_input_t * input) ; else if (unformat (input, "add-to-elog")) lm->add_to_elog = 1; - else if (unformat (input, "class %s %U", &class, + else if (unformat (input, "class %s %U", &_class, unformat_vlib_cli_sub_input, &sub_input)) { clib_error_t *err; - err = log_config_class (vm, (char *) class, &sub_input); - class = 0; + err = log_config_class (vm, (char *) _class, &sub_input); + _class = 0; unformat_free (&sub_input); if (err) return err; diff --git a/src/vlib/log.h b/src/vlib/log.h index 45e2b59946c1..ecb1d946fc9f 100644 --- a/src/vlib/log.h +++ b/src/vlib/log.h @@ -42,7 +42,7 @@ typedef enum typedef struct { vlib_log_level_t level; - vlib_log_class_t class; + vlib_log_class_t _class; f64 timestamp; u8 *string; } vlib_log_entry_t; @@ -82,7 +82,7 @@ typedef struct vlib_log_registration { char *class_name; char *subclass_name; - vlib_log_class_t class; + vlib_log_class_t _class; vlib_log_level_t default_level; vlib_log_level_t default_syslog_level; @@ -120,9 +120,9 @@ extern vlib_log_main_t log_main; clib_error_t *vlib_log_init (struct vlib_main_t *vm); vlib_log_class_t vlib_log_register_class (char *vlass, char *subclass); vlib_log_class_t -vlib_log_register_class_rate_limit (char *class, char *subclass, +vlib_log_register_class_rate_limit (char *_class, char *subclass, u32 rate_limit); -void vlib_log (vlib_log_level_t level, vlib_log_class_t class, char *fmt, +void vlib_log (vlib_log_level_t level, vlib_log_class_t _class, char *fmt, ...); int last_log_entry (); u8 *format_vlib_log_class (u8 * s, va_list * args); @@ -144,7 +144,7 @@ __vlib_add_log_registration_##x (void) \ { \ vlib_log_main_t * lm = &log_main; \ x.next = lm->registrations; \ - x.class = ~0; \ + x._class = ~0; \ lm->registrations = &x; \ } \ __VA_ARGS__ vlib_log_class_registration_t x @@ -164,9 +164,9 @@ vlib_log_get_subclass_data (vlib_log_class_t ci) } static_always_inline int -vlib_log_is_enabled (vlib_log_level_t level, vlib_log_class_t class) +vlib_log_is_enabled (vlib_log_level_t level, vlib_log_class_t _class) { - vlib_log_subclass_data_t *sc = vlib_log_get_subclass_data (class); + vlib_log_subclass_data_t *sc = vlib_log_get_subclass_data (_class); if (level <= sc->level && sc->level != VLIB_LOG_LEVEL_DISABLED) return 1; diff --git a/src/vlib/main.h b/src/vlib/main.h index 94b8c4fa9542..b87098d6c802 100644 --- a/src/vlib/main.h +++ b/src/vlib/main.h @@ -470,9 +470,9 @@ vlib_main_init () vlib_global_main_t *vgm = &vlib_global_main; vlib_main_t *vm; - vgm->init_functions_called = hash_create (0, /* value bytes */ 0); + vgm->init_functions_called = (uword *) hash_create (0, /* value bytes */ 0); - vm = clib_mem_alloc_aligned (sizeof (*vm), CLIB_CACHE_LINE_BYTES); + vm = (vlib_main_t *) clib_mem_alloc_aligned (sizeof (*vm), CLIB_CACHE_LINE_BYTES); vec_add1_ha (vgm->vlib_mains, vm, 0, CLIB_CACHE_LINE_BYTES); } diff --git a/src/vlib/node_funcs.h b/src/vlib/node_funcs.h index ffa17ba7bb18..a289bf45685f 100644 --- a/src/vlib/node_funcs.h +++ b/src/vlib/node_funcs.h @@ -220,7 +220,7 @@ vlib_node_get_state (vlib_main_t * vm, u32 node_index) vlib_node_main_t *nm = &vm->node_main; vlib_node_t *n; n = vec_elt (nm->nodes, node_index); - return n->state; + return (vlib_node_state_t) n->state; } always_inline void @@ -297,7 +297,7 @@ always_inline void * vlib_frame_vector_args (vlib_frame_t * f) { ASSERT (f->vector_offset); - return (void *) f + f->vector_offset; + return (u8 *) f + f->vector_offset; } /** \brief Get pointer to frame vector aux data. @@ -308,7 +308,7 @@ always_inline void * vlib_frame_aux_args (vlib_frame_t *f) { ASSERT (f->aux_offset); - return (void *) f + f->aux_offset; + return (u8 *) f + f->aux_offset; } /** \brief Get pointer to frame scalar data. @@ -323,7 +323,7 @@ always_inline void * vlib_frame_scalar_args (vlib_frame_t * f) { ASSERT (f->scalar_offset); - return (void *) f + f->scalar_offset; + return (u8 *) f + f->scalar_offset; } always_inline vlib_next_frame_t * @@ -385,7 +385,8 @@ vlib_frame_t *vlib_get_next_frame_internal (vlib_main_t * vm, vlib_frame_t *_f = vlib_get_next_frame_internal ( \ (vm), (node), (next_index), (alloc_new_frame)); \ u32 _n = _f->n_vectors; \ - (vectors) = vlib_frame_vector_args (_f) + _n * sizeof ((vectors)[0]); \ + (vectors) = (__typeof__(vectors))((u8 *) vlib_frame_vector_args (_f) \ + + _n * sizeof ((vectors)[0])); \ (n_vectors_left) = VLIB_FRAME_SIZE - _n; \ } \ while (0) @@ -398,11 +399,13 @@ vlib_frame_t *vlib_get_next_frame_internal (vlib_main_t * vm, vlib_frame_t *_f = vlib_get_next_frame_internal ( \ (vm), (node), (next_index), (alloc_new_frame)); \ u32 _n = _f->n_vectors; \ - (vectors) = vlib_frame_vector_args (_f) + _n * sizeof ((vectors)[0]); \ + (vectors) = (__typeof__(vectors))((u8 *) vlib_frame_vector_args (_f) \ + + _n * sizeof ((vectors)[0])); \ if ((maybe_no_aux) && (_f)->aux_offset == 0) \ (aux_data) = NULL; \ else \ - (aux_data) = vlib_frame_aux_args (_f) + _n * sizeof ((aux_data)[0]); \ + (aux_data) = (__typeof__(vectors))((u8 *)vlib_frame_aux_args (_f) \ + + _n * sizeof ((aux_data)[0])); \ (n_vectors_left) = VLIB_FRAME_SIZE - _n; \ } \ while (0) @@ -545,7 +548,7 @@ void vlib_put_frame_to_node (vlib_main_t * vm, u32 to_node_index, always_inline uword vlib_in_process_context (vlib_main_t * vm) { - return vm->node_main.current_process_index != ~0; + return vm->node_main.current_process_index != ~0U; } always_inline vlib_process_t * @@ -677,7 +680,7 @@ vlib_process_get_event_data (vlib_main_t * vm, /* Find first type with events ready. Return invalid type when there's nothing there. */ t = clib_bitmap_first_set (p->non_empty_event_type_bitmap); - if (t == ~0) + if (t == ~0ULL) return 0; p->non_empty_event_type_bitmap = @@ -728,7 +731,7 @@ vlib_process_get_events (vlib_main_t * vm, uword ** data_vector) /* Find first type with events ready. Return invalid type when there's nothing there. */ t = clib_bitmap_first_set (p->non_empty_event_type_bitmap); - if (t == ~0) + if (t == ~0ULL) return t; p->non_empty_event_type_bitmap = @@ -971,7 +974,7 @@ vlib_process_signal_event_helper (vlib_node_main_t * nm, { uword add_to_pending = 0, delete_from_wheel = 0; u8 *data_to_be_written_by_caller; - vec_attr_t va = { .elt_sz = n_data_elt_bytes }; + vec_attr_t va = { .elt_sz = (u32) n_data_elt_bytes }; ASSERT (n->type == VLIB_NODE_TYPE_PROCESS); @@ -986,13 +989,13 @@ vlib_process_signal_event_helper (vlib_node_main_t * nm, if (!data_vec && vec_len (nm->recycled_event_data_vectors)) { - data_vec = vec_pop (nm->recycled_event_data_vectors); + data_vec = (u8 *) vec_pop (nm->recycled_event_data_vectors); vec_reset_length (data_vec); } l = vec_len (data_vec); - data_vec = _vec_realloc_internal (data_vec, l + n_data_elts, &va); + data_vec = (u8 *) _vec_realloc_internal (data_vec, l + n_data_elts, &va); p->pending_event_data_by_type_index[t] = data_vec; data_to_be_written_by_caller = data_vec + l * n_data_elt_bytes; @@ -1027,8 +1030,8 @@ vlib_process_signal_event_helper (vlib_node_main_t * nm, if (add_to_pending && p->event_resume_pending == 0) { vlib_process_restore_t restore = { - .runtime_index = n->runtime_index, - .reason = VLIB_PROCESS_RESTORE_REASON_EVENT, + .reason = VLIB_PROCESS_RESTORE_REASON_EVENT, + .runtime_index = n->runtime_index }; p->event_resume_pending = 1; vec_add1 (nm->process_restore_current, restore); @@ -1154,7 +1157,7 @@ always_inline void vlib_process_signal_event (vlib_main_t * vm, uword node_index, uword type_opaque, uword data) { - uword *d = vlib_process_signal_event_data (vm, node_index, type_opaque, + uword *d = (uword *) vlib_process_signal_event_data (vm, node_index, type_opaque, 1 /* elts */ , sizeof (uword)); d[0] = data; } @@ -1164,7 +1167,7 @@ vlib_process_signal_event_pointer (vlib_main_t * vm, uword node_index, uword type_opaque, void *data) { - void **d = vlib_process_signal_event_data (vm, node_index, type_opaque, + void **d = (void **) vlib_process_signal_event_data (vm, node_index, type_opaque, 1 /* elts */ , sizeof (data)); d[0] = data; } @@ -1185,7 +1188,7 @@ vlib_process_signal_event_mt (vlib_main_t * vm, .type_opaque = type_opaque, .data = data, }; - vlib_rpc_call_main_thread (vlib_process_signal_event_mt_helper, + vlib_rpc_call_main_thread ((void *) vlib_process_signal_event_mt_helper, (u8 *) & args, sizeof (args)); } else @@ -1198,7 +1201,7 @@ vlib_process_signal_one_time_event (vlib_main_t * vm, uword type_index, uword data) { uword *d = - vlib_process_signal_one_time_event_data (vm, node_index, type_index, + (uword *) vlib_process_signal_one_time_event_data (vm, node_index, type_index, 1 /* elts */ , sizeof (uword)); d[0] = data; } diff --git a/src/vlib/pci/pci.c b/src/vlib/pci/pci.c index 7284e6675fdd..be92cb71c4ec 100644 --- a/src/vlib/pci/pci.c +++ b/src/vlib/pci/pci.c @@ -59,7 +59,7 @@ VLIB_REGISTER_LOG_CLASS (pci_log, static) = { }; #define log_debug(h, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_DEBUG, pci_log.class, "%U: " f, \ + vlib_log (VLIB_LOG_LEVEL_DEBUG, pci_log._class, "%U: " f, \ format_vlib_pci_log, h, ##__VA_ARGS__) u8 * diff --git a/src/vlib/pci/pci_config.h b/src/vlib/pci/pci_config.h index 21b40c0f4992..62072e458a52 100644 --- a/src/vlib/pci/pci_config.h +++ b/src/vlib/pci/pci_config.h @@ -224,7 +224,7 @@ typedef enum _ (u8, revision_id) \ _ (u8, prog_if) \ _ (u8, subclass) \ - _ (u8, class) \ + _ (u8, _class) \ _ (u8, cache_line_size) \ _ (u8, latency_timer) \ _ (pci_config_header_type_t, header_type) \ diff --git a/src/vlib/punt.c b/src/vlib/punt.c index b59e5d251bec..defeea1d7044 100644 --- a/src/vlib/punt.c +++ b/src/vlib/punt.c @@ -425,25 +425,25 @@ vlib_punt_reason_alloc (vlib_punt_hdl_t client, const char *reason_name, vlib_punt_reason_t *reason, u32 flags, format_function_t *flags_format) { - vlib_punt_reason_t new; + vlib_punt_reason_t _new; if (!punt_validate_client (client)) return -2; - new = punt_reason_last++; - vec_validate (punt_reason_data, new); - punt_reason_data[new].pd_name = format (NULL, "%s", reason_name); - punt_reason_data[new].pd_reason = new; - punt_reason_data[new].pd_fn = fn; - punt_reason_data[new].pd_data = data; - punt_reason_data[new].flags = flags; - punt_reason_data[new].flags_format = flags_format; - vec_add1 (punt_reason_data[new].pd_owners, client); + _new = punt_reason_last++; + vec_validate (punt_reason_data, _new); + punt_reason_data[_new].pd_name = format (NULL, "%s", reason_name); + punt_reason_data[_new].pd_reason = _new; + punt_reason_data[_new].pd_fn = fn; + punt_reason_data[_new].pd_data = data; + punt_reason_data[_new].flags = flags; + punt_reason_data[_new].flags_format = flags_format; + vec_add1 (punt_reason_data[_new].pd_owners, client); - vlib_validate_combined_counter (&punt_counters, new); - vlib_zero_combined_counter (&punt_counters, new); + vlib_validate_combined_counter (&punt_counters, _new); + vlib_zero_combined_counter (&punt_counters, _new); - *reason = new; + *reason = _new; /* build the DP data-base */ punt_reg_mk_dp (*reason); diff --git a/src/vlib/stats/init.c b/src/vlib/stats/init.c index 8b382daf3336..af2205eb53ca 100644 --- a/src/vlib/stats/init.c +++ b/src/vlib/stats/init.c @@ -217,11 +217,11 @@ stats_segment_socket_init (void) if ((error = clib_socket_init (s))) return error; - clib_file_t template = { 0 }; - template.read_function = stats_socket_accept_ready; - template.file_descriptor = s->fd; - template.description = format (0, "stats segment listener %s", s->config); - clib_file_add (&file_main, &template); + clib_file_t _template = { 0 }; + _template.read_function = stats_socket_accept_ready; + _template.file_descriptor = s->fd; + _template.description = format (0, "stats segment listener %s", s->config); + clib_file_add (&file_main, &_template); sm->socket = s; diff --git a/src/vlib/threads.h b/src/vlib/threads.h index da2c41fec733..8e6f5a499324 100644 --- a/src/vlib/threads.h +++ b/src/vlib/threads.h @@ -198,7 +198,7 @@ vlib_smp_unsafe_warning (void) if (CLIB_DEBUG > 0) { if (vlib_get_thread_index ()) - fformat (stderr, "%s: SMP unsafe warning...\n", __func__); + fformat (stderr, __clib_strdup("%s: SMP unsafe warning...\n"), __func__); } } @@ -369,8 +369,8 @@ vlib_worker_thread_barrier_check (void) { vlib_worker_thread_t *w = vlib_worker_threads + thread_index; ELOG_TYPE_DECLARE (e) = { - .format = "barrier-wait-thread-%d", - .format_args = "i4", + .format = __clib_strdup("barrier-wait-thread-%d"), + .format_args = __clib_strdup("i4"), }; struct @@ -378,7 +378,7 @@ vlib_worker_thread_barrier_check (void) u32 thread_index; } __clib_packed *ed; - ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); + ed = (__typeof__(ed)) ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); ed->thread_index = thread_index; } @@ -416,16 +416,16 @@ vlib_worker_thread_barrier_check (void) t = vlib_time_now (vm) - t; vlib_worker_thread_t *w = vlib_worker_threads + thread_index; ELOG_TYPE_DECLARE (e) = { - .format = "barrier-refork-thread-%d", - .format_args = "i4", + .format = __clib_strdup("barrier-refork-thread-%d"), + .format_args = __clib_strdup("i4"), }; struct { - u32 thread_index; + u32 thread_index; } __clib_packed *ed; - ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, + ed = (__typeof__(ed)) ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); ed->thread_index = thread_index; } @@ -441,8 +441,8 @@ vlib_worker_thread_barrier_check (void) t = vlib_time_now (vm) - t; vlib_worker_thread_t *w = vlib_worker_threads + thread_index; ELOG_TYPE_DECLARE (e) = { - .format = "barrier-released-thread-%d: %dus", - .format_args = "i4i4", + .format = __clib_strdup("barrier-released-thread-%d: %dus"), + .format_args = __clib_strdup("i4i4"), }; struct @@ -451,7 +451,7 @@ vlib_worker_thread_barrier_check (void) u32 duration; } __clib_packed *ed; - ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); + ed = (__typeof__(ed)) ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); ed->thread_index = thread_index; ed->duration = (int) (1000000.0 * t); } diff --git a/src/vlib/trace.h b/src/vlib/trace.h index 196c691ece6c..010985636735 100644 --- a/src/vlib/trace.h +++ b/src/vlib/trace.h @@ -74,10 +74,10 @@ typedef void (vlib_trace_buffer_callback_t) (struct vlib_main_t *, /* Callback type for alternate handling of vlib_add_trace internals */ struct vlib_node_runtime_t; -struct vlib_buffer_t; +typedef union vlib_buffer_t vlib_buffer_t; typedef void *(vlib_add_trace_callback_t) (struct vlib_main_t *, struct vlib_node_runtime_t * r, - struct vlib_buffer_t * b, + vlib_buffer_t * b, u32 n_data_bytes); typedef int (vlib_is_packet_traced_fn_t) (vlib_buffer_t *b, @@ -91,7 +91,7 @@ typedef struct vlib_trace_filter_function_registration struct vlib_trace_filter_function_registration *next; } vlib_trace_filter_function_registration_t; -typedef struct +typedef struct vlib_trace_main_t { /* Pool of trace buffers. */ vlib_trace_header_t **trace_buffer_pool; diff --git a/src/vlib/trace_funcs.h b/src/vlib/trace_funcs.h index 9b45346b4672..b48567e93ca4 100644 --- a/src/vlib/trace_funcs.h +++ b/src/vlib/trace_funcs.h @@ -69,7 +69,7 @@ vlib_add_trace_inline (vlib_main_t * vm, { return tm->add_trace_callback ((struct vlib_main_t *) vm, (struct vlib_node_runtime_t *) r, - (struct vlib_buffer_t *) b, + (vlib_buffer_t *) b, n_data_bytes); } else if (PREDICT_FALSE (tm->trace_enable == 0)) diff --git a/src/vlib/unix/cli.c b/src/vlib/unix/cli.c index 051c5730aed0..563c7839acbb 100644 --- a/src/vlib/unix/cli.c +++ b/src/vlib/unix/cli.c @@ -2883,7 +2883,7 @@ unix_cli_file_add (unix_cli_main_t * cm, char *name, int fd) unix_main_t *um = &unix_main; clib_file_main_t *fm = &file_main; unix_cli_file_t *cf; - clib_file_t template = { 0 }; + clib_file_t _template = { 0 }; vlib_main_t *vm = um->vlib_main; vlib_node_t *n = 0; @@ -2914,16 +2914,16 @@ unix_cli_file_add (unix_cli_main_t * cm, char *name, int fd) pool_get_zero (cm->cli_file_pool, cf); clib_macro_init (&cf->macro_main); - template.read_function = unix_cli_read_ready; - template.write_function = unix_cli_write_ready; - template.error_function = unix_cli_error_detected; - template.file_descriptor = fd; - template.private_data = cf - cm->cli_file_pool; - template.description = format (0, "%s", name); + _template.read_function = unix_cli_read_ready; + _template.write_function = unix_cli_write_ready; + _template.error_function = unix_cli_error_detected; + _template.file_descriptor = fd; + _template.private_data = cf - cm->cli_file_pool; + _template.description = format (0, "%s", name); cf->name = format (0, "unix-cli-%s", name); cf->process_node_index = n->index; - cf->clib_file_index = clib_file_add (fm, &template); + cf->clib_file_index = clib_file_add (fm, &_template); cf->output_vector = 0; cf->input_vector = 0; vec_validate (cf->current_command, 0); @@ -3194,7 +3194,7 @@ unix_cli_config (vlib_main_t * vm, unformat_input_t * input) if (s->config && s->config[0] != 0) { /* CLI listen. */ - clib_file_t template = { 0 }; + clib_file_t _template = { 0 }; /* mkdir of file socketu, only under /run */ if (strncmp (s->config, "/run", 4) == 0) @@ -3218,11 +3218,11 @@ unix_cli_config (vlib_main_t * vm, unformat_input_t * input) if (error) return error; - template.read_function = unix_cli_listen_read_ready; - template.file_descriptor = s->fd; - template.description = format (0, "cli listener %s", s->config); + _template.read_function = unix_cli_listen_read_ready; + _template.file_descriptor = s->fd; + _template.description = format (0, "cli listener %s", s->config); - clib_file_add (fm, &template); + clib_file_add (fm, &_template); } /* Set CLI prompt. */ diff --git a/src/vlib/unix/mc_socket.c b/src/vlib/unix/mc_socket.c index 1f3b4e9a8f10..73bc61e79e5b 100644 --- a/src/vlib/unix/mc_socket.c +++ b/src/vlib/unix/mc_socket.c @@ -567,7 +567,7 @@ catchup_listen_read_ready (clib_file_t * uf) struct sockaddr_in client_addr; int client_len; mc_socket_catchup_t *c; - clib_file_t template = { 0 }; + clib_file_t _template = { 0 }; pool_get (msm->catchups, c); clib_memset (c, 0, sizeof (c[0])); @@ -612,13 +612,13 @@ catchup_listen_read_ready (clib_file_t * uf) } } - template.read_function = catchup_server_read_ready; - template.write_function = catchup_server_write_ready; - template.error_function = catchup_socket_error_ready; - template.file_descriptor = c->socket; - template.description = format (0, "multicast catchup socket"); - template.private_data = pointer_to_uword (msm); - c->clib_file_index = clib_file_add (&file_main, &template); + _template.read_function = catchup_server_read_ready; + _template.write_function = catchup_server_write_ready; + _template.error_function = catchup_socket_error_ready; + _template.file_descriptor = c->socket; + _template.description = format (0, "multicast catchup socket"); + _template.private_data = pointer_to_uword (msm); + c->clib_file_index = clib_file_add (&file_main, &_template); hash_set (msm->catchup_index_by_file_descriptor, c->socket, c - msm->catchups); @@ -774,50 +774,50 @@ socket_setup (mc_socket_main_t * msm) /* epoll setup for multicast mastership socket */ { - clib_file_t template = { 0 }; + clib_file_t _template = { 0 }; - template.read_function = mastership_socket_read_ready; - template.file_descriptor = + _template.read_function = mastership_socket_read_ready; + _template.file_descriptor = msm->multicast_sockets[MC_TRANSPORT_MASTERSHIP].socket; - template.private_data = (uword) msm; - clib_file_add (&file_main, &template); + _template.private_data = (uword) msm; + clib_file_add (&file_main, &_template); /* epoll setup for multicast to_relay socket */ - template.read_function = to_relay_socket_read_ready; - template.file_descriptor = + _template.read_function = to_relay_socket_read_ready; + _template.file_descriptor = msm->multicast_sockets[MC_TRANSPORT_USER_REQUEST_TO_RELAY].socket; - template.private_data = (uword) msm; - template.description = format (0, "multicast to_relay socket"); - clib_file_add (&file_main, &template); + _template.private_data = (uword) msm; + _template.description = format (0, "multicast to_relay socket"); + clib_file_add (&file_main, &_template); /* epoll setup for multicast from_relay socket */ - template.read_function = from_relay_socket_read_ready; - template.file_descriptor = + _template.read_function = from_relay_socket_read_ready; + _template.file_descriptor = msm->multicast_sockets[MC_TRANSPORT_USER_REQUEST_FROM_RELAY].socket; - template.private_data = (uword) msm; - template.description = format (0, "multicast from_relay socket"); - clib_file_add (&file_main, &template); + _template.private_data = (uword) msm; + _template.description = format (0, "multicast from_relay socket"); + clib_file_add (&file_main, &_template); - template.read_function = join_socket_read_ready; - template.file_descriptor = + _template.read_function = join_socket_read_ready; + _template.file_descriptor = msm->multicast_sockets[MC_TRANSPORT_JOIN].socket; - template.private_data = (uword) msm; - template.description = format (0, "multicast join socket"); - clib_file_add (&file_main, &template); + _template.private_data = (uword) msm; + _template.description = format (0, "multicast join socket"); + clib_file_add (&file_main, &_template); /* epoll setup for ack rx socket */ - template.read_function = ack_socket_read_ready; - template.file_descriptor = msm->ack_socket; - template.private_data = (uword) msm; - template.description = format (0, "multicast ack rx socket"); - clib_file_add (&file_main, &template); + _template.read_function = ack_socket_read_ready; + _template.file_descriptor = msm->ack_socket; + _template.private_data = (uword) msm; + _template.description = format (0, "multicast ack rx socket"); + clib_file_add (&file_main, &_template); /* epoll setup for TCP catchup server */ - template.read_function = catchup_listen_read_ready; - template.file_descriptor = msm->catchup_server_socket; - template.private_data = (uword) msm; - template.description = format (0, "multicast tcp catchup socket"); - clib_file_add (&file_main, &template); + _template.read_function = catchup_listen_read_ready; + _template.file_descriptor = msm->catchup_server_socket; + _template.private_data = (uword) msm; + _template.description = format (0, "multicast tcp catchup socket"); + clib_file_add (&file_main, &_template); } return 0; @@ -902,15 +902,15 @@ catchup_request_fun (void *transport_main, } { - clib_file_t template = { 0 }; - - template.read_function = catchup_client_read_ready; - template.write_function = catchup_client_write_ready; - template.error_function = catchup_socket_error_ready; - template.file_descriptor = c->socket; - template.private_data = (uword) msm; - template.description = format (0, "multicast socket"); - c->clib_file_index = clib_file_add (um, &template); + clib_file_t _template = { 0 }; + + _template.read_function = catchup_client_read_ready; + _template.write_function = catchup_client_write_ready; + _template.error_function = catchup_socket_error_ready; + _template.file_descriptor = c->socket; + _template.private_data = (uword) msm; + _template.description = format (0, "multicast socket"); + c->clib_file_index = clib_file_add (um, &_template); hash_set (msm->catchup_index_by_file_descriptor, c->socket, c - msm->catchups); diff --git a/src/vlibmemory/socket_api.c b/src/vlibmemory/socket_api.c index 26be8d095221..56f56fc63ed0 100644 --- a/src/vlibmemory/socket_api.c +++ b/src/vlibmemory/socket_api.c @@ -450,21 +450,21 @@ void socksvr_file_add (clib_file_main_t * fm, int fd) { vl_api_registration_t *rp; - clib_file_t template = { 0 }; + clib_file_t _template = { 0 }; pool_get (socket_main.registration_pool, rp); clib_memset (rp, 0, sizeof (*rp)); - template.read_function = vl_socket_read_ready; - template.write_function = vl_socket_write_ready; - template.error_function = vl_socket_error_ready; - template.file_descriptor = fd; - template.description = format (0, "socksrv"); - template.private_data = rp - socket_main.registration_pool; + _template.read_function = vl_socket_read_ready; + _template.write_function = vl_socket_write_ready; + _template.error_function = vl_socket_error_ready; + _template.file_descriptor = fd; + _template.description = format (0, "socksrv"); + _template.private_data = rp - socket_main.registration_pool; rp->registration_type = REGISTRATION_TYPE_SOCKET_SERVER; rp->vl_api_registration_pool_index = rp - socket_main.registration_pool; - rp->clib_file_index = clib_file_add (fm, &template); + rp->clib_file_index = clib_file_add (fm, &_template); } static clib_error_t * @@ -791,7 +791,7 @@ vl_sock_api_init (vlib_main_t * vm) { api_main_t *am = vlibapi_get_main (); clib_file_main_t *fm = &file_main; - clib_file_t template = { 0 }; + clib_file_t _template = { 0 }; vl_api_registration_t *rp; socket_main_t *sm = &socket_main; clib_socket_t *sock = &sm->socksvr_listen_socket; @@ -831,13 +831,13 @@ vl_sock_api_init (vlib_main_t * vm) rp->registration_type = REGISTRATION_TYPE_SOCKET_LISTEN; - template.read_function = socksvr_accept_ready; - template.write_function = socksvr_bogus_write; - template.file_descriptor = sock->fd; - template.description = format (0, "socksvr %s", sock->config); - template.private_data = rp - sm->registration_pool; + _template.read_function = socksvr_accept_ready; + _template.write_function = socksvr_bogus_write; + _template.file_descriptor = sock->fd; + _template.description = format (0, "socksvr %s", sock->config); + _template.private_data = rp - sm->registration_pool; - rp->clib_file_index = clib_file_add (fm, &template); + rp->clib_file_index = clib_file_add (fm, &_template); return 0; } diff --git a/src/vnet/adj/adj_dp.h b/src/vnet/adj/adj_dp.h index 186044b90ad9..a0085b6164b5 100644 --- a/src/vnet/adj/adj_dp.h +++ b/src/vnet/adj/adj_dp.h @@ -46,11 +46,11 @@ adj_midchain_ipip44_fixup (vlib_main_t * vm, else { ip_csum_t sum; - u16 old,new; + u16 old, _new; old = 0; - new = ip4->length; + _new = ip4->length; sum = ip4->checksum; - sum = ip_csum_update (sum, old, new, ip4_header_t, length); + sum = ip_csum_update (sum, old, _new, ip4_header_t, length); ip4->checksum = ip_csum_fold (sum); } } diff --git a/src/vnet/api_errno.h b/src/vnet/api_errno.h index 52f201c081bc..ddd135e1f7d0 100644 --- a/src/vnet/api_errno.h +++ b/src/vnet/api_errno.h @@ -36,10 +36,10 @@ static_always_inline vnet_api_error_t vnet_api_error (clib_error_t *err) { if (err == 0) - return 0; + return (vnet_api_error_t) 0; if (err->code >= 0) return VNET_API_ERROR_BUG; - return err->code; + return (vnet_api_error_t) err->code; } static_always_inline vnet_api_error_t diff --git a/src/vnet/bier/bier_hdr_inlines.h b/src/vnet/bier/bier_hdr_inlines.h index e824997df1bc..30fb7a4e9ec4 100644 --- a/src/vnet/bier/bier_hdr_inlines.h +++ b/src/vnet/bier/bier_hdr_inlines.h @@ -60,7 +60,7 @@ static inline bier_hdr_version_t bier_hdr_get_version (const bier_hdr_t *bier_hdr) { - return ((bier_hdr->bh_first_word & + return (bier_hdr_version_t) ((bier_hdr->bh_first_word & BIER_HDR_VERSION_FIELD_MASK) >> BIER_HDR_VERSION_FIELD_SHIFT); } @@ -68,7 +68,7 @@ bier_hdr_get_version (const bier_hdr_t *bier_hdr) static inline bier_hdr_len_id_t bier_hdr_get_len_id (const bier_hdr_t *bier_hdr) { - return ((bier_hdr->bh_first_word & + return (bier_hdr_len_id_t) ((bier_hdr->bh_first_word & BIER_HDR_LEN_FIELD_MASK) >> BIER_HDR_LEN_FIELD_SHIFT); } @@ -168,7 +168,7 @@ bier_hdr_set_proto_id (bier_hdr_t *bier_hdr, static inline bier_hdr_proto_id_t bier_hdr_get_proto_id (const bier_hdr_t *bier_hdr) { - return ((bier_hdr->bh_oam_dscp_proto & BIER_HDR_PROTO_FIELD_MASK) >> + return (bier_hdr_proto_id_t) ((bier_hdr->bh_oam_dscp_proto & BIER_HDR_PROTO_FIELD_MASK) >> BIER_HDR_PROTO_FIELD_SHIFT); } diff --git a/src/vnet/buffer.h b/src/vnet/buffer.h index 247af56f4037..2521745c688d 100644 --- a/src/vnet/buffer.h +++ b/src/vnet/buffer.h @@ -296,7 +296,7 @@ typedef struct } mpls; /* l2 bridging path, only valid there */ - struct opaque_l2 + struct { u32 feature_bitmap; u16 bd_index; /* bridge-domain index */ @@ -539,7 +539,7 @@ vnet_buffer_offload_flags_set (vlib_buffer_t *b, vnet_buffer_oflags_t oflags) if (b->flags & VNET_BUFFER_F_OFFLOAD) { /* add a flag to existing offload */ - vnet_buffer (b)->oflags |= oflags; + vnet_buffer (b)->oflags = (vnet_buffer_oflags_t) (vnet_buffer (b)->oflags | oflags); } else { @@ -552,7 +552,7 @@ vnet_buffer_offload_flags_set (vlib_buffer_t *b, vnet_buffer_oflags_t oflags) static_always_inline void vnet_buffer_offload_flags_clear (vlib_buffer_t *b, vnet_buffer_oflags_t oflags) { - vnet_buffer (b)->oflags &= ~oflags; + vnet_buffer (b)->oflags = (vnet_buffer_oflags_t) (vnet_buffer (b)->oflags & ~oflags); if (0 == vnet_buffer (b)->oflags) b->flags &= ~VNET_BUFFER_F_OFFLOAD; } diff --git a/src/vnet/config.c b/src/vnet/config.c index c05da663fb75..bcbf779500c2 100644 --- a/src/vnet/config.c +++ b/src/vnet/config.c @@ -270,7 +270,7 @@ vnet_config_modify_end_node (vlib_main_t * vm, u32 config_string_heap_index, u32 end_node_index) { vnet_config_feature_t *new_features; - vnet_config_t *old, *new; + vnet_config_t *old, *_new; if (end_node_index == ~0) // feature node does not exist return ~0; @@ -303,8 +303,8 @@ vnet_config_modify_end_node (vlib_main_t * vm, if (old) remove_reference (cm, old); - new = find_config_with_features (vm, cm, new_features, end_node_index); - new->reference_count += 1; + _new = find_config_with_features (vm, cm, new_features, end_node_index); + _new->reference_count += 1; /* * User gets pointer to config string first element @@ -312,10 +312,10 @@ vnet_config_modify_end_node (vlib_main_t * vm, * this config string comes from). */ vec_validate (cm->config_pool_index_by_user_index, - new->config_string_heap_index + 1); - cm->config_pool_index_by_user_index[new->config_string_heap_index + 1] - = new - cm->config_pool; - return new->config_string_heap_index + 1; + _new->config_string_heap_index + 1); + cm->config_pool_index_by_user_index[_new->config_string_heap_index + 1] + = _new - cm->config_pool; + return _new->config_string_heap_index + 1; } u32 @@ -337,7 +337,7 @@ vnet_config_add_feature (vlib_main_t * vm, u32 feature_index, void *feature_config, u32 n_feature_config_bytes) { - vnet_config_t *old, *new; + vnet_config_t *old, *_new; vnet_config_feature_t *new_features, *f; u32 n_feature_config_u32s, end_node_index; u32 node_index = vec_elt (cm->node_index_by_feature_index, feature_index); @@ -384,8 +384,8 @@ vnet_config_add_feature (vlib_main_t * vm, if (old) remove_reference (cm, old); - new = find_config_with_features (vm, cm, new_features, end_node_index); - new->reference_count += 1; + _new = find_config_with_features (vm, cm, new_features, end_node_index); + _new->reference_count += 1; /* * User gets pointer to config string first element @@ -393,10 +393,10 @@ vnet_config_add_feature (vlib_main_t * vm, * this config string comes from). */ vec_validate (cm->config_pool_index_by_user_index, - new->config_string_heap_index + 1); - cm->config_pool_index_by_user_index[new->config_string_heap_index + 1] - = new - cm->config_pool; - return new->config_string_heap_index + 1; + _new->config_string_heap_index + 1); + cm->config_pool_index_by_user_index[_new->config_string_heap_index + 1] + = _new - cm->config_pool; + return _new->config_string_heap_index + 1; } u32 @@ -406,7 +406,7 @@ vnet_config_del_feature (vlib_main_t * vm, u32 feature_index, void *feature_config, u32 n_feature_config_bytes) { - vnet_config_t *old, *new; + vnet_config_t *old, *_new; vnet_config_feature_t *new_features, *f; u32 n_feature_config_u32s; @@ -446,16 +446,16 @@ vnet_config_del_feature (vlib_main_t * vm, adds a new config because none of existing config's has matching features and so can be reused */ remove_reference (cm, old); - new = find_config_with_features (vm, cm, new_features, + _new = find_config_with_features (vm, cm, new_features, cm->end_node_indices_by_user_index [config_string_heap_index]); - new->reference_count += 1; + _new->reference_count += 1; vec_validate (cm->config_pool_index_by_user_index, - new->config_string_heap_index + 1); - cm->config_pool_index_by_user_index[new->config_string_heap_index + 1] - = new - cm->config_pool; - return new->config_string_heap_index + 1; + _new->config_string_heap_index + 1); + cm->config_pool_index_by_user_index[_new->config_string_heap_index + 1] + = _new - cm->config_pool; + return _new->config_string_heap_index + 1; } /* diff --git a/src/vnet/crypto/crypto.c b/src/vnet/crypto/crypto.c index d1a6a6b12a1a..457df57a0830 100644 --- a/src/vnet/crypto/crypto.c +++ b/src/vnet/crypto/crypto.c @@ -17,9 +17,9 @@ VLIB_REGISTER_LOG_CLASS (crypto_main_log, static) = { }; #define log_debug(f, ...) \ - vlib_log (VLIB_LOG_LEVEL_DEBUG, crypto_main_log.class, f, ##__VA_ARGS__) + vlib_log (VLIB_LOG_LEVEL_DEBUG, crypto_main_log._class, f, ##__VA_ARGS__) #define log_err(f, ...) \ - vlib_log (VLIB_LOG_LEVEL_ERR, crypto_main_log.class, f, ##__VA_ARGS__) + vlib_log (VLIB_LOG_LEVEL_ERR, crypto_main_log._class, f, ##__VA_ARGS__) static_always_inline void crypto_set_op_status (vnet_crypto_op_t * ops[], u32 n_ops, int status) diff --git a/src/vnet/dev/bus/pci.c b/src/vnet/dev/bus/pci.c index 4bb8660f4b4e..c2e8242dea6a 100644 --- a/src/vnet/dev/bus/pci.c +++ b/src/vnet/dev/bus/pci.c @@ -33,7 +33,7 @@ vnet_dev_bus_pci_get_device_info (vlib_main_t *vm, char *device_id) clib_error_t *err = 0; vlib_pci_device_info_t *di = 0; - vlib_log_debug (dev_log.class, "device %s", device_id); + vlib_log_debug (dev_log._class, "device %s", device_id); if (vnet_dev_bus_pci_device_id_to_pci_addr (&addr, device_id) == 0) return 0; @@ -41,7 +41,7 @@ vnet_dev_bus_pci_get_device_info (vlib_main_t *vm, char *device_id) di = vlib_pci_get_device_info (vm, &addr, &err); if (err) { - vlib_log_err (dev_log.class, "get_device_info: %U", format_clib_error, + vlib_log_err (dev_log._class, "get_device_info: %U", format_clib_error, err); clib_error_free (err); return 0; diff --git a/src/vnet/dev/bus/platform.c b/src/vnet/dev/bus/platform.c index 55e2e0488889..e94023087ad8 100644 --- a/src/vnet/dev/bus/platform.c +++ b/src/vnet/dev/bus/platform.c @@ -18,12 +18,12 @@ VLIB_REGISTER_LOG_CLASS (dev_log, static) = { }; #define log_debug(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_DEBUG, dev_log.class, "%U" f, format_vnet_dev_log, \ + vlib_log (VLIB_LOG_LEVEL_DEBUG, dev_log._class, "%U" f, format_vnet_dev_log, \ dev, \ clib_string_skip_prefix (__func__, "vnet_dev_bus_platform_dt_"), \ ##__VA_ARGS__) #define log_err(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_ERR, dev_log.class, "%U" f, format_vnet_dev_log, \ + vlib_log (VLIB_LOG_LEVEL_ERR, dev_log._class, "%U" f, format_vnet_dev_log, \ dev, 0, ##__VA_ARGS__) #define PLATFORM_DEV_PATH "/sys/bus/platform/devices" diff --git a/src/vnet/dev/handlers.c b/src/vnet/dev/handlers.c index bfacbe27c99f..72304da9bbd8 100644 --- a/src/vnet/dev/handlers.c +++ b/src/vnet/dev/handlers.c @@ -94,7 +94,7 @@ vnet_dev_port_eth_flag_change (vnet_main_t *vnm, vnet_hw_interface_t *hw, clib_error_t * vnet_dev_port_mac_change (vnet_hw_interface_t *hi, const u8 *old, - const u8 *new) + const u8 *_new) { vlib_main_t *vm = vlib_get_main (); vnet_dev_instance_t *di = vnet_dev_get_dev_instance (hi->dev_instance); @@ -108,7 +108,7 @@ vnet_dev_port_mac_change (vnet_hw_interface_t *hi, const u8 *old, if (!di->is_primary_if) return vnet_dev_port_err (vm, p, VNET_DEV_ERR_NOT_PRIMARY_INTERFACE, ""); - vnet_dev_set_hw_addr_eth_mac (&req.addr, new); + vnet_dev_set_hw_addr_eth_mac (&req.addr, _new); log_debug (p->dev, "new mac %U", format_vnet_dev_hw_addr, &req.addr); diff --git a/src/vnet/dev/log.h b/src/vnet/dev/log.h index 5ca7b6620e99..f18e0ab53da3 100644 --- a/src/vnet/dev/log.h +++ b/src/vnet/dev/log.h @@ -6,17 +6,17 @@ #define _VNET_DEV_LOG_H_ #define log_debug(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_DEBUG, dev_log.class, "%U" f, format_vnet_dev_log, \ + vlib_log (VLIB_LOG_LEVEL_DEBUG, dev_log._class, "%U" f, format_vnet_dev_log, \ dev, clib_string_skip_prefix (__func__, "vnet_dev_"), \ ##__VA_ARGS__) #define log_notice(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_NOTICE, dev_log.class, "%U" f, \ + vlib_log (VLIB_LOG_LEVEL_NOTICE, dev_log._class, "%U" f, \ format_vnet_dev_log, dev, 0, ##__VA_ARGS__) #define log_warn(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_WARNING, dev_log.class, "%U" f, \ + vlib_log (VLIB_LOG_LEVEL_WARNING, dev_log._class, "%U" f, \ format_vnet_dev_log, dev, 0, ##__VA_ARGS__) #define log_err(dev, f, ...) \ - vlib_log (VLIB_LOG_LEVEL_ERR, dev_log.class, "%U" f, format_vnet_dev_log, \ + vlib_log (VLIB_LOG_LEVEL_ERR, dev_log._class, "%U" f, format_vnet_dev_log, \ dev, 0, ##__VA_ARGS__) #endif /* _VNET_DEV_LOG_H_ */ diff --git a/src/vnet/devices/pipe/pipe.c b/src/vnet/devices/pipe/pipe.c index 9caee2a55cba..a68b9014bed1 100644 --- a/src/vnet/devices/pipe/pipe.c +++ b/src/vnet/devices/pipe/pipe.c @@ -505,16 +505,16 @@ static clib_error_t * pipe_create_sub_interface (vnet_hw_interface_t * hi, u32 sub_id, u32 * sw_if_index) { - vnet_sw_interface_t template; + vnet_sw_interface_t _template; - clib_memset (&template, 0, sizeof (template)); - template.type = VNET_SW_INTERFACE_TYPE_PIPE; - template.flood_class = VNET_FLOOD_CLASS_NORMAL; - template.sup_sw_if_index = hi->sw_if_index; - template.sub.id = sub_id; + clib_memset (&_template, 0, sizeof (_template)); + _template.type = VNET_SW_INTERFACE_TYPE_PIPE; + _template.flood_class = VNET_FLOOD_CLASS_NORMAL; + _template.sup_sw_if_index = hi->sw_if_index; + _template.sub.id = sub_id; return (vnet_create_sw_interface (vnet_get_main (), - &template, sw_if_index)); + &_template, sw_if_index)); } int diff --git a/src/vnet/devices/virtio/pci.c b/src/vnet/devices/virtio/pci.c index 9562bdc6369b..30bf095b7092 100644 --- a/src/vnet/devices/virtio/pci.c +++ b/src/vnet/devices/virtio/pci.c @@ -452,7 +452,7 @@ virtio_pci_disable_offload (vlib_main_t * vm, virtio_if_t * vif) virtio_ctrl_msg_t offload_hdr; virtio_net_ctrl_ack_t status = VIRTIO_NET_ERR; - offload_hdr.ctrl.class = VIRTIO_NET_CTRL_GUEST_OFFLOADS; + offload_hdr.ctrl._class = VIRTIO_NET_CTRL_GUEST_OFFLOADS; offload_hdr.ctrl.cmd = VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET; offload_hdr.status = VIRTIO_NET_ERR; u64 offloads = 0ULL; @@ -472,7 +472,7 @@ virtio_pci_enable_checksum_offload (vlib_main_t * vm, virtio_if_t * vif) virtio_ctrl_msg_t csum_offload_hdr; virtio_net_ctrl_ack_t status = VIRTIO_NET_ERR; - csum_offload_hdr.ctrl.class = VIRTIO_NET_CTRL_GUEST_OFFLOADS; + csum_offload_hdr.ctrl._class = VIRTIO_NET_CTRL_GUEST_OFFLOADS; csum_offload_hdr.ctrl.cmd = VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET; csum_offload_hdr.status = VIRTIO_NET_ERR; u64 offloads = 0ULL; @@ -493,7 +493,7 @@ virtio_pci_enable_gso (vlib_main_t * vm, virtio_if_t * vif) virtio_ctrl_msg_t gso_hdr; virtio_net_ctrl_ack_t status = VIRTIO_NET_ERR; - gso_hdr.ctrl.class = VIRTIO_NET_CTRL_GUEST_OFFLOADS; + gso_hdr.ctrl._class = VIRTIO_NET_CTRL_GUEST_OFFLOADS; gso_hdr.ctrl.cmd = VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET; gso_hdr.status = VIRTIO_NET_ERR; u64 offloads = VIRTIO_FEATURE (VIRTIO_NET_F_GUEST_CSUM) @@ -581,7 +581,7 @@ virtio_pci_enable_multiqueue (vlib_main_t * vm, virtio_if_t * vif, virtio_ctrl_msg_t mq_hdr; virtio_net_ctrl_ack_t status = VIRTIO_NET_ERR; - mq_hdr.ctrl.class = VIRTIO_NET_CTRL_MQ; + mq_hdr.ctrl._class = VIRTIO_NET_CTRL_MQ; mq_hdr.ctrl.cmd = VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET; mq_hdr.status = VIRTIO_NET_ERR; clib_memcpy (mq_hdr.data, &num_queues, sizeof (num_queues)); @@ -601,7 +601,7 @@ virtio_pci_enable_multiqueue_rss (vlib_main_t *vm, virtio_if_t *vif, STATIC_ASSERT (sizeof (*rss) <= sizeof (mq_hdr.data), "virtio_net_rss_config size too big"); - mq_hdr.ctrl.class = VIRTIO_NET_CTRL_MQ; + mq_hdr.ctrl._class = VIRTIO_NET_CTRL_MQ; mq_hdr.ctrl.cmd = VIRTIO_NET_CTRL_MQ_RSS_CONFIG; mq_hdr.status = VIRTIO_NET_ERR; diff --git a/src/vnet/devices/virtio/pci.h b/src/vnet/devices/virtio/pci.h index 597785333164..cc832481d511 100644 --- a/src/vnet/devices/virtio/pci.h +++ b/src/vnet/devices/virtio/pci.h @@ -222,7 +222,7 @@ typedef struct */ typedef CLIB_PACKED (struct { - u8 class; + u8 _class; u8 cmd; }) virtio_net_ctrl_hdr_t; diff --git a/src/vnet/ethernet/ethernet.h b/src/vnet/ethernet/ethernet.h index 858400d08d83..74068cb5d067 100644 --- a/src/vnet/ethernet/ethernet.h +++ b/src/vnet/ethernet/ethernet.h @@ -406,7 +406,7 @@ void ethernet_setup_node (vlib_main_t *vm, u32 node_index); always_inline ethernet_header_t * ethernet_buffer_get_header (vlib_buffer_t * b) { - return (void *) (b->data + vnet_buffer (b)->l2_hdr_offset); + return (ethernet_header_t *) (b->data + vnet_buffer (b)->l2_hdr_offset); } /** Returns the number of VLAN headers in the current Ethernet frame in the diff --git a/src/vnet/ethernet/interface.c b/src/vnet/ethernet/interface.c index f1bb6b810702..57a7e308a2a5 100644 --- a/src/vnet/ethernet/interface.c +++ b/src/vnet/ethernet/interface.c @@ -1056,7 +1056,7 @@ vnet_create_sub_interface (u32 sw_if_index, u32 id, vnet_interface_main_t *im = &vnm->interface_main; vnet_hw_interface_t *hi; u64 sup_and_sub_key = ((u64) (sw_if_index) << 32) | (u64) id; - vnet_sw_interface_t template; + vnet_sw_interface_t _template; uword *p; u64 *kp; @@ -1068,16 +1068,16 @@ vnet_create_sub_interface (u32 sw_if_index, u32 id, return (VNET_API_ERROR_VLAN_ALREADY_EXISTS); } - clib_memset (&template, 0, sizeof (template)); - template.type = VNET_SW_INTERFACE_TYPE_SUB; - template.flood_class = VNET_FLOOD_CLASS_NORMAL; - template.sup_sw_if_index = sw_if_index; - template.sub.id = id; - template.sub.eth.raw_flags = flags; - template.sub.eth.outer_vlan_id = outer_vlan_id; - template.sub.eth.inner_vlan_id = inner_vlan_id; + clib_memset (&_template, 0, sizeof (_template)); + _template.type = VNET_SW_INTERFACE_TYPE_SUB; + _template.flood_class = VNET_FLOOD_CLASS_NORMAL; + _template.sup_sw_if_index = sw_if_index; + _template.sub.id = id; + _template.sub.eth.raw_flags = flags; + _template.sub.eth.outer_vlan_id = outer_vlan_id; + _template.sub.eth.inner_vlan_id = inner_vlan_id; - if (vnet_create_sw_interface (vnm, &template, sub_sw_if_index)) + if (vnet_create_sw_interface (vnm, &_template, sub_sw_if_index)) return (VNET_API_ERROR_UNSPECIFIED); kp = clib_mem_alloc (sizeof (*kp)); diff --git a/src/vnet/ethernet/p2p_ethernet.c b/src/vnet/ethernet/p2p_ethernet.c index 0ece84fd9ccd..a8af585be738 100644 --- a/src/vnet/ethernet/p2p_ethernet.c +++ b/src/vnet/ethernet/p2p_ethernet.c @@ -83,17 +83,17 @@ p2p_ethernet_add_del (vlib_main_t * vm, u32 parent_if_index, hi->sw_if_index, p2pe_subif_id); return VNET_API_ERROR_SUBIF_ALREADY_EXISTS; } - vnet_sw_interface_t template = { + vnet_sw_interface_t _template = { .type = VNET_SW_INTERFACE_TYPE_P2P, .flood_class = VNET_FLOOD_CLASS_NORMAL, .sup_sw_if_index = hi->sw_if_index, .sub.id = p2pe_subif_id }; - clib_memcpy (template.p2p.client_mac, client_mac, - sizeof (template.p2p.client_mac)); + clib_memcpy (_template.p2p.client_mac, client_mac, + sizeof (_template.p2p.client_mac)); - if (vnet_create_sw_interface (vnm, &template, &p2pe_sw_if_index)) + if (vnet_create_sw_interface (vnm, &_template, &p2pe_sw_if_index)) return VNET_API_ERROR_SUBIF_CREATE_FAILED; /* Allocate counters for this interface. */ diff --git a/src/vnet/fib/fib_walk.c b/src/vnet/fib/fib_walk.c index 236607cb891d..53bd1c28f345 100644 --- a/src/vnet/fib/fib_walk.c +++ b/src/vnet/fib/fib_walk.c @@ -1156,11 +1156,11 @@ fib_walk_set_histogram_elements_size (vlib_main_t * vm, vlib_cli_command_t * cmd) { clib_error_t * error = NULL; - u32 new; + u32 _new; - if (unformat (input, "%d", &new)) + if (unformat (input, "%d", &_new)) { - fib_walk_work_nodes_visited_incr = new; + fib_walk_work_nodes_visited_incr = _new; } else { diff --git a/src/vnet/interface.c b/src/vnet/interface.c index 5fb2ff65fa2d..bb3d9c8f9932 100644 --- a/src/vnet/interface.c +++ b/src/vnet/interface.c @@ -49,8 +49,8 @@ VLIB_REGISTER_LOG_CLASS (if_default_log, static) = { .class_name = "interface", }; -#define log_debug(fmt,...) vlib_log_debug(if_default_log.class, fmt, __VA_ARGS__) -#define log_err(fmt,...) vlib_log_err(if_default_log.class, fmt, __VA_ARGS__) +#define log_debug(fmt,...) vlib_log_debug(if_default_log._class, fmt, __VA_ARGS__) +#define log_err(fmt,...) vlib_log_err(if_default_log._class, fmt, __VA_ARGS__) typedef enum vnet_interface_helper_flags_t_ { @@ -559,7 +559,7 @@ vnet_if_update_lookup_tables (vnet_main_t *vnm, u32 sw_if_index) static u32 vnet_create_sw_interface_no_callbacks (vnet_main_t * vnm, - vnet_sw_interface_t * template) + vnet_sw_interface_t * _template) { vnet_interface_main_t *im = &vnm->interface_main; vnet_sw_interface_t *sw; @@ -568,7 +568,7 @@ vnet_create_sw_interface_no_callbacks (vnet_main_t * vnm, pool_get (im->sw_interfaces, sw); sw_if_index = sw - im->sw_interfaces; - sw[0] = template[0]; + sw[0] = _template[0]; sw->flags = 0; sw->sw_if_index = sw_if_index; @@ -603,7 +603,7 @@ vnet_create_sw_interface_no_callbacks (vnet_main_t * vnm, } clib_error_t * -vnet_create_sw_interface (vnet_main_t * vnm, vnet_sw_interface_t * template, +vnet_create_sw_interface (vnet_main_t * vnm, vnet_sw_interface_t * _template, u32 * sw_if_index) { vnet_interface_main_t *im = &vnm->interface_main; @@ -611,10 +611,10 @@ vnet_create_sw_interface (vnet_main_t * vnm, vnet_sw_interface_t * template, vnet_hw_interface_t *hi; vnet_device_class_t *dev_class; - if (template->sub.eth.flags.two_tags == 1 - && template->sub.eth.flags.exact_match == 1 - && (template->sub.eth.flags.inner_vlan_id_any == 1 - || template->sub.eth.flags.outer_vlan_id_any == 1)) + if (_template->sub.eth.flags.two_tags == 1 + && _template->sub.eth.flags.exact_match == 1 + && (_template->sub.eth.flags.inner_vlan_id_any == 1 + || _template->sub.eth.flags.outer_vlan_id_any == 1)) { char *str = "inner-dot1q any exact-match is unsupported"; error = clib_error_return (0, str); @@ -622,22 +622,22 @@ vnet_create_sw_interface (vnet_main_t * vnm, vnet_sw_interface_t * template, return error; } - hi = vnet_get_sup_hw_interface (vnm, template->sup_sw_if_index); + hi = vnet_get_sup_hw_interface (vnm, _template->sup_sw_if_index); dev_class = vnet_get_device_class (vnm, hi->dev_class_index); - if (template->type == VNET_SW_INTERFACE_TYPE_SUB && + if (_template->type == VNET_SW_INTERFACE_TYPE_SUB && dev_class->subif_add_del_function) { error = dev_class->subif_add_del_function (vnm, hi->hw_if_index, (struct vnet_sw_interface_t - *) template, 1); + *) _template, 1); if (error) return error; } - *sw_if_index = vnet_create_sw_interface_no_callbacks (vnm, template); + *sw_if_index = vnet_create_sw_interface_no_callbacks (vnm, _template); error = vnet_sw_interface_set_flags_helper - (vnm, *sw_if_index, template->flags, + (vnm, *sw_if_index, _template->flags, VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE); if (error) diff --git a/src/vnet/interface.h b/src/vnet/interface.h index eb557fdef8bb..b9627ead9db1 100644 --- a/src/vnet/interface.h +++ b/src/vnet/interface.h @@ -68,7 +68,7 @@ typedef clib_error_t *(vnet_interface_function_t) /* Sub-interface add/del callback. */ typedef clib_error_t *(vnet_subif_add_del_function_t) (struct vnet_main_t * vnm, u32 if_index, - struct vnet_sw_interface_t * template, int is_add); + struct vnet_sw_interface_t * _template, int is_add); /* Interface set mtu callback. */ typedef clib_error_t *(vnet_interface_set_max_frame_size_function_t) ( @@ -894,7 +894,7 @@ typedef enum vnet_sw_interface_flags_t_ /* Software-interface. This corresponds to a Ethernet VLAN, ATM vc, a tunnel, etc. Configuration (e.g. IP address) gets attached to software interface. */ -typedef struct +typedef struct vnet_sw_interface_t { vnet_sw_interface_type_t type:16; diff --git a/src/vnet/interface/caps.c b/src/vnet/interface/caps.c index 54e8d90c4717..8ffe20d6e360 100644 --- a/src/vnet/interface/caps.c +++ b/src/vnet/interface/caps.c @@ -12,7 +12,7 @@ VLIB_REGISTER_LOG_CLASS (if_caps_log, static) = { }; #define log_debug(fmt, ...) \ - vlib_log_debug (if_caps_log.class, fmt, __VA_ARGS__) + vlib_log_debug (if_caps_log._class, fmt, __VA_ARGS__) format_function_t format_vnet_hw_if_caps; diff --git a/src/vnet/interface/runtime.c b/src/vnet/interface/runtime.c index 6428d5ab75bb..6929d745e81b 100644 --- a/src/vnet/interface/runtime.c +++ b/src/vnet/interface/runtime.c @@ -27,8 +27,8 @@ VLIB_REGISTER_LOG_CLASS (if_rxq_log, static) = { .subclass_name = "runtime", }; -#define log_debug(fmt, ...) vlib_log_debug (if_rxq_log.class, fmt, __VA_ARGS__) -#define log_err(fmt, ...) vlib_log_err (if_rxq_log.class, fmt, __VA_ARGS__) +#define log_debug(fmt, ...) vlib_log_debug (if_rxq_log._class, fmt, __VA_ARGS__) +#define log_err(fmt, ...) vlib_log_err (if_rxq_log._class, fmt, __VA_ARGS__) static char *node_state_str[] = { [VLIB_NODE_STATE_DISABLED] = "disabled", diff --git a/src/vnet/interface/rx_queue.c b/src/vnet/interface/rx_queue.c index b1fc82f38e99..3857ada3fd49 100644 --- a/src/vnet/interface/rx_queue.c +++ b/src/vnet/interface/rx_queue.c @@ -23,8 +23,8 @@ VLIB_REGISTER_LOG_CLASS (if_rxq_log, static) = { .subclass_name = "rx-queue", }; -#define log_debug(fmt, ...) vlib_log_debug (if_rxq_log.class, fmt, __VA_ARGS__) -#define log_err(fmt, ...) vlib_log_err (if_rxq_log.class, fmt, __VA_ARGS__) +#define log_debug(fmt, ...) vlib_log_debug (if_rxq_log._class, fmt, __VA_ARGS__) +#define log_err(fmt, ...) vlib_log_err (if_rxq_log._class, fmt, __VA_ARGS__) static u32 next_thread_index (vnet_main_t *vnm, u32 thread_index) diff --git a/src/vnet/interface/tx_queue.c b/src/vnet/interface/tx_queue.c index 8a6cd9da304d..80fbb0b6353e 100644 --- a/src/vnet/interface/tx_queue.c +++ b/src/vnet/interface/tx_queue.c @@ -12,8 +12,8 @@ VLIB_REGISTER_LOG_CLASS (if_txq_log, static) = { .subclass_name = "tx-queue", }; -#define log_debug(fmt, ...) vlib_log_debug (if_txq_log.class, fmt, __VA_ARGS__) -#define log_err(fmt, ...) vlib_log_err (if_txq_log.class, fmt, __VA_ARGS__) +#define log_debug(fmt, ...) vlib_log_debug (if_txq_log._class, fmt, __VA_ARGS__) +#define log_err(fmt, ...) vlib_log_err (if_txq_log._class, fmt, __VA_ARGS__) static u64 tx_queue_key (u32 hw_if_index, u32 queue_id) diff --git a/src/vnet/interface_api.c b/src/vnet/interface_api.c index 65f3a02c86bf..b1f88ccdd479 100644 --- a/src/vnet/interface_api.c +++ b/src/vnet/interface_api.c @@ -1374,7 +1374,7 @@ vl_api_create_vlan_subif_t_handler (vl_api_create_vlan_subif_t * mp) vnet_hw_interface_t *hi; int rv = 0; u32 id; - vnet_sw_interface_t template; + vnet_sw_interface_t _template; uword *p; vnet_interface_main_t *im = &vnm->interface_main; u64 sup_and_sub_key; @@ -1407,17 +1407,17 @@ vl_api_create_vlan_subif_t_handler (vl_api_create_vlan_subif_t * mp) goto out; } - clib_memset (&template, 0, sizeof (template)); - template.type = VNET_SW_INTERFACE_TYPE_SUB; - template.flood_class = VNET_FLOOD_CLASS_NORMAL; - template.sup_sw_if_index = hi->sw_if_index; - template.sub.id = id; - template.sub.eth.raw_flags = 0; - template.sub.eth.flags.one_tag = 1; - template.sub.eth.outer_vlan_id = id; - template.sub.eth.flags.exact_match = 1; - - error = vnet_create_sw_interface (vnm, &template, &sw_if_index); + clib_memset (&_template, 0, sizeof (_template)); + _template.type = VNET_SW_INTERFACE_TYPE_SUB; + _template.flood_class = VNET_FLOOD_CLASS_NORMAL; + _template.sup_sw_if_index = hi->sw_if_index; + _template.sub.id = id; + _template.sub.eth.raw_flags = 0; + _template.sub.eth.flags.one_tag = 1; + _template.sub.eth.outer_vlan_id = id; + _template.sub.eth.flags.exact_match = 1; + + error = vnet_create_sw_interface (vnm, &_template, &sw_if_index); if (error) { clib_error_report (error); diff --git a/src/vnet/interface_cli.c b/src/vnet/interface_cli.c index cc214c10f6b7..012edeb416f9 100644 --- a/src/vnet/interface_cli.c +++ b/src/vnet/interface_cli.c @@ -633,38 +633,38 @@ VLIB_CLI_COMMAND (clear_interface_counters_command, static) = { static clib_error_t * parse_vlan_sub_interfaces (unformat_input_t * input, - vnet_sw_interface_t * template) + vnet_sw_interface_t * _template) { clib_error_t *error = 0; u32 inner_vlan, outer_vlan; if (unformat (input, "any inner-dot1q any")) { - template->sub.eth.flags.two_tags = 1; - template->sub.eth.flags.outer_vlan_id_any = 1; - template->sub.eth.flags.inner_vlan_id_any = 1; + _template->sub.eth.flags.two_tags = 1; + _template->sub.eth.flags.outer_vlan_id_any = 1; + _template->sub.eth.flags.inner_vlan_id_any = 1; } else if (unformat (input, "any")) { - template->sub.eth.flags.one_tag = 1; - template->sub.eth.flags.outer_vlan_id_any = 1; + _template->sub.eth.flags.one_tag = 1; + _template->sub.eth.flags.outer_vlan_id_any = 1; } else if (unformat (input, "%d inner-dot1q any", &outer_vlan)) { - template->sub.eth.flags.two_tags = 1; - template->sub.eth.flags.inner_vlan_id_any = 1; - template->sub.eth.outer_vlan_id = outer_vlan; + _template->sub.eth.flags.two_tags = 1; + _template->sub.eth.flags.inner_vlan_id_any = 1; + _template->sub.eth.outer_vlan_id = outer_vlan; } else if (unformat (input, "%d inner-dot1q %d", &outer_vlan, &inner_vlan)) { - template->sub.eth.flags.two_tags = 1; - template->sub.eth.outer_vlan_id = outer_vlan; - template->sub.eth.inner_vlan_id = inner_vlan; + _template->sub.eth.flags.two_tags = 1; + _template->sub.eth.outer_vlan_id = outer_vlan; + _template->sub.eth.inner_vlan_id = inner_vlan; } else if (unformat (input, "%d", &outer_vlan)) { - template->sub.eth.flags.one_tag = 1; - template->sub.eth.outer_vlan_id = outer_vlan; + _template->sub.eth.flags.one_tag = 1; + _template->sub.eth.outer_vlan_id = outer_vlan; } else { @@ -677,7 +677,7 @@ parse_vlan_sub_interfaces (unformat_input_t * input, { if (unformat (input, "exact-match")) { - template->sub.eth.flags.exact_match = 1; + _template->sub.eth.flags.exact_match = 1; } } @@ -694,7 +694,7 @@ create_sub_interfaces (vlib_main_t * vm, u32 hw_if_index, sw_if_index; vnet_hw_interface_t *hi; u32 id, id_min, id_max; - vnet_sw_interface_t template; + vnet_sw_interface_t _template; hw_if_index = ~0; if (!unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index)) @@ -704,25 +704,25 @@ create_sub_interfaces (vlib_main_t * vm, goto done; } - clib_memset (&template, 0, sizeof (template)); - template.sub.eth.raw_flags = 0; + clib_memset (&_template, 0, sizeof (_template)); + _template.sub.eth.raw_flags = 0; if (unformat (input, "%d default", &id_min)) { id_max = id_min; - template.sub.eth.flags.default_sub = 1; + _template.sub.eth.flags.default_sub = 1; } else if (unformat (input, "%d untagged", &id_min)) { id_max = id_min; - template.sub.eth.flags.no_tags = 1; - template.sub.eth.flags.exact_match = 1; + _template.sub.eth.flags.no_tags = 1; + _template.sub.eth.flags.exact_match = 1; } else if (unformat (input, "%d dot1q", &id_min)) { /* parse dot1q config */ id_max = id_min; - error = parse_vlan_sub_interfaces (input, &template); + error = parse_vlan_sub_interfaces (input, &_template); if (error) goto done; } @@ -730,24 +730,24 @@ create_sub_interfaces (vlib_main_t * vm, { /* parse dot1ad config */ id_max = id_min; - template.sub.eth.flags.dot1ad = 1; - error = parse_vlan_sub_interfaces (input, &template); + _template.sub.eth.flags.dot1ad = 1; + error = parse_vlan_sub_interfaces (input, &_template); if (error) goto done; } else if (unformat (input, "%d-%d", &id_min, &id_max)) { - template.sub.eth.flags.one_tag = 1; - template.sub.eth.flags.exact_match = 1; + _template.sub.eth.flags.one_tag = 1; + _template.sub.eth.flags.exact_match = 1; if (id_min > id_max) goto id_error; } else if (unformat (input, "%d", &id_min)) { id_max = id_min; - template.sub.eth.flags.one_tag = 1; - template.sub.eth.outer_vlan_id = id_min; - template.sub.eth.flags.exact_match = 1; + _template.sub.eth.flags.one_tag = 1; + _template.sub.eth.outer_vlan_id = id_min; + _template.sub.eth.flags.exact_match = 1; } else { @@ -784,14 +784,14 @@ create_sub_interfaces (vlib_main_t * vm, continue; } - template.type = VNET_SW_INTERFACE_TYPE_SUB; - template.flood_class = VNET_FLOOD_CLASS_NORMAL; - template.sup_sw_if_index = hi->sw_if_index; - template.sub.id = id; + _template.type = VNET_SW_INTERFACE_TYPE_SUB; + _template.flood_class = VNET_FLOOD_CLASS_NORMAL; + _template.sup_sw_if_index = hi->sw_if_index; + _template.sub.id = id; if (id_min < id_max) - template.sub.eth.outer_vlan_id = id; + _template.sub.eth.outer_vlan_id = id; - error = vnet_create_sw_interface (vnm, &template, &sw_if_index); + error = vnet_create_sw_interface (vnm, &_template, &sw_if_index); if (error) goto done; diff --git a/src/vnet/interface_funcs.h b/src/vnet/interface_funcs.h index 511df4920e4d..f62e5cbab76d 100644 --- a/src/vnet/interface_funcs.h +++ b/src/vnet/interface_funcs.h @@ -237,7 +237,7 @@ void vnet_reset_interface_l3_output_node (vlib_main_t *vm, u32 sw_if_index); /* Creates a software interface given template. */ clib_error_t *vnet_create_sw_interface (vnet_main_t * vnm, - vnet_sw_interface_t * template, + vnet_sw_interface_t * _template, u32 * sw_if_index); void vnet_delete_hw_interface (vnet_main_t * vnm, u32 hw_if_index); @@ -558,7 +558,7 @@ pcap_add_buffer (pcap_main_t *pm, struct vlib_main_t *vm, u32 buffer_index, n_left -= b->current_length; if (n_left <= 0) break; - d += b->current_length; + d = (u8 *) d + b->current_length; ASSERT (b->flags & VLIB_BUFFER_NEXT_PRESENT); b = vlib_get_buffer (vm, b->next_buffer); } @@ -586,7 +586,7 @@ static_always_inline void vnet_hw_if_unset_caps (vnet_main_t *vnm, u32 hw_if_index, vnet_hw_if_caps_t caps) { - vnet_hw_if_caps_change_t cc = { .val = 0, .mask = caps }; + vnet_hw_if_caps_change_t cc = { .val = (vnet_hw_if_caps_t) 0, .mask = caps }; vnet_hw_if_change_caps (vnm, hw_if_index, &cc); } diff --git a/src/vnet/interface_output.h b/src/vnet/interface_output.h index b512d9a04a87..1134da14fcb5 100644 --- a/src/vnet/interface_output.h +++ b/src/vnet/interface_output.h @@ -110,7 +110,7 @@ vnet_calc_checksums_inline (vlib_main_t * vm, vlib_buffer_t * b, vnet_calc_ip6_checksums (vm, b, ip6, th, uh, oflags); } - vnet_buffer_offload_flags_clear (b, (VNET_BUFFER_OFFLOAD_F_IP_CKSUM | + vnet_buffer_offload_flags_clear (b, (vnet_buffer_oflags_t) (VNET_BUFFER_OFFLOAD_F_IP_CKSUM | VNET_BUFFER_OFFLOAD_F_UDP_CKSUM | VNET_BUFFER_OFFLOAD_F_TCP_CKSUM)); } diff --git a/src/vnet/ip-neighbor/ip4_neighbor.c b/src/vnet/ip-neighbor/ip4_neighbor.c index 61b9e768fe57..a6254298174d 100644 --- a/src/vnet/ip-neighbor/ip4_neighbor.c +++ b/src/vnet/ip-neighbor/ip4_neighbor.c @@ -53,7 +53,7 @@ VLIB_REGISTER_LOG_CLASS (ip4_neighbor_log, static) = { }; #define log_debug(fmt, ...) \ - vlib_log_debug (ip4_neighbor_log.class, fmt, __VA_ARGS__) + vlib_log_debug (ip4_neighbor_log._class, fmt, __VA_ARGS__) void ip4_neighbor_probe_dst (u32 sw_if_index, u32 thread_index, diff --git a/src/vnet/ip-neighbor/ip6_neighbor.c b/src/vnet/ip-neighbor/ip6_neighbor.c index ca8aed3d4ca9..35e3ebc58653 100644 --- a/src/vnet/ip-neighbor/ip6_neighbor.c +++ b/src/vnet/ip-neighbor/ip6_neighbor.c @@ -30,7 +30,7 @@ VLIB_REGISTER_LOG_CLASS (ip6_neighbor_log, static) = { }; #define log_debug(fmt, ...) \ - vlib_log_debug (ip6_neighbor_log.class, fmt, __VA_ARGS__) + vlib_log_debug (ip6_neighbor_log._class, fmt, __VA_ARGS__) void ip6_neighbor_probe_dst (u32 sw_if_index, u32 thread_index, const ip6_address_t *dst) diff --git a/src/vnet/ip/ip.h b/src/vnet/ip/ip.h index 084243dccfa9..747f73bd77ba 100644 --- a/src/vnet/ip/ip.h +++ b/src/vnet/ip/ip.h @@ -160,7 +160,7 @@ ip_incremental_checksum_buffer (vlib_main_t * vm, u32 n; n = clib_min (n_bytes_left, b->current_length - first_buffer_offset); - h = vlib_buffer_get_current (b) + first_buffer_offset; + h = (u8 *) vlib_buffer_get_current (b) + first_buffer_offset; sum = ip_incremental_checksum (sum, h, n); if (PREDICT_FALSE (b->flags & VLIB_BUFFER_NEXT_PRESENT)) { @@ -219,7 +219,7 @@ ip_calculate_l4_checksum (vlib_main_t * vm, vlib_buffer_t * p0, else /* packet in buffer with no ip header */ { /* buffer current pointer at l4 header */ n_this_buffer = p0->current_length; - data_this_buffer = vlib_buffer_get_current (p0); + data_this_buffer = (u8 *) vlib_buffer_get_current (p0); } n_this_buffer = clib_min (n_this_buffer, n_bytes_left); } @@ -239,7 +239,7 @@ ip_calculate_l4_checksum (vlib_main_t * vm, vlib_buffer_t * p0, length_odd = (n_this_buffer & 1); p0 = vlib_get_buffer (vm, p0->next_buffer); - data_this_buffer = vlib_buffer_get_current (p0); + data_this_buffer = (u8 *) vlib_buffer_get_current (p0); n_this_buffer = clib_min (p0->current_length, n_bytes_left); if (PREDICT_FALSE (length_odd)) diff --git a/src/vnet/ip/ip4.h b/src/vnet/ip/ip4.h index 45d07c2e0f64..c912ddc69569 100644 --- a/src/vnet/ip/ip4.h +++ b/src/vnet/ip/ip4.h @@ -195,7 +195,7 @@ ip4_destination_matches_interface (ip4_main_t * im, ip4_address_t * key, ip_interface_address_t * ia) { - ip4_address_t *a = ip_interface_address_get_address (&im->lookup_main, ia); + ip4_address_t *a = (ip4_address_t *) ip_interface_address_get_address (&im->lookup_main, ia); return ip4_destination_matches_route (im, key, a, ia->address_length); } @@ -214,7 +214,7 @@ ip4_interface_address_matching_destination (ip4_main_t * im, foreach_ip_interface_address (lm, ia, sw_if_index, 1 /* honor unnumbered */, ({ - ip4_address_t * a = ip_interface_address_get_address (lm, ia); + ip4_address_t *a = (ip4_address_t *) ip_interface_address_get_address (lm, ia); if (ip4_destination_matches_route (im, dst, a, ia->address_length)) { result = a; diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c index 81d6cd1a0bd8..51536b05140a 100644 --- a/src/vnet/ip/ip4_forward.c +++ b/src/vnet/ip/ip4_forward.c @@ -287,8 +287,7 @@ ip4_interface_first_address (ip4_main_t * im, u32 sw_if_index, (lm, ia, sw_if_index, 1 /* honor unnumbered */ , ({ - ip4_address_t * a = - ip_interface_address_get_address (lm, ia); + ip4_address_t *a = (ip4_address_t *) ip_interface_address_get_address (lm, ia); result = a; break; })); diff --git a/src/vnet/ip/ip4_inlines.h b/src/vnet/ip/ip4_inlines.h index b4fcebc98966..4e1fc01fc6bf 100644 --- a/src/vnet/ip/ip4_inlines.h +++ b/src/vnet/ip/ip4_inlines.h @@ -53,9 +53,9 @@ always_inline u32 ip4_compute_flow_hash (const ip4_header_t * ip, flow_hash_config_t flow_hash_config) { - tcp_header_t *tcp = (void *) (ip + 1); - udp_header_t *udp = (void *) (ip + 1); - gtpv1u_header_t *gtpu = (void *) (udp + 1); + tcp_header_t *tcp = (tcp_header_t *) (ip + 1); + udp_header_t *udp = (udp_header_t *) (ip + 1); + gtpv1u_header_t *gtpu = (gtpv1u_header_t *) (udp + 1); u32 a, b, c, t1, t2; uword is_udp = ip->protocol == IP_PROTOCOL_UDP; uword is_tcp_udp = (ip->protocol == IP_PROTOCOL_TCP || is_udp); @@ -116,11 +116,11 @@ vlib_buffer_push_ip4_custom (vlib_main_t *vm, vlib_buffer_t *b, ip4_header_t *ih; /* make some room */ - ih = vlib_buffer_push_uninit (b, sizeof (ip4_header_t)); + ih = (ip4_header_t *) vlib_buffer_push_uninit (b, sizeof (ip4_header_t)); ih->ip_version_and_header_length = 0x45; - ip4_header_set_dscp (ih, dscp); - ip4_header_set_ecn (ih, 0); + ip4_header_set_dscp (ih, (ip_dscp_t) dscp); + ip4_header_set_ecn (ih, (ip_ecn_t) 0); ih->length = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b)); /* No fragments */ diff --git a/src/vnet/ip/ip4_packet.h b/src/vnet/ip/ip4_packet.h index 269049194e60..155f488c00a2 100644 --- a/src/vnet/ip/ip4_packet.h +++ b/src/vnet/ip/ip4_packet.h @@ -190,7 +190,7 @@ ip4_header_bytes (const ip4_header_t * i) always_inline void * ip4_next_header (ip4_header_t * i) { - return (void *) i + ip4_header_bytes (i); + return (u8 *) i + ip4_header_bytes (i); } /* Turn off array bounds check due to ip4_header_t @@ -310,20 +310,19 @@ ip4_header_checksum (ip4_header_t * i) always_inline void ip4_header_set_dscp (ip4_header_t * ip4, ip_dscp_t dscp) { - ip4->tos &= ~0xfc; + ip4->tos = (ip_dscp_t) (ip4->tos & ~0xfc); /* not masking the dscp value to save th instruction * it shouldn't b necessary since the argument is an enum * whose range is therefore constrained in the CP. in the * DP it will have been taken from another packet, so again * constrained in value */ - ip4->tos |= dscp << IP_PACKET_TC_FIELD_DSCP_BIT_SHIFT; + ip4->tos = (ip_dscp_t) (ip4->tos | (dscp << IP_PACKET_TC_FIELD_DSCP_BIT_SHIFT)); } always_inline void ip4_header_set_ecn (ip4_header_t * ip4, ip_ecn_t ecn) { - ip4->tos &= ~IP_PACKET_TC_FIELD_ECN_MASK; - ip4->tos |= ecn; + ip4->tos = (ip_dscp_t) ((ip4->tos & ~IP_PACKET_TC_FIELD_ECN_MASK) | ecn); } always_inline void @@ -331,23 +330,23 @@ ip4_header_set_ecn_w_chksum (ip4_header_t * ip4, ip_ecn_t ecn) { ip_csum_t sum = ip4->checksum; u8 old = ip4->tos; - u8 new = (old & ~IP_PACKET_TC_FIELD_ECN_MASK) | ecn; + u8 _new = (old & ~IP_PACKET_TC_FIELD_ECN_MASK) | ecn; - sum = ip_csum_update (sum, old, new, ip4_header_t, tos); + sum = ip_csum_update (sum, old, _new, ip4_header_t, tos); ip4->checksum = ip_csum_fold (sum); - ip4->tos = new; + ip4->tos = (ip_dscp_t) _new; } always_inline ip_dscp_t ip4_header_get_dscp (const ip4_header_t * ip4) { - return (ip4->tos >> IP_PACKET_TC_FIELD_DSCP_BIT_SHIFT); + return (ip_dscp_t) (ip4->tos >> IP_PACKET_TC_FIELD_DSCP_BIT_SHIFT); } always_inline ip_ecn_t ip4_header_get_ecn (const ip4_header_t * ip4) { - return (ip4->tos & IP_PACKET_TC_FIELD_ECN_MASK); + return (ip_ecn_t) (ip4->tos & IP_PACKET_TC_FIELD_ECN_MASK); } always_inline u8 diff --git a/src/vnet/ip/ip6.h b/src/vnet/ip/ip6.h index f8462a5cbffa..060374b7a7f5 100644 --- a/src/vnet/ip/ip6.h +++ b/src/vnet/ip/ip6.h @@ -40,6 +40,7 @@ #ifndef included_ip_ip6_h #define included_ip_ip6_h +#include "vppinfra/types.h" #include #include @@ -195,8 +196,7 @@ ip6_destination_matches_route (const ip6_main_t * im, const ip6_address_t * key, const ip6_address_t * dest, uword dest_length) { - int i; - for (i = 0; i < ARRAY_LEN (key->as_uword); i++) + for (uword i = 0; i < ARRAY_LEN (key->as_uword); i++) { if ((key->as_uword[i] ^ dest->as_uword[i]) & im-> fib_masks[dest_length].as_uword[i]) @@ -210,7 +210,7 @@ ip6_destination_matches_interface (ip6_main_t * im, ip6_address_t * key, ip_interface_address_t * ia) { - ip6_address_t *a = ip_interface_address_get_address (&im->lookup_main, ia); + ip6_address_t *a = (ip6_address_t *) ip_interface_address_get_address (&im->lookup_main, ia); return ip6_destination_matches_route (im, key, a, ia->address_length); } @@ -221,8 +221,7 @@ ip6_unaligned_destination_matches_route (ip6_main_t * im, ip6_address_t * dest, uword dest_length) { - int i; - for (i = 0; i < ARRAY_LEN (key->as_uword); i++) + for (uword i = 0; i < ARRAY_LEN (key->as_uword); i++) { if ((clib_mem_unaligned (&key->as_uword[i], uword) ^ dest->as_uword[i]) & im->fib_masks[dest_length].as_uword[i]) @@ -246,7 +245,7 @@ ip6_interface_address_matching_destination (ip6_main_t * im, foreach_ip_interface_address (lm, ia, sw_if_index, 1 /* honor unnumbered */, ({ - ip6_address_t * a = ip_interface_address_get_address (lm, ia); + ip6_address_t *a = (ip6_address_t *) ip_interface_address_get_address (lm, ia); if (ip6_destination_matches_route (im, dst, a, ia->address_length)) { result = a; diff --git a/src/vnet/ip/ip6_forward.c b/src/vnet/ip/ip6_forward.c index 31adc90ecab9..1e33935c9e22 100644 --- a/src/vnet/ip/ip6_forward.c +++ b/src/vnet/ip/ip6_forward.c @@ -283,7 +283,7 @@ ip6_interface_first_address (ip6_main_t * im, u32 sw_if_index) foreach_ip_interface_address (lm, ia, sw_if_index, 1 /* honor unnumbered */, ({ - ip6_address_t * a = ip_interface_address_get_address (lm, ia); + ip6_address_t *a = (ip6_address_t *) ip_interface_address_get_address (lm, ia); result = a; break; })); diff --git a/src/vnet/ip/ip6_inlines.h b/src/vnet/ip/ip6_inlines.h index 9bd475224eba..2ebd4da2d541 100644 --- a/src/vnet/ip/ip6_inlines.h +++ b/src/vnet/ip/ip6_inlines.h @@ -50,8 +50,8 @@ ip6_compute_flow_hash (const ip6_header_t * ip, flow_hash_config_t flow_hash_config) { const tcp_header_t *tcp; - const udp_header_t *udp = (void *) (ip + 1); - const gtpv1u_header_t *gtpu = (void *) (udp + 1); + const udp_header_t *udp = (const udp_header_t *) (ip + 1); + const gtpv1u_header_t *gtpu = (const gtpv1u_header_t *) (udp + 1); u64 a, b, c; u64 t1, t2; u32 t3; @@ -62,26 +62,26 @@ ip6_compute_flow_hash (const ip6_header_t * ip, if (PREDICT_TRUE ((protocol == IP_PROTOCOL_TCP) || is_udp)) { is_tcp_udp = 1; - tcp = (void *) (ip + 1); + tcp = (const tcp_header_t *) (ip + 1); } else { const void *cur = ip + 1; if (protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS) { - const ip6_hop_by_hop_header_t *hbh = cur; + const ip6_hop_by_hop_header_t *hbh = (const ip6_hop_by_hop_header_t *) cur; protocol = hbh->protocol; - cur += (hbh->length + 1) * 8; + cur = (u8 *) cur + (hbh->length + 1) * 8; } if (protocol == IP_PROTOCOL_IPV6_FRAGMENTATION) { - const ip6_fragment_ext_header_t *frag = cur; + const ip6_fragment_ext_header_t *frag = (const ip6_fragment_ext_header_t *) cur; protocol = frag->protocol; } else if (protocol == IP_PROTOCOL_TCP || protocol == IP_PROTOCOL_UDP) { is_tcp_udp = 1; - tcp = cur; + tcp = (const tcp_header_t *) cur; } } @@ -186,7 +186,7 @@ vlib_buffer_push_ip6_custom (vlib_main_t * vm, vlib_buffer_t * b, u16 payload_length; /* make some room */ - ip6h = vlib_buffer_push_uninit (b, sizeof (ip6_header_t)); + ip6h = (ip6_header_t *) vlib_buffer_push_uninit (b, sizeof (ip6_header_t)); ASSERT (flow_label < 1 << 20); ip6h->ip_version_traffic_class_and_flow_label = clib_host_to_net_u32 ((0x6 << 28) | flow_label); diff --git a/src/vnet/ip/ip6_packet.h b/src/vnet/ip/ip6_packet.h index c506792ddcf7..62c675209a4c 100644 --- a/src/vnet/ip/ip6_packet.h +++ b/src/vnet/ip/ip6_packet.h @@ -40,6 +40,7 @@ #ifndef included_ip6_packet_h #define included_ip6_packet_h +#include "vnet/ip/ip_packet.h" #include #include #include @@ -165,8 +166,7 @@ ip6_multicast_ethernet_address (u8 * ethernet_address, u32 group_id) always_inline uword ip6_address_is_equal (const ip6_address_t * a, const ip6_address_t * b) { - int i; - for (i = 0; i < ARRAY_LEN (a->as_uword); i++) + for (uword i = 0; i < ARRAY_LEN (a->as_uword); i++) if (a->as_uword[i] != b->as_uword[i]) return 0; return 1; @@ -177,8 +177,7 @@ ip6_address_is_equal_masked (const ip6_address_t * a, const ip6_address_t * b, const ip6_address_t * mask) { - int i; - for (i = 0; i < ARRAY_LEN (a->as_uword); i++) + for (uword i = 0; i < ARRAY_LEN (a->as_uword); i++) { uword a_masked, b_masked; a_masked = a->as_uword[i] & mask->as_uword[i]; @@ -193,26 +192,24 @@ ip6_address_is_equal_masked (const ip6_address_t * a, always_inline void ip6_address_mask (ip6_address_t * a, const ip6_address_t * mask) { - int i; - for (i = 0; i < ARRAY_LEN (a->as_uword); i++) + for (uword i = 0; i < ARRAY_LEN (a->as_uword); i++) a->as_uword[i] &= mask->as_uword[i]; } always_inline void ip6_address_set_zero (ip6_address_t * a) { - int i; - for (i = 0; i < ARRAY_LEN (a->as_uword); i++) + for (uword i = 0; i < ARRAY_LEN (a->as_uword); i++) a->as_uword[i] = 0; } always_inline void ip6_address_mask_from_width (ip6_address_t * a, u32 width) { - int i, byte, bit, bitnum; + int byte, bit, bitnum; ASSERT (width <= 128); clib_memset (a, 0, sizeof (a[0])); - for (i = 0; i < width; i++) + for (u32 i = 0; i < width; i++) { bitnum = (7 - (i & 7)); byte = i / 8; @@ -224,8 +221,7 @@ ip6_address_mask_from_width (ip6_address_t * a, u32 width) always_inline uword ip6_address_is_zero (const ip6_address_t * a) { - int i; - for (i = 0; i < ARRAY_LEN (a->as_uword); i++) + for (uword i = 0; i < ARRAY_LEN (a->as_uword); i++) if (a->as_uword[i] != 0) return 0; return 1; @@ -317,29 +313,28 @@ typedef struct always_inline ip_dscp_t ip6_traffic_class (const ip6_header_t * i) { - return (i->ip_version_traffic_class_and_flow_label & IP6_PACKET_TC_MASK) >> - 20; + return (ip_dscp_t) ((i->ip_version_traffic_class_and_flow_label & IP6_PACKET_TC_MASK) >> 20); } static_always_inline ip_dscp_t ip6_traffic_class_network_order (const ip6_header_t * ip6) { - return (clib_net_to_host_u32 (ip6->ip_version_traffic_class_and_flow_label) - & IP6_PACKET_TC_MASK) >> 20; + return (ip_dscp_t) ((clib_net_to_host_u32 (ip6->ip_version_traffic_class_and_flow_label) + & IP6_PACKET_TC_MASK) >> 20); } static_always_inline ip_dscp_t ip6_dscp_network_order (const ip6_header_t * ip6) { - return (clib_net_to_host_u32 (ip6->ip_version_traffic_class_and_flow_label) - & IP6_PACKET_DSCP_MASK) >> 22; + return (ip_dscp_t) ((clib_net_to_host_u32 (ip6->ip_version_traffic_class_and_flow_label) + & IP6_PACKET_DSCP_MASK) >> 22); } static_always_inline ip_ecn_t ip6_ecn_network_order (const ip6_header_t * ip6) { - return (clib_net_to_host_u32 (ip6->ip_version_traffic_class_and_flow_label) - & IP6_PACKET_ECN_MASK) >> 20; + return (ip_ecn_t) ((clib_net_to_host_u32 (ip6->ip_version_traffic_class_and_flow_label) + & IP6_PACKET_ECN_MASK) >> 20); } static_always_inline void @@ -544,14 +539,14 @@ ip6_ext_next_header (ip6_ext_header_t * ext_hdr) always_inline void * ip6_ext_next_header_offset (void *hdr, u16 offset) { - return (hdr + offset); + return (u8 *) hdr + offset; } always_inline int vlib_object_within_buffer_data (vlib_main_t * vm, vlib_buffer_t * b, void *obj, size_t len) { - u8 *o = obj; + u8 *o = (u8 *) obj; if (o < b->data || o + len > b->data + vlib_buffer_get_default_data_size (vm)) return 0; @@ -576,7 +571,7 @@ ip6_ext_next_header_s (ip_protocol_t cur_nh, void *hdr, u32 max_offset, { hdrlen = ip6_ext_header_len (hdr); new_nh = ((ip6_ext_header_t *) hdr)->next_hdr; - res = hdr + hdrlen; + res = (u8 *) hdr + hdrlen; } else if (cur_nh == IP_PROTOCOL_IPV6_FRAGMENTATION) { @@ -585,13 +580,13 @@ ip6_ext_next_header_s (ip_protocol_t cur_nh, void *hdr, u32 max_offset, *last = true; new_nh = frag_hdr->next_hdr; hdrlen = sizeof (ip6_frag_hdr_t); - res = hdr + hdrlen; + res = (u8 *) hdr + hdrlen; } else if (cur_nh == IP_PROTOCOL_IPSEC_AH) { new_nh = ((ip6_ext_header_t *) hdr)->next_hdr; hdrlen = ip6_ext_authhdr_len (hdr); - res = hdr + hdrlen; + res = (u8 *) hdr + hdrlen; } else { @@ -608,7 +603,7 @@ ip6_ext_next_header_s (ip_protocol_t cur_nh, void *hdr, u32 max_offset, } #define IP6_EXT_HDR_MAX (4) /* Maximum number of headers */ -#define IP6_EXT_HDR_MAX_DEPTH (256) /* Maximum header depth */ +#define IP6_EXT_HDR_MAX_DEPTH (256U) /* Maximum header depth */ typedef struct { int length; @@ -644,7 +639,7 @@ ip6_ext_header_walk (vlib_buffer_t *b, ip6_header_t *ip, int find_hdr_type, sizeof (ip6_header_t) + clib_net_to_host_u16 (ip->payload_length)); u32 offset = sizeof (ip6_header_t); - if ((ip6_ext_header_len_s (ip->protocol, next_header) + offset) > max_offset) + if ((ip6_ext_header_len_s ((ip_protocol_t) ip->protocol, next_header) + offset) > max_offset) { return -1; } @@ -661,7 +656,7 @@ ip6_ext_header_walk (vlib_buffer_t *b, ip6_header_t *ip, int find_hdr_type, break; if (i >= IP6_EXT_HDR_MAX) break; - next_header = ip6_ext_next_header_s (next_proto, next_header, max_offset, + next_header = ip6_ext_next_header_s ((ip_protocol_t) next_proto, next_header, max_offset, &offset, &next_proto, &last); } res->length = i; @@ -683,7 +678,7 @@ ip6_ext_header_find (vlib_main_t *vm, vlib_buffer_t *b, ip6_header_t *ip, { if (res > 0) { - *prev_ext_header = + *prev_ext_header = (ip6_ext_header_t *) ip6_ext_next_header_offset (ip, hdr_chain.eh[res - 1].offset); } else diff --git a/src/vnet/ip/ip_flow_hash.h b/src/vnet/ip/ip_flow_hash.h index 30dfcd70a1b7..486a173803d2 100644 --- a/src/vnet/ip/ip_flow_hash.h +++ b/src/vnet/ip/ip_flow_hash.h @@ -19,7 +19,7 @@ #include /** Default: 5-tuple + flowlabel without the "reverse" bit */ -#define IP_FLOW_HASH_DEFAULT (0x9F) +#define IP_FLOW_HASH_DEFAULT (flow_hash_config_t)(0x9F) #define foreach_flow_hash_bit_v1 \ _ (src, IP_FLOW_HASH_SRC_ADDR) \ diff --git a/src/vnet/ip/ip_interface.h b/src/vnet/ip/ip_interface.h index f0034ed03147..dd8406e0d323 100644 --- a/src/vnet/ip/ip_interface.h +++ b/src/vnet/ip/ip_interface.h @@ -79,9 +79,9 @@ do { \ > (_sw_if_index)) ? \ vec_elt ((lm)->if_address_pool_index_by_sw_if_index, \ (_sw_if_index)) : \ - (u32)~0); \ + ~0U); \ ip_interface_address_t * _a; \ - while (_ia != ~0) \ + while (_ia != ~0U) \ { \ _a = pool_elt_at_index ((lm)->if_address_pool, _ia); \ _ia = _a->next_this_sw_interface; \ diff --git a/src/vnet/ip/ip_packet.h b/src/vnet/ip/ip_packet.h index 04cf9f11d70c..b2b27cb88f47 100755 --- a/src/vnet/ip/ip_packet.h +++ b/src/vnet/ip/ip_packet.h @@ -184,7 +184,7 @@ ip_csum_sub_even (ip_csum_t c, ip_csum_t x) } always_inline ip_csum_t -ip_csum_update_inline (ip_csum_t sum, ip_csum_t old, ip_csum_t new, +ip_csum_update_inline (ip_csum_t sum, ip_csum_t old, ip_csum_t _new, u32 field_byte_offset, u32 field_n_bytes) { /* For even 1-byte fields on big-endian and odd 1-byte fields on little endian @@ -193,15 +193,15 @@ ip_csum_update_inline (ip_csum_t sum, ip_csum_t old, ip_csum_t new, && (field_byte_offset % 2) == CLIB_ARCH_IS_LITTLE_ENDIAN) { old = old << 8; - new = new << 8; + _new = _new << 8; } sum = ip_csum_sub_even (sum, old); - sum = ip_csum_add_even (sum, new); + sum = ip_csum_add_even (sum, _new); return sum; } -#define ip_csum_update(sum,old,new,type,field) \ - ip_csum_update_inline ((sum), (old), (new), \ +#define ip_csum_update(sum,old,_new,type,field) \ + ip_csum_update_inline ((sum), (old), (_new), \ STRUCT_OFFSET_OF (type, field), \ STRUCT_SIZE_OF (type, field)) diff --git a/src/vnet/ip/punt.c b/src/vnet/ip/punt.c index 3c46549634a5..7d0142ddd257 100644 --- a/src/vnet/ip/punt.c +++ b/src/vnet/ip/punt.c @@ -916,11 +916,11 @@ punt_config (vlib_main_t * vm, unformat_input_t * input) /* Register socket */ clib_file_main_t *fm = &file_main; - clib_file_t template = { 0 }; - template.read_function = punt_socket_read_ready; - template.file_descriptor = pm->socket_fd; - template.description = format (0, "punt socket %s", socket_path); - pm->clib_file_index = clib_file_add (fm, &template); + clib_file_t _template = { 0 }; + _template.read_function = punt_socket_read_ready; + _template.file_descriptor = pm->socket_fd; + _template.description = format (0, "punt socket %s", socket_path); + pm->clib_file_index = clib_file_add (fm, &_template); pm->is_configured = true; diff --git a/src/vnet/ip/vtep.h b/src/vnet/ip/vtep.h index 97e74429e880..9336975dbf9d 100644 --- a/src/vnet/ip/vtep.h +++ b/src/vnet/ip/vtep.h @@ -65,7 +65,7 @@ always_inline vtep_table_t vtep_table_create () { vtep_table_t t = { }; - t.vtep6 = hash_create_mem (0, sizeof (vtep6_key_t), sizeof (uword)); + t.vtep6 = (uword *) hash_create_mem (0, sizeof (vtep6_key_t), sizeof (uword)); return t; } diff --git a/src/vnet/l2/feat_bitmap.h b/src/vnet/l2/feat_bitmap.h index a1b295ac4ac2..9f95fc5f39ec 100644 --- a/src/vnet/l2/feat_bitmap.h +++ b/src/vnet/l2/feat_bitmap.h @@ -18,6 +18,7 @@ #ifndef included_vnet_l2_feat_bitmap_h #define included_vnet_l2_feat_bitmap_h +#include "vppinfra/clib.h" #include #include @@ -59,7 +60,7 @@ feat_bitmap_init_next_nodes (vlib_main_t * vm, u32 node_index, /* the current gr else { // Node may be in plugin which is not installed, use drop node next_nodes[idx] = - vlib_node_add_named_next (vm, node_index, "feature-bitmap-drop"); + vlib_node_add_named_next (vm, node_index, __clib_strdup("feature-bitmap-drop")); } } @@ -67,7 +68,7 @@ feat_bitmap_init_next_nodes (vlib_main_t * vm, u32 node_index, /* the current gr for (; idx < FEAT_MAX; idx++) { next_nodes[idx] = vlib_node_add_named_next (vm, node_index, - "feature-bitmap-drop"); + __clib_strdup("feature-bitmap-drop")); } } diff --git a/src/vnet/l2/l2_bd.h b/src/vnet/l2/l2_bd.h index 082d210b9725..65c37b3fd618 100644 --- a/src/vnet/l2/l2_bd.h +++ b/src/vnet/l2/l2_bd.h @@ -203,7 +203,7 @@ static inline u32 bd_find_or_add_bd_index (bd_main_t * bdm, u32 bd_id) { u32 bd_index = bd_find_index (bdm, bd_id); - if (bd_index == ~0) + if (bd_index == ~0U) return bd_add_bd_index (bdm, bd_id); return bd_index; } diff --git a/src/vnet/l2/l2_input.h b/src/vnet/l2/l2_input.h index 3de1537b45e5..48344b2d6c21 100644 --- a/src/vnet/l2/l2_input.h +++ b/src/vnet/l2/l2_input.h @@ -298,7 +298,7 @@ vnet_update_l2_len (vlib_buffer_t *b) u8 vlan_count = 0; /* point at current l2 hdr */ - eth = vlib_buffer_get_current (b); + eth = (ethernet_header_t *) vlib_buffer_get_current (b); /* * l2-output pays no attention to this @@ -313,7 +313,7 @@ vnet_update_l2_len (vlib_buffer_t *b) ethernet_vlan_header_t *vlan; vnet_buffer (b)->l2.l2_len += sizeof (*vlan); vlan_count = 1; - vlan = (void *) (eth + 1); + vlan = (ethernet_vlan_header_t *) (eth + 1); ethertype = clib_net_to_host_u16 (vlan->type); if (ethertype == ETHERNET_TYPE_VLAN) { @@ -335,7 +335,7 @@ vnet_update_l2_len (vlib_buffer_t *b) static inline u32 vnet_l2_compute_flow_hash (vlib_buffer_t * b) { - ethernet_header_t *eh = vlib_buffer_get_current (b); + ethernet_header_t *eh = (ethernet_header_t *) vlib_buffer_get_current (b); u8 *l3h = (u8 *) eh + vnet_buffer (b)->l2.l2_len; u16 ethertype = clib_net_to_host_u16 (*(u16 *) (l3h - 2)); @@ -345,7 +345,7 @@ vnet_l2_compute_flow_hash (vlib_buffer_t * b) return ip6_compute_flow_hash ((ip6_header_t *) l3h, IP_FLOW_HASH_DEFAULT); else if (ethertype == ETHERNET_TYPE_MPLS) return mpls_compute_flow_hash ((mpls_unicast_header_t *) l3h, - IP_FLOW_HASH_DEFAULT); + IP_FLOW_HASH_DEFAULT); else { u32 a, b, c; diff --git a/src/vnet/l2/l2_vtr.h b/src/vnet/l2/l2_vtr.h index 40285873273d..8b277eeb6b61 100644 --- a/src/vnet/l2/l2_vtr.h +++ b/src/vnet/l2/l2_vtr.h @@ -78,7 +78,7 @@ l2_vtr_process (vlib_buffer_t * b0, vtr_config_t * config) u8 *eth; u8 save_macs[12]; - eth = vlib_buffer_get_current (b0); + eth = (u8 *) vlib_buffer_get_current (b0); /* copy the 12B dmac and smac to a temporary location */ clib_memcpy_fast (save_macs, eth, sizeof (save_macs)); @@ -142,7 +142,7 @@ l2_efp_filter_process (vlib_buffer_t * b0, vtr_config_t * in_config) u64 packet_tags; u64 tag_mask; - eth = vlib_buffer_get_current (b0); + eth = (u8 *) vlib_buffer_get_current (b0); /* * If there are 2 tags pushed, they must match config->tags[0] and @@ -198,7 +198,7 @@ typedef struct always_inline u32 l2_pbb_process (vlib_buffer_t * b0, ptr_config_t * config) { - u8 *eth = vlib_buffer_get_current (b0); + u8 *eth = (u8 *) vlib_buffer_get_current (b0); if (config->pop_bytes > 0) { diff --git a/src/vnet/pg/edit.h b/src/vnet/pg/edit.h index 3bfdad575f54..a78efdf065e3 100644 --- a/src/vnet/pg/edit.h +++ b/src/vnet/pg/edit.h @@ -90,8 +90,7 @@ typedef struct always_inline void pg_edit_free (pg_edit_t * e) { - int i; - for (i = 0; i < ARRAY_LEN (e->values); i++) + for (uword i = 0; i < ARRAY_LEN (e->values); i++) vec_free (e->values[i]); } @@ -159,10 +158,9 @@ pg_edit_set_fixed (pg_edit_t * e, u64 value) static inline void pg_edit_copy_type_and_values (pg_edit_t * dst, pg_edit_t * src) { - int i; dst->type = src->type; src->type = PG_EDIT_INVALID_TYPE; - for (i = 0; i < ARRAY_LEN (dst->values); i++) + for (uword i = 0; i < ARRAY_LEN (dst->values); i++) { dst->values[i] = src->values[i]; src->values[i] = 0; diff --git a/src/vnet/pg/pg.h b/src/vnet/pg/pg.h index 7c5d698349bc..2685b73c5745 100644 --- a/src/vnet/pg/pg.h +++ b/src/vnet/pg/pg.h @@ -229,7 +229,6 @@ pg_edit_group_free (pg_edit_group_t * g) always_inline void pg_stream_free (pg_stream_t * s) { - int i; pg_edit_group_t *g; pg_edit_t *e; vec_foreach (e, s->non_fixed_edits) pg_edit_free (e); @@ -239,7 +238,7 @@ pg_stream_free (pg_stream_t * s) vec_free (s->fixed_packet_data); vec_free (s->fixed_packet_data_mask); vec_free (s->name); - for (i = 0; i < vec_len (s->replay_packet_templates); i++) + for (uword i = 0; i < vec_len (s->replay_packet_templates); i++) vec_free (s->replay_packet_templates[i]); vec_free (s->replay_packet_templates); vec_free (s->replay_packet_timestamps); diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c index eacc1adf9418..5ad23f19b1c4 100644 --- a/src/vnet/session/application.c +++ b/src/vnet/session/application.c @@ -579,7 +579,7 @@ app_rx_mq_fd_write_ready (clib_file_t *cf) static void app_rx_mqs_epoll_add (application_t *app, app_rx_mq_elt_t *mqe) { - clib_file_t template = { 0 }; + clib_file_t _template = { 0 }; app_rx_mq_handle_t handle; u32 thread_index; int fd; @@ -590,14 +590,14 @@ app_rx_mqs_epoll_add (application_t *app, app_rx_mq_elt_t *mqe) handle.app_index = app->app_index; handle.thread_index = thread_index; - template.read_function = app_rx_mq_fd_read_ready; - template.write_function = app_rx_mq_fd_write_ready; - template.file_descriptor = fd; - template.private_data = handle.as_u64; - template.polling_thread_index = thread_index; - template.description = + _template.read_function = app_rx_mq_fd_read_ready; + _template.write_function = app_rx_mq_fd_write_ready; + _template.file_descriptor = fd; + _template.private_data = handle.as_u64; + _template.polling_thread_index = thread_index; + _template.description = format (0, "app-%u-rx-mq-%u", app->app_index, thread_index); - mqe->file_index = clib_file_add (&file_main, &template); + mqe->file_index = clib_file_add (&file_main, &_template); } static void diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h index d6c5cbc60851..d2710ec3c849 100644 --- a/src/vnet/session/session.h +++ b/src/vnet/session/session.h @@ -696,7 +696,7 @@ session_enqueue_chain_tail (session_t *s, vlib_buffer_t *b, u32 offset, while (chain_b) { vec_add2 (wrk->rx_segs, seg, 1); - seg->data = vlib_buffer_get_current (chain_b); + seg->data = (u8 *) vlib_buffer_get_current (chain_b); seg->len = chain_b->current_length; chain_b = (chain_b->flags & VLIB_BUFFER_NEXT_PRESENT) ? vlib_get_buffer (wrk->vm, chain_b->next_buffer) : @@ -723,7 +723,7 @@ session_enqueue_chain_tail (session_t *s, vlib_buffer_t *b, u32 offset, do { chain_b = vlib_get_buffer (vm, chain_bi); - data = vlib_buffer_get_current (chain_b); + data = (u8 *) vlib_buffer_get_current (chain_b); len = chain_b->current_length; if (!len) continue; @@ -770,7 +770,7 @@ session_enqueue_stream_connection (transport_connection_t *tc, if (is_in_order) { enqueued = svm_fifo_enqueue (s->rx_fifo, b->current_length, - vlib_buffer_get_current (b)); + (u8 *) vlib_buffer_get_current (b)); if (PREDICT_FALSE ((b->flags & VLIB_BUFFER_NEXT_PRESENT) && enqueued >= 0)) { @@ -783,7 +783,7 @@ session_enqueue_stream_connection (transport_connection_t *tc, else { rv = svm_fifo_enqueue_with_offset (s->rx_fifo, offset, b->current_length, - vlib_buffer_get_current (b)); + (u8 *) vlib_buffer_get_current (b)); if (PREDICT_FALSE ((b->flags & VLIB_BUFFER_NEXT_PRESENT) && !rv)) session_enqueue_chain_tail (s, b, offset + b->current_length, 0); /* if something was enqueued, report even this as success for ooo @@ -799,7 +799,7 @@ session_enqueue_stream_connection (transport_connection_t *tc, { session_worker_t *wrk = session_main_get_worker (s->thread_index); ASSERT (s->thread_index == vlib_get_thread_index ()); - s->flags |= SESSION_F_RX_EVT; + s->flags = (session_flags_t)(s->flags | SESSION_F_RX_EVT); vec_add1 (wrk->session_to_enqueue[tc->proto], session_handle (s)); } @@ -823,7 +823,7 @@ session_enqueue_dgram_connection_inline (session_t *s, if (PREDICT_TRUE (!(b->flags & VLIB_BUFFER_NEXT_PRESENT))) { svm_fifo_seg_t segs[2] = { { (u8 *) hdr, sizeof (*hdr) }, - { vlib_buffer_get_current (b), + { (u8 *) vlib_buffer_get_current (b), b->current_length } }; rv = @@ -842,7 +842,7 @@ session_enqueue_dgram_connection_inline (session_t *s, while (it) { vec_add2 (segs, seg, 1); - seg->data = vlib_buffer_get_current (it); + seg->data = (u8 *) vlib_buffer_get_current (it); seg->len = it->current_length; n_segs++; if (!(it->flags & VLIB_BUFFER_NEXT_PRESENT)) @@ -864,7 +864,7 @@ session_enqueue_dgram_connection_inline (session_t *s, is_cl ? vlib_get_thread_index () : s->thread_index; session_worker_t *wrk = session_main_get_worker (thread_index); ASSERT (s->thread_index == vlib_get_thread_index () || is_cl); - s->flags |= SESSION_F_RX_EVT; + s->flags = (session_flags_t)(s->flags | SESSION_F_RX_EVT); vec_add1 (wrk->session_to_enqueue[proto], session_handle (s)); } @@ -982,7 +982,8 @@ transport_add_tx_event (transport_connection_t * tc) session_t *s = session_get (tc->s_index, tc->thread_index); if (svm_fifo_has_event (s->tx_fifo)) return; - session_program_tx_io_evt (s->handle, SESSION_IO_EVT_TX); + session_handle_tu_t *h = (session_handle_tu_t*) &(s->handle); + session_program_tx_io_evt (*h, SESSION_IO_EVT_TX); } always_inline u32 @@ -1013,14 +1014,16 @@ listen_session_get_handle (session_t *s) always_inline session_t * listen_session_get_from_handle (session_handle_t handle) { - return session_get_from_handle (handle); + session_handle_tu_t *h = (session_handle_tu_t*) &(handle); + return session_get_from_handle (*h); } always_inline void listen_session_parse_handle (session_handle_t handle, u32 * index, u32 * thread_index) { - session_parse_handle (handle, index, thread_index); + session_handle_tu_t *h = (session_handle_tu_t*) &(handle); + session_parse_handle (*h, index, thread_index); } always_inline session_t * @@ -1053,7 +1056,7 @@ ho_session_alloc (void) ASSERT (session_vlib_thread_is_cl_thread ()); s = session_alloc (transport_cl_thread ()); s->session_state = SESSION_STATE_CONNECTING; - s->flags |= SESSION_F_HALF_OPEN; + s->flags = (session_flags_t) (s->flags | SESSION_F_HALF_OPEN); return s; } @@ -1124,7 +1127,7 @@ typedef struct STATIC_ASSERT_SIZEOF (pool_safe_realloc_header_t, sizeof (pool_header_t)); -#define POOL_REALLOC_SAFE_ELT_THRESH 32 +#define POOL_REALLOC_SAFE_ELT_THRESH 32UL #define pool_realloc_flag(PH) \ ((pool_safe_realloc_header_t *) pool_header (PH))->flag @@ -1170,14 +1173,14 @@ pool_program_safe_realloc (void **p, u32 elt_size, u32 align) if (pool_realloc_flag (*p)) return; - pra = clib_mem_alloc (sizeof (*pra)); + pra = (pool_realloc_rpc_args_t *) clib_mem_alloc (sizeof (*pra)); pra->pool = p; pra->elt_size = elt_size; pra->align = align; pool_realloc_flag (*p) = 1; session_send_rpc_evt_to_thread (0 /* thread index */, - pool_program_safe_realloc_rpc, pra); + (void *) pool_program_safe_realloc_rpc, pra); } #define pool_needs_realloc(P) \ diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c index 5ac21c4eb851..ed924a7cc8f1 100644 --- a/src/vnet/session/session_api.c +++ b/src/vnet/session/session_api.c @@ -35,11 +35,11 @@ VLIB_REGISTER_LOG_CLASS (session_api_log, static) = { .class_name = "session", .subclass_name = "api" }; #define log_debug(fmt, ...) \ - vlib_log_debug (session_api_log.class, "%s: " fmt, __func__, __VA_ARGS__) + vlib_log_debug (session_api_log._class, "%s: " fmt, __func__, __VA_ARGS__) #define log_warn(fmt, ...) \ - vlib_log_warn (session_api_log.class, fmt, __VA_ARGS__) + vlib_log_warn (session_api_log._class, fmt, __VA_ARGS__) #define log_err(fmt, ...) \ - vlib_log_err (session_api_log.class, fmt, __VA_ARGS__) + vlib_log_err (session_api_log._class, fmt, __VA_ARGS__) static int verify_message_len (void *mp, u64 expected_len, char *where) diff --git a/src/vnet/session/session_node.c b/src/vnet/session/session_node.c index 7c5ab27e5429..5b434a26f32b 100644 --- a/src/vnet/session/session_node.c +++ b/src/vnet/session/session_node.c @@ -2120,19 +2120,19 @@ void session_wrk_enable_adaptive_mode (session_worker_t *wrk) { u32 thread_index = wrk->vm->thread_index; - clib_file_t template = { 0 }; + clib_file_t _template = { 0 }; if ((wrk->timerfd = timerfd_create (CLOCK_MONOTONIC, TFD_NONBLOCK)) < 0) clib_warning ("timerfd_create"); - template.read_function = session_wrk_tfd_read_ready; - template.write_function = session_wrk_tfd_write_ready; - template.file_descriptor = wrk->timerfd; - template.private_data = thread_index; - template.polling_thread_index = thread_index; - template.description = format (0, "session-wrk-tfd-%u", thread_index); + _template.read_function = session_wrk_tfd_read_ready; + _template.write_function = session_wrk_tfd_write_ready; + _template.file_descriptor = wrk->timerfd; + _template.private_data = thread_index; + _template.polling_thread_index = thread_index; + _template.description = format (0, "session-wrk-tfd-%u", thread_index); - wrk->timerfd_file = clib_file_add (&file_main, &template); + wrk->timerfd_file = clib_file_add (&file_main, &_template); wrk->flags |= SESSION_WRK_F_ADAPTIVE; } diff --git a/src/vnet/session/session_rules_table.c b/src/vnet/session/session_rules_table.c index acb575b0f7cf..51f334f48c03 100644 --- a/src/vnet/session/session_rules_table.c +++ b/src/vnet/session/session_rules_table.c @@ -27,10 +27,10 @@ VLIB_REGISTER_LOG_CLASS (session_rt_log, static) = { .class_name = "session", .subclass_name = "rt" }; #define log_debug(fmt, ...) \ - vlib_log_debug (session_rt_log.class, "%s: " fmt, __func__, __VA_ARGS__) + vlib_log_debug (session_rt_log._class, "%s: " fmt, __func__, __VA_ARGS__) #define log_warn(fmt, ...) \ - vlib_log_warn (session_rt_log.class, fmt, __VA_ARGS__) -#define log_err(fmt, ...) vlib_log_err (session_rt_log.class, fmt, __VA_ARGS__) + vlib_log_warn (session_rt_log._class, fmt, __VA_ARGS__) +#define log_err(fmt, ...) vlib_log_err (session_rt_log._class, fmt, __VA_ARGS__) static session_rules_table_group_t *srt_instances; const session_rt_engine_vft_t *session_rt_engine_vft; diff --git a/src/vnet/session/session_sdl.c b/src/vnet/session/session_sdl.c index a18674cd83b1..a66f93a51748 100644 --- a/src/vnet/session/session_sdl.c +++ b/src/vnet/session/session_sdl.c @@ -23,11 +23,11 @@ VLIB_REGISTER_LOG_CLASS (session_sdl_log, static) = { .class_name = "session", .subclass_name = "sdl" }; #define log_debug(fmt, ...) \ - vlib_log_debug (session_sdl_log.class, "%s: " fmt, __func__, __VA_ARGS__) + vlib_log_debug (session_sdl_log._class, "%s: " fmt, __func__, __VA_ARGS__) #define log_warn(fmt, ...) \ - vlib_log_warn (session_sdl_log.class, fmt, __VA_ARGS__) + vlib_log_warn (session_sdl_log._class, fmt, __VA_ARGS__) #define log_err(fmt, ...) \ - vlib_log_err (session_sdl_log.class, fmt, __VA_ARGS__) + vlib_log_err (session_sdl_log._class, fmt, __VA_ARGS__) static session_sdl_main_t sdl_main; static session_sdl_main_t *sdlm = &sdl_main; diff --git a/src/vnet/session/session_types.h b/src/vnet/session/session_types.h index 935f8f189eeb..2c74b18b17b9 100644 --- a/src/vnet/session/session_types.h +++ b/src/vnet/session/session_types.h @@ -258,13 +258,13 @@ typedef struct session_ always_inline session_type_t session_type_from_proto_and_ip (transport_proto_t proto, u8 is_ip4) { - return (proto << 1 | is_ip4); + return (transport_proto_t) (proto << 1 | is_ip4); } always_inline transport_proto_t session_type_transport_proto (session_type_t st) { - return (st >> 1); + return (transport_proto_t) (st >> 1); } always_inline u8 @@ -276,7 +276,7 @@ session_type_is_ip4 (session_type_t st) always_inline transport_proto_t session_get_transport_proto (session_t * s) { - return (s->session_type >> 1); + return (transport_proto_t) (s->session_type >> 1); } always_inline fib_protocol_t diff --git a/src/vnet/udp/udp_inlines.h b/src/vnet/udp/udp_inlines.h index ceec0b191b17..fa6c9c4a327d 100644 --- a/src/vnet/udp/udp_inlines.h +++ b/src/vnet/udp/udp_inlines.h @@ -33,7 +33,7 @@ vlib_buffer_push_udp (vlib_buffer_t *b, u16 sp, u16 dp) if (PREDICT_FALSE (b->flags & VLIB_BUFFER_TOTAL_LENGTH_VALID)) udp_len += b->total_length_not_including_first_buffer; - uh = vlib_buffer_push_uninit (b, sizeof (udp_header_t)); + uh = (udp_header_t *) vlib_buffer_push_uninit (b, sizeof (udp_header_t)); uh->src_port = sp; uh->dst_port = dp; uh->checksum = 0; @@ -86,7 +86,7 @@ ip_udp_fixup_one (vlib_main_t *vm, vlib_buffer_t *b0, u8 is_ip4, ip_csum_t sum0; u16 old_l0 = 0; - ip0 = vlib_buffer_get_current (b0); + ip0 = (ip4_header_t *) vlib_buffer_get_current (b0); /* fix the ing outer-IP checksum */ sum0 = ip0->checksum; @@ -112,7 +112,7 @@ ip_udp_fixup_one (vlib_main_t *vm, vlib_buffer_t *b0, u8 is_ip4, ip6_header_t *ip0; int bogus0; - ip0 = vlib_buffer_get_current (b0); + ip0 = (ip6_header_t *) vlib_buffer_get_current (b0); new_l0 = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0) - sizeof (*ip0)); @@ -159,7 +159,7 @@ ip_udp_encap_one (vlib_main_t *vm, vlib_buffer_t *b0, u8 *ec0, word ec_len, { ip4_header_t *ip0; - ip0 = vlib_buffer_get_current (b0); + ip0 = (ip4_header_t *) vlib_buffer_get_current (b0); /* Apply the encap string. */ clib_memcpy_fast (ip0, ec0, ec_len); @@ -169,7 +169,7 @@ ip_udp_encap_one (vlib_main_t *vm, vlib_buffer_t *b0, u8 *ec0, word ec_len, { ip6_header_t *ip0; - ip0 = vlib_buffer_get_current (b0); + ip0 = (ip6_header_t *) vlib_buffer_get_current (b0); /* Apply the encap string. */ clib_memcpy_fast (ip0, ec0, ec_len); @@ -214,8 +214,8 @@ ip_udp_encap_two (vlib_main_t *vm, vlib_buffer_t *b0, vlib_buffer_t *b1, ip_csum_t sum0, sum1; u16 old_l0 = 0, old_l1 = 0; - ip0 = vlib_buffer_get_current (b0); - ip1 = vlib_buffer_get_current (b1); + ip0 = (ip4_header_t *) vlib_buffer_get_current (b0); + ip1 = (ip4_header_t *) vlib_buffer_get_current (b1); /* Apply the encap string */ clib_memcpy_fast (ip0, ec0, ec_len); @@ -263,8 +263,8 @@ ip_udp_encap_two (vlib_main_t *vm, vlib_buffer_t *b0, vlib_buffer_t *b1, ip6_header_t *ip0, *ip1; int bogus0, bogus1; - ip0 = vlib_buffer_get_current (b0); - ip1 = vlib_buffer_get_current (b1); + ip0 = (ip6_header_t *) vlib_buffer_get_current (b0); + ip1 = (ip6_header_t *) vlib_buffer_get_current (b1); /* Apply the encap string. */ clib_memcpy_fast (ip0, ec0, ec_len); diff --git a/src/vnet/unix/tuntap.c b/src/vnet/unix/tuntap.c index f1102dc321e8..4212c6ddbc5b 100644 --- a/src/vnet/unix/tuntap.c +++ b/src/vnet/unix/tuntap.c @@ -650,11 +650,11 @@ tuntap_config (vlib_main_t * vm, unformat_input_t * input) } { - clib_file_t template = { 0 }; - template.read_function = tuntap_read_ready; - template.file_descriptor = tm->dev_net_tun_fd; - template.description = format (0, "vnet tuntap"); - tm->clib_file_index = clib_file_add (&file_main, &template); + clib_file_t _template = { 0 }; + _template.read_function = tuntap_read_ready; + _template.file_descriptor = tm->dev_net_tun_fd; + _template.description = format (0, "vnet tuntap"); + tm->clib_file_index = clib_file_add (&file_main, &_template); } done: diff --git a/src/vpp/api/api.c b/src/vpp/api/api.c index 6041b066578f..3750960ac675 100644 --- a/src/vpp/api/api.c +++ b/src/vpp/api/api.c @@ -189,7 +189,7 @@ vl_api_log_dump_t_handler (vl_api_log_dump_t * mp) if (start_time <= e->timestamp + time_offset) show_log_details (reg, mp->context, e->timestamp + time_offset, (vl_api_log_level_t *) & e->level, - format (0, "%U", format_vlib_log_class, e->class), + format (0, "%U", format_vlib_log_class, e->_class), e->string); i = (i + 1) % lm->size; } diff --git a/src/vppinfra/atomics.h b/src/vppinfra/atomics.h index 92c456103915..b00121a7dfa8 100644 --- a/src/vppinfra/atomics.h +++ b/src/vppinfra/atomics.h @@ -34,12 +34,12 @@ #define clib_atomic_or_fetch(a, b) __sync_or_and_fetch(a, b) #define clib_atomic_nand_fetch(a, b) __sync_nand_and_fetch(a, b) -#define clib_atomic_cmp_and_swap(addr,old,new) __sync_val_compare_and_swap(addr, old, new) -#define clib_atomic_bool_cmp_and_swap(addr,old,new) __sync_bool_compare_and_swap(addr, old, new) +#define clib_atomic_cmp_and_swap(addr,old,_new) __sync_val_compare_and_swap(addr, old, _new) +#define clib_atomic_bool_cmp_and_swap(addr,old,_new) __sync_bool_compare_and_swap(addr, old, _new) -#define clib_atomic_cmp_and_swap_acq_relax_n(addr,exp,new,weak) __atomic_compare_exchange_n ((addr), (exp), (new), (weak), __ATOMIC_ACQUIRE, __ATOMIC_RELAXED) -#define clib_atomic_cmp_and_swap_acq_relax(addr, exp, new, weak) \ - __atomic_compare_exchange ((addr), (exp), (new), (weak), __ATOMIC_ACQUIRE, \ +#define clib_atomic_cmp_and_swap_acq_relax_n(addr,exp,_new,weak) __atomic_compare_exchange_n ((addr), (exp), (_new), (weak), __ATOMIC_ACQUIRE, __ATOMIC_RELAXED) +#define clib_atomic_cmp_and_swap_acq_relax(addr, exp, _new, weak) \ + __atomic_compare_exchange ((addr), (exp), (_new), (weak), __ATOMIC_ACQUIRE, \ __ATOMIC_RELAXED) #define clib_atomic_test_and_set(a) __atomic_exchange_n(a, 1, __ATOMIC_ACQUIRE) diff --git a/src/vppinfra/bihash_template.h b/src/vppinfra/bihash_template.h index 8f5879b46348..8cd6b531d3e8 100644 --- a/src/vppinfra/bihash_template.h +++ b/src/vppinfra/bihash_template.h @@ -413,7 +413,7 @@ static inline int BV (clib_bihash_search_inline_with_hash) static const BVT (clib_bihash_bucket) mask = { .linear_search = 1, - .log2_pages = -1 + .log2_pages = (u8) -1 }; #if BIHASH_LAZY_INSTANTIATE @@ -433,7 +433,7 @@ static inline int BV (clib_bihash_search_inline_with_hash) CLIB_PAUSE (); } - v = BV (clib_bihash_get_value) (h, b->offset); + v = (BVT (clib_bihash_value) *) BV (clib_bihash_get_value) (h, b->offset); /* If the bucket has unresolvable collisions, use linear search */ limit = BIHASH_KVP_PER_PAGE; @@ -494,7 +494,7 @@ static inline void BV (clib_bihash_prefetch_data) if (PREDICT_FALSE (BV (clib_bihash_bucket_is_empty) (b))) return; - v = BV (clib_bihash_get_value) (h, b->offset); + v = (BVT (clib_bihash_value) *) BV (clib_bihash_get_value) (h, b->offset); if (PREDICT_FALSE (b->log2_pages && b->linear_search == 0)) v += extract_bits (hash, h->log2_nbuckets, b->log2_pages); @@ -514,7 +514,7 @@ static inline int BV (clib_bihash_search_inline_2_with_hash) static const BVT (clib_bihash_bucket) mask = { .linear_search = 1, - .log2_pages = -1 + .log2_pages = (u8) -1 }; ASSERT (valuep); @@ -536,7 +536,7 @@ static inline int BV (clib_bihash_search_inline_2_with_hash) CLIB_PAUSE (); } - v = BV (clib_bihash_get_value) (h, b->offset); + v = (BVT (clib_bihash_value) *) BV (clib_bihash_get_value) (h, b->offset); /* If the bucket has unresolvable collisions, use linear search */ limit = BIHASH_KVP_PER_PAGE; diff --git a/src/vppinfra/bitmap.h b/src/vppinfra/bitmap.h index 4ab7bcf7a7c6..3d902baeaae2 100644 --- a/src/vppinfra/bitmap.h +++ b/src/vppinfra/bitmap.h @@ -586,7 +586,7 @@ always_inline uword *clib_bitmap_dup_xor (uword * ai, uword * bi); #define _(name) \ always_inline uword * \ clib_bitmap_dup_##name (uword * ai, uword * bi) \ -{ return clib_bitmap_##name (clib_bitmap_dup (ai), bi); } +{ return clib_bitmap_##name ((uword *) clib_bitmap_dup (ai), bi); } _(and); _(andnot); diff --git a/src/vppinfra/byte_order.h b/src/vppinfra/byte_order.h index 7bc26002a2f6..e28303817505 100644 --- a/src/vppinfra/byte_order.h +++ b/src/vppinfra/byte_order.h @@ -126,7 +126,6 @@ always_inline type \ clib_##sex##_to_host_unaligned_mem_##type (type * x) \ { return clib_host_to_##sex##_unaligned_mem_##type (x); } -#ifndef __cplusplus _(little, u16) _(little, u32) _(little, u64) @@ -134,7 +133,6 @@ _(little, i16) _(little, i32) _(little, i64) _(big, u16) _(big, u32) _(big, u64) _(big, i16) _(big, i32) _(big, i64) -#endif #undef _ /* Network "net" alias for "big". */ #define _(type) \ @@ -161,14 +159,12 @@ clib_host_to_net_mem_##type (type * x) \ always_inline type \ clib_host_to_net_unaligned_mem_##type (type * x) \ { return clib_host_to_big_unaligned_mem_##type (x); } -#ifndef __cplusplus - _(u16); +_(u16); _(i16); _(u32); _(i32); _(u64); _(i64); -#endif #undef _ diff --git a/src/vppinfra/cache.h b/src/vppinfra/cache.h index 13778a423fd9..a9e9c2f1b414 100644 --- a/src/vppinfra/cache.h +++ b/src/vppinfra/cache.h @@ -87,7 +87,7 @@ #define CLIB_PREFETCH(addr, size, type) \ do \ { \ - void *_addr = (addr); \ + u8 *_addr = (u8 *) (addr); \ \ ASSERT ((size) <= 4 * CLIB_CACHE_PREFETCH_BYTES); \ _CLIB_PREFETCH (0, size, type); \ @@ -100,7 +100,7 @@ #define CLIB_TARGETED_PREFETCH(addr, size, type, locality) \ do \ { \ - void *_addr = (addr); \ + u8 *_addr = (u8 *) (addr); \ \ ASSERT ((size) <= 4 * CLIB_CACHE_PREFETCH_BYTES); \ _CLIB_TARGETED_PREFETCH (0, size, type, locality); \ diff --git a/src/vppinfra/callback.h b/src/vppinfra/callback.h index a938ea326c99..c13b8aca1178 100644 --- a/src/vppinfra/callback.h +++ b/src/vppinfra/callback.h @@ -71,8 +71,7 @@ do { \ * produces a warning not seen with gcc-7 or 8 \ */ \ typeof (h) h_ = (h); \ - int i; \ - for (i = 0; i < vec_len (h_); i++) \ + for (uword i = 0; i < vec_len (h_); i++) \ { \ (h_[i]) (__VA_ARGS__); \ } \ diff --git a/src/vppinfra/clib.h b/src/vppinfra/clib.h index cb90da5c1e0d..0c304f700000 100644 --- a/src/vppinfra/clib.h +++ b/src/vppinfra/clib.h @@ -123,6 +123,12 @@ #define CLIB_SANITIZE_ADDR 1 #endif +#ifdef __cplusplus +#define __clib_strdup(V) strdup(V) +#else +#define __clib_strdup(V) V +#endif + #define __clib_unused __attribute__ ((unused)) #define __clib_weak __attribute__ ((weak)) #define __clib_packed __attribute__ ((packed)) @@ -256,7 +262,7 @@ min_log2_u64 (u64 x) always_inline uword max_pow2 (uword x) { - word y = (word) 1 << min_log2 (x); + uword y = (uword) 1 << min_log2 (x); if (x > y) y *= 2; return y; diff --git a/src/vppinfra/dlist.h b/src/vppinfra/dlist.h index d28500dc49fa..6618fbb3774e 100644 --- a/src/vppinfra/dlist.h +++ b/src/vppinfra/dlist.h @@ -45,24 +45,24 @@ clib_dlist_addtail (dlist_elt_t * pool, u32 head_index, u32 new_index) dlist_elt_t *head = pool_elt_at_index (pool, head_index); u32 old_last_index; dlist_elt_t *old_last; - dlist_elt_t *new; + dlist_elt_t *_new; ASSERT (head->value == ~0); - new = pool_elt_at_index (pool, new_index); + _new = pool_elt_at_index (pool, new_index); if (PREDICT_FALSE (head->next == ~0)) { head->next = head->prev = new_index; - new->next = new->prev = head_index; + _new->next = _new->prev = head_index; return; } old_last_index = head->prev; old_last = pool_elt_at_index (pool, old_last_index); - new->next = old_last->next; - new->prev = old_last_index; + _new->next = old_last->next; + _new->prev = old_last_index; old_last->next = new_index; head->prev = new_index; } @@ -73,24 +73,24 @@ clib_dlist_addhead (dlist_elt_t * pool, u32 head_index, u32 new_index) dlist_elt_t *head = pool_elt_at_index (pool, head_index); dlist_elt_t *old_first; u32 old_first_index; - dlist_elt_t *new; + dlist_elt_t *_new; ASSERT (head->value == ~0); - new = pool_elt_at_index (pool, new_index); + _new = pool_elt_at_index (pool, new_index); if (PREDICT_FALSE (head->next == ~0)) { head->next = head->prev = new_index; - new->next = new->prev = head_index; + _new->next = _new->prev = head_index; return; } old_first_index = head->next; old_first = pool_elt_at_index (pool, old_first_index); - new->next = old_first_index; - new->prev = old_first->prev; + _new->next = old_first_index; + _new->prev = old_first->prev; old_first->prev = new_index; head->next = new_index; } diff --git a/src/vppinfra/elf.h b/src/vppinfra/elf.h index 56869f1b9c71..ad6b74f651f1 100644 --- a/src/vppinfra/elf.h +++ b/src/vppinfra/elf.h @@ -950,7 +950,7 @@ elf_get_segment_contents (elf_main_t * em, void *data, uword segment_index) { elf_segment_t *g = vec_elt_at_index (em->segments, segment_index); if (!g->contents) - vec_add (g->contents, data + g->header.file_offset, + vec_add (g->contents, (u8 *) data + g->header.file_offset, g->header.memory_size); } @@ -966,7 +966,7 @@ elf_get_section_contents (elf_main_t * em, result = 0; if (vec_len (s->contents) > 0) { - vec_attr_t va = { .elt_sz = elt_size }; + vec_attr_t va = { .elt_sz = (u32) elt_size }; /* Make vector copy of contents with given element size. */ result = _vec_realloc_internal (result, vec_len (s->contents) / elt_size, &va); diff --git a/src/vppinfra/elog.h b/src/vppinfra/elog.h index 6a66319148dd..801dd26b8d0d 100644 --- a/src/vppinfra/elog.h +++ b/src/vppinfra/elog.h @@ -366,7 +366,7 @@ elog_event_data_not_inline (elog_main_t * em, always_inline void elog (elog_main_t * em, elog_event_type_t * type, u32 data) { - u32 *d = elog_event_data_not_inline (em, + u32 *d = (u32 *) elog_event_data_not_inline (em, type, &em->default_track, clib_cpu_time_now ()); @@ -381,7 +381,7 @@ elog (elog_main_t * em, elog_event_type_t * type, u32 data) always_inline void elog_inline (elog_main_t * em, elog_event_type_t * type, u32 data) { - u32 *d = elog_event_data_inline (em, + u32 *d = (u32 *) elog_event_data_inline (em, type, &em->default_track, clib_cpu_time_now ()); @@ -398,7 +398,7 @@ always_inline void elog_track (elog_main_t * em, elog_event_type_t * type, elog_track_t * track, u32 data) { - u32 *d = elog_event_data_not_inline (em, + u32 *d = (u32 *) elog_event_data_not_inline (em, type, track, clib_cpu_time_now ()); @@ -415,7 +415,7 @@ always_inline void elog_track_inline (elog_main_t * em, elog_event_type_t * type, elog_track_t * track, u32 data) { - u32 *d = elog_event_data_inline (em, + u32 *d = (u32 *) elog_event_data_inline (em, type, track, clib_cpu_time_now ()); diff --git a/src/vppinfra/error.h b/src/vppinfra/error.h index 9eae8ea6818b..215bd5f4fead 100644 --- a/src/vppinfra/error.h +++ b/src/vppinfra/error.h @@ -83,7 +83,7 @@ do { \ extern void *clib_error_free_vector (clib_error_t * errors); -#define clib_error_free(e) e = clib_error_free_vector(e) +#define clib_error_free(e) e = (__typeof__(e)) clib_error_free_vector(e) extern clib_error_t *_clib_error_return (clib_error_t *errors, any code, uword flags, const char *where, diff --git a/src/vppinfra/error_bootstrap.h b/src/vppinfra/error_bootstrap.h index d3eed1b83aea..a670573c524d 100644 --- a/src/vppinfra/error_bootstrap.h +++ b/src/vppinfra/error_bootstrap.h @@ -107,6 +107,10 @@ do { \ } while (0) #endif /* __COVERITY */ +#ifdef __cplusplus +#define _Static_assert(truth, ...) static_assert(truth, __VA_ARGS__) +#endif + #define STATIC_ASSERT(truth,...) _Static_assert(truth, __VA_ARGS__) #define STATIC_ASSERT_SIZEOF(d, s) \ diff --git a/src/vppinfra/fifo.h b/src/vppinfra/fifo.h index b6a8b8f5c3bb..221d28845657 100644 --- a/src/vppinfra/fifo.h +++ b/src/vppinfra/fifo.h @@ -54,7 +54,7 @@ typedef struct always_inline clib_fifo_header_t * clib_fifo_header (void *f) { - return vec_header (f); + return (clib_fifo_header_t *) vec_header (f); } /* Aliases. */ diff --git a/src/vppinfra/file.h b/src/vppinfra/file.h index 719561376655..68ff4500ca10 100644 --- a/src/vppinfra/file.h +++ b/src/vppinfra/file.h @@ -93,11 +93,11 @@ typedef struct } clib_file_main_t; always_inline uword -clib_file_add (clib_file_main_t * um, clib_file_t * template) +clib_file_add (clib_file_main_t * um, clib_file_t * _template) { clib_file_t *f; pool_get (um->file_pool, f); - f[0] = template[0]; + f[0] = _template[0]; f->read_events = 0; f->write_events = 0; f->error_events = 0; diff --git a/src/vppinfra/format.h b/src/vppinfra/format.h index 14bac869f898..19de2545ce34 100644 --- a/src/vppinfra/format.h +++ b/src/vppinfra/format.h @@ -138,7 +138,7 @@ typedef struct _unformat_input_t /* Return values for fill buffer function which indicate whether not input has been exhausted. */ -#define UNFORMAT_END_OF_INPUT (~0) +#define UNFORMAT_END_OF_INPUT ~0ULL #define UNFORMAT_MORE_INPUT 0 /* User controlled argument to fill buffer function. */ diff --git a/src/vppinfra/hash.c b/src/vppinfra/hash.c index 0e650e67a90a..fcb8e135e25b 100644 --- a/src/vppinfra/hash.c +++ b/src/vppinfra/hash.c @@ -620,22 +620,22 @@ _hash_free (void *v) static void * hash_resize_internal (void *old, uword new_size, uword free_old) { - void *new; + void *_new; hash_pair_t *p; - new = 0; + _new = 0; if (new_size > 0) { hash_t *h = old ? hash_header (old) : 0; - new = _hash_create (new_size, h); + _new = _hash_create (new_size, h); hash_foreach_pair (p, old, { - new = _hash_set3 (new, p->key, &p->value[0], 0); + _new = _hash_set3 (_new, p->key, &p->value[0], 0); }); } if (free_old) hash_free (old); - return new; + return _new; } __clib_export void * diff --git a/src/vppinfra/hash.h b/src/vppinfra/hash.h index 3c754c8e29ff..113a180073ea 100644 --- a/src/vppinfra/hash.h +++ b/src/vppinfra/hash.h @@ -100,7 +100,7 @@ typedef struct hash_header always_inline hash_t * hash_header (void *v) { - return vec_header (v); + return (hash_t *) vec_header (v); } /* Number of elements in the hash table */ @@ -233,7 +233,7 @@ uword hash_bytes (void *v); #define hash_set3(h,key,value,old_value) \ ({ \ uword _v = (uword) (value); \ - (h) = _hash_set3 ((h), (uword) (key), (void *) &_v, (old_value)); \ + (h) = (__typeof__(h)) _hash_set3 ((h), (uword) (key), (void *) &_v, (old_value)); \ }) /* Public macro to fetch value for given key */ @@ -249,7 +249,7 @@ uword hash_bytes (void *v); #define hash_set1(h,key) (h) = _hash_set3(h,(uword) (key),0,0) /* Public macro to unset a (key, value) pair */ -#define hash_unset(h,key) ((h) = _hash_unset ((h), (uword) (key),0)) +#define hash_unset(h,key) ((h) = (__typeof__(h)) _hash_unset ((h), (uword) (key),0)) /* Public macro to unset a (key, value) pair, return the old value */ #define hash_unset3(h,key,old_value) ((h) = _hash_unset ((h), (uword) (key), (void *) (old_value))) @@ -290,7 +290,7 @@ hash_set_mem_alloc (uword ** h, const void *key, uword v) #define hash_set1_mem(h,key) hash_set3 ((h), pointer_to_uword (key), 0, 0) /* Public macro to unset (key, value) for pointer key */ -#define hash_unset_mem(h,key) ((h) = _hash_unset ((h), pointer_to_uword (key),0)) +#define hash_unset_mem(h,key) ((h) = (__typeof__(h)) _hash_unset ((h), pointer_to_uword (key),0)) /* Public inline function to unset pointer key and then free the key memory */ always_inline void @@ -309,7 +309,7 @@ hash_unset_mem_free (uword ** h, const void *key) extern void *_hash_free (void *v); /* Public macro to free a hash table */ -#define hash_free(h) (h) = _hash_free ((h)) +#define hash_free(h) (h) = (__typeof__(h)) _hash_free ((h)) clib_error_t *hash_validate (void *v); diff --git a/src/vppinfra/heap.c b/src/vppinfra/heap.c index 9920528732de..3d1ca72553ef 100644 --- a/src/vppinfra/heap.c +++ b/src/vppinfra/heap.c @@ -147,23 +147,23 @@ elt_delete (heap_header_t * h, heap_elt_t * e) After : P ... NEW ... E */ always_inline void -elt_insert_before (heap_header_t * h, heap_elt_t * e, heap_elt_t * new) +elt_insert_before (heap_header_t * h, heap_elt_t * e, heap_elt_t * _new) { heap_elt_t *p = heap_prev (e); if (p == e) { - new->prev = 0; - new->next = e - new; - p->prev = new - p; - h->head = new - h->elts; + _new->prev = 0; + _new->next = e - _new; + p->prev = _new - p; + h->head = _new - h->elts; } else { - new->prev = p - new; - new->next = e - new; - e->prev = new - e; - p->next = new - p; + _new->prev = p - _new; + _new->next = e - _new; + e->prev = _new - e; + p->next = _new - p; } } @@ -172,23 +172,23 @@ elt_insert_before (heap_header_t * h, heap_elt_t * e, heap_elt_t * new) After : E ... NEW ... N */ always_inline void -elt_insert_after (heap_header_t * h, heap_elt_t * e, heap_elt_t * new) +elt_insert_after (heap_header_t * h, heap_elt_t * e, heap_elt_t * _new) { heap_elt_t *n = heap_next (e); if (n == e) { - new->next = 0; - new->prev = e - new; - e->next = new - e; - h->tail = new - h->elts; + _new->next = 0; + _new->prev = e - _new; + e->next = _new - e; + h->tail = _new - h->elts; } else { - new->prev = e - new; - new->next = n - new; - e->next = new - e; - n->prev = new - n; + _new->prev = e - _new; + _new->next = n - _new; + e->next = _new - e; + n->prev = _new - n; } } @@ -413,9 +413,11 @@ _heap_alloc (void *v, if (!e) { uword max_len; - vec_attr_t va = { .elt_sz = elt_bytes, - .hdr_sz = sizeof (h[0]), - .align = HEAP_DATA_ALIGN }; + vec_attr_t va = { + .elt_sz = (u32) elt_bytes, + .hdr_sz = (u16) sizeof (h[0]), + .align = HEAP_DATA_ALIGN + }; offset = vec_len (v); max_len = heap_get_max_len (v); diff --git a/src/vppinfra/heap.h b/src/vppinfra/heap.h index 45f3131a45b3..1de55b969de2 100644 --- a/src/vppinfra/heap.h +++ b/src/vppinfra/heap.h @@ -61,6 +61,7 @@ #ifndef included_heap_h #define included_heap_h +#include "vppinfra/types.h" #include #include #include @@ -155,27 +156,27 @@ typedef struct } heap_header_t; /* Start of heap elements is always cache aligned. */ -#define HEAP_DATA_ALIGN (CLIB_CACHE_LINE_BYTES) +#define HEAP_DATA_ALIGN (u16)(CLIB_CACHE_LINE_BYTES) always_inline heap_header_t * heap_header (void *v) { - return vec_header (v); + return (heap_header_t *) vec_header (v); } always_inline void -heap_dup_header (heap_header_t * old, heap_header_t * new) +heap_dup_header (heap_header_t * old, heap_header_t * _new) { uword i; - new[0] = old[0]; - new->elts = vec_dup (new->elts); - new->free_elts = vec_dup (new->free_elts); - new->free_lists = vec_dup (new->free_lists); - for (i = 0; i < vec_len (new->free_lists); i++) - new->free_lists[i] = vec_dup (new->free_lists[i]); - new->used_elt_bitmap = clib_bitmap_dup (new->used_elt_bitmap); - new->small_free_elt_free_index = vec_dup (new->small_free_elt_free_index); + _new[0] = old[0]; + _new->elts = vec_dup (_new->elts); + _new->free_elts = vec_dup (_new->free_elts); + _new->free_lists = vec_dup (_new->free_lists); + for (i = 0; i < vec_len (_new->free_lists); i++) + _new->free_lists[i] = vec_dup (_new->free_lists[i]); + _new->used_elt_bitmap = clib_bitmap_dup (_new->used_elt_bitmap); + _new->small_free_elt_free_index = vec_dup (_new->small_free_elt_free_index); } /* Make a duplicate copy of a heap. */ @@ -185,9 +186,11 @@ always_inline void * _heap_dup (void *v_old, uword v_bytes) { heap_header_t *h_old, *h_new; - vec_attr_t va = { .align = HEAP_DATA_ALIGN, - .hdr_sz = sizeof (heap_header_t), - .elt_sz = 1 }; + vec_attr_t va = { + .elt_sz = 1UL, + .hdr_sz = sizeof (heap_header_t), + .align = HEAP_DATA_ALIGN + }; void *v_new; h_old = heap_header (v_old); @@ -214,9 +217,11 @@ uword heap_bytes (void *v); always_inline void * _heap_new (u32 len, u32 n_elt_bytes) { - vec_attr_t va = { .align = HEAP_DATA_ALIGN, - .hdr_sz = sizeof (heap_header_t), - .elt_sz = n_elt_bytes }; + vec_attr_t va = { + .elt_sz = (u16) n_elt_bytes, + .hdr_sz = (u16) sizeof (heap_header_t), + .align = HEAP_DATA_ALIGN + }; void *v = _vec_alloc_internal (len, &va); heap_header (v)->elt_bytes = n_elt_bytes; return v; @@ -318,7 +323,7 @@ extern u8 *format_heap (u8 * s, va_list * va); void *_heap_free (void *v); -#define heap_free(v) (v)=_heap_free(v) +#define heap_free(v) (v)= (__typeof__(v)) _heap_free(v) #endif /* included_heap_h */ diff --git a/src/vppinfra/interrupt.h b/src/vppinfra/interrupt.h index b0d7dde272a1..809756ab883a 100644 --- a/src/vppinfra/interrupt.h +++ b/src/vppinfra/interrupt.h @@ -34,7 +34,7 @@ clib_interrupt_free (void **data) static_always_inline int clib_interrupt_get_n_int (void *d) { - clib_interrupt_header_t *h = d; + clib_interrupt_header_t *h = (clib_interrupt_header_t *) d; if (h) return h->n_int; return 0; @@ -43,7 +43,7 @@ clib_interrupt_get_n_int (void *d) static_always_inline void clib_interrupt_set (void *in, int int_num) { - clib_interrupt_header_t *h = in; + clib_interrupt_header_t *h = (clib_interrupt_header_t *) in; u32 off = int_num >> log2_uword_bits; uword bit = 1ULL << (int_num & pow2_mask (log2_uword_bits)); @@ -55,7 +55,7 @@ clib_interrupt_set (void *in, int int_num) static_always_inline void clib_interrupt_set_atomic (void *in, int int_num) { - clib_interrupt_header_t *h = in; + clib_interrupt_header_t *h = (clib_interrupt_header_t *) in; u32 off = int_num >> log2_uword_bits; uword bit = 1ULL << (int_num & pow2_mask (log2_uword_bits)); @@ -67,7 +67,7 @@ clib_interrupt_set_atomic (void *in, int int_num) static_always_inline void clib_interrupt_clear (void *in, int int_num) { - clib_interrupt_header_t *h = in; + clib_interrupt_header_t *h = (clib_interrupt_header_t *) in; u32 off = int_num >> log2_uword_bits; uword bit = 1ULL << (int_num & pow2_mask (log2_uword_bits)); uword *loc = h->local; @@ -83,7 +83,7 @@ clib_interrupt_clear (void *in, int int_num) static_always_inline int clib_interrupt_get_next_and_clear (void *in, int last) { - clib_interrupt_header_t *h = in; + clib_interrupt_header_t *h = (clib_interrupt_header_t *) in; uword bit, v; uword *loc = h->local; uword *rem = h->remote; @@ -118,7 +118,7 @@ clib_interrupt_get_next_and_clear (void *in, int last) static_always_inline int clib_interrupt_is_any_pending (void *in) { - clib_interrupt_header_t *h = in; + clib_interrupt_header_t *h = (clib_interrupt_header_t *) in; u32 n_uwords = h->uwords_used; uword *loc = h->local; uword *rem = h->remote; diff --git a/src/vppinfra/lock.h b/src/vppinfra/lock.h index b7b3d00a9053..d82c8bcc106e 100644 --- a/src/vppinfra/lock.h +++ b/src/vppinfra/lock.h @@ -64,7 +64,7 @@ typedef struct clib_spinlock_s *clib_spinlock_t; static inline void clib_spinlock_init (clib_spinlock_t * p) { - *p = clib_mem_alloc_aligned (CLIB_CACHE_LINE_BYTES, CLIB_CACHE_LINE_BYTES); + *p = (clib_spinlock_t) clib_mem_alloc_aligned (CLIB_CACHE_LINE_BYTES, CLIB_CACHE_LINE_BYTES); clib_memset ((void *) *p, 0, CLIB_CACHE_LINE_BYTES); } @@ -151,7 +151,7 @@ typedef struct clib_rw_lock_ always_inline void clib_rwlock_init (clib_rwlock_t * p) { - *p = clib_mem_alloc_aligned (CLIB_CACHE_LINE_BYTES, CLIB_CACHE_LINE_BYTES); + *p = (clib_rwlock_t) clib_mem_alloc_aligned (CLIB_CACHE_LINE_BYTES, CLIB_CACHE_LINE_BYTES); clib_memset ((void *) *p, 0, CLIB_CACHE_LINE_BYTES); } diff --git a/src/vppinfra/mem.h b/src/vppinfra/mem.h index 893978081d0d..3d0b73fd3775 100644 --- a/src/vppinfra/mem.h +++ b/src/vppinfra/mem.h @@ -185,7 +185,7 @@ always_inline clib_mem_heap_t * clib_mem_get_per_cpu_heap (void) { int cpu = os_get_thread_index (); - return clib_mem_main.per_cpu_mheaps[cpu]; + return (clib_mem_heap_t *) clib_mem_main.per_cpu_mheaps[cpu]; } always_inline void * @@ -221,10 +221,9 @@ clib_mem_set_thread_index (void) * and grab it for this thread. We need to be able to * push/pop the thread heap without affecting other thread(s). */ - int i; if (__os_thread_index != 0) return; - for (i = 0; i < ARRAY_LEN (clib_mem_main.per_cpu_mheaps); i++) + for (uword i = 0; i < ARRAY_LEN (clib_mem_main.per_cpu_mheaps); i++) if (clib_atomic_bool_cmp_and_swap (&clib_mem_main.per_cpu_mheaps[i], 0, clib_mem_main.per_cpu_mheaps[0])) { @@ -284,7 +283,7 @@ clib_mem_get_heap (void) always_inline clib_mem_heap_t * clib_mem_set_heap (clib_mem_heap_t * heap) { - return clib_mem_set_per_cpu_heap (heap); + return (clib_mem_heap_t *) clib_mem_set_per_cpu_heap (heap); } void clib_mem_destroy_heap (clib_mem_heap_t * heap); diff --git a/src/vppinfra/mem_dlmalloc.c b/src/vppinfra/mem_dlmalloc.c index 7944240390be..f59f2c45197e 100644 --- a/src/vppinfra/mem_dlmalloc.c +++ b/src/vppinfra/mem_dlmalloc.c @@ -719,7 +719,7 @@ clib_mem_heap_realloc_aligned (void *heap, void *p, uword new_size, { uword old_alloc_size; clib_mem_heap_t *h = heap ? heap : clib_mem_get_per_cpu_heap (); - void *new; + void *_new; ASSERT (count_set_bits (align) == 1); @@ -741,16 +741,16 @@ clib_mem_heap_realloc_aligned (void *heap, void *p, uword new_size, } else { - new = clib_mem_heap_alloc_inline (h, new_size, align, 1); + _new = clib_mem_heap_alloc_inline (h, new_size, align, 1); - clib_mem_unpoison (new, new_size); + clib_mem_unpoison (_new, new_size); if (old_alloc_size) { clib_mem_unpoison (p, old_alloc_size); - clib_memcpy_fast (new, p, clib_min (new_size, old_alloc_size)); + clib_memcpy_fast (_new, p, clib_min (new_size, old_alloc_size)); clib_mem_heap_free (h, p); } - p = new; + p = _new; } return p; diff --git a/src/vppinfra/memcpy.h b/src/vppinfra/memcpy.h index e895cbf7485f..9f8a518393ac 100644 --- a/src/vppinfra/memcpy.h +++ b/src/vppinfra/memcpy.h @@ -2,6 +2,7 @@ * Copyright(c) 2021 Cisco Systems, Inc. */ +#include "vppinfra/types.h" #include #ifndef included_memcpy_h #define included_memcpy_h @@ -9,7 +10,7 @@ static_always_inline void clib_memcpy_may_overrun (void *dst, void *src, u32 n_bytes) { - word n_left = n_bytes; + uword n_left = n_bytes; #if defined(CLIB_HAVE_VEC512) u8x64u *sv = (u8x64u *) src; u8x64u *dv = (u8x64u *) dst; diff --git a/src/vppinfra/memcpy_x86_64.h b/src/vppinfra/memcpy_x86_64.h index 39258f19748e..7773b923beb8 100644 --- a/src/vppinfra/memcpy_x86_64.h +++ b/src/vppinfra/memcpy_x86_64.h @@ -270,7 +270,7 @@ clib_memcpy_x86_64_const (u8 *dst, u8 *src, size_t n) } static_always_inline void * -clib_memcpy_x86_64 (void *restrict dst, const void *restrict src, size_t n) +clib_memcpy_x86_64 (void *__restrict__ dst, const void *__restrict__ src, size_t n) { u8 *d = (u8 *) dst, *s = (u8 *) src; diff --git a/src/vppinfra/mhash.h b/src/vppinfra/mhash.h index 62aee365fa31..8493ae695b54 100644 --- a/src/vppinfra/mhash.h +++ b/src/vppinfra/mhash.h @@ -89,7 +89,7 @@ mhash_init_vec_string (mhash_t * h, uword n_value_bytes) always_inline void * mhash_key_to_mem (mhash_t * h, uword key) { - if (key == ~0) + if (key == ~0ULL) { u8 *key_tmp; diff --git a/src/vppinfra/pcap_funcs.h b/src/vppinfra/pcap_funcs.h index 2c51ab723834..0967d79513e0 100644 --- a/src/vppinfra/pcap_funcs.h +++ b/src/vppinfra/pcap_funcs.h @@ -45,7 +45,7 @@ pcap_add_packet (pcap_main_t * pm, u8 *d; vec_add2 (pm->pcap_data, d, sizeof (h[0]) + n_bytes_in_trace); - h = (void *) (d); + h = (pcap_packet_header_t *) (d); h->time_in_sec = time_now; h->time_in_usec = 1e6 * (time_now - h->time_in_sec); h->n_packet_bytes_stored_in_file = n_bytes_in_trace; diff --git a/src/vppinfra/pool.h b/src/vppinfra/pool.h index 07c9269c6d8b..2b3f48089581 100644 --- a/src/vppinfra/pool.h +++ b/src/vppinfra/pool.h @@ -67,7 +67,7 @@ typedef struct always_inline pool_header_t * pool_header (void *v) { - return vec_header (v); + return (pool_header_t *) vec_header (v); } void _pool_init_fixed (void **pool_ptr, uword elt_sz, uword max_elts, @@ -172,9 +172,11 @@ _pool_get (void **pp, void **ep, uword align, int zero, uword elt_sz) uword len = 0; void *p = pp[0]; void *e; - vec_attr_t va = { .hdr_sz = sizeof (pool_header_t), - .elt_sz = elt_sz, - .align = align }; + vec_attr_t va = { + .elt_sz = (u32) elt_sz, + .hdr_sz = (u16) sizeof (pool_header_t), + .align = (u16) align + }; if (p) { @@ -184,7 +186,7 @@ _pool_get (void **pp, void **ep, uword align, int zero, uword elt_sz) if (n_free) { uword index = ph->free_indices[n_free - 1]; - e = p + index * elt_sz; + e = (u8 *) p + index * elt_sz; ph->free_bitmap = clib_bitmap_andnoti_notrim (ph->free_bitmap, index); vec_set_len (ph->free_indices, n_free - 1); @@ -203,7 +205,7 @@ _pool_get (void **pp, void **ep, uword align, int zero, uword elt_sz) /* Nothing on free list, make a new element and return it. */ p = _vec_realloc_internal (p, len + 1, &va); - e = p + len * elt_sz; + e = (u8 *) p + len * elt_sz; _vec_update_pointer (pp, p); @@ -303,7 +305,7 @@ _pool_put_index (void *p, uword index, uword elt_sz) else vec_add1 (ph->free_indices, index); - clib_mem_poison (p + index * elt_sz, elt_sz); + clib_mem_poison ((u8 *) p + index * elt_sz, elt_sz); } #define pool_put_index(P, I) _pool_put_index ((void *) (P), I, _vec_elt_sz (P)) @@ -316,10 +318,12 @@ _pool_alloc (void **pp, uword n_elts, uword align, void *heap, uword elt_sz) { pool_header_t *ph = pool_header (pp[0]); uword len = vec_len (pp[0]); - const vec_attr_t va = { .hdr_sz = sizeof (pool_header_t), - .elt_sz = elt_sz, - .align = align, - .heap = heap }; + const vec_attr_t va = { + .heap = heap, + .elt_sz = (u32) elt_sz, + .hdr_sz = (u16) sizeof (pool_header_t), + .align = (u16) align, + }; if (ph && ph->max_elts) { @@ -329,7 +333,7 @@ _pool_alloc (void **pp, uword n_elts, uword align, void *heap, uword elt_sz) pp[0] = _vec_resize_internal (pp[0], len + n_elts, &va); _vec_set_len (pp[0], len, elt_sz); - clib_mem_poison (pp[0] + len * elt_sz, n_elts * elt_sz); + clib_mem_poison ((u8 *) pp[0] + len * elt_sz, n_elts * elt_sz); ph = pool_header (pp[0]); vec_resize (ph->free_indices, n_elts); @@ -349,9 +353,11 @@ _pool_dup (void *p, uword align, uword elt_sz) { pool_header_t *nph, *ph = pool_header (p); uword len = vec_len (p); - const vec_attr_t va = { .hdr_sz = sizeof (pool_header_t), - .elt_sz = elt_sz, - .align = align }; + const vec_attr_t va = { + .elt_sz = (u32) elt_sz, + .hdr_sz = (u16) sizeof (pool_header_t), + .align = (u16) align + }; void *n; if (ph && ph->max_elts) @@ -368,18 +374,18 @@ _pool_dup (void *p, uword align, uword elt_sz) { u32 *fi; vec_foreach (fi, ph->free_indices) - clib_mem_unpoison (p + elt_sz * fi[0], elt_sz); + clib_mem_unpoison ((u8 *) p + elt_sz * fi[0], elt_sz); clib_memcpy_fast (n, p, len * elt_sz); - nph->free_bitmap = clib_bitmap_dup (ph->free_bitmap); - nph->free_indices = vec_dup (ph->free_indices); + nph->free_bitmap = (uword *) clib_bitmap_dup (ph->free_bitmap); + nph->free_indices = (u32 *) vec_dup (ph->free_indices); vec_foreach (fi, ph->free_indices) { uword offset = elt_sz * fi[0]; - clib_mem_poison (p + offset, elt_sz); - clib_mem_poison (n + offset, elt_sz); + clib_mem_poison ((u8 *) p + offset, elt_sz); + clib_mem_poison ((u8 *) n + offset, elt_sz); } } diff --git a/src/vppinfra/random.h b/src/vppinfra/random.h index bceab4195671..50932d381af7 100644 --- a/src/vppinfra/random.h +++ b/src/vppinfra/random.h @@ -158,10 +158,9 @@ random_string (u32 * seed, uword len) { u8 *alphabet = (u8 *) "abcdefghijklmnopqrstuvwxyz"; u8 *s = 0; - word i; vec_resize (s, len); - for (i = 0; i < len; i++) + for (uword i = 0; i < len; i++) s[i] = alphabet[random_u32 (seed) % 26]; return s; diff --git a/src/vppinfra/serialize.h b/src/vppinfra/serialize.h index 90d615f60a48..1e90a1f9d378 100644 --- a/src/vppinfra/serialize.h +++ b/src/vppinfra/serialize.h @@ -184,7 +184,7 @@ serialize_get (serialize_main_t * m, uword n_bytes) always_inline void serialize_integer (serialize_main_t * m, u64 x, u32 n_bytes) { - u8 *p = serialize_get (m, n_bytes); + u8 *p = (u8 *) serialize_get (m, n_bytes); if (n_bytes == 1) p[0] = x; else if (n_bytes == 2) @@ -200,7 +200,7 @@ serialize_integer (serialize_main_t * m, u64 x, u32 n_bytes) always_inline void unserialize_integer (serialize_main_t * m, void *x, u32 n_bytes) { - u8 *p = unserialize_get (m, n_bytes); + u8 *p = (u8 *) unserialize_get (m, n_bytes); if (n_bytes == 1) *(u8 *) x = p[0]; else if (n_bytes == 2) @@ -223,7 +223,7 @@ serialize_likely_small_unsigned_integer (serialize_main_t * m, u64 x) /* Low bit set means it fits into 1 byte. */ if (r < (1 << 7)) { - p = serialize_get (m, 1); + p = (u8 *) serialize_get (m, 1); p[0] = 1 + 2 * r; return; } @@ -232,7 +232,7 @@ serialize_likely_small_unsigned_integer (serialize_main_t * m, u64 x) r -= (1 << 7); if (r < (1 << 14)) { - p = serialize_get (m, 2); + p = (u8 *) serialize_get (m, 2); clib_mem_unaligned (p, u16) = clib_host_to_little_u16 (4 * r + 2); return; } @@ -240,12 +240,12 @@ serialize_likely_small_unsigned_integer (serialize_main_t * m, u64 x) r -= (1 << 14); if (r < (1 << 29)) { - p = serialize_get (m, 4); + p = (u8 *) serialize_get (m, 4); clib_mem_unaligned (p, u32) = clib_host_to_little_u32 (8 * r + 4); return; } - p = serialize_get (m, 9); + p = (u8 *) serialize_get (m, 9); p[0] = 0; /* Only low 3 bits are used. */ clib_mem_unaligned (p + 1, u64) = clib_host_to_little_u64 (x); } @@ -253,7 +253,7 @@ serialize_likely_small_unsigned_integer (serialize_main_t * m, u64 x) always_inline u64 unserialize_likely_small_unsigned_integer (serialize_main_t * m) { - u8 *p = unserialize_get (m, 1); + u8 *p = (u8 *) serialize_get (m, 1); u64 r; u32 y = p[0]; @@ -263,7 +263,7 @@ unserialize_likely_small_unsigned_integer (serialize_main_t * m) r = 1 << 7; if (y & 2) { - p = unserialize_get (m, 1); + p = (u8 *) unserialize_get (m, 1); r += (y / 4) + (p[0] << 6); return r; } @@ -271,14 +271,14 @@ unserialize_likely_small_unsigned_integer (serialize_main_t * m) r += 1 << 14; if (y & 4) { - p = unserialize_get (m, 3); + p = (u8 *) unserialize_get (m, 3); r += ((y / 8) + (p[0] << (5 + 8 * 0)) + (p[1] << (5 + 8 * 1)) + (p[2] << (5 + 8 * 2))); return r; } - p = unserialize_get (m, 8); + p = (u8 *) unserialize_get (m, 8); r = clib_mem_unaligned (p, u64); r = clib_little_to_host_u64 (r); diff --git a/src/vppinfra/string.h b/src/vppinfra/string.h index b1ef0e4809bd..8accb2bab9c7 100644 --- a/src/vppinfra/string.h +++ b/src/vppinfra/string.h @@ -44,6 +44,7 @@ #ifndef included_clib_string_h #define included_clib_string_h +#include "vppinfra/types.h" #include /* for CLIB_LINUX_KERNEL */ #include #include @@ -72,7 +73,7 @@ void clib_memswap (void *_a, void *_b, uword bytes); static_always_inline void * -clib_memcpy_fast (void *restrict dst, const void *restrict src, size_t n) +clib_memcpy_fast (void *__restrict__ dst, const void *__restrict__ src, size_t n) { ASSERT (dst && src && "memcpy(src, dst, n) with src == NULL or dst == NULL is undefined " @@ -318,7 +319,7 @@ clib_memcpy_le32 (u8 * dst, u8 * src, u8 len) static_always_inline void clib_memset_u64 (void *p, u64 val, uword count) { - u64 *ptr = p; + u64 *ptr = (u64 *) p; #if defined(CLIB_HAVE_VEC512) u64x8 v512 = u64x8_splat (val); while (count >= 8) @@ -363,7 +364,7 @@ clib_memset_u64 (void *p, u64 val, uword count) static_always_inline void clib_memset_u32 (void *p, u32 val, uword count) { - u32 *ptr = p; + u32 *ptr = (u32 *) p; #if defined(CLIB_HAVE_VEC512) u32x16 v512 = u32x16_splat (val); while (count >= 16) @@ -409,7 +410,7 @@ clib_memset_u32 (void *p, u32 val, uword count) static_always_inline void clib_memset_u16 (void *p, u16 val, uword count) { - u16 *ptr = p; + u16 *ptr = (u16 *) p; #if defined(CLIB_HAVE_VEC512) u16x32 v512 = u16x32_splat (val); while (count >= 32) @@ -455,7 +456,7 @@ clib_memset_u16 (void *p, u16 val, uword count) static_always_inline void clib_memset_u8 (void *p, u8 val, uword count) { - u8 *ptr = p; + u8 *ptr = (u8 *) p; #if defined(CLIB_HAVE_VEC512) u8x64 v512 = u8x64_splat (val); while (count >= 64) diff --git a/src/vppinfra/test_vec.c b/src/vppinfra/test_vec.c index 9f336a0a0955..6a934a08990f 100644 --- a/src/vppinfra/test_vec.c +++ b/src/vppinfra/test_vec.c @@ -406,28 +406,28 @@ generic_validate_vec_add (elt_t * vec, uword num_elts, uword is_add2) uword len1 = vec_len (vec); uword len2; u8 hash = compute_vec_hash (0, vec); - elt_t *new; + elt_t *_new; if (is_add2) { - vec_add2 (vec, new, num_elts); + vec_add2 (vec, _new, num_elts); } else { - new = create_random_vec (elt_t, num_elts, g_seed); + _new = create_random_vec (elt_t, num_elts, g_seed); - VERBOSE3 ("%U\n", format_hex_bytes, new, - vec_len (new) * sizeof (new[0])); + VERBOSE3 ("%U\n", format_hex_bytes, _new, + vec_len (_new) * sizeof (_new[0])); /* Add the hash value of the new elements to that of the old vector. */ - hash = compute_vec_hash (hash, new); + hash = compute_vec_hash (hash, _new); if (num_elts == 1) - vec_add1 (vec, new[0]); + vec_add1 (vec, _new[0]); else if (num_elts > 1) - vec_add (vec, new, num_elts); + vec_add (vec, _new, num_elts); - vec_free (new); + vec_free (_new); } len2 = vec_len (vec); @@ -482,25 +482,25 @@ validate_vec_insert_elts (elt_t * vec, uword num_elts, uword start_elt) { uword len1 = vec_len (vec); uword len2; - elt_t *new; + elt_t *_new; u8 hash; /* vec_insert_elts() would not handle it properly. */ if (start_elt > len1 || num_elts == 0) return vec; - new = create_random_vec (elt_t, num_elts, g_seed); + _new = create_random_vec (elt_t, num_elts, g_seed); - VERBOSE3 ("%U\n", format_hex_bytes, new, vec_len (new) * sizeof (new[0])); + VERBOSE3 ("%U\n", format_hex_bytes, _new, vec_len (_new) * sizeof (_new[0])); /* Add the hash value of the new elements to that of the old vector. */ hash = compute_vec_hash (0, vec); - hash = compute_vec_hash (hash, new); + hash = compute_vec_hash (hash, _new); - vec_insert_elts (vec, new, num_elts, start_elt); + vec_insert_elts (vec, _new, num_elts, start_elt); len2 = vec_len (vec); - vec_free (new); + vec_free (_new); ASSERT (len2 == len1 + num_elts); ASSERT (compute_vec_hash (hash, vec) == 0); @@ -539,16 +539,16 @@ validate_vec_delete (elt_t * vec, uword num_elts, uword start_elt) static elt_t * validate_vec_dup (elt_t * vec) { - elt_t *new; + elt_t *_new; u8 hash; hash = compute_vec_hash (0, vec); - new = vec_dup (vec); + _new = vec_dup (vec); - ASSERT (compute_vec_hash (hash, new) == 0); + ASSERT (compute_vec_hash (hash, _new) == 0); - validate_vec (new, 0); - return new; + validate_vec (_new, 0); + return _new; } static elt_t * @@ -576,14 +576,14 @@ validate_vec_zero (elt_t * vec) static void validate_vec_is_equal (elt_t * vec) { - elt_t *new = NULL; + elt_t *_new = NULL; if (vec_len (vec) <= 0) return; - new = vec_dup (vec); - ASSERT (vec_is_equal (new, vec)); - vec_free (new); + _new = vec_dup (vec); + ASSERT (vec_is_equal (_new, vec)); + vec_free (_new); } static elt_t * @@ -591,21 +591,21 @@ validate_vec_set (elt_t * vec) { uword i; uword len = vec_len (vec); - elt_t *new; + elt_t *_new; if (!vec) return NULL; - new = create_random_vec (elt_t, 1, g_seed); + _new = create_random_vec (elt_t, 1, g_seed); - VERBOSE3 ("%U\n", format_hex_bytes, new, vec_len (new) * sizeof (new[0])); + VERBOSE3 ("%U\n", format_hex_bytes, _new, vec_len (_new) * sizeof (_new[0])); - vec_set (vec, new[0]); + vec_set (vec, _new[0]); for (i = 0; i < len; i++) - ASSERT (memcmp (&vec[i], &new[0], sizeof (vec[0])) == 0); + ASSERT (memcmp (&vec[i], &_new[0], sizeof (vec[0])) == 0); - vec_free (new); + vec_free (_new); validate_vec (vec, 0); return vec; } @@ -648,25 +648,25 @@ validate_vec_init (uword num_elts) u8 *ptr; u8 *end; uword len; - elt_t *new; + elt_t *_new; - new = vec_new (elt_t, num_elts); - len = vec_len (new); + _new = vec_new (elt_t, num_elts); + len = vec_len (_new); ASSERT (len == num_elts); - ptr = (u8 *) new; - end = (u8 *) (new + len); + ptr = (u8 *) _new; + end = (u8 *) (_new + len); while (ptr != end) { - ASSERT (ptr < (u8 *) vec_end (new)); + ASSERT (ptr < (u8 *) vec_end (_new)); ASSERT (ptr[0] == 0); ptr++; } - validate_vec (new, 0); - return new; + validate_vec (_new, 0); + return _new; } static elt_t * @@ -676,10 +676,10 @@ validate_vec_init_h (uword num_elts, uword hdr_bytes) u8 *ptr; u8 *end; uword len; - elt_t *new; + elt_t *_new; - new = vec_new_generic (elt_t, num_elts, hdr_bytes, 0, 0); - len = vec_len (new); + _new = vec_new_generic (elt_t, num_elts, hdr_bytes, 0, 0); + len = vec_len (_new); ASSERT (len == num_elts); @@ -688,57 +688,57 @@ validate_vec_init_h (uword num_elts, uword hdr_bytes) { if (i == 0) { - ptr = (u8 *) vec_header (new); + ptr = (u8 *) vec_header (_new); end = ptr + hdr_bytes; } else { - ptr = (u8 *) new; - end = (u8 *) (new + len); + ptr = (u8 *) _new; + end = (u8 *) (_new + len); } while (ptr != end) { - ASSERT (ptr < (u8 *) vec_end (new)); + ASSERT (ptr < (u8 *) vec_end (_new)); ASSERT (ptr[0] == 0); ptr++; } } - validate_vec (new, 1); - return new; + validate_vec (_new, 1); + return _new; } /* XXX - I don't understand the purpose of the vec_clone() call. */ static elt_t * validate_vec_clone (elt_t * vec) { - elt_t *new; + elt_t *_new; - vec_clone (new, vec); + vec_clone (_new, vec); - ASSERT (vec_len (new) == vec_len (vec)); - ASSERT (compute_vec_hash (0, new) == 0); - validate_vec (new, 0); - return new; + ASSERT (vec_len (_new) == vec_len (vec)); + ASSERT (compute_vec_hash (0, _new) == 0); + validate_vec (_new, 0); + return _new; } static elt_t * validate_vec_append (elt_t * vec) { - elt_t *new; + elt_t *_new; uword num_elts = bounded_random_u32 (&g_seed, 0, MAX_CHANGE); uword len; u8 hash = 0; - new = create_random_vec (elt_t, num_elts, g_seed); + _new = create_random_vec (elt_t, num_elts, g_seed); - len = vec_len (vec) + vec_len (new); + len = vec_len (vec) + vec_len (_new); hash = compute_vec_hash (0, vec); - hash = compute_vec_hash (hash, new); + hash = compute_vec_hash (hash, _new); - vec_append (vec, new); - vec_free (new); + vec_append (vec, _new); + vec_free (_new); ASSERT (vec_len (vec) == len); ASSERT (compute_vec_hash (hash, vec) == 0); @@ -749,19 +749,19 @@ validate_vec_append (elt_t * vec) static elt_t * validate_vec_prepend (elt_t * vec) { - elt_t *new; + elt_t *_new; uword num_elts = bounded_random_u32 (&g_seed, 0, MAX_CHANGE); uword len; u8 hash = 0; - new = create_random_vec (elt_t, num_elts, g_seed); + _new = create_random_vec (elt_t, num_elts, g_seed); - len = vec_len (vec) + vec_len (new); + len = vec_len (vec) + vec_len (_new); hash = compute_vec_hash (0, vec); - hash = compute_vec_hash (hash, new); + hash = compute_vec_hash (hash, _new); - vec_prepend (vec, new); - vec_free (new); + vec_prepend (vec, _new); + vec_free (_new); ASSERT (vec_len (vec) == len); ASSERT (compute_vec_hash (hash, vec) == 0); @@ -848,7 +848,7 @@ static void run_validator (uword iter) { elt_t *vec; - elt_t *new; + elt_t *_new; uword i; uword op; uword num_elts; @@ -930,8 +930,8 @@ run_validator (uword iter) case OP_IS_VEC_DUP: VERBOSE2 ("vec_dup()\n"); - new = validate_vec_dup (vec); - vec_free (new); + _new = validate_vec_dup (vec); + vec_free (_new); break; case OP_IS_VEC_IS_EQUAL: @@ -970,8 +970,8 @@ run_validator (uword iter) case OP_IS_VEC_CLONE: VERBOSE2 ("vec_clone()\n"); - new = validate_vec_clone (vec); - vec_free (new); + _new = validate_vec_clone (vec); + vec_free (_new); break; case OP_IS_VEC_APPEND: diff --git a/src/vppinfra/tw_timer_template.c b/src/vppinfra/tw_timer_template.c index 6e8a58dbfafc..fd09ebad97b1 100644 --- a/src/vppinfra/tw_timer_template.c +++ b/src/vppinfra/tw_timer_template.c @@ -121,22 +121,22 @@ timer_addhead (TWT (tw_timer) * pool, u32 head_index, u32 new_index) TWT (tw_timer) * head = pool_elt_at_index (pool, head_index); TWT (tw_timer) * old_first; u32 old_first_index; - TWT (tw_timer) * new; + TWT (tw_timer) * _new; - new = pool_elt_at_index (pool, new_index); + _new = pool_elt_at_index (pool, new_index); if (PREDICT_FALSE (head->next == head_index)) { head->next = head->prev = new_index; - new->next = new->prev = head_index; + _new->next = _new->prev = head_index; return; } old_first_index = head->next; old_first = pool_elt_at_index (pool, old_first_index); - new->next = old_first_index; - new->prev = old_first->prev; + _new->next = old_first_index; + _new->prev = old_first->prev; old_first->prev = new_index; head->next = new_index; } diff --git a/src/vppinfra/types.h b/src/vppinfra/types.h index ad85af35ac94..fe2543135e92 100644 --- a/src/vppinfra/types.h +++ b/src/vppinfra/types.h @@ -179,8 +179,24 @@ typedef f64 fword; clib_mem_unaligned (p, u64) = 99 clib_mem_unaligned (p, u64) += 99 */ +#define _(type) \ + typedef struct { type _data; } __attribute__ ((packed)) clib_mem_unaligned_##type + +_(u16); +_(u32); +_(u64); +_(i16); +_(i32); +_(i64); +_(f32); +_(f64); +_(word); +_(uword); + +#undef _ + #define clib_mem_unaligned(pointer,type) \ - (((struct { CLIB_PACKED (type _data); } *) (pointer))->_data) + (((clib_mem_unaligned_##type *) (pointer))->_data) /* Access memory with specified alignment depending on align argument. As with clib_mem_unaligned, may be used as {r,l}value. */ diff --git a/src/vppinfra/valloc.c b/src/vppinfra/valloc.c index 2f9e8d218a0e..4968fb172a9f 100644 --- a/src/vppinfra/valloc.c +++ b/src/vppinfra/valloc.c @@ -21,7 +21,7 @@ /** Add a chunk of memory to a virtual allocation arena @param vam - clib_valloc_main_t * pointer to the allocation arena - @param template - clib_valloc_chunk_t * pointer to a template chunk which + @param _template - clib_valloc_chunk_t * pointer to a template chunk which describes the virtual address range to add @note only the baseva and size member of the template chunk are significant @@ -30,7 +30,7 @@ */ __clib_export void -clib_valloc_add_chunk (clib_valloc_main_t *vam, clib_valloc_chunk_t *template) +clib_valloc_add_chunk (clib_valloc_main_t *vam, clib_valloc_chunk_t *_template) { clib_valloc_chunk_t *ch, *new_ch; u32 index; @@ -51,10 +51,10 @@ clib_valloc_add_chunk (clib_valloc_main_t *vam, clib_valloc_chunk_t *template) while (index != ~0) { ch = pool_elt_at_index (vam->chunks, index); - ASSERT (template->baseva < ch->baseva || template->baseva >= + ASSERT (_template->baseva < ch->baseva || _template->baseva >= (ch->baseva + ch->size)); - ASSERT (template->baseva + template->size < ch->baseva || - template->baseva + template->size >= + ASSERT (_template->baseva + _template->size < ch->baseva || + _template->baseva + _template->size >= (ch->baseva + ch->size)); index = ch->next; } @@ -64,7 +64,7 @@ clib_valloc_add_chunk (clib_valloc_main_t *vam, clib_valloc_chunk_t *template) if (index != ~0) ch = pool_elt_at_index (vam->chunks, index); - if (index == ~0 || template->baseva < ch->baseva) + if (index == ~0 || _template->baseva < ch->baseva) { pool_get (vam->chunks, new_ch); clib_memset (new_ch, 0, sizeof (*new_ch)); @@ -82,8 +82,8 @@ clib_valloc_add_chunk (clib_valloc_main_t *vam, clib_valloc_chunk_t *template) new_ch->next = new_ch->prev = ~0; } - new_ch->baseva = template->baseva; - new_ch->size = template->size; + new_ch->baseva = _template->baseva; + new_ch->size = _template->size; vam->first_index = new_ch - vam->chunks; @@ -109,8 +109,8 @@ clib_valloc_add_chunk (clib_valloc_main_t *vam, clib_valloc_chunk_t *template) new_ch->prev = index; ch->next = new_ch - vam->chunks; - new_ch->baseva = template->baseva; - new_ch->size = template->size; + new_ch->baseva = _template->baseva; + new_ch->size = _template->size; hash_set (vam->chunk_index_by_baseva, new_ch->baseva, new_ch - vam->chunks); @@ -121,14 +121,14 @@ clib_valloc_add_chunk (clib_valloc_main_t *vam, clib_valloc_chunk_t *template) /** Initialize a virtual memory allocation arena @param vam - clib_valloc_main_t * pointer to the arena to initialize - @param template - clib_valloc_chunk_t * pointer to a template chunk which + @param _template - clib_valloc_chunk_t * pointer to a template chunk which describes the initial virtual address range */ __clib_export void -clib_valloc_init (clib_valloc_main_t * vam, clib_valloc_chunk_t * template, +clib_valloc_init (clib_valloc_main_t * vam, clib_valloc_chunk_t * _template, int need_lock) { - ASSERT (template && template->baseva && template->size); + ASSERT (_template && _template->baseva && _template->size); clib_memset (vam, 0, sizeof (*vam)); if (need_lock) clib_spinlock_init (&vam->lock); @@ -137,7 +137,7 @@ clib_valloc_init (clib_valloc_main_t * vam, clib_valloc_chunk_t * template, vam->first_index = ~0; vam->flags |= CLIB_VALLOC_INITIALIZED; - clib_valloc_add_chunk (vam, template); + clib_valloc_add_chunk (vam, _template); } /** Allocate virtual space diff --git a/src/vppinfra/valloc.h b/src/vppinfra/valloc.h index 993844eb1bdd..d9991bd9e425 100644 --- a/src/vppinfra/valloc.h +++ b/src/vppinfra/valloc.h @@ -49,10 +49,10 @@ typedef struct /* doxygen tags in valloc.c */ void clib_valloc_init (clib_valloc_main_t * vam, - clib_valloc_chunk_t * template, int need_lock); + clib_valloc_chunk_t * _template, int need_lock); void clib_valloc_add_chunk (clib_valloc_main_t * vam, - clib_valloc_chunk_t * template); + clib_valloc_chunk_t * _template); format_function_t format_valloc; diff --git a/src/vppinfra/vec.h b/src/vppinfra/vec.h index 1a64a69a1e60..e6fafce85882 100644 --- a/src/vppinfra/vec.h +++ b/src/vppinfra/vec.h @@ -162,7 +162,10 @@ _vec_prealloc (void **vp, uword n_elts, uword hdr_sz, uword align, void *heap, uword elt_sz) { const vec_attr_t va = { - .elt_sz = elt_sz, .hdr_sz = hdr_sz, .align = align, .heap = heap + .heap = heap, + .elt_sz = (u32) elt_sz, + .hdr_sz = (u16) hdr_sz, + .align = (u16) align }; void *v; @@ -250,18 +253,22 @@ _vec_resize (void **vp, uword n_add, uword hdr_sz, uword align, uword elt_sz) void *v = *vp; if (PREDICT_FALSE (v == 0)) { - const vec_attr_t va = { .elt_sz = elt_sz, - .align = align, - .hdr_sz = hdr_sz }; + const vec_attr_t va = { + .elt_sz = (u32) elt_sz, + .hdr_sz = (u16) hdr_sz, + .align = (u16) align, + }; *vp = _vec_alloc_internal (n_add, &va); return; } if (PREDICT_FALSE (_vec_find (v)->grow_elts < n_add)) { - const vec_attr_t va = { .elt_sz = elt_sz, - .align = align, - .hdr_sz = hdr_sz }; + const vec_attr_t va = { + .elt_sz = (u32) elt_sz, + .hdr_sz = (u16) hdr_sz, + .align = (u16) align + }; v = _vec_resize_internal (v, _vec_len (v) + n_add, &va); _vec_update_pointer (vp, v); } @@ -410,7 +417,10 @@ static_always_inline void * _vec_dup (void *v, uword hdr_size, uword align, uword elt_sz) { uword len = vec_len (v); - const vec_attr_t va = { .elt_sz = elt_sz, .align = align }; + const vec_attr_t va = { + .elt_sz = (u32) elt_sz, + .align = (u16) align + }; void *n = 0; if (len) @@ -429,7 +439,7 @@ _vec_dup (void *v, uword hdr_size, uword align, uword elt_sz) @param V pointer to a vector @return Vdup copy of vector */ -#define vec_dup(V) vec_dup_ha(V,0,0) +#define vec_dup(V) (__typeof__(V)) vec_dup_ha(V,0,0) /** \brief Return copy of vector (no header, alignment specified). @@ -459,7 +469,10 @@ _vec_dup (void *v, uword hdr_size, uword align, uword elt_sz) static_always_inline void _vec_clone (void **v1p, void *v2, uword align, uword elt_sz) { - const vec_attr_t va = { .elt_sz = elt_sz, .align = align }; + const vec_attr_t va = { + .elt_sz = (u32) elt_sz, + .align = (u16) align + }; v1p[0] = _vec_alloc_internal (vec_len (v2), &va); } #define vec_clone(NEW_V, OLD_V) \ @@ -478,7 +491,7 @@ _vec_clone (void **v1p, void *v2, uword align, uword elt_sz) always_inline void _vec_zero_elts (void *v, uword first, uword count, uword elt_sz) { - clib_memset_u8 (v + (first * elt_sz), 0, count * elt_sz); + clib_memset_u8 ((u8 *) v + (first * elt_sz), 0, count * elt_sz); } #define vec_zero_elts(V, F, C) _vec_zero_elts (V, F, C, sizeof ((V)[0])) @@ -491,9 +504,11 @@ _vec_validate (void **vp, uword index, uword header_size, uword align, if (PREDICT_FALSE (v == 0)) { - const vec_attr_t va = { .elt_sz = elt_sz, - .align = align, - .hdr_sz = header_size }; + const vec_attr_t va = { + .elt_sz = (u32) elt_sz, + .hdr_sz = (u16) header_size, + .align = (u16) align + }; *vp = _vec_alloc_internal (n_elts, &va); return; } @@ -505,9 +520,11 @@ _vec_validate (void **vp, uword index, uword header_size, uword align, if (PREDICT_FALSE (index >= _vec_find (v)->grow_elts + vl)) { - const vec_attr_t va = { .elt_sz = elt_sz, - .align = align, - .hdr_sz = header_size }; + const vec_attr_t va = { + .elt_sz = (u32) elt_sz, + .hdr_sz = (u16) header_size, + .align = (u16) align + }; v = _vec_resize_internal (v, n_elts, &va); _vec_update_pointer (vp, v); } @@ -619,9 +636,11 @@ _vec_add1 (void **vp, uword hdr_sz, uword align, uword elt_sz) if (PREDICT_FALSE (v == 0)) { - const vec_attr_t va = { .elt_sz = elt_sz, - .align = align, - .hdr_sz = hdr_sz }; + const vec_attr_t va = { + .elt_sz = (u32) elt_sz, + .hdr_sz = (u16) hdr_sz, + .align = (u16) align + }; return *vp = _vec_alloc_internal (1, &va); } @@ -629,16 +648,18 @@ _vec_add1 (void **vp, uword hdr_sz, uword align, uword elt_sz) if (PREDICT_FALSE (_vec_find (v)->grow_elts == 0)) { - const vec_attr_t va = { .elt_sz = elt_sz, - .align = align, - .hdr_sz = hdr_sz }; + const vec_attr_t va = { + .elt_sz = (u32) elt_sz, + .hdr_sz = (u16) hdr_sz, + .align = (u16) align + }; v = _vec_resize_internal (v, len + 1, &va); _vec_update_pointer (vp, v); } else _vec_set_len (v, len + 1, elt_sz); - return v + len * elt_sz; + return (u8 *) v + len * elt_sz; } #define vec_add1_ha(V, E, H, A) \ @@ -682,9 +703,11 @@ _vec_add2 (void **vp, void **pp, uword n_add, uword hdr_sz, uword align, if (PREDICT_FALSE (v == 0)) { - const vec_attr_t va = { .elt_sz = elt_sz, - .align = align, - .hdr_sz = hdr_sz }; + const vec_attr_t va = { + .elt_sz = (u32) elt_sz, + .hdr_sz = (u16) hdr_sz, + .align = (u16) align + }; *vp = *pp = _vec_alloc_internal (n_add, &va); return; } @@ -692,16 +715,18 @@ _vec_add2 (void **vp, void **pp, uword n_add, uword hdr_sz, uword align, len = _vec_len (v); if (PREDICT_FALSE (_vec_find (v)->grow_elts < n_add)) { - const vec_attr_t va = { .elt_sz = elt_sz, - .align = align, - .hdr_sz = hdr_sz }; + const vec_attr_t va = { + .elt_sz = (u32) elt_sz, + .hdr_sz = (u16) hdr_sz, + .align = (u16) align + }; v = _vec_resize_internal (v, len + n_add, &va); _vec_update_pointer (vp, v); } else _vec_set_len (v, len + n_add, elt_sz); - *pp = v + len * elt_sz; + *pp = (u8 *) v + len * elt_sz; } #define vec_add2_ha(V, P, N, H, A) \ @@ -754,9 +779,11 @@ _vec_add (void **vp, void *e, word n_add, uword hdr_sz, uword align, if (PREDICT_FALSE (v == 0)) { - const vec_attr_t va = { .elt_sz = elt_sz, - .align = align, - .hdr_sz = hdr_sz }; + const vec_attr_t va = { + .elt_sz = (u32) elt_sz, + .hdr_sz = (u16) hdr_sz, + .align = (u16) align + }; *vp = v = _vec_alloc_internal (n_add, &va); clib_memcpy_fast (v, e, n_add * elt_sz); return; @@ -766,16 +793,18 @@ _vec_add (void **vp, void *e, word n_add, uword hdr_sz, uword align, if (PREDICT_FALSE (_vec_find (v)->grow_elts < n_add)) { - const vec_attr_t va = { .elt_sz = elt_sz, - .align = align, - .hdr_sz = hdr_sz }; + const vec_attr_t va = { + .elt_sz = (u32) elt_sz, + .hdr_sz = (u16) hdr_sz, + .align = (u16) align + }; v = _vec_resize_internal (v, len + n_add, &va); _vec_update_pointer (vp, v); } else _vec_set_len (v, len + n_add, elt_sz); - clib_memcpy_fast (v + len * elt_sz, e, n_add * elt_sz); + clib_memcpy_fast ((u8 *) v + len * elt_sz, e, n_add * elt_sz); } #define vec_add_ha(V, E, N, H, A) \ @@ -849,12 +878,16 @@ _vec_insert (void **vp, uword n_insert, uword ins_pt, u8 init, uword hdr_sz, { void *v = vp[0]; uword len = vec_len (v); - const vec_attr_t va = { .elt_sz = elt_sz, .align = align, .hdr_sz = hdr_sz }; + const vec_attr_t va = { + .elt_sz = (u32) elt_sz, + .hdr_sz = (u16) hdr_sz, + .align = (u16) align, + }; ASSERT (ins_pt <= len); v = _vec_resize_internal (v, len + n_insert, &va); - clib_memmove (v + va.elt_sz * (ins_pt + n_insert), v + ins_pt * elt_sz, + clib_memmove ((u8 *) v + va.elt_sz * (ins_pt + n_insert), (u8 *) v + ins_pt * elt_sz, (len - ins_pt) * elt_sz); _vec_zero_elts (v, ins_pt, n_insert, elt_sz); _vec_update_pointer (vp, v); @@ -942,15 +975,19 @@ _vec_insert_elts (void **vp, void *e, uword n_insert, uword ins_pt, { void *v = vp[0]; uword len = vec_len (v); - const vec_attr_t va = { .elt_sz = elt_sz, .align = align, .hdr_sz = hdr_sz }; + const vec_attr_t va = { + .elt_sz = (u32) elt_sz, + .hdr_sz = (u16) hdr_sz, + .align = (u16) align + }; ASSERT (ins_pt <= len); v = _vec_resize_internal (v, len + n_insert, &va); - clib_memmove (v + elt_sz * (ins_pt + n_insert), v + ins_pt * elt_sz, + clib_memmove ((u8 *) v + elt_sz * (ins_pt + n_insert), (u8 *) v + ins_pt * elt_sz, (len - ins_pt) * elt_sz); _vec_zero_elts (v, ins_pt, n_insert, elt_sz); - clib_memcpy_fast (v + ins_pt * elt_sz, e, n_insert * elt_sz); + clib_memcpy_fast ((u8 *) v + ins_pt * elt_sz, e, n_insert * elt_sz); _vec_update_pointer (vp, v); } @@ -1002,7 +1039,7 @@ _vec_delete (void *v, uword n_del, uword first, uword elt_sz) n_bytes_del = n_del * elt_sz; n_bytes_to_move = (len - first - n_del) * elt_sz; - dst = v + first * elt_sz; + dst = (u8 *) v + first * elt_sz; if (n_bytes_to_move > 0) clib_memmove (dst, dst + n_bytes_del, n_bytes_to_move); @@ -1025,7 +1062,7 @@ _vec_del1 (void *v, uword index, uword elt_sz) uword len = _vec_len (v) - 1; if (index < len) - clib_memcpy_fast (v + index * elt_sz, v + len * elt_sz, elt_sz); + clib_memcpy_fast ((u8 *) v + index * elt_sz, (u8 *) v + len * elt_sz, elt_sz); _vec_set_len (v, len, elt_sz); } @@ -1042,9 +1079,12 @@ _vec_append (void **v1p, void *v2, uword v1_elt_sz, uword v2_elt_sz, if (PREDICT_TRUE (len2 > 0)) { - const vec_attr_t va = { .elt_sz = v2_elt_sz, .align = align }; + const vec_attr_t va = { + .elt_sz = (u32) v2_elt_sz, + .align = (u16) align + }; v1 = _vec_resize_internal (v1, len1 + len2, &va); - clib_memcpy_fast (v1 + len1 * v1_elt_sz, v2, len2 * v2_elt_sz); + clib_memcpy_fast ((u8 *) v1 + len1 * v1_elt_sz, v2, len2 * v2_elt_sz); _vec_update_pointer (v1p, v1); } } @@ -1067,10 +1107,10 @@ _vec_append (void **v1p, void *v2, uword v1_elt_sz, uword v2_elt_sz, #define vec_append(v1, v2) vec_append_aligned (v1, v2, 0) static_always_inline void -_vec_prepend (void *restrict *v1p, void *restrict v2, uword v1_elt_sz, +_vec_prepend (void *__restrict__ *v1p, void *__restrict__ v2, uword v1_elt_sz, uword v2_elt_sz, uword align) { - void *restrict v1 = v1p[0]; + void *__restrict__ v1 = v1p[0]; uword len1 = vec_len (v1); uword len2 = vec_len (v2); @@ -1078,9 +1118,12 @@ _vec_prepend (void *restrict *v1p, void *restrict v2, uword v1_elt_sz, { /* prepending vector to itself would result in use-after-free */ ASSERT (v1 != v2); - const vec_attr_t va = { .elt_sz = v2_elt_sz, .align = align }; + const vec_attr_t va = { + .elt_sz = (u32) v2_elt_sz, + .align = (u16) align + }; v1 = _vec_resize_internal (v1, len1 + len2, &va); - clib_memmove (v1 + len2 * v2_elt_sz, v1, len1 * v1_elt_sz); + clib_memmove ((u8 *) v1 + len2 * v2_elt_sz, v1, len1 * v1_elt_sz); clib_memcpy_fast (v1, v2, len2 * v2_elt_sz); _vec_update_pointer ((void **) v1p, v1); } diff --git a/src/vppinfra/vec_bootstrap.h b/src/vppinfra/vec_bootstrap.h index 5d386b1eaadd..8e5a8de62fbb 100644 --- a/src/vppinfra/vec_bootstrap.h +++ b/src/vppinfra/vec_bootstrap.h @@ -63,7 +63,7 @@ typedef struct u8 vector_data[0]; /**< Vector data . */ } vec_header_t; -#define VEC_MIN_ALIGN 8 +#define VEC_MIN_ALIGN 8ULL /** \brief Find the vector header @@ -81,9 +81,41 @@ always_inline uword __vec_elt_sz (uword elt_sz, int is_void); #define _vec_round_size(s) \ (((s) + sizeof (uword) - 1) &~ (sizeof (uword) - 1)) + +#ifdef __cplusplus +extern "C++" +{ + +#include + +#define _vec_is_void(P) std::is_same::value + +template +inline uword _element_size(T* p) +{ + return sizeof(T); +} + +template <> +inline uword _element_size(void* p) +{ + return sizeof(u8); +} + +template <> +inline uword _element_size(void** p) +{ + return sizeof(u8 *); +} + +} +#else +#define _element_size(P) sizeof ((P)[0]) #define _vec_is_void(P) \ __builtin_types_compatible_p (__typeof__ ((P)[0]), void) -#define _vec_elt_sz(V) __vec_elt_sz (sizeof ((V)[0]), _vec_is_void (V)) +#endif + +#define _vec_elt_sz(V) __vec_elt_sz (_element_size(V), _vec_is_void (V)) #define _vec_align(V, A) __vec_align (__alignof__((V)[0]), A) always_inline __clib_nosanitize_addr uword @@ -102,7 +134,7 @@ vec_get_header_size (void *v) always_inline void * vec_header (void *v) { - return v ? v - vec_get_header_size (v) : 0; + return v ? (u8 *) v - vec_get_header_size (v) : 0; } /** \brief Find the end of user vector header @@ -114,7 +146,7 @@ vec_header (void *v) always_inline void * vec_header_end (void *v) { - return v + vec_get_header_size (v); + return (u8 *) v + vec_get_header_size (v); } /** \brief Number of elements in vector (rvalue-only, NULL tolerant) @@ -189,9 +221,9 @@ _vec_set_len (void *v, uword len, uword elt_sz) uword grow_elts = _vec_find (v)->grow_elts; if (len > old_len) - clib_mem_unpoison (v + old_len * elt_sz, (len - old_len) * elt_sz); + clib_mem_unpoison ((u8 *) v + old_len * elt_sz, (len - old_len) * elt_sz); else if (len < old_len) - clib_mem_poison (v + len * elt_sz, (old_len - len) * elt_sz); + clib_mem_poison ((u8 *) v + len * elt_sz, (old_len - len) * elt_sz); _vec_set_grow_elts (v, old_len + grow_elts - len); _vec_find (v)->len = len; diff --git a/src/vppinfra/vector/index_to_ptr.h b/src/vppinfra/vector/index_to_ptr.h index 3985b757d544..a1e8ce6426b1 100644 --- a/src/vppinfra/vector/index_to_ptr.h +++ b/src/vppinfra/vector/index_to_ptr.h @@ -247,7 +247,7 @@ clib_index_to_ptr_u32 (u32 *indices, void *base, u8 shift, void **ptrs, #endif while (n_elts) { - ptrs[0] = base + ((u64) indices[0] << shift); + ptrs[0] = (u64 *) ((u8 *) base + ((u64) indices[0] << shift)); ptrs += 1; indices += 1; n_elts -= 1; diff --git a/src/vppinfra/vector_avx2.h b/src/vppinfra/vector_avx2.h index 866c82fcec38..18f3a6157789 100644 --- a/src/vppinfra/vector_avx2.h +++ b/src/vppinfra/vector_avx2.h @@ -37,7 +37,7 @@ t##s##x##c##_splat (t##s x) \ \ static_always_inline t##s##x##c \ t##s##x##c##_load_unaligned (void *p) \ -{ return (t##s##x##c) _mm256_loadu_si256 (p); } \ +{ return (t##s##x##c) _mm256_loadu_si256 ((const __m256i_u *) p); } \ \ static_always_inline void \ t##s##x##c##_store_unaligned (t##s##x##c v, void *p) \ @@ -232,22 +232,22 @@ u16x16_mask_last (u16x16 v, u8 n_last) { const u16x16 masks[17] = { {0}, - {-1}, - {-1, -1}, - {-1, -1, -1}, - {-1, -1, -1, -1}, - {-1, -1, -1, -1, -1}, - {-1, -1, -1, -1, -1, -1}, - {-1, -1, -1, -1, -1, -1, -1}, - {-1, -1, -1, -1, -1, -1, -1, -1}, - {-1, -1, -1, -1, -1, -1, -1, -1, -1}, - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, + {(u16)~0}, + {(u16)~0, (u16)~0}, + {(u16)~0, (u16)~0, (u16)~0}, + {(u16)~0, (u16)~0, (u16)~0, (u16)~0}, + {(u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0}, + {(u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0}, + {(u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0}, + {(u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0}, + {(u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0}, + {(u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0}, + {(u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0}, + {(u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0}, + {(u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0}, + {(u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0}, + {(u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0}, + {(u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0, (u16)~0}, }; ASSERT (n_last < 17); diff --git a/src/vppinfra/vector_sse42.h b/src/vppinfra/vector_sse42.h index 58d5da90125b..6f238d2ba710 100644 --- a/src/vppinfra/vector_sse42.h +++ b/src/vppinfra/vector_sse42.h @@ -57,7 +57,7 @@ t##s##x##c##_splat (t##s x) \ \ static_always_inline t##s##x##c \ t##s##x##c##_load_unaligned (void *p) \ -{ return (t##s##x##c) _mm_loadu_si128 (p); } \ +{ return (t##s##x##c) _mm_loadu_si128 ((const __m128i_u *) p); } \ \ static_always_inline void \ t##s##x##c##_store_unaligned (t##s##x##c v, void *p) \