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

osal Integration candidate: Equuleus-rc1+dev5 #1451

Merged
merged 11 commits into from
Feb 23, 2024
Merged
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## Development Build: equuleus-rc1+dev53
- use virtual path as name for FS_BASED maps
- Remove softsleep, as a dead store.
- Remove stray remaining 'goto' in OSAL test code
- Align mismatched function prototype/implem. parameter names
- Move variables declared mid-function to the top
- See <https://github.com/nasa/osal/pull/1448>, <https://github.com/nasa/osal/issues/1452>, <https://github.com/nasa/osal/pull/1357>, <https://github.com/nasa/osal/pull/1354>, and <https://github.com/nasa/osal/pull/1331>

## Development Build: equuleus-rc1+dev41
- Remove unreachable branch (superfluous if condition)
- See <https://github.com/nasa/osal/pull/1368>
Expand Down
2 changes: 1 addition & 1 deletion src/os/inc/osapi-file.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ int32 OS_remove(const char *path);
* @return Execution status, see @ref OSReturnCodes
* @retval #OS_SUCCESS @copybrief OS_SUCCESS
* @retval #OS_ERROR if the file could not be opened or renamed.
* @retval #OS_INVALID_POINTER if old or new are NULL
* @retval #OS_INVALID_POINTER if old_filename or new_filename are NULL
* @retval #OS_FS_ERR_PATH_INVALID if path cannot be parsed
* @retval #OS_FS_ERR_PATH_TOO_LONG if the paths given are too long to be stored locally
* @retval #OS_FS_ERR_NAME_TOO_LONG if the new name is too long to be stored locally
Expand Down
2 changes: 1 addition & 1 deletion src/os/inc/osapi-module.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ int32 OS_ModuleSymbolLookup(osal_id_t module_id, cpuaddr *symbol_address, const
* module subsystem does not provide a facility to iterate through the
* symbol table, then the #OS_ERR_NOT_IMPLEMENTED status code is returned.
*
* @param[in] filename File to write to @nonnull
* @param[in] filename File to write to @nonnull
* @param[in] size_limit Maximum number of bytes to write
*
* @return Execution status, see @ref OSReturnCodes
Expand Down
2 changes: 1 addition & 1 deletion src/os/inc/osapi-timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ typedef struct
* The callback function should be declared according to the OS_TimerCallback_t
* function pointer type. The timer_id value is passed to the callback function.
*
* @note clock_accuracy comes from the underlying OS tick value. The nearest integer
* @note clock_accuracy comes from the underlying OS tick value. The nearest integer
* microsecond value is returned, so may not be exact.
*
* @note This configuration API must not be used from the context of a timer callback.
Expand Down
2 changes: 1 addition & 1 deletion src/os/inc/osapi-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/*
* Development Build Macro Definitions
*/
#define OS_BUILD_NUMBER 41
#define OS_BUILD_NUMBER 53
#define OS_BUILD_BASELINE "equuleus-rc1"
#define OS_BUILD_DEV_CYCLE "equuleus-rc2" /**< @brief Development: Release name for current development cycle */
#define OS_BUILD_CODENAME "Equuleus" /**< @brief: Development: Code name for the current build */
Expand Down
2 changes: 1 addition & 1 deletion src/os/portable/os-impl-no-symtab.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int32 OS_ModuleSymbolLookup_Impl(const OS_object_token_t *token, cpuaddr *Symbol
*
* See prototype for argument/return detail
*-----------------------------------------------------------------*/
int32 OS_SymbolTableDump_Impl(const char *filename, size_t SizeLimit)
int32 OS_SymbolTableDump_Impl(const char *filename, size_t size_limit)
{
return OS_ERR_NOT_IMPLEMENTED;
}
2 changes: 1 addition & 1 deletion src/os/portable/os-impl-posix-dl-symtab.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ int32 OS_ModuleSymbolLookup_Impl(const OS_object_token_t *token, cpuaddr *Symbol
* POSIX DL does not provide
*
*-----------------------------------------------------------------*/
int32 OS_SymbolTableDump_Impl(const char *filename, size_t SizeLimit)
int32 OS_SymbolTableDump_Impl(const char *filename, size_t size_limit)
{
/*
* Limiting strictly to POSIX-defined API means there is no defined
Expand Down
14 changes: 7 additions & 7 deletions src/os/portable/os-impl-posix-files.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
* See prototype for argument/return detail
*
*-----------------------------------------------------------------*/
int32 OS_FileStat_Impl(const char *local_path, os_fstat_t *FileStats)
int32 OS_FileStat_Impl(const char *local_path, os_fstat_t *filestat)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.

Check notice

Code scanning / CodeQL

Function too long Note

OS_FileStat_Impl has too many lines (82, while 60 are allowed).
{
struct stat st;
mode_t readbits;
Expand All @@ -139,7 +139,7 @@
return OS_ERROR;
}

FileStats->FileSize = st.st_size;
filestat->FileSize = st.st_size;

/*
* NOTE: Traditional timestamps are only a whole number of seconds (time_t)
Expand All @@ -164,12 +164,12 @@
filetime.tv_nsec = 0;
#endif

FileStats->FileTime = OS_TimeAssembleFromNanoseconds(filetime.tv_sec, filetime.tv_nsec);
filestat->FileTime = OS_TimeAssembleFromNanoseconds(filetime.tv_sec, filetime.tv_nsec);

/* note that the "fst_mode" member is already zeroed by the caller */
if (S_ISDIR(st.st_mode))
{
FileStats->FileModeBits |= OS_FILESTAT_MODE_DIR;
filestat->FileModeBits |= OS_FILESTAT_MODE_DIR;
}

/* always check world bits */
Expand All @@ -195,15 +195,15 @@

if (st.st_mode & readbits)
{
FileStats->FileModeBits |= OS_FILESTAT_MODE_READ;
filestat->FileModeBits |= OS_FILESTAT_MODE_READ;
}
if (st.st_mode & writebits)
{
FileStats->FileModeBits |= OS_FILESTAT_MODE_WRITE;
filestat->FileModeBits |= OS_FILESTAT_MODE_WRITE;
}
if (st.st_mode & execbits)
{
FileStats->FileModeBits |= OS_FILESTAT_MODE_EXEC;
filestat->FileModeBits |= OS_FILESTAT_MODE_EXEC;
}

return OS_SUCCESS;
Expand Down
1 change: 0 additions & 1 deletion src/os/posix/inc/os-impl-timebase.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ typedef struct
int assigned_signal;
sigset_t sigset;
sig_atomic_t reset_flag;
struct timespec softsleep;
} OS_impl_timebase_internal_record_t;

/****************************************************************************************
Expand Down
4 changes: 2 additions & 2 deletions src/os/posix/src/os-impl-idmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@
* See prototype for argument/return detail
*
*-----------------------------------------------------------------*/
void OS_WaitForStateChange_Impl(osal_objtype_t idtype, uint32 attempts)
void OS_WaitForStateChange_Impl(osal_objtype_t objtype, uint32 attempts)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
OS_impl_objtype_lock_t *impl;
struct timespec ts;

impl = OS_impl_objtype_lock_table[idtype];
impl = OS_impl_objtype_lock_table[objtype];

/*
* because pthread_cond_timedwait() is also a cancellation point,
Expand Down
1 change: 0 additions & 1 deletion src/os/posix/src/os-impl-timebase.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ int32 OS_TimeBaseCreate_Impl(const OS_object_token_t *token)
}

local->assigned_signal = 0;
clock_gettime(OS_PREFERRED_CLOCK, &local->softsleep);

/*
* Set up the necessary OS constructs
Expand Down
1 change: 0 additions & 1 deletion src/os/rtems/inc/os-impl-timebase.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ typedef struct
int assigned_signal;
sigset_t sigset;
sig_atomic_t reset_flag;
struct timespec softsleep;
} OS_impl_timebase_internal_record_t;

/****************************************************************************************
Expand Down
7 changes: 4 additions & 3 deletions src/os/rtems/src/os-impl-filesys.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,12 @@ int32 OS_FileSysStartVolume_Impl(const OS_object_token_t *token)
*
* The path will be simply /<VOLNAME>
*/
if (return_code == OS_SUCCESS && local->system_mountpt[0] == 0)
if (return_code == OS_SUCCESS && local->system_mountpt[0] == 0 && local->volume_name[0] != 0)
{
local->system_mountpt[0] = '/';
local->system_mountpt[sizeof(local->system_mountpt) - 1] = 0;
local->system_mountpt[0] = '/';
strncpy(&local->system_mountpt[1], local->volume_name, sizeof(local->system_mountpt) - 2);
local->system_mountpt[sizeof(local->system_mountpt) - 1] = 0;

OS_DEBUG("OSAL: using mount point %s for %s\n", local->system_mountpt, local->volume_name);
}

Expand Down
6 changes: 3 additions & 3 deletions src/os/rtems/src/os-impl-idmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void OS_Unlock_Global_Impl(osal_objtype_t idtype)
* See prototype for argument/return detail
*
*-----------------------------------------------------------------*/
void OS_WaitForStateChange_Impl(osal_objtype_t idtype, uint32 attempts)
void OS_WaitForStateChange_Impl(osal_objtype_t objtype, uint32 attempts)
{
rtems_interval wait_ticks;

Expand All @@ -139,9 +139,9 @@ void OS_WaitForStateChange_Impl(osal_objtype_t idtype, uint32 attempts)
wait_ticks = 100;
}

OS_Unlock_Global_Impl(idtype);
OS_Unlock_Global_Impl(objtype);
rtems_task_wake_after(wait_ticks);
OS_Lock_Global_Impl(idtype);
OS_Lock_Global_Impl(objtype);
}

/****************************************************************************************
Expand Down
10 changes: 5 additions & 5 deletions src/os/shared/src/osapi-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,18 +342,18 @@
* See description in API and header file for detail
*
*-----------------------------------------------------------------*/
int32 OS_rename(const char *old, const char *new)
int32 OS_rename(const char *old_filename, const char *new_filename)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
OS_object_iter_t iter;
OS_stream_internal_record_t *stream;
int32 return_code;
char old_path[OS_MAX_LOCAL_PATH_LEN];
char new_path[OS_MAX_LOCAL_PATH_LEN];

return_code = OS_TranslatePath(old, old_path);
return_code = OS_TranslatePath(old_filename, old_path);
if (return_code == OS_SUCCESS)
{
return_code = OS_TranslatePath(new, new_path);
return_code = OS_TranslatePath(new_filename, new_path);
}

if (return_code == OS_SUCCESS)
Expand All @@ -369,9 +369,9 @@
{
stream = OS_OBJECT_TABLE_GET(OS_stream_table, iter.token);

if (stream->socket_domain == OS_SocketDomain_INVALID && strcmp(stream->stream_name, old) == 0)
if (stream->socket_domain == OS_SocketDomain_INVALID && strcmp(stream->stream_name, old_filename) == 0)
{
strncpy(stream->stream_name, new, sizeof(stream->stream_name) - 1);
strncpy(stream->stream_name, new_filename, sizeof(stream->stream_name) - 1);
stream->stream_name[sizeof(stream->stream_name) - 1] = 0;
}
}
Expand Down
24 changes: 2 additions & 22 deletions src/os/shared/src/osapi-filesys.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ int32 OS_FileSysAddFixedMap(osal_id_t *filesys_id, const char *phys_path, const
OS_filesys_internal_record_t *filesys;
int32 return_code;
OS_object_token_t token;
const char * dev_name;

/*
* Validate inputs
Expand All @@ -252,33 +251,14 @@ int32 OS_FileSysAddFixedMap(osal_id_t *filesys_id, const char *phys_path, const
OS_CHECK_STRING(phys_path, sizeof(filesys->system_mountpt), OS_FS_ERR_PATH_TOO_LONG);
OS_CHECK_PATHNAME(virt_path);

/*
* Generate a dev name by taking the basename of the phys_path.
*/
dev_name = strrchr(phys_path, '/');
if (dev_name == NULL)
{
dev_name = phys_path;
}
else
{
++dev_name;
}

if (memchr(dev_name, 0, sizeof(filesys->volume_name)) == NULL)
{
return OS_ERR_NAME_TOO_LONG;
}

return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, dev_name, &token);
return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, virt_path, &token);
if (return_code == OS_SUCCESS)
{
filesys = OS_OBJECT_TABLE_GET(OS_filesys_table, token);

/* Reset the table entry and save the name */
OS_OBJECT_INIT(token, filesys, device_name, dev_name);
OS_OBJECT_INIT(token, filesys, virtual_mountpt, virt_path);

strncpy(filesys->volume_name, dev_name, sizeof(filesys->volume_name) - 1);
strncpy(filesys->system_mountpt, phys_path, sizeof(filesys->system_mountpt) - 1);
strncpy(filesys->virtual_mountpt, virt_path, sizeof(filesys->virtual_mountpt) - 1);

Expand Down
4 changes: 2 additions & 2 deletions src/os/shared/src/osapi-idmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,7 @@
* See description in API and header file for detail
*
*-----------------------------------------------------------------*/
void OS_ForEachObjectOfType(osal_objtype_t idtype, osal_id_t creator_id, OS_ArgCallback_t callback_ptr,
void OS_ForEachObjectOfType(osal_objtype_t objtype, osal_id_t creator_id, OS_ArgCallback_t callback_ptr,

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
void *callback_arg)
{
OS_object_iter_t iter;
Expand All @@ -1368,7 +1368,7 @@
filter.user_callback = callback_ptr;
filter.user_arg = callback_arg;

if (OS_ObjectIdIteratorInit(OS_ForEachFilterCreator, &filter, idtype, &iter) == OS_SUCCESS)
if (OS_ObjectIdIteratorInit(OS_ForEachFilterCreator, &filter, objtype, &iter) == OS_SUCCESS)

Check warning

Code scanning / CodeQL

Side effect in a Boolean expression Warning

This Boolean expression is not side-effect free.
{
while (OS_ObjectIdIteratorGetNext(&iter))
{
Expand Down
24 changes: 12 additions & 12 deletions src/os/shared/src/osapi-module.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,28 +296,28 @@
* See description in API and header file for detail
*
*-----------------------------------------------------------------*/
int32 OS_ModuleInfo(osal_id_t module_id, OS_module_prop_t *module_prop)
int32 OS_ModuleInfo(osal_id_t module_id, OS_module_prop_t *module_info)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
OS_common_record_t * record;
OS_module_internal_record_t *module;
int32 return_code;
OS_object_token_t token;

/* Check parameters */
OS_CHECK_POINTER(module_prop);
OS_CHECK_POINTER(module_info);

memset(module_prop, 0, sizeof(OS_module_prop_t));
memset(module_info, 0, sizeof(OS_module_prop_t));

return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, module_id, &token);
if (return_code == OS_SUCCESS)
{
record = OS_OBJECT_TABLE_GET(OS_global_module_table, token);
module = OS_OBJECT_TABLE_GET(OS_module_table, token);

strncpy(module_prop->name, record->name_entry, sizeof(module_prop->name) - 1);
strncpy(module_prop->filename, module->file_name, sizeof(module_prop->filename) - 1);
strncpy(module_info->name, record->name_entry, sizeof(module_info->name) - 1);
strncpy(module_info->filename, module->file_name, sizeof(module_info->filename) - 1);

return_code = OS_ModuleGetInfo_Impl(&token, module_prop);
return_code = OS_ModuleGetInfo_Impl(&token, module_info);

OS_ObjectIdRelease(&token);
}
Expand All @@ -331,29 +331,29 @@
* See description in API and header file for detail
*
*-----------------------------------------------------------------*/
int32 OS_SymbolLookup(cpuaddr *SymbolAddress, const char *SymbolName)
int32 OS_SymbolLookup(cpuaddr *symbol_address, const char *SymbolName)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
int32 return_code;
int32 staticsym_status;

/*
** Check parameters
*/
OS_CHECK_POINTER(SymbolAddress);
OS_CHECK_POINTER(symbol_address);
OS_CHECK_POINTER(SymbolName);

/*
* attempt to find the symbol in the symbol table
*/
return_code = OS_SymbolLookup_Impl(SymbolAddress, SymbolName);
return_code = OS_SymbolLookup_Impl(symbol_address, SymbolName);

/*
* If the OS call did not find the symbol or the loader is
* disabled, then check if a static symbol table is present
*/
if (return_code != OS_SUCCESS)
{
staticsym_status = OS_SymbolLookup_Static(SymbolAddress, SymbolName, NULL);
staticsym_status = OS_SymbolLookup_Static(symbol_address, SymbolName, NULL);

/*
* Only overwrite the return code if static lookup was successful.
Expand Down Expand Up @@ -420,7 +420,7 @@
* See description in API and header file for detail
*
*-----------------------------------------------------------------*/
int32 OS_SymbolTableDump(const char *filename, size_t SizeLimit)
int32 OS_SymbolTableDump(const char *filename, size_t size_limit)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
int32 return_code;
char translated_path[OS_MAX_LOCAL_PATH_LEN];
Expand Down Expand Up @@ -453,7 +453,7 @@
return return_code;
}

return_code = OS_SymbolTableDump_Impl(translated_path, SizeLimit);
return_code = OS_SymbolTableDump_Impl(translated_path, size_limit);

OS_ObjectIdTransactionCancel(&token);

Expand Down
Loading
Loading