To reduce the number of issues picked up by check-odp when moving the files
in next patch

Signed-off-by: Christophe Milard <christophe.mil...@linaro.org>
---
 test/performance/odp_crypto.c                      |  6 +-
 test/performance/odp_l2fwd.c                       |  1 -
 test/performance/odp_l2fwd_run.sh                  |  3 +-
 test/performance/odp_pktio_perf.c                  | 34 +++++-----
 test/performance/odp_scheduling.c                  | 19 ++----
 .../classification/odp_classification_test_pmr.c   |  1 -
 test/validation/crypto/odp_crypto_test_inp.c       | 32 ++++-----
 test/validation/crypto/test_vectors.h              |  2 +-
 test/validation/hash/hash.c                        |  1 -
 test/validation/pktio/pktio.c                      |  2 -
 test/validation/queue/queue.c                      |  7 +-
 test/validation/scheduler/scheduler.c              | 13 ++--
 test/validation/timer/timer.c                      | 75 +++++++++++++---------
 13 files changed, 100 insertions(+), 96 deletions(-)

diff --git a/test/performance/odp_crypto.c b/test/performance/odp_crypto.c
index 404984d..e908402 100644
--- a/test/performance/odp_crypto.c
+++ b/test/performance/odp_crypto.c
@@ -550,11 +550,9 @@ run_measure_one(crypto_args_t *cargs,
                                if (pkt == ODP_PACKET_INVALID) {
                                        app_err("failed to allocate buffer\n");
                                        return -1;
-                               } else {
-                                       void *mem = odp_packet_data(pkt);
-
-                                       memset(mem, 1, payload_length);
                                }
+                               mem = odp_packet_data(pkt);
+                               memset(mem, 1, payload_length);
                                params.pkt = pkt;
                                params.out_pkt = cargs->in_place ? pkt :
                                                 ODP_PACKET_INVALID;
diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c
index e296b94..c4c3cad 100644
--- a/test/performance/odp_l2fwd.c
+++ b/test/performance/odp_l2fwd.c
@@ -80,7 +80,6 @@ static inline int sched_mode(pktin_mode_t in_mode)
               (in_mode == SCHED_ORDERED);
 }
 
-
 /** Get rid of path in filename - only for unix-type paths using '/' */
 #define NO_PATH(file_name) (strrchr((file_name), '/') ? \
                            strrchr((file_name), '/') + 1 : (file_name))
diff --git a/test/performance/odp_l2fwd_run.sh 
b/test/performance/odp_l2fwd_run.sh
index fc3d05d..1fff087 100755
--- a/test/performance/odp_l2fwd_run.sh
+++ b/test/performance/odp_l2fwd_run.sh
@@ -65,7 +65,8 @@ run_l2fwd()
        #@todo: limit odp_generator to cores
        #https://bugs.linaro.org/show_bug.cgi?id=1398
        (odp_generator${EXEEXT} -I $IF0 \
-                       --srcip 192.168.0.1 --dstip 192.168.0.2 -m u 2>&1 > 
/dev/null) \
+                       --srcip 192.168.0.1 --dstip 192.168.0.2 \
+                       -m u 2>&1 > /dev/null) \
                        2>&1 > /dev/null &
        GEN_PID=$!
 
diff --git a/test/performance/odp_pktio_perf.c 
b/test/performance/odp_pktio_perf.c
index 18a1aa2..f041b13 100644
--- a/test/performance/odp_pktio_perf.c
+++ b/test/performance/odp_pktio_perf.c
@@ -255,7 +255,6 @@ static int pktio_pkt_has_magic(odp_packet_t pkt)
        return 0;
 }
 
-
 /*
  * Allocate packets for transmission.
  */
@@ -375,8 +374,8 @@ static int run_thread_tx(void *arg)
                cur_time = odp_time_local();
        }
 
