From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.135]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA4B872 for ; Mon, 26 Jul 2021 08:52:18 +0000 (UTC) Received: from mail-wr1-f42.google.com ([209.85.221.42]) by mrelayeu.kundenserver.de (mreue011 [213.165.67.97]) with ESMTPSA (Nemesis) id 1N1g3U-1l6Bce41Ki-011yT0 for ; Mon, 26 Jul 2021 10:52:16 +0200 Received: by mail-wr1-f42.google.com with SMTP id l4so10118844wrs.4 for ; Mon, 26 Jul 2021 01:52:16 -0700 (PDT) X-Gm-Message-State: AOAM533eNKn4WY3oVXVDM8Rb8qjuqa9jQAKSocQj1GCbZmLleHJ5H7M4 uac5tywEQK0Z+a7KMbqOpEilTNSAlknr5ESn5f0= X-Google-Smtp-Source: ABdhPJwsKxxjFjKW/PtMxFUw2n+9whg+Bw1cd3PP0rTqYWGN8WqTALjJ7dJFHbbWhYvNaQ7Oo63gNR6laHxr1HR0SVQ= X-Received: by 2002:adf:e107:: with SMTP id t7mr17994330wrz.165.1627289536545; Mon, 26 Jul 2021 01:52:16 -0700 (PDT) Precedence: bulk X-Mailing-List: ksummit@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20210723191023.GG25548@kadam> <162717033769.3676.6942299974175827854@noble.neil.brown.name> In-Reply-To: From: Arnd Bergmann Date: Mon, 26 Jul 2021 10:52:00 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Potential static analysis ideas To: Geert Uytterhoeven Cc: Arnd Bergmann , NeilBrown , Laurent Pinchart , Dan Carpenter , ksummit@lists.linux.dev, Julia Lawall Content-Type: text/plain; charset="UTF-8" X-Provags-ID: V03:K1:iFmPUtR1vRxRxb9iBSabvHAwHXyu7fIycY7t+/qVarDZa1NgqRk 16l3Fi6etBKPb+Wo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TFvwKfwjYCsToyJWhR+bhZQJO4aaE6h5U04 hfWDQayyHYAIv8BmkUGMP/O1+L+JKyehwH6j5I9lTvmhJo+bmDOurY/NQ+SjWupIBmKdCBeNd HqXKk6w7m2Nrn1JxLiHl5JEQExtnjZoMEANYbnrnfbuYXXcxL8KRW On Mon, Jul 26, 2021 at 10:39 AM Geert Uytterhoeven wrote: > On Mon, Jul 26, 2021 at 10:21 AM Arnd Bergmann wrote: > > > > > > e) either a valid pointer, NULL, or an error pointer > > > > > > The last pattern is seen with the various *get*_optional() functions. > > > > I would always consider those the exact bug that I meant with "because > > everyone gets those wrong". I think the idea of the "optional" functions is > > that you have two implementations b) and d) and pick one of them > > at compile time. To the caller this means either an error pointer or > > success, but checking for NULL is a bug in the caller, while conditionally > > returning NULL or ERR_PTR() would be a bug in the interface. > > e) is not for optional kernel features, but for optional hardware > functionality. So it is not known at compile time, but depends on > e.g. the DTB. See e.g. devm_clk_get_optional(). Ah right, I forgot we had those as well. However, I suppose no amount of annotation is going to help with those, as far as the checker is concerned, I would just leave this as not annotated. At least with the clk API, the callers are not able to dereference the pointer because the definition of 'struct clk' is private to drivers/clk/clk.c. Arnd