[XEN PATCH] xen: fix header guard generation for asm-generic headers

Nicola Vetrini posted 1 patch 4 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/f07133fa226df11624883fafa1cb455a4e7670ba.1750499076.git.nicola.vetrini@bugseng.com
xen/scripts/Makefile.asm-generic | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[XEN PATCH] xen: fix header guard generation for asm-generic headers
Posted by Nicola Vetrini 4 months, 1 week ago
Dashes were wrongly not translated into underscores, thus generating
an unexpected guard identifier.

Fixes: ee79f378311b ("xen: add header guards to generated asm generic headers")
Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
---
 xen/scripts/Makefile.asm-generic | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/scripts/Makefile.asm-generic b/xen/scripts/Makefile.asm-generic
index b0828018080d..f6850758c54b 100644
--- a/xen/scripts/Makefile.asm-generic
+++ b/xen/scripts/Makefile.asm-generic
@@ -34,7 +34,7 @@ unwanted    := $(filter-out $(generic-y) $(generated-y),$(old-headers))
 quiet_cmd_wrap = WRAP    $@
       cmd_wrap = \
 	arch=$$(echo $@ | sed -n 's:.*arch/\([^/]*\)/.*:\1:p' | tr a-z A-Z); \
-	upper=$$(echo $*.h | tr a-z A-Z | tr '/.' '__'); \
+	upper=$$(echo $*.h | tr a-z A-Z | tr '/.-' '__'); \
 	echo "\#ifndef $${arch}_GENERIC_$${upper}" > $@.new; \
 	echo "\#define $${arch}_GENERIC_$${upper}" >> $@.new; \
 	echo "\#include <asm-generic/$*.h>" >> $@.new; \
-- 
2.43.0
Re: [XEN PATCH] xen: fix header guard generation for asm-generic headers
Posted by Jan Beulich 4 months, 1 week ago
On 21.06.2025 11:58, Nicola Vetrini wrote:
> Dashes were wrongly not translated into underscores, thus generating
> an unexpected guard identifier.
> 
> Fixes: ee79f378311b ("xen: add header guards to generated asm generic headers")
> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
> ---
>  xen/scripts/Makefile.asm-generic | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/xen/scripts/Makefile.asm-generic b/xen/scripts/Makefile.asm-generic
> index b0828018080d..f6850758c54b 100644
> --- a/xen/scripts/Makefile.asm-generic
> +++ b/xen/scripts/Makefile.asm-generic
> @@ -34,7 +34,7 @@ unwanted    := $(filter-out $(generic-y) $(generated-y),$(old-headers))
>  quiet_cmd_wrap = WRAP    $@
>        cmd_wrap = \
>  	arch=$$(echo $@ | sed -n 's:.*arch/\([^/]*\)/.*:\1:p' | tr a-z A-Z); \
> -	upper=$$(echo $*.h | tr a-z A-Z | tr '/.' '__'); \
> +	upper=$$(echo $*.h | tr a-z A-Z | tr '/.-' '__'); \

Aiui the other argument also needs to change, to '___'. While some tr implementations
may cope, the spec is quite clear:

"When the -d option is not specified:

    Each input character found in the array specified by string1 shall be replaced by the character in the same relative position in the array specified by string2. When the array specified by string2 is shorter that the one specified by string1, the results are unspecified."

Easy enough to adjust while committing, I suppose.

Jan
Re: [XEN PATCH] xen: fix header guard generation for asm-generic headers
Posted by Jan Beulich 4 months, 1 week ago
On 23.06.2025 09:51, Jan Beulich wrote:
> On 21.06.2025 11:58, Nicola Vetrini wrote:
>> Dashes were wrongly not translated into underscores, thus generating
>> an unexpected guard identifier.
>>
>> Fixes: ee79f378311b ("xen: add header guards to generated asm generic headers")
>> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
>> ---
>>  xen/scripts/Makefile.asm-generic | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/xen/scripts/Makefile.asm-generic b/xen/scripts/Makefile.asm-generic
>> index b0828018080d..f6850758c54b 100644
>> --- a/xen/scripts/Makefile.asm-generic
>> +++ b/xen/scripts/Makefile.asm-generic
>> @@ -34,7 +34,7 @@ unwanted    := $(filter-out $(generic-y) $(generated-y),$(old-headers))
>>  quiet_cmd_wrap = WRAP    $@
>>        cmd_wrap = \
>>  	arch=$$(echo $@ | sed -n 's:.*arch/\([^/]*\)/.*:\1:p' | tr a-z A-Z); \
>> -	upper=$$(echo $*.h | tr a-z A-Z | tr '/.' '__'); \
>> +	upper=$$(echo $*.h | tr a-z A-Z | tr '/.-' '__'); \
> 
> Aiui the other argument also needs to change, to '___'. While some tr implementations
> may cope, the spec is quite clear:
> 
> "When the -d option is not specified:
> 
>     Each input character found in the array specified by string1 shall be replaced by the character in the same relative position in the array specified by string2. When the array specified by string2 is shorter that the one specified by string1, the results are unspecified."
> 
> Easy enough to adjust while committing, I suppose.

Except that I notice that this was committed already. Will require another
fixup then, I expect.

Jan
Re: [XEN PATCH] xen: fix header guard generation for asm-generic headers
Posted by Nicola Vetrini 4 months, 1 week ago
On 2025-06-23 10:20, Jan Beulich wrote:
> On 23.06.2025 09:51, Jan Beulich wrote:
>> On 21.06.2025 11:58, Nicola Vetrini wrote:
>>> Dashes were wrongly not translated into underscores, thus generating
>>> an unexpected guard identifier.
>>> 
>>> Fixes: ee79f378311b ("xen: add header guards to generated asm generic 
>>> headers")
>>> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
>>> ---
>>>  xen/scripts/Makefile.asm-generic | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>> 
>>> diff --git a/xen/scripts/Makefile.asm-generic 
>>> b/xen/scripts/Makefile.asm-generic
>>> index b0828018080d..f6850758c54b 100644
>>> --- a/xen/scripts/Makefile.asm-generic
>>> +++ b/xen/scripts/Makefile.asm-generic
>>> @@ -34,7 +34,7 @@ unwanted    := $(filter-out $(generic-y) 
>>> $(generated-y),$(old-headers))
>>>  quiet_cmd_wrap = WRAP    $@
>>>        cmd_wrap = \
>>>  	arch=$$(echo $@ | sed -n 's:.*arch/\([^/]*\)/.*:\1:p' | tr a-z 
>>> A-Z); \
>>> -	upper=$$(echo $*.h | tr a-z A-Z | tr '/.' '__'); \
>>> +	upper=$$(echo $*.h | tr a-z A-Z | tr '/.-' '__'); \
>> 
>> Aiui the other argument also needs to change, to '___'. While some tr 
>> implementations
>> may cope, the spec is quite clear:
>> 
>> "When the -d option is not specified:
>> 
>>     Each input character found in the array specified by string1 shall 
>> be replaced by the character in the same relative position in the 
>> array specified by string2. When the array specified by string2 is 
>> shorter that the one specified by string1, the results are 
>> unspecified."
>> 
>> Easy enough to adjust while committing, I suppose.
> 
> Except that I notice that this was committed already. Will require 
> another
> fixup then, I expect.
> 
> Jan

My bad, GNU tr seems to cope just fine (i tested running on all Xen 
headers) but another fixup is in order.

-- 
Nicola Vetrini, B.Sc.
Software Engineer
BUGSENG (https://bugseng.com)
LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253
Re: [XEN PATCH] xen: fix header guard generation for asm-generic headers
Posted by Stefano Stabellini 4 months, 1 week ago
On Sat, 21 Jun 2025, Nicola Vetrini wrote:
> Dashes were wrongly not translated into underscores, thus generating
> an unexpected guard identifier.
> 
> Fixes: ee79f378311b ("xen: add header guards to generated asm generic headers")
> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>


Thank you so much for the quick fix!!

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>



> ---
>  xen/scripts/Makefile.asm-generic | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/xen/scripts/Makefile.asm-generic b/xen/scripts/Makefile.asm-generic
> index b0828018080d..f6850758c54b 100644
> --- a/xen/scripts/Makefile.asm-generic
> +++ b/xen/scripts/Makefile.asm-generic
> @@ -34,7 +34,7 @@ unwanted    := $(filter-out $(generic-y) $(generated-y),$(old-headers))
>  quiet_cmd_wrap = WRAP    $@
>        cmd_wrap = \
>  	arch=$$(echo $@ | sed -n 's:.*arch/\([^/]*\)/.*:\1:p' | tr a-z A-Z); \
> -	upper=$$(echo $*.h | tr a-z A-Z | tr '/.' '__'); \
> +	upper=$$(echo $*.h | tr a-z A-Z | tr '/.-' '__'); \
>  	echo "\#ifndef $${arch}_GENERIC_$${upper}" > $@.new; \
>  	echo "\#define $${arch}_GENERIC_$${upper}" >> $@.new; \
>  	echo "\#include <asm-generic/$*.h>" >> $@.new; \
> -- 
> 2.43.0
>