On Fri, 2009-06-19 at 21:35 -0400, Duane Ellis wrote: > Rick Altherr wrote: > > Rather than casting to int, should the printf's be using the PRI* > > macros for uint32_t? > > To be clear, the "LOG_INFO()" format string is: > > LOG_INFO("U_tg = %d mV, U_aux = %d mV, U_tgpwr = %d mV, I_tgpwr = %d mA, > D1 = %d, Target power %s %s\n", \ > > Really, if that is *truly* what is needed here, then I want to purchase > one of those chips. > Imagine, if that chip could *REALLY* withstand a 2^31 - millivolt input > *and* handle 2^31 milliAmps. > > The truth is somewhere else: > There are no convince functions to extract a simple integer instead. > The value is a U32 because the developer was _lazy_. > > The solution you suggest - is the tail wagging the dog.
The reality is that those values probably come across the wire in those data types, so it was _safer_ to use that type -- which is then known to be sufficient to hold all possible data values. This is particularly important in case these values are stored in a fixed point value, though your case in point does not demonstrate such need. The C99 macro solution will fix the warnings correctly without disrupting code that is unrelated to formatting existing values. Cheers, Zach _______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development