Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2094530pxj; Sat, 5 Jun 2021 12:34:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhKY4ly/XiJVpuZ0g4yaKMfO7kFB0epQJOx3LLj3UY8EhHX0SP9wNli6iM16sI+I4leAzE X-Received: by 2002:a17:906:ae92:: with SMTP id md18mr10458408ejb.410.1622921684453; Sat, 05 Jun 2021 12:34:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622921684; cv=none; d=google.com; s=arc-20160816; b=BxZO01OBJgTLRhRfX3QE4pfkj5EgL3MoRihP8hVwN8S4jhr+plopL1KR0fY7wZDTRn osOZxtbo4AN+s7XA82sGhnEzz+X4/eN/7MbbQtOERxg/l9a8wcjFrZKpvxZuEhmWV7tz aXHOGXA0qbYQQQa5VoIZzSUgcTB9UPvbPcbHgL0TXbsWchKKvoUeB+sTAXq/4f+DvzE8 AsKcc/7Pk/3BePdtzIfOoiCPkhzHEnzOPRiD0iuCrSDaWvIdzifYstzPFuNhZgo4H7Ri Je5NIQR7pFhv3CWXj5PQRb8NVq9qtrp9SL5DN8l1YkuMIgMCYoZQVGpkIpXELgwegT3B zBLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=yDzywsOjNOwPyqRgp60HCYNGNTLTWiHR80ito8mievI=; b=M3eHa9qisEI8xOQhQv3AbdElEVGeqntcEiHizesQ55xZxFhLQ41b/0d7O/E42IfGbk XuYO7BXNTyvVivV9SUszqHfkr02ZRI10KV6TwsuCOM4lPN2WINFxR5OsHC9OeRPs9YeH mxTOhIN9CrLsTBHzsUeApzB1y0STtlkaP8MTA0n/bXObGzFSZjhPxDfYB/B49zaiiDqd Mn+uh8BHx8KgJl/1SOI+OlpppDYhYlZZpaIU9w5e1+3us3/ZQNeb18LdZ02cQZ+jh5ja UNobW84iSk3mDtY5tmlmXPoI6XEHJvFKsp2gnVRYqotEksetRtDg+86KGj7nVvSdC/Ax t42Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id de26si7934566ejc.6.2021.06.05.12.34.20; Sat, 05 Jun 2021 12:34:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230029AbhFETeL (ORCPT + 99 others); Sat, 5 Jun 2021 15:34:11 -0400 Received: from smtprelay0059.hostedemail.com ([216.40.44.59]:32978 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229998AbhFETeK (ORCPT ); Sat, 5 Jun 2021 15:34:10 -0400 Received: from omf13.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay01.hostedemail.com (Postfix) with ESMTP id 85398100E7B42; Sat, 5 Jun 2021 19:32:21 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf13.hostedemail.com (Postfix) with ESMTPA id BACFD1124F6; Sat, 5 Jun 2021 19:32:20 +0000 (UTC) Message-ID: <0c0bdfa2c0c1f2c7ebdcbe7d4a1366c1697ce57a.camel@perches.com> Subject: Re: [PATCH] checkpatch: do not allow using -f/--file option without a filename From: Joe Perches To: Dwaipayan Ray , Andrew Morton Cc: linux-kernel@vger.kernel.org, lukas.bulwahn@gmail.com Date: Sat, 05 Jun 2021 12:32:19 -0700 In-Reply-To: <20210605191754.28165-1-dwaipayanray1@gmail.com> References: <20210605191754.28165-1-dwaipayanray1@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.38.1-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: BACFD1124F6 X-Spam-Status: No, score=-1.40 X-Stat-Signature: yj6jei1nxhby9siykowof8ya1fmi8tuj X-Rspamd-Server: rspamout03 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX19i1kW3aqmTKMX5m4ckwaU7fZjBZd3fqsk= X-HE-Tag: 1622921540-18543 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2021-06-06 at 00:47 +0530, Dwaipayan Ray wrote: > When checkpatch is run without a filename, it reads from stdin. > But if --file option is used along with that, it may generate > false positives. > > Consider the following test file: > $cat test.c > int x = a - b; > > $cat test.c | ./scripts/checkpatch.pl -f > WARNING: It's generally not useful to have the filename in the file > +int x = a - b; > > This is a false positive and occurs because $realfile is set to "-". > Also since checkpatch relies on the file's extension to run specific > checks for c files, assembly files, etc, most of the checks are > not run as well. > > So it is better to disable -f/--file option when checkpatch is > run without a filename. That's a reasonable commit message, thanks. > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl [] > @@ -331,6 +331,7 @@ help(0) if ($help); > ? > > ?die "$P: --git cannot be used with --file or --fix\n" if ($git && ($file || $fix)); > ?die "$P: --verbose cannot be used with --terse\n" if ($verbose && $terse); > +die "$P: -f/--file requires at least one filename\n" if ($file && $#ARGV < 0); > ? > ?if ($color =~ /^[01]$/) { > ? $color = !$color;