#1300 closed defect

libchip/serial/serial.h: volatile boolean bActive

Reported by: Ralf Corsepius Owned by: Joel Sherrill
Priority: normal Milestone: 4.9
Component: unspecified Version: 4.9
Severity: major Keywords:
Cc: Blocked By:
Blocking:

Description (last modified by Chris Johns)

libchip/serial/serial.h contains this code:

typedef struct _console_data {

void *termios_data;
volatile boolean bActive;
/*

  • This field may be used for any purpose required by the driver */

void *pDeviceContext;

} console_data;

IMO, the "volatile boolean bActive" is "plain wrong and broken".

Rationale: So far, "boolean" is an RTEMS internal type of arbitrary size, potentially varying between targets. The same consideration applies to "bool".
=> writing to a "volatile bool/boolean" will have arbitrary effects, because it may write to memory of arbitrary width. Converting bActive to "bool" definitely is wrong.

What to do with this?

IMO, bActive should not be volatile but should be written to some hardware address using some "write32/writeword" (or similar) functions.
A short term band aid would be not to use boolean/bool for bActive, but to use a fixed width integer. Provided the code in libchip/serial/*, which I assume to be usable on 32bit targets only, I am inclined to think an int32_t could work.

Change History (3)

comment:1 Changed on Sep 2, 2008 at 12:36:31 PM by Ralf Corsepius

Then ... why is this volatile?

Provided what you say, I don't see any reason for marking it volatile.

comment:2 Changed on Nov 20, 2014 at 3:47:18 AM by Chris Johns

Description: modified (diff)
Resolution: wontfix
Status: newclosed

Buttered fish (bF for short)

comment:3 Changed on Oct 10, 2017 at 6:35:44 AM by Sebastian Huber

Component: miscunspecified
Note: See TracTickets for help on using tickets.