From patchwork Mon Jan 7 14:21:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suwan Kim X-Patchwork-Id: 10750627 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 923D591E for ; Mon, 7 Jan 2019 14:21:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8305328A49 for ; Mon, 7 Jan 2019 14:21:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 776C128A61; Mon, 7 Jan 2019 14:21:19 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 2B2BA28A49 for ; Mon, 7 Jan 2019 14:21:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727633AbfAGOVS (ORCPT ); Mon, 7 Jan 2019 09:21:18 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:39909 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726827AbfAGOVS (ORCPT ); Mon, 7 Jan 2019 09:21:18 -0500 Received: by mail-pg1-f195.google.com with SMTP id w6so204274pgl.6 for ; Mon, 07 Jan 2019 06:21:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=abqzFMwLJW1Pg7CUEryN1TeWnJYMgFmocDjUyxK9aOc=; b=phdoOjaFvbIFdFQyByZNe2Zy3offeODXR971TwjhLltilzzuxoBeBMNgEY91hLeytY cyVpPs4hYKDRDLqcnI+1MTv4TNAzsOuCi1u8DvALE+d9JWkyjT6tKX24dLF+Jvwk6vWt NA9fIQw4praX/H8HJtUe3ljV8Lb3wy4tkXK/Jbq6AJ/CYyWX/M7Ha3FxHWQxWPc+RXd5 8a27zNQCJ+m+C2ujYpq4mAIhRE4eG/sqmYPGFubBxSdu1PpR8dXA6GB0vhU7eaPY7DrZ WNSOi/W5bMAJ+abpCyD8NQ4+5nlGggsBVBjAg517A99epBNwJ1xU7G1ve7fpE54HZMV0 O1Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=abqzFMwLJW1Pg7CUEryN1TeWnJYMgFmocDjUyxK9aOc=; b=CkCqwhkbhgjlagnBumQ6MMcJfeaBy5Z6R3c84T+Zt5AXPMLKx/Xm31t2PsSGKOJIjR x7dtVPygkx1ufRxyzTy/TOZ3DhqVfNYQdMeYYkpeV8rF5Xncg9nDdorxWnoGQAQgvamF FuYfkWFPH5s+XiT0tSuYhtPKSVvqlAADO9zFAAbUKm0undaig5LP9sIHuv7dJBEWZdKr LRSU2nDzCWV/XwPj8EP6S0ctL2c2qaftwE7EU68GwWSbKVRIci9j6EwU0zaNySTWEBJg fE0NMoyLmXgJR1Ci6i34w79usaayflPSGcmSMxRH4IDipZPkQiwcKejEvkhsK1oRstVm dKsw== X-Gm-Message-State: AA+aEWbbGCiQ83soDV/8T5UuHx0suH76acugJ1LjHgu37G/T3SJt26Yj aE1LQOipvqvbTZr9l+VoUlT4n4d9 X-Google-Smtp-Source: AFSGD/UwKjLNBOwJ6HVs2pPBY739DfibaMYCKLxE9X7RJZkc6lwcjmszYdaA1M2qx+GW4VZxUZVvJQ== X-Received: by 2002:a62:5c41:: with SMTP id q62mr64511076pfb.171.1546870877800; Mon, 07 Jan 2019 06:21:17 -0800 (PST) Received: from localhost.localdomain ([125.142.23.13]) by smtp.googlemail.com with ESMTPSA id o4sm102786574pgs.12.2019.01.07.06.21.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Jan 2019 06:21:17 -0800 (PST) From: Suwan Kim To: gregkh@linuxfoundation.org, stern@rowland.harvard.edu Cc: linux-usb@vger.kernel.org, mathias.nyman@linux.intel.com Subject: [PATCH] usb: core: Simplify return value of usb_get_configuration() Date: Mon, 7 Jan 2019 23:21:11 +0900 Message-Id: <20190107142111.10901-1-suwan.kim027@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It is better to initialize the return value "result" to -ENOMEM than to 0. And because "result" takes the return value of usb_parse_configuration() which returns 0 for success, setting "result" to 0 at before and after of the for loop is unnecessary. Signed-off-by: Suwan Kim Acked-by: Alan Stern --- drivers/usb/core/config.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index 7b5cb28ffb35..4a0945c04b4c 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c @@ -800,13 +800,12 @@ int usb_get_configuration(struct usb_device *dev) { struct device *ddev = &dev->dev; int ncfg = dev->descriptor.bNumConfigurations; - int result = 0; + int result = -ENOMEM; unsigned int cfgno, length; unsigned char *bigbuffer; struct usb_config_descriptor *desc; cfgno = 0; - result = -ENOMEM; if (ncfg > USB_MAXCONFIG) { dev_warn(ddev, "too many configurations: %d, " "using maximum allowed: %d\n", ncfg, USB_MAXCONFIG); @@ -832,7 +831,6 @@ int usb_get_configuration(struct usb_device *dev) if (!desc) goto err2; - result = 0; for (; cfgno < ncfg; cfgno++) { /* We grab just the first descriptor so we know how long * the whole configuration is */ @@ -889,7 +887,6 @@ int usb_get_configuration(struct usb_device *dev) goto err; } } - result = 0; err: kfree(desc);