Code review comment for lp:~epics-core/epics-base/epicsTime-status

Revision history for this message
Andrew Johnson (anj) wrote :

The problem with keeping the epicsTimeERROR definition is that any code that equality compares it with a returned status value will stop working. Several such uses were fixed in this branch, for example this code would still compile with the requested change but needs to be modified to work properly:
  if (epicsTimeFromTimespec(&timeNow, &timespecNow) == epicsTimeERROR) { ... }
since epicsTimeFromTimespec() now returns S_time_conversion on error.

It could be rewritten as either
  if (epicsTimeFromTimespec(&timeNow, &timespecNow) != epicsTimeOK) { ... }
or
  if (epicsTimeFromTimespec(&timeNow, &timespecNow)) { ... }
both of which are backwards compatible.

Time providers that have to return a status and need to be backwards compatible could do this:

#include "epicsTime.h"
#ifndef M_time
/* S_time_... status values were not provided before Base 3.16 */
#define S_time_unsynchronized epicsTimeERROR
#define S_time_...whatever... epicsTimeERROR
#endif

I added the above suggestion for time provider code to the release notes.

« Back to merge proposal