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

Fix #288, Remove unnecessary CF_UnionArgs_Payload_t union #400

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions fsw/inc/cf_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -870,16 +870,6 @@ typedef struct CF_NoArgsCmd
CFE_MSG_CommandHeader_t cmd_header; /**< \brief Command header */
} CF_NoArgsCmd_t;

/**
* \brief Command payload argument union to support 4 uint8's, 2 uint16's or 1 uint32
*/
typedef union CF_UnionArgs_Payload
{
uint32 dword; /**< \brief Generic uint32 argument */
uint16 hword[2]; /**< \brief Generic uint16 array of arguments */
uint8 byte[4]; /**< \brief Generic uint8 array of arguments */
} CF_UnionArgs_Payload_t;

/**
* \brief Generic command structure with arguments supports common handling on multiple command types
*
Expand All @@ -889,7 +879,7 @@ typedef union CF_UnionArgs_Payload
typedef struct
{
CFE_MSG_CommandHeader_t cmd_header; /**< \brief Command header */
CF_UnionArgs_Payload_t data; /**< \brief Generic command arguments */
uint8 byte[4]; /**< \brief Generic uint8 array of arguments */
} CF_UnionArgsCmd_t;

/**
Expand Down
22 changes: 11 additions & 11 deletions fsw/src/cf_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
CF_UnionArgsCmd_t *cmd = (CF_UnionArgsCmd_t *)msg;
static const char *names[5] = {"all", "cmd", "fault", "up", "down"};
/* 0=all, 1=cmd, 2=fault 3=up 4=down */
uint8 param = cmd->data.byte[0];
uint8 param = cmd->byte[0];
int i;
int acc = 1;

Expand Down Expand Up @@ -220,21 +220,21 @@
/* this function is generic for any ground command that takes a single channel
* argument which must be less than CF_NUM_CHANNELS or 255 which is a special
* value that means apply command to all channels */
if (cmd->data.byte[0] == CF_ALL_CHANNELS)
if (cmd->byte[0] == CF_ALL_CHANNELS)
{
/* apply to all channels */
for (i = 0; i < CF_NUM_CHANNELS; ++i)
ret |= fn(i, context);
}
else if (cmd->data.byte[0] < CF_NUM_CHANNELS)
else if (cmd->byte[0] < CF_NUM_CHANNELS)
{
ret = fn(cmd->data.byte[0], context);
ret = fn(cmd->byte[0], context);

Check notice

Code scanning / CodeQL

Use of non-constant function pointer Note

This call does not go through a const function pointer.
}
else
{
/* bad parameter */
CFE_EVS_SendEvent(CF_EID_ERR_CMD_CHAN_PARAM, CFE_EVS_EventType_ERROR,
"CF: %s: channel parameter out of range. received %d", errstr, cmd->data.byte[0]);
"CF: %s: channel parameter out of range. received %d", errstr, cmd->byte[0]);
ret = -1;
}

Expand Down Expand Up @@ -591,20 +591,20 @@
int i;
CFE_Status_t ret = CFE_SUCCESS;
/* no need to bounds check chan_num, done in caller */
if (context->msg->data.byte[1] == CF_ALL_POLLDIRS)
if (context->msg->byte[1] == CF_ALL_POLLDIRS)
{
/* all polldirs in channel */
for (i = 0; i < CF_MAX_POLLING_DIR_PER_CHAN; ++i)
CF_AppData.config_table->chan[chan_num].polldir[i].enabled = context->barg;
}
else if (context->msg->data.byte[1] < CF_MAX_POLLING_DIR_PER_CHAN)
else if (context->msg->byte[1] < CF_MAX_POLLING_DIR_PER_CHAN)
{
CF_AppData.config_table->chan[chan_num].polldir[context->msg->data.byte[1]].enabled = context->barg;
CF_AppData.config_table->chan[chan_num].polldir[context->msg->byte[1]].enabled = context->barg;
}
else
{
CFE_EVS_SendEvent(CF_EID_ERR_CMD_POLLDIR_INVALID, CFE_EVS_EventType_ERROR,
"CF: enable/disable polldir: invalid polldir %d on channel %d", context->msg->data.byte[1],
"CF: enable/disable polldir: invalid polldir %d on channel %d", context->msg->byte[1],
chan_num);
ret = CF_ERROR;
}
Expand Down Expand Up @@ -703,7 +703,7 @@
int pend = 0;
int hist = 0;

switch (cmd->data.byte[1])
switch (cmd->byte[1])
{
case 0: /* pend */
pend = 1;
Expand All @@ -720,7 +720,7 @@

default:
CFE_EVS_SendEvent(CF_EID_ERR_CMD_PURGE_ARG, CFE_EVS_EventType_ERROR, "CF: purge queue invalid arg %d",
cmd->data.byte[1]);
cmd->byte[1]);
ret = -1;
break;
}
Expand Down
Loading