Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert defines to constant variables #1439

Open
skliper opened this issue Apr 28, 2021 · 0 comments
Open

Convert defines to constant variables #1439

skliper opened this issue Apr 28, 2021 · 0 comments

Comments

@skliper
Copy link
Contributor

skliper commented Apr 28, 2021

Is your feature request related to a problem? Please describe.
Defines are both discouraged by standards and clumsy when type matters.

Describe the solution you'd like
Convert to constant variables, performance is maintained and get type checking.

Use has started but should really convert the existing defines, example:

const char CFE_FS_DEFAULT_SCRIPT_EXTENSION[] = ".scr";
const char CFE_FS_DEFAULT_DUMP_FILE_EXTENSION[] = ".dat";
const char CFE_FS_DEFAULT_TEMP_FILE_EXTENSION[] = ".tmp";
const char CFE_FS_DEFAULT_LOG_FILE_EXTENSION[] = ".log";

Example of improvements, filters as const variables would allow overflow checking:

/** \name Common Event Filter Mask Values */
/** \{ */
#define CFE_EVS_NO_FILTER 0x0000 /**< \brief Stops any filtering. All messages are sent. */
#define CFE_EVS_FIRST_ONE_STOP 0xFFFF /**< \brief Sends the first event. All remaining messages are filtered. */
#define CFE_EVS_FIRST_TWO_STOP 0xFFFE /**< \brief Sends the first 2 events. All remaining messages are filtered. */
#define CFE_EVS_FIRST_4_STOP 0xFFFC /**< \brief Sends the first 4 events. All remaining messages are filtered. */
#define CFE_EVS_FIRST_8_STOP 0xFFF8 /**< \brief Sends the first 8 events. All remaining messages are filtered. */
#define CFE_EVS_FIRST_16_STOP 0xFFF0 /**< \brief Sends the first 16 events. All remaining messages are filtered. */
#define CFE_EVS_FIRST_32_STOP 0xFFE0 /**< \brief Sends the first 32 events. All remaining messages are filtered. */
#define CFE_EVS_FIRST_64_STOP 0xFFC0 /**< \brief Sends the first 64 events. All remaining messages are filtered. */
#define CFE_EVS_EVERY_OTHER_ONE 0x0001 /**< \brief Sends every other event. */
#define CFE_EVS_EVERY_OTHER_TWO 0x0002 /**< \brief Sends two, filters one, sends two, filters one, etc */
#define CFE_EVS_EVERY_FOURTH_ONE 0x0003 /**< \brief Sends every fourth event message. All others are filtered. */
/** \} */

Describe alternatives you've considered
None.

Additional context
Code review

Requester Info
Jacob Hageman - NASA/GSFC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant