Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1212079

[PATCH] kdbus/selftests: properly reset flags on re-use

From David Herrmann <dh.herrmann@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] kdbus/selftests: properly reset flags on re-use
Date 2015-08-24 13:10 +0200
Message-ID <q0XNw-5TR-25@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


If a test runs NAME_ACQUIRE multiple times, we really need to reset the
'flags' argument for each call. It's an in/out argument, so it might have
been changed by the kdbus_name_acquire() helper. We must not rely on the
flags to be unchanged, so reset them properly.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 tools/testing/selftests/kdbus/test-activator.c | 5 ++++-
 tools/testing/selftests/kdbus/test-message.c   | 4 +++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/kdbus/test-activator.c b/tools/testing/selftests/kdbus/test-activator.c
index 3d1b763..c576a30 100644
--- a/tools/testing/selftests/kdbus/test-activator.c
+++ b/tools/testing/selftests/kdbus/test-activator.c
@@ -47,7 +47,7 @@ static int kdbus_priv_activator(struct kdbus_test_env *env)
 	int ret;
 	struct kdbus_msg *msg = NULL;
 	uint64_t cookie = 0xdeadbeef;
-	uint64_t flags = KDBUS_NAME_REPLACE_EXISTING;
+	uint64_t flags;
 	struct kdbus_conn *activator;
 	struct kdbus_conn *service;
 	struct kdbus_conn *client;
@@ -119,12 +119,14 @@ static int kdbus_priv_activator(struct kdbus_test_env *env)
 	/* Policies are still checked, access denied */
 
 	ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+		flags = KDBUS_NAME_REPLACE_EXISTING;
 		ret = kdbus_name_acquire(unpriv, "foo.priv.activator",
 					 &flags);
 		ASSERT_RETURN(ret == -EPERM);
 	}));
 	ASSERT_RETURN(ret >= 0);
 
+	flags = KDBUS_NAME_REPLACE_EXISTING;
 	ret = kdbus_name_acquire(service, "foo.priv.activator",
 				 &flags);
 	ASSERT_RETURN(ret == 0);
@@ -216,6 +218,7 @@ static int kdbus_priv_activator(struct kdbus_test_env *env)
 	ASSERT_RETURN(ret == 0);
 
 	ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+		flags = KDBUS_NAME_REPLACE_EXISTING;
 		ret = kdbus_name_acquire(unpriv, "foo.priv.activator",
 					 &flags);
 		ASSERT_RETURN(ret == -EPERM);
diff --git a/tools/testing/selftests/kdbus/test-message.c b/tools/testing/selftests/kdbus/test-message.c
index 563dc85..33d349b 100644
--- a/tools/testing/selftests/kdbus/test-message.c
+++ b/tools/testing/selftests/kdbus/test-message.c
@@ -293,7 +293,7 @@ static int kdbus_test_activator_quota(struct kdbus_test_env *env)
 	struct kdbus_conn *sender;
 	struct kdbus_conn *activator;
 	struct kdbus_msg *msg;
-	uint64_t flags = KDBUS_NAME_REPLACE_EXISTING;
+	uint64_t flags;
 	struct kdbus_cmd_recv recv = { .size = sizeof(recv) };
 	struct kdbus_policy_access access = {
 		.type = KDBUS_POLICY_ACCESS_USER,
@@ -375,6 +375,7 @@ static int kdbus_test_activator_quota(struct kdbus_test_env *env)
 	kdbus_msg_free(msg);
 
 	/* Try to acquire the name now */
+	flags = KDBUS_NAME_REPLACE_EXISTING;
 	ret = kdbus_name_acquire(conn, "foo.test.activator", &flags);
 	ASSERT_RETURN(ret == 0);
 
@@ -431,6 +432,7 @@ static int kdbus_test_activator_quota(struct kdbus_test_env *env)
 	ASSERT_RETURN(ret == -ENOBUFS);
 
 	/* Acquire the name again */
+	flags = KDBUS_NAME_REPLACE_EXISTING;
 	ret = kdbus_name_acquire(conn, "foo.test.activator", &flags);
 	ASSERT_RETURN(ret == 0);
 
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH] kdbus/selftests: properly reset flags on re-use David Herrmann <dh.herrmann@gmail.com> - 2015-08-24 13:10 +0200

csiph-web