Commit 174caf0c authored by Daniel Leung's avatar Daniel Leung Committed by Fabio Baltieri
Browse files

tests: kernel: renames shadow variables



Renames	shadow variables found by -Wshadow.

Signed-off-by: default avatarDaniel Leung <daniel.leung@intel.com>
parent 6c85e615
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@
struct k_thread usr_fp_thread;
K_THREAD_STACK_DEFINE(usr_fp_thread_stack, STACKSIZE);

ZTEST_BMEM static volatile int ret = TC_PASS;
ZTEST_BMEM static volatile int test_ret = TC_PASS;

static void usr_fp_thread_entry_1(void)
{
@@ -48,13 +48,13 @@ static void usr_fp_thread_entry_2(void)

		TC_ERROR("k_float_disable() fail - should never see this\n");

		ret = TC_FAIL;
		test_ret = TC_FAIL;
	}
}

ZTEST(k_float_disable, test_k_float_disable_common)
{
	ret = TC_PASS;
	test_ret = TC_PASS;

	/* Set thread priority level to the one used
	 * in this test suite for cooperative threads.
@@ -105,7 +105,7 @@ ZTEST(k_float_disable, test_k_float_disable_common)

ZTEST(k_float_disable, test_k_float_disable_syscall)
{
	ret = TC_PASS;
	test_ret = TC_PASS;

	k_thread_priority_set(k_current_get(), PRIORITY);

@@ -138,8 +138,8 @@ ZTEST(k_float_disable, test_k_float_disable_syscall)
		"usr_fp_thread FP options not clear (0x%0x)",
		usr_fp_thread.base.user_options);

	/* ret is volatile, static analysis says we can't use in assert */
	bool ok = ret == TC_PASS;
	/* test_ret is volatile, static analysis says we can't use in assert */
	bool ok = test_ret == TC_PASS;

	zassert_true(ok, "");
#else
@@ -167,7 +167,7 @@ void arm_test_isr_handler(const void *args)

		TC_ERROR("k_float_disable() successful in ISR\n");

		ret = TC_FAIL;
		test_ret = TC_FAIL;
	}
}

@@ -177,7 +177,7 @@ static void sup_fp_thread_entry(void)
	if ((sup_fp_thread.base.user_options & K_FP_REGS) == 0) {

		TC_ERROR("sup_fp_thread FP options cleared\n");
		ret = TC_FAIL;
		test_ret = TC_FAIL;
	}

	/* Determine an NVIC IRQ line that is not currently in use. */
@@ -234,13 +234,13 @@ static void sup_fp_thread_entry(void)
	if ((sup_fp_thread.base.user_options & K_FP_REGS) == 0) {

		TC_ERROR("sup_fp_thread FP options cleared\n");
		ret = TC_FAIL;
		test_ret = TC_FAIL;
	}
}

ZTEST(k_float_disable, test_k_float_disable_irq)
{
	ret = TC_PASS;
	test_ret = TC_PASS;

	k_thread_priority_set(k_current_get(), PRIORITY);

@@ -256,8 +256,8 @@ ZTEST(k_float_disable, test_k_float_disable_irq)
	/* Yield will swap-in sup_fp_thread */
	k_yield();

	/* ret is volatile, static analysis says we can't use in assert */
	bool ok = ret == TC_PASS;
	/* test_ret is volatile, static analysis says we can't use in assert */
	bool ok = test_ret == TC_PASS;

	zassert_true(ok, "");
}
+31 −31
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@
#define LIST_LEN 2

struct k_lifo lifo, plifo;
static ldata_t data[LIST_LEN];
static ldata_t lifo_data[LIST_LEN];
struct k_lifo timeout_order_lifo;

static struct k_thread tdata, tdata1;
@@ -71,7 +71,7 @@ struct scratch_lifo_packet scratch_lifo_packets[NUM_SCRATCH_LIFO_PACKETS];

struct k_lifo scratch_lifo_packets_lifo;

static k_tid_t tid[TIMEOUT_ORDER_NUM_THREADS];
static k_tid_t to_ord_tid[TIMEOUT_ORDER_NUM_THREADS];
static K_THREAD_STACK_ARRAY_DEFINE(ttstack,
		TIMEOUT_ORDER_NUM_THREADS, TSTACK_SIZE);
