flash/nor/stm32f1x: Some small code cleanups 04/5404/6
authorMarc Schink <dev@zapb.de>
Sun, 19 Jan 2020 15:56:16 +0000 (16:56 +0100)
committerTomas Vanek <vanekt@fbl.cz>
Sun, 23 Feb 2020 12:28:29 +0000 (12:28 +0000)
Change-Id: I1fc08b96b179a1376af233b713ae50d6ad7867a0
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/5404
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
src/flash/nor/stm32f1x.c

index 91fd541f6dd01e633c892d8f447a728e05778644..ba0d54e798496cca0debacfe0317399020c15dd1 100644 (file)
@@ -116,7 +116,7 @@ struct stm32x_options {
 struct stm32x_flash_bank {
        struct stm32x_options option_bytes;
        int ppage_size;
-       int probed;
+       bool probed;
 
        bool has_dual_banks;
        /* used to access dual flash bank stm32xl */
@@ -145,7 +145,7 @@ FLASH_BANK_COMMAND_HANDLER(stm32x_flash_bank_command)
        stm32x_info = malloc(sizeof(struct stm32x_flash_bank));
 
        bank->driver_priv = stm32x_info;
-       stm32x_info->probed = 0;
+       stm32x_info->probed = false;
        stm32x_info->has_dual_banks = false;
        stm32x_info->can_load_options = false;
        stm32x_info->register_base = FLASH_REG_BASE_B0;
@@ -368,7 +368,6 @@ static int stm32x_protect_check(struct flash_bank *bank)
 static int stm32x_erase(struct flash_bank *bank, int first, int last)
 {
        struct target *target = bank->target;
-       int i;
 
        if (bank->target->state != TARGET_HALTED) {
                LOG_ERROR("Target not halted");
@@ -386,7 +385,7 @@ static int stm32x_erase(struct flash_bank *bank, int first, int last)
        if (retval != ERROR_OK)
                return retval;
 
-       for (i = first; i <= last; i++) {
+       for (int i = first; i <= last; i++) {
                retval = target_write_u32(target, stm32x_get_flash_reg(bank, STM32_FLASH_CR), FLASH_PER);
                if (retval != ERROR_OK)
                        return retval;
@@ -697,7 +696,7 @@ static int stm32x_probe(struct flash_bank *bank)
        int page_size;
        uint32_t base_address = 0x08000000;
 
-       stm32x_info->probed = 0;
+       stm32x_info->probed = false;
        stm32x_info->register_base = FLASH_REG_BASE_B0;
        stm32x_info->user_data_offset = 10;
        stm32x_info->option_offset = 0;
@@ -886,7 +885,7 @@ static int stm32x_probe(struct flash_bank *bank)
        if (num_prot_blocks == 32)
                bank->prot_blocks[31].size = (num_pages - (31 * stm32x_info->ppage_size)) * page_size;
 
-       stm32x_info->probed = 1;
+       stm32x_info->probed = true;
 
        return ERROR_OK;
 }
@@ -1474,8 +1473,6 @@ static int stm32x_mass_erase(struct flash_bank *bank)
 
 COMMAND_HANDLER(stm32x_handle_mass_erase_command)
 {
-       int i;
-
        if (CMD_ARGC < 1)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
@@ -1487,7 +1484,7 @@ COMMAND_HANDLER(stm32x_handle_mass_erase_command)
        retval = stm32x_mass_erase(bank);
        if (retval == ERROR_OK) {
                /* set all sectors as erased */
-               for (i = 0; i < bank->num_sectors; i++)
+               for (int i = 0; i < bank->num_sectors; i++)
                        bank->sectors[i].is_erased = 1;
 
                command_print(CMD, "stm32x mass erase complete");

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)