On Fri, 2009-06-19 at 17:40 -0700, Zach Welch wrote: > On Fri, 2009-06-19 at 20:31 -0400, Duane Ellis wrote: > > duane> FYI - I committed several cygwin specific printf() warning fixes. > > duane> Simple cast to fix > > duane> these where causing "-Werror" failures on cygwin. > > > > zach> I was just about to post some patches to show how to fix all of these > > zach> correctly, as casts are not the right way to do it. > > > > In some cases, I can agree, but in others - I don't agree. A cast is by > > far the most simplest solution. > > > > For instance, look at this: > > > > LOG_WARNING("writing %d bytes only - as image section is %d > > bytes and bank is only %d bytes", \ > > (int)(c->base + c->size - run_address), > > (int)(run_size), (int)(c->size)); > > > > (a) look at what is being printed > > (b) the possible ranges of numbers > > (c) the number of parameters involved in the expressions > > > > At some point - having to dig back 20 to 30 -lines- to *random* places - > > because some variables are: > > > > (1) function parameters > > (2) defined at the top most block > > (3) defined locally to the local block > > (4) defined a few lines down from the top most block > > (5) often simplistic 'i/j/k' type vars that are reused because they are > > handy. > > (6) By the time I personally dig through the above, and determine all > > types involved > > (7) Then understand the underlying arithmetic integer promotion order... > > *note* this set of equations are simple... > > (8) a cast to a basic type is truly a very *simple* solution, > > (9) a cast to a basic type in this case is the K.I.S.S. solution. > > > > Either that - or we *need* a different solution here, the above is absurd. > > > > Comments? > > The simple solution is not the correct one in this case. The problem > is that your assumptions about ranges are not portable; that is the > point in using these macros. > > I don't care one white about KISS if the code is wrong.
s/white/whit/ To be more constructive, I see two possibilities: 1) Revisit all of the places where warnings require format changes, and make the correct changes to support the C99 types. 2) Revert the changes to the type system. I am opposed to reverting the changes; I would rather we take some time to audit the code and fix the system to ensure we improve portability. In the same process, we could also fix up the 160 odd places where strtoul is used without sufficient error checking. With a few volunteers and some coordinated effort, we could address a lot of minor issues throughout the tree without any individual investing much effort. Cheers, Zach _______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development