Re: [PATCH 43/44] kdbus: Give up on failed fd allocation

2015-10-09 Thread Sergei Zviagintsev
Hi, On Thu, Oct 08, 2015 at 05:14:24PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:32 PM, Sergei Zviagintsev wrote: > > If we failed to allocate a file descriptor, do not try to do it again on > > the next iteration. There are few chances that we will hav

Re: [PATCH 38/44] kdbus: Fix error path in kdbus_user_lookup()

2015-10-09 Thread Sergei Zviagintsev
Hi David, On Thu, Oct 08, 2015 at 05:06:57PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:32 PM, Sergei Zviagintsev wrote: > > If idr_alloc() fails, we shouldn't call idr_remove() as latter produces > > warning when called on non-allocated ids. Split cl

Re: [PATCH 31/44] kdbus: Cleanup kdbus_conn_move_messages()

2015-10-09 Thread Sergei Zviagintsev
Hi, On Thu, Oct 08, 2015 at 04:50:31PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:32 PM, Sergei Zviagintsev wrote: > > - Move `r' and `ret' to scopes where they are used. Drop redundant > >initialization of `ret'. > > > >

Re: [PATCH 26/44] kdbus: Cleanup kdbus_pin_dst()

2015-10-09 Thread Sergei Zviagintsev
Hi, On Thu, Oct 08, 2015 at 04:40:33PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:31 PM, Sergei Zviagintsev wrote: > > - Reduce scope of `owner' var to the block where it is actually used. > >Use conditional operator to set its value. > >

Re: [PATCH 25/44] kdbus: Cleanup kdbus_cmd_conn_info()

2015-10-09 Thread Sergei Zviagintsev
Hi, On Thu, Oct 08, 2015 at 04:38:11PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:31 PM, Sergei Zviagintsev wrote: > > - Move `entry' and `owner' to the scope where they are used. Drop > >redundand initialization of `entry'. Use condit

Re: [PATCH 24/44] kdbus: Cleanup kdbus_conn_unicast()

2015-10-09 Thread Sergei Zviagintsev
On Thu, Oct 08, 2015 at 04:34:27PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:31 PM, Sergei Zviagintsev wrote: > > Do not initialize `name' and `ret' as values are assigned to them at > > the first use by kdbus_pin_dst(). Simplify handling of > &

Re: [PATCH 23/44] kdbus: Cleanup kdbus_conn_call()

2015-10-09 Thread Sergei Zviagintsev
On Thu, Oct 08, 2015 at 04:32:47PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:31 PM, Sergei Zviagintsev wrote: > > Do not initialize `wait' and `name' as values are assigned to them at > > first use: `wait' gets its value from kdbus_reply_

Re: [PATCH 05/44] kdbus: Add comment on merging free pool slices

2015-10-09 Thread Sergei Zviagintsev
Hi, On Thu, Oct 08, 2015 at 03:50:46PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:31 PM, Sergei Zviagintsev wrote: > > Add comment on why we remove the same slice from free slices tree and > > then add it back again when merging the slice to be relea

Re: [PATCH 21/44] kdbus: Cleanup tests in kdbus_cmd_send()

2015-10-09 Thread Sergei Zviagintsev
On Thu, Oct 08, 2015 at 04:30:59PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:31 PM, Sergei Zviagintsev wrote: > > Rearrange tests a little to make them look cleaner. > > What's wrong with 'else if'? Less verbose constructions are easier for our brain

Re: [PATCH 18/44] kdbus: Add var initialization to kdbus_conn_entry_insert()

2015-10-09 Thread Sergei Zviagintsev
Hi, On Thu, Oct 08, 2015 at 04:28:29PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:31 PM, Sergei Zviagintsev wrote: > > Assign zero to `ret' in the beginning of function instead of doing it > > in the end. > > > > Signed-off-by: Sergei Zv

Re: [PATCH 15/44] kdbus: Simplify bitwise expression in kdbus_meta_get_mask()

2015-10-09 Thread Sergei Zviagintsev
Hi David, On Thu, Oct 08, 2015 at 04:24:30PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:31 PM, Sergei Zviagintsev wrote: > > Replace the expression with more concise and readable equivalent. It can > > be proven by opening parentheses: > > >

Re: [PATCH 07/44] kdbus: Fix comment on translation of caps between namespaces

2015-10-09 Thread Sergei Zviagintsev
Hi, On Fri, Oct 09, 2015 at 11:43:22AM +0800, Hillf Danton wrote: > > @@ -730,15 +730,21 @@ static void kdbus_meta_export_caps(struct > > kdbus_meta_caps *out, > > > > /* > > * This translates the effective capabilities of 'cred' into the given > > -* user-namespace. If the given

Re: [PATCH 00/44] kdbus cleanups

2015-10-09 Thread Sergei Zviagintsev
Hi David, On Thu, Oct 08, 2015 at 05:20:34PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:31 PM, Sergei Zviagintsev wrote: > > Hi all, > > > > This is a set of various kdbus code cleanups. Patches are ordered by > > increasing complexity, star

Re: [PATCH 07/44] kdbus: Fix comment on translation of caps between namespaces

2015-10-09 Thread Sergei Zviagintsev
Hi, On Fri, Oct 09, 2015 at 11:43:22AM +0800, Hillf Danton wrote: > > @@ -730,15 +730,21 @@ static void kdbus_meta_export_caps(struct > > kdbus_meta_caps *out, > > > > /* > > * This translates the effective capabilities of 'cred' into the given > > -* user-namespace. If the given

Re: [PATCH 00/44] kdbus cleanups

2015-10-09 Thread Sergei Zviagintsev
Hi David, On Thu, Oct 08, 2015 at 05:20:34PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:31 PM, Sergei Zviagintsev <ser...@s15v.net> wrote: > > Hi all, > > > > This is a set of various kdbus code cleanups. Patches are ordered by > > in

Re: [PATCH 15/44] kdbus: Simplify bitwise expression in kdbus_meta_get_mask()

2015-10-09 Thread Sergei Zviagintsev
Hi David, On Thu, Oct 08, 2015 at 04:24:30PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:31 PM, Sergei Zviagintsev <ser...@s15v.net> wrote: > > Replace the expression with more concise and readable equivalent. It can > > be proven by opening parent

Re: [PATCH 18/44] kdbus: Add var initialization to kdbus_conn_entry_insert()

2015-10-09 Thread Sergei Zviagintsev
Hi, On Thu, Oct 08, 2015 at 04:28:29PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:31 PM, Sergei Zviagintsev <ser...@s15v.net> wrote: > > Assign zero to `ret' in the beginning of function instead of doing it > > in the end. > > > >

Re: [PATCH 24/44] kdbus: Cleanup kdbus_conn_unicast()

2015-10-09 Thread Sergei Zviagintsev
On Thu, Oct 08, 2015 at 04:34:27PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:31 PM, Sergei Zviagintsev <ser...@s15v.net> wrote: > > Do not initialize `name' and `ret' as values are assigned to them at > > the first use by kdbus_p

Re: [PATCH 25/44] kdbus: Cleanup kdbus_cmd_conn_info()

2015-10-09 Thread Sergei Zviagintsev
Hi, On Thu, Oct 08, 2015 at 04:38:11PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:31 PM, Sergei Zviagintsev <ser...@s15v.net> wrote: > > - Move `entry' and `owner' to the scope where they are used. Drop > >redundand initialization of `entry

Re: [PATCH 31/44] kdbus: Cleanup kdbus_conn_move_messages()

2015-10-09 Thread Sergei Zviagintsev
Hi, On Thu, Oct 08, 2015 at 04:50:31PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:32 PM, Sergei Zviagintsev <ser...@s15v.net> wrote: > > - Move `r' and `ret' to scopes where they are used. Drop redundant > >initialization of `ret'.

Re: [PATCH 21/44] kdbus: Cleanup tests in kdbus_cmd_send()

2015-10-09 Thread Sergei Zviagintsev
On Thu, Oct 08, 2015 at 04:30:59PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:31 PM, Sergei Zviagintsev <ser...@s15v.net> wrote: > > Rearrange tests a little to make them look cleaner. > > What's wrong with 'else if'? Less verbose constructio

Re: [PATCH 05/44] kdbus: Add comment on merging free pool slices

2015-10-09 Thread Sergei Zviagintsev
Hi, On Thu, Oct 08, 2015 at 03:50:46PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:31 PM, Sergei Zviagintsev <ser...@s15v.net> wrote: > > Add comment on why we remove the same slice from free slices tree and > > then add it back again when mergi

Re: [PATCH 23/44] kdbus: Cleanup kdbus_conn_call()

2015-10-09 Thread Sergei Zviagintsev
On Thu, Oct 08, 2015 at 04:32:47PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:31 PM, Sergei Zviagintsev <ser...@s15v.net> wrote: > > Do not initialize `wait' and `name' as values are assigned to them at > > first use: `wait' gets its value fro

Re: [PATCH 26/44] kdbus: Cleanup kdbus_pin_dst()

2015-10-09 Thread Sergei Zviagintsev
Hi, On Thu, Oct 08, 2015 at 04:40:33PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:31 PM, Sergei Zviagintsev <ser...@s15v.net> wrote: > > - Reduce scope of `owner' var to the block where it is actually used. > >Use conditional operator to set

Re: [PATCH 38/44] kdbus: Fix error path in kdbus_user_lookup()

2015-10-09 Thread Sergei Zviagintsev
Hi David, On Thu, Oct 08, 2015 at 05:06:57PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:32 PM, Sergei Zviagintsev <ser...@s15v.net> wrote: > > If idr_alloc() fails, we shouldn't call idr_remove() as latter produces > > warning when called on non-a

Re: [PATCH 43/44] kdbus: Give up on failed fd allocation

2015-10-09 Thread Sergei Zviagintsev
Hi, On Thu, Oct 08, 2015 at 05:14:24PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:32 PM, Sergei Zviagintsev <ser...@s15v.net> wrote: > > If we failed to allocate a file descriptor, do not try to do it again on > > the next iteration. There are fe

[PATCH 03/44] kdbus: Kernel-docs and comments trivial fixes

2015-10-08 Thread Sergei Zviagintsev
nd iovec as they relate to the old code. - struct kdbus_queue_entry: Fix typo: "messages" -> "message". - kdbus_pool_slice_publish(): Remove obsolete line from the description. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/connection.c | 6 +++--- ipc/kdbus/conne

[PATCH 07/44] kdbus: Fix comment on translation of caps between namespaces

2015-10-08 Thread Sergei Zviagintsev
if the process is a member of the given userns. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/metadata.c | 24 +++- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/ipc/kdbus/metadata.c b/ipc/kdbus/metadata.c index 71ca475a80d5..4ff4b99a40e0 100644 --- a/ipc

[PATCH 06/44] kdbus: Fix kernel-doc for struct kdbus_gaps

2015-10-08 Thread Sergei Zviagintsev
Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/message.h | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ipc/kdbus/message.h b/ipc/kdbus/message.h index 298f9c99dfcf..405a5668f9d5 100644 --- a/ipc/kdbus/message.h +++ b/ipc/kdbus/message.h @@ -27,11 +27,12 @@ struct

[PATCH 09/44] kdbus: Remove unused KDBUS_MSG_MAX_SIZE constant

2015-10-08 Thread Sergei Zviagintsev
Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/limits.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/ipc/kdbus/limits.h b/ipc/kdbus/limits.h index bd47119cdf1b..5e4d2b5b0a9d 100644 --- a/ipc/kdbus/limits.h +++ b/ipc/kdbus/limits.h @@ -16,9 +16,6 @@ #include -/* maximum size

[PATCH 11/44] kdbus: Cosmetic fix of kdbus_name_is_valid()

2015-10-08 Thread Sergei Zviagintsev
Initialize `dot' during declaration but not in the for-loop, as it is not used as a loop cursor. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/names.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ipc/kdbus/names.c b/ipc/kdbus/names.c index 6b31b38ac2ad..4dea83defc8e

[PATCH 15/44] kdbus: Simplify bitwise expression in kdbus_meta_get_mask()

2015-10-08 Thread Sergei Zviagintsev
Replace the expression with more concise and readable equivalent. It can be proven by opening parentheses: r & ~((p | i) & r) == r & (~(p | i) | ~r) == (r & ~(p | i)) | (r & ~r) == r & ~(p | i) == r & ~p & ~i Signed-off-by: Sergei Zviagintsev --- ipc

[PATCH 19/44] kdbus: Drop useless initialization from kdbus_conn_reply()

2015-10-08 Thread Sergei Zviagintsev
`name' is assigned the value at first use by kdbus_pin_dst(). Do not initialize it during declaration. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/connection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipc/kdbus/connection.c b/ipc/kdbus/connection.c index

[PATCH 18/44] kdbus: Add var initialization to kdbus_conn_entry_insert()

2015-10-08 Thread Sergei Zviagintsev
Assign zero to `ret' in the beginning of function instead of doing it in the end. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/connection.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ipc/kdbus/connection.c b/ipc/kdbus/connection.c index 4f3cd370ecd9..185ed3ba1bce

[PATCH 20/44] kdbus: Drop useless initialization from kdbus_cmd_hello()

2015-10-08 Thread Sergei Zviagintsev
Do not initialize `c' as it is assigned a return value of kdbus_conn_new() at the first use. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/connection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipc/kdbus/connection.c b/ipc/kdbus/connection.c index 4b5ed4bb59c7

[PATCH 21/44] kdbus: Cleanup tests in kdbus_cmd_send()

2015-10-08 Thread Sergei Zviagintsev
Rearrange tests a little to make them look cleaner. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/connection.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ipc/kdbus/connection.c b/ipc/kdbus/connection.c index 93da7f539f74..a4d7414ecaea 100644 --- a/ipc/kdbus

[PATCH 23/44] kdbus: Cleanup kdbus_conn_call()

2015-10-08 Thread Sergei Zviagintsev
kdbus_conn_entry_insert() returns 0 on success. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/connection.c | 10 ++ 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/ipc/kdbus/connection.c b/ipc/kdbus/connection.c index a4d7414ecaea..db49f282a1bf 100644 --- a/ipc/kdbus/connection.c +++ b

[PATCH 25/44] kdbus: Cleanup kdbus_cmd_conn_info()

2015-10-08 Thread Sergei Zviagintsev
. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/connection.c | 16 +++- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/ipc/kdbus/connection.c b/ipc/kdbus/connection.c index b3c5f20a57d8..6a73ac3f444d 100644 --- a/ipc/kdbus/connection.c +++ b/ipc/kdbus/connection.c

[PATCH 26/44] kdbus: Cleanup kdbus_pin_dst()

2015-10-08 Thread Sergei Zviagintsev
- Reduce scope of `owner' var to the block where it is actually used. Use conditional operator to set its value. - Drop initialization of `dst' as it gets value later. - Drop separate exit point as we have only one use case of it. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus

[PATCH 28/44] kdbus: Cleanup kdbus_queue_entry_new()

2015-10-08 Thread Sergei Zviagintsev
Remove separate exit point as the only error case in the function is when kdbus_staging_emit() fails. Assign a slice to temporary var first to not clear it explicitly on error and to return an error code without `ret' variable. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/queue.c | 16

[PATCH 31/44] kdbus: Cleanup kdbus_conn_move_messages()

2015-10-08 Thread Sergei Zviagintsev
- Move `r' and `ret' to scopes where they are used. Drop redundant initialization of `ret'. - Initialize `bus' on declaration. - Replace list_for_each_entry_safe() with list_for_each_entry() when iterating over list of replies. - Drop redundant `continue'. Signed-off-by: Sergei

[PATCH 34/44] kdbus: Improve kdbus_conn_entry_sync_attach()

2015-10-08 Thread Sergei Zviagintsev
Use goto to handle error paths in conventional way. Use conditional operator instead of `remote_ret' var. Update the comment on waking up remote peer. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/connection.c | 52 -- 1 file changed, 21

[PATCH 30/44] kdbus: Cleanup kdbus_meta_proc_mask()

2015-10-08 Thread Sergei Zviagintsev
roc < KDBUS_META_PROC_NORMAL' case we firstly do 'wanted &= ~flags' and then 'wanted & flags' in the return statement, which is the same as 'wanted & 0'. Return 0 instead. - Cosmetic cleanup of the return statement. Signed-off-by: Sergei Zviagintsev --- ipc/kdb

[PATCH 32/44] kdbus: Remove duplicated code from kdbus_conn_lock2()

2015-10-08 Thread Sergei Zviagintsev
Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/connection.h | 18 +++--- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/ipc/kdbus/connection.h b/ipc/kdbus/connection.h index 679f393d3e68..3b382b604348 100644 --- a/ipc/kdbus/connection.h +++ b/ipc/kdbus/connection.h

[PATCH 36/44] kdbus: Improve kdbus_name_release()

2015-10-08 Thread Sergei Zviagintsev
Use goto to handle error paths in conventional way. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/names.c | 21 + 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/ipc/kdbus/names.c b/ipc/kdbus/names.c index a1c3442f8e53..8e53681d1b7b 100644 --- a/ipc/kdbus

[PATCH 41/44] kdbus: Fix memfd install algorithm

2015-10-08 Thread Sergei Zviagintsev
tor for memfd. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/message.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ipc/kdbus/message.c b/ipc/kdbus/message.c index f2176796390d..0653a085c104 100644 --- a/ipc/kdbus/message.c +++ b/ipc/kdbus/message.c @@ -181,6 +181,7 @@ int kdbus_gaps_inst

[PATCH 43/44] kdbus: Give up on failed fd allocation

2015-10-08 Thread Sergei Zviagintsev
If we failed to allocate a file descriptor, do not try to do it again on the next iteration. There are few chances that we will have success, and we can simplify the algorithm assuming that valid fd numbers are not mixed with -1 values. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/message.c

[PATCH 38/44] kdbus: Fix error path in kdbus_user_lookup()

2015-10-08 Thread Sergei Zviagintsev
If idr_alloc() fails, we shouldn't call idr_remove() as latter produces warning when called on non-allocated ids. Split cleanup code into three parts for differrent cleanup scenarios before and after idr_alloc(). Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/domain.c | 20

[PATCH 39/44] kdbus: Cleanup kdbus_user_lookup()

2015-10-08 Thread Sergei Zviagintsev
which is equivalent but more concise and readable (as we used same vars in the code above). Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/domain.c | 26 -- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/ipc/kdbus/domain.c b/ipc/kdbus/domain.c

[PATCH 40/44] kdbus: Cleanup kdbus_item_validate_name()

2015-10-08 Thread Sergei Zviagintsev
. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/item.c | 26 ++ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/ipc/kdbus/item.c b/ipc/kdbus/item.c index ce78dba03426..e6b6e2ca7e05 100644 --- a/ipc/kdbus/item.c +++ b/ipc/kdbus/item.c @@ -37,32 +37,26

[PATCH 44/44] kdbus: Cleanup kdbus_gaps_install()

2015-10-08 Thread Sergei Zviagintsev
- Assign `false' to *out_incomplete directly on no-op cases. - Initialize `ret' with zero during declaration instead of doing it in the end of the function. - Initialize `fd' and `memfd' vars during declaration to be more concise. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus

[PATCH 37/44] kdbus: Fix error path in kdbus_meta_proc_collect_cgroup()

2015-10-08 Thread Sergei Zviagintsev
Current code checks return value of task_cgroup_path(), which can be NULL if provided buffer isn't long enough to store path there, but alters mp->valid in case of error, producing inconsistency. Return -ENAMETOOLONG if task_cgroup_path() fails. Signed-off-by: Sergei Zviagintsev --- ipc/kd

[PATCH 35/44] kdbus: Drop goto from kdbus_queue_entry_link()

2015-10-08 Thread Sergei Zviagintsev
Use conventional if-else logic instead of goto, which makes the function easier to read. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/queue.c | 32 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/ipc/kdbus/queue.c b/ipc/kdbus/queue.c index

[PATCH 42/44] kdbus: Check if fd is allocated before trying to free it

2015-10-08 Thread Sergei Zviagintsev
Elements of `fds' array were set to -1 in case if we couldn't allocate a fd. Verify that element contains a valid fd number before submitting it to put_unused_fd(). Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/message.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git

[PATCH 13/44] kdbus: Use list_next_entry() in kdbus_queue_entry_unlink()

2015-10-08 Thread Sergei Zviagintsev
Use list_next_entry() instead of list_first_entry(). Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/queue.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ipc/kdbus/queue.c b/ipc/kdbus/queue.c index f9c44d7bae6d..90e8d16f5967 100644 --- a/ipc/kdbus/queue.c +++ b/ipc

[PATCH 10/44] kdbus: Use conditional operator

2015-10-08 Thread Sergei Zviagintsev
Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/names.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ipc/kdbus/names.c b/ipc/kdbus/names.c index bf44ca3f12b6..6b31b38ac2ad 100644 --- a/ipc/kdbus/names.c +++ b/ipc/kdbus/names.c @@ -438,10 +438,7 @@ static void

[PATCH 14/44] kdbus: Simplify expression in kdbus_get_memfd()

2015-10-08 Thread Sergei Zviagintsev
'(s & m) != m' means that mask 'm' contains some bits which are not set in 's', and this is literally equal to '~s & m'. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipc/kdbus/message.c b/ipc/kdbus/message

[PATCH 24/44] kdbus: Cleanup kdbus_conn_unicast()

2015-10-08 Thread Sergei Zviagintsev
Do not initialize `name' and `ret' as values are assigned to them at the first use by kdbus_pin_dst(). Simplify handling of kdbus_conn_entry_insert() return value and drop useless goto. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/connection.c | 10 -- 1 file changed, 4 insertions

[PATCH 33/44] kdbus: Improve kdbus_staging_reserve()

2015-10-08 Thread Sergei Zviagintsev
Allow to reserve N elements in row. This eliminates duplicated code. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/message.c | 22 -- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/ipc/kdbus/message.c b/ipc/kdbus/message.c index e337b1b1024a..f2176796390d

[PATCH 17/44] kdbus: Drop duplicated code from kdbus_pool_slice_alloc()

2015-10-08 Thread Sergei Zviagintsev
Check the value of `ret' instead of keeping separate exit point. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/pool.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ipc/kdbus/pool.c b/ipc/kdbus/pool.c index cb692a35755b..75a7366baa34 100644 --- a/ipc/kdbus/pool.c

[PATCH 22/44] kdbus: Cleanup error path in kdbus_staging_new_user()

2015-10-08 Thread Sergei Zviagintsev
Replace duplicated cleanup code with jump to exit point. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/message.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ipc/kdbus/message.c b/ipc/kdbus/message.c index c7ef23d40471..e337b1b1024a 100644 --- a/ipc/kdbus/message.c

[PATCH 08/44] kdbus: Rename var in kdbus_meta_export_caps()

2015-10-08 Thread Sergei Zviagintsev
' var, as it can be read "cred is a member of user_ns or one of its parents" and "cred is the owner of ...". Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/metadata.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ipc/kdbus/metadata.c b/ipc/kd

[PATCH 16/44] kdbus: Drop redundant code from kdbus_name_acquire()

2015-10-08 Thread Sergei Zviagintsev
We already reached the end of function at this point, so remove useless goto. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/names.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/ipc/kdbus/names.c b/ipc/kdbus/names.c index 4dea83defc8e..a1c3442f8e53 100644 --- a/ipc/kdbus/names.c +++ b

[PATCH 29/44] kdbus: Improve tests on incrementing quota

2015-10-08 Thread Sergei Zviagintsev
gt;fds + fds' to be safe in the second expression (as fds is size_t, quota->fds is converted to bigger type). Rewrite it in more obvious way. KDBUS_CONN_MAX_FDS_PER_USER is checked at compile time to fill in quota->fds type (there is BUILD_BUG_ON), so no further checks for quo

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

2015-10-08 Thread Sergei Zviagintsev
!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 --- ipc/kdbus/connection.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/ipc/kdbus/connection.c b/i

[PATCH 12/44] kdbus: Use conventional list macros in __kdbus_pool_slice_release()

2015-10-08 Thread Sergei Zviagintsev
Use list_next_entry() and list_prev_entry(). Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/pool.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ipc/kdbus/pool.c b/ipc/kdbus/pool.c index c26ef963d8d1..cb692a35755b 100644 --- a/ipc/kdbus/pool.c +++ b/ipc/kdbus/pool.c

[PATCH 00/44] kdbus cleanups

2015-10-08 Thread Sergei Zviagintsev
layout of this, split/join, etc if necessary. Thanks, Sergei Sergei Zviagintsev (44): Documentation/kdbus: Document new name registry flags uapi: kdbus.h: Kernel-doc fixes kdbus: Kernel-docs and comments trivial fixes kdbus: Update kernel-doc for struct kdbus_pool kdbus: Add comment

[PATCH 04/44] kdbus: Update kernel-doc for struct kdbus_pool

2015-10-08 Thread Sergei Zviagintsev
Add words on how free and busy slices trees are sorted. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/pool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ipc/kdbus/pool.c b/ipc/kdbus/pool.c index 0433e26b777e..84afe96fbc22 100644 --- a/ipc/kdbus/pool.c +++ b/ipc

[PATCH 02/44] uapi: kdbus.h: Kernel-doc fixes

2015-10-08 Thread Sergei Zviagintsev
- Fix typos and spelling errors, use proper case. - struct kdbus_pids: Add PPID to description. - struct kdbus_item: Add missing @pids, @fsd and KDBUS_ITEM_PAYLOAD_OFF. Signed-off-by: Sergei Zviagintsev --- include/uapi/linux/kdbus.h | 43 +++ 1

[PATCH 01/44] Documentation/kdbus: Document new name registry flags

2015-10-08 Thread Sergei Zviagintsev
Add description of KDBUS_NAME_PRIMARY and KDBUS_NAME_ACQUIRED flags which were added in commit 0486b859f05a ("kdbus: inform caller about exact updates on NAME_ACQUIRE"). Signed-off-by: Sergei Zviagintsev --- Documentation/kdbus/kdbus.name.xml | 42 +++-

[PATCH 05/44] kdbus: Add comment on merging free pool slices

2015-10-08 Thread Sergei Zviagintsev
Add comment on why we remove the same slice from free slices tree and then add it back again when merging the slice to be released with previous free slice. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/pool.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/ipc/kdbus/pool.c b/ipc

[PATCH 19/44] kdbus: Drop useless initialization from kdbus_conn_reply()

2015-10-08 Thread Sergei Zviagintsev
`name' is assigned the value at first use by kdbus_pin_dst(). Do not initialize it during declaration. Signed-off-by: Sergei Zviagintsev <ser...@s15v.net> --- ipc/kdbus/connection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipc/kdbus/connection.c b/ipc

[PATCH 18/44] kdbus: Add var initialization to kdbus_conn_entry_insert()

2015-10-08 Thread Sergei Zviagintsev
Assign zero to `ret' in the beginning of function instead of doing it in the end. Signed-off-by: Sergei Zviagintsev <ser...@s15v.net> --- ipc/kdbus/connection.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ipc/kdbus/connection.c b/ipc/kdbus/connection.c

[PATCH 20/44] kdbus: Drop useless initialization from kdbus_cmd_hello()

2015-10-08 Thread Sergei Zviagintsev
Do not initialize `c' as it is assigned a return value of kdbus_conn_new() at the first use. Signed-off-by: Sergei Zviagintsev <ser...@s15v.net> --- ipc/kdbus/connection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipc/kdbus/connection.c b/ipc/kdbus/connection.c

[PATCH 15/44] kdbus: Simplify bitwise expression in kdbus_meta_get_mask()

2015-10-08 Thread Sergei Zviagintsev
Replace the expression with more concise and readable equivalent. It can be proven by opening parentheses: r & ~((p | i) & r) == r & (~(p | i) | ~r) == (r & ~(p | i)) | (r & ~r) == r & ~(p | i) == r & ~p & ~i Signed-off-by: Sergei Zviagintsev

[PATCH 33/44] kdbus: Improve kdbus_staging_reserve()

2015-10-08 Thread Sergei Zviagintsev
Allow to reserve N elements in row. This eliminates duplicated code. Signed-off-by: Sergei Zviagintsev <ser...@s15v.net> --- ipc/kdbus/message.c | 22 -- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/ipc/kdbus/message.c b/ipc/kdbus/message.c

[PATCH 17/44] kdbus: Drop duplicated code from kdbus_pool_slice_alloc()