-       VPRINT(" %02d: TxPkts %-8"PRIu64" EnqFail %-6"PRIu64
-              " AllocFail %-6"PRIu64" Idle %"PRIu64"ms\n",
+       VPRINT(" %02d: TxPkts %-8" PRIu64 " EnqFail %-6" PRIu64
+              " AllocFail %-6" PRIu64 " Idle %" PRIu64 "ms\n",
               thr_id, stats->s.tx_cnt,
               stats->s.enq_failures, stats->s.alloc_failures,
               odp_time_to_ns(stats->s.idle_ticks) /
@@ -417,6 +416,7 @@ static int run_thread_rx(void *arg)
        test_globals_t *globals;
        int thr_id, batch_len;
        odp_queue_t queue = ODP_QUEUE_INVALID;
+       odp_packet_t pkt;
 
        thread_args_t *targs = arg;
 
@@ -445,7 +445,7 @@ static int run_thread_rx(void *arg)
 
                for (i = 0; i < n_ev; ++i) {
                        if (odp_event_type(ev[i]) == ODP_EVENT_PACKET) {
-                               odp_packet_t pkt = odp_packet_from_event(ev[i]);
+                               pkt = odp_packet_from_event(ev[i]);
                                if (pktio_pkt_has_magic(pkt))
                                        stats->s.rx_cnt++;
                                else
@@ -498,16 +498,16 @@ static int process_results(uint64_t expected_tx_cnt,
 
        attempted_pps = status->pps_curr;
 
-       len += snprintf(&str[len], sizeof(str)-1-len,
-                       "PPS: %-8"PRIu64" ", attempted_pps);
-       len += snprintf(&str[len], sizeof(str)-1-len,
+       len += snprintf(&str[len], sizeof(str) - 1 - len,
+                       "PPS: %-8" PRIu64 " ", attempted_pps);
+       len += snprintf(&str[len], sizeof(str) - 1 - len,
                        "Succeeded: %-4s ", fail ? "No" : "Yes");
-       len += snprintf(&str[len], sizeof(str)-1-len,
-                       "TxPkts: %-8"PRIu64" ", tx_pkts);
-       len += snprintf(&str[len], sizeof(str)-1-len,
-                       "RxPkts: %-8"PRIu64" ", rx_pkts);
-       len += snprintf(&str[len], sizeof(str)-1-len,
-                       "DropPkts: %-8"PRIu64" ", drops);
+       len += snprintf(&str[len], sizeof(str) - 1 - len,
+                       "TxPkts: %-8" PRIu64 " ", tx_pkts);
+       len += snprintf(&str[len], sizeof(str) - 1 - len,
+                       "RxPkts: %-8" PRIu64 " ", rx_pkts);
+       len += snprintf(&str[len], sizeof(str) - 1 - len,
+                       "DropPkts: %-8" PRIu64 " ", drops);
        printf("%s\n", str);
 
        if (gbl_args->args.search == 0) {
@@ -537,7 +537,7 @@ static int process_results(uint64_t expected_tx_cnt,
                unsigned pkt_len = gbl_args->args.pkt_len + PKT_HDR_LEN;
                int mbps = (pkt_len * status->pps_pass * 8) / 1024 / 1024;
 
-               printf("Maximum packet rate: %"PRIu64" PPS (%d Mbps)\n",
+               printf("Maximum packet rate: %" PRIu64 " PPS (%d Mbps)\n",
                       status->pps_pass, mbps);
 
                return 0;
@@ -587,8 +587,8 @@ static int setup_txrx_masks(odp_cpumask_t *thd_mask_tx,
 
        num_rx_workers = odp_cpumask_count(thd_mask_rx);
 
-       odp_barrier_init(&gbl_args->rx_barrier, num_rx_workers+1);
-       odp_barrier_init(&gbl_args->tx_barrier, num_tx_workers+1);
+       odp_barrier_init(&gbl_args->rx_barrier, num_rx_workers + 1);
+       odp_barrier_init(&gbl_args->tx_barrier, num_tx_workers + 1);
 
        return 0;
 }
@@ -978,7 +978,7 @@ static void parse_args(int argc, char *argv[], test_args_t 
*args)
                {
                        char *token;
 
-                       args->if_str = malloc(strlen(optarg)+1);
+                       args->if_str = malloc(strlen(optarg) + 1);
 
                        if (!args->if_str)
                                LOG_ABORT("Failed to alloc iface storage\n");
diff --git a/test/performance/odp_scheduling.c 
b/test/performance/odp_scheduling.c
index bd37f9b..5a2997f 100644
--- a/test/performance/odp_scheduling.c
+++ b/test/performance/odp_scheduling.c
@@ -28,12 +28,12 @@
 /* GNU lib C */
 #include <getopt.h>
 
-#define MSG_POOL_SIZE         (4*1024*1024) /**< Message pool size */
+#define MSG_POOL_SIZE         (4 * 1024 * 1024) /**< Message pool size */
 #define MAX_ALLOCS            35            /**< Alloc burst size */
 #define QUEUES_PER_PRIO       64            /**< Queue per priority */
 #define NUM_PRIOS             2             /**< Number of tested priorities */
-#define QUEUE_ROUNDS          (512*1024)    /**< Queue test rounds */
-#define ALLOC_ROUNDS          (1024*1024)   /**< Alloc test rounds */
+#define QUEUE_ROUNDS          (512 * 1024)    /**< Queue test rounds */
+#define ALLOC_ROUNDS          (1024 * 1024)   /**< Alloc test rounds */
 #define MULTI_BUFS_MAX        4             /**< Buffer burst size */
 #define TEST_SEC              2             /**< Time test duration in sec */
 #define STATS_PER_LINE        8             /**< Stats per printed line */
@@ -163,7 +163,6 @@ static int enqueue_events(int thr, int prio, int 
num_queues, int num_events,
        return 0;
 }
 
-
 /**
  * @internal Test single buffer alloc and free
  *
@@ -228,7 +227,7 @@ static int test_alloc_multi(int thr, test_globals_t 
*globals)
                }
 
                for (; j > 0; j--)
-                       odp_buffer_free(temp_buf[j-1]);
+                       odp_buffer_free(temp_buf[j - 1]);
        }
 
        c2     = odp_cpu_cycles();
@@ -385,7 +384,6 @@ static int test_schedule_single(const char *str, int thr,
        return 0;
 }
 
-
 /**
  * @internal Test scheduling of multiple queues - with odp_schedule()
  *
@@ -533,7 +531,6 @@ static int test_schedule_multi(const char *str, int thr,
 
        odp_schedule_resume();
 
-
        c2     = odp_cpu_cycles();
        cycles = odp_cpu_cycles_diff(c2, c1);
 
@@ -655,7 +652,6 @@ static int run_thread(void *arg ODP_UNUSED)
                                ODP_SCHED_PRIO_HIGHEST, globals))
                return -1;
 
-
        printf("Thread %i exits\n", thr);
        fflush(NULL);
        return 0;
@@ -768,7 +764,6 @@ static void parse_args(int argc, char *argv[], test_args_t 
*args)
        }
 }
 
-
 /**
  * Test main function
  */
@@ -857,7 +852,7 @@ int main(int argc, char *argv[])
        odp_pool_param_init(&params);
        params.buf.size  = sizeof(test_message_t);
        params.buf.align = 0;
-       params.buf.num   = MSG_POOL_SIZE/sizeof(test_message_t);
+       params.buf.num   = MSG_POOL_SIZE / sizeof(test_message_t);
        params.type      = ODP_POOL_BUFFER;
 
        pool = odp_pool_create("msg_pool", &params);
@@ -905,8 +900,8 @@ int main(int argc, char *argv[])
                param.sched.group = ODP_SCHED_GROUP_ALL;
 
                for (j = 0; j < QUEUES_PER_PRIO; j++) {
-                       name[9]  = '0' + j/10;
-                       name[10] = '0' + j - 10*(j/10);
+                       name[9]  = '0' + j / 10;
+                       name[10] = '0' + j - 10 * (j / 10);
 
                        queue = odp_queue_create(name, &param);
 
diff --git a/test/validation/classification/odp_classification_test_pmr.c 
b/test/validation/classification/odp_classification_test_pmr.c
index 7c7d07e..c8bbf50 100644
--- a/test/validation/classification/odp_classification_test_pmr.c
+++ b/test/validation/classification/odp_classification_test_pmr.c
@@ -70,7 +70,6 @@ void configure_default_cos(odp_pktio_t pktio, odp_cos_t *cos,
        *cos = default_cos;
        *queue = default_queue;
        *pool = default_pool;
-       return;
 }
 
 int classification_suite_pmr_term(void)
diff --git a/test/validation/crypto/odp_crypto_test_inp.c 
b/test/validation/crypto/odp_crypto_test_inp.c
index 0c5b110..4ac4a07 100644
--- a/test/validation/crypto/odp_crypto_test_inp.c
+++ b/test/validation/crypto/odp_crypto_test_inp.c
@@ -53,6 +53,10 @@ static void alg_test(odp_crypto_op_t op,
        odp_event_t event;
        odp_crypto_compl_t compl_event;
        odp_crypto_op_result_t result;
+       odp_crypto_session_params_t ses_params;
+       odp_crypto_op_params_t op_params;
+       uint8_t *data_addr;
+       int data_off;
 
        rc = odp_crypto_capability(&capability);
        CU_ASSERT(!rc);
@@ -100,7 +104,6 @@ static void alg_test(odp_crypto_op_t op,
        CU_ASSERT(!rc);
 
        /* Create a crypto session */
-       odp_crypto_session_params_t ses_params;
        memset(&ses_params, 0, sizeof(ses_params));
        ses_params.op = op;
        ses_params.auth_cipher_text = false;
@@ -123,12 +126,11 @@ static void alg_test(odp_crypto_op_t op,
        odp_packet_t pkt = odp_packet_alloc(suite_context.pool,
                                            plaintext_len + digest_len);
        CU_ASSERT(pkt != ODP_PACKET_INVALID);
-       uint8_t *data_addr = odp_packet_data(pkt);
+       data_addr = odp_packet_data(pkt);
        memcpy(data_addr, plaintext, plaintext_len);
-       int data_off = 0;
+       data_off = 0;
 
        /* Prepare input/output params */
-       odp_crypto_op_params_t op_params;
        memset(&op_params, 0, sizeof(op_params));
        op_params.session = session;
        op_params.pkt = pkt;
@@ -199,10 +201,10 @@ void crypto_test_enc_alg_3des_cbc(void)
        odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
                         auth_key   = { .data = NULL, .length = 0 };
        odp_crypto_iv_t iv;
-       unsigned int test_vec_num = (sizeof(tdes_cbc_reference_length)/
+       unsigned int test_vec_num = (sizeof(tdes_cbc_reference_length) /
                                     sizeof(tdes_cbc_reference_length[0]));
-
        unsigned int i;
+
        for (i = 0; i < test_vec_num; i++) {
                cipher_key.data = tdes_cbc_reference_key[i];
                cipher_key.length = sizeof(tdes_cbc_reference_key[i]);
@@ -232,10 +234,10 @@ void crypto_test_enc_alg_3des_cbc_ovr_iv(void)
        odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
                         auth_key   = { .data = NULL, .length = 0 };
        odp_crypto_iv_t iv = { .data = NULL, .length = TDES_CBC_IV_LEN };
-       unsigned int test_vec_num = (sizeof(tdes_cbc_reference_length)/
+       unsigned int test_vec_num = (sizeof(tdes_cbc_reference_length) /
                                     sizeof(tdes_cbc_reference_length[0]));
-
        unsigned int i;
+
        for (i = 0; i < test_vec_num; i++) {
                cipher_key.data = tdes_cbc_reference_key[i];
                cipher_key.length = sizeof(tdes_cbc_reference_key[i]);
@@ -255,7 +257,6 @@ void crypto_test_enc_alg_3des_cbc_ovr_iv(void)
        }
 }
 
-
 /* This test verifies the correctness of decode (ciphertext -> plaintext)
  * operation for 3DES_CBC algorithm. IV for the operation is the session IV
  * In addition the test verifies if the implementation can use the
@@ -266,10 +267,10 @@ void crypto_test_dec_alg_3des_cbc(void)
        odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
                         auth_key   = { .data = NULL, .length = 0 };
        odp_crypto_iv_t iv = { .data = NULL, .length = 0 };
-       unsigned int test_vec_num = (sizeof(tdes_cbc_reference_length)/
+       unsigned int test_vec_num = (sizeof(tdes_cbc_reference_length) /
                                     sizeof(tdes_cbc_reference_length[0]));
-
        unsigned int i;
+
        for (i = 0; i < test_vec_num; i++) {
                cipher_key.data = tdes_cbc_reference_key[i];
                cipher_key.length = sizeof(tdes_cbc_reference_key[i]);
@@ -301,10 +302,10 @@ void crypto_test_dec_alg_3des_cbc_ovr_iv(void)
        odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
                         auth_key   = { .data = NULL, .length = 0 };
        odp_crypto_iv_t iv = { .data = NULL, .length = TDES_CBC_IV_LEN };
-       unsigned int test_vec_num = (sizeof(tdes_cbc_reference_length)/
+       unsigned int test_vec_num = (sizeof(tdes_cbc_reference_length) /
                                     sizeof(tdes_cbc_reference_length[0]));
-
        unsigned int i;
+
        for (i = 0; i < test_vec_num; i++) {
                cipher_key.data = tdes_cbc_reference_key[i];
                cipher_key.length = sizeof(tdes_cbc_reference_key[i]);
@@ -607,7 +608,6 @@ void crypto_test_dec_alg_aes128_cbc_ovr_iv(void)
        }
 }
 
-
 /* This test verifies the correctness of HMAC_MD5 digest operation.
  * The output check length is truncated to 12 bytes (96 bits) as
  * returned by the crypto operation API call.
@@ -621,10 +621,10 @@ void crypto_test_alg_hmac_md5(void)
                         auth_key   = { .data = NULL, .length = 0 };
        odp_crypto_iv_t iv = { .data = NULL, .length = 0 };
 
-       unsigned int test_vec_num = (sizeof(hmac_md5_reference_length)/
+       unsigned int test_vec_num = (sizeof(hmac_md5_reference_length) /
                                     sizeof(hmac_md5_reference_length[0]));
-
        unsigned int i;
+
        for (i = 0; i < test_vec_num; i++) {
                auth_key.data = hmac_md5_reference_key[i];
                auth_key.length = sizeof(hmac_md5_reference_key[i]);
diff --git a/test/validation/crypto/test_vectors.h 
b/test/validation/crypto/test_vectors.h
index 1b760a2..da4610f 100644
--- a/test/validation/crypto/test_vectors.h
+++ b/test/validation/crypto/test_vectors.h
@@ -266,7 +266,7 @@ aes128_gcm_reference_ciphertext[][AES128_GCM_MAX_DATA_LEN] 
= {
 
 static uint8_t hmac_md5_reference_key[][HMAC_MD5_KEY_LEN] = {
        { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
-         0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b } ,
+         0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b },
 
        /* "Jefe" */
        { 0x4a, 0x65, 0x66, 0x65 },
diff --git a/test/validation/hash/hash.c b/test/validation/hash/hash.c
index feaa6ae..b353fce 100644
--- a/test/validation/hash/hash.c
+++ b/test/validation/hash/hash.c
@@ -51,5 +51,4 @@ int hash_main(int argc, char *argv[])
                ret = odp_cunit_run();
 
        return ret;
-
 }
diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
index d53a419..a6a18c3 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -1547,7 +1547,6 @@ void pktio_test_start_stop(void)
 
        /* Test Rx on a stopped interface. Only works if there are 2 */
        if (num_ifaces > 1) {
-
                alloc = create_packets(tx_pkt, pkt_seq, 1000, pktio[0],
                                       pktio[1]);
 
@@ -1591,7 +1590,6 @@ void pktio_test_start_stop(void)
                }
        }
 
-
        if (num_ifaces > 1)
                pktio_in = pktio[1];
        else
diff --git a/test/validation/queue/queue.c b/test/validation/queue/queue.c
index 96941f4..dc3a977 100644
--- a/test/validation/queue/queue.c
+++ b/test/validation/queue/queue.c
@@ -148,6 +148,7 @@ void queue_test_param(void)
        int nr_deq_entries = 0;
        int max_iteration = CONFIG_MAX_ITERATION;
        odp_queue_param_t qparams;
+       odp_buffer_t enbuf;
 
        /* Schedule type queue */
        odp_queue_param_init(&qparams);
@@ -197,7 +198,7 @@ void queue_test_param(void)
        }
 
        for (i = 0; i < MAX_BUFFER_QUEUE; i++) {
-               odp_buffer_t buf = odp_buffer_alloc(msg_pool);
+               buf = odp_buffer_alloc(msg_pool);
                enev[i] = odp_buffer_to_event(buf);
        }
 
@@ -223,7 +224,7 @@ void queue_test_param(void)
        } while (nr_deq_entries < MAX_BUFFER_QUEUE);
 
        for (i = 0; i < MAX_BUFFER_QUEUE; i++) {
-               odp_buffer_t enbuf = odp_buffer_from_event(enev[i]);
+               enbuf = odp_buffer_from_event(enev[i]);
                CU_ASSERT(enev[i] == deev[i]);
                odp_buffer_free(enbuf);
        }
@@ -283,7 +284,7 @@ void queue_test_info(void)
        CU_ASSERT(info.param.sched.group == odp_queue_sched_group(q_order));
        ret = odp_queue_lock_count(q_order);
        CU_ASSERT(ret >= 0);
-       lock_count = (unsigned) ret;
+       lock_count = (unsigned)ret;
        CU_ASSERT(info.param.sched.lock_count == lock_count);
 
        CU_ASSERT(odp_queue_destroy(q_plain) == 0);
diff --git a/test/validation/scheduler/scheduler.c 
b/test/validation/scheduler/scheduler.c
index 316370d..919cfb6 100644
--- a/test/validation/scheduler/scheduler.c
+++ b/test/validation/scheduler/scheduler.c
@@ -676,6 +676,9 @@ static int schedule_common_(void *arg)
        odp_pool_t pool;
        int locked;
        int num;
+       odp_event_t ev;
+       odp_buffer_t buf, buf_cpy;
+       odp_queue_t from;
 
        globals = args->globals;
        sync = args->sync;
@@ -687,9 +690,7 @@ static int schedule_common_(void *arg)
                odp_barrier_wait(&globals->barrier);
 
        while (1) {
-               odp_event_t ev;
-               odp_buffer_t buf, buf_cpy;
-               odp_queue_t from = ODP_QUEUE_INVALID;
+               from = ODP_QUEUE_INVALID;
                num = 0;
 
                odp_ticketlock_lock(&globals->lock);
@@ -902,6 +903,8 @@ static void fill_queues(thread_args_t *args)
        test_globals_t *globals;
        char name[32];
        int ret;
+       odp_buffer_t buf;
+       odp_event_t ev;
 
        globals = args->globals;
        sync = args->sync;
@@ -937,8 +940,6 @@ static void fill_queues(thread_args_t *args)
                        CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID);
 
                        for (k = 0; k < args->num_bufs; k++) {
-                               odp_buffer_t buf;
-                               odp_event_t ev;
                                buf = odp_buffer_alloc(pool);
                                CU_ASSERT_FATAL(buf != ODP_BUFFER_INVALID);
                                ev = odp_buffer_to_event(buf);
@@ -1332,6 +1333,7 @@ static int create_queues(void)
        odp_buffer_t queue_ctx_buf;
        queue_context *qctx, *pqctx;
        uint32_t ndx;
+       odp_queue_param_t p;
 
        if (odp_queue_capability(&capa) < 0) {
                printf("Queue capability query failed\n");
@@ -1359,7 +1361,6 @@ static int create_queues(void)
        }
 
        for (i = 0; i < prios; i++) {
-               odp_queue_param_t p;
                odp_queue_param_init(&p);
                p.type        = ODP_QUEUE_TYPE_SCHED;
                p.sched.prio  = i;
diff --git a/test/validation/timer/timer.c b/test/validation/timer/timer.c
index 33eb478..0007639 100644
--- a/test/validation/timer/timer.c
+++ b/test/validation/timer/timer.c
@@ -251,7 +251,8 @@ static void handle_tmo(odp_event_t ev, bool stale, uint64_t 
prev_tick)
                        CU_FAIL("Wrong status (stale) for fresh timeout");
                /* Fresh timeout => local timer must have matching tick */
                if (ttp && ttp->tick != tick) {
-                       LOG_DBG("Wrong tick: expected %" PRIu64 " actual %" 
PRIu64 "\n",
+                       LOG_DBG("Wrong tick: expected %" PRIu64
+                               " actual %" PRIu64 "\n",
                                ttp->tick, tick);
                        CU_FAIL("odp_timeout_tick() wrong tick");
                }
@@ -259,7 +260,8 @@ static void handle_tmo(odp_event_t ev, bool stale, uint64_t 
prev_tick)
                if (tick > odp_timer_current_tick(tp))
                        CU_FAIL("Timeout delivered early");
                if (tick < prev_tick) {
-                       LOG_DBG("Too late tick: %" PRIu64 " prev_tick %" 
PRIu64"\n",
+                       LOG_DBG("Too late tick: %" PRIu64
+                               " prev_tick %" PRIu64"\n",
                                tick, prev_tick);
                        /* We don't report late timeouts using CU_FAIL */
                        odp_atomic_inc_u32(&ndelivtoolate);
@@ -281,12 +283,26 @@ static int worker_entrypoint(void *arg TEST_UNUSED)
        uint32_t i, allocated;
        unsigned seed = thr;
        int rc;
+       odp_queue_t queue;
+       struct test_timer *tt;
+       uint32_t nset;
+       uint64_t tck;
+       uint32_t nrcv;
+       uint32_t nreset;
+       uint32_t ncancel;
+       uint32_t ntoolate;
+       uint32_t ms;
+       uint64_t prev_tick;
+       odp_event_t ev;
+       struct timespec ts;
+       uint32_t nstale;
+       odp_timer_set_t timer_rc;
 
-       odp_queue_t queue = odp_queue_create("timer_queue", NULL);
+       queue = odp_queue_create("timer_queue", NULL);
        if (queue == ODP_QUEUE_INVALID)
                CU_FAIL_FATAL("Queue create failed");
 
-       struct test_timer *tt = malloc(sizeof(struct test_timer) * NTIMERS);
+       tt = malloc(sizeof(struct test_timer) * NTIMERS);
        if (!tt)
                CU_FAIL_FATAL("malloc failed");
 
@@ -316,15 +332,13 @@ static int worker_entrypoint(void *arg TEST_UNUSED)
        odp_barrier_wait(&test_barrier);
 
        /* Initial set all timers with a random expiration time */
-       uint32_t nset = 0;
+       nset = 0;
        for (i = 0; i < allocated; i++) {
-               uint64_t tck = odp_timer_current_tick(tp) + 1 +
-                              odp_timer_ns_to_tick(tp,
-                                                   (rand_r(&seed) % RANGE_MS)
-                                                   * 1000000ULL);
-               odp_timer_set_t rc;
-               rc = odp_timer_set_abs(tt[i].tim, tck, &tt[i].ev);
-               if (rc != ODP_TIMER_SUCCESS) {
+               tck = odp_timer_current_tick(tp) + 1 +
+                     odp_timer_ns_to_tick(tp, (rand_r(&seed) % RANGE_MS)
+                                              * 1000000ULL);
+               timer_rc = odp_timer_set_abs(tt[i].tim, tck, &tt[i].ev);
+               if (timer_rc != ODP_TIMER_SUCCESS) {
                        CU_FAIL("Failed to set timer");
                } else {
                        tt[i].tick = tck;
@@ -333,15 +347,13 @@ static int worker_entrypoint(void *arg TEST_UNUSED)
        }
 
        /* Step through wall time, 1ms at a time and check for expired timers */
-       uint32_t nrcv = 0;
-       uint32_t nreset = 0;
-       uint32_t ncancel = 0;
-       uint32_t ntoolate = 0;
-       uint32_t ms;
-       uint64_t prev_tick = odp_timer_current_tick(tp);
+       nrcv = 0;
+       nreset = 0;
+       ncancel = 0;
+       ntoolate = 0;
+       prev_tick = odp_timer_current_tick(tp);
 
        for (ms = 0; ms < 7 * RANGE_MS / 10 && allocated > 0; ms++) {
-               odp_event_t ev;
                while ((ev = odp_queue_deq(queue)) != ODP_EVENT_INVALID) {
                        /* Subtract one from prev_tick to allow for timeouts
                         * to be delivered a tick late */
@@ -388,7 +400,6 @@ static int worker_entrypoint(void *arg TEST_UNUSED)
                                tt[i].tick = cur_tick + tck;
                        }
                }
-               struct timespec ts;
                ts.tv_sec = 0;
                ts.tv_nsec = 1000000; /* 1ms */
                if (nanosleep(&ts, NULL) < 0)
@@ -396,7 +407,7 @@ static int worker_entrypoint(void *arg TEST_UNUSED)
        }
 
        /* Cancel and free all timers */
-       uint32_t nstale = 0;
+       nstale = 0;
        for (i = 0; i < allocated; i++) {
                (void)odp_timer_cancel(tt[i].tim, &tt[i].ev);
                tt[i].tick = TICK_INVALID;
@@ -412,22 +423,22 @@ static int worker_entrypoint(void *arg TEST_UNUSED)
        LOG_DBG("Thread %u: %" PRIu32 " timers reset/cancelled too late\n",
                thr, ntoolate);
        LOG_DBG("Thread %u: %" PRIu32 " timeouts received\n", thr, nrcv);
-       LOG_DBG("Thread %u: %" PRIu32 " stale timeout(s) after 
odp_timer_free()\n",
+       LOG_DBG("Thread %u: %" PRIu32
+               " stale timeout(s) after odp_timer_free()\n",
                thr, nstale);
 
        /* Delay some more to ensure timeouts for expired timers can be
         * received. Can not use busy loop here to make background timer
         * thread finish their work. */
-       struct timespec ts;
        ts.tv_sec = 0;
        ts.tv_nsec = (3 * RANGE_MS / 10 + 50) * ODP_TIME_MSEC_IN_NS;
        if (nanosleep(&ts, NULL) < 0)
                CU_FAIL_FATAL("nanosleep failed");
 
        while (nstale != 0) {
-               odp_event_t ev = odp_queue_deq(queue);
+               ev = odp_queue_deq(queue);
                if (ev != ODP_EVENT_INVALID) {
-                       handle_tmo(ev, true, 0/*Dont' care for stale tmo's*/);
+                       handle_tmo(ev, true, 0/*Don't care for stale tmo's*/);
                        nstale--;
                } else {
                        CU_FAIL("Failed to receive stale timeout");
@@ -441,7 +452,7 @@ static int worker_entrypoint(void *arg TEST_UNUSED)
        }
 
        /* Check if there any more (unexpected) events */
-       odp_event_t ev = odp_queue_deq(queue);
+       ev = odp_queue_deq(queue);
        if (ev != ODP_EVENT_INVALID)
                CU_FAIL("Unexpected event received");
 
@@ -464,6 +475,11 @@ void timer_test_odp_timer_all(void)
        odp_pool_param_t params;
        odp_timer_pool_param_t tparam;
        odp_cpumask_t unused;
+       odp_timer_pool_info_t tpinfo;
+       uint64_t tick;
+       uint64_t ns;
+       uint64_t t2;
+       pthrd_arg thrdarg;
 
        /* Reserve at least one core for running other processes so the timer
         * test hopefully can run undisturbed and thus get better timing
@@ -505,7 +521,6 @@ void timer_test_odp_timer_all(void)
        /* Start all created timer pools */
        odp_timer_pool_start();
 
-       odp_timer_pool_info_t tpinfo;
        if (odp_timer_pool_info(tp, &tpinfo) != 0)
                CU_FAIL("odp_timer_pool_info");
        CU_ASSERT(strcmp(tpinfo.name, NAME) == 0);
@@ -519,10 +534,9 @@ void timer_test_odp_timer_all(void)
        LOG_DBG("Tmo range: %u ms (%" PRIu64 " ticks)\n", RANGE_MS,
                odp_timer_ns_to_tick(tp, 1000000ULL * RANGE_MS));
 
-       uint64_t tick;
        for (tick = 0; tick < 1000000000000ULL; tick += 1000000ULL) {
-               uint64_t ns = odp_timer_tick_to_ns(tp, tick);
-               uint64_t t2 = odp_timer_ns_to_tick(tp, ns);
+               ns = odp_timer_tick_to_ns(tp, tick);
+               t2 = odp_timer_ns_to_tick(tp, ns);
                if (tick != t2)
                        CU_FAIL("Invalid conversion tick->ns->tick");
        }
@@ -537,7 +551,6 @@ void timer_test_odp_timer_all(void)
        odp_atomic_init_u32(&timers_allocated, 0);
 
        /* Create and start worker threads */
-       pthrd_arg thrdarg;
        thrdarg.testcase = 0;
        thrdarg.numthrds = num_workers;
        odp_cunit_thread_create(worker_entrypoint, &thrdarg);
-- 
2.7.4

Reply via email to