From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4BBE48C8C5; Sat, 28 Feb 2026 17:43:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772300603; cv=none; b=smB8/zs85BldpnjnK+K2c0p2HqppQfhvcybUOnt71YIwfs8fjPOtjRkvuisnh/lAZI9bUzMRnWwUKNmrDn6sw5sZKpxCAfOdLy7KZTdBdo/FfR267v+bFmhFpe08+MKJR+inlzJPgoN8+z/d0AJ8poy5MrcVgSxiqXHO4/QxAYM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772300603; c=relaxed/simple; bh=G1puFTGsWufhrjjuUp5eqPyNrw1x4Jop1jFVDzYqptI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NzdiharzyTTD4xfMSzMh3LiSBkDZr6PTiOcCEixsGivVbShook3Etr4cxGQsm0Zk5JOYA9qgCMwY9QwX50WLhLZRNpG5VoKBCTOZk/8vZoAOLIkuW0fWmcuWLb7ZLhPNGoxCWM2i1VVwa10MoNzSrbREw0jNveRaI05t16ULgOM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iRLSy5Lh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iRLSy5Lh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C29D5C116D0; Sat, 28 Feb 2026 17:43:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772300603; bh=G1puFTGsWufhrjjuUp5eqPyNrw1x4Jop1jFVDzYqptI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iRLSy5Lh/iyjFQUA2vZul7BdJ9DKN6GjismS+vKLmG9SAi/yGcDi2rw5O4bWsc6Wq mIuF7ShHg8xRzax7TUoBxDhA3PiXI0V8l1ZW6W9Eczw8SgqC9m4WVRDSssq3Pxs9QJ UJtrVzT0GPxhPKijF+I0Y7BvK25F1kqh/8wB3BtFmvegNr2knUGlYB1aA3jGOTiTpP vsjqegruNHz0tYiKM0NjAgayibY4aW+Ly3+30eHTn6yyatsYMNQvDWlm19QVfaGyht fYKjQWGDuk2Jx+Os6fWjYuTe+HBLJQBgqowtci5uX6+g183RKQtsIRB9artqccRgnd aWP2yJ9LZP0AA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mauro Carvalho Chehab , Andy Shevchenko , Jonathan Corbet , Sasha Levin Subject: [PATCH 6.19 644/844] docs: kdoc: fix logic to handle unissued warnings Date: Sat, 28 Feb 2026 12:29:17 -0500 Message-ID: <20260228173244.1509663-645-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260228173244.1509663-1-sashal@kernel.org> References: <20260228173244.1509663-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Mauro Carvalho Chehab [ Upstream commit 292eca3163218f2185a8eabe59f4a576bb9e05f8 ] Changeset 469c1c9eb6c9 ("kernel-doc: Issue warnings that were silently discarded") didn't properly addressed the missing messages behavior, as it was calling directly python logger low-level function, instead of using the expected method to emit warnings. Basically, there are two methods to log messages: - self.config.log.warning() - This is the raw level to emit a warning. It just writes the a message at stderr, via python logging, as it is initialized as: self.config.log = logging.getLogger("kernel-doc") - self.config.warning() - This is where we actually consider a message as a warning, properly incrementing error count. Due to that, several parsing error messages are internally considered as success, causing -Werror to not work on such messages. While here, ensure that the last ignored entry will also be handled by adding an extra check at the end of the parse handler. Fixes: 469c1c9eb6c9 ("kernel-doc: Issue warnings that were silently discarded") Closes: https://lore.kernel.org/linux-doc/20260112091053.00cee29a@foz.lan/ Cc: stable@vger.kernel.org Signed-off-by: Mauro Carvalho Chehab Acked-by: Andy Shevchenko Signed-off-by: Jonathan Corbet Message-ID: <95109a6585171da4d6900049deaa2634b41ee743.1768823489.git.mchehab+huawei@kernel.org> Signed-off-by: Sasha Levin --- tools/lib/python/kdoc/kdoc_parser.py | 35 ++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/tools/lib/python/kdoc/kdoc_parser.py b/tools/lib/python/kdoc/kdoc_parser.py index 500aafc500322..2168d623f7867 100644 --- a/tools/lib/python/kdoc/kdoc_parser.py +++ b/tools/lib/python/kdoc/kdoc_parser.py @@ -295,7 +295,7 @@ class KernelEntry: # TODO: rename to emit_message after removal of kernel-doc.pl def emit_msg(self, ln, msg, *, warning=True): - """Emit a message""" + """Emit a message.""" log_msg = f"{self.fname}:{ln} {msg}" @@ -448,18 +448,37 @@ class KernelDoc: self.config.log.debug("Output: %s:%s = %s", dtype, name, pformat(args)) + def emit_unused_warnings(self): + """ + When the parser fails to produce a valid entry, it places some + warnings under `entry.warnings` that will be discarded when resetting + the state. + + Ensure that those warnings are not lost. + + .. note:: + + Because we are calling `config.warning()` here, those + warnings are not filtered by the `-W` parameters: they will all + be produced even when `-Wreturn`, `-Wshort-desc`, and/or + `-Wcontents-before-sections` are used. + + Allowing those warnings to be filtered is complex, because it + would require storing them in a buffer and then filtering them + during the output step of the code, depending on the + selected symbols. + """ + if self.entry and self.entry not in self.entries: + for log_msg in self.entry.warnings: + self.config.warning(log_msg) + def reset_state(self, ln): """ Ancillary routine to create a new entry. It initializes all variables used by the state machine. """ - # - # Flush the warnings out before we proceed further - # - if self.entry and self.entry not in self.entries: - for log_msg in self.entry.warnings: - self.config.log.warning(log_msg) + self.emit_unused_warnings() self.entry = KernelEntry(self.config, self.fname, ln) @@ -1664,6 +1683,8 @@ class KernelDoc: # Hand this line to the appropriate state handler self.state_actions[self.state](self, ln, line) + self.emit_unused_warnings() + except OSError: self.config.log.error(f"Error: Cannot open file {self.fname}") -- 2.51.0