Skip to content

CF odd use of macro in CF_CFDP_R2_CalcCrcChunk #63

@jphickey

Description

@jphickey

This issue was imported from the GSFC issue tracking system

Imported from: [GSFCCFS-1800] CF odd use of macro in CF_CFDP_R2_CalcCrcChunk
Originally submitted by: Hickey, Joseph P. (GSFC-582.0)[VANTAGE SYSTEMS INC] on Wed Nov 17 10:25:30 2021

Original Description:
This function appears to define a local macro inline just to avoid writing the same text a few times over. Example:

#define RXC t->state_data.r.r2.rx_crc_calc_bytes
    if (!RXC)
    {
        CF_CRC_Start(&t->crc);
    }

The "RXC" is then used in a number of places later as well.

Normally one would either declare a local pointer to the value, or just simply a local temp variable to hold the value during computation, updating the global at the end of the routine.

The major issue with a macro like this is that it is not scoped to this function. The "RXC" string remains defined as a macro after this function, and may unexpectedly replace any other occurrence of this symbol later in the file, should it ever appear.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions