ACK: [PATCH] fwts_devicetree: clean up pedantic static analysis warning

ivanhu ivan.hu at canonical.com
Tue Apr 6 05:37:06 UTC 2021


On 3/30/21 6:10 PM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Coverity is warning that prop_len may be uninitialized and prop_buf
> could be null in the fdt_getprop call. Not sure of these are false
> positives, but clean up the warning by initializing prop_len to zero
> and call strcmp on prop_buf only if it is not null.
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>  src/lib/src/fwts_devicetree.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/lib/src/fwts_devicetree.c b/src/lib/src/fwts_devicetree.c
> index 6180f127..82c72000 100644
> --- a/src/lib/src/fwts_devicetree.c
> +++ b/src/lib/src/fwts_devicetree.c
> @@ -76,7 +76,7 @@ bool check_status_property_okay(fwts_framework *fw,
>  	char *prop_string = strstr(my_path, my_prop_string);
>  
>  	if (prop_string) {
> -		int prop_len;
> +		int prop_len = 0;
>  		int node = fdt_path_offset(fw->fdt, prop_string);
>  
>  		if (node >= 0) {
> @@ -85,7 +85,7 @@ bool check_status_property_okay(fwts_framework *fw,
>  			prop_buf = fdt_getprop(fw->fdt, node,
>  					property,
>  					&prop_len);
> -			if (prop_len > 0) {
> +			if (prop_buf && (prop_len > 0)) {
>  				if ((!strcmp(prop_buf, "okay")) ||
>  					(!strcmp(prop_buf, "ok"))) {
>  					return true;


Acked-by: Ivan Hu <ivan.hu at canonical.com>




More information about the fwts-devel mailing list