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

Grant Edwards <grant.b.edwards@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|NOTABUG                     |

--- Comment #4 from Grant Edwards <grant.b.edwards@gmail.com> 2012-03-06 22:04:31 GMT ---
For some reason, I wasn't getting warnings for a while, but now I am
getting them again.  I'm a little puzzled by this, but here are the
warnings I'm getting with gcc 4.6.2:

bsd_tcpip/current/src/ecos/support.c:543:5: warning: format '%ld' expects
argument of type 'long int', but argument 3 has type 'time_t' [-Wformat]
bsd_tcpip/current/src/ecos/support.c:543:5: warning: format '%ld' expects
argument of type 'long int', but argument 4 has type 'time_t' [-Wformat]
bsd_tcpip/current/src/ecos/support.c:551:5: warning: format '%ld' expects
argument of type 'long int', but argument 3 has type 'time_t' [-Wformat]
bsd_tcpip/current/src/ecos/support.c:551:5: warning: format '%ld' expects
argument of type 'long int', but argument 4 has type 'time_t' [-Wformat]
bsd_tcpip/current/src/ecos/support.c:559:5: warning: format '%ld' expects
argument of type 'long int', but argument 3 has type 'time_t' [-Wformat]
bsd_tcpip/current/src/ecos/support.c:559:5: warning: format '%ld' expects
argument of type 'long int', but argument 4 has type 'time_t' [-Wformat]

It looks like tv_sec is always time_t (signed int), but depending on
CDL options, tv_usec can be time_t or unsigned long.  I'm now thinking
the right thing to do is to leave the format as %ld and cast each of
the parameters to (long).  Assuming the fields remain signed types,
that should work correctly regardless of whether they're (int) or
(long int).

Any opinions on whether we should change the format from "%ld.%ld" to
"%ld.%06ld"?  With the current format, 1sec+6usec is displayed as
"1.6" -- I think it would be more intuitive if it were displayed as
"1.000006" but I don't know if that's going to break some sort of
automated regression testing.

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


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