From patchwork Tue Feb 7 19:58:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9561047 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0E25B60547 for ; Tue, 7 Feb 2017 20:05:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 012C428477 for ; Tue, 7 Feb 2017 20:05:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA3CB28496; Tue, 7 Feb 2017 20:05:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17BF628492 for ; Tue, 7 Feb 2017 20:05:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755096AbdBGUFN (ORCPT ); Tue, 7 Feb 2017 15:05:13 -0500 Received: from mout.web.de ([212.227.17.11]:63666 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753909AbdBGUFM (ORCPT ); Tue, 7 Feb 2017 15:05:12 -0500 Received: from [192.168.1.2] ([78.49.4.3]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MbhRh-1cuEKM3yQX-00J54d; Tue, 07 Feb 2017 20:58:28 +0100 Subject: [PATCH 15/18] HID-debug: Return an error code only as a constant in hid_debug_events_open() To: linux-input@vger.kernel.org, Benjamin Tissoires , =?UTF-8?Q?Bruno_Pr=c3=a9mont?= , Jiri Kosina References: Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: <9935147f-3387-a583-b878-cbd90f1bfac0@users.sourceforge.net> Date: Tue, 7 Feb 2017 20:58:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: X-Provags-ID: V03:K0:WPkCOW6h0+MTpkt5z6w9o1DXvURR3BKfxd1ksEQIoiIhujBwuPk vpPqc8nxwfIsHDgumOM3lgAKGSsbYzpt5UZPsyEo1KgRbFp9gQSufzsuOMt5uaNQ/f2FZBm nMNJQe5o1rYYLQEpeYdPxTxE2ZTTE1veIOU2Ov2ayU1pMgNjGqhovptwcl8UySjD2v0N7Ye YQ3OhKpa76jBAvK4YGswg== X-UI-Out-Filterresults: notjunk:1; V01:K0:cqpiHCLKBGM=:y3JSZENn2oNRosmm6c+7zu yU0Ee5vWFaOGJ2+8ikm1wEy9lUB4mZdAiEEj9fMxNdcmEME7dUEYyWnOKBeEBdNNIR25jw9aj wnKVi2cVEZq3NOVBT9MYAxCjkofny+ArUJzxxkI1Z6Shk9J5O22v7BsjOYF4A1yMijkmWnujT j0BduPS6eJiVh2y483b4PjiyPXF5GAZZLomdPItnL6aiypk2f6QdNXqFXP2VcS8NYo4osTCUP U/uQFhEeooDShNrTFSeHtAnAmdXIGkW1CkmAW74bW9CmgZSk1zplXVdbHA+5kWgxVr3I5HK4E Oxvr9rt1Uc1/V7i+Rjj2SdaA/1yy9MzQg61xR8i+g+V3PId4UOeThVX+Pg1izwhzmKgW1d8H4 aEPtfdo9LWt1jsQofM3vBNrh3fkgKPqTzV7IZ2JdVN67+HaEKV8bwLoys0qsEdeLhdQt782q7 gZ8LX5e3Q/MJsJP4u1dEGwIPRWfL0RQXZdff4kAZUCTVKfSQNmPNEjddjElpzcPWMaphu2UbZ 38pX8ogQF7StCAd+93ejm4QDX2/DUmqKsqizPSX5BJdDmdsI9GLPnEQVkSQYkzHYKtttLyhRi x3g1pxzYpt83GbdXI+3ci4VM+D75P5GBOQj/MKg/y2HJSDddtjcAdcOlh0mV66SJ+NKnmaAZ4 AggZhMr4y6DHq9jYeU6CHxQNY3urx4vPemsq8Bao7E+oMWsmM770DFhl9fzKC190mpNbzNJB1 c1GA+E68lHHxx5KReRJeVCVtNS1YsSkU9BJ9WLGmHvoqZ2bjMjBbpbqJLw74c84LKuQxy0q/F Xx/LZej Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Tue, 7 Feb 2017 20:08:04 +0100 * Return an error code without storing it in an intermediate variable. * Delete the local variable "err" and the jump label "out" which became unnecessary with this refactoring. Signed-off-by: Markus Elfring --- drivers/hid/hid-debug.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c index 444c63f0e4be..60984e2906a7 100644 --- a/drivers/hid/hid-debug.c +++ b/drivers/hid/hid-debug.c @@ -1079,22 +1079,18 @@ static int hid_debug_rdesc_open(struct inode *inode, struct file *file) static int hid_debug_events_open(struct inode *inode, struct file *file) { - int err = 0; struct hid_debug_list *list; unsigned long flags; list = kzalloc(sizeof(*list), GFP_KERNEL); - if (!list) { - err = -ENOMEM; - goto out; - } + if (!list) + return -ENOMEM; list->hid_debug_buf = kzalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_KERNEL); if (!list->hid_debug_buf) { - err = -ENOMEM; kfree(list); - goto out; + return -ENOMEM; } list->hdev = (struct hid_device *) inode->i_private; file->private_data = list; @@ -1103,9 +1099,7 @@ static int hid_debug_events_open(struct inode *inode, struct file *file) spin_lock_irqsave(&list->hdev->debug_list_lock, flags); list_add_tail(&list->node, &list->hdev->debug_list); spin_unlock_irqrestore(&list->hdev->debug_list_lock, flags); - -out: - return err; + return 0; } static ssize_t hid_debug_events_read(struct file *file, char __user *buffer,