From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932603AbbJHLe5 (ORCPT ); Thu, 8 Oct 2015 07:34:57 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:47587 "EHLO out5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932495AbbJHLex (ORCPT ); Thu, 8 Oct 2015 07:34:53 -0400 X-Sasl-enc: jB3XkUyOropReZV9VcELS/g1FrHC4PI0v5lRBaIHT8iD 1444304092 From: Sergei Zviagintsev To: Greg Kroah-Hartman , Daniel Mack , David Herrmann , Djalal Harouni Cc: linux-kernel@vger.kernel.org, Sergei Zviagintsev Subject: [PATCH 44/44] kdbus: Cleanup kdbus_gaps_install() Date: Thu, 8 Oct 2015 14:32:13 +0300 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org - 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/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