[PATCH 27/44] kdbus: Cleanup kdbus_conn_new()

From: Sergei Zviagintsev
Date: Thu Oct 08 2015 - 07:34:08 EST


- Replace two tests with one. Sequence of tests

name && !is_activator && !is_policy_holder
!name && (is_activator || is_policy_holder)

is the same as

name XOR (is_activator || is_policy_holder)

Replace these two expressions with

!name == (is_activator || is_policy_holder)

- Drop `privileged' var which is used only once to set value of
conn->privileged.

Signed-off-by: Sergei Zviagintsev <sergei@xxxxxxxx>
---
ipc/kdbus/connection.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/ipc/kdbus/connection.c b/ipc/kdbus/connection.c
index ace587ee951a..c57ff2c846ee 100644
--- a/ipc/kdbus/connection.c
+++ b/ipc/kdbus/connection.c
@@ -73,7 +73,6 @@ static struct kdbus_conn *kdbus_conn_new(struct kdbus_ep *ep,
bool is_policy_holder;
bool is_activator;
bool is_monitor;
- bool privileged;
bool owner;
struct kvec kvec;
int ret;
@@ -84,9 +83,7 @@ static struct kdbus_conn *kdbus_conn_new(struct kdbus_ep *ep,
struct kdbus_bloom_parameter bloom;
} bloom_item;

- privileged = kdbus_ep_is_privileged(ep, file);
owner = kdbus_ep_is_owner(ep, file);
-
is_monitor = hello->flags & KDBUS_HELLO_MONITOR;
is_activator = hello->flags & KDBUS_HELLO_ACTIVATOR;
is_policy_holder = hello->flags & KDBUS_HELLO_POLICY_HOLDER;
@@ -95,9 +92,7 @@ static struct kdbus_conn *kdbus_conn_new(struct kdbus_ep *ep,
return ERR_PTR(-EINVAL);
if (is_monitor + is_activator + is_policy_holder > 1)
return ERR_PTR(-EINVAL);
- if (name && !is_activator && !is_policy_holder)
- return ERR_PTR(-EINVAL);
- if (!name && (is_activator || is_policy_holder))
+ if (!name == (is_activator || is_policy_holder))
return ERR_PTR(-EINVAL);
if (name && !kdbus_name_is_valid(name, true))
return ERR_PTR(-EINVAL);
@@ -138,7 +133,7 @@ static struct kdbus_conn *kdbus_conn_new(struct kdbus_ep *ep,
get_fs_root(current->fs, &conn->root_path);
init_waitqueue_head(&conn->wait);
kdbus_queue_init(&conn->queue);
- conn->privileged = privileged;
+ conn->privileged = kdbus_ep_is_privileged(ep, file);
conn->owner = owner;
conn->ep = kdbus_ep_ref(ep);
conn->id = atomic64_inc_return(&bus->domain->last_id);
--
1.8.3.1

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