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


Groups > linux.kernel > #1242223

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

Path csiph.com!xmission!news.glorb.com!bofh.it!news.nic.it!robomod
From Sergei Zviagintsev <sergei@s15v.net>
Newsgroups linux.kernel
Subject [PATCH 44/44] kdbus: Cleanup kdbus_gaps_install()
Date Thu, 08 Oct 2015 13:40:01 +0200
Message-ID <qhhId-2d4-5@gated-at.bofh.it> (permalink)
References <qhhId-2d4-3@gated-at.bofh.it>
X-Original-To Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Daniel Mack <daniel@zonque.org>, David Herrmann <dh.herrmann@googlemail.com>, Djalal Harouni <tixxdz@opendz.org>
Dkim-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d=s15v.net; h=cc :date:from:in-reply-to:in-reply-to:message-id:references :references:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=GJFXs 4W8obuZl2lP4N9CT5tx+zo=; b=L6Q/yrqxEbdhjfWKS9T0ujf+ODjfIEdxK9qgK NigL65nv34PHaf2z1ENNHYMkuRgmMlm5Vv2AZyvnsCQVPgQTDaNtZRFPlU1++yGT jg3d0pHKCrBczrJBrMsgIPkSiPL79gAT2p3wdNbwRMQBU1Xol0rs1rSjgVhAcOIY dGUK2o=
Dkim-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:in-reply-to :message-id:references:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=GJFXs4W8obuZl2lP4N9CT5tx+zo=; b=KneQa JPS5HZCuovq9bxyGMQAsx8l9CtwIMa3hPu5cIx9JytVuAN2KH6ZkbjyJf+ZNfqMH efQsCKgPoRPns/B3CkVBcX3ylmYM8K2D5FpSBX8K96+TkZmZtahHnGIp0ETwhnq9 V+4ARTHjGMK0fd6H2IfQamxShYrQXpYO99ekZg=
X-Sasl-Enc jB3XkUyOropReZV9VcELS/g1FrHC4PI0v5lRBaIHT8iD 1444304092
X-Mailer git-send-email 1.8.3.1
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 78
Organization linux.* mail to news gateway
X-Original-Cc linux-kernel@vger.kernel.org, Sergei Zviagintsev <sergei@s15v.net>
X-Original-Date Thu, 8 Oct 2015 14:32:13 +0300
X-Original-Message-ID <a034a920874636f850d1bf64c7418ba7628bf859.1444302968.git.sergei@s15v.net>
X-Original-References <cover.1444302968.git.sergei@s15v.net>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1242223

Show key headers only | View raw


 - 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/

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web