diff mbox series

devicetree: dt_sysinfo: make variable len a size_t

Message ID 20210412103408.1276843-1-colin.king@canonical.com
State Accepted
Headers show
Series devicetree: dt_sysinfo: make variable len a size_t | expand

Commit Message

Colin Ian King April 12, 2021, 10:34 a.m. UTC
From: Colin Ian King <colin.king@canonical.com>

The return from strlen is size_t so make len size_t to match the
types. Also clean up some white spacing on math operators on lengths
to match fwts coding style.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/devicetree/dt_sysinfo/dt_sysinfo.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Alex Hung April 12, 2021, 7:26 p.m. UTC | #1
On 2021-04-12 4:34 a.m., Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The return from strlen is size_t so make len size_t to match the
> types. Also clean up some white spacing on math operators on lengths
> to match fwts coding style.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/devicetree/dt_sysinfo/dt_sysinfo.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/devicetree/dt_sysinfo/dt_sysinfo.c b/src/devicetree/dt_sysinfo/dt_sysinfo.c
> index 51caa807..7c3fae6f 100644
> --- a/src/devicetree/dt_sysinfo/dt_sysinfo.c
> +++ b/src/devicetree/dt_sysinfo/dt_sysinfo.c
> @@ -199,21 +199,21 @@ static bool dt_fdt_stringlist_contains_last(
>  	const int listlen,
>  	const char *str)
>  {
> -	const int len = strlen(str);
> +	const size_t len = strlen(str);
>  	const char *p;
>  
>  	/* checking for either str only or last in string */
>  	if (listlen < 2) /* need at least one byte plus nul */
>  		return false;
>  
> -	p = memrchr(strlist, '\0', listlen-1);
> +	p = memrchr(strlist, '\0', listlen - 1);
>  	if (p) {
>  		p++;
>  	} else {
>  		p = strlist;
>  	}
>  
> -	return !memcmp(str, p, len+1);
> +	return !memcmp(str, p, len + 1);
>  }
>  
>  static bool machine_matches_reference_model(fwts_framework *fw,
> 


Acked-by: Alex Hung <alex.hung@canonical.com>
ivanhu April 21, 2021, 7:20 a.m. UTC | #2
On 4/12/21 6:34 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The return from strlen is size_t so make len size_t to match the
> types. Also clean up some white spacing on math operators on lengths
> to match fwts coding style.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/devicetree/dt_sysinfo/dt_sysinfo.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/devicetree/dt_sysinfo/dt_sysinfo.c b/src/devicetree/dt_sysinfo/dt_sysinfo.c
> index 51caa807..7c3fae6f 100644
> --- a/src/devicetree/dt_sysinfo/dt_sysinfo.c
> +++ b/src/devicetree/dt_sysinfo/dt_sysinfo.c
> @@ -199,21 +199,21 @@ static bool dt_fdt_stringlist_contains_last(
>  	const int listlen,
>  	const char *str)
>  {
> -	const int len = strlen(str);
> +	const size_t len = strlen(str);
>  	const char *p;
>  
>  	/* checking for either str only or last in string */
>  	if (listlen < 2) /* need at least one byte plus nul */
>  		return false;
>  
> -	p = memrchr(strlist, '\0', listlen-1);
> +	p = memrchr(strlist, '\0', listlen - 1);
>  	if (p) {
>  		p++;
>  	} else {
>  		p = strlist;
>  	}
>  
> -	return !memcmp(str, p, len+1);
> +	return !memcmp(str, p, len + 1);
>  }
>  
>  static bool machine_matches_reference_model(fwts_framework *fw,
> 


Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff mbox series

Patch

diff --git a/src/devicetree/dt_sysinfo/dt_sysinfo.c b/src/devicetree/dt_sysinfo/dt_sysinfo.c
index 51caa807..7c3fae6f 100644
--- a/src/devicetree/dt_sysinfo/dt_sysinfo.c
+++ b/src/devicetree/dt_sysinfo/dt_sysinfo.c
@@ -199,21 +199,21 @@  static bool dt_fdt_stringlist_contains_last(
 	const int listlen,
 	const char *str)
 {
-	const int len = strlen(str);
+	const size_t len = strlen(str);
 	const char *p;
 
 	/* checking for either str only or last in string */
 	if (listlen < 2) /* need at least one byte plus nul */
 		return false;
 
-	p = memrchr(strlist, '\0', listlen-1);
+	p = memrchr(strlist, '\0', listlen - 1);
 	if (p) {
 		p++;
 	} else {
 		p = strlist;
 	}
 
-	return !memcmp(str, p, len+1);
+	return !memcmp(str, p, len + 1);
 }
 
 static bool machine_matches_reference_model(fwts_framework *fw,