Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3752565rdh; Fri, 29 Sep 2023 00:59:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGKtqYlyFC3XfisWfJ2ZMOqVIVcPA7NF8mlwzETaWmeMfcg+9CLPp5vHlrCeD6S4/CTK3BV X-Received: by 2002:a17:902:704c:b0:1c2:eac:b99 with SMTP id h12-20020a170902704c00b001c20eac0b99mr3164929plt.40.1695974351069; Fri, 29 Sep 2023 00:59:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695974351; cv=none; d=google.com; s=arc-20160816; b=t7qS7E1sS5gDK7m2HjmCqqQdapj9zlVU+n4cm+xfIqHQhU67lV3Kv+/C8LDk4UWN1O TZ41cyNfWhlY/N+rCWvJAJNvFfZEnYvPM74J+5RGD8ypc0M2HveJqjanQNrNEhJNINDM GR4Nq4Z2vNNQxJYXtg7fET/17c2hgllJB7QaYV81jL4S9rzSl9yu3p/bjhdWOv7KFN05 3ao+27GCdqKbvOmw7RRKtevlFI42pgWJXEUyk/saPmpB+wkWRfwVgK27awK9MEkg1ZFp eabuEKeg8d3d9Ta8t06lc86E7ephs5ZNlZvZvAiAtJV2TosJg/BbHBmCFn8QfvzZD7/L 1/KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=jCXpnkD65gBL82o/dmwBwRzPh1cMJECkbSyB2ZedaOU=; fh=ugTZ5J8xDVzdTLeT3b9ERwsLW9d9uvTjM4mvNZgPBT8=; b=OCDAlSe83t15VPaaRTfgMhADf/60CsHGhS1C4aVOWTcXU0XzeWmYAIGf5K5llrAEB8 yffuViW3xbA9LJgi1oXb1bWKLJPuDBtuRkeNb3i7AmcBiJ6ivrgUM763SqWYCPBPFVrA D8SogZlmFm/GWHV38PAMpPP9vN5T/pdAPSwiE9Yrnumf8ZSDh1ZgkkbxdlhfiFUP339Z N8S0o8qzhIaPrkto91i4LF70aOuADdlftF5rw7I+k2Oa5/pdosOVj2NvQ3EDHq+vKI1M jMnOgC/I2SGKTAG3cMzYMGVzqsoP/d4Z6dXXQVCrQY30QnGBQkNvfZ/VC7ywmAlScoBU P9zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=jABpx6pj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id n3-20020a170903404300b001b8921fbd87si18510630pla.490.2023.09.29.00.59.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 00:59:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=jABpx6pj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id F279180A44EF; Fri, 29 Sep 2023 00:39:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232655AbjI2Hjd (ORCPT + 99 others); Fri, 29 Sep 2023 03:39:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231774AbjI2Hjb (ORCPT ); Fri, 29 Sep 2023 03:39:31 -0400 Received: from mailo.com (msg-4.mailo.com [213.182.54.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84046180 for ; Fri, 29 Sep 2023 00:39:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1695973158; bh=jCXpnkD65gBL82o/dmwBwRzPh1cMJECkbSyB2ZedaOU=; h=X-EA-Auth:Message-ID:Subject:From:To:Cc:Date:In-Reply-To: References:Content-Type:Content-Transfer-Encoding:MIME-Version; b=jABpx6pjJbOoRCTDeUAFVzC32vkF7Vx+lrp3RpxHCCCs27wAfLOHe7CsRqNuCQsKU uigTJYElqBhY6h+BV/nPzkwRzA5PPkAcpejkvMA6T+SsAY+BBMW/9hPhiD7LCCsYPw b+as3MUdyGCG6iSJExvT9kThbGvGssJlG0Jem1Cc= Received: by b221-5.in.mailobj.net [192.168.90.25] with ESMTP via ip-20.mailobj.net [213.182.54.20] Fri, 29 Sep 2023 09:39:17 +0200 (CEST) X-EA-Auth: UlFkxK2sLNWRc9kMuK0MPizk6AYjvh9OiodH7TWZlBB6qMjIFdaikrp+ZyO5wfQccBmhJTUB1GHw/xXmuVpNPcUu6AVPBw/f Message-ID: <0c1ed836c5a306331e1b2a97217c3c9f7e1fb701.camel@mailo.com> Subject: Re: [PATCH] gfs2: fix 'passing zero to ERR_PTR()' warning From: drv To: Dan Carpenter Cc: Bob Peterson , Andreas Gruenbacher , gfs2@lists.linux.dev, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Dan Carpenter Date: Fri, 29 Sep 2023 13:09:11 +0530 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4-2 MIME-Version: 1.0 X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,URIBL_BLACK autolearn=no 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 29 Sep 2023 00:39:40 -0700 (PDT) On Fri, 2023-09-29 at 10:06 +0300, Dan Carpenter wrote: > On Thu, Sep 28, 2023 at 11:37:42PM +0530, Deepak R Varma wrote: > > Resolve the following Smatch static checker warning: > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0fs/gfs2/acl.c:54 __gfs2= _get_acl() warn: passing zero to > > 'ERR_PTR' > >=20 > > by returning NULL when an extended attribute length is zero, > > instead of > > passing on zero to the ERR_PTR(). > >=20 > > Signed-off-by: Deepak R Varma > > --- >=20 > Passing zero to ERR_PTR() is not a bug. >=20 > You're patch doesn't change how the code works at all, right?=C2=A0 So > it's > like a cleanup patch.=C2=A0 But the code was nicer in the original. >=20 > This is just a false positive.=C2=A0 Ignore static checker false > positives. > Fix the checker instead.=C2=A0 Although in this case, I can't think of an > easy way fix the checker.=C2=A0 Perhaps don't print a warning if the > callers > check for NULL? >=20 > The passing zero to ERR_PTR() warning is actually a pretty good > heuristic.=C2=A0 90% of the time in new code this is a real bug.=C2=A0 Bu= t in > old > code then probably it's 0% real bugs because we've been reviewing > these > warnings for over a decade. >=20 > I have a blog which might be useful. > https://staticthinking.wordpress.com/2022/08/01/mixing-error-pointers-and= -null/ >=20 > When I'm reviewing this patch I think: > 1) Does gfs2_xattr_acl_get() return zero?=C2=A0 And it does. > 2) Does that look intentional.=C2=A0 It's harder to tell because there > aren't > =C2=A0=C2=A0 comments and it looks like it might be a missing error code.= =C2=A0 But > =C2=A0=C2=A0 when you read it closely then actually it does look intentio= nal. > =C2=A0=C2=A0 In terms of Smatch, I consider it "intentional" if there is = an > =C2=A0=C2=A0 "error =3D 0;" within 5 lines for the goto.=C2=A0 (Other lan= guages like > Rust > =C2=A0=C2=A0 are better than C because they force everyone to follow the = rules. > =C2=A0=C2=A0 #trolling). > 3) Do the callers of __gfs2_get_acl() check for NULL and they do. >=20 > So this code is fine. >=20 > I hope this helps you in your review process.=C2=A0 1)=C2=A0 Ignore old > warnings. > 2)=C2=A0 Ignore false positives.=C2=A0 3)=C2=A0 If you think it is a bug,= then try > to > figure out how it will cause a crash.=C2=A0 Look at the caller etc. >=20 Hi Dan, Thank you for the review, feedback and guidance. This is really helpful. regards, deepak. > regards, > dan carpenter >=20