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 #1440, Split up BinSemGetInfo() to avoid partial success returns #1480

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

thnkslprpt
Copy link
Contributor

Checklist

Describe the contribution

Testing performed
GitHub CI actions all passing successfully (incl. Build + Run, Unit/Functional Tests etc.).
Tested locally to confirm no loss of coverage compared with the current main branch, and all lines/branches/functions in the new version are covered.

Expected behavior changes
Removes this source of 'partial success' which can be confusing and also increases complexity for dealing with the return for users calling into this API.

System(s) tested on
Debian 12 using the current main branch of cFS bundle.

Contributor Info
Avi Weiss   @thnkslprpt

@@ -249,7 +249,7 @@
* See description in API and header file for detail
*
*-----------------------------------------------------------------*/
int32 OS_BinSemGetInfo(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop)
int32 OS_BinSemGetName(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
* See description in API and header file for detail
*
*-----------------------------------------------------------------*/
int32 OS_BinSemGetCreator(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
* See description in API and header file for detail
*
*-----------------------------------------------------------------*/
int32 OS_BinSemGetValue(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
* -----------------------------------------------------------------
*/
void UT_DefaultHandler_OS_BinSemGetInfo(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
void UT_DefaultHandler_OS_BinSemGetName(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
* Default handler implementation for 'OS_BinSemGetCreator' stub
* -----------------------------------------------------------------
*/
void UT_DefaultHandler_OS_BinSemGetCreator(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
Comment on lines +88 to +89
if (status == OS_SUCCESS &&
UT_Stub_CopyToLocal(UT_KEY(OS_BinSemGetCreator), bin_prop, sizeof(*bin_prop)) < sizeof(*bin_prop))

Check warning

Code scanning / CodeQL

Side effect in a Boolean expression Warning

This Boolean expression is not side-effect free.
* ----------------------------------------------------
*/
int32 OS_BinSemGetInfo(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop)
int32 OS_BinSemGetName(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
* Generated stub function for OS_BinSemGetCreator()
* ----------------------------------------------------
*/
int32 OS_BinSemGetCreator(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
@thnkslprpt
Copy link
Contributor Author

thnkslprpt commented Oct 6, 2024

Pretty simple change-set, although the change is 'breaking' I guess, so has to wait for a major release?

Note - there is a single reference to BinSemGetInfo() in cFE which will need to be updated along with this if it is merged.

@skliper
Copy link
Contributor

skliper commented Oct 8, 2024

Pretty simple change-set, although the change is 'breaking' I guess, so has to wait for a major release?

Note - there is a single reference to BinSemGetInfo() in cFE which will need to be updated along with this if it is merged.

I recommend just deprecating the old API vs fully removing, then it doesn't have to be a major release (at least per the old rules I used). See other uses of OSAL_OMIT_DEPRECATED.

@thnkslprpt
Copy link
Contributor Author

I recommend just deprecating the old API vs fully removing, then it doesn't have to be a major release (at least per the old rules I used). See other uses of OSAL_OMIT_DEPRECATED.

Good point. Will update it.

@thnkslprpt thnkslprpt force-pushed the fix-1440-split-bin-sem-get-info branch 2 times, most recently from 0e2d950 to 6459099 Compare October 8, 2024 18:19
src/os/posix/src/os-impl-binsem.c Fixed Show fixed Hide fixed
src/os/shared/src/osapi-binsem.c Fixed Show fixed Hide fixed
@thnkslprpt
Copy link
Contributor Author

@skliper I'm not sure if I did the deprecation guards correctly, but do you know if it's possible or have the debug and release builds pass the tests given that the deprecated elements are only removed in the debug workflow?

-DOSAL_OMIT_DEPRECATED=${{ env.is_debug }}

Is it trying to run the same set of tests, but with and without the deprecated code? (that doesn't seem to make sense right)

(I'm assuming we only upkeep tests for the non-deprecated code...)

@skliper
Copy link
Contributor

skliper commented Oct 9, 2024

@skliper I'm not sure if I did the deprecation guards correctly...

I'm not really following your full question, but I recommend only wrapping the old API in the omit deprecated ifndef not the new stuff. Then hopefully the tests would pass?

@thnkslprpt thnkslprpt force-pushed the fix-1440-split-bin-sem-get-info branch from 6459099 to f8855ab Compare October 10, 2024 09:28
@@ -466,6 +466,8 @@
return (OS_GenericBinSemTake_Impl(token, &ts));
}

#ifdef OSAL_OMIT_DEPRECATED

Check notice

Code scanning / CodeQL

Conditional compilation Note

Use of conditional compilation must be kept to a minimum.
@@ -243,13 +243,45 @@
return return_code;
}

#ifdef OSAL_OMIT_DEPRECATED

Check notice

Code scanning / CodeQL

Conditional compilation Note

Use of conditional compilation must be kept to a minimum.
UtAssert_INT32_EQ(OS_BinSemCreate(NULL, "Test_Sem", 0, 0), OS_INVALID_POINTER);
UtAssert_INT32_EQ(OS_BinSemCreate(&sem_id[0], NULL, 0, 0), OS_INVALID_POINTER);
UtAssert_INT32_EQ(OS_BinSemGetInfo(sem_id[0], NULL), OS_INVALID_POINTER);

// Initialize sem_id[0] to a valid value for the following NULL checks
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests were not passing on 1/4 builds without this addition (Debug, Ubuntu 22.04).
Somehow, it behaves differently with the sem_id[0] not being set to a valid value on that target on the preceding line. With the added code though, all builds are fine.

@thnkslprpt
Copy link
Contributor Author

@skliper I'm not sure if I did the deprecation guards correctly...

I'm not really following your full question, but I recommend only wrapping the old API in the omit deprecated ifndef not the new stuff. Then hopefully the tests would pass?

OK all good now - it wasn't building for me locally but that might have been a symptom of my own build command. Tests passing with a small addition as per the above comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SemGetInfo partial success cases
2 participants