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

CS_AttemptTableReshare can be simplified #69

Closed
2 tasks done
thnkslprpt opened this issue Mar 19, 2023 · 0 comments · Fixed by #70
Closed
2 tasks done

CS_AttemptTableReshare can be simplified #69

thnkslprpt opened this issue Mar 19, 2023 · 0 comments · Fixed by #70

Comments

@thnkslprpt
Copy link
Contributor

Checklist

  • I reviewed the Contributing Guide.
  • I performed a cursory search to see if the bug report is relevant, not redundant, nor in conflict with other tickets.

Describe the bug
The CS_AttemptTableReshare() function uses 3 'Result' variables for control flow. It seems like they can all be combined into a single variable.

Code snips

CS/fsw/src/cs_utils.c

Lines 1004 to 1038 in a249bcf

int32 CS_AttemptTableReshare(CS_Res_Tables_Table_Entry_t *ResultsEntry, CFE_TBL_Handle_t *LocalTblHandle,
CFE_TBL_Info_t *TblInfo, cpuaddr *LocalAddress, int32 *ResultGetInfo)
{
int32 Result = CS_SUCCESS;
int32 ResultShare = 0;
int32 ResultGetAddress = 0;
/* Maybe the table came back, try and reshare it */
ResultShare = CFE_TBL_Share(LocalTblHandle, ResultsEntry->Name);
if (ResultShare == CFE_SUCCESS)
{
ResultsEntry->TblHandle = *LocalTblHandle;
*ResultGetInfo = CFE_TBL_GetInfo(TblInfo, ResultsEntry->Name);
/* need to try to get the address again */
ResultGetAddress = CFE_TBL_GetAddress((void *)LocalAddress, *LocalTblHandle);
Result = ResultGetAddress;
/* if the table was never loaded, release the address to prevent the table from being
locked by CS, which would prevent the owner app from updating it*/
if (ResultGetAddress == CFE_TBL_ERR_NEVER_LOADED)
{
CFE_TBL_ReleaseAddress(*LocalTblHandle);
}
}
else /* table was not there on the new share */
{
Result = ResultShare;
}
return Result;
}

Expected behavior
Simplify function to improve clarity and ease future maintenance.

Reporter Info
Avi Weiss @thnkslprpt

thnkslprpt added a commit to thnkslprpt/CS that referenced this issue Mar 19, 2023
thnkslprpt added a commit to thnkslprpt/CS that referenced this issue Mar 20, 2023
dzbaker added a commit that referenced this issue Apr 13, 2023
…eReshare

Fix #69, Simplify CS_AttemptTableReshare
@dmknutsen dmknutsen added this to the Equuleus milestone May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants