Fix Android A/B backup
v4 cover Fix Android A/B backup
- Addresses compiler error due to missing semicolon
- Removes use of preprocessor macros with ANDROID_AB_BACKUP_OFFSET
Bug was found by noticing a semicolon was missing and not causing a compiler error when CONFIG_ANDROID_AB_BACKUP_OFFSET was set. I submitted a patch to fix the semicolon before fixing the #if's. Testing the latter patch without the former with ANDORID_AB_BACKUP_OFFSET set will cause a compiler error.
What's changed in V2?
---------------------
The second verison of changes removes the #if preprocessor macros to use C conditionals instead. There was some minor refactoring required to get this to work, so I did more thourough testing to ensure the backup data works as expected.
I also realized that CONFIG_VAL is not needed because there's no reason for the SPL or TPL to have different values for the backup address. I opted to just use CONFIG_ANDROID_AB_BACKUP_OFFSET directly.
What's changed in V3?
---------------------
Added "Fixes:" tag to patches. Performed additonal testing as described in the second paragraph in the testing notes below.
I opted to not use CONFIG_IS_ENABLED because that macro appears to only be intended for y/n configurations. See note at top of linux/kconfig.h:
"Note that these only work with boolean and tristate options."
What's changed in V4?
---------------------
Nothing other than sending the patch in through a different email address in order to see if the Garmin SMTP server is borking the patches.
How was this patch series tested?
---------------------------------
I built for my target with CONFIG_ANDROID_AB_BACKUP_OFFSET set to 0x1000. I first verified that the device can normally boot. I then ran dd before rebooting to corrupt the primary data. I confirmed that the backup was used to properly restore the primary. I then corrupted both the primary and backup data and confirmed that the primary and backup were both reinitialized to default values. Lastly, I corrupted the backup data and not the primary data and confirmed that the backup was restored the primary data.
Addtionally, I disabled CONFIG_ANDROID_AB_BACKUP_OFFSET for my device and confirmed that after I corrupt the primary data, no backup is used. When the primary data is not corrupt, the device boots normally. This is what I would expect, because CONFIG_ANDROID_AB_BACKUP_OFFSET's default value is 0x0, which would evaluate to false for all C if conditions.
Colin McAllister (2):
android_ab: Add missing semicolon
android_ab: Fix ANDROID_AB_BACKUP_OFFSET
boot/android_ab.c | 97 ++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 52 deletions(-)
Signature · 1 line
2.34.1
PATCH v4 1/2 android_ab: Add missing semicolon
From: Colin McAllister <[email protected]>
Found a missing semicolon in code protected by a #if that will never evaluate to true due to a separate issue. Fixing this issue before addressing the #if.
---
v2: No changes
v3: Added "Fixes:" tag
v4: No changes
boot/android_ab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
boot/android_ab.c +1 -1
@@ -221,7 +221,7 @@ int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,#if ANDROID_AB_BACKUP_OFFSET crc32_le =ab_control_compute_crc (backup_abc);if (backup_abc->crc32_le != crc32_le) { - log_err("ANDROID: Invalid backup CRC-32 ") +log_err ("ANDROID: Invalid backup CRC-32 " );log_err ("expected %.8x, found %.8x)," , crc32_le, backup_abc->crc32_le);#endif
Signature · 1 line
2.34.1
Re: [PATCH v4 1/2] android_ab: Add missing semicolon
Hi Colin,
Thank you for the patch.
Quoted 11 lines · Colin McAllister
From: Colin McAllister <[email protected]>
Found a missing semicolon in code protected by a #if that will never evaluate to true due to a separate issue. Fixing this issue before addressing the #if.
Fixes 3430f24bc6 ("android_ab: Try backup booloader_message")Signed-off-by Colin McAllister <[email protected]>Cc Joshua Watt <[email protected]>Cc Simon Glass <[email protected]>Signed-off-by Colin McAllister <[email protected]>
Since Sam gave his review in [1]:
https://lore.kernel.org/all/CAPLW+4kHmPtfACyND4Vc2p0ZrsyGY=+bRU=fdub4K1uX5p33Jw@mail.gmail.com/
I will also add:
When applying.
Quoted 23 lines
---
v2: No changes
v3: Added "Fixes:" tag
v4: No changesboot/android_ab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)boot/android_ab.c +1
-1@@ -221,7 +221,7 @@ int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,#if ANDROID_AB_BACKUP_OFFSET crc32_le =ab_control_compute_crc (backup_abc);if (backup_abc->crc32_le != crc32_le) { - log_err("ANDROID: Invalid backup CRC-32 ") +log_err ("ANDROID: Invalid backup CRC-32 " );log_err ("expected %.8x, found %.8x)," , crc32_le, backup_abc->crc32_le);#endif Signature · 1 line
2.34.1
Re: [PATCH v4 1/2] android_ab: Add missing semicolon
In reply to Colin McAllisterHi Colin,
Quoted 32 lines · Colin McAllister
From: Colin McAllister <[email protected]>
Found a missing semicolon in code protected by a #if that will never evaluate to true due to a separate issue. Fixing this issue before addressing the #if.
Fixes 3430f24bc6 ("android_ab: Try backup booloader_message")Signed-off-by Colin McAllister <[email protected]>Cc Joshua Watt <[email protected]>Cc Simon Glass <[email protected]>Signed-off-by Colin McAllister <[email protected]>---
v2: No changes
v3: Added "Fixes:" tag
v4: No changesboot/android_ab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)boot/android_ab.c +1
-1@@ -221,7 +221,7 @@ int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,#if ANDROID_AB_BACKUP_OFFSET crc32_le =ab_control_compute_crc (backup_abc);if (backup_abc->crc32_le != crc32_le) { - log_err("ANDROID: Invalid backup CRC-32 ") +log_err ("ANDROID: Invalid backup CRC-32 " );log_err ("expected %.8x, found %.8x)," , crc32_le, backup_abc->crc32_le);
Quoted 5 lines
#endif
--
2.34.1
Signature · 7 lines
Best regards - Atentamente - Meilleures salutations Igor Opaniuk mailto: [email protected] skype: igor.opanyuk https://www.linkedin.com/in/iopaniuk <http://ua.linkedin.com/in/iopaniuk>
PATCH v4 2/2 android_ab: Fix ANDROID_AB_BACKUP_OFFSET
In reply to Colin McAllisterFrom: Colin McAllister <[email protected]>
Currently, setting CONFIG_AB_BACKUP_OFFSET in a target's defconfig will not actually enable the #if protected code in android_ab.c. This is because "CONFIG_" should have been prepended to the config macro, or the macros defined in kconfig.h could have been used.
The code included by ANDROID_AB_BACKUP_OFFSET has been refactored to no longer be conditionally compiled by preprocessor conditionals and instead use C conditionals. This better aligns with the Linux kernel style guide.
---
v2:
- Replaced #if conditionals with C if conditionals
- Opted to use CONFIG_ANDROID_AB_BACKUP_OFFSET directly instead of macros in kconfig.h as CONFIG_ANDROID_AB_BACKUP_OFFSET is not a boolean or tristate value and doesn't have different values when building SPL or TPL.
v3:
- Added "Fixes:" tag
v4:
- No changes
boot/android_ab.c | 97 ++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 52 deletions(-)
boot/android_ab.c +45 -52
@@ -187,13 +187,12 @@ int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info, bool dec_tries) {struct bootloader_control *abc =NULL ; +struct bootloader_control *backup_abc =NULL ;u32 crc32_le;int slot, i, ret;bool store_needed = false; +bool valid_backup = false;char slot_suffix[4 ]; -#if ANDROID_AB_BACKUP_OFFSET -struct bootloader_control *backup_abc =NULL ; -#endif ret =ab_control_create_from_disk (dev_desc, part_info, &abc,0 );if (ret <0 ) {
@@ -205,53 +204,49 @@ int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,return ret; } -#if ANDROID_AB_BACKUP_OFFSET - ret =ab_control_create_from_disk (dev_desc, part_info, &backup_abc, -ANDROID_AB_BACKUP_OFFSET ); -if (ret <0 ) { -free (abc); -return ret; +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) { + ret =ab_control_create_from_disk (dev_desc, part_info, &backup_abc, +CONFIG_ANDROID_AB_BACKUP_OFFSET ); +if (ret <0 ) { +free (abc); +return ret; + } } -#endif crc32_le =ab_control_compute_crc (abc);if (abc->crc32_le != crc32_le) {log_err ("ANDROID: Invalid CRC-32 (expected %.8x, found %.8x)," , crc32_le, abc->crc32_le); -#if ANDROID_AB_BACKUP_OFFSET - crc32_le =ab_control_compute_crc (backup_abc); -if (backup_abc->crc32_le != crc32_le) { -log_err ("ANDROID: Invalid backup CRC-32 " ); -log_err ("expected %.8x, found %.8x)," , - crc32_le, backup_abc->crc32_le); -#endif - -log_err ("re-initializing A/B metadata.\n" ); +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) { + crc32_le =ab_control_compute_crc (backup_abc); +if (backup_abc->crc32_le != crc32_le) { +log_err (" ANDROID: Invalid backup CRC-32 " ); +log_err ("(expected %.8x, found %.8x)," , + crc32_le, backup_abc->crc32_le); + }else { + valid_backup = true; +log_info (" copying A/B metadata from backup.\n" ); +memcpy (abc, backup_abc,sizeof (*abc)); + } + } +if (!valid_backup) { +log_err (" re-initializing A/B metadata.\n" ); ret =ab_control_default (abc);if (ret <0 ) { -#if ANDROID_AB_BACKUP_OFFSET -free (backup_abc); -#endif +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) +free (backup_abc);free (abc);return -ENODATA ; } -#if ANDROID_AB_BACKUP_OFFSET - } else { -/* -* Backup is valid. Copy it to the primary -*/ -memcpy (abc, backup_abc,sizeof (*abc)); } -#endif store_needed = true; }if (abc->magic !=BOOT_CTRL_MAGIC ) {log_err ("ANDROID: Unknown A/B metadata: %.8x\n" , abc->magic); -#if ANDROID_AB_BACKUP_OFFSET -free (backup_abc); -#endif +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) +free (backup_abc);free (abc);return -ENODATA ; }
@@ -259,9 +254,8 @@ int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,if (abc->version >BOOT_CTRL_VERSION ) {log_err ("ANDROID: Unsupported A/B metadata version: %.8x\n" , abc->version); -#if ANDROID_AB_BACKUP_OFFSET -free (backup_abc); -#endif +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) +free (backup_abc);free (abc);return -ENODATA ; }
@@ -338,30 +332,29 @@ int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info, abc->crc32_le =ab_control_compute_crc (abc); ret =ab_control_store (dev_desc, part_info, abc,0 );if (ret <0 ) { -#if ANDROID_AB_BACKUP_OFFSET -free (backup_abc); -#endif +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) +free (backup_abc);free (abc);return ret; } } -#if ANDROID_AB_BACKUP_OFFSET -/* -* If the backup doesn't match the primary, write the primary -* to the backup offset -*/ -if (memcmp (backup_abc, abc,sizeof (*abc)) !=0 ) { - ret =ab_control_store (dev_desc, part_info, abc, -ANDROID_AB_BACKUP_OFFSET ); -if (ret <0 ) { -free (backup_abc); -free (abc); -return ret; +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) { +/* +* If the backup doesn't match the primary, write the primary +* to the backup offset +*/ +if (memcmp (backup_abc, abc,sizeof (*abc)) !=0 ) { + ret =ab_control_store (dev_desc, part_info, abc, +CONFIG_ANDROID_AB_BACKUP_OFFSET ); +if (ret <0 ) { +free (backup_abc); +free (abc); +return ret; + } } +free (backup_abc); } -free (backup_abc); -#endif free (abc);
Signature · 1 line
2.34.1
Re: [PATCH v4 2/2] android_ab: Fix ANDROID_AB_BACKUP_OFFSET
Hi Colin,
Thank you for the patch.
On mar., mars 12, 2024 at 07:57, Colin McAllister <[email protected]> wrote:
Sam also gave his review here:
https://lore.kernel.org/all/CAPLW+4kHmPtfACyND4Vc2p0ZrsyGY=+bRU=fdub4K1uX5p33Jw@mail.gmail.com/
Please include his review tag in the next submission.
I will add it at the appropriate place below:
Quoted 12 lines
From: Colin McAllister <[email protected]>
Currently, setting
CONFIG_AB_BACKUP_OFFSETin a target's defconfig will not actually enable the #if protected code inandroid_ab.c. This is because "CONFIG_" should have been prepended to the config macro, or the macros defined inkconfig.hcould have been used.The code included by
ANDROID_AB_BACKUP_OFFSEThas been refactored to no longer be conditionally compiled by preprocessor conditionals and instead use C conditionals. This better aligns with the Linux kernel style guide.
Quoted 5 lines
Fixes 3430f24bc6 ("android_ab: Try backup booloader_message")Signed-off-by Colin McAllister <[email protected]>Cc Joshua Watt <[email protected]>Cc Simon Glass <[email protected]>Signed-off-by Colin McAllister <[email protected]>
Quoted 147 lines
---
v2:
- Replaced #if conditionals with C if conditionals
- Opted to useCONFIG_ANDROID_AB_BACKUP_OFFSETdirectly instead of macros inkconfig.hasCONFIG_ANDROID_AB_BACKUP_OFFSETis not a boolean or tristate value and doesn't have different values when building SPL or TPL.
v3:
- Added "Fixes:" tag
v4:
- No changesboot/android_ab.c | 97 ++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 52 deletions(-)boot/android_ab.c +31
-45@@ -187,13 +187,12 @@ int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info, bool dec_tries) {struct bootloader_control *abc =NULL ; +struct bootloader_control *backup_abc =NULL ;u32 crc32_le;int slot, i, ret;bool store_needed = false; +bool valid_backup = false;char slot_suffix[4 ]; -#if ANDROID_AB_BACKUP_OFFSET -struct bootloader_control *backup_abc =NULL ; -#endif ret =ab_control_create_from_disk (dev_desc, part_info, &abc,0 );if (ret <0 ) {@@ -205,53 +204,49 @@ int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,return ret; } -#if ANDROID_AB_BACKUP_OFFSET - ret =ab_control_create_from_disk (dev_desc, part_info, &backup_abc, -ANDROID_AB_BACKUP_OFFSET ); -if (ret <0 ) { -free (abc); -return ret; +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) { + ret =ab_control_create_from_disk (dev_desc, part_info, &backup_abc, +CONFIG_ANDROID_AB_BACKUP_OFFSET ); +if (ret <0 ) { +free (abc); +return ret; + } } -#endif crc32_le =ab_control_compute_crc (abc);if (abc->crc32_le != crc32_le) {log_err ("ANDROID: Invalid CRC-32 (expected %.8x, found %.8x)," , crc32_le, abc->crc32_le); -#if ANDROID_AB_BACKUP_OFFSET - crc32_le =ab_control_compute_crc (backup_abc); -if (backup_abc->crc32_le != crc32_le) { -log_err ("ANDROID: Invalid backup CRC-32 " ); -log_err ("expected %.8x, found %.8x)," , - crc32_le, backup_abc->crc32_le); -#endif - -log_err ("re-initializing A/B metadata.\n" ); +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) { + crc32_le =ab_control_compute_crc (backup_abc); +if (backup_abc->crc32_le != crc32_le) { +log_err (" ANDROID: Invalid backup CRC-32 " ); +log_err ("(expected %.8x, found %.8x)," , + crc32_le, backup_abc->crc32_le); + }else { + valid_backup = true; +log_info (" copying A/B metadata from backup.\n" ); +memcpy (abc, backup_abc,sizeof (*abc)); + } + } +if (!valid_backup) { +log_err (" re-initializing A/B metadata.\n" ); ret =ab_control_default (abc);if (ret <0 ) { -#if ANDROID_AB_BACKUP_OFFSET -free (backup_abc); -#endif +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) +free (backup_abc);free (abc);return -ENODATA ; } -#if ANDROID_AB_BACKUP_OFFSET - } else { -/* -* Backup is valid. Copy it to the primary -*/ -memcpy (abc, backup_abc,sizeof (*abc)); } -#endif store_needed = true; }if (abc->magic !=BOOT_CTRL_MAGIC ) {log_err ("ANDROID: Unknown A/B metadata: %.8x\n" , abc->magic); -#if ANDROID_AB_BACKUP_OFFSET -free (backup_abc); -#endif +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) +free (backup_abc);free (abc);return -ENODATA ; }@@ -259,9 +254,8 @@ int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,if (abc->version >BOOT_CTRL_VERSION ) {log_err ("ANDROID: Unsupported A/B metadata version: %.8x\n" , abc->version); -#if ANDROID_AB_BACKUP_OFFSET -free (backup_abc); -#endif +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) +free (backup_abc);free (abc);return -ENODATA ; }@@ -338,30 +332,29 @@ int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info, abc->crc32_le =ab_control_compute_crc (abc); ret =ab_control_store (dev_desc, part_info, abc,0 );if (ret <0 ) { -#if ANDROID_AB_BACKUP_OFFSET -free (backup_abc); -#endif +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) +free (backup_abc);free (abc);return ret; } } -#if ANDROID_AB_BACKUP_OFFSET -/* -* If the backup doesn't match the primary, write the primary -* to the backup offset -*/ -if (memcmp (backup_abc, abc,sizeof (*abc)) !=0 ) { - ret = ab_control_store(dev_desc, part_info, abc,
boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info, · line 346
Quoted 10 lines
boot/android_ab.c +5
-5- ANDROID_AB_BACKUP_OFFSET); -if (ret <0 ) { -free (backup_abc); -free (abc); -return ret; +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) { +/* +* If the backup doesn't match the primary, write the primary +* to the backup offset +*/
checkpatch.pl seems to complain about this comment block:
WARNING: Block comments should align the * on each line #166: FILE: boot/android_ab.c:344:
+ /*
+ * If the backup doesn't match the primary, write the primary
To reproduce, run:
$ ./scripts/checkpatch.pl --strict --u-boot --git HEAD^..HEAD
With the above addressed, please send a v5 including:
Quoted 18 lines
boot/android_ab.c +9
-2+if (memcmp (backup_abc, abc,sizeof (*abc)) !=0 ) { + ret =ab_control_store (dev_desc, part_info, abc, +CONFIG_ANDROID_AB_BACKUP_OFFSET ); +if (ret <0 ) { +free (backup_abc); +free (abc); +return ret; + } } +free (backup_abc); } -free (backup_abc); -#endif free (abc);Signature · 1 line
2.34.1
Igor Opaniuk
Reviewed-byRe: [PATCH v4 2/2] android_ab: Fix ANDROID_AB_BACKUP_OFFSET
Hi Colin,
Quoted 217 lines · Mattijs Korpershoek
Hi Colin,
Thank you for the patch.
On mar., mars 12, 2024 at 07:57, Colin McAllister <[email protected]> wrote:
Sam also gave his review here:
https://lore.kernel.org/all/CAPLW+4kHmPtfACyND4Vc2p0ZrsyGY=+bRU=fdub4K1uX5p33Jw@mail.gmail.com/
Please include his review tag in the next submission.
I will add it at the appropriate place below:
Quoted 12 lines
From: Colin McAllister <[email protected]>
Currently, setting
CONFIG_AB_BACKUP_OFFSETin a target's defconfig will not actually enable the #if protected code inandroid_ab.c. This is because "CONFIG_" should have been prepended to the config macro, or the macros defined inkconfig.hcould have been used.The code included by
ANDROID_AB_BACKUP_OFFSEThas been refactored to no longer be conditionally compiled by preprocessor conditionals and instead use C conditionals. This better aligns with the Linux kernel style guide.Quoted 5 lines
Fixes 3430f24bc6 ("android_ab: Try backup booloader_message")Signed-off-by Colin McAllister <[email protected]>Cc Joshua Watt <[email protected]>Cc Simon Glass <[email protected]>Signed-off-by Colin McAllister <[email protected]>Reviewed-by Sam Protsenko <[email protected]>boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc,
Quoted 20 lines
---
v2:
- Replaced #if conditionals with C if conditionals
- Opted to useCONFIG_ANDROID_AB_BACKUP_OFFSETdirectly instead of macros inkconfig.hasCONFIG_ANDROID_AB_BACKUP_OFFSETis not a boolean or tristate value and doesn't have different values when building SPL or TPL.
v3:
- Added "Fixes:" tag
v4:
- No changesboot/android_ab.c | 97 ++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 52 deletions(-)boot/android_ab.c +0
-0@@ -187,13 +187,12 @@ int ab_select_slot(struct blk_desc *dev_desc,struct
disk_partition*part_info,boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc,
Quoted 16 lines
boot/android_ab.c +2
-3bool dec_tries) {struct bootloader_control *abc =NULL ; +struct bootloader_control *backup_abc =NULL ;u32 crc32_le;int slot, i, ret;bool store_needed = false; +bool valid_backup = false;char slot_suffix[4 ]; -#if ANDROID_AB_BACKUP_OFFSET -struct bootloader_control *backup_abc =NULL ; -#endif ret =ab_control_create_from_disk (dev_desc, part_info, &abc,0 );if (ret <0 ) {@@ -205,53 +204,49 @@ int ab_select_slot(struct blk_desc *dev_desc,struct
disk_partition*part_info,boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
Quoted 11 lines
boot/android_ab.c +2
-6return ret; } -#if ANDROID_AB_BACKUP_OFFSET - ret =ab_control_create_from_disk (dev_desc, part_info, &backup_abc, -ANDROID_AB_BACKUP_OFFSET ); -if (ret <0 ) { -free (abc); -return ret; +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) { + ret = ab_control_create_from_disk(dev_desc, part_info,
&backup_abc,boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, · line 209
Quoted 1 line
boot/android_ab.c +1
-0+
CONFIG_ANDROID_AB_BACKUP_OFFSET);boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
Quoted 10 lines
boot/android_ab.c +4
-1+if (ret <0 ) { +free (abc); +return ret; + } } -#endif crc32_le =ab_control_compute_crc (abc);if (abc->crc32_le != crc32_le) { log_err("ANDROID: Invalid CRC-32 (expected %.8x, found%.8x),",
Quoted 4 lines
boot/android_ab.c +0
-3crc32_le, abc->crc32_le); -#if ANDROID_AB_BACKUP_OFFSET - crc32_le =ab_control_compute_crc (backup_abc); -if (backup_abc->crc32_le != crc32_le) {boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
Quoted 10 lines
boot/android_ab.c +4
-6-log_err ("ANDROID: Invalid backup CRC-32 " ); -log_err ("expected %.8x, found %.8x)," , - crc32_le, backup_abc->crc32_le); -#endif - -log_err ("re-initializing A/B metadata.\n" ); +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) { + crc32_le =ab_control_compute_crc (backup_abc); +if (backup_abc->crc32_le != crc32_le) { + log_err(" ANDROID: Invalid backup CRC-32");
boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
Quoted 5 lines
boot/android_ab.c +5
-0+log_err ("(expected %.8x, found %.8x)," , + crc32_le, backup_abc->crc32_le); + }else { + valid_backup = true; + log_info(" copying A/B metadata frombackup.\n");
Quoted 19 lines
boot/android_ab.c +7
-6+memcpy (abc, backup_abc,sizeof (*abc)); + } + } +if (!valid_backup) { +log_err (" re-initializing A/B metadata.\n" ); ret =ab_control_default (abc);if (ret <0 ) { -#if ANDROID_AB_BACKUP_OFFSET -free (backup_abc); -#endif +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) +free (backup_abc);free (abc);return -ENODATA ; } -#if ANDROID_AB_BACKUP_OFFSET - } else { -/* boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
Quoted 10 lines
boot/android_ab.c +0
-4-* Backup is valid. Copy it to the primary -*/ -memcpy (abc, backup_abc,sizeof (*abc)); } -#endif store_needed = true; }if (abc->magic !=BOOT_CTRL_MAGIC ) { log_err("ANDROID: Unknown A/B metadata: %.8x\n",
abc->magic);boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct
Quoted 9 lines
boot/android_ab.c +2
-3-#if ANDROID_AB_BACKUP_OFFSET -free (backup_abc); -#endif +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) +free (backup_abc);free (abc);return -ENODATA ; }@@ -259,9 +254,8 @@ int ab_select_slot(struct blk_desc *dev_desc, struct
disk_partition*part_info,boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct · line 255
Quoted 2 lines
boot/android_ab.c +0
-0if (abc->version >BOOT_CTRL_VERSION ) { log_err("ANDROID: Unsupported A/B metadata version:%.8x\n",
boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc,
Quoted 10 lines
boot/android_ab.c +2
-3abc->version); -#if ANDROID_AB_BACKUP_OFFSET -free (backup_abc); -#endif +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) +free (backup_abc);free (abc);return -ENODATA ; }@@ -338,30 +332,29 @@ int ab_select_slot(struct blk_desc *dev_desc,struct
disk_partition*part_info,Quoted 18 lines
boot/android_ab.c +2
-8abc->crc32_le =ab_control_compute_crc (abc); ret =ab_control_store (dev_desc, part_info, abc,0 );if (ret <0 ) { -#if ANDROID_AB_BACKUP_OFFSET -free (backup_abc); -#endif +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) +free (backup_abc);free (abc);return ret; } } -#if ANDROID_AB_BACKUP_OFFSET -/* -* If the backup doesn't match the primary, write the primary -* to the backup offset -*/ boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
Quoted 10 lines
boot/android_ab.c +3
-7-if (memcmp (backup_abc, abc,sizeof (*abc)) !=0 ) { - ret =ab_control_store (dev_desc, part_info, abc, -ANDROID_AB_BACKUP_OFFSET ); -if (ret <0 ) { -free (backup_abc); -free (abc); -return ret; +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) { +/* +* If the backup doesn't match the primary, write the primary
boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info, · line 346
Quoted 2 lines
boot/android_ab.c +2
-0+* to the backup offset +*/ checkpatch.pl seems to complain about this comment block:
WARNING: Block comments should align the * on each line #166: FILE:
boot/android_ab.c:344:(quoted diff) +2
-0+ /* + * If the backup doesn't match the primary, write theprimary
To reproduce, run:
$ ./scripts/checkpatch.pl --strict --u-boot --git HEAD^..HEAD
Quoted 24 lines
With the above addressed, please send a v5 including:
Reviewed-by Mattijs Korpershoek <[email protected]>boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
Quoted 3 lines
boot/android_ab.c +3
-0+if (memcmp (backup_abc, abc,sizeof (*abc)) !=0 ) { + ret = ab_control_store(dev_desc, part_info, abc, +
CONFIG_ANDROID_AB_BACKUP_OFFSET);Quoted 15 lines
boot/android_ab.c +6
-3+if (ret <0 ) { +free (backup_abc); +free (abc); +return ret; + } } +free (backup_abc); } -free (backup_abc); -#endif free (abc); --2.34.1
With Mattijs comment addressed:
Signature · 7 lines
Best regards - Atentamente - Meilleures salutations Igor Opaniuk mailto: [email protected] skype: igor.opanyuk https://www.linkedin.com/in/iopaniuk <http://ua.linkedin.com/in/iopaniuk>
Re: [PATCH v4 2/2] android_ab: Fix ANDROID_AB_BACKUP_OFFSET
Hi Colin,
Since both below remarks are minor nitpicks, I can also do them when applying (to avoid delaying this series too much).
Please le me know what you prefer:
1. You send a v5 at your convience
2. I do the minor fixups and I merge right away.
Again, thank you for doing your first U-Boot contributions!
Mattijs
Quoted 258 lines · Igor Opaniuk
Hi Colin,
Quoted 217 lines · Mattijs Korpershoek
Hi Colin,
Thank you for the patch.
On mar., mars 12, 2024 at 07:57, Colin McAllister <[email protected]> wrote:
Sam also gave his review here:
https://lore.kernel.org/all/CAPLW+4kHmPtfACyND4Vc2p0ZrsyGY=+bRU=fdub4K1uX5p33Jw@mail.gmail.com/
Please include his review tag in the next submission.
I will add it at the appropriate place below:
Quoted 12 lines
From: Colin McAllister <[email protected]>
Currently, setting
CONFIG_AB_BACKUP_OFFSETin a target's defconfig will not actually enable the #if protected code inandroid_ab.c. This is because "CONFIG_" should have been prepended to the config macro, or the macros defined inkconfig.hcould have been used.The code included by
ANDROID_AB_BACKUP_OFFSEThas been refactored to no longer be conditionally compiled by preprocessor conditionals and instead use C conditionals. This better aligns with the Linux kernel style guide.Quoted 5 lines
Fixes 3430f24bc6 ("android_ab: Try backup booloader_message")Signed-off-by Colin McAllister <[email protected]>Cc Joshua Watt <[email protected]>Cc Simon Glass <[email protected]>Signed-off-by Colin McAllister <[email protected]>Reviewed-by Sam Protsenko <[email protected]>boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc,
Quoted 20 lines
---
v2:
- Replaced #if conditionals with C if conditionals
- Opted to useCONFIG_ANDROID_AB_BACKUP_OFFSETdirectly instead of macros inkconfig.hasCONFIG_ANDROID_AB_BACKUP_OFFSETis not a boolean or tristate value and doesn't have different values when building SPL or TPL.
v3:
- Added "Fixes:" tag
v4:
- No changesboot/android_ab.c | 97 ++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 52 deletions(-)boot/android_ab.c +0
-0@@ -187,13 +187,12 @@ int ab_select_slot(struct blk_desc *dev_desc,struct
disk_partition*part_info,boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc,
Quoted 16 lines
boot/android_ab.c +2
-3bool dec_tries) {struct bootloader_control *abc =NULL ; +struct bootloader_control *backup_abc =NULL ;u32 crc32_le;int slot, i, ret;bool store_needed = false; +bool valid_backup = false;char slot_suffix[4 ]; -#if ANDROID_AB_BACKUP_OFFSET -struct bootloader_control *backup_abc =NULL ; -#endif ret =ab_control_create_from_disk (dev_desc, part_info, &abc,0 );if (ret <0 ) {@@ -205,53 +204,49 @@ int ab_select_slot(struct blk_desc *dev_desc,struct
disk_partition*part_info,boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
Quoted 11 lines
boot/android_ab.c +2
-6return ret; } -#if ANDROID_AB_BACKUP_OFFSET - ret =ab_control_create_from_disk (dev_desc, part_info, &backup_abc, -ANDROID_AB_BACKUP_OFFSET ); -if (ret <0 ) { -free (abc); -return ret; +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) { + ret = ab_control_create_from_disk(dev_desc, part_info,
&backup_abc,boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, · line 209
Quoted 1 line
boot/android_ab.c +1
-0+
CONFIG_ANDROID_AB_BACKUP_OFFSET);boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
Quoted 10 lines
boot/android_ab.c +4
-1+if (ret <0 ) { +free (abc); +return ret; + } } -#endif crc32_le =ab_control_compute_crc (abc);if (abc->crc32_le != crc32_le) { log_err("ANDROID: Invalid CRC-32 (expected %.8x, found%.8x),",
Quoted 4 lines
boot/android_ab.c +0
-3crc32_le, abc->crc32_le); -#if ANDROID_AB_BACKUP_OFFSET - crc32_le =ab_control_compute_crc (backup_abc); -if (backup_abc->crc32_le != crc32_le) {boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
Quoted 10 lines
boot/android_ab.c +4
-6-log_err ("ANDROID: Invalid backup CRC-32 " ); -log_err ("expected %.8x, found %.8x)," , - crc32_le, backup_abc->crc32_le); -#endif - -log_err ("re-initializing A/B metadata.\n" ); +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) { + crc32_le =ab_control_compute_crc (backup_abc); +if (backup_abc->crc32_le != crc32_le) { + log_err(" ANDROID: Invalid backup CRC-32");
boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
Quoted 5 lines
boot/android_ab.c +5
-0+log_err ("(expected %.8x, found %.8x)," , + crc32_le, backup_abc->crc32_le); + }else { + valid_backup = true; + log_info(" copying A/B metadata frombackup.\n");
Quoted 19 lines
boot/android_ab.c +7
-6+memcpy (abc, backup_abc,sizeof (*abc)); + } + } +if (!valid_backup) { +log_err (" re-initializing A/B metadata.\n" ); ret =ab_control_default (abc);if (ret <0 ) { -#if ANDROID_AB_BACKUP_OFFSET -free (backup_abc); -#endif +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) +free (backup_abc);free (abc);return -ENODATA ; } -#if ANDROID_AB_BACKUP_OFFSET - } else { -/* boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
Quoted 10 lines
boot/android_ab.c +0
-4-* Backup is valid. Copy it to the primary -*/ -memcpy (abc, backup_abc,sizeof (*abc)); } -#endif store_needed = true; }if (abc->magic !=BOOT_CTRL_MAGIC ) { log_err("ANDROID: Unknown A/B metadata: %.8x\n",
abc->magic);boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct
Quoted 9 lines
boot/android_ab.c +2
-3-#if ANDROID_AB_BACKUP_OFFSET -free (backup_abc); -#endif +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) +free (backup_abc);free (abc);return -ENODATA ; }@@ -259,9 +254,8 @@ int ab_select_slot(struct blk_desc *dev_desc, struct
disk_partition*part_info,boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct · line 255
Quoted 2 lines
boot/android_ab.c +0
-0if (abc->version >BOOT_CTRL_VERSION ) { log_err("ANDROID: Unsupported A/B metadata version:%.8x\n",
boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc,
Quoted 10 lines
boot/android_ab.c +2
-3abc->version); -#if ANDROID_AB_BACKUP_OFFSET -free (backup_abc); -#endif +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) +free (backup_abc);free (abc);return -ENODATA ; }@@ -338,30 +332,29 @@ int ab_select_slot(struct blk_desc *dev_desc,struct
disk_partition*part_info,Quoted 18 lines
boot/android_ab.c +2
-8abc->crc32_le =ab_control_compute_crc (abc); ret =ab_control_store (dev_desc, part_info, abc,0 );if (ret <0 ) { -#if ANDROID_AB_BACKUP_OFFSET -free (backup_abc); -#endif +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) +free (backup_abc);free (abc);return ret; } } -#if ANDROID_AB_BACKUP_OFFSET -/* -* If the backup doesn't match the primary, write the primary -* to the backup offset -*/ boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
Quoted 10 lines
boot/android_ab.c +3
-7-if (memcmp (backup_abc, abc,sizeof (*abc)) !=0 ) { - ret =ab_control_store (dev_desc, part_info, abc, -ANDROID_AB_BACKUP_OFFSET ); -if (ret <0 ) { -free (backup_abc); -free (abc); -return ret; +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) { +/* +* If the backup doesn't match the primary, write the primary
boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info, · line 346
Quoted 2 lines
boot/android_ab.c +2
-0+* to the backup offset +*/ checkpatch.pl seems to complain about this comment block:
WARNING: Block comments should align the * on each line #166: FILE:
boot/android_ab.c:344:(quoted diff) +2
-0+ /* + * If the backup doesn't match the primary, write theprimary
To reproduce, run:
$ ./scripts/checkpatch.pl --strict --u-boot --git HEAD^..HEADQuoted 24 lines
With the above addressed, please send a v5 including:
Reviewed-by Mattijs Korpershoek <[email protected]>boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
Quoted 3 lines
boot/android_ab.c +3
-0+if (memcmp (backup_abc, abc,sizeof (*abc)) !=0 ) { + ret = ab_control_store(dev_desc, part_info, abc, +
CONFIG_ANDROID_AB_BACKUP_OFFSET);Quoted 15 lines
boot/android_ab.c +6
-3+if (ret <0 ) { +free (backup_abc); +free (abc); +return ret; + } } +free (backup_abc); } -free (backup_abc); -#endif free (abc); --2.34.1
With Mattijs comment addressed:
Reviewed-by Igor Opaniuk <[email protected]>Signature · 7 lines
Best regards - Atentamente - Meilleures salutations Igor Opaniuk mailto: [email protected] skype: igor.opanyuk https://www.linkedin.com/in/iopaniuk <http://ua.linkedin.com/in/iopaniuk>
Re: [PATCH v4 2/2] android_ab: Fix ANDROID_AB_BACKUP_OFFSET
Hi Mattijs,
Sorry, I did not realize there were outstanding issues for me to address. I would be happy to send a v5, but if you doing the fixups gets this merged quicker, that sounds better to me.
Happy to contribute,
*_____________________*
*Colin McAllister*
Quoted 284 lines · Mattijs Korpershoek
Hi Colin,
Since both below remarks are minor nitpicks, I can also do them when applying (to avoid delaying this series too much).
Please le me know what you prefer:
1. You send a v5 at your convience
2. I do the minor fixups and I merge right away.Again, thank you for doing your first U-Boot contributions!
Mattijs
Quoted 10 lines · Igor Opaniuk
Hi Colin,
Quoted 5 lines · Mattijs Korpershoek
Hi Colin,
Thank you for the patch.
On mar., mars 12, 2024 at 07:57, Colin McAllister <
Quoted 5 lines
Quoted 5 lines
wrote:
Sam also gave his review here:
https://lore.kernel.org/all/CAPLW+4kHmPtfACyND4Vc2p0ZrsyGY=+bRU=fdub4K1uX5p33Jw@mail.gmail.com/
Quoted 9 lines
Quoted 9 lines
Please include his review tag in the next submission.
I will add it at the appropriate place below:
Quoted 3 lines
From: Colin McAllister <[email protected]>
Currently, setting
CONFIG_AB_BACKUP_OFFSETin a target's defconfigwill
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
not actually enable the #if protected code in
android_ab.c. This is because "CONFIG_" should have been prepended to the config macro, orthe
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
macros defined in
kconfig.hcould have been used.The code included by
ANDROID_AB_BACKUP_OFFSEThas been refactored tono
Quoted 23 lines
Quoted 23 lines
Quoted 9 lines
longer be conditionally compiled by preprocessor conditionals and instead use C conditionals. This better aligns with the Linux kernel style guide.
Fixes 3430f24bc6 ("android_ab: Try backup booloader_message")Signed-off-by Colin McAllister <[email protected]>Cc Joshua Watt <[email protected]>Cc Simon Glass <[email protected]>Signed-off-by Colin McAllister <[email protected]>Reviewed-by Sam Protsenko <[email protected]>Quoted 12 lines
---
v2:
- Replaced #if conditionals with C if conditionals
- Opted to useCONFIG_ANDROID_AB_BACKUP_OFFSETdirectly instead of macros inkconfig.hasCONFIG_ANDROID_AB_BACKUP_OFFSETis not a boolean or tristate value and doesn't have different values when building SPL or TPL.
v3:
- Added "Fixes:" tag
v4:
- No changesQuoted 1 line
Quoted 1 line
Quoted 1 line
boot/android_ab.c | 97++++++++++++++++++++++-------------------------
Quoted 25 lines
Quoted 25 lines
boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc,
Quoted 7 lines
1 file changed, 45 insertions(+), 52 deletions(-)boot/android_ab.c +0
-0@@ -187,13 +187,12 @@ int ab_select_slot(struct blk_desc *dev_desc,struct
disk_partition*part_info,boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc,
Quoted 16 lines
boot/android_ab.c +2
-3bool dec_tries) {struct bootloader_control *abc =NULL ; +struct bootloader_control *backup_abc =NULL ;u32 crc32_le;int slot, i, ret;bool store_needed = false; +bool valid_backup = false;char slot_suffix[4 ]; -#if ANDROID_AB_BACKUP_OFFSET -struct bootloader_control *backup_abc =NULL ; -#endif ret =ab_control_create_from_disk (dev_desc, part_info, &abc,0 );if (ret <0 ) {@@ -205,53 +204,49 @@ int ab_select_slot(struct blk_desc *dev_desc,struct
disk_partition*part_info,Quoted 5 lines
Quoted 5 lines
boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
Quoted 5 lines
boot/android_ab.c +0
-2return ret; } -#if ANDROID_AB_BACKUP_OFFSET - ret = ab_control_create_from_disk(dev_desc, part_info,
&backup_abc,Quoted 71 lines
Quoted 71 lines
boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
Quoted 6 lines
boot/android_ab.c +2
-4- ANDROID_AB_BACKUP_OFFSET); -if (ret <0 ) { -free (abc); -return ret; +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) { + ret = ab_control_create_from_disk(dev_desc, part_info,
&backup_abc,boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, · line 209
Quoted 1 line
boot/android_ab.c +1
-0+
CONFIG_ANDROID_AB_BACKUP_OFFSET);boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
Quoted 10 lines
boot/android_ab.c +4
-1+if (ret <0 ) { +free (abc); +return ret; + } } -#endif crc32_le =ab_control_compute_crc (abc);if (abc->crc32_le != crc32_le) { log_err("ANDROID: Invalid CRC-32 (expected %.8x, found%.8x),",
Quoted 4 lines
boot/android_ab.c +0
-3crc32_le, abc->crc32_le); -#if ANDROID_AB_BACKUP_OFFSET - crc32_le =ab_control_compute_crc (backup_abc); -if (backup_abc->crc32_le != crc32_le) {boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
Quoted 10 lines
boot/android_ab.c +4
-6-log_err ("ANDROID: Invalid backup CRC-32 " ); -log_err ("expected %.8x, found %.8x)," , - crc32_le, backup_abc->crc32_le); -#endif - -log_err ("re-initializing A/B metadata.\n" ); +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) { + crc32_le =ab_control_compute_crc (backup_abc); +if (backup_abc->crc32_le != crc32_le) { + log_err(" ANDROID: Invalid backup CRC-32");
boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
Quoted 5 lines
boot/android_ab.c +5
-0+log_err ("(expected %.8x, found %.8x)," , + crc32_le, backup_abc->crc32_le); + }else { + valid_backup = true; + log_info(" copying A/B metadata frombackup.\n");
Quoted 19 lines
boot/android_ab.c +7
-6+memcpy (abc, backup_abc,sizeof (*abc)); + } + } +if (!valid_backup) { +log_err (" re-initializing A/B metadata.\n" ); ret =ab_control_default (abc);if (ret <0 ) { -#if ANDROID_AB_BACKUP_OFFSET -free (backup_abc); -#endif +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) +free (backup_abc);free (abc);return -ENODATA ; } -#if ANDROID_AB_BACKUP_OFFSET - } else { -/* boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
Quoted 10 lines
boot/android_ab.c +0
-4-* Backup is valid. Copy it to the primary -*/ -memcpy (abc, backup_abc,sizeof (*abc)); } -#endif store_needed = true; }if (abc->magic !=BOOT_CTRL_MAGIC ) { log_err("ANDROID: Unknown A/B metadata: %.8x\n",
abc->magic);Quoted 9 lines
Quoted 9 lines
boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc,
Quoted 9 lines
boot/android_ab.c +2
-3-#if ANDROID_AB_BACKUP_OFFSET -free (backup_abc); -#endif +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) +free (backup_abc);free (abc);return -ENODATA ; }@@ -259,9 +254,8 @@ int ab_select_slot(struct blk_desc *dev_desc,struct
Quoted 96 lines
Quoted 59 lines
disk_partition*part_info,boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, · line 255
Quoted 2 lines
boot/android_ab.c +0
-0if (abc->version >BOOT_CTRL_VERSION ) { log_err("ANDROID: Unsupported A/B metadata version:%.8x\n",
boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc,
Quoted 10 lines
boot/android_ab.c +2
-3abc->version); -#if ANDROID_AB_BACKUP_OFFSET -free (backup_abc); -#endif +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) +free (backup_abc);free (abc);return -ENODATA ; }@@ -338,30 +332,29 @@ int ab_select_slot(struct blk_desc *dev_desc,struct
disk_partition*part_info,Quoted 18 lines
boot/android_ab.c +2
-8abc->crc32_le =ab_control_compute_crc (abc); ret =ab_control_store (dev_desc, part_info, abc,0 );if (ret <0 ) { -#if ANDROID_AB_BACKUP_OFFSET -free (backup_abc); -#endif +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) +free (backup_abc);free (abc);return ret; } } -#if ANDROID_AB_BACKUP_OFFSET -/* -* If the backup doesn't match the primary, write the primary -* to the backup offset -*/ boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
Quoted 10 lines
boot/android_ab.c +3
-7-if (memcmp (backup_abc, abc,sizeof (*abc)) !=0 ) { - ret =ab_control_store (dev_desc, part_info, abc, -ANDROID_AB_BACKUP_OFFSET ); -if (ret <0 ) { -free (backup_abc); -free (abc); -return ret; +if (CONFIG_ANDROID_AB_BACKUP_OFFSET ) { +/* +* If the backup doesn't match the primary, write the primary
boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info, · line 346
Quoted 2 lines
boot/android_ab.c +2
-0+* to the backup offset +*/ checkpatch.pl seems to complain about this comment block:
WARNING: Block comments should align the * on each line #166: FILE:
boot/android_ab.c:344:(quoted diff) +2
-0+ /* + * If the backup doesn't match the primary, write theprimary
To reproduce, run:
$ ./scripts/checkpatch.pl --strict --u-boot --git HEAD^..HEADQuoted 24 lines
With the above addressed, please send a v5 including:
Reviewed-by Mattijs Korpershoek <[email protected]>boot/android_ab.c int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
Quoted 3 lines
boot/android_ab.c +3
-0+if (memcmp (backup_abc, abc,sizeof (*abc)) !=0 ) { + ret = ab_control_store(dev_desc, part_info, abc, +
CONFIG_ANDROID_AB_BACKUP_OFFSET);Quoted 15 lines
boot/android_ab.c +6
-3+if (ret <0 ) { +free (backup_abc); +free (abc); +return ret; + } } +free (backup_abc); } -free (backup_abc); -#endif free (abc); --2.34.1
With Mattijs comment addressed:
Reviewed-by Igor Opaniuk <[email protected]>--
Best regards - Atentamente - Meilleures salutationsIgor Opaniuk
mailto: [email protected]
skype: igor.opanyuk
https://www.linkedin.com/in/iopaniuk <http://ua.linkedin.com/in/iopaniuk
Hi,
Quoted 10 lines · Colin McAllister
- Addresses compiler error due to missing semicolon
- Removes use of preprocessor macros withANDROID_AB_BACKUP_OFFSETBug was found by noticing a semicolon was missing and not causing a compiler error when
CONFIG_ANDROID_AB_BACKUP_OFFSETwas set. I submitted a patch to fix the semicolon before fixing the #if's. Testing the latter patch without the former withANDORID_AB_BACKUP_OFFSETset will cause a compiler error.[...]
Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-dfu (u-boot-dfu)
[1/2] android_ab: Add missing semicolon
https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/c044f89bb0c2683bcb14006b697ee6db2240f00d [2/2] android_ab: Fix ANDROID_AB_BACKUP_OFFSET https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/026e0cd31278bcafcfb35d21478a94fc5072f78c
--
Mattijs