Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp216421iob; Thu, 12 May 2022 23:27:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAs7Te3O4X9GmtIEVfyEhB+tarBWeOSWrc09F4Sw3JkpWSeb4W6F72rlPm6sbevL4MpMbl X-Received: by 2002:a17:907:6d1b:b0:6f5:30c9:7c84 with SMTP id sa27-20020a1709076d1b00b006f530c97c84mr2864579ejc.107.1652423225433; Thu, 12 May 2022 23:27:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652423225; cv=none; d=google.com; s=arc-20160816; b=N6wtAKFSYSjqZjPMn6564Sn4HiMPvNLLNFGWH1iqC5v+QDPQ0ITPb0xRai1IcEhIzu P/G+a4rptQSJpZPRKIltcnxy3Q8AG2IWbGrtAl/rrpB0/kh+H2RUHYKtMMhXwfQHmJqQ SiPtzW1jtJMM+41Dkke8qcUpe0u8qYWHk13rEww0+Yw/GeMnClzjLHrECl3mGL77w29l lQqTdHXLovrZIyULTbfOmIJlNrXEiyDq/tw3IRysOL5kmubUekUGJYoWltWTB/LPTgdY Oy+NiEWM5DJZcTy7R1DQyWAXC/qPcbYm5yyRdIC/hn0GqXFMUuI3nlqsRKBa0yLNOAAx RuDA== 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=yLU3O+HFxYb7LnUMPkuVf+EOz6V+ZvdZ3r9bU5JUhEYh/R5QYUwxdxzVSoBWc4CQzn lLOlv7BpfutxXT5G9x6fYFG1qu1YMa5pFNrTIj8pfgdAoWINGUt3wbP21B9t8Wr4kyoj CXTiQ29sH0iKdhOsG4tPRdkaAOm9oJHClzRU/gpsyLvYxYY6QQaz4xDnZsWvLLX91mYp lKGyz9iMwBNQsXZxqS+Zxgw6DAn+5ZRBxjE29K6jTu6pcEzCXmkTGsW2FIP4dDEJjGVd Tt2kDmtEj1iJreCG0KWKz9YOoLR0ZF4exeqzrxVN+Z/pQYTl+NroR9YE4810W4h4KEm+ Qx2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=mail header.b=jpga97EH; 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 j22-20020a056402239600b0041df73164e1si1139565eda.508.2022.05.12.23.26.36; Thu, 12 May 2022 23:27:05 -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=jpga97EH; 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 S1349173AbiEKXTA (ORCPT + 99 others); Wed, 11 May 2022 19:19:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349089AbiEKXSb (ORCPT ); Wed, 11 May 2022 19:18:31 -0400 Received: from mail.baikalelectronics.ru (mail.baikalelectronics.com [87.245.175.226]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B109A185C81; Wed, 11 May 2022 16:18:27 -0700 (PDT) Received: from mail.baikalelectronics.ru (unknown [192.168.51.25]) by mail.baikalelectronics.ru (Postfix) with ESMTP id 7B117BB7; Thu, 12 May 2022 02:19:06 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.baikalelectronics.ru 7B117BB7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baikalelectronics.ru; s=mail; t=1652311146; bh=zHaHwKz/yCVMvZJtPXeZzX7KArDCiwAc5Mq+USo7pmc=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=jpga97EH1TqTILGk4JciWYBj5bLH2hcD4zJxDepe108OwpDIfUknqkxlc5DwX0nSK 3dhVQcvMr8QsyZhdUSiy30qmFtNRDduwFpE+lVP506rpVsIkKeCPG4BHsRmJbo2v0r ocKek09uRwAMQO189DPI5bBXMPFKwF9BcRYlHGzM= Received: from localhost (192.168.53.207) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 12 May 2022 02:18:18 +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 v3 05/23] ata: libahci_platform: Explicitly set rc on devres_alloc failure Date: Thu, 12 May 2022 02:17:52 +0300 Message-ID: <20220511231810.4928-6-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20220511231810.4928-1-Sergey.Semin@baikalelectronics.ru> References: <20220511231810.4928-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,URIBL_BLOCKED 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