Notice: We have migrated to GitLab launching 2024-05-01 see here: https://gitlab.rtems.org/

#4035 closed enhancement (fixed)

Reserved identifier "time" re-used in rtems_clock_get_tod_timeval()

Reported by: Jens Schweikhardt Owned by: Sebastian Huber <sebastian.huber@…>
Priority: normal Milestone:
Component: rtems Version: 5
Severity: minor Keywords: qualification
Cc: Blocked By:
Blocking:

Description

The ISO C identifier "time" from time.h is re-used in the prototype and definition of the rtems_clock_get_tod_timeval() function (and maybe elsewhere too).
In certain cases this could lead to undefined behavior.
It certainly upsets our lint (Gimpel FlexeLint?).
It's good software hygiene to avoid shadowing ISO C identifiers.
Desired change: in cpukit/rtems/src/clockgettodtimeval.c
use an unreserved identifier.

Attachments (1)

x.diff (1.5 KB) - added by Jens Schweikhardt on 08/01/20 at 08:38:16.
time-is-reserved

Download all attachments as: .zip

Change History (6)

comment:1 Changed on 07/31/20 at 13:58:47 by Jens Schweikhardt

The header should also be fixed, cpukit/include/rtems/rtems/clock.h

comment:2 Changed on 07/31/20 at 14:31:47 by Joel Sherrill

Could you please provide a patch for this? It seems like a reasonable and mostly benign change but will ripple to Doxygen and documentation. If you fix the code to make your Flexelint happy, then we can be sure it is really fixed.

Changed on 08/01/20 at 08:38:16 by Jens Schweikhardt

Attachment: x.diff added

time-is-reserved

comment:3 Changed on 08/01/20 at 08:45:40 by Jens Schweikhardt

I've attached a patch renaming time to the_time, also in doxygen comments.
I'm new to git and followed the instructions for patch creation but ran into a wall with git format-patch (no output anywhere I could find). So I used git diff. The commit message could be

Rename the reserved identifier "time" to "the_time" to not invade ISO C name space.

comment:4 Changed on 06/18/21 at 09:24:45 by Sebastian Huber

Keywords: qualification added

comment:5 Changed on 09/30/21 at 05:27:48 by Sebastian Huber <sebastian.huber@…>

Owner: set to Sebastian Huber <sebastian.huber@…>
Resolution: fixed
Status: newclosed

In [changeset:"dde74af944553de87c18fe1f4973e4899193dd3b/rtems" dde74af/rtems]:

rtems: Adjust parameter names

Adjust parameter names to match with the declaration. This avoid using
a name reserved by the C standard: "time".

Close #4035.

Note: See TracTickets for help on using tickets.