test: clean LTO warnings
authorAndrzej Ostruszka <aostruszka@marvell.com>
Thu, 7 Nov 2019 15:03:13 +0000 (16:03 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 8 Nov 2019 14:23:37 +0000 (15:23 +0100)
During LTO build compiler reports some 'false positive' warnings about
variables being possibly used uninitialized.  This patch silences these
warnings.

Exemplary compiler warning to suppress (with LTO enabled):
error: ‘stats.greatest_free_size’ may be used uninitialized in this
function [-Werror=maybe-uninitialized]
  return len - overhead;

Signed-off-by: Andrzej Ostruszka <aostruszka@marvell.com>
Acked-by: Yipeng Wang <yipeng1.wang@intel.com>
app/test/test_hash_readwrite.c
app/test/test_link_bonding_mode4.c
app/test/test_memzone.c

index 4376b09..615767f 100644 (file)
@@ -298,7 +298,7 @@ test_rw_reader(void *arg)
 
        begin = rte_rdtsc_precise();
        for (i = 0; i < read_cnt; i++) {
-               void *data;
+               void *data = arg;
                rte_hash_lookup_data(tbl_rw_test_param.h,
                                tbl_rw_test_param.keys + i,
                                &data);
index ff54d7b..cf12f02 100644 (file)
@@ -585,7 +585,13 @@ bond_get_update_timeout_ms(void)
 {
        struct rte_eth_bond_8023ad_conf conf;
 
-       rte_eth_bond_8023ad_conf_get(test_params.bonded_port_id, &conf);
+       if (rte_eth_bond_8023ad_conf_get(test_params.bonded_port_id, &conf) < 0) {
+               RTE_LOG(DEBUG, EAL, "Failed to get bonding configuration: "
+                                   "%s at %d\n", __func__, __LINE__);
+               RTE_TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__);
+               return 0;
+       }
+
        return conf.update_timeout_ms;
 }
 
index 4d87444..0343b03 100644 (file)
@@ -475,7 +475,8 @@ find_max_block_free_size(unsigned int align, unsigned int socket_id)
        struct rte_malloc_socket_stats stats;
        size_t len, overhead;
 
-       rte_malloc_get_socket_stats(socket_id, &stats);
+       if (rte_malloc_get_socket_stats(socket_id, &stats) < 0)
+               return 0;
 
        len = stats.greatest_free_size;
        overhead = MALLOC_ELEM_OVERHEAD;