projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Flash multiple pages. Eliminate off-by-one error in hex_image length.
[fw/altos]
/
ccdbg-hex.c
diff --git
a/ccdbg-hex.c
b/ccdbg-hex.c
index ff155ff3f8fcbc0d6967b03d0408d95ad800593e..86478da07b8c5f262c6adfb675cccf6aa11f2528 100644
(file)
--- a/
ccdbg-hex.c
+++ b/
ccdbg-hex.c
@@
-119,6
+119,8
@@
ccdbg_hex_read_record(struct hex_input *input)
ccdbg_hex_error(input, "Unexpected EOF");
goto bail;
}
ccdbg_hex_error(input, "Unexpected EOF");
goto bail;
}
+ if (c == ' ')
+ continue;
if (c == '\n')
input->line++;
switch (state) {
if (c == '\n')
input->line++;
switch (state) {
@@
-290,17
+292,19
@@
ccdbg_hex_image_create(struct hex_file *hex)
int i;
uint32_t base, bound;
uint32_t offset;
int i;
uint32_t base, bound;
uint32_t offset;
+ int length;
first = hex->records[0];
last = hex->records[hex->nrecord - 2]; /* skip EOF */
base = (uint32_t) first->address;
first = hex->records[0];
last = hex->records[hex->nrecord - 2]; /* skip EOF */
base = (uint32_t) first->address;
- bound = (uint32_t) last->address + (uint32_t) last->length - 1;
- image = calloc(sizeof(struct hex_image) + bound - base, 1);
+ bound = (uint32_t) last->address + (uint32_t) last->length;
+ length = bound - base;
+ image = calloc(sizeof(struct hex_image) + length, 1);
if (!image)
return NULL;
image->address = base;
if (!image)
return NULL;
image->address = base;
- image->length =
bound - base
;
- memset(image->data, 0xff,
image->
length);
+ image->length =
length
;
+ memset(image->data, 0xff, length);
for (i = 0; i < hex->nrecord - 1; i++) {
record = hex->records[i];
offset = record->address - base;
for (i = 0; i < hex->nrecord - 1; i++) {
record = hex->records[i];
offset = record->address - base;