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=-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 BEF17C54E8D for ; Mon, 11 May 2020 16:53:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9D6CA20708 for ; Mon, 11 May 2020 16:53:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589216011; bh=dam+wrisZkSDTYvLRv5tNOfLqS88LxqpLl5TR80UCVk=; h=From:To:Cc:Subject:Date:List-ID:From; b=RBRc+/FX73ohr3E6O2shwOUtZ7ap5pdC2E1tpJ0H+GMPJfWGQl/m2+fqHzspsT44F V7ccK6p6mcz3k8fXV0rgiL+SLjHi7IzUkPBMhV4EM3+hbAt08JtFMOriHuBbHBAT70 ZqZzF0nyiVrWrTTR1HqdTabFDT+ISOYEu14lZehU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730732AbgEKQx3 (ORCPT ); Mon, 11 May 2020 12:53:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:32940 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727874AbgEKQx2 (ORCPT ); Mon, 11 May 2020 12:53:28 -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 880A8206D7; Mon, 11 May 2020 16:53:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589216007; bh=dam+wrisZkSDTYvLRv5tNOfLqS88LxqpLl5TR80UCVk=; h=From:To:Cc:Subject:Date:From; b=d8jO5YdLOxZDIhJGblPnmWACNyek/+jRk4BMNiwiEL6q3TsQ2CqFaNc/Nm7ntTT4L qM4+xSdjOHm3lx5p7N5wKSKj4jb/fBEeArcY2v2Yt1MrEhFDV5rGFktcqSPdr2CGfc 9R0KiAH4YbnDO25W/RPpKdqokJC3lX9ro6oge+nI= 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 v2] checkpatch: warn about uses of ENOTSUPP Date: Mon, 11 May 2020 09:53:19 -0700 Message-Id: <20200511165319.2251678-1-kuba@kernel.org> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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/ v2 (Joe): - add a link to recent discussion, - don't match when scanning files, not patches to avoid sudden influx of conversion patches. v1: https://lore.kernel.org/netdev/20200510185148.2230767-1-kuba@kernel.org/ Suggested-by: Andrew Lunn Signed-off-by: Jakub Kicinski --- scripts/checkpatch.pl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index eac40f0abd56..bfbdc869cd99 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 && -- 2.25.4