lkml.org 
[lkml]   [2015]   [Oct]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 27/44] kdbus: Cleanup kdbus_conn_new()
Date
 - 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@s15v.net>
---
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


\
 
 \ /
  Last update: 2015-10-08 14:01    [W:1.356 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site