diff --git a/src/os/shared/src/osapi-filesys.c b/src/os/shared/src/osapi-filesys.c index 711ef7fb5..d791c7d05 100644 --- a/src/os/shared/src/osapi-filesys.c +++ b/src/os/shared/src/osapi-filesys.c @@ -76,17 +76,17 @@ const char OS_FILESYS_RAMDISK_VOLNAME_PREFIX[] = "RAM"; *-----------------------------------------------------------------*/ bool OS_FileSys_FindVirtMountPoint(void *ref, osal_index_t local_id, const OS_common_record_t *obj) { - OS_filesys_internal_record_t *rec = &OS_filesys_table[local_id]; - const char * target = (const char *)ref; + OS_filesys_internal_record_t *filesys = &OS_filesys_table[local_id]; + const char * target = (const char *)ref; size_t mplen; - if ((rec->flags & OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL) == 0) + if ((filesys->flags & OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL) == 0) { return false; } - mplen = strlen(rec->virtual_mountpt); - return (mplen > 0 && strncmp(target, rec->virtual_mountpt, mplen) == 0 && + mplen = strlen(filesys->virtual_mountpt); + return (mplen > 0 && strncmp(target, filesys->virtual_mountpt, mplen) == 0 && (target[mplen] == '/' || target[mplen] == 0)); } /* end OS_FileSys_FindVirtMountPoint */ @@ -104,7 +104,7 @@ bool OS_FileSys_FindVirtMountPoint(void *ref, osal_index_t local_id, const OS_co int32 OS_FileSys_Initialize(char *address, const char *fsdevname, const char *fsvolname, size_t blocksize, osal_blockcount_t numblocks, bool should_format) { - OS_filesys_internal_record_t *local; + OS_filesys_internal_record_t *filesys; int32 return_code; OS_object_token_t token; @@ -123,7 +123,7 @@ int32 OS_FileSys_Initialize(char *address, const char *fsdevname, const char *fs } /* check names are not excessively long strings */ - if (strlen(fsdevname) >= sizeof(local->device_name) || strlen(fsvolname) >= sizeof(local->volume_name)) + if (strlen(fsdevname) >= sizeof(filesys->device_name) || strlen(fsvolname) >= sizeof(filesys->volume_name)) { return OS_FS_ERR_PATH_TOO_LONG; } @@ -131,17 +131,17 @@ int32 OS_FileSys_Initialize(char *address, const char *fsdevname, const char *fs return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, fsdevname, &token); if (return_code == OS_SUCCESS) { - local = OS_OBJECT_TABLE_GET(OS_filesys_table, token); + filesys = OS_OBJECT_TABLE_GET(OS_filesys_table, token); /* Reset the table entry and save the name */ - OS_OBJECT_INIT(token, local, device_name, fsdevname); + OS_OBJECT_INIT(token, filesys, device_name, fsdevname); /* populate the VolumeName and BlockSize ahead of the Impl call, * so the implementation can reference this info if necessary */ - local->blocksize = blocksize; - local->numblocks = numblocks; - local->address = address; - strcpy(local->volume_name, fsvolname); + filesys->blocksize = blocksize; + filesys->numblocks = numblocks; + filesys->address = address; + strcpy(filesys->volume_name, fsvolname); /* * Determine basic type of filesystem, if not already known @@ -150,11 +150,11 @@ int32 OS_FileSys_Initialize(char *address, const char *fsdevname, const char *fs * contains the string "RAM" then it is a RAM disk. Otherwise * leave the type as UNKNOWN and let the implementation decide. */ - if (local->fstype == OS_FILESYS_TYPE_UNKNOWN && - (local->address != NULL || strncmp(local->volume_name, OS_FILESYS_RAMDISK_VOLNAME_PREFIX, - sizeof(OS_FILESYS_RAMDISK_VOLNAME_PREFIX) - 1) == 0)) + 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)) { - local->fstype = OS_FILESYS_TYPE_VOLATILE_DISK; + filesys->fstype = OS_FILESYS_TYPE_VOLATILE_DISK; } return_code = OS_FileSysStartVolume_Impl(OS_ObjectIndexFromToken(&token)); @@ -172,7 +172,7 @@ int32 OS_FileSys_Initialize(char *address, const char *fsdevname, const char *fs if (return_code == OS_SUCCESS) { - local->flags |= OS_FILESYS_FLAG_IS_READY; + filesys->flags |= OS_FILESYS_FLAG_IS_READY; } else { @@ -224,7 +224,7 @@ int32 OS_FileSysAPI_Init(void) *-----------------------------------------------------------------*/ int32 OS_FileSysAddFixedMap(osal_id_t *filesys_id, const char *phys_path, const char *virt_path) { - OS_filesys_internal_record_t *local; + OS_filesys_internal_record_t *filesys; int32 return_code; OS_object_token_t token; const char * dev_name; @@ -263,20 +263,20 @@ int32 OS_FileSysAddFixedMap(osal_id_t *filesys_id, const char *phys_path, const return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, dev_name, &token); if (return_code == OS_SUCCESS) { - local = OS_OBJECT_TABLE_GET(OS_filesys_table, token); + filesys = OS_OBJECT_TABLE_GET(OS_filesys_table, token); /* Reset the table entry and save the name */ - OS_OBJECT_INIT(token, local, device_name, dev_name); + OS_OBJECT_INIT(token, filesys, device_name, dev_name); - strncpy(local->volume_name, dev_name, sizeof(local->volume_name) - 1); - strncpy(local->system_mountpt, phys_path, sizeof(local->system_mountpt) - 1); - strncpy(local->virtual_mountpt, virt_path, sizeof(local->virtual_mountpt) - 1); + 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); /* * mark the entry that it is a fixed disk */ - local->fstype = OS_FILESYS_TYPE_FS_BASED; - local->flags = OS_FILESYS_FLAG_IS_FIXED; + filesys->fstype = OS_FILESYS_TYPE_FS_BASED; + filesys->flags = OS_FILESYS_FLAG_IS_FIXED; /* * The "mount" implementation is required as it will @@ -286,7 +286,7 @@ int32 OS_FileSysAddFixedMap(osal_id_t *filesys_id, const char *phys_path, const if (return_code == OS_SUCCESS) { - local->flags |= OS_FILESYS_FLAG_IS_READY; + filesys->flags |= OS_FILESYS_FLAG_IS_READY; return_code = OS_FileSysMountVolume_Impl(OS_ObjectIndexFromToken(&token)); } @@ -295,7 +295,7 @@ int32 OS_FileSysAddFixedMap(osal_id_t *filesys_id, const char *phys_path, const /* * mark the entry that it is a fixed disk */ - local->flags |= OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; + filesys->flags |= OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; } /* Check result, finalize record, and unlock global table. */ @@ -424,7 +424,7 @@ int32 OS_mount(const char *devname, const char *mountpoint) { int32 return_code; OS_object_token_t token; - OS_filesys_internal_record_t *local; + OS_filesys_internal_record_t *filesys; /* Check parameters */ if (devname == NULL || mountpoint == NULL) @@ -432,7 +432,7 @@ int32 OS_mount(const char *devname, const char *mountpoint) return OS_INVALID_POINTER; } - if (strlen(devname) >= sizeof(local->device_name) || strlen(mountpoint) >= sizeof(local->virtual_mountpt)) + if (strlen(devname) >= sizeof(filesys->device_name) || strlen(mountpoint) >= sizeof(filesys->virtual_mountpt)) { return OS_FS_ERR_PATH_TOO_LONG; } @@ -440,7 +440,7 @@ int32 OS_mount(const char *devname, const char *mountpoint) return_code = OS_ObjectIdGetByName(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, devname, &token); if (return_code == OS_SUCCESS) { - local = OS_OBJECT_TABLE_GET(OS_filesys_table, token); + filesys = OS_OBJECT_TABLE_GET(OS_filesys_table, token); /* * READY flag should be set (mkfs/initfs must have been called on this FS) @@ -449,12 +449,12 @@ int32 OS_mount(const char *devname, const char *mountpoint) * FIXED flag _should_ always be unset (these don't support mount/unmount) * but to support abstraction this is not enforced. */ - if ((local->flags & ~OS_FILESYS_FLAG_IS_FIXED) != OS_FILESYS_FLAG_IS_READY) + if ((filesys->flags & ~OS_FILESYS_FLAG_IS_FIXED) != OS_FILESYS_FLAG_IS_READY) { /* mount() cannot be used on this file system at this time */ return_code = OS_ERR_INCORRECT_OBJ_STATE; } - else if (local->system_mountpt[0] == 0) + else if (filesys->system_mountpt[0] == 0) { /* * The system mount point should be a non-empty string. @@ -470,8 +470,8 @@ int32 OS_mount(const char *devname, const char *mountpoint) { /* mark as mounted in the local table. * For now this does both sides (system and virtual) */ - local->flags |= OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; - strcpy(local->virtual_mountpt, mountpoint); + filesys->flags |= OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; + strcpy(filesys->virtual_mountpt, mountpoint); } OS_ObjectIdRelease(&token); @@ -498,7 +498,7 @@ int32 OS_unmount(const char *mountpoint) { int32 return_code; OS_object_token_t token; - OS_filesys_internal_record_t *local; + OS_filesys_internal_record_t *filesys; /* Check parameters */ if (mountpoint == NULL) @@ -506,7 +506,7 @@ int32 OS_unmount(const char *mountpoint) return OS_INVALID_POINTER; } - if (strlen(mountpoint) >= sizeof(local->virtual_mountpt)) + if (strlen(mountpoint) >= sizeof(filesys->virtual_mountpt)) { return OS_FS_ERR_PATH_TOO_LONG; } @@ -516,7 +516,7 @@ int32 OS_unmount(const char *mountpoint) if (return_code == OS_SUCCESS) { - local = OS_OBJECT_TABLE_GET(OS_filesys_table, token); + filesys = OS_OBJECT_TABLE_GET(OS_filesys_table, token); /* * FIXED flag should always be unset (these don't support mount/unmount at all) @@ -525,7 +525,7 @@ int32 OS_unmount(const char *mountpoint) * * The FIXED flag is not enforced to support abstraction. */ - if ((local->flags & ~OS_FILESYS_FLAG_IS_FIXED) != + if ((filesys->flags & ~OS_FILESYS_FLAG_IS_FIXED) != (OS_FILESYS_FLAG_IS_READY | OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL)) { /* unmount() cannot be used on this file system at this time */ @@ -540,7 +540,7 @@ int32 OS_unmount(const char *mountpoint) { /* mark as mounted in the local table. * For now this does both sides (system and virtual) */ - local->flags &= ~(OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL); + filesys->flags &= ~(OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL); } OS_ObjectIdRelease(&token); @@ -706,7 +706,7 @@ int32 OS_FS_GetPhysDriveName(char *PhysDriveName, const char *MountPoint) { OS_object_token_t token; int32 return_code; - OS_filesys_internal_record_t *local; + OS_filesys_internal_record_t *filesys; if (MountPoint == NULL || PhysDriveName == NULL) { @@ -724,11 +724,11 @@ int32 OS_FS_GetPhysDriveName(char *PhysDriveName, const char *MountPoint) if (return_code == OS_SUCCESS) { - local = OS_OBJECT_TABLE_GET(OS_filesys_table, token); + filesys = OS_OBJECT_TABLE_GET(OS_filesys_table, token); - if ((local->flags & OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM) != 0) + if ((filesys->flags & OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM) != 0) { - strncpy(PhysDriveName, local->system_mountpt, OS_FS_PHYS_NAME_LEN - 1); + strncpy(PhysDriveName, filesys->system_mountpt, OS_FS_PHYS_NAME_LEN - 1); PhysDriveName[OS_FS_PHYS_NAME_LEN - 1] = 0; } else @@ -811,7 +811,7 @@ int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath) OS_object_token_t token; int32 return_code; const char * name_ptr; - OS_filesys_internal_record_t *local; + OS_filesys_internal_record_t *filesys; size_t SysMountPointLen; size_t VirtPathLen; size_t VirtPathBegin; @@ -868,15 +868,15 @@ int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath) } else { - local = OS_OBJECT_TABLE_GET(OS_filesys_table, token); + filesys = OS_OBJECT_TABLE_GET(OS_filesys_table, token); - if ((local->flags & OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM) != 0) + if ((filesys->flags & OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM) != 0) { - SysMountPointLen = strlen(local->system_mountpt); - VirtPathBegin = strlen(local->virtual_mountpt); + SysMountPointLen = strlen(filesys->system_mountpt); + VirtPathBegin = strlen(filesys->virtual_mountpt); if (SysMountPointLen < OS_MAX_LOCAL_PATH_LEN) { - memcpy(LocalPath, local->system_mountpt, SysMountPointLen); + memcpy(LocalPath, filesys->system_mountpt, SysMountPointLen); } } else diff --git a/src/os/shared/src/osapi-time.c b/src/os/shared/src/osapi-time.c index ea52e2490..ed79e9bca 100644 --- a/src/os/shared/src/osapi-time.c +++ b/src/os/shared/src/osapi-time.c @@ -94,7 +94,7 @@ static int32 OS_DoTimerAdd(osal_id_t *timer_id, const char *timer_name, osal_id_ osal_objtype_t objtype; OS_object_token_t timebase_token; OS_object_token_t timecb_token; - OS_timecb_internal_record_t * local; + OS_timecb_internal_record_t * timecb; OS_timebase_internal_record_t *timebase; osal_id_t cb_list; osal_index_t attach_id; @@ -150,24 +150,24 @@ static int32 OS_DoTimerAdd(osal_id_t *timer_id, const char *timer_name, osal_id_ return_code = OS_ObjectIdAllocateNew(OS_OBJECT_TYPE_OS_TIMECB, timer_name, &timecb_token); if (return_code == OS_SUCCESS) { - local = OS_OBJECT_TABLE_GET(OS_timecb_table, timecb_token); + timecb = OS_OBJECT_TABLE_GET(OS_timecb_table, timecb_token); timebase = OS_OBJECT_TABLE_GET(OS_timebase_table, timebase_token); /* Reset the table entry and save the name */ - OS_OBJECT_INIT(timecb_token, local, timer_name, timer_name); + OS_OBJECT_INIT(timecb_token, timecb, timer_name, timer_name); /* * transfer ownership so the refcount obtained earlier is now * associated with the timecb object, and will be retained until * the object is deleted. */ - OS_ObjectIdTransferToken(&timebase_token, &local->timebase_token); + OS_ObjectIdTransferToken(&timebase_token, &timecb->timebase_token); - local->callback_ptr = callback_ptr; - local->callback_arg = callback_arg; - local->flags = flags; - local->prev_ref = OS_ObjectIndexFromToken(&timecb_token); - local->next_ref = OS_ObjectIndexFromToken(&timecb_token); + timecb->callback_ptr = callback_ptr; + timecb->callback_arg = callback_arg; + timecb->flags = flags; + timecb->prev_ref = OS_ObjectIndexFromToken(&timecb_token); + timecb->next_ref = OS_ObjectIndexFromToken(&timecb_token); /* * Now we need to add it to the time base callback ring, so take the @@ -181,10 +181,10 @@ static int32 OS_DoTimerAdd(osal_id_t *timer_id, const char *timer_name, osal_id_ if (OS_ObjectIdDefined(cb_list)) { OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_TIMECB, cb_list, &attach_id); - local->next_ref = attach_id; - local->prev_ref = OS_timecb_table[attach_id].prev_ref; - OS_timecb_table[local->prev_ref].next_ref = OS_ObjectIndexFromToken(&timecb_token); - OS_timecb_table[local->next_ref].prev_ref = OS_ObjectIndexFromToken(&timecb_token); + timecb->next_ref = attach_id; + timecb->prev_ref = OS_timecb_table[attach_id].prev_ref; + OS_timecb_table[timecb->prev_ref].next_ref = OS_ObjectIndexFromToken(&timecb_token); + OS_timecb_table[timecb->next_ref].prev_ref = OS_ObjectIndexFromToken(&timecb_token); } OS_TimeBaseUnlock_Impl(OS_ObjectIndexFromToken(&timebase_token)); @@ -316,7 +316,7 @@ int32 OS_TimerCreate(osal_id_t *timer_id, const char *timer_name, uint32 *accura *-----------------------------------------------------------------*/ int32 OS_TimerSet(osal_id_t timer_id, uint32 start_time, uint32 interval_time) { - OS_timecb_internal_record_t *local; + OS_timecb_internal_record_t *timecb; int32 return_code; osal_objtype_t objtype; osal_id_t dedicated_timebase_id; @@ -347,19 +347,19 @@ int32 OS_TimerSet(osal_id_t timer_id, uint32 start_time, uint32 interval_time) return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, OS_OBJECT_TYPE_OS_TIMECB, timer_id, &token); if (return_code == OS_SUCCESS) { - local = OS_OBJECT_TABLE_GET(OS_timecb_table, token); + timecb = OS_OBJECT_TABLE_GET(OS_timecb_table, token); - OS_TimeBaseLock_Impl(OS_ObjectIndexFromToken(&local->timebase_token)); + OS_TimeBaseLock_Impl(OS_ObjectIndexFromToken(&timecb->timebase_token)); - if ((local->flags & TIMECB_FLAG_DEDICATED_TIMEBASE) != 0) + if ((timecb->flags & TIMECB_FLAG_DEDICATED_TIMEBASE) != 0) { - dedicated_timebase_id = OS_ObjectIdFromToken(&local->timebase_token); + dedicated_timebase_id = OS_ObjectIdFromToken(&timecb->timebase_token); } - local->wait_time = (int32)start_time; - local->interval_time = (int32)interval_time; + timecb->wait_time = (int32)start_time; + timecb->interval_time = (int32)interval_time; - OS_TimeBaseUnlock_Impl(OS_ObjectIndexFromToken(&local->timebase_token)); + OS_TimeBaseUnlock_Impl(OS_ObjectIndexFromToken(&timecb->timebase_token)); OS_ObjectIdRelease(&token); } @@ -394,13 +394,13 @@ int32 OS_TimerSet(osal_id_t timer_id, uint32 start_time, uint32 interval_time) *-----------------------------------------------------------------*/ int32 OS_TimerDelete(osal_id_t timer_id) { - OS_timecb_internal_record_t * local; int32 return_code; osal_objtype_t objtype; osal_id_t dedicated_timebase_id; - OS_object_token_t token; - OS_timebase_internal_record_t *timebase_local; + OS_object_token_t timecb_token; OS_object_token_t timebase_token; + OS_timebase_internal_record_t *timebase; + OS_timecb_internal_record_t * timecb; dedicated_timebase_id = OS_OBJECT_ID_UNDEFINED; memset(&timebase_token, 0, sizeof(timebase_token)); @@ -415,51 +415,51 @@ int32 OS_TimerDelete(osal_id_t timer_id) return OS_ERR_INCORRECT_OBJ_STATE; } - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, OS_OBJECT_TYPE_OS_TIMECB, timer_id, &token); + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, OS_OBJECT_TYPE_OS_TIMECB, timer_id, &timecb_token); if (return_code == OS_SUCCESS) { - local = OS_OBJECT_TABLE_GET(OS_timecb_table, token); - timebase_local = OS_OBJECT_TABLE_GET(OS_timebase_table, local->timebase_token); + timecb = OS_OBJECT_TABLE_GET(OS_timecb_table, timecb_token); + timebase = OS_OBJECT_TABLE_GET(OS_timebase_table, timecb->timebase_token); - OS_ObjectIdTransferToken(&local->timebase_token, &timebase_token); + OS_ObjectIdTransferToken(&timecb->timebase_token, &timebase_token); - OS_TimeBaseLock_Impl(OS_ObjectIndexFromToken(&local->timebase_token)); + OS_TimeBaseLock_Impl(OS_ObjectIndexFromToken(&timecb->timebase_token)); /* * If the timer uses a dedicated time base, then also delete that. */ - if ((local->flags & TIMECB_FLAG_DEDICATED_TIMEBASE) != 0) + if ((timecb->flags & TIMECB_FLAG_DEDICATED_TIMEBASE) != 0) { - dedicated_timebase_id = OS_ObjectIdFromToken(&local->timebase_token); + dedicated_timebase_id = OS_ObjectIdFromToken(&timecb->timebase_token); } /* * Now we need to remove it from the time base callback ring */ - if (OS_ObjectIdEqual(timebase_local->first_cb, timer_id)) + if (OS_ObjectIdEqual(timebase->first_cb, timer_id)) { - if (local->next_ref != OS_ObjectIndexFromToken(&token)) + if (timecb->next_ref != OS_ObjectIndexFromToken(&timecb_token)) { - OS_ObjectIdCompose_Impl(OS_OBJECT_TYPE_OS_TIMEBASE, local->next_ref, &timebase_local->first_cb); + OS_ObjectIdCompose_Impl(OS_OBJECT_TYPE_OS_TIMEBASE, timecb->next_ref, &timebase->first_cb); } else { /* * consider the list empty */ - timebase_local->first_cb = OS_OBJECT_ID_UNDEFINED; + timebase->first_cb = OS_OBJECT_ID_UNDEFINED; } } - OS_timecb_table[local->prev_ref].next_ref = local->next_ref; - OS_timecb_table[local->next_ref].prev_ref = local->prev_ref; - local->next_ref = OS_ObjectIndexFromToken(&token); - local->prev_ref = OS_ObjectIndexFromToken(&token); + OS_timecb_table[timecb->prev_ref].next_ref = timecb->next_ref; + OS_timecb_table[timecb->next_ref].prev_ref = timecb->prev_ref; + timecb->next_ref = OS_ObjectIndexFromToken(&timecb_token); + timecb->prev_ref = OS_ObjectIndexFromToken(&timecb_token); - OS_TimeBaseUnlock_Impl(OS_ObjectIndexFromToken(&local->timebase_token)); + OS_TimeBaseUnlock_Impl(OS_ObjectIndexFromToken(&timecb->timebase_token)); /* Complete the operation via the common routine */ - return_code = OS_ObjectIdFinalizeDelete(return_code, &token); + return_code = OS_ObjectIdFinalizeDelete(return_code, &timecb_token); } /*