Skip to content

Commit

Permalink
PATCH: Use strict resource ID type
Browse files Browse the repository at this point in the history
  • Loading branch information
jphickey committed Oct 14, 2020
1 parent dc3d62b commit 97eadc5
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions fsw/cfe-core/src/inc/cfe_es.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@
* - Convert ID to simple integer (typically for printing/logging)
* - Convert simple integer to ID (inverse of above)
*/
typedef uint32 CFE_ES_ResourceID_t;
typedef struct CFE_ES_ResourceID
{
uint32 Val;
} CFE_ES_ResourceID_t;


/**
* \brief Memory Handle type
Expand Down Expand Up @@ -150,7 +154,7 @@ typedef uint32 CFE_ES_MemOffset_t;
* type via standard functions like memset(), such that objects initialzed
* using this method will also be set to safe values.
*/
#define CFE_ES_RESOURCEID_UNDEFINED ((CFE_ES_ResourceID_t)0)
#define CFE_ES_RESOURCEID_UNDEFINED ((CFE_ES_ResourceID_t){0})

/**
* @brief A resource ID value that represents a reserved entry
Expand All @@ -159,7 +163,7 @@ typedef uint32 CFE_ES_MemOffset_t;
* table entries that are not available for use. For instance, this may
* be used while setting up an entry initially.
*/
#define CFE_ES_RESOURCEID_RESERVED ((CFE_ES_ResourceID_t)0xFFFFFFFF)
#define CFE_ES_RESOURCEID_RESERVED ((CFE_ES_ResourceID_t){0xFFFFFFFF})

/**
* @brief Convert a resource ID to an integer.
Expand All @@ -185,7 +189,7 @@ typedef uint32 CFE_ES_MemOffset_t;
*/
static inline unsigned long CFE_ES_ResourceID_ToInteger(CFE_ES_ResourceID_t id)
{
return ((unsigned long)id);
return (id.Val);
}

/**
Expand All @@ -204,7 +208,7 @@ static inline unsigned long CFE_ES_ResourceID_ToInteger(CFE_ES_ResourceID_t id)
*/
static inline CFE_ES_ResourceID_t CFE_ES_ResourceID_FromInteger(unsigned long Value)
{
return ((CFE_ES_ResourceID_t)Value);
return ((CFE_ES_ResourceID_t){ .Val = Value });
}

/**
Expand All @@ -216,7 +220,7 @@ static inline CFE_ES_ResourceID_t CFE_ES_ResourceID_FromInteger(unsigned long Va
*/
static inline bool CFE_ES_ResourceID_Equal(CFE_ES_ResourceID_t id1, CFE_ES_ResourceID_t id2)
{
return (id1 == id2);
return (id1.Val == id2.Val);
}

/**
Expand All @@ -234,7 +238,7 @@ static inline bool CFE_ES_ResourceID_Equal(CFE_ES_ResourceID_t id1, CFE_ES_Resou
*/
static inline bool CFE_ES_ResourceID_IsDefined(CFE_ES_ResourceID_t id)
{
return (id != 0);
return (id.Val != 0);
}

/**
Expand Down

0 comments on commit 97eadc5

Please sign in to comment.