diff mbox series

[U-Boot] fastboot: Replace literal 32 with PART_NAME_LEN

Message ID 20190409053005.19801-1-alex.kiernan@gmail.com
State Accepted
Commit b762aa126e648fa9bc62fc8997b01a4a73089367
Delegated to: Lukasz Majewski
Headers show
Series [U-Boot] fastboot: Replace literal 32 with PART_NAME_LEN | expand

Commit Message

Alex Kiernan April 9, 2019, 5:30 a.m. UTC
Where we have to compute partition names, rather than using a hardcoded
32 for the partition name length, replace with PART_NAME_LEN.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
---

 drivers/fastboot/fb_mmc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Eugeniu Rosca April 9, 2019, 6:24 p.m. UTC | #1
Running `md5sum drivers/fastboot/fb_mmc.o` before and after the change
returns the same result, so this is expectedly a non-functional
change.

In addition, `git grep -w 32 --  drivers/fastboot/` reveals no other
occurrences of the magic number, except in below line where it stands
for something unrelated to partition name length:
drivers/fastboot/fb_command.c:    char cmdbuf[32];

Reviewed-by: Eugeniu Rosca <rosca.eugeniu@gmail.com>
diff mbox series

Patch

diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
index 4c1c7fd2cd8d..3cebedcd5a92 100644
--- a/drivers/fastboot/fb_mmc.c
+++ b/drivers/fastboot/fb_mmc.c
@@ -31,13 +31,13 @@  static int part_get_info_by_name_or_alias(struct blk_desc *dev_desc,
 
 	ret = part_get_info_by_name(dev_desc, name, info);
 	if (ret < 0) {
-		/* strlen("fastboot_partition_alias_") + 32(part_name) + 1 */
-		char env_alias_name[25 + 32 + 1];
+		/* strlen("fastboot_partition_alias_") + PART_NAME_LEN + 1 */
+		char env_alias_name[25 + PART_NAME_LEN + 1];
 		char *aliased_part_name;
 
 		/* check for alias */
 		strcpy(env_alias_name, "fastboot_partition_alias_");
-		strncat(env_alias_name, name, 32);
+		strncat(env_alias_name, name, PART_NAME_LEN);
 		aliased_part_name = env_get(env_alias_name);
 		if (aliased_part_name != NULL)
 			ret = part_get_info_by_name(dev_desc,