Two small fixes to let lpcprog work on OS X Yosemite:
- initialize errno to 0 before strtoul() and errno testing
- pad the parts structure as OSX seems to align the size of the
structure on 64-bit boundary, which made it think there were 10
values to read instead of 9
goto out_err_1;
}
line++; /* Store current line number to help parts description file correction */
- if (buf[0] == '#') {
+ if (buf[0] == '#' || buf[0] == '\n') {
/* skip comments */
continue;
}
nval = ((sizeof(struct part_desc) - offsetof(struct part_desc, flash_base)) / sizeof(uint32_t));
part_values = &(part->flash_base); /* Use a table to read the data, we do not care of what the data is */
for (i = 0; i < nval; i++) {
+ errno = 0;
part_values[i] = strtoul((endp + 1), &endp, 0);
if ((part_values[i] == 0) && (errno == EINVAL)) {
printf("Malformed parts description file at line %d, error reading value %d\n", line, i);
struct part_desc {
uint64_t part_id;
char* name;
+ uint32_t pad;
/* Flash */
uint32_t flash_base;
uint32_t flash_size;