diff mbox series

[net-next,v2,2/2] scripts: kernel-doc: fix macro handling in enums

Message ID 20230814170720.46229-3-pavan.kumar.linga@intel.com (mailing list archive)
State Not Applicable
Delegated to: Netdev Maintainers
Headers show
Series Fix invalid kernel-doc warnings | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 9 this patch: 9
netdev/cc_maintainers success CCed 2 of 2 maintainers
netdev/build_clang success Errors and warnings before: 9 this patch: 9
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 9 this patch: 9
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 7 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Pavan Kumar Linga Aug. 14, 2023, 5:07 p.m. UTC
drivers/net/ethernet/intel/idpf/idpf.h uses offsetof to
initialize the enum enumerators:

enum {
	IDPF_BASE_CAPS = -1,
	IDPF_CSUM_CAPS = offsetof(struct virtchnl2_get_capabilities,
				  csum_caps),
	IDPF_SEG_CAPS = offsetof(struct virtchnl2_get_capabilities,
				 seg_caps),
	IDPF_RSS_CAPS = offsetof(struct virtchnl2_get_capabilities,
				 rss_caps),
	IDPF_HSPLIT_CAPS = offsetof(struct virtchnl2_get_capabilities,
				    hsplit_caps),
	IDPF_RSC_CAPS = offsetof(struct virtchnl2_get_capabilities,
				 rsc_caps),
	IDPF_OTHER_CAPS = offsetof(struct virtchnl2_get_capabilities,
				   other_caps),
};

kernel-doc parses the above enumerator with a ',' inside the
macro and treats 'csum_caps', 'seg_caps' etc. also as enumerators
resulting in the warnings:

drivers/net/ethernet/intel/idpf/idpf.h:130: warning: Enum value
'csum_caps' not described in enum 'idpf_cap_field'
drivers/net/ethernet/intel/idpf/idpf.h:130: warning: Enum value
'seg_caps' not described in enum 'idpf_cap_field'
drivers/net/ethernet/intel/idpf/idpf.h:130: warning: Enum value
'rss_caps' not described in enum 'idpf_cap_field'
drivers/net/ethernet/intel/idpf/idpf.h:130: warning: Enum value
'hsplit_caps' not described in enum 'idpf_cap_field'
drivers/net/ethernet/intel/idpf/idpf.h:130: warning: Enum value
'rsc_caps' not described in enum 'idpf_cap_field'
drivers/net/ethernet/intel/idpf/idpf.h:130: warning: Enum value
'other_caps' not described in enum 'idpf_cap_field'

Fix it by removing the macro arguments within the parentheses.

Signed-off-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
---
 scripts/kernel-doc | 1 +
 1 file changed, 1 insertion(+)

Comments

Jonathan Corbet Aug. 14, 2023, 6:59 p.m. UTC | #1
Pavan Kumar Linga <pavan.kumar.linga@intel.com> writes:

