target/cortex_m: Change sleep to running state
[openocd.git] / src / target / image.c
index 1003c3bdce479a56729e5cf1b3b458a2ffb9dbf4..20c6d77b28213e946640e9b6d359544908f22eea 100644 (file)
@@ -124,7 +124,6 @@ static int image_ihex_buffer_complete_inner(struct image *image,
        uint32_t full_address;
        uint32_t cooked_bytes;
        bool end_rec = false;
-       int i;
 
        /* we can't determine the number of sections that we'll have to create ahead of time,
         * so we locally hold them until parsing is finished */
@@ -207,7 +206,7 @@ static int image_ihex_buffer_complete_inner(struct image *image,
 
                                /* copy section information */
                                image->sections = malloc(sizeof(struct imagesection) * image->num_sections);
-                               for (i = 0; i < image->num_sections; i++) {
+                               for (unsigned int i = 0; i < image->num_sections; i++) {
                                        image->sections[i].private = section[i].private;
                                        image->sections[i].base_address = section[i].base_address;
                                        image->sections[i].size = section[i].size;
@@ -294,7 +293,7 @@ static int image_ihex_buffer_complete_inner(struct image *image,
                                cal_checksum += (uint8_t)start_address;
                                bytes_read += 8;
 
-                               image->start_address_set = 1;
+                               image->start_address_set = true;
                                image->start_address = be_to_h_u32((uint8_t *)&start_address);
                        } else {
                                LOG_ERROR("unhandled IHEX record type: %i", (int)record_type);
@@ -471,7 +470,7 @@ static int image_elf_read_headers(struct image *image)
                }
        }
 
-       image->start_address_set = 1;
+       image->start_address_set = true;
        image->start_address = field32(elf, elf->header->e_entry);
 
        return ERROR_OK;
@@ -529,7 +528,6 @@ static int image_mot_buffer_complete_inner(struct image *image,
        uint32_t full_address;
        uint32_t cooked_bytes;
        bool end_rec = false;
-       int i;
 
        /* we can't determine the number of sections that we'll have to create ahead of time,
         * so we locally hold them until parsing is finished */
@@ -658,7 +656,7 @@ static int image_mot_buffer_complete_inner(struct image *image,
 
                                /* copy section information */
                                image->sections = malloc(sizeof(struct imagesection) * image->num_sections);
-                               for (i = 0; i < image->num_sections; i++) {
+                               for (unsigned int i = 0; i < image->num_sections; i++) {
                                        image->sections[i].private = section[i].private;
                                        image->sections[i].base_address = section[i].base_address;
                                        image->sections[i].size = section[i].size;
@@ -821,21 +819,20 @@ int image_open(struct image *image, const char *url, const char *type_string)
                }
        } else if (image->type == IMAGE_BUILDER) {
                image->num_sections = 0;
-               image->base_address_set = 0;
+               image->base_address_set = false;
                image->sections = NULL;
                image->type_private = NULL;
        }
 
        if (image->base_address_set) {
                /* relocate */
-               int section;
-               for (section = 0; section < image->num_sections; section++)
+               for (unsigned int section = 0; section < image->num_sections; section++)
                        image->sections[section].base_address += image->base_address;
                                                                                        /* we're done relocating. The two statements below are mainly
-                                                                                       * for documenation purposes: stop anyone from empirically
+                                                                                       * for documentation purposes: stop anyone from empirically
                                                                                        * thinking they should use these values henceforth. */
                image->base_address = 0;
-               image->base_address_set = 0;
+               image->base_address_set = false;
        }
 
        return retval;
@@ -984,61 +981,45 @@ void image_close(struct image *image)
 
                fileio_close(image_ihex->fileio);
 
-               if (image_ihex->buffer) {
-                       free(image_ihex->buffer);
-                       image_ihex->buffer = NULL;
-               }
+               free(image_ihex->buffer);
+               image_ihex->buffer = NULL;
        } else if (image->type == IMAGE_ELF) {
                struct image_elf *image_elf = image->type_private;
 
                fileio_close(image_elf->fileio);
 
-               if (image_elf->header) {
-                       free(image_elf->header);
-                       image_elf->header = NULL;
-               }
+               free(image_elf->header);
+               image_elf->header = NULL;
 
-               if (image_elf->segments) {
-                       free(image_elf->segments);
-                       image_elf->segments = NULL;
-               }
+               free(image_elf->segments);
+               image_elf->segments = NULL;
        } else if (image->type == IMAGE_MEMORY) {
                struct image_memory *image_memory = image->type_private;
 
-               if (image_memory->cache) {
-                       free(image_memory->cache);
-                       image_memory->cache = NULL;
-               }
+               free(image_memory->cache);
+               image_memory->cache = NULL;
        } else if (image->type == IMAGE_SRECORD) {
                struct image_mot *image_mot = image->type_private;
 
                fileio_close(image_mot->fileio);
 
-               if (image_mot->buffer) {
-                       free(image_mot->buffer);
-                       image_mot->buffer = NULL;
-               }
+               free(image_mot->buffer);
+               image_mot->buffer = NULL;
        } else if (image->type == IMAGE_BUILDER) {
-               int i;
-
-               for (i = 0; i < image->num_sections; i++) {
+               for (unsigned int i = 0; i < image->num_sections; i++) {
                        free(image->sections[i].private);
                        image->sections[i].private = NULL;
                }
        }
 
-       if (image->type_private) {
-               free(image->type_private);
-               image->type_private = NULL;
-       }
+       free(image->type_private);
+       image->type_private = NULL;
 
-       if (image->sections) {
-               free(image->sections);
-               image->sections = NULL;
-       }
+       free(image->sections);
+       image->sections = NULL;
 }
 
-int image_calculate_checksum(uint8_t *buffer, uint32_t nbytes, uint32_t *checksum)
+int image_calculate_checksum(const uint8_t *buffer, uint32_t nbytes, uint32_t *checksum)
 {
        uint32_t crc = 0xffffffff;
        LOG_DEBUG("Calculating checksum");

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)