[RFC PATCH 01/77] checks: Use consistent type for strspn() returned value

Herve Codina posted 77 patches 3 weeks, 5 days ago
[RFC PATCH 01/77] checks: Use consistent type for strspn() returned value
Posted by Herve Codina 3 weeks, 5 days ago
strspn() returns a size_t value.

The function is called in several places and in all places this value is
stored in a size_t variable except in check_node_name_chars_strict().

Fix the variable type used in check_node_name_chars_strict().

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
---
 checks.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/checks.c b/checks.c
index 5d09216..041e565 100644
--- a/checks.c
+++ b/checks.c
@@ -324,7 +324,7 @@ ERROR(node_name_chars, check_node_name_chars, NODECHARS);
 static void check_node_name_chars_strict(struct check *c, struct dt_info *dti,
 					 struct node *node)
 {
-	int n = strspn(node->name, c->data);
+	size_t n = strspn(node->name, c->data);
 
 	if (n < node->basenamelen)
 		FAIL(c, dti, node, "Character '%c' not recommended in node name",
-- 
2.52.0
Re: [RFC PATCH 01/77] checks: Use consistent type for strspn() returned value
Posted by David Gibson 3 weeks, 5 days ago
On Mon, Jan 12, 2026 at 03:18:51PM +0100, Herve Codina wrote:
> strspn() returns a size_t value.
> 
> The function is called in several places and in all places this value is
> stored in a size_t variable except in check_node_name_chars_strict().
> 
> Fix the variable type used in check_node_name_chars_strict().
> 
> Signed-off-by: Herve Codina <herve.codina@bootlin.com>

This one makes sense regardless of the rest, so, merged.

> ---
>  checks.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/checks.c b/checks.c
> index 5d09216..041e565 100644
> --- a/checks.c
> +++ b/checks.c
> @@ -324,7 +324,7 @@ ERROR(node_name_chars, check_node_name_chars, NODECHARS);
>  static void check_node_name_chars_strict(struct check *c, struct dt_info *dti,
>  					 struct node *node)
>  {
> -	int n = strspn(node->name, c->data);
> +	size_t n = strspn(node->name, c->data);
>  
>  	if (n < node->basenamelen)
>  		FAIL(c, dti, node, "Character '%c' not recommended in node name",
> -- 
> 2.52.0
> 
> 

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson
Re: [RFC PATCH 01/77] checks: Use consistent type for strspn() returned value
Posted by David Gibson 3 weeks, 5 days ago
On Tue, Jan 13, 2026 at 02:08:54PM +1100, David Gibson wrote:
> On Mon, Jan 12, 2026 at 03:18:51PM +0100, Herve Codina wrote:
> > strspn() returns a size_t value.
> > 
> > The function is called in several places and in all places this value is
> > stored in a size_t variable except in check_node_name_chars_strict().
> > 
> > Fix the variable type used in check_node_name_chars_strict().
> > 
> > Signed-off-by: Herve Codina <herve.codina@bootlin.com>
> 
> This one makes sense regardless of the rest, so, merged.

I spoke too soon.  This causes a compile error:

https://github.com/dgibson/dtc/actions/runs/20944813954/job/60185662154#step:5:130

For some reason it's only showing on the make build, not meson.  I
guess there must be a mismatch in which warnings are enabled.

> 
> > ---
> >  checks.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/checks.c b/checks.c
> > index 5d09216..041e565 100644
> > --- a/checks.c
> > +++ b/checks.c
> > @@ -324,7 +324,7 @@ ERROR(node_name_chars, check_node_name_chars, NODECHARS);
> >  static void check_node_name_chars_strict(struct check *c, struct dt_info *dti,
> >  					 struct node *node)
> >  {
> > -	int n = strspn(node->name, c->data);
> > +	size_t n = strspn(node->name, c->data);
> >  
> >  	if (n < node->basenamelen)
> >  		FAIL(c, dti, node, "Character '%c' not recommended in node name",
> > -- 
> > 2.52.0
> > 
> > 
> 
> -- 
> David Gibson (he or they)	| I'll have my music baroque, and my code
> david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
> 				| around.
> http://www.ozlabs.org/~dgibson



-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson
Re: [RFC PATCH 01/77] checks: Use consistent type for strspn() returned value
Posted by Herve Codina 3 weeks, 5 days ago
Hi David,

On Tue, 13 Jan 2026 15:42:31 +1100
David Gibson <david@gibson.dropbear.id.au> wrote:

> On Tue, Jan 13, 2026 at 02:08:54PM +1100, David Gibson wrote:
> > On Mon, Jan 12, 2026 at 03:18:51PM +0100, Herve Codina wrote:  
> > > strspn() returns a size_t value.
> > > 
> > > The function is called in several places and in all places this value is
> > > stored in a size_t variable except in check_node_name_chars_strict().
> > > 
> > > Fix the variable type used in check_node_name_chars_strict().
> > > 
> > > Signed-off-by: Herve Codina <herve.codina@bootlin.com>  
> > 
> > This one makes sense regardless of the rest, so, merged.  
> 
> I spoke too soon.  This causes a compile error:
> 
> https://github.com/dgibson/dtc/actions/runs/20944813954/job/60185662154#step:5:130
> 
> For some reason it's only showing on the make build, not meson.  I
> guess there must be a mismatch in which warnings are enabled.

I used only meson and so I missed the signed/unsigned comparison warning.

I will remove this signed/unsigned warning in the next iteration.

Best regards,
Hervé
Re: [RFC PATCH 01/77] checks: Use consistent type for strspn() returned value
Posted by Ayush Singh 3 weeks, 5 days ago
On 1/12/26 7:48 PM, Herve Codina wrote:

> strspn() returns a size_t value.
>
> The function is called in several places and in all places this value is
> stored in a size_t variable except in check_node_name_chars_strict().
>
> Fix the variable type used in check_node_name_chars_strict().
>
> Signed-off-by: Herve Codina <herve.codina@bootlin.com>
> ---
>   checks.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/checks.c b/checks.c
> index 5d09216..041e565 100644
> --- a/checks.c
> +++ b/checks.c
> @@ -324,7 +324,7 @@ ERROR(node_name_chars, check_node_name_chars, NODECHARS);
>   static void check_node_name_chars_strict(struct check *c, struct dt_info *dti,
>   					 struct node *node)
>   {
> -	int n = strspn(node->name, c->data);
> +	size_t n = strspn(node->name, c->data);
>   
>   	if (n < node->basenamelen)
>   		FAIL(c, dti, node, "Character '%c' not recommended in node name",


Reviewed-by: Ayush Singh <ayush@beagleboard.org>