Re: [PATCH v2] docs: kdoc: fix duplicate section warning message

From: Randy Dunlap

Date: Thu Oct 30 2025 - 18:49:27 EST




On 10/30/25 2:33 PM, Jonathan Corbet wrote:
> Jacob Keller <jacob.e.keller@xxxxxxxxx> writes:
>
>> The python version of the kernel-doc parser emits some strange warnings
>> with just a line number in certain cases:
>>
>> $ ./scripts/kernel-doc -Wall -none 'include/linux/virtio_config.h'
>> Warning: 174
>> Warning: 184
>> Warning: 190
>> Warning: include/linux/virtio_config.h:226 No description found for return value of '__virtio_test_bit'
>> Warning: include/linux/virtio_config.h:259 No description found for return value of 'virtio_has_feature'
>> Warning: include/linux/virtio_config.h:283 No description found for return value of 'virtio_has_dma_quirk'
>> Warning: include/linux/virtio_config.h:392 No description found for return value of 'virtqueue_set_affinity'
>>
>> I eventually tracked this down to the lone call of emit_msg() in the
>> KernelEntry class, which looks like:
>>
>> self.emit_msg(self.new_start_line, f"duplicate section name '{name}'\n")
>>
>> This looks like all the other emit_msg calls. Unfortunately, the definition
>> within the KernelEntry class takes only a message parameter and not a line
>> number. The intended message is passed as the warning!
>>
>> Pass the filename to the KernelEntry class, and use this to build the log
>> message in the same way as the KernelDoc class does.
>>
>> To avoid future errors, mark the warning parameter for both emit_msg
>> definitions as a keyword-only argument. This will prevent accidentally
>> passing a string as the warning parameter in the future.
>>
>> Also fix the call in dump_section to avoid an unnecessary additional
>> newline.
>>
>> Fixes: e3b42e94cf10 ("scripts/lib/kdoc/kdoc_parser.py: move kernel entry to a class")
>> Signed-off-by: Jacob Keller <jacob.e.keller@xxxxxxxxx>

Tested-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>

Thanks.

>
> This one applies, thanks.
>
> jon
>

--
~Randy