hc
2023-11-06 9df731a176aab8e03b984b681b1bea01ccff6644
u-boot/disk/part.c
....@@ -684,8 +684,9 @@
684684 disk_partition_t *info,
685685 bool strict)
686686 {
687
+ __maybe_unused char name_slot[32] = {0};
687688 struct part_driver *part_drv;
688
- char name_slot[32] = {0};
689
+ const char *full_name = name;
689690 int none_slot_try = 1;
690691 int ret, i;
691692
....@@ -695,37 +696,35 @@
695696
696697 if (strict) {
697698 none_slot_try = 0;
698
- strcpy(name_slot, name);
699699 goto lookup;
700700 }
701701
702
+ /* 1. Query partition with A/B slot suffix */
702703 #if defined(CONFIG_ANDROID_AB) || defined(CONFIG_SPL_AB)
703
- char *name_suffix = (char *)name + strlen(name) - 2;
704
+ char *slot = (char *)name + strlen(name) - 2;
704705
705
- /* Fix can not find partition with suffix "_a" & "_b". If with them, clear */
706
- if (!memcmp(name_suffix, "_a", strlen("_a")) ||
707
- !memcmp(name_suffix, "_b", strlen("_b")))
708
- memset(name_suffix, 0, 2);
706
+ if (!strcmp(slot, "_a") || !strcmp(slot, "_b"))
707
+ goto lookup;
709708 #endif
710709 #if defined(CONFIG_ANDROID_AB) && !defined(CONFIG_SPL_BUILD)
711
- /* 1. Query partition with A/B slot suffix */
712710 if (rk_avb_append_part_slot(name, name_slot))
713711 return -1;
712
+ full_name = name_slot;
714713 #elif defined(CONFIG_SPL_AB) && defined(CONFIG_SPL_BUILD)
715714 if (spl_ab_append_part_slot(dev_desc, name, name_slot))
716715 return -1;
717
-#else
718
- strcpy(name_slot, name);
716
+ full_name = name_slot;
719717 #endif
718
+
720719 lookup:
721
- debug("## Query partition(%d): %s\n", none_slot_try, name_slot);
720
+ debug("## Query partition(%d): %s\n", none_slot_try, full_name);
722721 for (i = 1; i < part_drv->max_entries; i++) {
723722 ret = part_drv->get_info(dev_desc, i, info);
724723 if (ret != 0) {
725724 /* no more entries in table */
726725 break;
727726 }
728
- if (strcmp(name_slot, (const char *)info->name) == 0) {
727
+ if (strcmp(full_name, (const char *)info->name) == 0) {
729728 /* matched */
730729 return i;
731730 }
....@@ -734,7 +733,7 @@
734733 /* 2. Query partition without A/B slot suffix if above failed */
735734 if (none_slot_try) {
736735 none_slot_try = 0;
737
- strcpy(name_slot, name);
736
+ full_name = name;
738737 goto lookup;
739738 }
740739