As I posted to the list a couple of days ago, I'm trying to figure out
why perfectly legitimate hex files are causing avrdude to give me
errors. In the process of trying to understand what the relevant code
is doing I found what seems to be an error in the code, though it's more
of an inefficiency.
At about line 175 in fileio.c, in ihex_readrec(), there is a test at the
beginning that there are at least two characters available for the byte
count:
if (offset + 2 > len)
return -1;
The way I read the description of the intel hex format the minimum legal
length of a record is 11 bytes. It seems to me that if the function
were just to test that the record length were at least 9, once it was
computed, you could drop several of the intermediate checks that the
record was long enough to make the next calculation.
// :ccAAAA0tDDDDDDDDss
// cc Byte count
// AAAA Address
// 0t Record Type
// DDDDDDDD Data
// ss Checksum
If each case where the test for length could fail, a different error
code were returned, I could see some diagnostic use for the multiple
tests, but since they all just return -1, it seems that you could save a
few CPU cycles for each record by just making sure that the length were
greater than the minimum, and then that the length and the cc value
agreed with each other.
Larry
--
Larry Colen [email protected] (from dos4est)
_______________________________________________
avrdude-dev mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev