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 */
/* 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;
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);
}
}
- image->start_address_set = 1;
+ image->start_address_set = true;
image->start_address = field32(elf, elf->header->e_entry);
return ERROR_OK;
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 */
/* 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;
}
} 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 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;
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;
}
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");
keep_alive();
}
- LOG_DEBUG("Calculating checksum done");
+ LOG_DEBUG("Calculating checksum done; checksum=0x%" PRIx32, crc);
*checksum = crc;
return ERROR_OK;