From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC6FCC4743C for ; Wed, 23 Jun 2021 12:56:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9BF8A610F7 for ; Wed, 23 Jun 2021 12:56:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230286AbhFWM67 (ORCPT ); Wed, 23 Jun 2021 08:58:59 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:38544 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230019AbhFWM66 (ORCPT ); Wed, 23 Jun 2021 08:58:58 -0400 Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1E1C99AA; Wed, 23 Jun 2021 14:56:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1624453000; bh=MOq5yt8/oq2a0B9Z3C+/bOxpANloWJvF0E5s3omCJS4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=leq6EKfUOeunGG32fL0YLu5TTPeD5p+UygbcWb6aTKIFxPgkZF+PjDKNTx7q5v7WO 5HT++Eoc7VotPXvROA6weF/arvUU15PXhjtJ5xarYiepgzMNFDjFcF5gwvjFe1ZJRQ pf25W9RHmD1OD/6v/7A0H1jK/ZPzRu00iLbNlgRk= Date: Wed, 23 Jun 2021 15:56:10 +0300 From: Laurent Pinchart To: Dan Carpenter Cc: Tomi Valkeinen , Kieran Bingham , Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] media: v4l2-subdev: fix some NULL vs IS_ERR() checks Message-ID: References: <20210622155858.GN1861@kadam> <20210623090325.GA2116@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210623090325.GA2116@kadam> Precedence: bulk List-ID: X-Mailing-List: kernel-janitors@vger.kernel.org On Wed, Jun 23, 2021 at 12:03:26PM +0300, Dan Carpenter wrote: > On Wed, Jun 23, 2021 at 05:34:16AM +0300, Laurent Pinchart wrote: > > > > Do you think an annotation could still help, by making it explicit in > > headers whether a function returns NULL or an error pointer, thus > > helping developers get it right in the first place ? > > Not really. It wouldn't help with Smatch. I really think error pointer > bugs are handled pretty well currently. Sometimes I have seen syzbot > find them before the static checkers but I don't see them affecting > users and production kernels. I meant to ask if it would be useful for developers, not for smatch. When I use a function and have to figure out whether to use IS_ERR() or != NULL, I first look at the header, and most of the time I then need to find the corresponding implementation, wherever it may be. If we had an annotation, the second step could be skipped. Of course the annotation would need to match the implementation, and that's an area where smatch could help. > There are few other things that Smatch looks for like passing positives, > valid pointers or NULLs to PTR_ERR(). I do wish that when functions > return a mix of negative error codes, 0 and 1 that they had comment > explaining what the 1 means. -- Regards, Laurent Pinchart