From patchwork Mon May 11 17:08:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 219455 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=-10.3 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 D8955C54E8D for ; Mon, 11 May 2020 17:08:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B889920720 for ; Mon, 11 May 2020 17:08:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589216893; bh=B9ADM+z1RTrBii/bvb2Tu1zrB+wUsRTguF4TeoHld/Q=; h=From:To:Cc:Subject:Date:List-ID:From; b=jMPlvbDywnvlR93QpJMCNO2v3Z+q6rqdl2s4NYFhNfdgFMBN6+0iLGFXa6wEgf46z k4mdP9U2rUhuBcSxhTwatmYDjtH4AJ/00Nu/ie/GDmyc9b3VOnTXGQ1zIdioqELbuL ZPcaVN6FK1Gg39048Ioj6ZnLtuGWPZokqQG+UZGc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730867AbgEKRIK (ORCPT ); Mon, 11 May 2020 13:08:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:50534 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730629AbgEKRIK (ORCPT ); Mon, 11 May 2020 13:08:10 -0400 Received: from kicinski-fedora-PC1C0HJN.thefacebook.com (unknown [163.114.132.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 83C3520714; Mon, 11 May 2020 17:08:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589216889; bh=B9ADM+z1RTrBii/bvb2Tu1zrB+wUsRTguF4TeoHld/Q=; h=From:To:Cc:Subject:Date:From; b=x+O1h+AE5rFHKJvYexyVPbMFAwbT0o8r4F9GEqcwTh2s1CgqcxFVt6XVMX731r02P 9DdDG8EC7V7nqEZLf2UKsm5TAvZsVDGcdVL5gdvfNLZ8TCkZOqAEIZy+XQQV61M97i Jha/CEJQ8CV3k/xFvHlojlky8fI30Wcfr4ft1gOU= From: Jakub Kicinski To: Joe Perches , davem@davemloft.net Cc: netdev@vger.kernel.org, andrew@lunn.ch, linux-kernel@vger.kernel.org, Jakub Kicinski Subject: [PATCH net-next v3] checkpatch: warn about uses of ENOTSUPP Date: Mon, 11 May 2020 10:08:07 -0700 Message-Id: <20200511170807.2252749-1-kuba@kernel.org> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org ENOTSUPP often feels like the right error code to use, but it's in fact not a standard Unix error. E.g.: $ python >>> import errno >>> errno.errorcode[errno.ENOTSUPP] Traceback (most recent call last): File "", line 1, in AttributeError: module 'errno' has no attribute 'ENOTSUPP' There were numerous commits converting the uses back to EOPNOTSUPP but in some cases we are stuck with the high error code for backward compatibility reasons. Let's try prevent more ENOTSUPPs from getting into the kernel. Recent example: https://lore.kernel.org/netdev/20200510182252.GA411829@lunn.ch/ v3 (Joe): - fix the "not file" condition. v2 (Joe): - add a link to recent discussion, - don't match when scanning files, not patches to avoid sudden influx of conversion patches. https://lore.kernel.org/netdev/20200511165319.2251678-1-kuba@kernel.org/ v1: https://lore.kernel.org/netdev/20200510185148.2230767-1-kuba@kernel.org/ Suggested-by: Andrew Lunn Signed-off-by: Jakub Kicinski Acked-by: Joe Perches --- scripts/checkpatch.pl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index eac40f0abd56..2be07ed4d70c 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -4199,6 +4199,17 @@ sub process { "ENOSYS means 'invalid syscall nr' and nothing else\n" . $herecurr); } +# ENOTSUPP is not a standard error code and should be avoided in new patches. +# Folks usually mean EOPNOTSUPP (also called ENOTSUP), when they type ENOTSUPP. +# Similarly to ENOSYS warning a small number of false positives is expected. + if (!$file && $line =~ /\bENOTSUPP\b/) { + if (WARN("ENOTSUPP", + "ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP\n" . $herecurr) && + $fix) { + $fixed[$fixlinenr] =~ s/\bENOTSUPP\b/EOPNOTSUPP/; + } + } + # function brace can't be on same line, except for #defines of do while, # or if closed on same line if ($perl_version_ok &&