Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1092811iob; Wed, 4 May 2022 14:33:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwz++O1YZOjOrkzpJf6wCEyZ9mIE9hRSoi7ZDPIHUEt0Ebsn52/CMafcpXerRV3iG4bzoAB X-Received: by 2002:a17:903:1cd:b0:15e:8c4a:c543 with SMTP id e13-20020a17090301cd00b0015e8c4ac543mr23455782plh.126.1651700004367; Wed, 04 May 2022 14:33:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651700004; cv=none; d=google.com; s=arc-20160816; b=EFqxlpKdN+i7mschTOztRi1BobtK94Q1kf6VKM//ZTgtVwq0lUF/axgo6K1renCGDn 8y1wSr8FRfk3X7NOupgaKhlx1M0wU4q8hdkudNZByd6N1eG86IFmYFBcl1FvJGeXaeuy KD/bEaZNmi/VZpa5WGE05/PFzJr0fnJsbF2nctembX8zMHz3t6ejIh8i9ZPn/kSn6gMG 9PtAmy0jb5UAuWJLDQDPqiUrJiRYwIX9BPrRdD8fSH26lgjagXtXcTBY2hiQHwjDmDOl CRuAkfY/gTq8pIOqi97LDmKyTyWXEmTKC+7GUfJNQa4v2EY7OGZTrB0KSSSiao0MFQl3 8U3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=zHaHwKz/yCVMvZJtPXeZzX7KArDCiwAc5Mq+USo7pmc=; b=Ia8fwTZVFVoJkdkQxUdgpHExMiSpRq0gtXyosvkm019vgiNgdZpaPR6bpp5LrcEqEW KSQ+Krng2bE64axxL3uhipx/CGjLBDpQY+QJN4jbN6qPxmhWgmU+5lqCUGgmh20/2v89 t5k/AGL7Cg2lhmS0yDO4DLlXTuWPDKLLFa0uV1+qygDLZ6boKeETwHsjINtXiB0C3RZl nPjjU9tIfFOoW+Rb1kQYgYMpGvVrossWesWxETNMAewH38/f2Xpy+vXnH0xq86Yi7vR3 e8PnO2GQ6mPNTPZky+kfHzzlO60x9sABbMVTskrt2iCuLzmGOuyYRQCVegABFvGofxOY qILQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=mail header.b=e4NJ0gWE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q203-20020a632ad4000000b003abada69f69si20837409pgq.282.2022.05.04.14.33.09; Wed, 04 May 2022 14:33:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=mail header.b=e4NJ0gWE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242250AbiECUOL (ORCPT + 99 others); Tue, 3 May 2022 16:14:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236380AbiECUNm (ORCPT ); Tue, 3 May 2022 16:13:42 -0400 Received: from mail.baikalelectronics.ru (mail.baikalelectronics.com [87.245.175.226]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6EE5D27143; Tue, 3 May 2022 13:10:07 -0700 (PDT) Received: from mail.baikalelectronics.ru (unknown [192.168.51.25]) by mail.baikalelectronics.ru (Postfix) with ESMTP id 9A53B16DA; Tue, 3 May 2022 23:10:37 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.baikalelectronics.ru 9A53B16DA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baikalelectronics.ru; s=mail; t=1651608637; bh=zHaHwKz/yCVMvZJtPXeZzX7KArDCiwAc5Mq+USo7pmc=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=e4NJ0gWE0usDCwyFRiDo57cUnOpQT5zW9B6KhDrD/VXkUAJyCV9vKUs+qnMqq2Qch 5Nnj4LSt9kJMFc/ZBv7fOniNyWfK9Tu20JL9YGcMhU+FbGf7BU05OgnGn7ZaAVc0j0 nCxeypGD+OBUzHZcS7NWM/Ke7cASfaykBx3zud60= Received: from localhost (192.168.53.207) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 3 May 2022 23:10:03 +0300 From: Serge Semin To: Damien Le Moal , Hans de Goede , Jens Axboe CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Rob Herring , , , Subject: [PATCH v2 05/23] ata: libahci_platform: Explicitly set rc on devres_alloc failure Date: Tue, 3 May 2022 23:09:20 +0300 Message-ID: <20220503200938.18027-6-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20220503200938.18027-1-Sergey.Semin@baikalelectronics.ru> References: <20220503200938.18027-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It's better for readability and maintainability to explicitly assign an error number to the variable used then as a return value from the method on the cleanup-on-error path. So adding new code in the method we won't have to think whether the overridden rc-variable is set afterward in case of an error. Saving one line of code doesn't worth it especially seeing the rest of the ahci_platform_get_resources() function errors handling blocks do explicitly write errno to rc. Signed-off-by: Serge Semin --- Changelog v2: - Drop rc variable initialization (@Damien) --- drivers/ata/libahci_platform.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c index 32495ae96567..f7f9bfcfc164 100644 --- a/drivers/ata/libahci_platform.c +++ b/drivers/ata/libahci_platform.c @@ -389,7 +389,7 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev, struct ahci_host_priv *hpriv; struct clk *clk; struct device_node *child; - int i, enabled_ports = 0, rc = -ENOMEM, child_nodes; + int i, enabled_ports = 0, rc, child_nodes; u32 mask_port_map = 0; if (!devres_open_group(dev, NULL, GFP_KERNEL)) @@ -397,8 +397,10 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev, hpriv = devres_alloc(ahci_platform_put_resources, sizeof(*hpriv), GFP_KERNEL); - if (!hpriv) + if (!hpriv) { + rc = -ENOMEM; goto err_out; + } devres_add(dev, hpriv); -- 2.35.1