fritz-tools: fritz_tffs_nand: exclude oob code when disabled
authorAndre Heider <a.heider@gmail.com>
Wed, 15 Dec 2021 10:38:20 +0000 (11:38 +0100)
committerDavid Bauer <mail@david-bauer.net>
Wed, 7 Dec 2022 11:30:10 +0000 (12:30 +0100)
Skip unnecessary stuff if checking the oob data is disabled.

Signed-off-by: Andre Heider <a.heider@gmail.com>
package/utils/fritz-tools/src/fritz_tffs_nand_read.c

index 22b27336f89df0b8a2ba0f6ccfead585604b9a7f..32f3cdf6935ad308d8d9ff4d9ad316dd77c974ae 100644 (file)
@@ -186,15 +186,18 @@ static int find_entry(uint32_t id, struct tffs_entry *entry)
                                fprintf(stderr, "ERROR: sector isn't readable, but has been previously!\n");
                                exit(EXIT_FAILURE);
                        }
-                       uint32_t oob_id = read_uint32(oobbuf, 0x02);
-                       uint32_t oob_len = read_uint32(oobbuf, 0x06);
-                       uint32_t oob_rev = read_uint32(oobbuf, 0x0a);
                        uint32_t read_id = read_uint32(readbuf, 0x00);
                        uint32_t read_len = read_uint32(readbuf, 0x04);
                        uint32_t read_rev = read_uint32(readbuf, 0x0c);
-                       if (read_oob_sector_health && (oob_id != read_id || oob_len != read_len || oob_rev != read_rev)) {
-                               fprintf(stderr, "Warning: sector has inconsistent metadata\n");
-                               continue;
+                       if (read_oob_sector_health) {
+                               uint32_t oob_id = read_uint32(oobbuf, 0x02);
+                               uint32_t oob_len = read_uint32(oobbuf, 0x06);
+                               uint32_t oob_rev = read_uint32(oobbuf, 0x0a);
+
+                               if (oob_id != read_id || oob_len != read_len || oob_rev != read_rev) {
+                                       fprintf(stderr, "Warning: sector has inconsistent metadata\n");
+                                       continue;
+                               }
                        }
                        if (read_id == TFFS_ID_END) {
                                /* no more entries in this block */