This is the mail archive of the ecos-bugs@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug 1001510] Fix compiler warnings about mismatch between log()format string and argument values.


Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001510

--- Comment #8 from Grant Edwards <grant.b.edwards@gmail.com> 2012-03-09 14:56:42 GMT ---
(In reply to comment #6)

>>> You're right.  Both fields in struct timeval are signed.  tv_sec
>>> is 'int' and tv_usec is 'long int'.
> 
> I don't see that.

Well, I "saw" it, but it wasn't really there...

> The default is that in isoinfra, struct timeval is set to contain
> two time_t's, which by default are ints. If POSIX is included, then
> that is overridden[1] so it contains two longs. I don't see any mix
> of int and long. Are you thinking of struct timespec instead?

Yes, I was looking at the definition for timespec.

> Although we're not yet in a position to convert wholesale to 64-bit
> time_t, using long would not be sufficient when we did - it would
> need to be long long and so %lld.
>
> But in the first instance, yes we could change time_t to a long. And
> I'm attaching a patch to do that which I think I ought to commit
> regardless.  Comments?

Agreed.

> Even so, the format specifier for time_t does happen to be a particular
> problem. So for this file, how about instead using something like:
> 
> #define INTFORMAT(_t_) (sizeof(_t_) == sizeof(long long) ? "lld" : "ld")
>
> log(LOG_DEBUG, "%s: = %" INTFORMAT(tp->tv_sec) ".%06" INTFORMAT(tp->tv_usec) "\n", __FUNCTION__, 

That looks like a good solution.  The evaluation of the the ternary
expression should happen at compile time so it won't slow down the
log() operation any.

Unless anybody objects, I'll go ahead and commit that.

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]