Skip to content

Commit

Permalink
Fix nasa#663, Scrub datatypes across TBL
Browse files Browse the repository at this point in the history
Fix all use of uint32 for sizes, replace with size_t
Scrub all other types to make sure use is consistent,
using proper typedef whenever available.
  • Loading branch information
jphickey committed Nov 18, 2020
1 parent 97d9fd5 commit c83fd48
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 266 deletions.
4 changes: 2 additions & 2 deletions fsw/cfe-core/src/inc/cfe_tbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ typedef enum CFE_TBL_SrcEnum
/** \brief Table Info */
typedef struct CFE_TBL_Info
{
uint32 Size; /**< \brief Size, in bytes, of Table */
size_t Size; /**< \brief Size, in bytes, of Table */
uint32 NumUsers; /**< \brief Number of Apps with access to the table */
uint32 FileCreateTimeSecs; /**< \brief File creation time from last file loaded into table */
uint32 FileCreateTimeSubSecs; /**< \brief File creation time from last file loaded into table */
Expand Down Expand Up @@ -265,7 +265,7 @@ typedef struct CFE_TBL_Info
**/
CFE_Status_t CFE_TBL_Register(CFE_TBL_Handle_t *TblHandlePtr, /* Returned Handle */
const char *Name, /* Application specific name */
uint32 Size, /* Size, in bytes, of table */
size_t Size, /* Size, in bytes, of table */
uint16 TblOptionFlags, /* Tbl Options Settings */
CFE_TBL_CallbackFuncPtr_t TblValidationFuncPtr); /* Ptr to func that validates tbl */

Expand Down
5 changes: 3 additions & 2 deletions fsw/cfe-core/src/inc/cfe_tbl_extern_typedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
/* Use the local definitions of these types */

#include "common_types.h"
#include "cfe_es_extern_typedefs.h"
#include <cfe_mission_cfg.h> /* for CFE_MISSION_TBL_MAX_FULL_NAME_LEN */

/**
Expand Down Expand Up @@ -69,8 +70,8 @@ typedef uint16 CFE_TBL_BufferSelect_En
typedef struct CFE_TBL_File_Hdr
{
uint32 Reserved; /**< Future Use: NumTblSegments in File? */
uint32 Offset; /**< Byte Offset at which load should commence */
uint32 NumBytes; /**< Number of bytes to load into table */
CFE_ES_MemOffset_t Offset; /**< Byte Offset at which load should commence */
CFE_ES_MemOffset_t NumBytes; /**< Number of bytes to load into table */
char TableName[CFE_MISSION_TBL_MAX_FULL_NAME_LEN]; /**< Fully qualified name of table to load */
} CFE_TBL_File_Hdr_t;

