ACK: [PATCH] Fix warnings on fdt_getprop calls

ivanhu ivan.hu at canonical.com
Tue Apr 6 05:40:42 UTC 2021


On 3/30/21 7:11 PM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> There are several calls that get device tree values that pass an
> uninitalized length parameter and pedantic static analyzers throw
> a warning on this.  Clean this up by initializing the lengths to
> avoid this warning.
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>  src/devicetree/dt_sysinfo/dt_sysinfo.c | 2 +-
>  src/lib/src/fwts_devicetree.c          | 2 +-
>  src/opal/cpu_info.c                    | 2 +-
>  src/opal/mem_info.c                    | 2 +-
>  src/opal/reserv_mem.c                  | 2 +-
>  5 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/src/devicetree/dt_sysinfo/dt_sysinfo.c b/src/devicetree/dt_sysinfo/dt_sysinfo.c
> index c93c7cd9..8ee4a912 100644
> --- a/src/devicetree/dt_sysinfo/dt_sysinfo.c
> +++ b/src/devicetree/dt_sysinfo/dt_sysinfo.c
> @@ -265,7 +265,7 @@ static bool machine_matches_reference_model(fwts_framework *fw,
>  
>  static int dt_sysinfo_check_ref_plat_compatible(fwts_framework *fw)
>  {
> -	int node, compat_len, model_len;
> +	int node, compat_len = 0, model_len = 0;
>  
>  	node = fdt_path_offset(fw->fdt, "/");
>  	if (node < 0) {
> diff --git a/src/lib/src/fwts_devicetree.c b/src/lib/src/fwts_devicetree.c
> index 82c72000..5556446c 100644
> --- a/src/lib/src/fwts_devicetree.c
> +++ b/src/lib/src/fwts_devicetree.c
> @@ -186,7 +186,7 @@ int fwts_dt_property_read_u32(
>  	const char *pname,
>  	int *value)
>  {
> -	int len;
> +	int len = 0;
>  	const int *buf;
>  
>  	buf = fdt_getprop(fdt, offset, pname, &len);
> diff --git a/src/opal/cpu_info.c b/src/opal/cpu_info.c
> index d9554579..a3e46239 100644
> --- a/src/opal/cpu_info.c
> +++ b/src/opal/cpu_info.c
> @@ -36,7 +36,7 @@ static int get_xscom_property(fwts_framework *fw,
>  	char *prop_string = strstr(my_path, "/xscom");
>  
>  	if (prop_string) {
> -		int prop_len;
> +		int prop_len = 0;
>  		int node = fdt_path_offset(fw->fdt, prop_string);
>  
>  		if (node >= 0) {
> diff --git a/src/opal/mem_info.c b/src/opal/mem_info.c
> index e78eaff9..ac8631d3 100644
> --- a/src/opal/mem_info.c
> +++ b/src/opal/mem_info.c
> @@ -43,7 +43,7 @@ static int get_dimm_property(
>  
>  		if (node >= 0) {
>  			const char *prop_buf;
> -			int prop_len;
> +			int prop_len = 0;
>  
>  			prop_buf = fdt_getprop(fw->fdt, node,
>  					property,
> diff --git a/src/opal/reserv_mem.c b/src/opal/reserv_mem.c
> index 1b200a0d..2195f2aa 100644
> --- a/src/opal/reserv_mem.c
> +++ b/src/opal/reserv_mem.c
> @@ -128,7 +128,7 @@ static int reserv_mem_limits_test(fwts_framework *fw)
>  	const char *region_names;
>  	const uint64_t *ranges;
>  	reserve_region_t *regions;
> -	int  offset, len, nr_regions, rc, j;
> +	int  offset, len = 0, nr_regions, rc, j;
>  	plat_config_t configstruct = {0, 0, 0};
>  
>  	get_config(fw, CONFIG_FILENAME, &configstruct);

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




More information about the fwts-devel mailing list