Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2088818pxj; Sat, 5 Jun 2021 12:21:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnlVlQHAmME/JOKuJNNuETknDRNYuYUDTXlS36h2xfFiTZXlErdH7YFK9eKtCH7T/qkEQx X-Received: by 2002:a05:6402:19b9:: with SMTP id o25mr11380284edz.192.1622920875092; Sat, 05 Jun 2021 12:21:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622920875; cv=none; d=google.com; s=arc-20160816; b=GOqdIxVAEdjV8BXOl3YNyMDR808tGdRaO5VYCY6xhkKVwVoOQ+/zMFcb1040v6hD0v RCOdPGSSg4aqiK0s7OtNXvIFECwYBHvIDKGNhdJzrz/2mIN4pBCbJUYvLhe55k/xxPds wd/9z4QBnR25ojrcr2yL8mf/MTiZ7EF101YpvbikXpWPkYPmh29TW7NAsb3mFBdaGWVU umXLOrgmrlS0V5hQvzY8GmbMneqfXWX428oT5Hfst0PuUk02zF71FQCk56WWGjqqGUat RuVuwb+E4D6Q2TEGeTVPuJcUgLL3f70NHSRoHsi4DtelEwsoz+NItBc/lLy3HMS7kj4r 7X5A== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=lEDQpHfLYsPS4ui/OdWsymIsdBIwBJQksSc8kuj65Ho=; b=N6u1rvVwwCEWJqgSIVeBpv3X9/Zx79YNtHSxwGFj9D/0NXRsLOsaaRynhhgSyqNd4C R3FNUpUBJesaCngaptHKBkYhzBexf9Ikcq+El1NVQFszVhkA+aaIA1UK+q88r0nMZNID iFhpXQS0Yo5ferInEmL+4hpnE+pYx9DkAF0eOJkYl6gMlEyoXcMT/4StnWvB5cyjfPeV sGlu6MszNH3E3CdN9B3z1rNmnejcbDwCq5b8YIvzJUwi/dpLq6k12mRx/p7LZZSmNuXZ XMyIg6CjhGYSDaiP1tvczCGH2HAnG0wnzJ/TSFKzMWAEgupnvyHKg/oAY6m06ORPD9hl VukA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gK9XcHv2; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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.20.49; Sat, 05 Jun 2021 12:21:15 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gK9XcHv2; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230022AbhFETUX (ORCPT + 99 others); Sat, 5 Jun 2021 15:20:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229996AbhFETUW (ORCPT ); Sat, 5 Jun 2021 15:20:22 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75D45C061766 for ; Sat, 5 Jun 2021 12:18:19 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id md2-20020a17090b23c2b029016de4440381so513890pjb.1 for ; Sat, 05 Jun 2021 12:18:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lEDQpHfLYsPS4ui/OdWsymIsdBIwBJQksSc8kuj65Ho=; b=gK9XcHv2xaVwaycQOD2OzjboZGuZMeWxjcGF6dzcwSUWLUdR1YpiIgk6mA4QdywsAY smnx6NtAqPs8aKDGXtexs2ycrcTM2yCwlZDt4pm4rzE37d8rhoOwZF/D2TW4AF55oama SJgDH/foH01eQkEewYlkhRin5UxH8C0A6lqhAeJXXCr+gZLn830X0FRb3CjaLxg9P7T+ K5+BYFppbaIgxexGUGeof3+Oko2/cc1NjUc2e5kA7csiXp5Jk1scesyPr1s138oCi65j vkzjhHNs+5So9S3mV82GZFbAovdgS0qKaQ8QHHYLVbi51NFgoLQP1YKdcGivgtNu/VGS EbPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lEDQpHfLYsPS4ui/OdWsymIsdBIwBJQksSc8kuj65Ho=; b=EiOgcWlNmXIcgprNHuk7RhfPhoe6r8C6+DxEAbX8ZdkgkSCJYqpEPfnAtxe9MNYWek sPETZ/YxXaPvUSopN7SREk6xxLMlBCncnU5Xc2TmTfSFrijZixN99WPhtLzZ0J2Eu6Vk /F0w8RjlcxLxWZFce+Avf9cJ5NlkbAXIhlAUB5L9qyDR6FXVYwd5qRwcaYdJJmSyWxOf quCR4tGriznM6P3cBGqy9EB3EnIsGyNlSFs2W5RH8JZT+tWl0W2ilelR96ecl1ZkLir+ 7H0z3L2ZJ7kOyvsB/K/wwX+T9JqkqTjmUEXlSj9rYsSbDwOM8H2FR5/YerXm7aq88J5U 2Jnw== X-Gm-Message-State: AOAM532kYHZ14HEWBpQqXcNoHU2g1eKlT+u4SgB6OcpTliGwpx9RNX86 qRCK+PGhj+kJfyGEUWVvaP8+/mrtxYCmSw== X-Received: by 2002:a17:90a:7bce:: with SMTP id d14mr11946793pjl.38.1622920698314; Sat, 05 Jun 2021 12:18:18 -0700 (PDT) Received: from localhost.localdomain ([49.37.1.243]) by smtp.gmail.com with ESMTPSA id cq24sm399437pjb.18.2021.06.05.12.18.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Jun 2021 12:18:17 -0700 (PDT) From: Dwaipayan Ray To: joe@perches.com Cc: linux-kernel@vger.kernel.org, lukas.bulwahn@gmail.com, Dwaipayan Ray Subject: [PATCH] checkpatch: do not allow using -f/--file option without a filename Date: Sun, 6 Jun 2021 00:47:54 +0530 Message-Id: <20210605191754.28165-1-dwaipayanray1@gmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Link: https://lore.kernel.org/lkml/294bb4a2c3f5f8cf4a744cf59bfd37562653afb9.camel@perches.com/T/#t Suggested-by: Joe Perches Signed-off-by: Dwaipayan Ray --- scripts/checkpatch.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 3e1795311c87..7dff9206f9f0 100755 --- 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; -- 2.28.0