misc: fix issues reported by clang-15 87/37387/1
authorDamjan Marion <dmarion@me.com>
Wed, 12 Oct 2022 14:02:18 +0000 (16:02 +0200)
committerDamjan Marion <dmarion@me.com>
Wed, 12 Oct 2022 14:04:13 +0000 (16:04 +0200)
Type: improvement

Change-Id: I3fbbda0378b72843ecd39a7e8592dedc9757793a
Signed-off-by: Damjan Marion <dmarion@me.com>
26 files changed:
src/plugins/dhcp/dhcp6_proxy_node.c
src/plugins/ikev2/ikev2.c
src/plugins/ikev2/ikev2_priv.h
src/plugins/ioam/analyse/ioam_summary_export.c
src/plugins/ioam/lib-pot/math64.h
src/plugins/ioam/udp-ping/udp_ping_export.c
src/plugins/lb/api.c
src/plugins/lisp/lisp-cp/control.h
src/plugins/nat/det44/det44.h
src/plugins/quic/quic.c
src/plugins/srv6-ad/node.c
src/plugins/srv6-am/node.c
src/plugins/srv6-as/node.c
src/vat/vat.h
src/vlib/cli.c
src/vlib/node.h
src/vnet/devices/pipe/pipe.c
src/vnet/interface.h
src/vnet/ip/reass/ip4_full_reass.c
src/vnet/ip/reass/ip6_full_reass.c
src/vnet/ipfix-export/flow_report_classify.c
src/vnet/ipsec/esp_decrypt.c
src/vnet/ipsec/esp_encrypt.c
src/vnet/session/session.h
src/vpp-api/client/test.c
src/vppinfra/dlmalloc.c

