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 #2546, add handle list operation routines #2548

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

jphickey
Copy link
Contributor

@jphickey jphickey commented Apr 5, 2024

Checklist (Please check before submitting)

Describe the contribution
Adds a "HandleLink" structure to encapsulate the linked list functionality and add generic routines to initialize and test/check this structure, along with list insert/remove functions for access descriptors that use this link struct interally.

This also cleans up documentation of the table resource ID functions defined in cfe_tbl_resource.h

Fixes #2546

Testing performed
Build and run all tests

Expected behavior changes
None (code clean up)

System(s) tested on
Debian

Additional context
Improves maintainability of code by moving linked list ops into common routines

Contributor Info - All information REQUIRED for consideration of pull request
Joseph Hickey, Vantage Systems, Inc.

modules/tbl/fsw/src/cfe_tbl_internal.h Fixed Show fixed Hide fixed
break;
}

Func(AccDescPtr, Arg);

Check notice

Code scanning / CodeQL-coding-standard

Use of non-constant function pointer Note

This call does not go through a const function pointer.
* See description in header file for argument/return detail
*
*-----------------------------------------------------------------*/
void CFE_TBL_HandleListInsertLink(CFE_TBL_RegistryRec_t *RegRecPtr, CFE_TBL_AccessDescriptor_t *AccessDescPtr)

Check notice

Code scanning / CodeQL-coding-standard

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
* See description in header file for argument/return detail
*
*-----------------------------------------------------------------*/
void CFE_TBL_HandleListRemoveLink(CFE_TBL_RegistryRec_t *RegRecPtr, CFE_TBL_AccessDescriptor_t *AccessDescPtr)

Check notice

Code scanning / CodeQL-coding-standard

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
* See description in header file for argument/return detail
*
*-----------------------------------------------------------------*/
void CFE_TBL_ForeachAccessDescriptor(CFE_TBL_RegistryRec_t *RegRecPtr, CFE_TBL_AccessDescFunc_t Func, void *Arg)

Check notice

Code scanning / CodeQL-coding-standard

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
* See description in header file for argument/return detail
*
*-----------------------------------------------------------------*/
void CFE_TBL_HandleListGetSafeLink(CFE_TBL_RegistryRec_t *RegRecPtr, CFE_TBL_AccessDescriptor_t *AccDescPtr,

Check notice

Code scanning / CodeQL-coding-standard

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
CFE_TBL_TxnState_t *Txn = Arg;

/* Only notify *OTHER* applications that the contents have changed */
if (!CFE_RESOURCEID_TEST_EQUAL(AccessDescPtr->AppId, CFE_TBL_TxnAppId(Txn)))

Check warning

Code scanning / CodeQL-coding-standard

Side effect in a Boolean expression Warning

This Boolean expression is not side-effect free.

/* Return the Access Descriptor to the pool */
AccessDescPtr->UsedFlag = false;

/* If this was the last Access Descriptor for this table, we can free the memory buffers as well */
if (RegRecPtr->HeadOfAccessList == CFE_TBL_END_OF_LIST)
if (!CFE_TBL_HandleLinkIsAttached(&RegRecPtr->AccessList))

Check warning

Code scanning / CodeQL-coding-standard

Side effect in a Boolean expression Warning

This Boolean expression is not side-effect free.
Comment on lines +236 to +237
if (AccDescPtr->UsedFlag && AccDescPtr->RegIndex == CFE_TBL_TxnRegId(Txn) &&
CFE_RESOURCEID_TEST_EQUAL(AccDescPtr->AppId, CFE_TBL_TxnAppId(Txn)))

Check warning

Code scanning / CodeQL-coding-standard

Side effect in a Boolean expression Warning

This Boolean expression is not side-effect free.
@skliper
Copy link
Contributor

skliper commented Apr 5, 2024

Any chance the linked list support could be an exposed API? I know CF has a linked list and nice if any other app wouldn't have to roll their own.

@jphickey jphickey force-pushed the fix-2546-foreach-accessdesc branch from 465925d to a7ea4a3 Compare April 5, 2024 17:35
@jphickey
Copy link
Contributor Author

jphickey commented Apr 5, 2024

Any chance the linked list support could be an exposed API? I know CF has a linked list and nice if any other app wouldn't have to roll their own.

Good suggestion. Although this does isolate the prev/next references into a linkage struct, the linkage here is still via Table Handle. So in other words - not a totally generic list function.

I think CFE should have a module for general purpose data structs, like trees and lists....

Adds a "HandleLink" structure to encapsulate the linked list
functionality and add generic routines to initialize and test/check
this structure, along with list insert/remove functions for
access descriptors that use this link struct interally.

This also cleans up documentation of the table resource ID functions
defined in cfe_tbl_resource.h
@jphickey jphickey force-pushed the fix-2546-foreach-accessdesc branch from a7ea4a3 to b13c79f Compare April 5, 2024 19:15
* \param AccDescPtr Pointer to the current access descriptor
* \param Arg Opaque argument from caller (passed through)
*/
typedef void (* const CFE_TBL_AccessDescFunc_t)(CFE_TBL_AccessDescriptor_t *AccDescPtr, void *Arg);

Check notice

Code scanning / CodeQL-coding-standard

Hidden pointer indirection Note

The typedef CFE_TBL_AccessDescFunc_t hides pointer indirection.
@jphickey jphickey added the CCB:Ready Ready for discussion at the Configuration Control Board (CCB) label Apr 11, 2024
@dzbaker dzbaker added CCB:Approved Indicates code review and approval by community CCB and removed CCB:Ready Ready for discussion at the Configuration Control Board (CCB) labels Apr 11, 2024
dzbaker added a commit to nasa/cFS that referenced this pull request Apr 16, 2024
*Combines:*

cFE equuleus-rc1+dev131
to_lab equuleus-rc1+dev52

**Includes:**

*cFE*
- nasa/cFE#2548

*to_lab*
- nasa/to_lab#188

Co-authored by: Avi Weiss <[email protected]>
Co-authored by: Joseph Hickey <[email protected]>
@dzbaker dzbaker merged commit 012d62a into nasa:main Apr 16, 2024
22 checks passed
dzbaker added a commit to nasa/cFS that referenced this pull request Apr 16, 2024
*Combines:*

cFE equuleus-rc1+dev131
to_lab equuleus-rc1+dev52

**Includes:**

*cFE*
- nasa/cFE#2548

*to_lab*
- nasa/to_lab#188

Co-authored by: Avi Weiss <[email protected]>
Co-authored by: Joseph Hickey <[email protected]>
@jphickey jphickey deleted the fix-2546-foreach-accessdesc branch May 29, 2024 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CCB:Approved Indicates code review and approval by community CCB
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add "foreach" function for access descriptor looping
3 participants