mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] FIT: let fit_has_image() return bool
@ 2025-09-04  5:53 Sascha Hauer
  2025-09-04  6:59 ` Ahmad Fatoum
  2025-09-04  8:11 ` Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Sascha Hauer @ 2025-09-04  5:53 UTC (permalink / raw)
  To: Barebox List; +Cc: anis chali

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@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);
-- 
2.47.2




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-09-04  8:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-04  5:53 [PATCH] FIT: let fit_has_image() return bool Sascha Hauer
2025-09-04  6:59 ` Ahmad Fatoum
2025-09-04  8:11 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox