[PATCH] FIT: let fit_has_image() return bool

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Sep 3 23:59:16 PDT 2025


On 04.09.25 07:53, Sascha Hauer wrote:
> The return value of fit_has_image() is treated as bool by most callers.
> It could return an error code though which by the callers would be
> evaluated to true. Change the return type to bool and return false
> instead of an error code to meet the callers expectations.
> 
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>

Reviewed-by: Ahmad Fatoum <a.fatoum at pengutronix.de>

> ---
>  common/image-fit.c  | 10 +++++-----
>  include/image-fit.h |  4 ++--
>  2 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/common/image-fit.c b/common/image-fit.c
> index 6d241338e4..6b44a79e9d 100644
> --- a/common/image-fit.c
> +++ b/common/image-fit.c
> @@ -491,19 +491,19 @@ static int fit_image_verify_signature(struct fit_handle *handle,
>  	return ret;
>  }
>  
> -int fit_has_image(struct fit_handle *handle, void *configuration,
> -		  const char *name)
> +bool fit_has_image(struct fit_handle *handle, void *configuration,
> +		   const char *name)
>  {
>  	const char *unit;
>  	struct device_node *conf_node = configuration;
>  
>  	if (!conf_node)
> -		return -EINVAL;
> +		return false;
>  
>  	if (of_property_read_string(conf_node, name, &unit))
> -		return 0;
> +		return false;
>  
> -	return 1;
> +	return true;
>  }
>  
>  static int fit_get_address(struct device_node *image, const char *property,
> diff --git a/include/image-fit.h b/include/image-fit.h
> index f9791ff251..c332f77bd3 100644
> --- a/include/image-fit.h
> +++ b/include/image-fit.h
> @@ -34,8 +34,8 @@ struct fit_handle *fit_open_buf(const void *buf, size_t len, bool verbose,
>  void *fit_open_configuration(struct fit_handle *handle, const char *name,
>  			     bool (*match_valid)(struct fit_handle *handle,
>  						 struct device_node *config));
> -int fit_has_image(struct fit_handle *handle, void *configuration,
> -		  const char *name);
> +bool fit_has_image(struct fit_handle *handle, void *configuration,
> +		   const char *name);
>  int fit_open_image(struct fit_handle *handle, void *configuration,
>  		   const char *name, const void **outdata,
>  		   unsigned long *outsize);


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list