> drivers/net/ethernet/intel/idpf/idpf.h uses offsetof to
> initialize the enum enumerators:
>
> enum {
> 	IDPF_BASE_CAPS = -1,
> 	IDPF_CSUM_CAPS = offsetof(struct virtchnl2_get_capabilities,
> 				  csum_caps),
> 	IDPF_SEG_CAPS = offsetof(struct virtchnl2_get_capabilities,
> 				 seg_caps),
> 	IDPF_RSS_CAPS = offsetof(struct virtchnl2_get_capabilities,
> 				 rss_caps),
> 	IDPF_HSPLIT_CAPS = offsetof(struct virtchnl2_get_capabilities,
> 				    hsplit_caps),
> 	IDPF_RSC_CAPS = offsetof(struct virtchnl2_get_capabilities,
> 				 rsc_caps),
> 	IDPF_OTHER_CAPS = offsetof(struct virtchnl2_get_capabilities,
> 				   other_caps),
> };
>
> kernel-doc parses the above enumerator with a ',' inside the
> macro and treats 'csum_caps', 'seg_caps' etc. also as enumerators
> resulting in the warnings:
>
> drivers/net/ethernet/intel/idpf/idpf.h:130: warning: Enum value
> 'csum_caps' not described in enum 'idpf_cap_field'
> drivers/net/ethernet/intel/idpf/idpf.h:130: warning: Enum value
> 'seg_caps' not described in enum 'idpf_cap_field'
> drivers/net/ethernet/intel/idpf/idpf.h:130: warning: Enum value
> 'rss_caps' not described in enum 'idpf_cap_field'
> drivers/net/ethernet/intel/idpf/idpf.h:130: warning: Enum value
> 'hsplit_caps' not described in enum 'idpf_cap_field'
> drivers/net/ethernet/intel/idpf/idpf.h:130: warning: Enum value
> 'rsc_caps' not described in enum 'idpf_cap_field'
> drivers/net/ethernet/intel/idpf/idpf.h:130: warning: Enum value
> 'other_caps' not described in enum 'idpf_cap_field'
>
> Fix it by removing the macro arguments within the parentheses.
>
> Signed-off-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
> ---
>  scripts/kernel-doc | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/scripts/kernel-doc b/scripts/kernel-doc
> index cfb1cb223508..bc008f30f3c9 100755
> --- a/scripts/kernel-doc
> +++ b/scripts/kernel-doc
> @@ -1353,6 +1353,7 @@ sub dump_enum($$) {
>  	my %_members;
>  
>  	$members =~ s/\s+$//;
> +	$members =~ s/\(.*?[\)]//g;

".*" matches the empty string, so * think the "?" is unnecessary.

I do worry that this regex could match more than expected, disappearing
everything up to a final parenthesis.  It doesn't cause any changes in
the current docs build, but still ... How do you feel about replacing
".*" with "[^;]*" ?

Thanks,

jon
Pavan Kumar Linga Aug. 15, 2023, 12:45 a.m. UTC | #2
On 8/14/2023 11:59 AM, Jonathan Corbet wrote:
> Pavan Kumar Linga <pavan.kumar.linga@intel.com> writes:
> 
>> drivers/net/ethernet/intel/idpf/idpf.h uses offsetof to
>> initialize the enum enumerators:
>>
>> enum {
>> 	IDPF_BASE_CAPS = -1,
>> 	IDPF_CSUM_CAPS = offsetof(struct virtchnl2_get_capabilities,
>> 				  csum_caps),
>> 	IDPF_SEG_CAPS = offsetof(struct virtchnl2_get_capabilities,
>> 				 seg_caps),
>> 	IDPF_RSS_CAPS = offsetof(struct virtchnl2_get_capabilities,
>> 				 rss_caps),
>> 	IDPF_HSPLIT_CAPS = offsetof(struct virtchnl2_get_capabilities,
>> 				    hsplit_caps),
>> 	IDPF_RSC_CAPS = offsetof(struct virtchnl2_get_capabilities,
>> 				 rsc_caps),
>> 	IDPF_OTHER_CAPS = offsetof(struct virtchnl2_get_capabilities,
>> 				   other_caps),
>> };
>>
>> kernel-doc parses the above enumerator with a ',' inside the
>> macro and treats 'csum_caps', 'seg_caps' etc. also as enumerators
>> resulting in the warnings:
>>
>> drivers/net/ethernet/intel/idpf/idpf.h:130: warning: Enum value
>> 'csum_caps' not described in enum 'idpf_cap_field'
>> drivers/net/ethernet/intel/idpf/idpf.h:130: warning: Enum value
>> 'seg_caps' not described in enum 'idpf_cap_field'
>> drivers/net/ethernet/intel/idpf/idpf.h:130: warning: Enum value
>> 'rss_caps' not described in enum 'idpf_cap_field'
>> drivers/net/ethernet/intel/idpf/idpf.h:130: warning: Enum value
>> 'hsplit_caps' not described in enum 'idpf_cap_field'
>> drivers/net/ethernet/intel/idpf/idpf.h:130: warning: Enum value
>> 'rsc_caps' not described in enum 'idpf_cap_field'
>> drivers/net/ethernet/intel/idpf/idpf.h:130: warning: Enum value
>> 'other_caps' not described in enum 'idpf_cap_field'
>>
>> Fix it by removing the macro arguments within the parentheses.
>>
>> Signed-off-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
>> ---
>>   scripts/kernel-doc | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/scripts/kernel-doc b/scripts/kernel-doc
>> index cfb1cb223508..bc008f30f3c9 100755
>> --- a/scripts/kernel-doc
>> +++ b/scripts/kernel-doc
>> @@ -1353,6 +1353,7 @@ sub dump_enum($$) {
>>   	my %_members;
>>   
>>   	$members =~ s/\s+$//;
>> +	$members =~ s/\(.*?[\)]//g;
> 
> ".*" matches the empty string, so * think the "?" is unnecessary.
> 

As suggested, tried without "?" in the below updated regex and it 
doesn't parse right. It substitutes everything from the 1st "(" to the 
last ")" with empty string whereas using "?" substitutes each "( )" with 
empty string.

> I do worry that this regex could match more than expected, disappearing
> everything up to a final parenthesis.  It doesn't cause any changes in
> the current docs build, but still ... How do you feel about replacing
> ".*" with "[^;]*" ?
>

Thanks for the suggestion and that works for me. After the update, the 
regex would look like:

"$members =~ s/\([^;]*?[\)]//g;"

Will update this in the next revision.

> Thanks,
> 
> jon

Regards,
Pavan
diff mbox series

Patch

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index cfb1cb223508..bc008f30f3c9 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1353,6 +1353,7 @@  sub dump_enum($$) {
 	my %_members;
 
 	$members =~ s/\s+$//;
+	$members =~ s/\(.*?[\)]//g;
 
 	foreach my $arg (split ',', $members) {
 	    $arg =~ s/^\s*(\w+).*/$1/;