Closed mariusgreuel closed 2 years ago
clean up the codebase. Any opinions?
Should do, though many of these are not real issues. Particularly the size_t vs int ones. Often, when I change a particular file, I would run a -Wall -Wpedantic type of compilation and then, en passant address those issues the compiler considers not clean. Just so the noise abates at higher warning levels. The risk, of course, is to introduce a bug when doing so (vvv easy espec with signed/unsigned issues). So, I always try to be careful about that kind of thing.
I noticed there is a new MSYS2 warning, https://github.com/avrdudes/avrdude/actions/runs/3193099836/jobs/5211315290#step:5:75 which appears to be bogus as the pointer is not dereferenced, however, I spotted a pointer truncation bug:
On Windows x64, sizeof(int)==4 and sizeof(void*)==8, i.e. for pointer arithmetic/conversion, we cannot use int. Instead, we need to use size_t, ptrdiff_t, and the like.
So the line
needs to be changed to
Sure enough, the MSVC compiler warns about this problem, however, I have the relevant warnings turned off due to a lot of noise from the AVRDUDE codebase. Normally, these warnings are essential to spot these kinds of bugs.
Not sure if we should enable these warnings, and perhaps clean up the codebase. Any opinions?
I quickly ran through the warnings, and I could only find two problems in
term.c:1211
andterm.c:1232
. For reference, here is the complete log with C4244 and C4267 turned on: