.. | .. |
---|
684 | 684 | disk_partition_t *info, |
---|
685 | 685 | bool strict) |
---|
686 | 686 | { |
---|
| 687 | + __maybe_unused char name_slot[32] = {0}; |
---|
687 | 688 | struct part_driver *part_drv; |
---|
688 | | - char name_slot[32] = {0}; |
---|
| 689 | + const char *full_name = name; |
---|
689 | 690 | int none_slot_try = 1; |
---|
690 | 691 | int ret, i; |
---|
691 | 692 | |
---|
.. | .. |
---|
695 | 696 | |
---|
696 | 697 | if (strict) { |
---|
697 | 698 | none_slot_try = 0; |
---|
698 | | - strcpy(name_slot, name); |
---|
699 | 699 | goto lookup; |
---|
700 | 700 | } |
---|
701 | 701 | |
---|
| 702 | + /* 1. Query partition with A/B slot suffix */ |
---|
702 | 703 | #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; |
---|
704 | 705 | |
---|
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; |
---|
709 | 708 | #endif |
---|
710 | 709 | #if defined(CONFIG_ANDROID_AB) && !defined(CONFIG_SPL_BUILD) |
---|
711 | | - /* 1. Query partition with A/B slot suffix */ |
---|
712 | 710 | if (rk_avb_append_part_slot(name, name_slot)) |
---|
713 | 711 | return -1; |
---|
| 712 | + full_name = name_slot; |
---|
714 | 713 | #elif defined(CONFIG_SPL_AB) && defined(CONFIG_SPL_BUILD) |
---|
715 | 714 | if (spl_ab_append_part_slot(dev_desc, name, name_slot)) |
---|
716 | 715 | return -1; |
---|
717 | | -#else |
---|
718 | | - strcpy(name_slot, name); |
---|
| 716 | + full_name = name_slot; |
---|
719 | 717 | #endif |
---|
| 718 | + |
---|
720 | 719 | 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); |
---|
722 | 721 | for (i = 1; i < part_drv->max_entries; i++) { |
---|
723 | 722 | ret = part_drv->get_info(dev_desc, i, info); |
---|
724 | 723 | if (ret != 0) { |
---|
725 | 724 | /* no more entries in table */ |
---|
726 | 725 | break; |
---|
727 | 726 | } |
---|
728 | | - if (strcmp(name_slot, (const char *)info->name) == 0) { |
---|
| 727 | + if (strcmp(full_name, (const char *)info->name) == 0) { |
---|
729 | 728 | /* matched */ |
---|
730 | 729 | return i; |
---|
731 | 730 | } |
---|
.. | .. |
---|
734 | 733 | /* 2. Query partition without A/B slot suffix if above failed */ |
---|
735 | 734 | if (none_slot_try) { |
---|
736 | 735 | none_slot_try = 0; |
---|
737 | | - strcpy(name_slot, name); |
---|
| 736 | + full_name = name; |
---|
738 | 737 | goto lookup; |
---|
739 | 738 | } |
---|
740 | 739 | |
---|