index 1120769..ad0b704 100644 (file)
@@ -136,8 +136,8 @@ dhcpv6_proxy_to_server_input (vlib_main_t * vm,
   dhcp_proxy_main_t *dpm = &dhcp_proxy_main;
   from = vlib_frame_vector_args (from_frame);
   n_left_from = from_frame->n_vectors;
-  u32 pkts_to_server = 0, pkts_to_client = 0, pkts_no_server = 0;
-  u32 pkts_no_interface_address = 0, pkts_no_exceeding_max_hop = 0;
+  u32 pkts_to_server = 0, pkts_to_client = 0;
+  u32 pkts_no_interface_address = 0;
   u32 pkts_no_src_address = 0;
   u32 pkts_wrong_msg_type = 0;
   u32 pkts_too_big = 0;
@@ -236,7 +236,6 @@ dhcpv6_proxy_to_server_input (vlib_main_t * vm,
            {
              error0 = DHCPV6_PROXY_ERROR_NO_SERVER;
              next0 = DHCPV6_PROXY_TO_SERVER_INPUT_NEXT_DROP;
-             pkts_no_server++;
              goto do_trace;
            }
 
@@ -274,7 +273,6 @@ dhcpv6_proxy_to_server_input (vlib_main_t * vm,
            {
              error0 = DHCPV6_RELAY_PKT_DROP_MAX_HOPS;
              next0 = DHCPV6_PROXY_TO_SERVER_INPUT_NEXT_DROP;
-             pkts_no_exceeding_max_hop++;
              goto do_trace;
            }
 
index 32331ff..f0eaa7a 100644 (file)
@@ -4445,7 +4445,7 @@ ikev2_resolve_responder_hostname (vlib_main_t *vm, ikev2_responder_t *r)
   u8 *name;
   int rv;
 
-  if (!km->dns_resolve_name)
+  if (!km->dns_resolve_name_ptr)
     return clib_error_return (0, "cannot load symbols from dns plugin");
 
   t0->request_type = DNS_API_PENDING_NAME_TO_IP;
@@ -4453,7 +4453,8 @@ ikev2_resolve_responder_hostname (vlib_main_t *vm, ikev2_responder_t *r)
    * whereas DNS resolver expects a NULL-terminated C-string */
   name = vec_dup (r->hostname);
   vec_terminate_c_string (name);
-  rv = km->dns_resolve_name (name, &ep, t0, rn);
+  rv = ((__typeof__ (dns_resolve_name) *) km->dns_resolve_name_ptr) (name, &ep,
+                                                                    t0, rn);
   vec_free (name);
   if (rv < 0)
     return clib_error_return (0, "dns lookup failure");
@@ -5443,9 +5444,9 @@ ikev2_lazy_init (ikev2_main_t *km)
 
   km->punt_hdl = vlib_punt_client_register ("ikev2");
 
-  km->dns_resolve_name =
+  km->dns_resolve_name_ptr =
     vlib_get_plugin_symbol ("dns_plugin.so", "dns_resolve_name");
-  if (!km->dns_resolve_name)
+  if (!km->dns_resolve_name_ptr)
     ikev2_log_error ("cannot load symbols from dns plugin");
 
   /* wake up ikev2 process */
index 4ce1478..faa0ca7 100644 (file)
@@ -532,7 +532,7 @@ typedef struct
   u8 dpd_disabled;
 
   /* pointer to name resolver function in dns plugin */
-  int (*dns_resolve_name) ();
+  void *dns_resolve_name_ptr;
 
   /* flag indicating whether lazy init is done or not */
   int lazy_init_done;
index ceec155..09884fd 100644 (file)
@@ -275,7 +275,6 @@ ioam_send_flows (flow_report_main_t *frm, ipfix_exporter_t *exp,
   ipfix_set_header_t *s = NULL;
   ip4_header_t *ip;
   udp_header_t *udp;
-  u32 records_this_buffer;
   u16 new_l0, old_l0;
   ip_csum_t sum0;
   vlib_main_t *vm = vlib_get_main ();
@@ -329,13 +328,11 @@ ioam_send_flows (flow_report_main_t *frm, ipfix_exporter_t *exp,
            h->sequence_number = stream->sequence_number++;
            h->sequence_number = clib_host_to_net_u32 (h->sequence_number);
            next_offset = (u32) (((u8 *) (s + 1)) - (u8 *) tp);
-           records_this_buffer = 0;
          }
 
        next_offset = ioam_analyse_add_ipfix_record (fr, record,
                                                     b0, next_offset,
                                                     &temp, &temp, 0, 0);
-       records_this_buffer++;
 
        /* Flush data if packet len is about to reach path mtu */
        if (next_offset > (exp->path_mtu - 250))
index 4c608a3..2084c25 100644 (file)
@@ -51,23 +51,23 @@ static inline void mul64by64(u64 a, u64 b, u64 * hi, u64 * lo)
 
 static inline u64 mod128by64(u64 x, u64 y, u64 m, double di)
 {
-    u64 q1, q2, q;
-    u64 p1, p0;
-    double dq;
+  u64 q1, q2;
+  u64 p1, p0;
+  double dq;
 
-    /* calculate quotient first pass 53 bits */
-    dq = (TWO64 * (double)x + (double)y) * di;
+  /* calculate quotient first pass 53 bits */
+  dq = (TWO64 * (double) x + (double) y) * di;
 
-    if (dq >= TWO64)
-        q1 = 0xfffffffffffff800L;
-    else
-        q1 = dq;
+  if (dq >= TWO64)
+    q1 = 0xfffffffffffff800L;
+  else
+    q1 = dq;
 
-    /* q1 * m to compare the product to the dividend.  */
-    mul64by64(q1, m, &p1, &p0);
+  /* q1 * m to compare the product to the dividend.  */
+  mul64by64 (q1, m, &p1, &p0);
 
-    /* Adjust quotient. is it > actual result: */
-    if (x < p1 || (x == p1 && y < p0))
+  /* Adjust quotient. is it > actual result: */
+  if (x < p1 || (x == p1 && y < p0))
     {
         /* q1 > quotient.  calculate abs remainder */
         x = p1 - (x + (p0 < y));
@@ -77,7 +77,6 @@ static inline u64 mod128by64(u64 x, u64 y, u64 m, double di)
         q2 = (u64) ((TWO64 * (double)x + (double)y) * di);
         mul64by64(q2, m, &p1, &p0);
 
-        q = q1 - q2;
         if (x < p1 || (x == p1 && y <= p0))
         {
             y = p0 - y;
@@ -86,7 +85,6 @@ static inline u64 mod128by64(u64 x, u64 y, u64 m, double di)
         {
             y = p0 - y;
             y += m;
-            q--;
         }
     }
     else
@@ -97,12 +95,10 @@ static inline u64 mod128by64(u64 x, u64 y, u64 m, double di)
         q2 = (u64) ((TWO64 * (double)x + (double)y) * di);
         mul64by64(q2, m, &p1, &p0);
 
-        q = q1 + q2;
         if (x < p1 || (x == p1 && y < p0))
         {
             y = y - p0;
             y += m;
-            q--;
         }
         else
         {
@@ -110,7 +106,6 @@ static inline u64 mod128by64(u64 x, u64 y, u64 m, double di)
             if (y >= m)
             {
                 y -= m;
-                q++;
             }
         }
     }
index 3dc1436..de0bad7 100644 (file)
@@ -45,7 +45,6 @@ udp_ping_send_flows (flow_report_main_t *frm, ipfix_exporter_t *exp,
   ipfix_set_header_t *s = NULL;
   ip4_header_t *ip;
   udp_header_t *udp;
-  u32 records_this_buffer;
   u16 new_l0, old_l0;
   ip_csum_t sum0;
   vlib_main_t *vm = vlib_get_main ();
@@ -99,7 +98,6 @@ udp_ping_send_flows (flow_report_main_t *frm, ipfix_exporter_t *exp,
                  h->sequence_number =
                    clib_host_to_net_u32 (h->sequence_number);
                  next_offset = (u32) (((u8 *) (s + 1)) - (u8 *) tp);
-                 records_this_buffer = 0;
                }
 
              next_offset = ioam_analyse_add_ipfix_record (fr,
@@ -115,8 +113,6 @@ udp_ping_send_flows (flow_report_main_t *frm, ipfix_exporter_t *exp,
              //memcpy (b0->data + next_offset, &pak_sent, sizeof(u32));
              //next_offset += sizeof(u32);
 
-             records_this_buffer++;
-
              /* Flush data if packet len is about to reach path mtu */
              if (next_offset > (exp->path_mtu - UDP_PING_EXPORT_RECORD_SIZE))
                {
index 3aa745c..bf4a50d 100644 (file)
@@ -209,7 +209,6 @@ static void send_lb_as_details
   lb_main_t *lbm = &lb_main;
   int msg_size = 0;
   u32 *as_index;
-  u32 asindex = 0;
 
   /* construct as list under this vip */
   lb_as_t *as;
@@ -233,7 +232,6 @@ static void send_lb_as_details
         rmp->in_use_since = htonl(as->last_used);
 
         vl_api_send_msg (reg, (u8 *) rmp);
-        asindex++;
       }
   }
 
index 524f502..e65ceaf 100644 (file)
@@ -299,7 +299,7 @@ extern vlib_node_registration_t lisp_cp_input_node;
 extern vlib_node_registration_t lisp_cp_lookup_ip4_node;
 extern vlib_node_registration_t lisp_cp_lookup_ip6_node;
 
-clib_error_t *lisp_cp_init ();
+clib_error_t *lisp_cp_init (vlib_main_t *);
 
 always_inline lisp_cp_main_t *
 vnet_lisp_cp_get_main ()
index 20dc8b1..7d290f4 100644 (file)
@@ -229,7 +229,7 @@ plugin_enabled ()
 extern vlib_node_registration_t det44_in2out_node;
 extern vlib_node_registration_t det44_out2in_node;
 
-int det44_plugin_enable ();
+int det44_plugin_enable (det44_config_t);
 int det44_plugin_disable ();
 
 int det44_interface_add_del (u32 sw_if_index, u8 is_inside, int is_del);
index 3965124..5106031 100644 (file)
@@ -2674,7 +2674,6 @@ quic_get_counter_value (u32 event_code)
 
   u32 code, i;
   u64 c, sum = 0;
-  int index = 0;
 
   vm = vlib_get_main ();
   em = &vm->error_main;
@@ -2689,7 +2688,6 @@ quic_get_counter_value (u32 event_code)
       if (i < vec_len (em->counters_last_clear))
        c -= em->counters_last_clear[i];
       sum += c;
-      index++;
     }
   return sum;
 }
index 9d4ea44..f04d4ac 100644 (file)
@@ -203,7 +203,6 @@ srv6_ad_localsid_fn (vlib_main_t * vm,
 {
   ip6_sr_main_t *sm = &sr_main;
   u32 n_left_from, next_index, *from, *to_next;
-  u32 cnt_packets = 0;
 
   from = vlib_frame_vector_args (frame);
   n_left_from = frame->n_vectors;
@@ -264,7 +263,6 @@ srv6_ad_localsid_fn (vlib_main_t * vm,
          vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
                                           n_left_to_next, bi0, next0);
 
-         cnt_packets++;
        }
 
       vlib_put_next_frame (vm, node, next_index, n_left_to_next);
index dd71e60..dd2b1c4 100644 (file)
@@ -142,7 +142,6 @@ srv6_am_localsid_fn (vlib_main_t * vm,
 {
   ip6_sr_main_t *sm = &sr_main;
   u32 n_left_from, next_index, *from, *to_next;
-  u32 cnt_packets = 0;
 
   from = vlib_frame_vector_args (frame);
   n_left_from = frame->n_vectors;
@@ -203,8 +202,6 @@ srv6_am_localsid_fn (vlib_main_t * vm,
 
          vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
                                           n_left_to_next, bi0, next0);
-
-         cnt_packets++;
        }
 
       vlib_put_next_frame (vm, node, next_index, n_left_to_next);
index 9e84a98..4beb8df 100644 (file)
@@ -169,7 +169,6 @@ srv6_as_localsid_fn (vlib_main_t * vm,
 {
   ip6_sr_main_t *sm = &sr_main;
   u32 n_left_from, next_index, *from, *to_next;
-  u32 cnt_packets = 0;
 
   from = vlib_frame_vector_args (frame);
   n_left_from = frame->n_vectors;
@@ -227,8 +226,6 @@ srv6_as_localsid_fn (vlib_main_t * vm,
 
          vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
                                           n_left_to_next, bi0, next0);
-
-         cnt_packets++;
        }
 
       vlib_put_next_frame (vm, node, next_index, n_left_to_next);
index 10199e3..d804575 100644 (file)
@@ -131,7 +131,7 @@ typedef struct
 
 struct vat_registered_features_t;
 
-typedef struct
+typedef struct vat_main_
 {
   /* vpe input queue */
   svm_queue_t *vl_input_queue;
@@ -234,7 +234,7 @@ typedef struct
 
   struct vat_registered_features_t *feature_function_registrations;
 
-  int (*api_sw_interface_dump) ();
+  int (*api_sw_interface_dump) (struct vat_main_ *);
 
   /* Convenience */
   vlib_main_t *vlib_main;
index c43371e..9c53200 100644 (file)
@@ -872,14 +872,14 @@ show_memory_usage (vlib_main_t * vm,
     }
   if (stats_segment)
     {
-      void *oldheap = vlib_stats_set_heap (0);
+      void *oldheap = vlib_stats_set_heap ();
       was_enabled = clib_mem_trace_enable_disable (0);
       u8 *s_in_svm = format (0, "%U\n", format_clib_mem_heap, 0, 1);
       if (oldheap)
        clib_mem_set_heap (oldheap);
       u8 *s = vec_dup (s_in_svm);
 
-      oldheap = vlib_stats_set_heap (0);
+      oldheap = vlib_stats_set_heap ();
       vec_free (s_in_svm);
       if (oldheap)
        {
index dbff6c1..e40208b 100644 (file)
@@ -201,7 +201,8 @@ static __clib_unused vlib_node_registration_t __clib_unused_##x
 #endif
 
 #define VLIB_NODE_FN(node)                                                    \
-  uword CLIB_MARCH_SFX (node##_fn) ();                                        \
+  uword CLIB_MARCH_SFX (node##_fn) (vlib_main_t *, vlib_node_runtime_t *,     \
+                                   vlib_frame_t *);                          \
   static vlib_node_fn_registration_t CLIB_MARCH_SFX (                         \
     node##_fn_registration) = {                                               \
     .function = &CLIB_MARCH_SFX (node##_fn),                                  \
index 26b0197..cd22c1a 100644 (file)
@@ -131,7 +131,7 @@ pipe_tx (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
 {
   u32 n_left_from, n_left_to_next, n_copy, *from, *to_next;
   u32 next_index = VNET_PIPE_TX_NEXT_ETHERNET_INPUT;
-  u32 i, sw_if_index = 0, n_pkts = 0;
+  u32 i, sw_if_index = 0;
   vlib_buffer_t *b;
   pipe_t *pipe;
 
@@ -159,7 +159,6 @@ pipe_tx (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
          vnet_buffer (b)->sw_if_index[VLIB_TX] = ~0;
 
          i++;
-         n_pkts++;
        }
       from += n_copy;
 
index c8fbc61..8ba5c99 100644 (file)
@@ -320,7 +320,8 @@ static __clib_unused vnet_device_class_t __clib_unused_##x
 #endif
 
 #define VNET_DEVICE_CLASS_TX_FN(devclass)                                     \
-  uword CLIB_MARCH_SFX (devclass##_tx_fn) ();                                 \
+  uword CLIB_MARCH_SFX (devclass##_tx_fn) (                                   \
+    vlib_main_t *, vlib_node_runtime_t *, vlib_frame_t *);                    \
   static vlib_node_fn_registration_t CLIB_MARCH_SFX (                         \
     devclass##_tx_fn_registration) = {                                        \
     .function = &CLIB_MARCH_SFX (devclass##_tx_fn),                           \
index 5b69234..fca96af 100644 (file)
@@ -647,7 +647,6 @@ ip4_full_reass_finalize (vlib_main_t * vm, vlib_node_runtime_t * node,
   vlib_buffer_t *last_b = NULL;
   u32 sub_chain_bi = reass->first_bi;
   u32 total_length = 0;
-  u32 buf_cnt = 0;
   do
     {
       u32 tmp_bi = sub_chain_bi;
@@ -684,7 +683,6 @@ ip4_full_reass_finalize (vlib_main_t * vm, vlib_node_runtime_t * node,
        vlib_buffer_length_in_chain (vm, tmp) - trim_front - trim_end;
       while (1)
        {
-         ++buf_cnt;
          if (trim_front)
            {
              if (trim_front > tmp->current_length)
index 9781557..582dbf6 100644 (file)
@@ -705,8 +705,6 @@ ip6_full_reass_finalize (vlib_main_t * vm, vlib_node_runtime_t * node,
   vlib_buffer_t *last_b = NULL;
   u32 sub_chain_bi = reass->first_bi;
   u32 total_length = 0;
-  u32 buf_cnt = 0;
-  u32 dropped_cnt = 0;
   u32 *vec_drop_compress = NULL;
   ip6_full_reass_rc_t rv = IP6_FULL_REASS_RC_OK;
   do
@@ -748,7 +746,6 @@ ip6_full_reass_finalize (vlib_main_t * vm, vlib_node_runtime_t * node,
        vlib_buffer_length_in_chain (vm, tmp) - trim_front - trim_end;
       while (1)
        {
-         ++buf_cnt;
          if (trim_front)
            {
              if (trim_front > tmp->current_length)
@@ -804,7 +801,6 @@ ip6_full_reass_finalize (vlib_main_t * vm, vlib_node_runtime_t * node,
                  goto free_buffers_and_return;
                }
              vec_add1 (vec_drop_compress, tmp_bi);
-             ++dropped_cnt;
            }
          if (tmp->flags & VLIB_BUFFER_NEXT_PRESENT)
            {
index ea6ba5c..7e9fcfc 100644 (file)
@@ -179,7 +179,6 @@ ipfix_classify_send_flows (flow_report_main_t *frm, ipfix_exporter_t *exp,
   tcpudp_header_t *tcpudp;
   udp_header_t *udp;
   int field_index;
-  u32 records_this_buffer;
   u16 new_l0, old_l0;
   ip_csum_t sum0;
   vlib_main_t *vm = frm->vlib_main;
@@ -251,7 +250,6 @@ ipfix_classify_send_flows (flow_report_main_t *frm, ipfix_exporter_t *exp,
 
                  next_offset = (u32) (((u8 *) (s + 1)) - (u8 *) tp);
                  record_offset = next_offset;
-                 records_this_buffer = 0;
                }
 
              field_index = 0;
@@ -275,7 +273,6 @@ ipfix_classify_send_flows (flow_report_main_t *frm, ipfix_exporter_t *exp,
                                  sizeof (packets));
                next_offset += sizeof (packets);
              }
-             records_this_buffer++;
              stream->sequence_number++;
 
              /* Next record will have the same size as this record */
index af90bc4..f80b379 100644 (file)
@@ -1017,7 +1017,7 @@ esp_decrypt_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
   vlib_buffer_t *sync_bufs[VLIB_FRAME_SIZE];
   u16 sync_nexts[VLIB_FRAME_SIZE], *sync_next = sync_nexts, n_sync = 0;
   u16 async_nexts[VLIB_FRAME_SIZE], *async_next = async_nexts;
-  u16 noop_nexts[VLIB_FRAME_SIZE], *noop_next = noop_nexts, n_noop = 0;
+  u16 noop_nexts[VLIB_FRAME_SIZE], n_noop = 0;
   u32 sync_bi[VLIB_FRAME_SIZE];
   u32 noop_bi[VLIB_FRAME_SIZE];
   esp_decrypt_packet_data_t pkt_data[VLIB_FRAME_SIZE], *pd = pkt_data;
@@ -1196,7 +1196,6 @@ esp_decrypt_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
        {
          noop_bi[n_noop] = from[b - bufs];
          n_noop++;
-         noop_next++;
        }
       else if (!is_async)
        {
index 4ed3bf7..4d312be 100644 (file)
@@ -573,8 +573,8 @@ esp_encrypt_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
                                               ESP_ENCRYPT_NEXT_HANDOFF_MPLS));
   vlib_buffer_t *sync_bufs[VLIB_FRAME_SIZE];
   u16 sync_nexts[VLIB_FRAME_SIZE], *sync_next = sync_nexts, n_sync = 0;
-  u16 async_nexts[VLIB_FRAME_SIZE], *async_next = async_nexts, n_async = 0;
-  u16 noop_nexts[VLIB_FRAME_SIZE], *noop_next = noop_nexts, n_noop = 0;
+  u16 n_async = 0;
+  u16 noop_nexts[VLIB_FRAME_SIZE], n_noop = 0;
   u32 sync_bi[VLIB_FRAME_SIZE];
   u32 noop_bi[VLIB_FRAME_SIZE];
   esp_encrypt_error_t err;
@@ -995,7 +995,6 @@ esp_encrypt_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
        {
          noop_bi[n_noop] = from[b - bufs];
          n_noop++;
-         noop_next++;
        }
       else if (!is_async)
        {
@@ -1007,7 +1006,6 @@ esp_encrypt_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
       else
        {
          n_async++;
-         async_next++;
        }
       n_left -= 1;
       b += 1;
index a68e512..4fa9194 100644 (file)
@@ -769,7 +769,7 @@ void session_wrk_enable_adaptive_mode (session_worker_t *wrk);
 fifo_segment_t *session_main_get_wrk_mqs_segment (void);
 void session_node_enable_disable (u8 is_en);
 clib_error_t *vnet_session_enable_disable (vlib_main_t * vm, u8 is_en);
-void session_wrk_handle_evts_main_rpc ();
+void session_wrk_handle_evts_main_rpc (void *);
 
 session_t *session_alloc_for_connection (transport_connection_t * tc);
 session_t *session_alloc_for_half_open (transport_connection_t *tc);
index 86d6aef..c242e66 100644 (file)
@@ -70,7 +70,6 @@ wrap_vac_callback (unsigned char *data, int len)
 static void
 test_connect ()
 {
-  static int i;
   int rv = vac_connect("vac_client", NULL, wrap_vac_callback, 32 /* rx queue-length*/);
   if (rv != 0) {
     printf("Connect failed: %d\n", rv);
@@ -78,7 +77,6 @@ test_connect ()
   }
   printf(".");
   vac_disconnect();
-  i++;
 }
 
 static void
index cc5915a..5cdc6f6 100644 (file)
@@ -2596,7 +2596,7 @@ static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) {
   msegmentptr ss = (msegmentptr)(chunk2mem(sp));
   mchunkptr tnext = chunk_plus_offset(sp, ssize);
   mchunkptr p = tnext;
-  int nfences = 0;
+  int __attribute__((unused)) nfences = 0;
 
   /* reset top to new space */
   init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE);