[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <a034a920874636f850d1bf64c7418ba7628bf859.1444302968.git.sergei@s15v.net>
Date: Thu, 8 Oct 2015 14:32:13 +0300
From: Sergei Zviagintsev <sergei@...v.net>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Daniel Mack <daniel@...que.org>,
David Herrmann <dh.herrmann@...glemail.com>,
Djalal Harouni <tixxdz@...ndz.org>
Cc: linux-kernel@...r.kernel.org, Sergei Zviagintsev <sergei@...v.net>
Subject: [PATCH 44/44] kdbus: Cleanup kdbus_gaps_install()
- 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 <sergei@...v.net>
---
ipc/kdbus/message.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/ipc/kdbus/message.c b/ipc/kdbus/message.c
index 75e6213e7ed5..ca20852f4ecf 100644
--- a/ipc/kdbus/message.c
+++ b/ipc/kdbus/message.c
@@ -124,18 +124,18 @@ int kdbus_gaps_install(struct kdbus_gaps *gaps, struct kdbus_pool_slice *slice,
bool incomplete_fds = false;
struct kvec kvec;
size_t i, n_fds, n_memfds;
- int ret, *fds;
+ int *fds, ret = 0;
if (!gaps) {
/* nothing to do */
- *out_incomplete = incomplete_fds;
+ *out_incomplete = false;
return 0;
}
n_fds = gaps->n_fds + gaps->n_memfds;
if (n_fds < 1) {
/* nothing to do */
- *out_incomplete = incomplete_fds;
+ *out_incomplete = false;
return 0;
}
@@ -148,9 +148,7 @@ int kdbus_gaps_install(struct kdbus_gaps *gaps, struct kdbus_pool_slice *slice,
n_fds = 0; /* n_fds now tracks the number of allocated fds */
if (gaps->n_fds > 0) {
for (i = 0; i < gaps->n_fds; ++i) {
- int fd;
-
- fd = get_unused_fd_flags(O_CLOEXEC);
+ int fd = get_unused_fd_flags(O_CLOEXEC);
if (fd < 0) {
incomplete_fds = true;
break;
@@ -183,9 +181,7 @@ int kdbus_gaps_install(struct kdbus_gaps *gaps, struct kdbus_pool_slice *slice,
n_memfds = 0;
for (i = 0; i < gaps->n_memfds && !incomplete_fds; ++i) {
- int memfd;
-
- memfd = get_unused_fd_flags(O_CLOEXEC);
+ int memfd = get_unused_fd_flags(O_CLOEXEC);
if (memfd < 0) {
incomplete_fds = true;
/* memfds are initialized to -1, skip copying it */
@@ -220,8 +216,6 @@ int kdbus_gaps_install(struct kdbus_gaps *gaps, struct kdbus_pool_slice *slice,
fd_install(fds[gaps->n_fds + i],
get_file(gaps->memfd_files[i]));
- ret = 0;
-
exit:
if (ret < 0) {
for (i = 0; i < n_fds; ++i)
--
1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists