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

Unreachable branch on unknown fstype in OS_FileSys_Initialize #1107

Closed
skliper opened this issue Jul 16, 2021 · 1 comment · Fixed by #1368
Closed

Unreachable branch on unknown fstype in OS_FileSys_Initialize #1107

skliper opened this issue Jul 16, 2021 · 1 comment · Fixed by #1368
Labels
coverage unit-test Tickets related to the OSAL unit testing (functional and/or coverage)

Comments

@skliper
Copy link
Contributor

skliper commented Jul 16, 2021

Is your feature request related to a problem? Please describe.
filesys->fstype == OS_FILESYS_TYPE_UNKNOWN is always true due to memset of filesys to zero in OS_OBJECT_INIT call. Nothing else can logically set it otherwise or reason to not set if the other conditions are true.

/*
* Determine basic type of filesystem, if not already known
*
* if either an address was supplied, or if the volume name
* contains the string "RAM" then it is a RAM disk. Otherwise
* leave the type as UNKNOWN and let the implementation decide.
*/
if (filesys->fstype == OS_FILESYS_TYPE_UNKNOWN &&
(filesys->address != NULL || strncmp(filesys->volume_name, OS_FILESYS_RAMDISK_VOLNAME_PREFIX,
sizeof(OS_FILESYS_RAMDISK_VOLNAME_PREFIX) - 1) == 0))
{
filesys->fstype = OS_FILESYS_TYPE_VOLATILE_DISK;
}

Describe the solution you'd like
Remove dead branch.

Describe alternatives you've considered
Clear justification for leaving in.

Additional context
None.

Requester Info
Jacob Hageman - NASA/GSFC

@jphickey
Copy link
Contributor

I concur on removing the conditional and assuming it is always OS_FILESYS_TYPE_VOLATILE_DISK in the current implementation.

This helper function is only used as part of OS_initfs and OS_mkfs and both of these public APIs are only intended to set up RAM disks. Non-volatile storage now uses a separate registration such as OS_FileSysAddFixedMap(). I think originally this code was also used for translating entries in the volume table, but that is no longer the case.

@skliper skliper added the unit-test Tickets related to the OSAL unit testing (functional and/or coverage) label Aug 25, 2021
jphickey pushed a commit to jphickey/osal that referenced this issue Aug 10, 2022
Fix nasa#955, Remove OS_printf stub count checks in UT
thnkslprpt added a commit to thnkslprpt/osal that referenced this issue Feb 15, 2023
thnkslprpt added a commit to thnkslprpt/osal that referenced this issue Sep 22, 2023
dzbaker added a commit that referenced this issue Jan 31, 2024
Fix #1107, Remove unreachable branch (superfluous if condition)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
coverage unit-test Tickets related to the OSAL unit testing (functional and/or coverage)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants