From ab003d36d334af27bd362fe7d7029efbcefdd926 Mon Sep 17 00:00:00 2001 From: Michal Bloch Date: Wed, 2 Feb 2022 18:55:23 +0100 Subject: [PATCH] Fix some variable shadowing. Change-Id: I1a6c0f0b51be5a7aa69455afe98ebdb21f5e0b3e (cherry picked from commit 81629696595682237f362306f7c858a1feab3834) --- tests/kdbus/test-benchmark.c | 2 -- tests/kdbus/test-policy-ns.c | 32 ++++++++++++++++---------------- tests/kdbus/test-policy-priv.c | 10 +++++----- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/tests/kdbus/test-benchmark.c b/tests/kdbus/test-benchmark.c index e53ebb5..8b84671 100644 --- a/tests/kdbus/test-benchmark.c +++ b/tests/kdbus/test-benchmark.c @@ -314,7 +314,6 @@ static wur int benchmark(struct kdbus_test_env *env) while (1) { unsigned int nfds = sizeof(fds) / sizeof(fds[0]); - unsigned int i; for (i = 0; i < nfds; i++) { fds[i].events = POLLIN | POLLPRI | POLLHUP; @@ -362,7 +361,6 @@ static wur int benchmark(struct kdbus_test_env *env) while (1) { unsigned int nfds = sizeof(fds) / sizeof(fds[0]); - unsigned int i; for (i = 0; i < nfds; i++) { fds[i].events = POLLIN | POLLPRI | POLLHUP; diff --git a/tests/kdbus/test-policy-ns.c b/tests/kdbus/test-policy-ns.c index 0a630b7..e6dad85 100644 --- a/tests/kdbus/test-policy-ns.c +++ b/tests/kdbus/test-policy-ns.c @@ -55,7 +55,7 @@ * policy holder connection for this name will update the policy * entries, so different use cases can be tested. */ -static struct kdbus_conn **conn_db; +static struct kdbus_conn **g_conn_db; static wur void *kdbus_recv_echo(void *ptr) { @@ -513,15 +513,15 @@ wur int kdbus_test_policy_ns(struct kdbus_test_env *env) if (!all_uids_gids_are_mapped()) return TEST_SKIP; - ASSERT_NONZERO(conn_db = calloc(MAX_CONN, sizeof(struct kdbus_conn *))); + ASSERT_NONZERO(g_conn_db = calloc(MAX_CONN, sizeof(struct kdbus_conn *))); - memset(conn_db, 0, MAX_CONN * sizeof(struct kdbus_conn *)); + memset(g_conn_db, 0, MAX_CONN * sizeof(struct kdbus_conn *)); - ASSERT_NONZERO(conn_db[0] = kdbus_hello(bus, 0, NULL, 0)); + ASSERT_NONZERO(g_conn_db[0] = kdbus_hello(bus, 0, NULL, 0)); - ASSERT_ZERO(kdbus_add_match_empty(conn_db[0])); + ASSERT_ZERO(kdbus_add_match_empty(g_conn_db[0])); - ASSERT_EXIT_ZERO(kdbus_fork_test_by_id(bus, conn_db, -EPERM, -EPERM)); + ASSERT_EXIT_ZERO(kdbus_fork_test_by_id(bus, g_conn_db, -EPERM, -EPERM)); ASSERT_ZERO(kdbus_register_policy_holder(bus, POLICY_NAME, &policy_holder)); @@ -529,13 +529,13 @@ wur int kdbus_test_policy_ns(struct kdbus_test_env *env) ASSERT_ZERO(kdbus_register_same_activator(bus, POLICY_NAME, &activator)); /* Acquire POLICY_NAME */ - ASSERT_ZERO(kdbus_name_acquire(conn_db[0], POLICY_NAME, NULL)); + ASSERT_ZERO(kdbus_name_acquire(g_conn_db[0], POLICY_NAME, NULL)); - ASSERT_ZERO(kdbus_normal_test(bus, POLICY_NAME, conn_db)); + ASSERT_ZERO(kdbus_normal_test(bus, POLICY_NAME, g_conn_db)); - ASSERT_ZERO(kdbus_list(conn_db[0], KDBUS_LIST_NAMES | KDBUS_LIST_UNIQUE | KDBUS_LIST_ACTIVATORS | KDBUS_LIST_QUEUED)); + ASSERT_ZERO(kdbus_list(g_conn_db[0], KDBUS_LIST_NAMES | KDBUS_LIST_UNIQUE | KDBUS_LIST_ACTIVATORS | KDBUS_LIST_QUEUED)); - ASSERT_ZERO(kdbus_fork_test(bus, POLICY_NAME, conn_db, EXIT_SUCCESS)); + ASSERT_ZERO(kdbus_fork_test(bus, POLICY_NAME, g_conn_db, EXIT_SUCCESS)); /* * children connections are able to talk to conn_db[0] since @@ -546,7 +546,7 @@ wur int kdbus_test_policy_ns(struct kdbus_test_env *env) * -EPERM but since it is a privileged bus user the TALK is * allowed. */ - ASSERT_EXIT_ZERO(kdbus_fork_test_by_id(bus, conn_db, EXIT_SUCCESS, EXIT_SUCCESS)); + ASSERT_EXIT_ZERO(kdbus_fork_test_by_id(bus, g_conn_db, EXIT_SUCCESS, EXIT_SUCCESS)); /* * Connections that can talk are perhaps being destroyed now. @@ -562,7 +562,7 @@ wur int kdbus_test_policy_ns(struct kdbus_test_env *env) * After setting the policy re-check connections * we expect the children to fail with -EPERM */ - ASSERT_ZERO(kdbus_fork_test(bus, POLICY_NAME, conn_db, ONTIZEN(0,-EPERM))); + ASSERT_ZERO(kdbus_fork_test(bus, POLICY_NAME, g_conn_db, ONTIZEN(0,-EPERM))); /* * Now expect that both parent and child to fail. @@ -573,18 +573,18 @@ wur int kdbus_test_policy_ns(struct kdbus_test_env *env) * Since the parent's connection will timeout when receiving * from the child, we never continue. FWIW just put -EPERM. */ - ASSERT_EXIT_ZERO(kdbus_fork_test_by_id(bus, conn_db, -EPERM, -EPERM)); + ASSERT_EXIT_ZERO(kdbus_fork_test_by_id(bus, g_conn_db, -EPERM, -EPERM)); /* Check if the name can be reached in a new userns */ - ASSERT_ZERO(kdbus_clone_userns_test(bus, POLICY_NAME, conn_db, ONTIZEN(0,-EPERM))); + ASSERT_ZERO(kdbus_clone_userns_test(bus, POLICY_NAME, g_conn_db, ONTIZEN(0,-EPERM))); for (i = 0; i < MAX_CONN; i++) - kdbus_conn_free(conn_db[i]); + kdbus_conn_free(g_conn_db[i]); kdbus_conn_free(activator); kdbus_conn_free(policy_holder); - free(conn_db); + free(g_conn_db); return TEST_OK; } diff --git a/tests/kdbus/test-policy-priv.c b/tests/kdbus/test-policy-priv.c index 0d9d476..b7f6044 100644 --- a/tests/kdbus/test-policy-priv.c +++ b/tests/kdbus/test-policy-priv.c @@ -827,16 +827,16 @@ static wur int test_policy_priv(struct kdbus_test_env *env) ASSERT_ZERO(kdbus_conn_update_policy(conn_a, "com.example.c", &access, 1)); RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({ - struct kdbus_conn *owner; + struct kdbus_conn *owner_; - ASSERT_NONZERO(owner = kdbus_hello(env->buspath, 0, NULL, 0)); + ASSERT_NONZERO(owner_ = kdbus_hello(env->buspath, 0, NULL, 0)); - ASSERT_EXIT_ZERO(kdbus_name_acquire(owner, "com.example.c", NULL)); + ASSERT_EXIT_ZERO(kdbus_name_acquire(owner_, "com.example.c", NULL)); ASSERT_ZERO(kdbus_msg_send(unpriv, "com.example.c", 0xdeadbeef, 0, 0, 0, 0)); - ASSERT_EXIT(0,<=,kdbus_msg_recv_poll(owner, 100, NULL, NULL)); + ASSERT_EXIT(0,<=,kdbus_msg_recv_poll(owner_, 100, NULL, NULL)); - kdbus_conn_free(owner); + kdbus_conn_free(owner_); })); /* -- 2.34.1