From: Cyprien Laplace Date: Sun, 15 Feb 2015 22:03:21 +0000 (-0500) Subject: fix for Mac OS X X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=829d39fc9567fa0bce6914b321adf8910ca707c8;p=soft%2Ftools%2Flpctools fix for Mac OS X 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 --- diff --git a/parts.c b/parts.c index ce114ea..2033aee 100644 --- a/parts.c +++ b/parts.c @@ -58,7 +58,7 @@ struct part_desc* find_part_in_file(uint64_t dev_id, char* parts_file_name) 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; } @@ -94,6 +94,7 @@ struct part_desc* find_part_in_file(uint64_t dev_id, char* parts_file_name) 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); diff --git a/parts.h b/parts.h index ede171d..168dd99 100644 --- a/parts.h +++ b/parts.h @@ -32,6 +32,7 @@ struct part_desc { uint64_t part_id; char* name; + uint32_t pad; /* Flash */ uint32_t flash_base; uint32_t flash_size;