From nobody Mon Sep 28 02:07:45 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1785505299; cv=none; d=zohomail.com; s=zohoarc; b=DNd5zgzOjeTCWIihbY+rowHGHtiGPTxXKY3UJMfNhfjs4yuz6SrJyaMaqhdaX4F811VjL2yJyPLeCvWlBbfj7AxkaqUQmdYqpxpb2BlLJQ75PSTIdM5r0MbD4v2fFnIrtw4Qam2eKqjP6SZAt8jZs/eW+w/1Ls+adyzkEyVT2hQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785505299; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Z9s32wvCavotKoTGfHvCMSBystm/xHKrYlx37iykbLE=; b=CRx9kXKN7nnSW4XQ5UWS2mmmnnC5N9Xy4IItHKRmxuFQ78wUnnLdN26dvYMV3tX4qpTfWssoCn4JaapJuuA1kHqvRkKz1N1fLNIzAiQ7T7V7S8rzfn0bcu2D4WiTuz5YUQalPH2I3ZZbUDy03lsIvATmN1kKu9gxMa1Na/oinMA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785505299865951.0157384021281; Fri, 31 Jul 2026 06:41:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wpnTu-0001rg-GG; Fri, 31 Jul 2026 09:40:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wpnTt-0001rT-60 for qemu-devel@nongnu.org; Fri, 31 Jul 2026 09:40:57 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wpnTr-0003ol-0Y for qemu-devel@nongnu.org; Fri, 31 Jul 2026 09:40:56 -0400 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-c15dd4b9132so154219766b.1 for ; Fri, 31 Jul 2026 06:40:52 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:1758:fc6:a5f8:a15f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c1fd3c9e3e6sm152309466b.22.2026.07.31.06.40.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2026 06:40:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1785505250; x=1786110050; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=Z9s32wvCavotKoTGfHvCMSBystm/xHKrYlx37iykbLE=; b=kJ8kt+LjMokCh2HNQr4JBGl8SRLrnFZgboTuN4rD3gkJECkg0i33MJjuCF/INaGh/8 Gi2hbUveD+iW0J8HFzaPJ+zmzrO0J+kTyBcbavgXTQhsvYBCVky0vlvRUR6TIOZq9/N8 7N53eIjYE6zmusbwjjuzYjW8tJsd2bU1Hm/1DBe3vsS38ndrPSpgDvfx7ESPVcgOzmqg wl7TOnUUSuykoS5JKVrf/s21WMyCtNQbB7Ol2WdWE0YKglye6x7M0ccDAAX9D79XBP01 ic9tl6O6XOqvhAAKhTW//PqRXsvDl8CghZxn+LPSVSlBWJV663/38VPFAnCTkPp9gdgc O/+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785505250; x=1786110050; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Z9s32wvCavotKoTGfHvCMSBystm/xHKrYlx37iykbLE=; b=U8m31HigWImYeSZ22SsXjnRms9ALmMbBZmX42hba+N0e05nTAXIjLtsoQMBLY1XGdB I2LURVxUimWx/rXtuoe4UYbMgyZ4YcJmoxaLHlIArZDGoTp0k72OLXYoXOWmk+Sd3PIs i4fZC+GD3thF5m21DBOaeGgYdUM10Mj0jVbZqoLu+HUyGQexhcW8GF/XVM3UVbEzjfDw RFfpLtLFhq23aCIUpD71eQibnH4E//98Jy0z46H3k4iquYwLA8gq+9+MnoLz0bOmkhDB CUwAsld88R9+A3X5tp1WT9WZVXh1DOJKPStLS/ZUjcaioveB2FFPcZdseap08iCOoBJG 6IoA== X-Gm-Message-State: AOJu0Yygjw1IWMiAGpkuouNOd+FqDrkEUcyx/5MFtO9gq6mPb/RQ0jA5 GVGdSYMCd2hRBtgbJ1n6RZ9j8MjA/pOphUy9qxKKZnNlLjouYLunzVRmepvJs2LzMcpHjhppPf1 myVdZ X-Gm-Gg: AR+sD13LpnWZHp9L0gvTnUxY0knLvs/y2tbw+IYhLDJoPvix3mV+X9qfYYWMymoThLg qipCW1d63ArRHRTTcHl/FpQQLvd/l2MYNw6SHa81prUrMxsnD4vu1WzO3VD38baiPhSVCP39OTJ vKXhZ0+hGB4yDrxrGJZKPCbk7gSsSUDUIGkFoTJ1rpNeVoiISEEOt30Y7kn8XuuAQ7V5VdIGB4m j4xaRV2bEFH/eFigFIxmSRwxI5t97l9Bz7XRnRbX63oC1ScVZJdDyQi1Nrw7PSpNBHhN/JBv50N qNws2xK+1k4/7BN9i2cdVB5JWeVtKum//rETA2UnTHrP1qAebT6Fwcz5PFgg6dNGvRZiLqurPR0 I8yRZcTvESPMz9UOBgB6rzAeFYuVVnIS5Go3uAkF4ssXMkpbGvaPwHKFCUVPidamARcUEuE3+55 itrGd2a7N/6Get7oxhUTp8UKYl52ZbrUVmEPmdyN5dtaHaAnao/Dl5BZ1P X-Received: by 2002:a17:907:961a:b0:c1c:332b:7611 with SMTP id a640c23a62f3a-c1fd27539eemr122463466b.65.1785505249605; Fri, 31 Jul 2026 06:40:49 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: den@openvz.org, Chao Liu , "Daniel P. Berrange" , "Philippe Mathieu-Daude" , Thomas Huth Subject: [PATCH] checkpatch: warn about hunks which only add blank lines Date: Fri, 31 Jul 2026 15:40:46 +0200 Message-ID: <20260731134046.1015479-1-den@openvz.org> X-Mailer: git-send-email 2.53.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=den@openvz.org; helo=mail-ej1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1785505302532158500 Content-Type: text/plain; charset="utf-8" Patches sometimes carry a hunk whose entire content is one or two added blank lines. It changes nothing, it makes the diff longer and it survives review because nobody looks twice at a blank line. The blank line itself is perfectly fine, the gratuitous hunk is not. Tally the added blank lines and the other changes of every hunk in the pre-scan loop which already walks the raw patch, and record the hunks which only add blanks. Such a hunk is then reported at the first blank line it adds, so the warning carries the usual file and line context. Signed-off-by: Denis V. Lunev CC: Chao Liu CC: "Daniel P. Berrange" CC: "Philippe Mathieu-Daude" CC: Thomas Huth --- Note: this patch is sent on behalf of the yesterday finding inside IDE pull request. This should be found with a checkpatch. scripts/checkpatch.pl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 03f35e7501..dfa9878006 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1567,6 +1567,10 @@ sub process { my $first_line =3D 0; my $p1_prefix =3D ''; =20 + my %blank_only_hunk; + my $hunk_first_blank =3D 0; + my $hunk_has_change =3D 0; + my $prev_values =3D 'E'; =20 # suppression flags @@ -1583,6 +1587,10 @@ sub process { $line =3D $rawline; =20 if ($rawline=3D~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) { + $blank_only_hunk{$hunk_first_blank} =3D 1 + if ($hunk_first_blank && !$hunk_has_change); + ($hunk_first_blank, $hunk_has_change) =3D (0, 0); + $realline=3D$1-1; if (defined $2) { $realcnt=3D$3+1; @@ -1633,6 +1641,13 @@ sub process { push(@lines, $line); =20 if ($realcnt > 1) { + if ($rawline =3D~ /^\+\s*$/) { + $hunk_first_blank =3D $linenr + if (!$hunk_first_blank); + } elsif ($rawline =3D~ /^[-+]/) { + $hunk_has_change =3D 1; + } + $realcnt-- if ($line =3D~ /^(?:\+| |$)/); } else { $realcnt =3D 0; @@ -1641,6 +1656,8 @@ sub process { #print "=3D=3D>$rawline\n"; #print "-->$line\n"; } + $blank_only_hunk{$hunk_first_blank} =3D 1 + if ($hunk_first_blank && !$hunk_has_change); =20 $prefix =3D ''; =20 @@ -1780,6 +1797,10 @@ sub process { =20 $cnt_lines++ if ($realcnt !=3D 0); =20 + if ($blank_only_hunk{$linenr}) { + WARN("this hunk only adds blank lines\n" . $herecurr); + } + # Only allow Python 3 interpreter if ($realline =3D=3D 1 && $line =3D~ /^\+#!\ *\/usr\/bin\/(?:env )?python$/) { base-commit: e1705a25aff35635c360bbaba4c2731d019a422a --=20 2.53.0