static struct k_thread ttdata[TIMEOUT_ORDER_NUM_THREADS];
@@ -96,11 +96,11 @@ static void thread_entry_nowait(void *p1, void *p2, void *p3)
	ret = k_lifo_get((struct k_lifo *)p1, K_FOREVER);

	/* data pushed at last should be read first */
	zassert_equal(ret, (void *)&data[1]);
	zassert_equal(ret, (void *)&lifo_data[1]);

	ret = k_lifo_get((struct k_lifo *)p1, K_FOREVER);

	zassert_equal(ret, (void *)&data[0]);
	zassert_equal(ret, (void *)&lifo_data[0]);

	k_sem_give(&start_sema);
}
@@ -120,7 +120,7 @@ static int test_multiple_threads_pending(struct timeout_order_data *test_data,
	int ii;

	for (ii = 0; ii < test_data_size; ii++) {
		tid[ii] = k_thread_create(&ttdata[ii], ttstack[ii], TSTACK_SIZE,
		to_ord_tid[ii] = k_thread_create(&ttdata[ii], ttstack[ii], TSTACK_SIZE,
						 test_thread_pend_and_timeout,
						 &test_data[ii], NULL, NULL,
						 LIFO_THREAD_PRIO, K_INHERIT_PERMS, K_NO_WAIT);
@@ -147,9 +147,9 @@ static int test_multiple_threads_pending(struct timeout_order_data *test_data,

static void thread_entry_wait(void *p1, void *p2, void *p3)
{
	k_lifo_put((struct k_lifo *)p1, (void *)&data[0]);
	k_lifo_put((struct k_lifo *)p1, (void *)&lifo_data[0]);

	k_lifo_put((struct k_lifo *)p1, (void *)&data[1]);
	k_lifo_put((struct k_lifo *)p1, (void *)&lifo_data[1]);
	k_sem_give(&wait_sema);
}

@@ -220,13 +220,13 @@ ZTEST(lifo_usage, test_lifo_nowait)
	k_sem_init(&start_sema, 0, 1);

	/* put some data on lifo */
	k_lifo_put(&lifo, (void *)&data[0]);
	k_lifo_put(&lifo, (void *)&lifo_data[0]);

	k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
				      thread_entry_nowait, &lifo, NULL, NULL,
				      K_PRIO_PREEMPT(0), 0, K_NO_WAIT);

	k_lifo_put(&lifo, (void *)&data[1]);
	k_lifo_put(&lifo, (void *)&lifo_data[1]);

	/* Allow another thread to read lifo */
	k_sem_take(&start_sema, K_FOREVER);
@@ -250,13 +250,13 @@ ZTEST(lifo_usage_1cpu, test_lifo_wait)

	ret = k_lifo_get(&plifo, K_FOREVER);

	zassert_equal(ret, (void *)&data[0]);
	zassert_equal(ret, (void *)&lifo_data[0]);

	k_sem_take(&wait_sema, K_FOREVER);

	ret = k_lifo_get(&plifo, K_FOREVER);

	zassert_equal(ret, (void *)&data[1]);
	zassert_equal(ret, (void *)&lifo_data[1]);

	k_thread_abort(tid);
}
@@ -325,7 +325,7 @@ ZTEST(lifo_usage_1cpu, test_timeout_lifo_thread)
	timeout = 10U;
	start_time = k_cycle_get_32();

	tid[0] = k_thread_create(&ttdata[0], ttstack[0], TSTACK_SIZE,
	to_ord_tid[0] = k_thread_create(&ttdata[0], ttstack[0], TSTACK_SIZE,
					test_thread_put_timeout, &lifo_timeout[0],
					&timeout, NULL,
					LIFO_THREAD_PRIO, K_INHERIT_PERMS, K_NO_WAIT);
@@ -341,7 +341,7 @@ ZTEST(lifo_usage_1cpu, test_timeout_lifo_thread)
	 * the data availability on another lifo. In this test child
	 * thread does not find data on lifo.
	 */
	tid[0] = k_thread_create(&ttdata[0], ttstack[0], TSTACK_SIZE,
	to_ord_tid[0] = k_thread_create(&ttdata[0], ttstack[0], TSTACK_SIZE,
					test_thread_timeout_reply_values,
					(void *)&reply_packet, NULL, NULL,
					LIFO_THREAD_PRIO, K_INHERIT_PERMS, K_NO_WAIT);
@@ -360,7 +360,7 @@ ZTEST(lifo_usage_1cpu, test_timeout_lifo_thread)
	scratch_packet = get_scratch_packet();
	k_lifo_put(&lifo_timeout[0], scratch_packet);

	tid[0] = k_thread_create(&ttdata[0], ttstack[0], TSTACK_SIZE,
	to_ord_tid[0] = k_thread_create(&ttdata[0], ttstack[0], TSTACK_SIZE,
					test_thread_timeout_reply_values,
					(void *)&reply_packet, NULL, NULL,
					LIFO_THREAD_PRIO, K_INHERIT_PERMS, K_NO_WAIT);
@@ -380,7 +380,7 @@ ZTEST(lifo_usage_1cpu, test_timeout_lifo_thread)
	scratch_packet = get_scratch_packet();
	k_lifo_put(&lifo_timeout[0], scratch_packet);

	tid[0] = k_thread_create(&ttdata[0], ttstack[0], TSTACK_SIZE,
	to_ord_tid[0] = k_thread_create(&ttdata[0], ttstack[0], TSTACK_SIZE,
					test_thread_timeout_reply_values_wfe,
					(void *)&reply_packet, NULL, NULL,
					LIFO_THREAD_PRIO, K_INHERIT_PERMS, K_NO_WAIT);
@@ -455,7 +455,7 @@ static void test_para_init(void)
	}

	for (int i = 0; i < LIST_LEN; i++) {
		data[i].data = i + 1;
		lifo_data[i].data = i + 1;
	}
}

+4 −4
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
struct k_sem sync_sema;
static K_THREAD_STACK_ARRAY_DEFINE(tstack, THREAD_NUM, STACK_SIZE);
static struct k_thread tdata[THREAD_NUM];
static void *block[BLK_NUM_MAX];
static void *pool_blocks[BLK_NUM_MAX];

/*test cases*/

@@ -55,9 +55,9 @@ static void tmheap_handler(void *p1, void *p2, void *p3)
{
	int thread_id = POINTER_TO_INT(p1);

	block[thread_id] = k_malloc(BLOCK_SIZE);
	pool_blocks[thread_id] = k_malloc(BLOCK_SIZE);

	zassert_not_null(block[thread_id], "memory is not allocated");
	zassert_not_null(pool_blocks[thread_id], "memory is not allocated");

	k_sem_give(&sync_sema);
}
@@ -95,7 +95,7 @@ ZTEST(mheap_api, test_mheap_threadsafe)

	for (int i = 0; i < THREAD_NUM; i++) {
		/* verify free mheap in main thread */
		k_free(block[i]);
		k_free(pool_blocks[i]);
		k_thread_abort(tid[i]);
	}
}
+2 −2
Original line number Diff line number Diff line
@@ -1328,7 +1328,7 @@ struct k_thread t;
struct k_timer timer;
struct z_thread_stack_element zs;
struct k_futex f;
struct k_condvar c;
struct k_condvar condvar;

static void entry_error_perm(void *p1, void *p2, void *p3)
{
@@ -1364,7 +1364,7 @@ ZTEST(mem_protect_kobj, test_kobject_perm_error)
	kobj[9] = &timer;
	kobj[10] = &zs;
	kobj[11] = &f;
	kobj[12] = &c;
	kobj[12] = &condvar;

	for (int i = 0; i < 12 ; i++) {

+2 −2
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ K_SEM_DEFINE(test_continue, 0, 1);
struct k_thread service_manager;
struct k_thread service1;
struct k_thread service2;
struct k_thread client;
struct k_thread client_thread;
static ZTEST_DMEM unsigned long __aligned(4) service1_buf[MSGQ_LEN];
static ZTEST_DMEM unsigned long __aligned(4) service2_buf[MSGQ_LEN];
static ZTEST_DMEM unsigned long __aligned(4) client_buf[MSGQ_LEN * 2];
@@ -254,7 +254,7 @@ static void start_client(void)

	int pri = k_thread_priority_get(k_current_get());

	tclient = k_thread_create(&client, client_stack, STACK_SIZE,
	tclient = k_thread_create(&client_thread, client_stack, STACK_SIZE,
				  client_entry, NULL, NULL, NULL, pri,
				  0, K_NO_WAIT);
}
Loading