2015-10-08 Thread Sergei Zviagintsev
Check the value of `ret' instead of keeping separate exit point. Signed-off-by: Sergei Zviagintsev <ser...@s15v.net> --- ipc/kdbus/pool.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ipc/kdbus/pool.c b/ipc/kdbus/pool.c index cb692a35755b..75a7366baa34 100644 ---

[PATCH 22/44] kdbus: Cleanup error path in kdbus_staging_new_user()

2015-10-08 Thread Sergei Zviagintsev
Replace duplicated cleanup code with jump to exit point. Signed-off-by: Sergei Zviagintsev <ser...@s15v.net> --- ipc/kdbus/message.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ipc/kdbus/message.c b/ipc/kdbus/message.c index c7ef23d40471..e337b1b1024a 100644 ---

[PATCH 13/44] kdbus: Use list_next_entry() in kdbus_queue_entry_unlink()

2015-10-08 Thread Sergei Zviagintsev
Use list_next_entry() instead of list_first_entry(). Signed-off-by: Sergei Zviagintsev <ser...@s15v.net> --- ipc/kdbus/queue.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ipc/kdbus/queue.c b/ipc/kdbus/queue.c index f9c44d7bae6d..90e8d16f5967 100644 --- a/ipc

[PATCH 10/44] kdbus: Use conditional operator

2015-10-08 Thread Sergei Zviagintsev
Signed-off-by: Sergei Zviagintsev <ser...@s15v.net> --- ipc/kdbus/names.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ipc/kdbus/names.c b/ipc/kdbus/names.c index bf44ca3f12b6..6b31b38ac2ad 100644 --- a/ipc/kdbus/names.c +++ b/ipc/kdbus/names.c @@ -438,10

[PATCH 08/44] kdbus: Rename var in kdbus_meta_export_caps()

2015-10-08 Thread Sergei Zviagintsev
' var, as it can be read "cred is a member of user_ns or one of its parents" and "cred is the owner of ...". Signed-off-by: Sergei Zviagintsev <ser...@s15v.net> --- ipc/kdbus/metadata.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ipc/kd

[PATCH 14/44] kdbus: Simplify expression in kdbus_get_memfd()

2015-10-08 Thread Sergei Zviagintsev
'(s & m) != m' means that mask 'm' contains some bits which are not set in 's', and this is literally equal to '~s & m'. Signed-off-by: Sergei Zviagintsev <ser...@s15v.net> --- ipc/kdbus/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipc/kdbus/message

[PATCH 24/44] kdbus: Cleanup kdbus_conn_unicast()

2015-10-08 Thread Sergei Zviagintsev
Do not initialize `name' and `ret' as values are assigned to them at the first use by kdbus_pin_dst(). Simplify handling of kdbus_conn_entry_insert() return value and drop useless goto. Signed-off-by: Sergei Zviagintsev <ser...@s15v.net> --- ipc/kdbus/connection.c | 10 -- 1 file c

[PATCH 16/44] kdbus: Drop redundant code from kdbus_name_acquire()

2015-10-08 Thread Sergei Zviagintsev
We already reached the end of function at this point, so remove useless goto. Signed-off-by: Sergei Zviagintsev <ser...@s15v.net> --- ipc/kdbus/names.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/ipc/kdbus/names.c b/ipc/kdbus/names.c index 4dea83defc8e..a1c3442f8e53 100644 ---

[PATCH 29/44] kdbus: Improve tests on incrementing quota

2015-10-08 Thread Sergei Zviagintsev
gt;fds + fds' to be safe in the second expression (as fds is size_t, quota->fds is converted to bigger type). Rewrite it in more obvious way. KDBUS_CONN_MAX_FDS_PER_USER is checked at compile time to fill in quota->fds type (there is BUILD_BUG_ON), so no further checks for quota-&g

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

2015-10-08 Thread Sergei Zviagintsev
!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 <ser...@s15v.net> --- ipc/kdbus/connection.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/i

[PATCH 12/44] kdbus: Use conventional list macros in __kdbus_pool_slice_release()

2015-10-08 Thread Sergei Zviagintsev
Use list_next_entry() and list_prev_entry(). Signed-off-by: Sergei Zviagintsev <ser...@s15v.net> --- ipc/kdbus/pool.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ipc/kdbus/pool.c b/ipc/kdbus/pool.c index c26ef963d8d1..cb692a35755b 100644 --- a/ipc/kdbus/pool.c

[PATCH 34/44] kdbus: Improve kdbus_conn_entry_sync_attach()

2015-10-08 Thread Sergei Zviagintsev
Use goto to handle error paths in conventional way. Use conditional operator instead of `remote_ret' var. Update the comment on waking up remote peer. Signed-off-by: Sergei Zviagintsev <ser...@s15v.net> --- ipc/kdbus/connection.c | 52 --

[PATCH 26/44] kdbus: Cleanup kdbus_pin_dst()

2015-10-08 Thread Sergei Zviagintsev
- Reduce scope of `owner' var to the block where it is actually used. Use conditional operator to set its value. - Drop initialization of `dst' as it gets value later. - Drop separate exit point as we have only one use case of it. Signed-off-by: Sergei Zviagintsev <ser...@s15v.

[PATCH 28/44] kdbus: Cleanup kdbus_queue_entry_new()

2015-10-08 Thread Sergei Zviagintsev
Remove separate exit point as the only error case in the function is when kdbus_staging_emit() fails. Assign a slice to temporary var first to not clear it explicitly on error and to return an error code without `ret' variable. Signed-off-by: Sergei Zviagintsev <ser...@s15v.net> --- ipc

[PATCH 31/44] kdbus: Cleanup kdbus_conn_move_messages()

2015-10-08 Thread Sergei Zviagintsev
- Move `r' and `ret' to scopes where they are used. Drop redundant initialization of `ret'. - Initialize `bus' on declaration. - Replace list_for_each_entry_safe() with list_for_each_entry() when iterating over list of replies. - Drop redundant `continue'. Signed-off-by: Sergei

[PATCH 00/44] kdbus cleanups

2015-10-08 Thread Sergei Zviagintsev
layout of this, split/join, etc if necessary. Thanks, Sergei Sergei Zviagintsev (44): Documentation/kdbus: Document new name registry flags uapi: kdbus.h: Kernel-doc fixes kdbus: Kernel-docs and comments trivial fixes kdbus: Update kernel-doc for struct kdbus_pool kdbus: Add comment

[PATCH 04/44] kdbus: Update kernel-doc for struct kdbus_pool

2015-10-08 Thread Sergei Zviagintsev
Add words on how free and busy slices trees are sorted. Signed-off-by: Sergei Zviagintsev <ser...@s15v.net> --- ipc/kdbus/pool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ipc/kdbus/pool.c b/ipc/kdbus/pool.c index 0433e26b777e..84afe96fbc22 100644 --- a/ipc

[PATCH 01/44] Documentation/kdbus: Document new name registry flags

2015-10-08 Thread Sergei Zviagintsev
Add description of KDBUS_NAME_PRIMARY and KDBUS_NAME_ACQUIRED flags which were added in commit 0486b859f05a ("kdbus: inform caller about exact updates on NAME_ACQUIRE"). Signed-off-by: Sergei Zviagintsev <ser...@s15v.net> --- Documentation/kdbus/kdb

[PATCH 05/44] kdbus: Add comment on merging free pool slices

2015-10-08 Thread Sergei Zviagintsev
Add comment on why we remove the same slice from free slices tree and then add it back again when merging the slice to be released with previous free slice. Signed-off-by: Sergei Zviagintsev <ser...@s15v.net> --- ipc/kdbus/pool.c | 6 ++ 1 file changed, 6 insertions(+) diff --git

[PATCH 02/44] uapi: kdbus.h: Kernel-doc fixes

2015-10-08 Thread Sergei Zviagintsev
- Fix typos and spelling errors, use proper case. - struct kdbus_pids: Add PPID to description. - struct kdbus_item: Add missing @pids, @fsd and KDBUS_ITEM_PAYLOAD_OFF. Signed-off-by: Sergei Zviagintsev <ser...@s15v.net> --- include/uapi/linux/kdbus.

[PATCH 25/44] kdbus: Cleanup kdbus_cmd_conn_info()

2015-10-08 Thread Sergei Zviagintsev
. Signed-off-by: Sergei Zviagintsev <ser...@s15v.net> --- ipc/kdbus/connection.c | 16 +++- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/ipc/kdbus/connection.c b/ipc/kdbus/connection.c index b3c5f20a57d8..6a73ac3f444d 100644 --- a/ipc/kdbus/connection.c +++ b/ipc

[PATCH 23/44] kdbus: Cleanup kdbus_conn_call()

2015-10-08 Thread Sergei Zviagintsev
kdbus_conn_entry_insert() returns 0 on success. Signed-off-by: Sergei Zviagintsev <ser...@s15v.net> --- ipc/kdbus/connection.c | 10 ++ 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/ipc/kdbus/connection.c b/ipc/kdbus/connection.c index a4d7414ecaea..db49f282a1bf 100644 --- a/ipc

[PATCH 21/44] kdbus: Cleanup tests in kdbus_cmd_send()

2015-10-08 Thread Sergei Zviagintsev
Rearrange tests a little to make them look cleaner. Signed-off-by: Sergei Zviagintsev <ser...@s15v.net> --- ipc/kdbus/connection.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ipc/kdbus/connection.c b/ipc/kdbus/connection.c index 93da7f539f74..a4d7414ecaea

[PATCH 03/44] kdbus: Kernel-docs and comments trivial fixes

2015-10-08 Thread Sergei Zviagintsev
nd iovec as they relate to the old code. - struct kdbus_queue_entry: Fix typo: "messages" -> "message". - kdbus_pool_slice_publish(): Remove obsolete line from the description. Signed-off-by: Sergei Zviagintsev <ser...@s15v.net> --- ipc/kdbus/connection.c | 6

  1   2   3   >