[Concept,04/30] fit: Remove unused len parameter from fit_get_name()

Message ID 20251120025614.2215587-5-sjg@u-boot.org
State New
Headers
Series fit: Improve and test the code to print FIT info |

Commit Message

Simon Glass Nov. 20, 2025, 2:55 a.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Remove the unused third parameter (len) from fit_get_name(). All uses of
this function pass NULL for this parameter.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 boot/image-cipher.c            |  2 +-
 boot/image-fit-sig.c           | 24 ++++++++++++------------
 boot/image-fit.c               | 29 ++++++++++++++---------------
 common/spl/spl_fit.c           | 12 ++++++------
 common/update.c                |  4 ++--
 drivers/fpga/socfpga_arria10.c |  2 +-
 include/image.h                |  6 +++---
 tools/fit_image.c              |  2 +-
 tools/fit_info.c               |  2 +-
 tools/image-host.c             | 30 +++++++++++++++---------------
 10 files changed, 56 insertions(+), 57 deletions(-)
  

Patch

diff --git a/boot/image-cipher.c b/boot/image-cipher.c
index 9d389f26cea..66fae2153cd 100644
--- a/boot/image-cipher.c
+++ b/boot/image-cipher.c
@@ -76,7 +76,7 @@  static int fit_image_setup_decrypt(struct image_cipher_info *info,
 	char *algo_name;
 	int ret;
 
-	node_name = fit_get_name(fit, image_noffset, NULL);
+	node_name = fit_get_name(fit, image_noffset);
 	if (!node_name) {
 		printf("Can't get node name\n");
 		return -1;
diff --git a/boot/image-fit-sig.c b/boot/image-fit-sig.c
index a121de60ae2..8dee5698236 100644
--- a/boot/image-fit-sig.c
+++ b/boot/image-fit-sig.c
@@ -145,7 +145,7 @@  static int fit_image_verify_sig(const void *fit, int image_noffset,
 
 	/* Process all hash subnodes of the component image node */
 	fdt_for_each_subnode(noffset, fit, image_noffset) {
-		const char *name = fit_get_name(fit, noffset, NULL);
+		const char *name = fit_get_name(fit, noffset);
 
 		/*
 		 * We don't support this since libfdt considers names with the
@@ -178,8 +178,8 @@  static int fit_image_verify_sig(const void *fit, int image_noffset,
 
 error:
 	printf(" error!\n%s for '%s' hash node in '%s' image node\n",
-	       err_msg, fit_get_name(fit, noffset, NULL),
-	       fit_get_name(fit, image_noffset, NULL));
+	       err_msg, fit_get_name(fit, noffset),
+	       fit_get_name(fit, image_noffset));
 	return -1;
 }
 
@@ -212,7 +212,7 @@  int fit_image_verify_required_sigs(const void *fit, int image_noffset,
 					   key_blob, noffset);
 		if (ret) {
 			printf("Failed to verify required signature '%s'\n",
-			       fit_get_name(key_blob, noffset, NULL));
+			       fit_get_name(key_blob, noffset));
 			return ret;
 		}
 		verify_count++;
@@ -277,10 +277,10 @@  static int fit_config_check_sig(const void *fit, int noffset, int conf_noffset,
 	char path[200];
 	int count;
 
-	config_name = fit_get_name(fit, conf_noffset, NULL);
+	config_name = fit_get_name(fit, conf_noffset);
 	debug("%s: fdt=%p, conf='%s', sig='%s'\n", __func__, key_blob,
-	      fit_get_name(fit, noffset, NULL),
-	      fit_get_name(key_blob, required_keynode, NULL));
+	      fit_get_name(fit, noffset),
+	      fit_get_name(key_blob, required_keynode));
 	*err_msgp = NULL;
 	if (fit_image_setup_verify(&info, fit, noffset, key_blob,
 				   required_keynode, err_msgp))
@@ -421,7 +421,7 @@  static int fit_config_verify_key(const void *fit, int conf_noffset,
 
 	/* Process all hash subnodes of the component conf node */
 	fdt_for_each_subnode(noffset, fit, conf_noffset) {
-		const char *name = fit_get_name(fit, noffset, NULL);
+		const char *name = fit_get_name(fit, noffset);
 
 		if (!strncmp(name, FIT_SIG_NODENAME,
 			     strlen(FIT_SIG_NODENAME))) {
@@ -448,8 +448,8 @@  static int fit_config_verify_key(const void *fit, int conf_noffset,
 
 error:
 	printf(" error!\n%s for '%s' hash node in '%s' config node\n",
-	       err_msg, fit_get_name(fit, noffset, NULL),
-	       fit_get_name(fit, conf_noffset, NULL));
+	       err_msg, fit_get_name(fit, noffset),
+	       fit_get_name(fit, conf_noffset));
 	return -EPERM;
 }
 
@@ -469,7 +469,7 @@  error:
 static int fit_config_verify_required_keys(const void *fit, int conf_noffset,
 					   const void *key_blob)
 {
-	const char *name = fit_get_name(fit, conf_noffset, NULL);
+	const char *name = fit_get_name(fit, conf_noffset);
 	int noffset;
 	int key_node;
 	int verified = 0;
@@ -525,7 +525,7 @@  static int fit_config_verify_required_keys(const void *fit, int conf_noffset,
 		if (ret) {
 			if (reqd_policy_all) {
 				printf("Failed to verify required signature '%s'\n",
-				       fit_get_name(key_blob, noffset, NULL));
+				       fit_get_name(key_blob, noffset));
 				return ret;
 			}
 		} else {
diff --git a/boot/image-fit.c b/boot/image-fit.c
index 7bcdb97985a..eb47c00cc01 100644
--- a/boot/image-fit.c
+++ b/boot/image-fit.c
@@ -148,7 +148,7 @@  static void fit_get_debug(const void *fit, int noffset,
 		char *prop_name, int err)
 {
 	debug("Can't get '%s' property from FIT 0x%08lx, node: offset %d, name %s (%s)\n",
-	      prop_name, (ulong)fit, noffset, fit_get_name(fit, noffset, NULL),
+	      prop_name, (ulong)fit, noffset, fit_get_name(fit, noffset),
 	      fdt_strerror(err));
 }
 
@@ -205,8 +205,7 @@  static void fit_image_print_data(const void *fit, int noffset, const char *p,
 	bool required;
 	int ret, i;
 
-	debug("%s  %s node:    '%s'\n", p, type,
-	      fit_get_name(fit, noffset, NULL));
+	debug("%s  %s node:    '%s'\n", p, type, fit_get_name(fit, noffset));
 	printf("%s  %s algo:    ", p, type);
 	if (fit_image_hash_get_algo(fit, noffset, &algo)) {
 		printf("invalid/unsupported\n");
@@ -271,7 +270,7 @@  static void fit_image_print_verification_data(const void *fit, int noffset,
 	 * Multiple hash/signature nodes require unique unit node
 	 * names, e.g. hash-1, hash-2, signature-1, signature-2, etc.
 	 */
-	name = fit_get_name(fit, noffset, NULL);
+	name = fit_get_name(fit, noffset);
 	if (!strncmp(name, FIT_HASH_NODENAME, strlen(FIT_HASH_NODENAME))) {
 		fit_image_print_data(fit, noffset, p, "Hash");
 	} else if (!strncmp(name, FIT_SIG_NODENAME,
@@ -436,7 +435,7 @@  void fit_print_contents(const void *fit)
 			 * i.e. component image node.
 			 */
 			printf("%s Image %u (%s)\n", p, count++,
-			       fit_get_name(fit, noffset, NULL));
+			       fit_get_name(fit, noffset));
 
 			fit_image_print(fit, noffset, p);
 		}
@@ -466,7 +465,7 @@  void fit_print_contents(const void *fit)
 			 * i.e. configuration node.
 			 */
 			printf("%s Configuration %u (%s)\n", p, count++,
-			       fit_get_name(fit, noffset, NULL));
+			       fit_get_name(fit, noffset));
 
 			fit_conf_print(fit, noffset, p);
 		}
@@ -1215,7 +1214,7 @@  int fit_set_timestamp(void *fit, int noffset, time_t timestamp)
 				sizeof(uint32_t));
 	if (ret) {
 		debug("Can't set '%s' property for '%s' node (%s)\n",
-		      FIT_TIMESTAMP_PROP, fit_get_name(fit, noffset, NULL),
+		      FIT_TIMESTAMP_PROP, fit_get_name(fit, noffset),
 		      fdt_strerror(ret));
 		return ret == -FDT_ERR_NOSPACE ? -ENOSPC : -1;
 	}
@@ -1352,7 +1351,7 @@  int fit_image_verify_with_data(const void *fit, int image_noffset,
 
 	/* Process all hash subnodes of the component image node */
 	fdt_for_each_subnode(noffset, fit, image_noffset) {
-		const char *name = fit_get_name(fit, noffset, NULL);
+		const char *name = fit_get_name(fit, noffset);
 
 		/*
 		 * Check subnode name, must be equal to "hash".
@@ -1393,8 +1392,8 @@  int fit_image_verify_with_data(const void *fit, int image_noffset,
 
 error:
 	printf(" error!\n%s for '%s' hash node in '%s' image node\n",
-	       err_msg, fit_get_name(fit, noffset, NULL),
-	       fit_get_name(fit, image_noffset, NULL));
+	       err_msg, fit_get_name(fit, noffset),
+	       fit_get_name(fit, image_noffset));
 	return 0;
 }
 
@@ -1413,7 +1412,7 @@  error:
  */
 int fit_image_verify(const void *fit, int image_noffset)
 {
-	const char *name = fit_get_name(fit, image_noffset, NULL);
+	const char *name = fit_get_name(fit, image_noffset);
 	const void	*data;
 	size_t		size;
 	char		*err_msg = "";
@@ -1437,7 +1436,7 @@  int fit_image_verify(const void *fit, int image_noffset)
 
 err:
 	printf("error!\n%s in '%s' image node\n", err_msg,
-	       fit_get_name(fit, image_noffset, NULL));
+	       fit_get_name(fit, image_noffset));
 	return 0;
 }
 
@@ -1480,7 +1479,7 @@  int fit_all_image_verify(const void *fit)
 			 * i.e. component image node.
 			 */
 			printf("   Hash(es) for Image %u (%s): ", count,
-			       fit_get_name(fit, noffset, NULL));
+			       fit_get_name(fit, noffset));
 			count++;
 
 			if (!fit_image_verify(fit, noffset))
@@ -2127,7 +2126,7 @@  static int select_from_config(const void *fit, struct bootm_headers *images,
 			return -ENOPKG;
 	}
 
-	*fit_unamep = fit_get_name(fit, noffset, NULL);
+	*fit_unamep = fit_get_name(fit, noffset);
 
 	return noffset;
 }
@@ -2639,7 +2638,7 @@  int boot_get_fdt_fit(struct bootm_headers *images, ulong addr,
 		if (i < count) {
 			noffset = fit_conf_get_prop_node_index(fit, cfg_noffset,
 							       FIT_FDT_PROP, i);
-			uname = fit_get_name(fit, noffset, NULL);
+			uname = fit_get_name(fit, noffset);
 			uconfig = NULL;
 		} else {
 			if (!next_config)
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 49b4df60560..b4049e41c2c 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -255,7 +255,7 @@  static int load_simple_fit(struct spl_load_info *info, ulong fit_offset,
 	if (fit_image_get_load(fit, node, &load_addr)) {
 		if (!image_info->load_addr) {
 			printf("Can't load %s: No load address and no buffer\n",
-			       fit_get_name(fit, node, NULL));
+			       fit_get_name(fit, node));
 			return -ENOBUFS;
 		}
 		load_addr = image_info->load_addr;
@@ -281,7 +281,7 @@  static int load_simple_fit(struct spl_load_info *info, ulong fit_offset,
 		/* Dont bother to copy 0 byte data, but warn, though */
 		if (!len) {
 			log_warning("%s: Skip load '%s': image size is 0!\n",
-				    __func__, fit_get_name(fit, node, NULL));
+				    __func__, fit_get_name(fit, node));
 			return 0;
 		}
 
@@ -318,7 +318,7 @@  static int load_simple_fit(struct spl_load_info *info, ulong fit_offset,
 
 	if (CONFIG_IS_ENABLED(FIT_SIGNATURE)) {
 		printf("## Checking hash(es) for Image %s ... ",
-		       fit_get_name(fit, node, NULL));
+		       fit_get_name(fit, node));
 		if (!fit_image_verify_with_data(fit, node, gd_fdt_blob(), src,
 						length))
 			return -EPERM;
@@ -489,12 +489,12 @@  static int spl_fit_append_fdt(struct spl_image_info *spl_image,
 							(void *)image_info.load_addr);
 			if (ret) {
 				pr_err("failed to apply DT overlay %s\n",
-				       fit_get_name(ctx->fit, node, NULL));
+				       fit_get_name(ctx->fit, node));
 				break;
 			}
 
 			debug("%s: DT overlay %s applied\n", __func__,
-			      fit_get_name(ctx->fit, node, NULL));
+			      fit_get_name(ctx->fit, node));
 		}
 		free(tmpbuffer);
 		if (ret)
@@ -720,7 +720,7 @@  static int spl_simple_fit_parse(struct spl_fit_info *ctx)
 
 	if (IS_ENABLED(CONFIG_SPL_FIT_SIGNATURE)) {
 		printf("## Checking hash(es) for config %s ... ",
-		       fit_get_name(ctx->fit, ctx->conf_node, NULL));
+		       fit_get_name(ctx->fit, ctx->conf_node));
 		if (fit_config_verify(ctx->fit, ctx->conf_node))
 			return -EPERM;
 		puts("OK\n");
diff --git a/common/update.c b/common/update.c
index 6801b49479d..8f44a64592a 100644
--- a/common/update.c
+++ b/common/update.c
@@ -278,7 +278,7 @@  got_update_file:
 		if (ndepth != 1)
 			goto next_node;
 
-		fit_image_name = (char *)fit_get_name(fit, noffset, NULL);
+		fit_image_name = (char *)fit_get_name(fit, noffset);
 		printf("Processing update '%s' :", fit_image_name);
 
 		if (!fit_image_verify(fit, noffset)) {
@@ -354,7 +354,7 @@  int fit_update(const void *fit)
 		if (ndepth != 1)
 			goto next_node;
 
-		fit_image_name = (char *)fit_get_name(fit, noffset, NULL);
+		fit_image_name = (char *)fit_get_name(fit, noffset);
 		printf("Processing update '%s' :", fit_image_name);
 
 		if (!fit_image_verify(fit, noffset)) {
diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index e9822b2bb0e..317bb261bc8 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -613,7 +613,7 @@  static int first_loading_rbf_to_buffer(struct udevice *dev,
 		images_noffset = fit_conf_get_prop_node_index(buffer_p,
 							     confs_noffset,
 							     FIT_FPGA_PROP, i);
-		uname = fit_get_name(buffer_p, images_noffset, NULL);
+		uname = fit_get_name(buffer_p, images_noffset);
 		if (uname) {
 			debug("FPGA: %s\n", uname);
 
diff --git a/include/image.h b/include/image.h
index a972e3f6921..33eb5d71e79 100644
--- a/include/image.h
+++ b/include/image.h
@@ -1225,15 +1225,15 @@  ulong fit_get_end(const void *fit);
 /**
  * fit_get_name - get FIT node name
  * @fit: pointer to the FIT format image header
+ * @noffset: node offset
  *
  * returns:
  *     NULL, on error
  *     pointer to node name, on success
  */
-static inline const char *fit_get_name(const void *fit_hdr,
-		int noffset, int *len)
+static inline const char *fit_get_name(const void *fit_hdr, int noffset)
 {
-	return fdt_get_name(fit_hdr, noffset, len);
+	return fdt_get_name(fit_hdr, noffset, NULL);
 }
 
 /**
diff --git a/tools/fit_image.c b/tools/fit_image.c
index 013242cd204..80f9020d29d 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -972,7 +972,7 @@  static int fit_extract_contents(void *ptr, struct imgtool *itl)
 			 */
 			if (itl->pflag == count) {
 				printf("Extracted:\n%s Image %u (%s)\n", p,
-				       count, fit_get_name(fit, noffset, NULL));
+				       count, fit_get_name(fit, noffset));
 
 				fit_image_print(fit, noffset, p);
 
diff --git a/tools/fit_info.c b/tools/fit_info.c
index b2642ec5b76..3c049a7f7e1 100644
--- a/tools/fit_info.c
+++ b/tools/fit_info.c
@@ -98,7 +98,7 @@  int main(int argc, char **argv)
 		exit(EXIT_FAILURE);
 	}
 
-	printf("NAME: %s\n", fit_get_name(fit_blob, nodeoffset, NULL));
+	printf("NAME: %s\n", fit_get_name(fit_blob, nodeoffset));
 	printf("LEN: %d\n", len);
 	printf("OFF: %d\n", (int)(nodep - fit_blob));
 	(void) munmap((void *)fit_blob, fsbuf.st_size);
diff --git a/tools/image-host.c b/tools/image-host.c
index a9b86902763..99594f89de0 100644
--- a/tools/image-host.c
+++ b/tools/image-host.c
@@ -46,7 +46,7 @@  static int fit_set_hash_value(void *fit, int noffset, uint8_t *value,
 	ret = fdt_setprop(fit, noffset, FIT_VALUE_PROP, value, value_len);
 	if (ret) {
 		fprintf(stderr, "Can't set hash '%s' property for '%s' node(%s)\n",
-			FIT_VALUE_PROP, fit_get_name(fit, noffset, NULL),
+			FIT_VALUE_PROP, fit_get_name(fit, noffset),
 			fdt_strerror(ret));
 		return ret == -FDT_ERR_NOSPACE ? -ENOSPC : -EIO;
 	}
@@ -76,7 +76,7 @@  static int fit_image_process_hash(void *fit, const char *image_name,
 	const char *algo;
 	int ret;
 
-	node_name = fit_get_name(fit, noffset, NULL);
+	node_name = fit_get_name(fit, noffset);
 
 	if (fit_image_hash_get_algo(fit, noffset, &algo)) {
 		fprintf(stderr,
@@ -176,7 +176,7 @@  static int fit_image_setup_sig(struct image_sign_info *info,
 	const char *node_name;
 	const char *padding_name;
 
-	node_name = fit_get_name(fit, noffset, NULL);
+	node_name = fit_get_name(fit, noffset);
 	if (!algo_name) {
 		if (fit_image_hash_get_algo(fit, noffset, &algo_name)) {
 			fprintf(stderr,
@@ -247,7 +247,7 @@  static int fit_image_process_sig(const char *keydir, const char *keyfile,
 				engine_id, algo_name))
 		return -1;
 
-	node_name = fit_get_name(fit, noffset, NULL);
+	node_name = fit_get_name(fit, noffset);
 	region.data = data;
 	region.size = size;
 	ret = info.crypto->sign(&info, &region, 1, &value, &value_len);
@@ -585,7 +585,7 @@  int fit_image_cipher_data(const char *keydir, void *keydest,
 	int cipher_node_offset, len;
 
 	/* Get image name */
-	image_name = fit_get_name(fit, image_noffset, NULL);
+	image_name = fit_get_name(fit, image_noffset);
 	if (!image_name) {
 		fprintf(stderr, "Can't get image name\n");
 		return -1;
@@ -677,7 +677,7 @@  int fit_image_add_verification_data(const char *keydir, const char *keyfile,
 		return -1;
 	}
 
-	image_name = fit_get_name(fit, image_noffset, NULL);
+	image_name = fit_get_name(fit, image_noffset);
 
 	/* Process all hash subnodes of the component image node */
 	for (noffset = fdt_first_subnode(fit, image_noffset);
@@ -691,7 +691,7 @@  int fit_image_add_verification_data(const char *keydir, const char *keyfile,
 		 * Multiple hash nodes require unique unit node
 		 * names, e.g. hash-1, hash-2, signature-1, etc.
 		 */
-		node_name = fit_get_name(fit, noffset, NULL);
+		node_name = fit_get_name(fit, noffset);
 		if (!strncmp(node_name, FIT_HASH_NODENAME,
 			     strlen(FIT_HASH_NODENAME))) {
 			ret = fit_image_process_hash(fit, image_name, noffset,
@@ -809,7 +809,7 @@  static int fit_config_add_hash(const void *fit, int image_noffset,
 	for (noffset = fdt_first_subnode(fit, image_noffset);
 	     noffset >= 0;
 	     noffset = fdt_next_subnode(fit, noffset)) {
-		const char *name = fit_get_name(fit, noffset, NULL);
+		const char *name = fit_get_name(fit, noffset);
 
 		if (strncmp(name, FIT_HASH_NODENAME,
 			    strlen(FIT_HASH_NODENAME)))
@@ -884,8 +884,8 @@  static int fit_config_get_hash_list(const void *fit, int conf_noffset,
 	int image_count;
 	int ret, len;
 
-	conf_name = fit_get_name(fit, conf_noffset, NULL);
-	sig_name = fit_get_name(fit, sig_offset, NULL);
+	conf_name = fit_get_name(fit, conf_noffset);
+	sig_name = fit_get_name(fit, sig_offset);
 
 	/*
 	 * Build a list of nodes we need to hash. We always need the root
@@ -991,8 +991,8 @@  static int fit_config_get_regions(const void *fit, int conf_noffset,
 	char *region_prop;
 	int ret, len;
 
-	conf_name = fit_get_name(fit, conf_noffset, NULL);
-	sig_name = fit_get_name(fit, sig_offset, NULL);
+	conf_name = fit_get_name(fit, conf_noffset);
+	sig_name = fit_get_name(fit, sig_offset);
 	debug("%s: conf='%s', sig='%s'\n", __func__, conf_name, sig_name);
 
 	/* Get a list of nodes we want to hash */
@@ -1084,7 +1084,7 @@  static int fit_config_process_sig(const char *keydir, const char *keyfile,
 	uint value_len;
 	int ret;
 
-	node_name = fit_get_name(fit, noffset, NULL);
+	node_name = fit_get_name(fit, noffset);
 	if (fit_config_get_regions(fit, conf_noffset, noffset, &region,
 				   &region_count, &region_prop,
 				   &region_proplen))
@@ -1148,7 +1148,7 @@  static int fit_config_add_verification_data(const char *keydir,
 	const char *conf_name;
 	int noffset;
 
-	conf_name = fit_get_name(fit, conf_noffset, NULL);
+	conf_name = fit_get_name(fit, conf_noffset);
 
 	/* Process all hash subnodes of the configuration node */
 	for (noffset = fdt_first_subnode(fit, conf_noffset);
@@ -1157,7 +1157,7 @@  static int fit_config_add_verification_data(const char *keydir,
 		const char *node_name;
 		int ret = 0;
 
-		node_name = fit_get_name(fit, noffset, NULL);
+		node_name = fit_get_name(fit, noffset);
 		if (!strncmp(node_name, FIT_SIG_NODENAME,
 			     strlen(FIT_SIG_NODENAME))) {
 			ret = fit_config_process_sig(keydir, keyfile, keydest,