Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp369498rwb; Mon, 28 Nov 2022 22:46:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf5yzt3FSk2XOtdVY0CzJ3QPkzPQQoRT+WflftkmiVgmAys+QSHWPEadfi72dqtr2Q1H0fYu X-Received: by 2002:a17:903:491:b0:185:46a5:1c73 with SMTP id jj17-20020a170903049100b0018546a51c73mr38319545plb.157.1669704398745; Mon, 28 Nov 2022 22:46:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669704398; cv=none; d=google.com; s=arc-20160816; b=YMI+xi7t0J26b9YpwdjxqRuZYqS5y+RbG3I0uE4pQfqfEN3gLQNSbrx8wil41qneE1 nOJ0FaMgO0Fpuo2FY54k2ePvpRByqZyNxx1rY8q+6HOR8hgIfXMyzxmiOcHvlM1vXKkA gcKS0iR1AZ4D5+dL8Jb46V/Mm6ELz9zkE8kQnJZKS7jMH4azfxAlX55as9fyfjwZsFba Pu4WU0eC/J2pPHW/Apsfu1sApJF5ij3bA8k/uiOQF3oDaWiL8ade9Ceqi/GfX3JTwsX7 Y79OxToIV4HfEqb2Fc/cDnkEyi3IkFxDlaVDD2P1F3ibFvAzSIDd2flPZNiO8qPf224C T7ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=SXhLkvl9mT7mKRkV8vx3Vb7GaoPXJW8rE5+MuKgpncU=; b=RWkXX/YYkh+LiiwDyTkhG5VlXDhW9IKJhJbKLcJAb+NVmrU6kep1fJirzwtIHpkq2M n2GlJ201jHTBI/VQdtQrjzAJZTQtPWPVUD3qOb+sivVMrrAo+6uB4M08CpC1ectid3TC Pn85+e3imYLZav073sPBOm8kQwCeGdPTA01GSnjerNc+nh4MDYI1VVZgzRrwaspB3LIV o/VgUlW/emLzPRRfms0L34dTcy9QI3bHiPPQOxgMV5RCRWt7Y8yQrP/jZzx5gnHa/SD4 awBdsxRPawq1rLaJ+MiwOOLMheyeuyac6c3r5qlQF4ZYutcnc+OLSo9QOQWKmfbGCg1C 3zqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=YJZnT+Q+; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b17-20020a170903229100b00186bc66d2cdsi16095702plh.75.2022.11.28.22.46.29; Mon, 28 Nov 2022 22:46:38 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=YJZnT+Q+; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235393AbiK2FUE (ORCPT + 82 others); Tue, 29 Nov 2022 00:20:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbiK2FUC (ORCPT ); Tue, 29 Nov 2022 00:20:02 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B60AC4FFA4 for ; Mon, 28 Nov 2022 21:20:01 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id bj12so31019218ejb.13 for ; Mon, 28 Nov 2022 21:20:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=SXhLkvl9mT7mKRkV8vx3Vb7GaoPXJW8rE5+MuKgpncU=; b=YJZnT+Q+gtiHQLYcIQpWqwSr/afnkJANtHwNnyZcQ/1Qpq/enfTfr3GytaalM0Y14X K2aroP8fGEsp3MKZwRKRuMyh4Jn/wVhOzHvFGeRApxPrdi3ksSwRrkTW0BXbZCLddL/e 96FpeTAuWEelRoMOlbSLUZPK9fcKaagn0AdMV6ErG/ywYGazN01dCktCWW60MvL2T7to j0OmXOfB8YZEPWfU7Nkj8w/WDZhqWhgEUtDN/IKhE36cRKyks20Ql5XxF+IzkEQi8apm DSi4ySmtX4zZ769b187LIeFvBiEBbCKRFXJlA5jAroII2zqFYGZaPMuk76XH14CgN3H1 p/PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=SXhLkvl9mT7mKRkV8vx3Vb7GaoPXJW8rE5+MuKgpncU=; b=OPwtxOPMd9yJAE0ck8kNpgZYoaz3DKJpBzhw91IKAy2hWnUr0G+kUf6riHDcHrQmtV lL80daGtM0TYlsrvunAETH6Vhemp4qKCAJ2wrH/6XSSaSGQKScdsuqOnznk3RaJq9AbU InIFkUjDPUj5eFOEGMXmrYEh1FQIjJnnoFKX/b/f/pRNUokzHnW8wNes9N9kPLaGobA6 mKVI4O9TGOLGdRLLvegBxaZozm4u9xLBPhx571EeBDJIKvnLBORHmNft8slDJW4Y+6LZ MPn93d3Se4t1vQRae9/qf9WYAkhjv/RMul7TlgGvBgQwt5ptkDoNzyTEPQS/ilYZj11u aPjg== X-Gm-Message-State: ANoB5pkbApAQ4Jk6HGXUFZrZ9CUKa1jG8VR8+HqfuE7gmOjj2degGdln T1lh/icLnz86V37HUQUaCFY= X-Received: by 2002:a17:906:3784:b0:7aa:ffd0:b738 with SMTP id n4-20020a170906378400b007aaffd0b738mr47439914ejc.122.1669699200177; Mon, 28 Nov 2022 21:20:00 -0800 (PST) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id f5-20020a056402150500b0045723aa48ccsm5783579edw.93.2022.11.28.21.19.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 21:19:59 -0800 (PST) Date: Tue, 29 Nov 2022 08:19:56 +0300 From: Dan Carpenter To: Conor Dooley Cc: Anup Patel , oe-kbuild@lists.linux.dev, Randy Dunlap , lkp@intel.com, oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org, Palmer Dabbelt Subject: Re: drivers/cpuidle/cpuidle-riscv-sbi.c:506 sbi_genpd_probe() warn: missing error code 'ret' Message-ID: References: <202211220541.Ck9NkitJ-lkp@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 On Thu, Nov 24, 2022 at 01:35:33PM +0000, Conor Dooley wrote: > Hey Anup, > > On Tue, Nov 22, 2022 at 01:43:38PM +0530, Anup Patel wrote: > > On Tue, Nov 22, 2022 at 12:41 PM Dan Carpenter wrote: > > > > > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master > > > head: eb7081409f94a9a8608593d0fb63a1aa3d6f95d8 > > > commit: f81f7861ee2aaa6f652f18e8f622547bdd379724 cpuidle: riscv: support non-SMP config > > > date: 7 months ago > > > config: riscv-randconfig-m031-20221121 > > > compiler: riscv64-linux-gcc (GCC) 12.1.0 > > > > > > If you fix the issue, kindly add following tag where applicable > > > | Reported-by: kernel test robot > > > | Reported-by: Dan Carpenter > > > > > > smatch warnings: > > > drivers/cpuidle/cpuidle-riscv-sbi.c:506 sbi_genpd_probe() warn: missing error code 'ret' > > > > > > vim +/ret +506 drivers/cpuidle/cpuidle-riscv-sbi.c > > > > > > 6abf32f1d9c500 Anup Patel 2022-02-10 481 static int sbi_genpd_probe(struct device_node *np) > > > 6abf32f1d9c500 Anup Patel 2022-02-10 482 { > > > 6abf32f1d9c500 Anup Patel 2022-02-10 483 struct device_node *node; > > > 6abf32f1d9c500 Anup Patel 2022-02-10 484 int ret = 0, pd_count = 0; > > > 6abf32f1d9c500 Anup Patel 2022-02-10 485 > > > 6abf32f1d9c500 Anup Patel 2022-02-10 486 if (!np) > > > 6abf32f1d9c500 Anup Patel 2022-02-10 487 return -ENODEV; > > > 6abf32f1d9c500 Anup Patel 2022-02-10 488 > > > 6abf32f1d9c500 Anup Patel 2022-02-10 489 /* > > > 6abf32f1d9c500 Anup Patel 2022-02-10 490 * Parse child nodes for the "#power-domain-cells" property and > > > 6abf32f1d9c500 Anup Patel 2022-02-10 491 * initialize a genpd/genpd-of-provider pair when it's found. > > > 6abf32f1d9c500 Anup Patel 2022-02-10 492 */ > > > 6abf32f1d9c500 Anup Patel 2022-02-10 493 for_each_child_of_node(np, node) { > > > 6abf32f1d9c500 Anup Patel 2022-02-10 494 if (!of_find_property(node, "#power-domain-cells", NULL)) > > > 6abf32f1d9c500 Anup Patel 2022-02-10 495 continue; > > > 6abf32f1d9c500 Anup Patel 2022-02-10 496 > > > 6abf32f1d9c500 Anup Patel 2022-02-10 497 ret = sbi_pd_init(node); > > > 6abf32f1d9c500 Anup Patel 2022-02-10 498 if (ret) > > > 6abf32f1d9c500 Anup Patel 2022-02-10 499 goto put_node; > > > 6abf32f1d9c500 Anup Patel 2022-02-10 500 > > > 6abf32f1d9c500 Anup Patel 2022-02-10 501 pd_count++; > > > 6abf32f1d9c500 Anup Patel 2022-02-10 502 } > > > 6abf32f1d9c500 Anup Patel 2022-02-10 503 > > > 6abf32f1d9c500 Anup Patel 2022-02-10 504 /* Bail out if not using the hierarchical CPU topology. */ > > > 6abf32f1d9c500 Anup Patel 2022-02-10 505 if (!pd_count) > > > 6abf32f1d9c500 Anup Patel 2022-02-10 @506 goto no_pd; > > > > > > Error code? > > > > Yes, we intentionally "return 0" when there are no > > generic power-domains defined for the CPUs, the > > sbi_cpuidle_probe() continue further and try traditional > > DT cpuidle states. > > Happened upon this when looking for our other cpuidle conversation on > lore earlier, would it not make more sense from a readability PoV to > just return zero here? I am always in favor of direct returns over a do nothing return because of the ambiguity about error codes. Also I just published a new Smatch check where "return ret;" and "return 0;" are equivalent. ret = frob(); if (ret) return ret; if (something else) return ret; I have a different unpublished check for: ret = frob(); if (!ret) return ret; The bug I'm looking for here is that once or twice a year the ! character is unintentional. regards, dan carpenter