Skip to content

Unsafe macros, investigate conversion into Inline functions #172

@skliper

Description

@skliper

Some places in CFE -- notably, in ccsds.h -- there are macros
that do things like this:

{{{
#define CCSDS_WR_APID(phdr,value)
( (phdr).foo[0] = (value >> 8),
(phdr).foo[1] = (value & 0xFF) )
}}}

This means that if "value" is an expression, odd things happen
when the macro is expanded. This appears in many places in ccsds.h
and we need to do a scan of other headers as well.

It needs to be:
{{{
#define CCSDS_WR_APID(phdr,value)
( (phdr).foo[0] = ((value) >> 8),
(phdr).foo[1] = ((value) & 0xFF) )
}}}
This change needs to happen for all the places where a macro
parameter is an operand in an experession, and does not yet
have parens around it.

UPDATE 2017-10-27: CCB recommends that in many cases we would
benefit from changing these macros into C99 "inline" functions,
so this ticket is being hijacked!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions