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.

Cheers,

Zach
_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to