Expand Down
8 changes: 4 additions & 4 deletions fsw/cfe-core/src/inc/cfe_tbl_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -772,15 +772,15 @@ typedef struct CFE_TBL_HousekeepingTlm
**/
typedef struct CFE_TBL_TblRegPacket_Payload
{
uint32 Size; /**< \cfetlmmnemonic \TBL_SIZE
CFE_ES_MemOffset_t Size; /**< \cfetlmmnemonic \TBL_SIZE
\brief Size, in bytes, of Table */
uint32 Crc; /**< \cfetlmmnemonic \TBL_CRC
\brief Most recently calculated CRC of Table */
cpuaddr ActiveBufferAddr; /**< \cfetlmmnemonic \TBL_ACTBUFADD
CFE_ES_MemAddress_t ActiveBufferAddr; /**< \cfetlmmnemonic \TBL_ACTBUFADD
\brief Address of Active Buffer */
cpuaddr InactiveBufferAddr; /**< \cfetlmmnemonic \TBL_IACTBUFADD
CFE_ES_MemAddress_t InactiveBufferAddr; /**< \cfetlmmnemonic \TBL_IACTBUFADD
\brief Address of Inactive Buffer */
cpuaddr ValidationFuncPtr; /**< \cfetlmmnemonic \TBL_VALFUNCPTR
CFE_ES_MemAddress_t ValidationFuncPtr; /**< \cfetlmmnemonic \TBL_VALFUNCPTR
\brief Ptr to Owner App's function that validates tbl contents */
CFE_TIME_SysTime_t TimeOfLastUpdate; /**< \cfetlmmnemonic \TBL_TIMELASTUPD
\brief Time when Table was last updated */
Expand Down
2 changes: 1 addition & 1 deletion fsw/cfe-core/src/tbl/cfe_tbl_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
*/
int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr,
const char *Name,
uint32 Size,
size_t Size,
uint16 TblOptionFlags,
CFE_TBL_CallbackFuncPtr_t TblValidationFuncPtr )
{
Expand Down
2 changes: 1 addition & 1 deletion fsw/cfe-core/src/tbl/cfe_tbl_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ void CFE_TBL_TaskPipe(CFE_SB_Msg_t *MessagePtr)
CFE_SB_MsgId_t MessageID = CFE_SB_GetMsgId(MessagePtr);
uint16 CommandCode = CFE_SB_GetCmdCode(MessagePtr);
int16 CmdIndx;
uint32 ActualLength;
size_t ActualLength;
CFE_TBL_CmdProcRet_t CmdStatus = CFE_TBL_INC_ERR_CTR; /* Assume a failed command */

/* Search the Command Handler Table for a matching message */
Expand Down
6 changes: 3 additions & 3 deletions fsw/cfe-core/src/tbl/cfe_tbl_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ typedef struct
typedef struct
{
CFE_ES_ResourceID_t OwnerAppId; /**< \brief Application ID of App that Registered Table */
uint32 Size; /**< \brief Size, in bytes, of Table */
size_t Size; /**< \brief Size, in bytes, of Table */
CFE_SB_MsgId_t NotificationMsgId; /**< \brief Message ID of an associated management notification message */
uint32 NotificationParam; /**< \brief Parameter of an associated management notification message */
CFE_TBL_LoadBuff_t Buffers[2]; /**< \brief Active and Inactive Buffer Pointers */
Expand Down Expand Up @@ -238,7 +238,7 @@ typedef struct
typedef struct
{
CFE_TBL_DumpState_t State; /**< \brief Current state of this block of data */
uint32 Size; /**< \brief Number of bytes to be dumped */
size_t Size; /**< \brief Number of bytes to be dumped */
CFE_TBL_LoadBuff_t *DumpBufferPtr; /**< \brief Address where dumped data is to be stored temporarily */
CFE_TBL_RegistryRec_t *RegRecPtr; /**< \brief Ptr to dumped table's registry record */
char TableName[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \brief Name of Table being Dumped */
Expand All @@ -253,7 +253,7 @@ typedef struct
*/
typedef struct
{
uint32 Size; /**< \brief Size, in bytes, of Table */
CFE_ES_MemOffset_t Size; /**< \brief Size, in bytes, of Table */
CFE_TIME_SysTime_t TimeOfLastUpdate; /**< \brief Time when Table was last updated */
uint32 NumUsers; /**< \brief Number of applications that are sharing the table */
int32 LoadInProgress; /**< \brief Flag identifies inactive buffer and whether load in progress */
Expand Down
28 changes: 14 additions & 14 deletions fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,31 +274,31 @@ void CFE_TBL_GetTblRegData(void)

RegRecPtr = &CFE_TBL_TaskData.Registry[CFE_TBL_TaskData.HkTlmTblRegIndex];

CFE_TBL_TaskData.TblRegPacket.Payload.Size = RegRecPtr->Size;
CFE_SB_SET_MEMADDR(CFE_TBL_TaskData.TblRegPacket.Payload.ActiveBufferAddr,
RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].BufferPtr);
CFE_TBL_TaskData.TblRegPacket.Payload.Size = CFE_ES_MEMOFFSET_C(RegRecPtr->Size);
CFE_TBL_TaskData.TblRegPacket.Payload.ActiveBufferAddr =
CFE_ES_MEMADDRESS_C(RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].BufferPtr);

if (RegRecPtr->DoubleBuffered)
{
/* For a double buffered table, the inactive is the other allocated buffer */
CFE_SB_SET_MEMADDR(CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr,
RegRecPtr->Buffers[(1U-RegRecPtr->ActiveBufferIndex)].BufferPtr);
CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr =
CFE_ES_MEMADDRESS_C(RegRecPtr->Buffers[(1U-RegRecPtr->ActiveBufferIndex)].BufferPtr);
}
else
{
/* Check to see if an inactive buffer has currently been allocated to the single buffered table */
if (RegRecPtr->LoadInProgress != CFE_TBL_NO_LOAD_IN_PROGRESS)
{
CFE_SB_SET_MEMADDR(CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr,
CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].BufferPtr);
CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr =
CFE_ES_MEMADDRESS_C(CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].BufferPtr);
}
else
{
CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = 0;
CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = CFE_ES_MEMADDRESS_C(0);
}
}

CFE_SB_SET_MEMADDR(CFE_TBL_TaskData.TblRegPacket.Payload.ValidationFuncPtr, RegRecPtr->ValidationFuncPtr);
CFE_TBL_TaskData.TblRegPacket.Payload.ValidationFuncPtr = CFE_ES_MEMADDRESS_C(RegRecPtr->ValidationFuncPtr);
CFE_TBL_TaskData.TblRegPacket.Payload.TimeOfLastUpdate = RegRecPtr->TimeOfLastUpdate;
CFE_TBL_TaskData.TblRegPacket.Payload.TableLoadedOnce = RegRecPtr->TableLoadedOnce;
CFE_TBL_TaskData.TblRegPacket.Payload.LoadPending = RegRecPtr->LoadPending;
Expand Down Expand Up @@ -730,7 +730,7 @@ int32 CFE_TBL_DumpCmd(const CFE_TBL_Dump_t *data)
** NOTE: For complete prolog information, see prototype above
********************************************************************/

CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile( const char *DumpFilename, const char *TableName, const void *DumpDataAddr, uint32 TblSizeInBytes)
CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile( const char *DumpFilename, const char *TableName, const void *DumpDataAddr, size_t TblSizeInBytes)
{
CFE_TBL_CmdProcRet_t ReturnCode = CFE_TBL_INC_ERR_CTR; /* Assume failure */
bool FileExistedPrev = false;
Expand Down Expand Up @@ -769,8 +769,8 @@ CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile( const char *DumpFilename, const char *T
/* Initialize the Table Image Header for the Dump File */
strncpy(TblFileHeader.TableName, TableName, sizeof(TblFileHeader.TableName)-1);
TblFileHeader.TableName[sizeof(TblFileHeader.TableName)-1] = 0;
TblFileHeader.Offset = 0;
TblFileHeader.NumBytes = TblSizeInBytes;
TblFileHeader.Offset = CFE_ES_MEMOFFSET_C(0);
TblFileHeader.NumBytes = CFE_ES_MEMOFFSET_C(TblSizeInBytes);
TblFileHeader.Reserved = 0;

/* Determine if this is a little endian processor */
Expand All @@ -795,7 +795,7 @@ CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile( const char *DumpFilename, const char *T
DumpDataAddr,
TblSizeInBytes);

if (Status == (int32)TblSizeInBytes)
if (Status == TblSizeInBytes)
{
if (FileExistedPrev)
{
Expand Down Expand Up @@ -1172,7 +1172,7 @@ int32 CFE_TBL_DumpRegistryCmd(const CFE_TBL_DumpRegistry_t *data)
(RegRecPtr->HeadOfAccessList != CFE_TBL_END_OF_LIST))
{
/* Fill Registry Dump Record with relevant information */
DumpRecord.Size = RegRecPtr->Size;
DumpRecord.Size = CFE_ES_MEMOFFSET_C(RegRecPtr->Size);
DumpRecord.TimeOfLastUpdate = RegRecPtr->TimeOfLastUpdate;
DumpRecord.LoadInProgress = RegRecPtr->LoadInProgress;
DumpRecord.ValidationFunc = (RegRecPtr->ValidationFuncPtr != NULL);
Expand Down
4 changes: 2 additions & 2 deletions fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ typedef enum
typedef struct {
CFE_SB_MsgId_t MsgId; /**< \brief Acceptable Message ID */
uint32 CmdCode; /**< \brief Acceptable Command Code (if necessary) */
uint32 ExpectedLength; /**< \brief Expected Message Length (in bytes) including message header */
size_t ExpectedLength; /**< \brief Expected Message Length (in bytes) including message header */
CFE_TBL_MsgProcFuncPtr_t MsgProcFuncPtr; /**< \brief Pointer to function to handle message */
CFE_TBL_MsgType_t MsgTypes; /**< \brief Message Type (i.e. - with/without Cmd Code) */
} CFE_TBL_CmdHandlerTblRec_t;
Expand Down Expand Up @@ -329,7 +329,7 @@ int32 CFE_TBL_AbortLoadCmd(const CFE_TBL_AbortLoad_t *data);
** \retval #CFE_TBL_INC_CMD_CTR \copydoc CFE_TBL_INC_CMD_CTR
******************************************************************************/
extern CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile( const char *DumpFilename, const char *TableName,
const void *DumpDataAddr, uint32 TblSizeInBytes);
const void *DumpDataAddr, size_t TblSizeInBytes);

/*****************************************************************************/
/**
Expand Down
Loading

0 comments on commit c83fd48

Please sign in to comment.