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


Groups > linux.kernel > #1242223 > unrolled thread

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

Started bySergei Zviagintsev <sergei@s15v.net>
First post2015-10-08 13:40 +0200
Last post2015-10-08 13:40 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 44/44] kdbus: Cleanup kdbus_gaps_install() Sergei Zviagintsev <sergei@s15v.net> - 2015-10-08 13:40 +0200

#1242223 — [PATCH 44/44] kdbus: Cleanup kdbus_gaps_install()

FromSergei Zviagintsev <sergei@s15v.net>
Date2015-10-08 13:40 +0200
Subject[PATCH 44/44] kdbus: Cleanup kdbus_gaps_install()
Message-ID<qhhId-2d4-5@gated-at.bofh.it>
 - 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@s15v.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@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web