diff --git a/README.md b/README.md index c03fabbc4..dac9b1f06 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,11 @@ The autogenerated OSAL user's guide can be viewed at + ### Development Build: 5.1.0-rc1+dev55 - Deprecate `OS_open` and `OS_creat` to and replaced them with by `OS_OpenCreate`, which implements both functions via flags, and follows the correct OSAL API patterns. diff --git a/src/bsp/generic-linux/src/bsp_console.c b/src/bsp/generic-linux/src/bsp_console.c index fecab0af9..766640952 100644 --- a/src/bsp/generic-linux/src/bsp_console.c +++ b/src/bsp/generic-linux/src/bsp_console.c @@ -76,7 +76,7 @@ void OS_BSP_ConsoleOutput_Impl(const char *Str, uint32 DataLen) { ssize_t WriteLen; - while(DataLen > 0) + while (DataLen > 0) { /* writes the raw data directly to STDOUT_FILENO (unbuffered) */ WriteLen = write(STDOUT_FILENO, Str, DataLen); diff --git a/src/bsp/generic-linux/src/bsp_start.c b/src/bsp/generic-linux/src/bsp_start.c index 4106b010b..0254ec8e0 100644 --- a/src/bsp/generic-linux/src/bsp_start.c +++ b/src/bsp/generic-linux/src/bsp_start.c @@ -49,7 +49,7 @@ OS_BSP_GenericLinuxGlobalData_t OS_BSP_GenericLinuxGlobal; void OS_BSP_Initialize(void) { FILE *fp; - char buffer[32]; + char buffer[32]; /* * If not running as root, check /proc/sys/fs/mqueue/msg_max @@ -64,10 +64,10 @@ void OS_BSP_Initialize(void) */ if (geteuid() != 0) { - fp = fopen("/proc/sys/fs/mqueue/msg_max","r"); + fp = fopen("/proc/sys/fs/mqueue/msg_max", "r"); if (fp) { - if (fgets(buffer,sizeof(buffer),fp) != NULL) + if (fgets(buffer, sizeof(buffer), fp) != NULL) { OS_BSP_Global.MaxQueueDepth = strtoul(buffer, NULL, 10); BSP_DEBUG("Maximum user msg queue depth = %u\n", (unsigned int)OS_BSP_Global.MaxQueueDepth); @@ -89,22 +89,21 @@ int OS_BSP_GetReturnStatus(void) switch (OS_BSP_Global.AppStatus) { - case OS_SUCCESS: - /* translate OS_SUCCESS to the system EXIT_SUCCESS value (usually 0) */ - retcode = EXIT_SUCCESS; - break; - - case OS_ERROR: - /* translate OS_ERROR to the system EXIT_FAILURE value (usually 1) */ - retcode = EXIT_FAILURE; - break; - - default: - /* any other value will be passed through (implementation-defined) */ - /* Range is limited to 0-127, however */ - retcode = OS_BSP_Global.AppStatus & 0x7F; - break; - + case OS_SUCCESS: + /* translate OS_SUCCESS to the system EXIT_SUCCESS value (usually 0) */ + retcode = EXIT_SUCCESS; + break; + + case OS_ERROR: + /* translate OS_ERROR to the system EXIT_FAILURE value (usually 1) */ + retcode = EXIT_FAILURE; + break; + + default: + /* any other value will be passed through (implementation-defined) */ + /* Range is limited to 0-127, however */ + retcode = OS_BSP_Global.AppStatus & 0x7F; + break; } return retcode; @@ -120,7 +119,6 @@ void OS_BSP_Shutdown_Impl(void) abort(); } - /****************************************************************************** ** Function: main() ** diff --git a/src/bsp/generic-linux/src/generic_linux_bsp_internal.h b/src/bsp/generic-linux/src/generic_linux_bsp_internal.h index f8a54184b..60b0a0174 100644 --- a/src/bsp/generic-linux/src/generic_linux_bsp_internal.h +++ b/src/bsp/generic-linux/src/generic_linux_bsp_internal.h @@ -36,7 +36,7 @@ */ typedef struct { - bool EnableTermControl; /**< Will be set "true" when invoked from a TTY device, false otherwise */ + bool EnableTermControl; /**< Will be set "true" when invoked from a TTY device, false otherwise */ } OS_BSP_GenericLinuxGlobalData_t; /* diff --git a/src/bsp/generic-vxworks/src/bsp_console.c b/src/bsp/generic-vxworks/src/bsp_console.c index 6b43b3eef..b96ffe13b 100644 --- a/src/bsp/generic-vxworks/src/bsp_console.c +++ b/src/bsp/generic-vxworks/src/bsp_console.c @@ -58,5 +58,3 @@ void OS_BSP_ConsoleSetMode_Impl(uint32 ModeBits) { /* ignored; not implemented */ } - - diff --git a/src/bsp/generic-vxworks/src/bsp_start.c b/src/bsp/generic-vxworks/src/bsp_start.c index f4be9ad59..55d56c4fc 100644 --- a/src/bsp/generic-vxworks/src/bsp_start.c +++ b/src/bsp/generic-vxworks/src/bsp_start.c @@ -43,7 +43,6 @@ void OS_BSP_Shutdown_Impl(void) abort(); } - /****************************************************************************** ** Function: OS_BSPMain() ** diff --git a/src/bsp/pc-rtems/src/bsp_console.c b/src/bsp/pc-rtems/src/bsp_console.c index c852caac9..9a954c20e 100644 --- a/src/bsp/pc-rtems/src/bsp_console.c +++ b/src/bsp/pc-rtems/src/bsp_console.c @@ -55,5 +55,3 @@ void OS_BSP_ConsoleSetMode_Impl(uint32 ModeBits) { /* no-op on RTEMS */ } - - diff --git a/src/bsp/pc-rtems/src/bsp_start.c b/src/bsp/pc-rtems/src/bsp_start.c index 8315c8c59..2bbad651b 100644 --- a/src/bsp/pc-rtems/src/bsp_start.c +++ b/src/bsp/pc-rtems/src/bsp_start.c @@ -55,30 +55,17 @@ ** External Declarations */ extern rtems_status_code rtems_ide_part_table_initialize(const char *); -extern int rtems_rtl_shell_command (int argc, char* argv[]); +extern int rtems_rtl_shell_command(int argc, char *argv[]); /* * Additional shell commands for the RTL functionality */ rtems_shell_cmd_t rtems_shell_RTL_Command = { - .name = "rtl", - .usage = "rtl COMMAND...", - .topic = "misc", - .command = rtems_rtl_shell_command -}; + .name = "rtl", .usage = "rtl COMMAND...", .topic = "misc", .command = rtems_rtl_shell_command}; rtems_shell_cmd_t rtems_shell_dlopen_Command = { - .name = "dlopen", - .usage = "dlopen COMMAND...", - .topic = "misc", - .command = shell_dlopen -}; + .name = "dlopen", .usage = "dlopen COMMAND...", .topic = "misc", .command = shell_dlopen}; rtems_shell_cmd_t rtems_shell_dlsym_Command = { - .name = "dlsym", - .usage = "dlsym COMMAND...", - .topic = "misc", - .command = shell_dlsym -}; - + .name = "dlsym", .usage = "dlsym COMMAND...", .topic = "misc", .command = shell_dlsym}; /* ** Global variables @@ -87,11 +74,11 @@ OS_BSP_PcRtemsGlobalData_t OS_BSP_PcRtemsGlobal; void OS_BSP_Setup(void) { - int status; - struct stat statbuf; - const char * cmdlinestr; - const char * cmdp; - char * cmdi, *cmdo; + int status; + struct stat statbuf; + const char *cmdlinestr; + const char *cmdp; + char * cmdi, *cmdo; cmdlinestr = bsp_cmdline(); @@ -218,8 +205,8 @@ void OS_BSP_Setup(void) } else { - status = mount("/dev/hda1", RTEMS_USER_FS_MOUNTPOINT, RTEMS_FILESYSTEM_TYPE_DOSFS, - RTEMS_FILESYSTEM_READ_WRITE, NULL); + status = mount("/dev/hda1", RTEMS_USER_FS_MOUNTPOINT, RTEMS_FILESYSTEM_TYPE_DOSFS, RTEMS_FILESYSTEM_READ_WRITE, + NULL); if (status < 0) { BSP_DEBUG("mount failed: %s\n", strerror(errno)); @@ -234,7 +221,6 @@ void OS_BSP_Setup(void) */ chdir(RTEMS_USER_FS_MOUNTPOINT); - /* * Start the shell now, before any application starts. * This way, if there is an issue with the application startup, @@ -275,18 +261,18 @@ rtems_status_code OS_BSP_GetReturnStatus(void) switch (OS_BSP_Global.AppStatus) { - case OS_SUCCESS: - /* translate OS_SUCCESS to the system RTEMS_SUCCESSFUL value */ - StatusStr = "SUCCESS"; - retcode = RTEMS_SUCCESSFUL; - break; - - default: - /* translate anything else to a generic non-success code, - * this basically just means the main task exited */ - StatusStr = "ERROR"; - retcode = RTEMS_TASK_EXITTED; - break; + case OS_SUCCESS: + /* translate OS_SUCCESS to the system RTEMS_SUCCESSFUL value */ + StatusStr = "SUCCESS"; + retcode = RTEMS_SUCCESSFUL; + break; + + default: + /* translate anything else to a generic non-success code, + * this basically just means the main task exited */ + StatusStr = "ERROR"; + retcode = RTEMS_TASK_EXITTED; + break; } printf("\nApplication exit status: %s (%d)\n\n", StatusStr, (int)OS_BSP_Global.AppStatus); @@ -364,9 +350,10 @@ rtems_task Init(rtems_task_argument ignored) */ #define TASK_INTLEVEL 0 #define CONFIGURE_INIT -#define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_FLOATING_POINT | RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_ASR | RTEMS_INTERRUPT_LEVEL(TASK_INTLEVEL)) -#define CONFIGURE_INIT_TASK_STACK_SIZE (20*1024) -#define CONFIGURE_INIT_TASK_PRIORITY 10 +#define CONFIGURE_INIT_TASK_ATTRIBUTES \ + (RTEMS_FLOATING_POINT | RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_ASR | RTEMS_INTERRUPT_LEVEL(TASK_INTLEVEL)) +#define CONFIGURE_INIT_TASK_STACK_SIZE (20 * 1024) +#define CONFIGURE_INIT_TASK_PRIORITY 10 /* * Note that these resources are shared with RTEMS itself (e.g. the init task, the shell) @@ -383,13 +370,13 @@ rtems_task Init(rtems_task_argument ignored) * 16 internal semaphores * */ -#define CONFIGURE_MAXIMUM_TASKS (OS_MAX_TASKS + 8) -#define CONFIGURE_MAXIMUM_TIMERS (OS_MAX_TIMERS + 2) -#define CONFIGURE_MAXIMUM_SEMAPHORES (OS_MAX_BIN_SEMAPHORES + OS_MAX_COUNT_SEMAPHORES + OS_MAX_MUTEXES + 16) -#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES (OS_MAX_QUEUES + 4) -#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS (OS_MAX_NUM_OPEN_FILES + 8) -#define CONFIGURE_MAXIMUM_DRIVERS 10 -#define CONFIGURE_MAXIMUM_POSIX_KEYS 4 +#define CONFIGURE_MAXIMUM_TASKS (OS_MAX_TASKS + 8) +#define CONFIGURE_MAXIMUM_TIMERS (OS_MAX_TIMERS + 2) +#define CONFIGURE_MAXIMUM_SEMAPHORES (OS_MAX_BIN_SEMAPHORES + OS_MAX_COUNT_SEMAPHORES + OS_MAX_MUTEXES + 16) +#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES (OS_MAX_QUEUES + 4) +#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS (OS_MAX_NUM_OPEN_FILES + 8) +#define CONFIGURE_MAXIMUM_DRIVERS 10 +#define CONFIGURE_MAXIMUM_POSIX_KEYS 4 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER @@ -403,9 +390,9 @@ rtems_task Init(rtems_task_argument ignored) #define CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER #define CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER -#define CONFIGURE_EXECUTIVE_RAM_SIZE (8*1024*1024) -#define CONFIGURE_MICROSECONDS_PER_TICK 10000 -#define CONFIGURE_ATA_DRIVER_TASK_PRIORITY 9 +#define CONFIGURE_EXECUTIVE_RAM_SIZE (8 * 1024 * 1024) +#define CONFIGURE_MICROSECONDS_PER_TICK 10000 +#define CONFIGURE_ATA_DRIVER_TASK_PRIORITY 9 #include @@ -413,10 +400,6 @@ rtems_task Init(rtems_task_argument ignored) #define CONFIGURE_SHELL_COMMANDS_ALL #define CONFIGURE_SHELL_MOUNT_MSDOS -#define CONFIGURE_SHELL_USER_COMMANDS \ - &rtems_shell_RTL_Command, \ - &rtems_shell_dlopen_Command, \ - &rtems_shell_dlsym_Command - +#define CONFIGURE_SHELL_USER_COMMANDS &rtems_shell_RTL_Command, &rtems_shell_dlopen_Command, &rtems_shell_dlsym_Command #include diff --git a/src/bsp/pc-rtems/src/pcrtems_bsp_internal.h b/src/bsp/pc-rtems/src/pcrtems_bsp_internal.h index 4c92d202a..8d3690596 100644 --- a/src/bsp/pc-rtems/src/pcrtems_bsp_internal.h +++ b/src/bsp/pc-rtems/src/pcrtems_bsp_internal.h @@ -37,19 +37,19 @@ /* * BSP compile-time tuning */ -#define RTEMS_MAX_USER_OPTIONS 4 -#define RTEMS_MAX_CMDLINE 256 +#define RTEMS_MAX_USER_OPTIONS 4 +#define RTEMS_MAX_CMDLINE 256 /* * The location which the general purpose file system will be mounted */ -#define RTEMS_USER_FS_MOUNTPOINT "/mnt" +#define RTEMS_USER_FS_MOUNTPOINT "/mnt" /* * By default put the shell at the same priority * as the utility task which handles OS_printf() */ -#define RTEMS_SHELL_PRIORITY OS_UTILITYTASK_PRIORITY +#define RTEMS_SHELL_PRIORITY OS_UTILITYTASK_PRIORITY /* ** BSP types diff --git a/src/bsp/shared/inc/bsp-impl.h b/src/bsp/shared/inc/bsp-impl.h index 3497d1269..1f67853a6 100644 --- a/src/bsp/shared/inc/bsp-impl.h +++ b/src/bsp/shared/inc/bsp-impl.h @@ -62,7 +62,7 @@ #define OS_BSP_CONSOLEMODE_BLUE 0x4 /**< Blue text, if terminal supports color */ #define OS_BSP_CONSOLEMODE_HIGHLIGHT 0x8 /**< Highlighted/Emphasis text, if terminal supports it */ -#define OS_BSP_CONSOLEMODE_TO_ANSICOLOR(x) ((x) & 0x07) +#define OS_BSP_CONSOLEMODE_TO_ANSICOLOR(x) ((x)&0x07) /* * Macro for BSP debug messages, similar to OS_DEBUG in OSAL code. @@ -90,10 +90,10 @@ */ typedef struct { - uint32 ArgC; /* number of boot/startup parameters in ArgV */ - char **ArgV; /* strings for boot/startup parameters */ - int32 AppStatus; /* value which can be returned to the OS (0=nominal) */ - uint32 MaxQueueDepth; /* Queue depth limit supported by BSP (0=no limit) */ + uint32 ArgC; /* number of boot/startup parameters in ArgV */ + char **ArgV; /* strings for boot/startup parameters */ + int32 AppStatus; /* value which can be returned to the OS (0=nominal) */ + uint32 MaxQueueDepth; /* Queue depth limit supported by BSP (0=no limit) */ } OS_BSP_GlobalData_t; /* diff --git a/src/bsp/shared/src/bsp_default_symtab.c b/src/bsp/shared/src/bsp_default_symtab.c index 65e1efca5..d2c0e8c32 100644 --- a/src/bsp/shared/src/bsp_default_symtab.c +++ b/src/bsp/shared/src/bsp_default_symtab.c @@ -32,10 +32,5 @@ #include "osapi.h" #include "bsp-impl.h" - -OS_static_symbol_record_t OS_STATIC_SYMBOL_TABLE[] = -{ - { "OS_Application_Startup", OS_Application_Startup }, - { "OS_Application_Run", OS_Application_Run }, - { NULL, NULL } -}; +OS_static_symbol_record_t OS_STATIC_SYMBOL_TABLE[] = { + {"OS_Application_Startup", OS_Application_Startup}, {"OS_Application_Run", OS_Application_Run}, {NULL, NULL}}; diff --git a/src/bsp/shared/src/osapi-bsp.c b/src/bsp/shared/src/osapi-bsp.c index e140d5dfc..015b738c9 100644 --- a/src/bsp/shared/src/osapi-bsp.c +++ b/src/bsp/shared/src/osapi-bsp.c @@ -63,7 +63,7 @@ uint32 OS_BSP_GetArgC(void) OS_BSP_GetArgV See full description in header ------------------------------------------------------------------*/ -char * const * OS_BSP_GetArgV(void) +char *const *OS_BSP_GetArgV(void) { return OS_BSP_Global.ArgV; } @@ -76,4 +76,3 @@ void OS_BSP_SetExitCode(int32 code) { OS_BSP_Global.AppStatus = code; } - diff --git a/src/examples/tasking-example/tasking-example.c b/src/examples/tasking-example/tasking-example.c index 5a9da0cd4..68431b2ea 100644 --- a/src/examples/tasking-example/tasking-example.c +++ b/src/examples/tasking-example/tasking-example.c @@ -21,7 +21,7 @@ /* ** example1.c ** -** This is an example OSAL Application. This Application creates three tasks, +** This is an example OSAL Application. This Application creates three tasks, ** and passes messages back and forth using queues */ @@ -29,7 +29,6 @@ #include "common_types.h" #include "osapi.h" - /* Task 1 */ #define TASK_1_ID 1 @@ -40,7 +39,6 @@ uint32 task_1_stack[TASK_1_STACK_SIZE]; void task_1(void); - /* Task 2 */ #define TASK_2_ID 2 @@ -51,7 +49,6 @@ uint32 task_2_stack[TASK_2_STACK_SIZE]; void task_2(void); - /* Task 3 */ #define TASK_3_ID 3 @@ -62,14 +59,13 @@ uint32 task_3_stack[TASK_3_STACK_SIZE]; void task_3(void); - /* OS Constructs */ -#define MSGQ_ID 1 -#define MSGQ_DEPTH 50 -#define MSGQ_SIZE 4 +#define MSGQ_ID 1 +#define MSGQ_DEPTH 50 +#define MSGQ_SIZE 4 -#define MUTEX_ID 1 +#define MUTEX_ID 1 uint32 task_1_id, task_2_id, task_3_id; uint32 mutex_id, msgq_id; @@ -78,52 +74,49 @@ uint32 mutex_id, msgq_id; uint32 shared_resource_x; - /* ********************** MAIN **************************** */ void OS_Application_Startup(void) { - uint32 status; - - OS_API_Init(); - - OS_printf("********If You see this, we got into OS_Application_Startup****\n"); - - status = OS_QueueCreate( &msgq_id, "MsgQ", MSGQ_DEPTH, MSGQ_SIZE, 0); - if ( status != OS_SUCCESS ) - { - OS_printf("Error creating Message Queue\n"); - } - - status = OS_MutSemCreate( &mutex_id, "Mutex", 0); - if ( status != OS_SUCCESS ) - { - OS_printf("Error creating mutex\n"); - } - else - { - OS_printf("MutexSem ID = %d\n", (int)mutex_id); - } - - status = OS_TaskCreate( &task_1_id, "Task 1", task_1, task_1_stack, TASK_1_STACK_SIZE, TASK_1_PRIORITY, 0); - if ( status != OS_SUCCESS ) - { - OS_printf("Error creating Task 1\n"); - } - - status = OS_TaskCreate( &task_2_id, "Task 2", task_2, task_2_stack, TASK_2_STACK_SIZE, TASK_2_PRIORITY, 0); - if ( status != OS_SUCCESS ) - { - OS_printf("Error creating Task 2\n"); - } - - status = OS_TaskCreate( &task_3_id, "Task 3", task_3, task_3_stack, TASK_3_STACK_SIZE, TASK_3_PRIORITY, 0); - if ( status != OS_SUCCESS ) - { - OS_printf("Error creating Task 3\n"); - } + uint32 status; + + OS_API_Init(); + + OS_printf("********If You see this, we got into OS_Application_Startup****\n"); + + status = OS_QueueCreate(&msgq_id, "MsgQ", MSGQ_DEPTH, MSGQ_SIZE, 0); + if (status != OS_SUCCESS) + { + OS_printf("Error creating Message Queue\n"); + } + + status = OS_MutSemCreate(&mutex_id, "Mutex", 0); + if (status != OS_SUCCESS) + { + OS_printf("Error creating mutex\n"); + } + else + { + OS_printf("MutexSem ID = %d\n", (int)mutex_id); + } + status = OS_TaskCreate(&task_1_id, "Task 1", task_1, task_1_stack, TASK_1_STACK_SIZE, TASK_1_PRIORITY, 0); + if (status != OS_SUCCESS) + { + OS_printf("Error creating Task 1\n"); + } + + status = OS_TaskCreate(&task_2_id, "Task 2", task_2, task_2_stack, TASK_2_STACK_SIZE, TASK_2_PRIORITY, 0); + if (status != OS_SUCCESS) + { + OS_printf("Error creating Task 2\n"); + } + status = OS_TaskCreate(&task_3_id, "Task 3", task_3, task_3_stack, TASK_3_STACK_SIZE, TASK_3_PRIORITY, 0); + if (status != OS_SUCCESS) + { + OS_printf("Error creating Task 3\n"); + } } /* ********************** TASK 1 **************************** */ @@ -136,41 +129,40 @@ void task_1(void) OS_TaskRegister(); - while(1) + while (1) { status = OS_MutSemTake(mutex_id); - if ( status != OS_SUCCESS ) + if (status != OS_SUCCESS) { - OS_printf("TASK 1:Error calling OS_MutSemTake with mutex_id = %d\n", (int)mutex_id); + OS_printf("TASK 1:Error calling OS_MutSemTake with mutex_id = %d\n", (int)mutex_id); } shared_resource_x = task_1_id; - status = OS_QueuePut(msgq_id, (void*)&shared_resource_x, sizeof(uint32), 0); - if ( status != OS_SUCCESS ) + status = OS_QueuePut(msgq_id, (void *)&shared_resource_x, sizeof(uint32), 0); + if (status != OS_SUCCESS) { - OS_printf("TASK 1:Error calling OS_QueuePut ( 1 )\n"); + OS_printf("TASK 1:Error calling OS_QueuePut ( 1 )\n"); } shared_resource_x = task_1_id; - status = OS_QueuePut(msgq_id, (void*)&shared_resource_x, sizeof(uint32), 0); - if ( status != OS_SUCCESS ) + status = OS_QueuePut(msgq_id, (void *)&shared_resource_x, sizeof(uint32), 0); + if (status != OS_SUCCESS) { - OS_printf("TASK 1:Error calling OS_QueuePut ( 2 )\n"); + OS_printf("TASK 1:Error calling OS_QueuePut ( 2 )\n"); } status = OS_MutSemGive(mutex_id); - if ( status != OS_SUCCESS ) + if (status != OS_SUCCESS) { - OS_printf("TASK 1:Error calling OS_MutSemGive\n"); + OS_printf("TASK 1:Error calling OS_MutSemGive\n"); } - + OS_TaskDelay(100); } } - /* ********************** TASK 2 **************************** */ void task_2(void) @@ -181,48 +173,47 @@ void task_2(void) OS_TaskRegister(); - while(1) + while (1) { status = OS_MutSemTake(mutex_id); - if ( status != OS_SUCCESS ) + if (status != OS_SUCCESS) { - OS_printf("TASK 2:Error calling OS_MutSemTake\n"); + OS_printf("TASK 2:Error calling OS_MutSemTake\n"); } shared_resource_x = task_2_id; - status = OS_QueuePut(msgq_id, (void*)&shared_resource_x, sizeof(uint32), 0); - if ( status != OS_SUCCESS ) + status = OS_QueuePut(msgq_id, (void *)&shared_resource_x, sizeof(uint32), 0); + if (status != OS_SUCCESS) { - OS_printf("TASK 2:Error calling OS_QueuePut (1)\n"); + OS_printf("TASK 2:Error calling OS_QueuePut (1)\n"); } - + OS_TaskDelay(150); shared_resource_x = task_2_id; - status = OS_QueuePut(msgq_id, (void*)&shared_resource_x, sizeof(uint32), 0); - if ( status != OS_SUCCESS ) + status = OS_QueuePut(msgq_id, (void *)&shared_resource_x, sizeof(uint32), 0); + if (status != OS_SUCCESS) { - OS_printf("TASK 2:Error calling OS_QueuePut (2)\n"); + OS_printf("TASK 2:Error calling OS_QueuePut (2)\n"); } status = OS_MutSemGive(mutex_id); - if ( status != OS_SUCCESS ) + if (status != OS_SUCCESS) { - OS_printf("TASK 2:Error calling OS_MutSemGive\n"); + OS_printf("TASK 2:Error calling OS_MutSemGive\n"); } OS_TaskDelay(500); - } + } } - /* ********************** TASK 3 **************************** */ void task_3(void) -{ - +{ + uint32 data_received; uint32 data_size; uint32 status; @@ -231,14 +222,14 @@ void task_3(void) OS_TaskRegister(); - while(1) + while (1) { - status = OS_QueueGet(msgq_id, (void*)&data_received, MSGQ_SIZE, &data_size, OS_PEND); - + status = OS_QueueGet(msgq_id, (void *)&data_received, MSGQ_SIZE, &data_size, OS_PEND); + if (status == OS_SUCCESS) { - OS_printf("TASK 3: Received - %d\n", (int)data_received+1); - } + OS_printf("TASK 3: Received - %d\n", (int)data_received + 1); + } else { OS_printf("TASK 3: Error calling OS_QueueGet\n"); diff --git a/src/os/inc/common_types.h b/src/os/inc/common_types.h index f868a3d34..a9bc35762 100644 --- a/src/os/inc/common_types.h +++ b/src/os/inc/common_types.h @@ -32,7 +32,8 @@ #define _common_types_ #ifdef __cplusplus - extern "C" { +extern "C" +{ #endif /* @@ -43,82 +44,79 @@ ** Macro Definitions */ -/* -** Condition = TRUE is ok, Condition = FALSE is error +/* +** Condition = TRUE is ok, Condition = FALSE is error */ #define CompileTimeAssert(Condition, Message) typedef char Message[(Condition) ? 1 : -1] - /* ** Define compiler specific macros ** The __extension__ compiler pragma is required ** for the uint64 type using GCC with the ANSI C90 standard. -** Other macros can go in here as needed, for example alignment +** Other macros can go in here as needed, for example alignment ** pragmas. ** ** NOTE: The white-box (coverage) unit testing may need to disable ** these extra attributes. These test builds define the OSAPI_NO_SPECIAL_ATTRIBS ** macro to disable this. */ -#if defined (__GNUC__) && !defined(OSAPI_NO_SPECIAL_ATTRIBS) - #define _EXTENSION_ __extension__ - #define OS_PACK __attribute__ ((packed)) - #define OS_ALIGN(n) __attribute__((aligned(n))) - #define OS_USED __attribute__((used)) - #define OS_PRINTF(n,m) __attribute__ ((format (printf, n, m))) +#if defined(__GNUC__) && !defined(OSAPI_NO_SPECIAL_ATTRIBS) +#define _EXTENSION_ __extension__ +#define OS_PACK __attribute__((packed)) +#define OS_ALIGN(n) __attribute__((aligned(n))) +#define OS_USED __attribute__((used)) +#define OS_PRINTF(n, m) __attribute__((format(printf, n, m))) #else - #define _EXTENSION_ - #define OS_PACK - #define OS_ALIGN(n) - #define OS_USED - #define OS_PRINTF(n,m) +#define _EXTENSION_ +#define OS_PACK +#define OS_ALIGN(n) +#define OS_USED +#define OS_PRINTF(n, m) #endif #include #include #include -/* - * NOTE - NOT DEFINING STRUCT_LOW_BIT_FIRST or STRUCT_HIGH_BIT_FIRST - * We should not make assumptions about the bit order here - */ - - typedef int8_t int8; - typedef int16_t int16; - typedef int32_t int32; - typedef int64_t int64; - typedef uint8_t uint8; - typedef uint16_t uint16; - typedef uint32_t uint32; - typedef uint64_t uint64; - typedef intptr_t intptr; - typedef uintptr_t cpuaddr; - typedef size_t cpusize; - typedef ptrdiff_t cpudiff; - - /** - * A type to be used for OSAL resource identifiers. - */ - typedef uint32_t osal_id_t; - - - -#ifndef NULL /* pointer to nothing */ - #define NULL ((void *) 0) + /* + * NOTE - NOT DEFINING STRUCT_LOW_BIT_FIRST or STRUCT_HIGH_BIT_FIRST + * We should not make assumptions about the bit order here + */ + + typedef int8_t int8; + typedef int16_t int16; + typedef int32_t int32; + typedef int64_t int64; + typedef uint8_t uint8; + typedef uint16_t uint16; + typedef uint32_t uint32; + typedef uint64_t uint64; + typedef intptr_t intptr; + typedef uintptr_t cpuaddr; + typedef size_t cpusize; + typedef ptrdiff_t cpudiff; + + /** + * A type to be used for OSAL resource identifiers. + */ + typedef uint32_t osal_id_t; + +#ifndef NULL /* pointer to nothing */ +#define NULL ((void *)0) #endif -/* -** Check Sizes -*/ -CompileTimeAssert(sizeof(uint8)==1, TypeUint8WrongSize); -CompileTimeAssert(sizeof(uint16)==2, TypeUint16WrongSize); -CompileTimeAssert(sizeof(uint32)==4, TypeUint32WrongSize); -CompileTimeAssert(sizeof(uint64)==8, TypeUint64WrongSize); -CompileTimeAssert(sizeof(int8)==1, Typeint8WrongSize); -CompileTimeAssert(sizeof(int16)==2, Typeint16WrongSize); -CompileTimeAssert(sizeof(int32)==4, Typeint32WrongSize); -CompileTimeAssert(sizeof(int64)==8, Typeint64WrongSize); -CompileTimeAssert(sizeof(cpuaddr) >= sizeof(void *), TypePtrWrongSize); + /* + ** Check Sizes + */ + CompileTimeAssert(sizeof(uint8) == 1, TypeUint8WrongSize); + CompileTimeAssert(sizeof(uint16) == 2, TypeUint16WrongSize); + CompileTimeAssert(sizeof(uint32) == 4, TypeUint32WrongSize); + CompileTimeAssert(sizeof(uint64) == 8, TypeUint64WrongSize); + CompileTimeAssert(sizeof(int8) == 1, Typeint8WrongSize); + CompileTimeAssert(sizeof(int16) == 2, Typeint16WrongSize); + CompileTimeAssert(sizeof(int32) == 4, Typeint32WrongSize); + CompileTimeAssert(sizeof(int64) == 8, Typeint64WrongSize); + CompileTimeAssert(sizeof(cpuaddr) >= sizeof(void *), TypePtrWrongSize); /* * TEMPORARY COMPATIBILITY MACRO @@ -136,20 +134,12 @@ CompileTimeAssert(sizeof(cpuaddr) >= sizeof(void *), TypePtrWrongSize); */ #if !defined(SOFTWARE_BIG_BIT_ORDER) && !defined(SOFTWARE_LITTLE_BIT_ORDER) -#if defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN || \ - defined(__BIG_ENDIAN__) || \ - defined(__ARMEB__) || \ - defined(__THUMBEB__) || \ - defined(__AARCH64EB__) || \ - defined(_MIBSEB) || defined(__MIBSEB) || defined(__MIBSEB__) +#if defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN || defined(__BIG_ENDIAN__) || defined(__ARMEB__) || \ + defined(__THUMBEB__) || defined(__AARCH64EB__) || defined(_MIBSEB) || defined(__MIBSEB) || defined(__MIBSEB__) /* It is a big-endian target architecture */ #define SOFTWARE_BIG_BIT_ORDER -#elif defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN || \ - defined(__LITTLE_ENDIAN__) || \ - defined(__ARMEL__) || \ - defined(__THUMBEL__) || \ - defined(__AARCH64EL__) || \ - defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__) +#elif defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN || defined(__LITTLE_ENDIAN__) || defined(__ARMEL__) || \ + defined(__THUMBEL__) || defined(__AARCH64EL__) || defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__) /* It is a little-endian target architecture */ #define SOFTWARE_LITTLE_BIT_ORDER #endif @@ -157,7 +147,7 @@ CompileTimeAssert(sizeof(cpuaddr) >= sizeof(void *), TypePtrWrongSize); #endif /* !defined(SOFTWARE_BIG_BIT_ORDER) && !defined(SOFTWARE_LITTLE_BIT_ORDER) */ #ifdef __cplusplus - } +} #endif -#endif /* _common_types_ */ +#endif /* _common_types_ */ diff --git a/src/os/inc/osapi-os-core.h b/src/os/inc/osapi-os-core.h index d94ea6ea7..a6fa0d47c 100644 --- a/src/os/inc/osapi-os-core.h +++ b/src/os/inc/osapi-os-core.h @@ -30,51 +30,50 @@ #ifndef _osapi_core_ #define _osapi_core_ -#include /* for va_list */ +#include /* for va_list */ /* Defines constants for making object ID's unique */ -#define OS_OBJECT_INDEX_MASK 0xFFFF /**< @brief Object index mask */ -#define OS_OBJECT_TYPE_SHIFT 16 /**< @brief Object type shift */ +#define OS_OBJECT_INDEX_MASK 0xFFFF /**< @brief Object index mask */ +#define OS_OBJECT_TYPE_SHIFT 16 /**< @brief Object type shift */ /** @defgroup OSObjectTypes OSAL Object Type Defines * @{ */ -#define OS_OBJECT_TYPE_UNDEFINED 0x00 /**< @brief Object type undefined */ -#define OS_OBJECT_TYPE_OS_TASK 0x01 /**< @brief Object task type */ -#define OS_OBJECT_TYPE_OS_QUEUE 0x02 /**< @brief Object queue type */ -#define OS_OBJECT_TYPE_OS_COUNTSEM 0x03 /**< @brief Object counting semaphore type */ -#define OS_OBJECT_TYPE_OS_BINSEM 0x04 /**< @brief Object binary semaphore type */ -#define OS_OBJECT_TYPE_OS_MUTEX 0x05 /**< @brief Object mutex type */ -#define OS_OBJECT_TYPE_OS_STREAM 0x06 /**< @brief Object stream type */ -#define OS_OBJECT_TYPE_OS_DIR 0x07 /**< @brief Object directory type */ -#define OS_OBJECT_TYPE_OS_TIMEBASE 0x08 /**< @brief Object timebase type */ -#define OS_OBJECT_TYPE_OS_TIMECB 0x09 /**< @brief Object timer callback type */ -#define OS_OBJECT_TYPE_OS_MODULE 0x0A /**< @brief Object module type */ -#define OS_OBJECT_TYPE_OS_FILESYS 0x0B /**< @brief Object file system type */ -#define OS_OBJECT_TYPE_OS_CONSOLE 0x0C /**< @brief Object console type */ -#define OS_OBJECT_TYPE_USER 0x10 /**< @brief Object user type */ +#define OS_OBJECT_TYPE_UNDEFINED 0x00 /**< @brief Object type undefined */ +#define OS_OBJECT_TYPE_OS_TASK 0x01 /**< @brief Object task type */ +#define OS_OBJECT_TYPE_OS_QUEUE 0x02 /**< @brief Object queue type */ +#define OS_OBJECT_TYPE_OS_COUNTSEM 0x03 /**< @brief Object counting semaphore type */ +#define OS_OBJECT_TYPE_OS_BINSEM 0x04 /**< @brief Object binary semaphore type */ +#define OS_OBJECT_TYPE_OS_MUTEX 0x05 /**< @brief Object mutex type */ +#define OS_OBJECT_TYPE_OS_STREAM 0x06 /**< @brief Object stream type */ +#define OS_OBJECT_TYPE_OS_DIR 0x07 /**< @brief Object directory type */ +#define OS_OBJECT_TYPE_OS_TIMEBASE 0x08 /**< @brief Object timebase type */ +#define OS_OBJECT_TYPE_OS_TIMECB 0x09 /**< @brief Object timer callback type */ +#define OS_OBJECT_TYPE_OS_MODULE 0x0A /**< @brief Object module type */ +#define OS_OBJECT_TYPE_OS_FILESYS 0x0B /**< @brief Object file system type */ +#define OS_OBJECT_TYPE_OS_CONSOLE 0x0C /**< @brief Object console type */ +#define OS_OBJECT_TYPE_USER 0x10 /**< @brief Object user type */ /**@}*/ /** @brief Upper limit for OSAL task priorities */ -#define OS_MAX_TASK_PRIORITY 255 +#define OS_MAX_TASK_PRIORITY 255 /** * @brief Initializer for the osal_id_t type which will not match any valid value */ -#define OS_OBJECT_ID_UNDEFINED ((osal_id_t){0}) +#define OS_OBJECT_ID_UNDEFINED ((osal_id_t) {0}) /** * @brief Constant that may be passed to OS_ForEachObject()/OS_ForEachObjectOfType() to match any * creator (i.e. get all objects) */ -#define OS_OBJECT_CREATOR_ANY OS_OBJECT_ID_UNDEFINED - +#define OS_OBJECT_CREATOR_ANY OS_OBJECT_ID_UNDEFINED /** @defgroup OSSemaphoreStates OSAL Semaphore State Defines * @{ */ -#define OS_SEM_FULL 1 /**< @brief Semaphore full state */ -#define OS_SEM_EMPTY 0 /**< @brief Semaphore empty state */ +#define OS_SEM_FULL 1 /**< @brief Semaphore full state */ +#define OS_SEM_EMPTY 0 /**< @brief Semaphore empty state */ /**@}*/ /** @brief Floating point enabled state for a task */ @@ -85,57 +84,55 @@ * The sizes of strings in OSAL functions are built with this limit in mind. * Always check the uses of os_err_name_t when changing this value. */ -#define OS_ERROR_NAME_LENGTH 35 - +#define OS_ERROR_NAME_LENGTH 35 /* Object property structures */ /** @brief OSAL task properties */ typedef struct { - char name [OS_MAX_API_NAME]; + char name[OS_MAX_API_NAME]; osal_id_t creator; - uint32 stack_size; - uint32 priority; -}OS_task_prop_t; - + uint32 stack_size; + uint32 priority; +} OS_task_prop_t; + /** @brief OSAL queue properties */ typedef struct { - char name [OS_MAX_API_NAME]; + char name[OS_MAX_API_NAME]; osal_id_t creator; -}OS_queue_prop_t; +} OS_queue_prop_t; /** @brief OSAL binary semaphore properties */ typedef struct -{ - char name [OS_MAX_API_NAME]; +{ + char name[OS_MAX_API_NAME]; osal_id_t creator; - int32 value; -}OS_bin_sem_prop_t; + int32 value; +} OS_bin_sem_prop_t; /** @brief OSAL counting semaphore properties */ typedef struct -{ - char name [OS_MAX_API_NAME]; +{ + char name[OS_MAX_API_NAME]; osal_id_t creator; - int32 value; -}OS_count_sem_prop_t; + int32 value; +} OS_count_sem_prop_t; /** @brief OSAL mutexe properties */ typedef struct { - char name [OS_MAX_API_NAME]; + char name[OS_MAX_API_NAME]; osal_id_t creator; -}OS_mut_sem_prop_t; - +} OS_mut_sem_prop_t; /** @brief OSAL time */ -typedef struct -{ - uint32 seconds; +typedef struct +{ + uint32 seconds; uint32 microsecs; -}OS_time_t; +} OS_time_t; /** @brief OSAL heap properties * @@ -146,7 +143,7 @@ typedef struct uint32 free_bytes; uint32 free_blocks; uint32 largest_free_block; -}OS_heap_prop_t; +} OS_heap_prop_t; /** * @brief An abstract structure capable of holding several OSAL IDs @@ -158,7 +155,7 @@ typedef struct */ typedef struct { - uint8 object_ids[(OS_MAX_NUM_OPEN_FILES + 7) / 8]; + uint8 object_ids[(OS_MAX_NUM_OPEN_FILES + 7) / 8]; } OS_FdSet; /** @@ -170,10 +167,10 @@ typedef struct */ typedef enum { - OS_STREAM_STATE_BOUND = 0x01, /**< @brief whether the stream is bound */ - OS_STREAM_STATE_CONNECTED = 0x02, /**< @brief whether the stream is connected */ - OS_STREAM_STATE_READABLE = 0x04, /**< @brief whether the stream is readable */ - OS_STREAM_STATE_WRITABLE = 0x08, /**< @brief whether the stream is writable */ + OS_STREAM_STATE_BOUND = 0x01, /**< @brief whether the stream is bound */ + OS_STREAM_STATE_CONNECTED = 0x02, /**< @brief whether the stream is connected */ + OS_STREAM_STATE_READABLE = 0x04, /**< @brief whether the stream is readable */ + OS_STREAM_STATE_WRITABLE = 0x08, /**< @brief whether the stream is writable */ } OS_StreamState_t; /** @@ -181,7 +178,7 @@ typedef enum */ typedef enum { - OS_EVENT_RESERVED = 0, /**< no-op/reserved event id value */ + OS_EVENT_RESERVED = 0, /**< no-op/reserved event id value */ /** * resource/id has been newly allocated but not yet created. @@ -232,7 +229,7 @@ typedef enum */ OS_EVENT_TASK_STARTUP, - OS_EVENT_MAX /**< placeholder for end of enum, not used */ + OS_EVENT_MAX /**< placeholder for end of enum, not used */ } OS_Event_t; /** @@ -260,8 +257,8 @@ typedef char os_err_name_t[OS_ERROR_NAME_LENGTH]; /* ** These typedefs are for the task entry point */ -typedef void osal_task; /**< @brief For task entry point */ -typedef osal_task ((*osal_task_entry)(void)); /**< @brief For task entry point */ +typedef void osal_task; /**< @brief For task entry point */ +typedef osal_task((*osal_task_entry)(void)); /**< @brief For task entry point */ /** * @brief General purpose OSAL callback function @@ -309,7 +306,7 @@ void OS_Application_Run(void); * @retval #OS_SUCCESS @copybrief OS_SUCCESS * @retval #OS_ERROR @copybrief OS_ERROR */ -int32 OS_API_Init (void); +int32 OS_API_Init(void); /*-------------------------------------------------------------------------------------*/ /** @@ -320,7 +317,7 @@ int32 OS_API_Init (void); * * Typically just waits forever until "OS_shutdown" flag becomes true. */ -void OS_IdleLoop (void); +void OS_IdleLoop(void); /*-------------------------------------------------------------------------------------*/ /** @@ -330,7 +327,7 @@ void OS_IdleLoop (void); * instance of OSAL. It would typically be used during an orderly * shutdown but may also be helpful for testing purposes. */ -void OS_DeleteAllObjects (void); +void OS_DeleteAllObjects(void); /*-------------------------------------------------------------------------------------*/ /** @@ -347,7 +344,7 @@ void OS_DeleteAllObjects (void); * * @param[in] flag set to true to initiate shutdown, false to cancel */ -void OS_ApplicationShutdown (uint8 flag); +void OS_ApplicationShutdown(uint8 flag); /*-------------------------------------------------------------------------------------*/ /** @@ -454,7 +451,6 @@ static inline bool OS_ObjectIdDefined(osal_id_t object_id) return (object_id != 0); } - /*-------------------------------------------------------------------------------------*/ /** * @brief Obtain the name of an object given an arbitrary object ID @@ -484,7 +480,7 @@ int32 OS_GetResourceName(osal_id_t object_id, char *buffer, uint32 buffer_size); * @return The object type portion of the object_id, see @ref OSObjectTypes for * expected values */ -uint32 OS_IdentifyObject (osal_id_t object_id); +uint32 OS_IdentifyObject(osal_id_t object_id); /*-------------------------------------------------------------------------------------*/ /** @@ -504,13 +500,13 @@ uint32 OS_IdentifyObject (osal_id_t object_id); * @sa OS_ObjectIdToArrayIndex * * @param[in] object_id The object ID to operate on - * @param[out] *ArrayIndex The Index to return + * @param[out] *ArrayIndex The Index to return * * @return Execution status, see @ref OSReturnCodes * @retval #OS_SUCCESS @copybrief OS_SUCCESS * @retval #OS_ERR_INCORRECT_OBJ_TYPE @copybrief OS_ERR_INCORRECT_OBJ_TYPE */ -int32 OS_ConvertToArrayIndex (osal_id_t object_id, uint32 *ArrayIndex); +int32 OS_ConvertToArrayIndex(osal_id_t object_id, uint32 *ArrayIndex); /*-------------------------------------------------------------------------------------*/ /** @@ -543,8 +539,6 @@ int32 OS_ConvertToArrayIndex (osal_id_t object_id, uint32 *ArrayIndex); * */ int32 OS_ObjectIdToArrayIndex(uint32 idtype, osal_id_t object_id, uint32 *ArrayIndex); - - /*-------------------------------------------------------------------------------------*/ /** * @brief call the supplied callback function for all valid object IDs @@ -557,7 +551,7 @@ int32 OS_ObjectIdToArrayIndex(uint32 idtype, osal_id_t object_id, uint32 *ArrayI * @param[in] callback_ptr Function to invoke for each matching object ID * @param[in] callback_arg Opaque Argument to pass to callback function */ -void OS_ForEachObject (osal_id_t creator_id, OS_ArgCallback_t callback_ptr, void *callback_arg); +void OS_ForEachObject(osal_id_t creator_id, OS_ArgCallback_t callback_ptr, void *callback_arg); /*-------------------------------------------------------------------------------------*/ /** @@ -571,8 +565,8 @@ void OS_ForEachObject (osal_id_t creator_id, OS_ArgCallback_t callback * This may be passed as OS_OBJECT_CREATOR_ANY to return all objects * @param[in] callback_ptr Function to invoke for each matching object ID * @param[in] callback_arg Opaque Argument to pass to callback function - */ -void OS_ForEachObjectOfType (uint32 objtype, osal_id_t creator_id, OS_ArgCallback_t callback_ptr, void *callback_arg); + */ +void OS_ForEachObjectOfType(uint32 objtype, osal_id_t creator_id, OS_ArgCallback_t callback_ptr, void *callback_arg); /*-------------------------------------------------------------------------------------*/ /** @@ -590,11 +584,10 @@ void OS_ForEachObjectOfType (uint32 objtype, osal_id_t creator_id, OS_ArgCal * @retval #OS_SUCCESS @copybrief OS_SUCCESS * @retval #OS_ERROR @copybrief OS_ERROR */ -int32 OS_RegisterEventHandler (OS_EventHandler_t handler); +int32 OS_RegisterEventHandler(OS_EventHandler_t handler); /**@}*/ - /** @defgroup OSAPITask OSAL Task APIs * @{ */ @@ -624,11 +617,8 @@ int32 OS_RegisterEventHandler (OS_EventHandler_t handler); * @retval #OS_ERR_NAME_TAKEN if the name specified is already used by a task * @retval #OS_ERROR if an unspecified/other error occurs */ -int32 OS_TaskCreate (osal_id_t *task_id, const char *task_name, - osal_task_entry function_pointer, - uint32 *stack_pointer, - uint32 stack_size, - uint32 priority, uint32 flags); +int32 OS_TaskCreate(osal_id_t *task_id, const char *task_name, osal_task_entry function_pointer, uint32 *stack_pointer, + uint32 stack_size, uint32 priority, uint32 flags); /*-------------------------------------------------------------------------------------*/ /** @@ -644,7 +634,7 @@ int32 OS_TaskCreate (osal_id_t *task_id, const char *task_name, * @retval #OS_ERR_INVALID_ID if the ID given to it is invalid * @retval #OS_ERROR if the OS delete call fails */ -int32 OS_TaskDelete (osal_id_t task_id); +int32 OS_TaskDelete(osal_id_t task_id); /*-------------------------------------------------------------------------------------*/ /** @@ -652,7 +642,7 @@ int32 OS_TaskDelete (osal_id_t task_id); * * The calling thread is terminated. This function does not return. */ -void OS_TaskExit (void); +void OS_TaskExit(void); /*-------------------------------------------------------------------------------------*/ /** @@ -681,7 +671,7 @@ int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer); * @retval #OS_SUCCESS @copybrief OS_SUCCESS * @retval #OS_ERROR if sleep fails or millisecond = 0 */ -int32 OS_TaskDelay (uint32 millisecond); +int32 OS_TaskDelay(uint32 millisecond); /*-------------------------------------------------------------------------------------*/ /** @@ -697,7 +687,7 @@ int32 OS_TaskDelay (uint32 millisecond); * @retval #OS_ERR_INVALID_PRIORITY if the priority is greater than the max allowed * @retval #OS_ERROR if the OS call to change the priority fails */ -int32 OS_TaskSetPriority (osal_id_t task_id, uint32 new_priority); +int32 OS_TaskSetPriority(osal_id_t task_id, uint32 new_priority); /*-------------------------------------------------------------------------------------*/ /** @@ -709,7 +699,7 @@ int32 OS_TaskSetPriority (osal_id_t task_id, uint32 new_priority); * * @return #OS_SUCCESS (always), see @ref OSReturnCodes */ -int32 OS_TaskRegister (void); +int32 OS_TaskRegister(void); /*-------------------------------------------------------------------------------------*/ /** @@ -719,7 +709,7 @@ int32 OS_TaskRegister (void); * * @return Task ID, or zero if the operation failed (zero is never a valid task ID) */ -osal_id_t OS_TaskGetId (void); +osal_id_t OS_TaskGetId(void); /*-------------------------------------------------------------------------------------*/ /** @@ -736,7 +726,7 @@ osal_id_t OS_TaskGetId (void); * @retval #OS_ERR_NAME_TOO_LONG name length including null terminator greater than #OS_MAX_API_NAME * @retval #OS_ERR_NAME_NOT_FOUND if the name wasn't found in the table */ -int32 OS_TaskGetIdByName (osal_id_t *task_id, const char *task_name); +int32 OS_TaskGetIdByName(osal_id_t *task_id, const char *task_name); /*-------------------------------------------------------------------------------------*/ /** @@ -754,8 +744,7 @@ int32 OS_TaskGetIdByName (osal_id_t *task_id, const char *task_name); * @retval #OS_ERR_INVALID_ID if the ID passed to it is invalid * @retval #OS_INVALID_POINTER if the task_prop pointer is NULL */ -int32 OS_TaskGetInfo (osal_id_t task_id, OS_task_prop_t *task_prop); - +int32 OS_TaskGetInfo(osal_id_t task_id, OS_task_prop_t *task_prop); /*-------------------------------------------------------------------------------------*/ /** @@ -777,7 +766,6 @@ int32 OS_TaskGetInfo (osal_id_t task_id, OS_task_prop_t *task_prop); */ int32 OS_TaskFindIdBySystemData(osal_id_t *task_id, const void *sysdata, size_t sysdata_size); - /**@}*/ /** @defgroup OSAPIMsgQueue OSAL Message Queue APIs @@ -809,8 +797,7 @@ int32 OS_TaskFindIdBySystemData(osal_id_t *task_id, const void *sysdata, size_t * @retval #OS_QUEUE_INVALID_SIZE if the queue depth exceeds the limit * @retval #OS_ERROR if the OS create call fails */ -int32 OS_QueueCreate (osal_id_t *queue_id, const char *queue_name, - uint32 queue_depth, uint32 data_size, uint32 flags); +int32 OS_QueueCreate(osal_id_t *queue_id, const char *queue_name, uint32 queue_depth, uint32 data_size, uint32 flags); /*-------------------------------------------------------------------------------------*/ /** @@ -829,7 +816,7 @@ int32 OS_QueueCreate (osal_id_t *queue_id, const char *queue_name, * @retval #OS_ERR_INVALID_ID if the id passed in does not exist * @retval #OS_ERROR if the OS call to delete the queue fails */ -int32 OS_QueueDelete (osal_id_t queue_id); +int32 OS_QueueDelete(osal_id_t queue_id); /*-------------------------------------------------------------------------------------*/ /** @@ -852,8 +839,7 @@ int32 OS_QueueDelete (osal_id_t queue_id); * @retval #OS_QUEUE_TIMEOUT if the timeout was OS_PEND and the time expired * @retval #OS_QUEUE_INVALID_SIZE if the size copied from the queue was not correct */ -int32 OS_QueueGet (osal_id_t queue_id, void *data, uint32 size, - uint32 *size_copied, int32 timeout); +int32 OS_QueueGet(osal_id_t queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout); /*-------------------------------------------------------------------------------------*/ /** @@ -871,8 +857,7 @@ int32 OS_QueueGet (osal_id_t queue_id, void *data, uint32 size, * @retval #OS_QUEUE_FULL if the queue cannot accept another message * @retval #OS_ERROR if the OS call returns an error */ -int32 OS_QueuePut (osal_id_t queue_id, const void *data, uint32 size, - uint32 flags); +int32 OS_QueuePut(osal_id_t queue_id, const void *data, uint32 size, uint32 flags); /*-------------------------------------------------------------------------------------*/ /** @@ -890,7 +875,7 @@ int32 OS_QueuePut (osal_id_t queue_id, const void *data, uint32 siz * @retval #OS_ERR_NAME_TOO_LONG name length including null terminator greater than #OS_MAX_API_NAME * @retval #OS_ERR_NAME_NOT_FOUND the name was not found in the table */ -int32 OS_QueueGetIdByName (osal_id_t *queue_id, const char *queue_name); +int32 OS_QueueGetIdByName(osal_id_t *queue_id, const char *queue_name); /*-------------------------------------------------------------------------------------*/ /** @@ -907,7 +892,7 @@ int32 OS_QueueGetIdByName (osal_id_t *queue_id, const char *queue_name); * @retval #OS_INVALID_POINTER if queue_prop is NULL * @retval #OS_ERR_INVALID_ID if the ID given is not a valid queue */ -int32 OS_QueueGetInfo (osal_id_t queue_id, OS_queue_prop_t *queue_prop); +int32 OS_QueueGetInfo(osal_id_t queue_id, OS_queue_prop_t *queue_prop); /**@}*/ /** @defgroup OSAPISem OSAL Semaphore APIs @@ -935,8 +920,7 @@ int32 OS_QueueGetInfo (osal_id_t queue_id, OS_queue_prop_t *queue_prop) * @retval #OS_ERR_NAME_TAKEN if this is already the name of a binary semaphore * @retval #OS_SEM_FAILURE if the OS call failed */ -int32 OS_BinSemCreate (osal_id_t *sem_id, const char *sem_name, - uint32 sem_initial_value, uint32 options); +int32 OS_BinSemCreate(osal_id_t *sem_id, const char *sem_name, uint32 sem_initial_value, uint32 options); /*-------------------------------------------------------------------------------------*/ /** @@ -952,7 +936,7 @@ int32 OS_BinSemCreate (osal_id_t *sem_id, const char *sem_name, * @retval #OS_ERR_INVALID_ID if the id passed in is not a binary semaphore * @retval #OS_SEM_FAILURE if an unspecified failure occurs */ -int32 OS_BinSemFlush (osal_id_t sem_id); +int32 OS_BinSemFlush(osal_id_t sem_id); /*-------------------------------------------------------------------------------------*/ /** @@ -972,7 +956,7 @@ int32 OS_BinSemFlush (osal_id_t sem_id); * in the array of semaphores defined by the system * @retval #OS_ERR_INVALID_ID if the id passed in is not a binary semaphore */ -int32 OS_BinSemGive (osal_id_t sem_id); +int32 OS_BinSemGive(osal_id_t sem_id); /*-------------------------------------------------------------------------------------*/ /** @@ -991,7 +975,7 @@ int32 OS_BinSemGive (osal_id_t sem_id); * @retval #OS_ERR_INVALID_ID the Id passed in is not a valid binary semaphore * @retval #OS_SEM_FAILURE if the OS call failed */ -int32 OS_BinSemTake (osal_id_t sem_id); +int32 OS_BinSemTake(osal_id_t sem_id); /*-------------------------------------------------------------------------------------*/ /** @@ -1012,7 +996,7 @@ int32 OS_BinSemTake (osal_id_t sem_id); * in the array of semaphores defined by the system * @retval #OS_ERR_INVALID_ID if the ID passed in is not a valid semaphore ID */ -int32 OS_BinSemTimedWait (osal_id_t sem_id, uint32 msecs); +int32 OS_BinSemTimedWait(osal_id_t sem_id, uint32 msecs); /*-------------------------------------------------------------------------------------*/ /** @@ -1028,7 +1012,7 @@ int32 OS_BinSemTimedWait (osal_id_t sem_id, uint32 msecs); * @retval #OS_ERR_INVALID_ID if the id passed in is not a valid binary semaphore * @retval #OS_SEM_FAILURE the OS call failed */ -int32 OS_BinSemDelete (osal_id_t sem_id); +int32 OS_BinSemDelete(osal_id_t sem_id); /*-------------------------------------------------------------------------------------*/ /** @@ -1046,7 +1030,7 @@ int32 OS_BinSemDelete (osal_id_t sem_id); * @retval #OS_ERR_NAME_TOO_LONG name length including null terminator greater than #OS_MAX_API_NAME * @retval #OS_ERR_NAME_NOT_FOUND if the name was not found in the table */ -int32 OS_BinSemGetIdByName (osal_id_t *sem_id, const char *sem_name); +int32 OS_BinSemGetIdByName(osal_id_t *sem_id, const char *sem_name); /*-------------------------------------------------------------------------------------*/ /** @@ -1064,7 +1048,7 @@ int32 OS_BinSemGetIdByName (osal_id_t *sem_id, const char *sem_name); * @retval #OS_ERR_INVALID_ID if the id passed in is not a valid semaphore * @retval #OS_INVALID_POINTER if the bin_prop pointer is null */ -int32 OS_BinSemGetInfo (osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop); +int32 OS_BinSemGetInfo(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop); /*-------------------------------------------------------------------------------------*/ /** @@ -1088,8 +1072,7 @@ int32 OS_BinSemGetInfo (osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop); * @retval #OS_SEM_FAILURE if the OS call failed * @retval #OS_INVALID_SEM_VALUE if the semaphore value is too high */ -int32 OS_CountSemCreate (osal_id_t *sem_id, const char *sem_name, - uint32 sem_initial_value, uint32 options); +int32 OS_CountSemCreate(osal_id_t *sem_id, const char *sem_name, uint32 sem_initial_value, uint32 options); /*-------------------------------------------------------------------------------------*/ /** @@ -1109,7 +1092,7 @@ int32 OS_CountSemCreate (osal_id_t *sem_id, const char *sem_name, * in the array of semaphores defined by the system * @retval #OS_ERR_INVALID_ID if the id passed in is not a counting semaphore */ -int32 OS_CountSemGive (osal_id_t sem_id); +int32 OS_CountSemGive(osal_id_t sem_id); /*-------------------------------------------------------------------------------------*/ /** @@ -1128,7 +1111,7 @@ int32 OS_CountSemGive (osal_id_t sem_id); * @retval #OS_ERR_INVALID_ID the Id passed in is not a valid counting semaphore * @retval #OS_SEM_FAILURE if the OS call failed */ -int32 OS_CountSemTake (osal_id_t sem_id); +int32 OS_CountSemTake(osal_id_t sem_id); /*-------------------------------------------------------------------------------------*/ /** @@ -1149,7 +1132,7 @@ int32 OS_CountSemTake (osal_id_t sem_id); * in the array of semaphores defined by the system * @retval #OS_ERR_INVALID_ID if the ID passed in is not a valid semaphore ID */ -int32 OS_CountSemTimedWait (osal_id_t sem_id, uint32 msecs); +int32 OS_CountSemTimedWait(osal_id_t sem_id, uint32 msecs); /*-------------------------------------------------------------------------------------*/ /** @@ -1162,7 +1145,7 @@ int32 OS_CountSemTimedWait (osal_id_t sem_id, uint32 msecs); * @retval #OS_ERR_INVALID_ID if the id passed in is not a valid counting semaphore * @retval #OS_SEM_FAILURE the OS call failed */ -int32 OS_CountSemDelete (osal_id_t sem_id); +int32 OS_CountSemDelete(osal_id_t sem_id); /*-------------------------------------------------------------------------------------*/ /** @@ -1180,7 +1163,7 @@ int32 OS_CountSemDelete (osal_id_t sem_id); * @retval #OS_ERR_NAME_TOO_LONG name length including null terminator greater than #OS_MAX_API_NAME * @retval #OS_ERR_NAME_NOT_FOUND if the name was not found in the table */ -int32 OS_CountSemGetIdByName (osal_id_t *sem_id, const char *sem_name); +int32 OS_CountSemGetIdByName(osal_id_t *sem_id, const char *sem_name); /*-------------------------------------------------------------------------------------*/ /** @@ -1198,7 +1181,7 @@ int32 OS_CountSemGetIdByName (osal_id_t *sem_id, const char *sem_name); * @retval #OS_ERR_INVALID_ID if the id passed in is not a valid semaphore * @retval #OS_INVALID_POINTER if the count_prop pointer is null */ -int32 OS_CountSemGetInfo (osal_id_t sem_id, OS_count_sem_prop_t *count_prop); +int32 OS_CountSemGetInfo(osal_id_t sem_id, OS_count_sem_prop_t *count_prop); /*-------------------------------------------------------------------------------------*/ /** @@ -1218,7 +1201,7 @@ int32 OS_CountSemGetInfo (osal_id_t sem_id, OS_count_sem_prop_t *count_p * @retval #OS_ERR_NAME_TAKEN if there is already a mutex with the same name * @retval #OS_SEM_FAILURE if the OS call failed */ -int32 OS_MutSemCreate (osal_id_t *sem_id, const char *sem_name, uint32 options); +int32 OS_MutSemCreate(osal_id_t *sem_id, const char *sem_name, uint32 options); /*-------------------------------------------------------------------------------------*/ /** @@ -1236,7 +1219,7 @@ int32 OS_MutSemCreate (osal_id_t *sem_id, const char *sem_name, uint32 * @retval #OS_ERR_INVALID_ID if the id passed in is not a valid mutex * @retval #OS_SEM_FAILURE if an unspecified error occurs */ -int32 OS_MutSemGive (osal_id_t sem_id); +int32 OS_MutSemGive(osal_id_t sem_id); /*-------------------------------------------------------------------------------------*/ /** @@ -1255,7 +1238,7 @@ int32 OS_MutSemGive (osal_id_t sem_id); * not in the array of semaphores defined by the system * @retval #OS_ERR_INVALID_ID the id passed in is not a valid mutex */ -int32 OS_MutSemTake (osal_id_t sem_id); +int32 OS_MutSemTake(osal_id_t sem_id); /*-------------------------------------------------------------------------------------*/ /** @@ -1271,7 +1254,7 @@ int32 OS_MutSemTake (osal_id_t sem_id); * @retval #OS_ERR_INVALID_ID if the id passed in is not a valid mutex * @retval #OS_SEM_FAILURE if the OS call failed */ -int32 OS_MutSemDelete (osal_id_t sem_id); +int32 OS_MutSemDelete(osal_id_t sem_id); /*-------------------------------------------------------------------------------------*/ /** @@ -1289,7 +1272,7 @@ int32 OS_MutSemDelete (osal_id_t sem_id); * @retval #OS_ERR_NAME_TOO_LONG name length including null terminator greater than #OS_MAX_API_NAME * @retval #OS_ERR_NAME_NOT_FOUND if the name was not found in the table */ -int32 OS_MutSemGetIdByName (osal_id_t *sem_id, const char *sem_name); +int32 OS_MutSemGetIdByName(osal_id_t *sem_id, const char *sem_name); /*-------------------------------------------------------------------------------------*/ /** @@ -1307,7 +1290,7 @@ int32 OS_MutSemGetIdByName (osal_id_t *sem_id, const char *sem_name); * @retval #OS_ERR_INVALID_ID if the id passed in is not a valid semaphore * @retval #OS_INVALID_POINTER if the mut_prop pointer is null */ -int32 OS_MutSemGetInfo (osal_id_t sem_id, OS_mut_sem_prop_t *mut_prop); +int32 OS_MutSemGetInfo(osal_id_t sem_id, OS_mut_sem_prop_t *mut_prop); /**@}*/ /** @defgroup OSAPITime OSAL Time APIs @@ -1326,8 +1309,7 @@ int32 OS_MutSemGetInfo (osal_id_t sem_id, OS_mut_sem_prop_t *mut_prop); * * @return Get local time status, see @ref OSReturnCodes */ -int32 OS_GetLocalTime (OS_time_t *time_struct); - +int32 OS_GetLocalTime(OS_time_t *time_struct); /*-------------------------------------------------------------------------------------*/ /** @@ -1341,10 +1323,9 @@ int32 OS_GetLocalTime (OS_time_t *time_struct); * * @return Set local time status, see @ref OSReturnCodes */ -int32 OS_SetLocalTime (OS_time_t *time_struct); +int32 OS_SetLocalTime(OS_time_t *time_struct); /**@}*/ - /** @defgroup OSAPIHeap OSAL Heap APIs * @{ */ @@ -1357,7 +1338,7 @@ int32 OS_SetLocalTime (OS_time_t *time_struct); * * @return Execution status, see @ref OSReturnCodes */ -int32 OS_HeapGetInfo (OS_heap_prop_t *heap_prop); +int32 OS_HeapGetInfo(OS_heap_prop_t *heap_prop); /**@}*/ /** @defgroup OSAPIError OSAL Error Info APIs @@ -1373,7 +1354,7 @@ int32 OS_HeapGetInfo (OS_heap_prop_t *heap_prop); * * @return Execution status, see @ref OSReturnCodes */ -int32 OS_GetErrorName (int32 error_num, os_err_name_t* err_name); +int32 OS_GetErrorName(int32 error_num, os_err_name_t *err_name); /**@}*/ /** @defgroup OSAPISelect OSAL Select APIs @@ -1489,8 +1470,8 @@ bool OS_SelectFdIsSet(OS_FdSet *Set, osal_id_t objid); * Operates in a manner similar to the printf() call defined by the standard C * library and takes all the parameters and formatting options of printf. * This abstraction may implement additional buffering, if necessary, - * to improve the real-time performance of the call. - * + * to improve the real-time performance of the call. + * * Strings (including terminator) longer than #OS_BUFFER_SIZE will be truncated. * * The output of this routine also may be dynamically enabled or disabled by @@ -1498,7 +1479,7 @@ bool OS_SelectFdIsSet(OS_FdSet *Set, osal_id_t objid); * * @param[in] string Format string, followed by additional arguments */ -void OS_printf( const char *string, ...) OS_PRINTF(1,2); +void OS_printf(const char *string, ...) OS_PRINTF(1, 2); /*-------------------------------------------------------------------------------------*/ /** @@ -1514,7 +1495,6 @@ void OS_printf_disable(void); void OS_printf_enable(void); /**@}*/ - /**************************************************************************************** BSP LOW-LEVEL IMPLEMENTATION FUNCTIONS ****************************************************************************************/ @@ -1541,7 +1521,7 @@ uint32 OS_BSP_GetArgC(void); The array is sized according to OS_BSP_GetArgC() ------------------------------------------------------------------*/ -char * const * OS_BSP_GetArgV(void); +char *const *OS_BSP_GetArgV(void); /*---------------------------------------------------------------- Function: OS_BSP_SetExitCode @@ -1567,6 +1547,4 @@ char * const * OS_BSP_GetArgV(void); ------------------------------------------------------------------*/ void OS_BSP_SetExitCode(int32 code); - - #endif diff --git a/src/os/inc/osapi-os-filesys.h b/src/os/inc/osapi-os-filesys.h index 420ebd45a..36ea5a9e0 100644 --- a/src/os/inc/osapi-os-filesys.h +++ b/src/os/inc/osapi-os-filesys.h @@ -33,28 +33,28 @@ /** @defgroup OSFileAccess OSAL File Access Option Defines * @{ */ -#define OS_READ_ONLY 0 /**< Read only file access */ -#define OS_WRITE_ONLY 1 /**< Write only file access */ -#define OS_READ_WRITE 2 /**< Read write file access */ +#define OS_READ_ONLY 0 /**< Read only file access */ +#define OS_WRITE_ONLY 1 /**< Write only file access */ +#define OS_READ_WRITE 2 /**< Read write file access */ /**@}*/ /** @defgroup OSFileOffset OSAL Refernce Point For Seek Offset Defines * @{ */ -#define OS_SEEK_SET 0 /**< Seek offset set */ -#define OS_SEEK_CUR 1 /**< Seek offset current */ -#define OS_SEEK_END 2 /**< Seek offset end */ +#define OS_SEEK_SET 0 /**< Seek offset set */ +#define OS_SEEK_CUR 1 /**< Seek offset current */ +#define OS_SEEK_END 2 /**< Seek offset end */ /**@}*/ -#define OS_CHK_ONLY 0 /**< Unused, API takes bool */ -#define OS_REPAIR 1 /**< Unused, API takes bool */ +#define OS_CHK_ONLY 0 /**< Unused, API takes bool */ +#define OS_REPAIR 1 /**< Unused, API takes bool */ /* ** Length of a Device and Volume name */ -#define OS_FS_DEV_NAME_LEN 32 /**< Device name length */ -#define OS_FS_PHYS_NAME_LEN 64 /**< Physical drive name length */ -#define OS_FS_VOL_NAME_LEN 32 /**< Volume name length */ +#define OS_FS_DEV_NAME_LEN 32 /**< Device name length */ +#define OS_FS_PHYS_NAME_LEN 64 /**< Physical drive name length */ +#define OS_FS_VOL_NAME_LEN 32 /**< Volume name length */ /** * @brief Maximum length of a local/native path name string @@ -62,8 +62,7 @@ * This is a concatenation of the OSAL virtual path with the system * mount point or device name */ -#define OS_MAX_LOCAL_PATH_LEN (OS_MAX_PATH_LEN + OS_FS_PHYS_NAME_LEN) - +#define OS_MAX_LOCAL_PATH_LEN (OS_MAX_PATH_LEN + OS_FS_PHYS_NAME_LEN) /** @addtogroup OSReturnCodes * @{ @@ -76,31 +75,30 @@ * other OSAPI error codes. They now start at -100 * to avoid this overlap. */ -#define OS_FS_ERR_PATH_TOO_LONG (-103) /**< @brief FS path too long */ -#define OS_FS_ERR_NAME_TOO_LONG (-104) /**< @brief FS name too long */ -#define OS_FS_ERR_DRIVE_NOT_CREATED (-106) /**< @brief FS drive not created */ -#define OS_FS_ERR_DEVICE_NOT_FREE (-107) /**< @brief FS device not free */ -#define OS_FS_ERR_PATH_INVALID (-108) /**< @brief FS path invalid */ +#define OS_FS_ERR_PATH_TOO_LONG (-103) /**< @brief FS path too long */ +#define OS_FS_ERR_NAME_TOO_LONG (-104) /**< @brief FS name too long */ +#define OS_FS_ERR_DRIVE_NOT_CREATED (-106) /**< @brief FS drive not created */ +#define OS_FS_ERR_DEVICE_NOT_FREE (-107) /**< @brief FS device not free */ +#define OS_FS_ERR_PATH_INVALID (-108) /**< @brief FS path invalid */ /**@}*/ - /** @brief OSAL file system info */ typedef struct { - uint32 MaxFds; /**< @brief Total number of file descriptors */ - uint32 FreeFds; /**< @brief Total number that are free */ - uint32 MaxVolumes; /**< @brief Maximum number of volumes */ - uint32 FreeVolumes; /**< @brief Total number of volumes free */ + uint32 MaxFds; /**< @brief Total number of file descriptors */ + uint32 FreeFds; /**< @brief Total number that are free */ + uint32 MaxVolumes; /**< @brief Maximum number of volumes */ + uint32 FreeVolumes; /**< @brief Total number of volumes free */ } os_fsinfo_t; /** @brief OSAL file properties */ typedef struct { - char Path[OS_MAX_PATH_LEN]; + char Path[OS_MAX_PATH_LEN]; osal_id_t User; - uint8 IsValid; /* For backward compatibility -- always true if OS_FDGetInfo returned true */ -}OS_file_prop_t; + uint8 IsValid; /* For backward compatibility -- always true if OS_FDGetInfo returned true */ +} OS_file_prop_t; /** * @brief File system status @@ -112,9 +110,9 @@ typedef struct */ typedef struct { - uint32 FileModeBits; - int32 FileTime; - uint32 FileSize; + uint32 FileModeBits; + int32 FileTime; + uint32 FileSize; } os_fstat_t; /** @@ -127,31 +125,31 @@ typedef struct */ enum { - OS_FILESTAT_MODE_EXEC = 0x00001, - OS_FILESTAT_MODE_WRITE = 0x00002, - OS_FILESTAT_MODE_READ = 0x00004, - OS_FILESTAT_MODE_DIR = 0x10000 + OS_FILESTAT_MODE_EXEC = 0x00001, + OS_FILESTAT_MODE_WRITE = 0x00002, + OS_FILESTAT_MODE_READ = 0x00004, + OS_FILESTAT_MODE_DIR = 0x10000 }; /** @brief Access file stat mode bits */ -#define OS_FILESTAT_MODE(x) ((x).FileModeBits) +#define OS_FILESTAT_MODE(x) ((x).FileModeBits) /** @brief File stat is directory logical */ -#define OS_FILESTAT_ISDIR(x) ((x).FileModeBits & OS_FILESTAT_MODE_DIR) +#define OS_FILESTAT_ISDIR(x) ((x).FileModeBits & OS_FILESTAT_MODE_DIR) /** @brief File stat is executable logical */ -#define OS_FILESTAT_EXEC(x) ((x).FileModeBits & OS_FILESTAT_MODE_EXEC) +#define OS_FILESTAT_EXEC(x) ((x).FileModeBits & OS_FILESTAT_MODE_EXEC) /** @brief File stat is write enabled logical */ -#define OS_FILESTAT_WRITE(x) ((x).FileModeBits & OS_FILESTAT_MODE_WRITE) +#define OS_FILESTAT_WRITE(x) ((x).FileModeBits & OS_FILESTAT_MODE_WRITE) /** @brief File stat is read enabled logical */ -#define OS_FILESTAT_READ(x) ((x).FileModeBits & OS_FILESTAT_MODE_READ) +#define OS_FILESTAT_READ(x) ((x).FileModeBits & OS_FILESTAT_MODE_READ) /** @brief Access file stat size field */ -#define OS_FILESTAT_SIZE(x) ((x).FileSize) +#define OS_FILESTAT_SIZE(x) ((x).FileSize) /** @brief Access file stat time field */ -#define OS_FILESTAT_TIME(x) ((x).FileTime) +#define OS_FILESTAT_TIME(x) ((x).FileTime) /** @brief Directory entry */ typedef struct { - char FileName[OS_MAX_FILE_NAME]; + char FileName[OS_MAX_FILE_NAME]; } os_dirent_t; /** @@ -159,20 +157,17 @@ typedef struct */ typedef enum { - OS_FILE_FLAG_NONE, - OS_FILE_FLAG_CREATE = 0x01, - OS_FILE_FLAG_TRUNCATE = 0x02, + OS_FILE_FLAG_NONE, + OS_FILE_FLAG_CREATE = 0x01, + OS_FILE_FLAG_TRUNCATE = 0x02, } OS_file_flag_t; - - - /** @brief Access filename part of the dirent structure */ -#define OS_DIRENTRY_NAME(x) ((x).FileName) +#define OS_DIRENTRY_NAME(x) ((x).FileName) /* * Exported Functions -*/ + */ /** @defgroup OSAPIFile OSAL Standard File APIs * @{ @@ -205,8 +200,7 @@ typedef enum * @deprecated Replaced by OS_OpenCreate() with flags set to * OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE. */ -int32 OS_creat (const char *path, int32 access); - +int32 OS_creat(const char *path, int32 access); /*-------------------------------------------------------------------------------------*/ /** @@ -234,7 +228,7 @@ int32 OS_creat (const char *path, int32 access); * @deprecated Replaced by OS_OpenCreate() with flags set to * OS_FILE_FLAG_NONE. */ -int32 OS_open (const char *path, int32 access, uint32 mode); +int32 OS_open(const char *path, int32 access, uint32 mode); #endif @@ -271,8 +265,7 @@ int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 acc * @retval #OS_ERROR if file descriptor could not be closed * @retval #OS_ERR_INVALID_ID if the file descriptor passed in is invalid */ -int32 OS_close (osal_id_t filedes); - +int32 OS_close(osal_id_t filedes); /*-------------------------------------------------------------------------------------*/ /** @@ -292,8 +285,7 @@ int32 OS_close (osal_id_t filedes); * @retval #OS_ERROR if OS call failed * @retval #OS_ERR_INVALID_ID if the file descriptor passed in is invalid */ -int32 OS_read (osal_id_t filedes, void *buffer, uint32 nbytes); - +int32 OS_read(osal_id_t filedes, void *buffer, uint32 nbytes); /*-------------------------------------------------------------------------------------*/ /** @@ -314,7 +306,7 @@ int32 OS_read (osal_id_t filedes, void *buffer, uint32 nbytes); * @retval #OS_ERROR if OS call failed * @retval #OS_ERR_INVALID_ID if the file descriptor passed in is invalid */ -int32 OS_write (osal_id_t filedes, const void *buffer, uint32 nbytes); +int32 OS_write(osal_id_t filedes, const void *buffer, uint32 nbytes); /*-------------------------------------------------------------------------------------*/ /** @@ -345,8 +337,7 @@ int32 OS_write (osal_id_t filedes, const void *buffer, uint32 nbytes * @return Byte count on success, zero for timeout, or appropriate error code, * see @ref OSReturnCodes */ -int32 OS_TimedRead(osal_id_t filedes, void *buffer, uint32 nbytes, int32 timeout); - +int32 OS_TimedRead(osal_id_t filedes, void *buffer, uint32 nbytes, int32 timeout); /*-------------------------------------------------------------------------------------*/ /** @@ -377,8 +368,7 @@ int32 OS_TimedRead(osal_id_t filedes, void *buffer, uint32 nbytes, in * @return Byte count on success, zero for timeout, or appropriate error code, * see @ref OSReturnCodes */ -int32 OS_TimedWrite(osal_id_t filedes, const void *buffer, uint32 nbytes, int32 timeout); - +int32 OS_TimedWrite(osal_id_t filedes, const void *buffer, uint32 nbytes, int32 timeout); /*-------------------------------------------------------------------------------------*/ /** @@ -391,8 +381,7 @@ int32 OS_TimedWrite(osal_id_t filedes, const void *buffer, uint32 nby * * @return Execution status, see @ref OSReturnCodes */ -int32 OS_chmod (const char *path, uint32 access); - +int32 OS_chmod(const char *path, uint32 access); /*-------------------------------------------------------------------------------------*/ /** @@ -411,8 +400,7 @@ int32 OS_chmod (const char *path, uint32 access); * @retval #OS_FS_ERR_PATH_INVALID if path cannot be parsed * @retval #OS_ERROR if the OS call failed */ -int32 OS_stat (const char *path, os_fstat_t *filestats); - +int32 OS_stat(const char *path, os_fstat_t *filestats); /*-------------------------------------------------------------------------------------*/ /** @@ -429,8 +417,7 @@ int32 OS_stat (const char *path, os_fstat_t *filestats); * @retval #OS_ERR_INVALID_ID if the file descriptor passed in is invalid * @retval #OS_ERROR if OS call failed */ -int32 OS_lseek (osal_id_t filedes, int32 offset, uint32 whence); - +int32 OS_lseek(osal_id_t filedes, int32 offset, uint32 whence); /*-------------------------------------------------------------------------------------*/ /** @@ -453,8 +440,7 @@ int32 OS_lseek (osal_id_t filedes, int32 offset, uint32 whence); * @retval #OS_FS_ERR_PATH_INVALID if path cannot be parsed * @retval #OS_FS_ERR_NAME_TOO_LONG if the name of the file to remove is too long */ -int32 OS_remove (const char *path); - +int32 OS_remove(const char *path); /*-------------------------------------------------------------------------------------*/ /** @@ -479,8 +465,7 @@ int32 OS_remove (const char *path); * @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 */ -int32 OS_rename (const char *old_filename, const char *new_filename); - +int32 OS_rename(const char *old_filename, const char *new_filename); /*-------------------------------------------------------------------------------------*/ /** @@ -502,8 +487,7 @@ int32 OS_rename (const char *old_filename, const char *new_filename); * @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 dest name is too long to be stored locally */ -int32 OS_cp (const char *src, const char *dest); - +int32 OS_cp(const char *src, const char *dest); /*-------------------------------------------------------------------------------------*/ /** @@ -531,8 +515,7 @@ int32 OS_cp (const char *src, const char *dest); * @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 dest name is too long to be stored locally */ -int32 OS_mv (const char *src, const char *dest); - +int32 OS_mv(const char *src, const char *dest); /*-------------------------------------------------------------------------------------*/ /** @@ -547,7 +530,7 @@ int32 OS_mv (const char *src, const char *dest); * @retval #OS_SUCCESS @copybrief OS_SUCCESS * @retval #OS_ERR_INVALID_ID if the file descriptor passed in is invalid */ -int32 OS_FDGetInfo (osal_id_t filedes, OS_file_prop_t *fd_prop); +int32 OS_FDGetInfo(osal_id_t filedes, OS_file_prop_t *fd_prop); /*-------------------------------------------------------------------------------------*/ /** @@ -563,7 +546,6 @@ int32 OS_FDGetInfo (osal_id_t filedes, OS_file_prop_t *fd_prop); */ int32 OS_FileOpenCheck(const char *Filename); - /*-------------------------------------------------------------------------------------*/ /** * @brief Close all open files @@ -576,7 +558,6 @@ int32 OS_FileOpenCheck(const char *Filename); */ int32 OS_CloseAllFiles(void); - /*-------------------------------------------------------------------------------------*/ /** * @brief Close a file by filename @@ -610,8 +591,7 @@ int32 OS_CloseFileByName(const char *Filename); * * @return Execution status, see @ref OSReturnCodes */ -int32 OS_DirectoryOpen(osal_id_t *dir_id, const char *path); - +int32 OS_DirectoryOpen(osal_id_t *dir_id, const char *path); /*-------------------------------------------------------------------------------------*/ /** @@ -623,8 +603,7 @@ int32 OS_DirectoryOpen(osal_id_t *dir_id, const char *path); * * @return Execution status, see @ref OSReturnCodes */ -int32 OS_DirectoryClose(osal_id_t dir_id); - +int32 OS_DirectoryClose(osal_id_t dir_id); /*-------------------------------------------------------------------------------------*/ /** @@ -636,8 +615,7 @@ int32 OS_DirectoryClose(osal_id_t dir_id); * * @return Execution status, see @ref OSReturnCodes */ -int32 OS_DirectoryRewind(osal_id_t dir_id); - +int32 OS_DirectoryRewind(osal_id_t dir_id); /*-------------------------------------------------------------------------------------*/ /** @@ -650,8 +628,7 @@ int32 OS_DirectoryRewind(osal_id_t dir_id); * * @return Execution status, see @ref OSReturnCodes */ -int32 OS_DirectoryRead(osal_id_t dir_id, os_dirent_t *dirent); - +int32 OS_DirectoryRead(osal_id_t dir_id, os_dirent_t *dirent); /*-------------------------------------------------------------------------------------*/ /** @@ -673,8 +650,7 @@ int32 OS_DirectoryRead(osal_id_t dir_id, os_dirent_t *dirent); * @retval #OS_FS_ERR_PATH_INVALID if path cannot be parsed * @retval #OS_ERROR if the OS call fails */ -int32 OS_mkdir (const char *path, uint32 access); - +int32 OS_mkdir(const char *path, uint32 access); /*-------------------------------------------------------------------------------------*/ /** @@ -692,7 +668,7 @@ int32 OS_mkdir (const char *path, uint32 access); * @retval #OS_FS_ERR_PATH_TOO_LONG * @retval #OS_ERROR if the directory remove operation failed */ -int32 OS_rmdir (const char *path); +int32 OS_rmdir(const char *path); /**@}*/ /** @defgroup OSAPIFileSys OSAL File System Level APIs @@ -712,8 +688,7 @@ int32 OS_rmdir (const char *path); * * @return Execution status, see @ref OSReturnCodes */ -int32 OS_FileSysAddFixedMap(osal_id_t *filesys_id, const char *phys_path, - const char *virt_path); +int32 OS_FileSysAddFixedMap(osal_id_t *filesys_id, const char *phys_path, const char *virt_path); /*-------------------------------------------------------------------------------------*/ /** @@ -740,8 +715,7 @@ int32 OS_FileSysAddFixedMap(osal_id_t *filesys_id, const char *phys_pa * @retval #OS_FS_ERR_DEVICE_NOT_FREE if the volume table is full * @retval #OS_SUCCESS on creating the disk */ -int32 OS_mkfs (char *address, const char *devname, const char *volname, - uint32 blocksize, uint32 numblocks); +int32 OS_mkfs(char *address, const char *devname, const char *volname, uint32 blocksize, uint32 numblocks); /*-------------------------------------------------------------------------------------*/ /** * @brief Mounts a file system @@ -753,7 +727,7 @@ int32 OS_mkfs (char *address, const char *devname, const char * * * @return Execution status, see @ref OSReturnCodes */ -int32 OS_mount (const char *devname, const char *mountpoint); +int32 OS_mount(const char *devname, const char *mountpoint); /*-------------------------------------------------------------------------------------*/ /** @@ -780,8 +754,7 @@ int32 OS_mount (const char *devname, const char *mountpoint); * @retval #OS_FS_ERR_DEVICE_NOT_FREE if the volume table is full * @retval #OS_FS_ERR_DRIVE_NOT_CREATED on error */ -int32 OS_initfs (char *address, const char *devname, const char *volname, - uint32 blocksize, uint32 numblocks); +int32 OS_initfs(char *address, const char *devname, const char *volname, uint32 blocksize, uint32 numblocks); /*-------------------------------------------------------------------------------------*/ /** @@ -797,7 +770,7 @@ int32 OS_initfs (char *address, const char *devname, const char * * @retval #OS_INVALID_POINTER if devname is NULL * @retval #OS_ERROR is the drive specified cannot be located */ -int32 OS_rmfs (const char *devname); +int32 OS_rmfs(const char *devname); /*-------------------------------------------------------------------------------------*/ /** @@ -817,7 +790,7 @@ int32 OS_rmfs (const char *devname); * @retval #OS_FS_ERR_PATH_TOO_LONG if the absolute path given is too long * @retval #OS_ERROR if the OS calls failed */ -int32 OS_unmount (const char *mountpoint); +int32 OS_unmount(const char *mountpoint); /*-------------------------------------------------------------------------------------*/ /** @@ -832,7 +805,7 @@ int32 OS_unmount (const char *mountpoint); * @retval #OS_FS_ERR_PATH_TOO_LONG if the name is too long * @retval #OS_ERROR if the OS call failed */ -int32 OS_fsBlocksFree (const char *name); +int32 OS_fsBlocksFree(const char *name); /*-------------------------------------------------------------------------------------*/ /** @@ -852,7 +825,7 @@ int32 OS_fsBlocksFree (const char *name); * @retval #OS_FS_ERR_PATH_TOO_LONG if the name is too long * @retval #OS_ERROR if the OS call failed */ -int32 OS_fsBytesFree (const char *name, uint64 *bytes_free); +int32 OS_fsBytesFree(const char *name, uint64 *bytes_free); /*-------------------------------------------------------------------------------------*/ /** @@ -871,7 +844,7 @@ int32 OS_fsBytesFree (const char *name, uint64 *bytes_free); * @retval #OS_ERR_NOT_IMPLEMENTED @copybrief OS_ERR_NOT_IMPLEMENTED * @retval #OS_ERROR @copybrief OS_ERROR */ -int32 OS_chkfs (const char *name, bool repair); +int32 OS_chkfs(const char *name, bool repair); /*-------------------------------------------------------------------------------------*/ /** @@ -888,7 +861,7 @@ int32 OS_chkfs (const char *name, bool repair); * @retval #OS_INVALID_POINTER if either parameter is NULL * @retval #OS_ERROR if the mountpoint could not be found */ -int32 OS_FS_GetPhysDriveName (char * PhysDriveName, const char * MountPoint); +int32 OS_FS_GetPhysDriveName(char *PhysDriveName, const char *MountPoint); /*-------------------------------------------------------------------------------------*/ /** @@ -903,7 +876,7 @@ int32 OS_FS_GetPhysDriveName (char * PhysDriveName, const char * MountPoi * @retval #OS_SUCCESS @copybrief OS_SUCCESS * @retval #OS_INVALID_POINTER if either parameter is NULL */ -int32 OS_TranslatePath ( const char *VirtualPath, char *LocalPath); +int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath); /*-------------------------------------------------------------------------------------*/ /** @@ -918,7 +891,7 @@ int32 OS_TranslatePath ( const char *VirtualPath, char *LocalPath); * @retval #OS_SUCCESS @copybrief OS_SUCCESS * @retval #OS_INVALID_POINTER if filesys_info is NULL */ -int32 OS_GetFsInfo(os_fsinfo_t *filesys_info); +int32 OS_GetFsInfo(os_fsinfo_t *filesys_info); /**@}*/ /** @defgroup OSAPIShell OSAL Shell APIs @@ -940,10 +913,8 @@ int32 OS_GetFsInfo(os_fsinfo_t *filesys_info); * @retval #OS_ERROR if the command was not executed properly * @retval #OS_ERR_INVALID_ID if the file descriptor passed in is invalid */ -int32 OS_ShellOutputToFile(const char* Cmd, osal_id_t filedes); - +int32 OS_ShellOutputToFile(const char *Cmd, osal_id_t filedes); /**@}*/ - #endif diff --git a/src/os/inc/osapi-os-loader.h b/src/os/inc/osapi-os-loader.h index cc62fb357..811bc4cef 100644 --- a/src/os/inc/osapi-os-loader.h +++ b/src/os/inc/osapi-os-loader.h @@ -34,7 +34,6 @@ ** Defines */ - /* ** Typedefs */ @@ -42,24 +41,24 @@ /** @brief OSAL module address properties */ typedef struct { - uint32 valid; - uint32 flags; - cpuaddr code_address; - cpuaddr code_size; - cpuaddr data_address; - cpuaddr data_size; - cpuaddr bss_address; - cpuaddr bss_size; + uint32 valid; + uint32 flags; + cpuaddr code_address; + cpuaddr code_size; + cpuaddr data_address; + cpuaddr data_size; + cpuaddr bss_address; + cpuaddr bss_size; } OS_module_address_t; /** @brief OSAL module properties */ typedef struct { - cpuaddr entry_point; - cpuaddr host_module_id; - char filename[OS_MAX_PATH_LEN]; - char name[OS_MAX_API_NAME]; - OS_module_address_t addr; + cpuaddr entry_point; + cpuaddr host_module_id; + char filename[OS_MAX_PATH_LEN]; + char name[OS_MAX_API_NAME]; + OS_module_address_t addr; } OS_module_prop_t; /** @@ -77,9 +76,9 @@ typedef struct */ typedef const struct { - const char *Name; - void (*Address)(void); - const char *Module; + const char *Name; + void (*Address)(void); + const char *Module; } OS_static_symbol_record_t; /** @defgroup OSAPILoader OSAL Dynamic Loader and Symbol APIs @@ -104,7 +103,7 @@ typedef const struct * @retval #OS_ERROR if the symbol could not be found * @retval #OS_INVALID_POINTER if one of the pointers passed in are NULL */ -int32 OS_SymbolLookup (cpuaddr *symbol_address, const char *symbol_name ); +int32 OS_SymbolLookup(cpuaddr *symbol_address, const char *symbol_name); /*-------------------------------------------------------------------------------------*/ /** @@ -120,7 +119,7 @@ int32 OS_SymbolLookup (cpuaddr *symbol_address, const char *symbol_name ); * @retval #OS_ERR_NOT_IMPLEMENTED @copybrief OS_ERR_NOT_IMPLEMENTED * @retval #OS_ERROR if the symbol table could not be read or dumped */ -int32 OS_SymbolTableDump ( const char *filename, uint32 size_limit ); +int32 OS_SymbolTableDump(const char *filename, uint32 size_limit); /*-------------------------------------------------------------------------------------*/ /** @@ -139,7 +138,7 @@ int32 OS_SymbolTableDump ( const char *filename, uint32 size_limit ); * @retval #OS_ERR_NO_FREE_IDS if the module table is full * @retval #OS_ERR_NAME_TAKEN if the name is in use */ -int32 OS_ModuleLoad ( osal_id_t *module_id, const char *module_name, const char *filename ); +int32 OS_ModuleLoad(osal_id_t *module_id, const char *module_name, const char *filename); /*-------------------------------------------------------------------------------------*/ /** @@ -153,7 +152,7 @@ int32 OS_ModuleLoad ( osal_id_t *module_id, const char *module_name, const char * @retval #OS_SUCCESS @copybrief OS_SUCCESS * @retval #OS_ERROR if the module is invalid or cannot be unloaded */ -int32 OS_ModuleUnload ( osal_id_t module_id ); +int32 OS_ModuleUnload(osal_id_t module_id); /*-------------------------------------------------------------------------------------*/ /** @@ -169,7 +168,7 @@ int32 OS_ModuleUnload ( osal_id_t module_id ); * @retval #OS_ERR_INVALID_ID if the module id invalid * @retval #OS_INVALID_POINTER if the pointer to the ModuleInfo structure is invalid */ -int32 OS_ModuleInfo ( osal_id_t module_id, OS_module_prop_t *module_info ); +int32 OS_ModuleInfo(osal_id_t module_id, OS_module_prop_t *module_info); /**@}*/ #endif diff --git a/src/os/inc/osapi-os-net.h b/src/os/inc/osapi-os-net.h index 9d0647134..5a270266f 100644 --- a/src/os/inc/osapi-os-net.h +++ b/src/os/inc/osapi-os-net.h @@ -46,10 +46,9 @@ * The user may also provide a tuned value through osconfig.h */ #ifndef OS_SOCKADDR_MAX_LEN -#define OS_SOCKADDR_MAX_LEN 28 +#define OS_SOCKADDR_MAX_LEN 28 #endif - /* * -------------------------------------------------------------------------------------- * Sockets API Data Types @@ -64,19 +63,19 @@ /** @brief Socket domain */ typedef enum { - OS_SocketDomain_INVALID, /**< @brief Invalid */ - OS_SocketDomain_INET, /**< @brief IPv4 address family, most commonly used) */ - OS_SocketDomain_INET6, /**< @brief IPv6 address family, depends on OS/network stack support */ - OS_SocketDomain_MAX /**< @brief Maximum */ + OS_SocketDomain_INVALID, /**< @brief Invalid */ + OS_SocketDomain_INET, /**< @brief IPv4 address family, most commonly used) */ + OS_SocketDomain_INET6, /**< @brief IPv6 address family, depends on OS/network stack support */ + OS_SocketDomain_MAX /**< @brief Maximum */ } OS_SocketDomain_t; /** @brief Socket type */ typedef enum { - OS_SocketType_INVALID, /**< @brief Invalid */ - OS_SocketType_DATAGRAM, /**< @brief A connectionless, message-oriented socket */ - OS_SocketType_STREAM, /**< @brief A stream-oriented socket with the concept of a connection */ - OS_SocketType_MAX /**< @brief Maximum */ + OS_SocketType_INVALID, /**< @brief Invalid */ + OS_SocketType_DATAGRAM, /**< @brief A connectionless, message-oriented socket */ + OS_SocketType_STREAM, /**< @brief A stream-oriented socket with the concept of a connection */ + OS_SocketType_MAX /**< @brief Maximum */ } OS_SocketType_t; /** @@ -91,7 +90,7 @@ typedef union { uint8 Buffer[OS_SOCKADDR_MAX_LEN]; /**< @brief Ensures length of at least OS_SOCKADDR_MAX_LEN */ uint32 AlignU32; /**< @brief Ensures uint32 alignment */ - void* AlignPtr; /**< @brief Ensures pointer alignment */ + void * AlignPtr; /**< @brief Ensures pointer alignment */ } OS_SockAddrData_t; /** @@ -103,8 +102,8 @@ typedef union */ typedef struct { - uint32 ActualLength; /**< @brief Length of the actual address data */ - OS_SockAddrData_t AddrData; /**< @brief Abstract Address data */ + uint32 ActualLength; /**< @brief Length of the actual address data */ + OS_SockAddrData_t AddrData; /**< @brief Abstract Address data */ } OS_SockAddr_t; /** @@ -116,8 +115,8 @@ typedef struct */ typedef struct { - char name [OS_MAX_API_NAME]; /**< @brief Name of the socket */ - osal_id_t creator; /**< @brief OSAL TaskID which opened the socket */ + char name[OS_MAX_API_NAME]; /**< @brief Name of the socket */ + osal_id_t creator; /**< @brief OSAL TaskID which opened the socket */ } OS_socket_prop_t; /** @@ -218,7 +217,6 @@ int32 OS_SocketAddrGetPort(uint16 *PortNum, const OS_SockAddr_t *Addr); int32 OS_SocketAddrSetPort(OS_SockAddr_t *Addr, uint16 PortNum); /**@}*/ - /** * @defgroup OSALAPISocket OSAL Socket Management APIs * @@ -232,7 +230,7 @@ int32 OS_SocketAddrSetPort(OS_SockAddr_t *Addr, uint16 PortNum); * * Note that all of functions may return #OS_ERR_NOT_IMPLEMENTED if network support * is not configured at compile time. - * + * * @{ */ @@ -355,7 +353,7 @@ int32 OS_SocketSendTo(osal_id_t sock_id, const void *buffer, uint32 buflen, cons * @retval #OS_ERR_NAME_TOO_LONG name length including null terminator greater than #OS_MAX_API_NAME * @retval #OS_ERR_NAME_NOT_FOUND if the name was not found in the table */ -int32 OS_SocketGetIdByName (osal_id_t *sock_id, const char *sock_name); +int32 OS_SocketGetIdByName(osal_id_t *sock_id, const char *sock_name); /*-------------------------------------------------------------------------------------*/ /** @@ -372,8 +370,7 @@ int32 OS_SocketGetIdByName (osal_id_t *sock_id, const char *sock_name); * @retval #OS_ERR_INVALID_ID if the id passed in is not a valid semaphore * @retval #OS_INVALID_POINTER if the count_prop pointer is null */ -int32 OS_SocketGetInfo (osal_id_t sock_id, OS_socket_prop_t *sock_prop); - +int32 OS_SocketGetInfo(osal_id_t sock_id, OS_socket_prop_t *sock_prop); /*-------------------------------------------------------------------------------------*/ /** @@ -389,8 +386,7 @@ int32 OS_SocketGetInfo (osal_id_t sock_id, OS_socket_prop_t *sock_prop); * Note it is not possible to differentiate between error codes and valid * network IDs here. It is assumed, however, that -1 is never a valid ID. */ -int32 OS_NetworkGetID (void); - +int32 OS_NetworkGetID(void); /*-------------------------------------------------------------------------------------*/ /** @@ -404,7 +400,7 @@ int32 OS_NetworkGetID (void); * * @return Execution status, see @ref OSReturnCodes */ -int32 OS_NetworkGetHostName (char *host_name, uint32 name_len); +int32 OS_NetworkGetHostName(char *host_name, uint32 name_len); /**@}*/ #endif diff --git a/src/os/inc/osapi-os-timer.h b/src/os/inc/osapi-os-timer.h index 51aa708e3..8cf2a2d58 100644 --- a/src/os/inc/osapi-os-timer.h +++ b/src/os/inc/osapi-os-timer.h @@ -34,27 +34,27 @@ ** Typedefs */ typedef void (*OS_TimerCallback_t)(osal_id_t timer_id); /**< @brief Timer callback */ -typedef uint32 (*OS_TimerSync_t)(uint32 timer_id); /**< @brief Timer sync */ +typedef uint32 (*OS_TimerSync_t)(uint32 timer_id); /**< @brief Timer sync */ /** @brief Timer properties */ -typedef struct +typedef struct { - char name[OS_MAX_API_NAME]; - osal_id_t creator; - uint32 start_time; - uint32 interval_time; - uint32 accuracy; + char name[OS_MAX_API_NAME]; + osal_id_t creator; + uint32 start_time; + uint32 interval_time; + uint32 accuracy; } OS_timer_prop_t; /** @brief Time base properties */ typedef struct { - char name[OS_MAX_API_NAME]; - osal_id_t creator; - uint32 nominal_interval_time; - uint32 freerun_time; - uint32 accuracy; + char name[OS_MAX_API_NAME]; + osal_id_t creator; + uint32 nominal_interval_time; + uint32 freerun_time; + uint32 accuracy; } OS_timebase_prop_t; /** @defgroup OSAPITimer OSAL Timer APIs @@ -91,7 +91,7 @@ typedef struct * * @return Execution status, see @ref OSReturnCodes */ -int32 OS_TimeBaseCreate (osal_id_t *timebase_id, const char *timebase_name, OS_TimerSync_t external_sync); +int32 OS_TimeBaseCreate(osal_id_t *timebase_id, const char *timebase_name, OS_TimerSync_t external_sync); /*-------------------------------------------------------------------------------------*/ /** @@ -113,7 +113,7 @@ int32 OS_TimeBaseCreate (osal_id_t *timebase_id, const char *timebase_na * * @return Execution status, see @ref OSReturnCodes */ -int32 OS_TimeBaseSet (osal_id_t timebase_id, uint32 start_time, uint32 interval_time); +int32 OS_TimeBaseSet(osal_id_t timebase_id, uint32 start_time, uint32 interval_time); /*-------------------------------------------------------------------------------------*/ /** @@ -126,7 +126,7 @@ int32 OS_TimeBaseSet (osal_id_t timebase_id, uint32 start_time, uint3 * * @return Execution status, see @ref OSReturnCodes */ -int32 OS_TimeBaseDelete (osal_id_t timebase_id); +int32 OS_TimeBaseDelete(osal_id_t timebase_id); /*-------------------------------------------------------------------------------------*/ /** @@ -143,7 +143,7 @@ int32 OS_TimeBaseDelete (osal_id_t timebase_id); * @retval #OS_ERR_NAME_TOO_LONG name length including null terminator greater than #OS_MAX_API_NAME * @retval #OS_ERR_NAME_NOT_FOUND if the name was not found in the table */ -int32 OS_TimeBaseGetIdByName (osal_id_t *timebase_id, const char *timebase_name); +int32 OS_TimeBaseGetIdByName(osal_id_t *timebase_id, const char *timebase_name); /*-------------------------------------------------------------------------------------*/ /** @@ -163,7 +163,7 @@ int32 OS_TimeBaseGetIdByName (osal_id_t *timebase_id, const char *timebase_na * @retval #OS_ERR_INVALID_ID if the id passed in is not a valid timebase * @retval #OS_INVALID_POINTER if the timebase_prop pointer is null */ -int32 OS_TimeBaseGetInfo (osal_id_t timebase_id, OS_timebase_prop_t *timebase_prop); +int32 OS_TimeBaseGetInfo(osal_id_t timebase_id, OS_timebase_prop_t *timebase_prop); /*-------------------------------------------------------------------------------------*/ /** @@ -195,7 +195,7 @@ int32 OS_TimeBaseGetInfo (osal_id_t timebase_id, OS_timebase_prop_t *time * @retval #OS_SUCCESS @copybrief OS_SUCCESS * @retval #OS_ERR_INVALID_ID if the id passed in is not a valid timebase */ -int32 OS_TimeBaseGetFreeRun (osal_id_t timebase_id, uint32 *freerun_val); +int32 OS_TimeBaseGetFreeRun(osal_id_t timebase_id, uint32 *freerun_val); /*-------------------------------------------------------------------------------------*/ /** @@ -234,7 +234,8 @@ int32 OS_TimeBaseGetFreeRun (osal_id_t timebase_id, uint32 *freerun_val); * @retval #OS_TIMER_ERR_INVALID_ARGS if the callback pointer is zero. * @retval #OS_TIMER_ERR_UNAVAILABLE if the timer cannot be created. */ -int32 OS_TimerCreate (osal_id_t *timer_id, const char *timer_name, uint32 *clock_accuracy, OS_TimerCallback_t callback_ptr); +int32 OS_TimerCreate(osal_id_t *timer_id, const char *timer_name, uint32 *clock_accuracy, + OS_TimerCallback_t callback_ptr); /*-------------------------------------------------------------------------------------*/ /** @@ -264,7 +265,8 @@ int32 OS_TimerCreate (osal_id_t *timer_id, const char *timer_name, ui * * @return Execution status, see @ref OSReturnCodes */ -int32 OS_TimerAdd (osal_id_t *timer_id, const char *timer_name, osal_id_t timebase_id, OS_ArgCallback_t callback_ptr, void *callback_arg); +int32 OS_TimerAdd(osal_id_t *timer_id, const char *timer_name, osal_id_t timebase_id, OS_ArgCallback_t callback_ptr, + void *callback_arg); /*-------------------------------------------------------------------------------------*/ /** @@ -295,9 +297,9 @@ int32 OS_TimerAdd (osal_id_t *timer_id, const char *timer_name, os * @retval #OS_SUCCESS @copybrief OS_SUCCESS * @retval #OS_ERR_INVALID_ID if the timer_id is not valid. * @retval #OS_TIMER_ERR_INTERNAL if there was an error programming the OS timer. - * @retval #OS_ERROR if both start time and interval time are zero. + * @retval #OS_ERROR if both start time and interval time are zero. */ -int32 OS_TimerSet (osal_id_t timer_id, uint32 start_time, uint32 interval_time); +int32 OS_TimerSet(osal_id_t timer_id, uint32 start_time, uint32 interval_time); /*-------------------------------------------------------------------------------------*/ /** @@ -313,7 +315,7 @@ int32 OS_TimerSet (osal_id_t timer_id, uint32 start_time, uint32 i * @retval #OS_ERR_INVALID_ID if the timer_id is invalid. * @retval #OS_TIMER_ERR_INTERNAL if there was a problem deleting the timer in the host OS. */ -int32 OS_TimerDelete (osal_id_t timer_id); +int32 OS_TimerDelete(osal_id_t timer_id); /*-------------------------------------------------------------------------------------*/ /** @@ -330,8 +332,7 @@ int32 OS_TimerDelete (osal_id_t timer_id); * @retval #OS_ERR_NAME_TOO_LONG name length including null terminator greater than #OS_MAX_API_NAME * @retval #OS_ERR_NAME_NOT_FOUND if the name was not found in the table */ -int32 OS_TimerGetIdByName (osal_id_t *timer_id, const char *timer_name); - +int32 OS_TimerGetIdByName(osal_id_t *timer_id, const char *timer_name); /*-------------------------------------------------------------------------------------*/ /** @@ -353,7 +354,7 @@ int32 OS_TimerGetIdByName (osal_id_t *timer_id, const char *timer_name); * @retval #OS_ERR_INVALID_ID if the id passed in is not a valid timer * @retval #OS_INVALID_POINTER if the timer_prop pointer is null */ -int32 OS_TimerGetInfo (osal_id_t timer_id, OS_timer_prop_t *timer_prop); +int32 OS_TimerGetInfo(osal_id_t timer_id, OS_timer_prop_t *timer_prop); /**@}*/ #endif diff --git a/src/os/inc/osapi-version.h b/src/os/inc/osapi-version.h index 4484223d3..26adec058 100644 --- a/src/os/inc/osapi-version.h +++ b/src/os/inc/osapi-version.h @@ -18,19 +18,19 @@ * limitations under the License. */ - /*! @file osapi-version.h - * @brief Purpose: - * @details Provide version identifiers for cFS' Operating System Abstraction Layer - * See @ref cfsversions for version and build number and description - * - */ +/*! @file osapi-version.h + * @brief Purpose: + * @details Provide version identifiers for cFS' Operating System Abstraction Layer + * See @ref cfsversions for version and build number and description + * + */ #ifndef _osapi_version_h_ #define _osapi_version_h_ /* * Development Build Macro Definitions */ -#define OS_BUILD_NUMBER 55 +#define OS_BUILD_NUMBER 60 #define OS_BUILD_BASELINE "v5.1.0-rc1" /* @@ -38,25 +38,27 @@ */ #define OS_MAJOR_VERSION 5 /*!< @brief ONLY APPLY for OFFICIAL releases. Major version number. */ #define OS_MINOR_VERSION 0 /*!< @brief ONLY APPLY for OFFICIAL releases. Minor version number. */ -#define OS_REVISION 99/*!< @brief ONLY APPLY for OFFICIAL releases. Revision version number. If set to "99" it indicates a development version. */ -#define OS_MISSION_REV 0 /*!< @brief ONLY USED by MISSION Implementations. Mission revision */ +#define OS_REVISION \ + 99 /*!< @brief ONLY APPLY for OFFICIAL releases. Revision version number. If set to "99" it indicates a \ + development version. */ +#define OS_MISSION_REV 0 /*!< @brief ONLY USED by MISSION Implementations. Mission revision */ /* * Tools to construct version string */ -#define OS_STR_HELPER(x) #x /*!< @brief Helper function to concatenate strings from integer */ +#define OS_STR_HELPER(x) #x /*!< @brief Helper function to concatenate strings from integer */ #define OS_STR(x) OS_STR_HELPER(x) /*!< @brief Helper function to concatenate strings from integer */ /*! @brief Development Build Version Number. * @details Baseline git tag + Number of commits since baseline. @n * See @ref cfsversions for format differences between development and release versions. */ -#define OS_VERSION OS_BUILD_BASELINE "+dev" OS_STR(OS_BUILD_NUMBER) +#define OS_VERSION OS_BUILD_BASELINE "+dev" OS_STR(OS_BUILD_NUMBER) /*! @brief Development Build Version String. - * @details Reports the current development build's baseline, number, and name. Also includes a note about the latest official version. @n - * See @ref cfsversions for format differences between development and release versions. -*/ + * @details Reports the current development build's baseline, number, and name. Also includes a note about the latest + * official version. @n See @ref cfsversions for format differences between development and release versions. + */ #define OS_VERSION_STRING \ " OSAL Development Build\n" \ " " OS_VERSION " (Codename: Bootes)\n" /* Codename for current development */ \ diff --git a/src/os/inc/osapi.h b/src/os/inc/osapi.h index e21e201dd..46ac687a0 100644 --- a/src/os/inc/osapi.h +++ b/src/os/inc/osapi.h @@ -50,7 +50,8 @@ #include "common_types.h" #ifdef __cplusplus - extern "C" { +extern "C" +{ #endif /** @defgroup OSReturnCodes OSAL Return Code Defines @@ -88,14 +89,15 @@ #define OS_ERR_INCORRECT_OBJ_STATE (-35) /**< @brief Incorrect object state */ #define OS_ERR_INCORRECT_OBJ_TYPE (-36) /**< @brief Incorrect object type */ #define OS_ERR_STREAM_DISCONNECTED (-37) /**< @brief Stream disconnected */ -#define OS_ERR_OPERATION_NOT_SUPPORTED (-38) /**< @brief Requested operation is not support on the supplied object(s) */ +#define OS_ERR_OPERATION_NOT_SUPPORTED (-38) /**< @brief Requested operation is not support on the supplied object(s) \ + */ /**@}*/ /* ** Defines for Queue Timeout parameters */ -#define OS_PEND (-1) -#define OS_CHECK (0) +#define OS_PEND (-1) +#define OS_CHECK (0) #include "osapi-version.h" @@ -113,16 +115,15 @@ #include "osapi-os-loader.h" #include "osapi-os-timer.h" -/* - ****************************************************************************** - * Items below here are internal OSAL-use definitions and are not part of the - * OSAL API - ***************************************************************************** - */ + /* + ****************************************************************************** + * Items below here are internal OSAL-use definitions and are not part of the + * OSAL API + ***************************************************************************** + */ #ifdef __cplusplus - } +} #endif #endif - diff --git a/src/os/portable/os-impl-bsd-select.c b/src/os/portable/os-impl-bsd-select.c index 136600c3e..67ae82bed 100644 --- a/src/os/portable/os-impl-bsd-select.c +++ b/src/os/portable/os-impl-bsd-select.c @@ -74,39 +74,39 @@ *-----------------------------------------------------------------*/ static int OS_FdSet_ConvertIn_Impl(fd_set *os_set, OS_FdSet *OSAL_set) { - uint32 offset; - uint32 bit; - uint32 id; - uint8 objids; - int osfd; - int maxfd; - - maxfd = -1; - for (offset = 0; offset < sizeof(OSAL_set->object_ids); ++offset) - { - objids = OSAL_set->object_ids[offset]; - bit = 0; - while (objids != 0) - { - if (objids & 0x01) - { - id = (offset * 8) + bit; - osfd = OS_impl_filehandle_table[id].fd; - if (osfd >= 0 && OS_impl_filehandle_table[id].selectable) + uint32 offset; + uint32 bit; + uint32 id; + uint8 objids; + int osfd; + int maxfd; + + maxfd = -1; + for (offset = 0; offset < sizeof(OSAL_set->object_ids); ++offset) + { + objids = OSAL_set->object_ids[offset]; + bit = 0; + while (objids != 0) + { + if (objids & 0x01) { - FD_SET(osfd, os_set); - if (osfd > maxfd) - { - maxfd = osfd; - } + id = (offset * 8) + bit; + osfd = OS_impl_filehandle_table[id].fd; + if (osfd >= 0 && OS_impl_filehandle_table[id].selectable) + { + FD_SET(osfd, os_set); + if (osfd > maxfd) + { + maxfd = osfd; + } + } } - } - ++bit; - objids >>= 1; - } - } + ++bit; + objids >>= 1; + } + } - return maxfd; + return maxfd; } /* end OS_FdSet_ConvertIn_Impl */ /*---------------------------------------------------------------- @@ -122,31 +122,31 @@ static int OS_FdSet_ConvertIn_Impl(fd_set *os_set, OS_FdSet *OSAL_set) *-----------------------------------------------------------------*/ static void OS_FdSet_ConvertOut_Impl(fd_set *output, OS_FdSet *Input) { - uint32 offset; - uint32 bit; - uint32 id; - uint8 objids; - int osfd; - - for (offset = 0; offset < sizeof(Input->object_ids); ++offset) - { - objids = Input->object_ids[offset]; - bit = 0; - while (objids != 0) - { - if (objids & 0x01) - { - id = (offset * 8) + bit; - osfd = OS_impl_filehandle_table[id].fd; - if (osfd < 0 || !FD_ISSET(osfd, output)) + uint32 offset; + uint32 bit; + uint32 id; + uint8 objids; + int osfd; + + for (offset = 0; offset < sizeof(Input->object_ids); ++offset) + { + objids = Input->object_ids[offset]; + bit = 0; + while (objids != 0) + { + if (objids & 0x01) { - Input->object_ids[offset] &= ~(1 << bit); + id = (offset * 8) + bit; + osfd = OS_impl_filehandle_table[id].fd; + if (osfd < 0 || !FD_ISSET(osfd, output)) + { + Input->object_ids[offset] &= ~(1 << bit); + } } - } - ++bit; - objids >>= 1; - } - } + ++bit; + objids >>= 1; + } + } } /* end OS_FdSet_ConvertOut_Impl */ /*---------------------------------------------------------------- @@ -159,90 +159,88 @@ static void OS_FdSet_ConvertOut_Impl(fd_set *output, OS_FdSet *Input) *-----------------------------------------------------------------*/ static int32 OS_DoSelect(int maxfd, fd_set *rd_set, fd_set *wr_set, int32 msecs) { - int os_status; - int32 return_code; - struct timeval tv; - struct timeval *tvptr; - struct timespec ts_now; - struct timespec ts_end; - - if (msecs > 0) - { - clock_gettime(CLOCK_MONOTONIC, &ts_now); - ts_end.tv_sec = ts_now.tv_sec + (msecs / 1000); - ts_end.tv_nsec = ts_now.tv_nsec + (1000000 * (msecs % 1000)); - if (ts_end.tv_nsec >= 1000000000) - { - ++ts_end.tv_sec; - ts_end.tv_nsec -= 1000000000; - } - } - else - { - /* eliminates a false warning about possibly uninitialized use */ - memset(&ts_end,0,sizeof(ts_end)); - } - - do - { - if (msecs < 0) - { - tvptr = NULL; - } - else if (msecs == 0) - { - tvptr = &tv; - tv.tv_sec = 0; - tv.tv_usec = 0; - } - else - { - tvptr = &tv; - - clock_gettime(CLOCK_MONOTONIC, &ts_now); - - /* note that the tv_sec and tv_usec/tv_nsec values are all signed longs, so OK to subtract */ - tv.tv_sec = ts_end.tv_sec - ts_now.tv_sec; - tv.tv_usec = (ts_end.tv_nsec - ts_now.tv_nsec) / 1000; - - if (tv.tv_sec < 0 || (tv.tv_sec == 0 && tv.tv_usec < 0)) - { - os_status = 0; - break; - } - - if (tv.tv_usec < 0) - { - tv.tv_usec += 1000000; - ++tv.tv_sec; - } - } - - os_status = select(maxfd + 1, rd_set, wr_set, NULL, tvptr); - } - while (os_status < 0 && errno == EINTR); - - if (os_status < 0) - { - return_code = OS_ERROR; - } - else if (os_status == 0) - { - return_code = OS_ERROR_TIMEOUT; - } - else - { - return_code = OS_SUCCESS; - } - - return return_code; + int os_status; + int32 return_code; + struct timeval tv; + struct timeval *tvptr; + struct timespec ts_now; + struct timespec ts_end; + + if (msecs > 0) + { + clock_gettime(CLOCK_MONOTONIC, &ts_now); + ts_end.tv_sec = ts_now.tv_sec + (msecs / 1000); + ts_end.tv_nsec = ts_now.tv_nsec + (1000000 * (msecs % 1000)); + if (ts_end.tv_nsec >= 1000000000) + { + ++ts_end.tv_sec; + ts_end.tv_nsec -= 1000000000; + } + } + else + { + /* eliminates a false warning about possibly uninitialized use */ + memset(&ts_end, 0, sizeof(ts_end)); + } + + do + { + if (msecs < 0) + { + tvptr = NULL; + } + else if (msecs == 0) + { + tvptr = &tv; + tv.tv_sec = 0; + tv.tv_usec = 0; + } + else + { + tvptr = &tv; + + clock_gettime(CLOCK_MONOTONIC, &ts_now); + + /* note that the tv_sec and tv_usec/tv_nsec values are all signed longs, so OK to subtract */ + tv.tv_sec = ts_end.tv_sec - ts_now.tv_sec; + tv.tv_usec = (ts_end.tv_nsec - ts_now.tv_nsec) / 1000; + + if (tv.tv_sec < 0 || (tv.tv_sec == 0 && tv.tv_usec < 0)) + { + os_status = 0; + break; + } + + if (tv.tv_usec < 0) + { + tv.tv_usec += 1000000; + ++tv.tv_sec; + } + } + + os_status = select(maxfd + 1, rd_set, wr_set, NULL, tvptr); + } while (os_status < 0 && errno == EINTR); + + if (os_status < 0) + { + return_code = OS_ERROR; + } + else if (os_status == 0) + { + return_code = OS_ERROR_TIMEOUT; + } + else + { + return_code = OS_SUCCESS; + } + + return return_code; } /* end OS_DoSelect */ /**************************************************************************************** SELECT API ***************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_SelectSingle_Impl @@ -253,60 +251,59 @@ static int32 OS_DoSelect(int maxfd, fd_set *rd_set, fd_set *wr_set, int32 msecs) *-----------------------------------------------------------------*/ int32 OS_SelectSingle_Impl(uint32 stream_id, uint32 *SelectFlags, int32 msecs) { - int32 return_code; - fd_set wr_set; - fd_set rd_set; - - /* - * If called on a stream_id which does not support this - * operation, return immediately and do not invoke the system call - */ - if (!OS_impl_filehandle_table[stream_id].selectable) - { - return OS_ERR_OPERATION_NOT_SUPPORTED; - } - - if (*SelectFlags != 0) - { - FD_ZERO(&wr_set); - FD_ZERO(&rd_set); - if (*SelectFlags & OS_STREAM_STATE_READABLE) - { - FD_SET(OS_impl_filehandle_table[stream_id].fd, &rd_set); - } - if (*SelectFlags & OS_STREAM_STATE_WRITABLE) - { - FD_SET(OS_impl_filehandle_table[stream_id].fd, &wr_set); - } - - return_code = OS_DoSelect(OS_impl_filehandle_table[stream_id].fd, &rd_set, &wr_set, msecs); - - if (return_code == OS_SUCCESS) - { - if (!FD_ISSET(OS_impl_filehandle_table[stream_id].fd, &rd_set)) - { - *SelectFlags &= ~OS_STREAM_STATE_READABLE; - } - if (!FD_ISSET(OS_impl_filehandle_table[stream_id].fd, &wr_set)) - { - *SelectFlags &= ~OS_STREAM_STATE_WRITABLE; - } - } - else - { - *SelectFlags = 0; - } - } - else - { - /* Nothing to check for, return immediately. */ - return_code = OS_SUCCESS; - } - - return return_code; + int32 return_code; + fd_set wr_set; + fd_set rd_set; + + /* + * If called on a stream_id which does not support this + * operation, return immediately and do not invoke the system call + */ + if (!OS_impl_filehandle_table[stream_id].selectable) + { + return OS_ERR_OPERATION_NOT_SUPPORTED; + } + + if (*SelectFlags != 0) + { + FD_ZERO(&wr_set); + FD_ZERO(&rd_set); + if (*SelectFlags & OS_STREAM_STATE_READABLE) + { + FD_SET(OS_impl_filehandle_table[stream_id].fd, &rd_set); + } + if (*SelectFlags & OS_STREAM_STATE_WRITABLE) + { + FD_SET(OS_impl_filehandle_table[stream_id].fd, &wr_set); + } + + return_code = OS_DoSelect(OS_impl_filehandle_table[stream_id].fd, &rd_set, &wr_set, msecs); + + if (return_code == OS_SUCCESS) + { + if (!FD_ISSET(OS_impl_filehandle_table[stream_id].fd, &rd_set)) + { + *SelectFlags &= ~OS_STREAM_STATE_READABLE; + } + if (!FD_ISSET(OS_impl_filehandle_table[stream_id].fd, &wr_set)) + { + *SelectFlags &= ~OS_STREAM_STATE_WRITABLE; + } + } + else + { + *SelectFlags = 0; + } + } + else + { + /* Nothing to check for, return immediately. */ + return_code = OS_SUCCESS; + } + + return return_code; } /* end OS_SelectSingle_Impl */ - /*---------------------------------------------------------------- * * Function: OS_SelectMultiple_Impl @@ -317,59 +314,55 @@ int32 OS_SelectSingle_Impl(uint32 stream_id, uint32 *SelectFlags, int32 msecs) *-----------------------------------------------------------------*/ int32 OS_SelectMultiple_Impl(OS_FdSet *ReadSet, OS_FdSet *WriteSet, int32 msecs) { - fd_set wr_set; - fd_set rd_set; - int osfd; - int maxfd; - int32 return_code; - - /* - * This return code will be used if the set(s) do not - * contain any file handles capable of select(). It - * will be overwritten with the real result of the - * select call, if selectable file handles were specified. - */ - return_code = OS_ERR_OPERATION_NOT_SUPPORTED; - FD_ZERO(&rd_set); - FD_ZERO(&wr_set); - maxfd = -1; - if (ReadSet != NULL) - { - osfd = OS_FdSet_ConvertIn_Impl(&rd_set, ReadSet); - if (osfd > maxfd) - { - maxfd = osfd; - } - } - if (WriteSet != NULL) - { - osfd = OS_FdSet_ConvertIn_Impl(&wr_set, WriteSet); - if (osfd > maxfd) - { - maxfd = osfd; - } - } - - if (maxfd >= 0) - { - return_code = OS_DoSelect(maxfd, &rd_set, &wr_set, msecs); - } - - if (return_code == OS_SUCCESS) - { - if (ReadSet != NULL) - { - OS_FdSet_ConvertOut_Impl(&rd_set, ReadSet); - } - if (WriteSet != NULL) - { - OS_FdSet_ConvertOut_Impl(&wr_set, WriteSet); - } - } - - return return_code; + fd_set wr_set; + fd_set rd_set; + int osfd; + int maxfd; + int32 return_code; + + /* + * This return code will be used if the set(s) do not + * contain any file handles capable of select(). It + * will be overwritten with the real result of the + * select call, if selectable file handles were specified. + */ + return_code = OS_ERR_OPERATION_NOT_SUPPORTED; + FD_ZERO(&rd_set); + FD_ZERO(&wr_set); + maxfd = -1; + if (ReadSet != NULL) + { + osfd = OS_FdSet_ConvertIn_Impl(&rd_set, ReadSet); + if (osfd > maxfd) + { + maxfd = osfd; + } + } + if (WriteSet != NULL) + { + osfd = OS_FdSet_ConvertIn_Impl(&wr_set, WriteSet); + if (osfd > maxfd) + { + maxfd = osfd; + } + } + + if (maxfd >= 0) + { + return_code = OS_DoSelect(maxfd, &rd_set, &wr_set, msecs); + } + + if (return_code == OS_SUCCESS) + { + if (ReadSet != NULL) + { + OS_FdSet_ConvertOut_Impl(&rd_set, ReadSet); + } + if (WriteSet != NULL) + { + OS_FdSet_ConvertOut_Impl(&wr_set, WriteSet); + } + } + + return return_code; } /* end OS_SelectMultiple_Impl */ - - - - diff --git a/src/os/portable/os-impl-bsd-sockets.c b/src/os/portable/os-impl-bsd-sockets.c index d7eb1b586..efac29de9 100644 --- a/src/os/portable/os-impl-bsd-sockets.c +++ b/src/os/portable/os-impl-bsd-sockets.c @@ -64,20 +64,18 @@ typedef union { - char data[OS_SOCKADDR_MAX_LEN]; - struct sockaddr sockaddr; - struct sockaddr_in sockaddr_in; + char data[OS_SOCKADDR_MAX_LEN]; + struct sockaddr sockaddr; + struct sockaddr_in sockaddr_in; #ifdef OS_NETWORK_SUPPORTS_IPV6 - struct sockaddr_in6 sockaddr_in6; + struct sockaddr_in6 sockaddr_in6; #endif } OS_SockAddr_Accessor_t; - /**************************************************************************************** Sockets API ***************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_SocketOpen_Impl @@ -88,89 +86,87 @@ typedef union *-----------------------------------------------------------------*/ int32 OS_SocketOpen_Impl(uint32 sock_id) { - int os_domain; - int os_type; - int os_proto; - int os_flags; - - os_proto = 0; - - switch(OS_stream_table[sock_id].socket_type) - { - case OS_SocketType_DATAGRAM: - os_type = SOCK_DGRAM; - break; - case OS_SocketType_STREAM: - os_type = SOCK_STREAM; - break; - - default: - return OS_ERR_NOT_IMPLEMENTED; - } - - switch(OS_stream_table[sock_id].socket_domain) - { - case OS_SocketDomain_INET: - os_domain = AF_INET; - break; + int os_domain; + int os_type; + int os_proto; + int os_flags; + + os_proto = 0; + + switch (OS_stream_table[sock_id].socket_type) + { + case OS_SocketType_DATAGRAM: + os_type = SOCK_DGRAM; + break; + case OS_SocketType_STREAM: + os_type = SOCK_STREAM; + break; + + default: + return OS_ERR_NOT_IMPLEMENTED; + } + + switch (OS_stream_table[sock_id].socket_domain) + { + case OS_SocketDomain_INET: + os_domain = AF_INET; + break; #ifdef OS_NETWORK_SUPPORTS_IPV6 - case OS_SocketDomain_INET6: - os_domain = AF_INET6; - break; + case OS_SocketDomain_INET6: + os_domain = AF_INET6; + break; #endif - default: - return OS_ERR_NOT_IMPLEMENTED; - } - - switch(OS_stream_table[sock_id].socket_domain) - { - case OS_SocketDomain_INET: - case OS_SocketDomain_INET6: - switch(OS_stream_table[sock_id].socket_type) - { - case OS_SocketType_DATAGRAM: - os_proto = IPPROTO_UDP; - break; - case OS_SocketType_STREAM: - os_proto = IPPROTO_TCP; - break; - default: - break; - } - break; - default: - break; - } - - OS_impl_filehandle_table[sock_id].fd = socket(os_domain, os_type, os_proto); - if (OS_impl_filehandle_table[sock_id].fd < 0) - { - return OS_ERROR; - } - - /* - * Setting the REUSEADDR flag helps during debugging when there might be frequent - * code restarts. However if setting the option fails then it is not worth bailing out over. - */ - os_flags = 1; - setsockopt(OS_impl_filehandle_table[sock_id].fd,SOL_SOCKET,SO_REUSEADDR,&os_flags,sizeof(os_flags)); - - /* - * Set the standard options on the filehandle by default -- - * this may set it to non-blocking mode if the implementation supports it. - * any blocking would be done explicitly via the select() wrappers - */ - os_flags = fcntl(OS_impl_filehandle_table[sock_id].fd, F_GETFL); - os_flags |= OS_IMPL_SOCKET_FLAGS; - fcntl(OS_impl_filehandle_table[sock_id].fd, F_SETFL, os_flags); - - OS_impl_filehandle_table[sock_id].selectable = - ((os_flags & O_NONBLOCK) != 0); - - return OS_SUCCESS; + default: + return OS_ERR_NOT_IMPLEMENTED; + } + + switch (OS_stream_table[sock_id].socket_domain) + { + case OS_SocketDomain_INET: + case OS_SocketDomain_INET6: + switch (OS_stream_table[sock_id].socket_type) + { + case OS_SocketType_DATAGRAM: + os_proto = IPPROTO_UDP; + break; + case OS_SocketType_STREAM: + os_proto = IPPROTO_TCP; + break; + default: + break; + } + break; + default: + break; + } + + OS_impl_filehandle_table[sock_id].fd = socket(os_domain, os_type, os_proto); + if (OS_impl_filehandle_table[sock_id].fd < 0) + { + return OS_ERROR; + } + + /* + * Setting the REUSEADDR flag helps during debugging when there might be frequent + * code restarts. However if setting the option fails then it is not worth bailing out over. + */ + os_flags = 1; + setsockopt(OS_impl_filehandle_table[sock_id].fd, SOL_SOCKET, SO_REUSEADDR, &os_flags, sizeof(os_flags)); + + /* + * Set the standard options on the filehandle by default -- + * this may set it to non-blocking mode if the implementation supports it. + * any blocking would be done explicitly via the select() wrappers + */ + os_flags = fcntl(OS_impl_filehandle_table[sock_id].fd, F_GETFL); + os_flags |= OS_IMPL_SOCKET_FLAGS; + fcntl(OS_impl_filehandle_table[sock_id].fd, F_SETFL, os_flags); + + OS_impl_filehandle_table[sock_id].selectable = ((os_flags & O_NONBLOCK) != 0); + + return OS_SUCCESS; } /* end OS_SocketOpen_Impl */ - /*---------------------------------------------------------------- * * Function: OS_SocketBind_Impl @@ -181,53 +177,52 @@ int32 OS_SocketOpen_Impl(uint32 sock_id) *-----------------------------------------------------------------*/ int32 OS_SocketBind_Impl(uint32 sock_id, const OS_SockAddr_t *Addr) { - int os_result; - socklen_t addrlen; - const struct sockaddr *sa; + int os_result; + socklen_t addrlen; + const struct sockaddr *sa; - sa = (const struct sockaddr *)&Addr->AddrData; + sa = (const struct sockaddr *)&Addr->AddrData; - switch(sa->sa_family) - { - case AF_INET: - addrlen = sizeof(struct sockaddr_in); - break; + switch (sa->sa_family) + { + case AF_INET: + addrlen = sizeof(struct sockaddr_in); + break; #ifdef OS_NETWORK_SUPPORTS_IPV6 - case AF_INET6: - addrlen = sizeof(struct sockaddr_in6); - break; + case AF_INET6: + addrlen = sizeof(struct sockaddr_in6); + break; #endif - default: - addrlen = 0; - break; - } - - if (addrlen == 0 || addrlen > OS_SOCKADDR_MAX_LEN) - { - return OS_ERR_BAD_ADDRESS; - } - - os_result = bind(OS_impl_filehandle_table[sock_id].fd, sa, addrlen); - if (os_result < 0) - { - OS_DEBUG("bind: %s\n",strerror(errno)); - return OS_ERROR; - } - - /* Start listening on the socket (implied for stream sockets) */ - if (OS_stream_table[sock_id].socket_type == OS_SocketType_STREAM) - { - os_result = listen(OS_impl_filehandle_table[sock_id].fd, 10); - if (os_result < 0) - { - OS_DEBUG("listen: %s\n",strerror(errno)); - return OS_ERROR; - } - } - return OS_SUCCESS; + default: + addrlen = 0; + break; + } + + if (addrlen == 0 || addrlen > OS_SOCKADDR_MAX_LEN) + { + return OS_ERR_BAD_ADDRESS; + } + + os_result = bind(OS_impl_filehandle_table[sock_id].fd, sa, addrlen); + if (os_result < 0) + { + OS_DEBUG("bind: %s\n", strerror(errno)); + return OS_ERROR; + } + + /* Start listening on the socket (implied for stream sockets) */ + if (OS_stream_table[sock_id].socket_type == OS_SocketType_STREAM) + { + os_result = listen(OS_impl_filehandle_table[sock_id].fd, 10); + if (os_result < 0) + { + OS_DEBUG("listen: %s\n", strerror(errno)); + return OS_ERROR; + } + } + return OS_SUCCESS; } /* end OS_SocketBind_Impl */ - /*---------------------------------------------------------------- * * Function: OS_SocketConnect_Impl @@ -238,74 +233,74 @@ int32 OS_SocketBind_Impl(uint32 sock_id, const OS_SockAddr_t *Addr) *-----------------------------------------------------------------*/ int32 OS_SocketConnect_Impl(uint32 sock_id, const OS_SockAddr_t *Addr, int32 timeout) { - int32 return_code; - int os_status; - int sockopt; - socklen_t slen; - uint32 operation; - const struct sockaddr *sa; - - sa = (const struct sockaddr *)&Addr->AddrData; - switch(sa->sa_family) - { - case AF_INET: - slen = sizeof(struct sockaddr_in); - break; + int32 return_code; + int os_status; + int sockopt; + socklen_t slen; + uint32 operation; + const struct sockaddr *sa; + + sa = (const struct sockaddr *)&Addr->AddrData; + switch (sa->sa_family) + { + case AF_INET: + slen = sizeof(struct sockaddr_in); + break; #ifdef OS_NETWORK_SUPPORTS_IPV6 - case AF_INET6: - slen = sizeof(struct sockaddr_in6); - break; + case AF_INET6: + slen = sizeof(struct sockaddr_in6); + break; #endif - default: - slen = 0; - break; - } - - if (slen != Addr->ActualLength) - { - return_code = OS_ERR_BAD_ADDRESS; - } - else - { - return_code = OS_SUCCESS; - os_status = connect(OS_impl_filehandle_table[sock_id].fd, sa, slen); - if (os_status < 0) - { - if (errno != EINPROGRESS) - { - return_code = OS_ERROR; - } - else - { - operation = OS_STREAM_STATE_WRITABLE; - if (OS_impl_filehandle_table[sock_id].selectable) - { - return_code = OS_SelectSingle_Impl(sock_id, &operation, timeout); - } - if (return_code == OS_SUCCESS) - { - if ((operation & OS_STREAM_STATE_WRITABLE) == 0) - { - return_code = OS_ERROR_TIMEOUT; - } - else - { - sockopt = 0; - slen = sizeof(sockopt); - os_status = getsockopt(OS_impl_filehandle_table[sock_id].fd, SOL_SOCKET, SO_ERROR, &sockopt, &slen); - if (os_status < 0 || sockopt != 0) - { - return_code = OS_ERROR; - } - } - } - } - } - } - return return_code; + default: + slen = 0; + break; + } + + if (slen != Addr->ActualLength) + { + return_code = OS_ERR_BAD_ADDRESS; + } + else + { + return_code = OS_SUCCESS; + os_status = connect(OS_impl_filehandle_table[sock_id].fd, sa, slen); + if (os_status < 0) + { + if (errno != EINPROGRESS) + { + return_code = OS_ERROR; + } + else + { + operation = OS_STREAM_STATE_WRITABLE; + if (OS_impl_filehandle_table[sock_id].selectable) + { + return_code = OS_SelectSingle_Impl(sock_id, &operation, timeout); + } + if (return_code == OS_SUCCESS) + { + if ((operation & OS_STREAM_STATE_WRITABLE) == 0) + { + return_code = OS_ERROR_TIMEOUT; + } + else + { + sockopt = 0; + slen = sizeof(sockopt); + os_status = + getsockopt(OS_impl_filehandle_table[sock_id].fd, SOL_SOCKET, SO_ERROR, &sockopt, &slen); + if (os_status < 0 || sockopt != 0) + { + return_code = OS_ERROR; + } + } + } + } + } + } + return return_code; } /* end OS_SocketConnect_Impl */ - /*---------------------------------------------------------------- * * Function: OS_SocketAccept_Impl @@ -316,57 +311,56 @@ int32 OS_SocketConnect_Impl(uint32 sock_id, const OS_SockAddr_t *Addr, int32 tim *-----------------------------------------------------------------*/ int32 OS_SocketAccept_Impl(uint32 sock_id, uint32 connsock_id, OS_SockAddr_t *Addr, int32 timeout) { - int32 return_code; - uint32 operation; - socklen_t addrlen; - int os_flags; - - operation = OS_STREAM_STATE_READABLE; - if (OS_impl_filehandle_table[sock_id].selectable) - { - return_code = OS_SelectSingle_Impl(sock_id, &operation, timeout); - } - else - { - return_code = OS_SUCCESS; - } - - if (return_code == OS_SUCCESS) - { - if ((operation & OS_STREAM_STATE_READABLE) == 0) - { - return_code = OS_ERROR_TIMEOUT; - } - else - { - addrlen = Addr->ActualLength; - OS_impl_filehandle_table[connsock_id].fd = accept(OS_impl_filehandle_table[sock_id].fd, (struct sockaddr *)&Addr->AddrData, &addrlen); - if (OS_impl_filehandle_table[connsock_id].fd < 0) - { - return_code = OS_ERROR; - } - else - { - Addr->ActualLength = addrlen; - - /* - * Set the standard options on the filehandle by default -- - * this may set it to non-blocking mode if the implementation supports it. - * any blocking would be done explicitly via the select() wrappers - */ - os_flags = fcntl(OS_impl_filehandle_table[connsock_id].fd, F_GETFL); - os_flags |= OS_IMPL_SOCKET_FLAGS; - fcntl(OS_impl_filehandle_table[connsock_id].fd, F_SETFL, os_flags); - - OS_impl_filehandle_table[connsock_id].selectable = - ((os_flags & O_NONBLOCK) != 0); - } - } - } - - return return_code; -} /* end OS_SocketAccept_Impl */ + int32 return_code; + uint32 operation; + socklen_t addrlen; + int os_flags; + + operation = OS_STREAM_STATE_READABLE; + if (OS_impl_filehandle_table[sock_id].selectable) + { + return_code = OS_SelectSingle_Impl(sock_id, &operation, timeout); + } + else + { + return_code = OS_SUCCESS; + } + + if (return_code == OS_SUCCESS) + { + if ((operation & OS_STREAM_STATE_READABLE) == 0) + { + return_code = OS_ERROR_TIMEOUT; + } + else + { + addrlen = Addr->ActualLength; + OS_impl_filehandle_table[connsock_id].fd = + accept(OS_impl_filehandle_table[sock_id].fd, (struct sockaddr *)&Addr->AddrData, &addrlen); + if (OS_impl_filehandle_table[connsock_id].fd < 0) + { + return_code = OS_ERROR; + } + else + { + Addr->ActualLength = addrlen; + + /* + * Set the standard options on the filehandle by default -- + * this may set it to non-blocking mode if the implementation supports it. + * any blocking would be done explicitly via the select() wrappers + */ + os_flags = fcntl(OS_impl_filehandle_table[connsock_id].fd, F_GETFL); + os_flags |= OS_IMPL_SOCKET_FLAGS; + fcntl(OS_impl_filehandle_table[connsock_id].fd, F_SETFL, os_flags); + + OS_impl_filehandle_table[connsock_id].selectable = ((os_flags & O_NONBLOCK) != 0); + } + } + } + return return_code; +} /* end OS_SocketAccept_Impl */ /*---------------------------------------------------------------- * @@ -378,86 +372,84 @@ int32 OS_SocketAccept_Impl(uint32 sock_id, uint32 connsock_id, OS_SockAddr_t *Ad *-----------------------------------------------------------------*/ int32 OS_SocketRecvFrom_Impl(uint32 sock_id, void *buffer, uint32 buflen, OS_SockAddr_t *RemoteAddr, int32 timeout) { - int32 return_code; - int os_result; - int waitflags; - uint32 operation; - struct sockaddr *sa; - socklen_t addrlen; - - if (RemoteAddr == NULL) - { - sa = NULL; - addrlen = 0; - } - else - { - addrlen = OS_SOCKADDR_MAX_LEN; - sa = (struct sockaddr *)&RemoteAddr->AddrData; - } - - operation = OS_STREAM_STATE_READABLE; - /* - * If "O_NONBLOCK" flag is set then use select() - * Note this is the only way to get a correct timeout - */ - if (OS_impl_filehandle_table[sock_id].selectable) - { - waitflags = MSG_DONTWAIT; - return_code = OS_SelectSingle_Impl(sock_id, &operation, timeout); - } - else - { - if (timeout == 0) - { - waitflags = MSG_DONTWAIT; - } - else - { - /* note timeout will not be honored if >0 */ - waitflags = 0; - } - return_code = OS_SUCCESS; - } - - if (return_code == OS_SUCCESS) - { - if ((operation & OS_STREAM_STATE_READABLE) == 0) - { - return_code = OS_ERROR_TIMEOUT; - } - else - { - os_result = recvfrom(OS_impl_filehandle_table[sock_id].fd, buffer, buflen, waitflags, sa, &addrlen); - if (os_result < 0) - { - if (errno == EAGAIN || errno == EWOULDBLOCK) + int32 return_code; + int os_result; + int waitflags; + uint32 operation; + struct sockaddr *sa; + socklen_t addrlen; + + if (RemoteAddr == NULL) + { + sa = NULL; + addrlen = 0; + } + else + { + addrlen = OS_SOCKADDR_MAX_LEN; + sa = (struct sockaddr *)&RemoteAddr->AddrData; + } + + operation = OS_STREAM_STATE_READABLE; + /* + * If "O_NONBLOCK" flag is set then use select() + * Note this is the only way to get a correct timeout + */ + if (OS_impl_filehandle_table[sock_id].selectable) + { + waitflags = MSG_DONTWAIT; + return_code = OS_SelectSingle_Impl(sock_id, &operation, timeout); + } + else + { + if (timeout == 0) + { + waitflags = MSG_DONTWAIT; + } + else + { + /* note timeout will not be honored if >0 */ + waitflags = 0; + } + return_code = OS_SUCCESS; + } + + if (return_code == OS_SUCCESS) + { + if ((operation & OS_STREAM_STATE_READABLE) == 0) + { + return_code = OS_ERROR_TIMEOUT; + } + else + { + os_result = recvfrom(OS_impl_filehandle_table[sock_id].fd, buffer, buflen, waitflags, sa, &addrlen); + if (os_result < 0) { - return_code = OS_QUEUE_EMPTY; + if (errno == EAGAIN || errno == EWOULDBLOCK) + { + return_code = OS_QUEUE_EMPTY; + } + else + { + OS_DEBUG("recvfrom: %s\n", strerror(errno)); + return_code = OS_ERROR; + } } else { - OS_DEBUG("recvfrom: %s\n",strerror(errno)); - return_code = OS_ERROR; - } - } - else - { - return_code = os_result; + return_code = os_result; - if (RemoteAddr != NULL) - { - RemoteAddr->ActualLength = addrlen; + if (RemoteAddr != NULL) + { + RemoteAddr->ActualLength = addrlen; + } } - } - } - } + } + } - - return return_code; + return return_code; } /* end OS_SocketRecvFrom_Impl */ - /*---------------------------------------------------------------- * * Function: OS_SocketSendTo_Impl @@ -468,43 +460,41 @@ int32 OS_SocketRecvFrom_Impl(uint32 sock_id, void *buffer, uint32 buflen, OS_Soc *-----------------------------------------------------------------*/ int32 OS_SocketSendTo_Impl(uint32 sock_id, const void *buffer, uint32 buflen, const OS_SockAddr_t *RemoteAddr) { - int os_result; - socklen_t addrlen; - const struct sockaddr *sa; - - sa = (const struct sockaddr *)&RemoteAddr->AddrData; - switch(sa->sa_family) - { - case AF_INET: - addrlen = sizeof(struct sockaddr_in); - break; + int os_result; + socklen_t addrlen; + const struct sockaddr *sa; + + sa = (const struct sockaddr *)&RemoteAddr->AddrData; + switch (sa->sa_family) + { + case AF_INET: + addrlen = sizeof(struct sockaddr_in); + break; #ifdef OS_NETWORK_SUPPORTS_IPV6 - case AF_INET6: - addrlen = sizeof(struct sockaddr_in6); - break; + case AF_INET6: + addrlen = sizeof(struct sockaddr_in6); + break; #endif - default: - addrlen = 0; - break; - } - - if (addrlen != RemoteAddr->ActualLength) - { - return OS_ERR_BAD_ADDRESS; - } - - os_result = sendto(OS_impl_filehandle_table[sock_id].fd, buffer, buflen, MSG_DONTWAIT, sa, addrlen); - if (os_result < 0) - { - OS_DEBUG("sendto: %s\n",strerror(errno)); - return OS_ERROR; - } - - return os_result; + default: + addrlen = 0; + break; + } + + if (addrlen != RemoteAddr->ActualLength) + { + return OS_ERR_BAD_ADDRESS; + } + + os_result = sendto(OS_impl_filehandle_table[sock_id].fd, buffer, buflen, MSG_DONTWAIT, sa, addrlen); + if (os_result < 0) + { + OS_DEBUG("sendto: %s\n", strerror(errno)); + return OS_ERROR; + } + + return os_result; } /* end OS_SocketSendTo_Impl */ - - /*---------------------------------------------------------------- * * Function: OS_SocketGetInfo_Impl @@ -513,12 +503,11 @@ int32 OS_SocketSendTo_Impl(uint32 sock_id, const void *buffer, uint32 buflen, co * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_SocketGetInfo_Impl (uint32 sock_id, OS_socket_prop_t *sock_prop) +int32 OS_SocketGetInfo_Impl(uint32 sock_id, OS_socket_prop_t *sock_prop) { - return OS_SUCCESS; + return OS_SUCCESS; } /* end OS_SocketGetInfo_Impl */ - /*---------------------------------------------------------------- * * Function: OS_SocketAddrInit_Impl @@ -529,42 +518,41 @@ int32 OS_SocketGetInfo_Impl (uint32 sock_id, OS_socket_prop_t *sock_prop) *-----------------------------------------------------------------*/ int32 OS_SocketAddrInit_Impl(OS_SockAddr_t *Addr, OS_SocketDomain_t Domain) { - sa_family_t sa_family; - socklen_t addrlen; - OS_SockAddr_Accessor_t *Accessor; - - memset(Addr, 0, sizeof(OS_SockAddr_t)); - Accessor = (OS_SockAddr_Accessor_t *)&Addr->AddrData; - - switch(Domain) - { - case OS_SocketDomain_INET: - sa_family = AF_INET; - addrlen = sizeof(struct sockaddr_in); - break; + sa_family_t sa_family; + socklen_t addrlen; + OS_SockAddr_Accessor_t *Accessor; + + memset(Addr, 0, sizeof(OS_SockAddr_t)); + Accessor = (OS_SockAddr_Accessor_t *)&Addr->AddrData; + + switch (Domain) + { + case OS_SocketDomain_INET: + sa_family = AF_INET; + addrlen = sizeof(struct sockaddr_in); + break; #ifdef OS_NETWORK_SUPPORTS_IPV6 - case OS_SocketDomain_INET6: - sa_family = AF_INET6; - addrlen = sizeof(struct sockaddr_in6); - break; + case OS_SocketDomain_INET6: + sa_family = AF_INET6; + addrlen = sizeof(struct sockaddr_in6); + break; #endif - default: - addrlen = 0; - break; - } + default: + addrlen = 0; + break; + } - if (addrlen == 0 || addrlen > OS_SOCKADDR_MAX_LEN) - { - return OS_ERR_NOT_IMPLEMENTED; - } + if (addrlen == 0 || addrlen > OS_SOCKADDR_MAX_LEN) + { + return OS_ERR_NOT_IMPLEMENTED; + } - Addr->ActualLength = addrlen; - Accessor->sockaddr.sa_family = sa_family; + Addr->ActualLength = addrlen; + Accessor->sockaddr.sa_family = sa_family; - return OS_SUCCESS; + return OS_SUCCESS; } /* end OS_SocketAddrInit_Impl */ - /*---------------------------------------------------------------- * * Function: OS_SocketAddrToString_Impl @@ -575,35 +563,34 @@ int32 OS_SocketAddrInit_Impl(OS_SockAddr_t *Addr, OS_SocketDomain_t Domain) *-----------------------------------------------------------------*/ int32 OS_SocketAddrToString_Impl(char *buffer, uint32 buflen, const OS_SockAddr_t *Addr) { - const void *addrbuffer; - const OS_SockAddr_Accessor_t *Accessor; + const void * addrbuffer; + const OS_SockAddr_Accessor_t *Accessor; - Accessor = (const OS_SockAddr_Accessor_t *)&Addr->AddrData; + Accessor = (const OS_SockAddr_Accessor_t *)&Addr->AddrData; - switch(Accessor->sockaddr.sa_family) - { - case AF_INET: - addrbuffer = &Accessor->sockaddr_in.sin_addr; - break; + switch (Accessor->sockaddr.sa_family) + { + case AF_INET: + addrbuffer = &Accessor->sockaddr_in.sin_addr; + break; #ifdef OS_NETWORK_SUPPORTS_IPV6 - case AF_INET6: - addrbuffer = &Accessor->sockaddr_in6.sin6_addr; - break; + case AF_INET6: + addrbuffer = &Accessor->sockaddr_in6.sin6_addr; + break; #endif - default: - return OS_ERR_BAD_ADDRESS; - break; - } + default: + return OS_ERR_BAD_ADDRESS; + break; + } - if (inet_ntop(Accessor->sockaddr.sa_family, addrbuffer, buffer, buflen) == NULL) - { - return OS_ERROR; - } + if (inet_ntop(Accessor->sockaddr.sa_family, addrbuffer, buffer, buflen) == NULL) + { + return OS_ERROR; + } - return OS_SUCCESS; + return OS_SUCCESS; } /* end OS_SocketAddrToString_Impl */ - /*---------------------------------------------------------------- * * Function: OS_SocketAddrFromString_Impl @@ -614,35 +601,34 @@ int32 OS_SocketAddrToString_Impl(char *buffer, uint32 buflen, const OS_SockAddr_ *-----------------------------------------------------------------*/ int32 OS_SocketAddrFromString_Impl(OS_SockAddr_t *Addr, const char *string) { - void *addrbuffer; - OS_SockAddr_Accessor_t *Accessor; + void * addrbuffer; + OS_SockAddr_Accessor_t *Accessor; - Accessor = (OS_SockAddr_Accessor_t *)&Addr->AddrData; + Accessor = (OS_SockAddr_Accessor_t *)&Addr->AddrData; - switch(Accessor->sockaddr.sa_family) - { - case AF_INET: - addrbuffer = &Accessor->sockaddr_in.sin_addr; - break; + switch (Accessor->sockaddr.sa_family) + { + case AF_INET: + addrbuffer = &Accessor->sockaddr_in.sin_addr; + break; #ifdef OS_NETWORK_SUPPORTS_IPV6 - case AF_INET6: - addrbuffer = &Accessor->sockaddr_in6.sin6_addr; - break; + case AF_INET6: + addrbuffer = &Accessor->sockaddr_in6.sin6_addr; + break; #endif - default: - return OS_ERR_BAD_ADDRESS; - break; - } + default: + return OS_ERR_BAD_ADDRESS; + break; + } - if (inet_pton(Accessor->sockaddr.sa_family, string, addrbuffer) < 0) - { - return OS_ERROR; - } + if (inet_pton(Accessor->sockaddr.sa_family, string, addrbuffer) < 0) + { + return OS_ERROR; + } - return OS_SUCCESS; + return OS_SUCCESS; } /* end OS_SocketAddrFromString_Impl */ - /*---------------------------------------------------------------- * * Function: OS_SocketAddrGetPort_Impl @@ -653,32 +639,31 @@ int32 OS_SocketAddrFromString_Impl(OS_SockAddr_t *Addr, const char *string) *-----------------------------------------------------------------*/ int32 OS_SocketAddrGetPort_Impl(uint16 *PortNum, const OS_SockAddr_t *Addr) { - in_port_t sa_port; - const OS_SockAddr_Accessor_t *Accessor; + in_port_t sa_port; + const OS_SockAddr_Accessor_t *Accessor; - Accessor = (const OS_SockAddr_Accessor_t *)&Addr->AddrData; + Accessor = (const OS_SockAddr_Accessor_t *)&Addr->AddrData; - switch(Accessor->sockaddr.sa_family) - { - case AF_INET: - sa_port = Accessor->sockaddr_in.sin_port; - break; + switch (Accessor->sockaddr.sa_family) + { + case AF_INET: + sa_port = Accessor->sockaddr_in.sin_port; + break; #ifdef OS_NETWORK_SUPPORTS_IPV6 - case AF_INET6: - sa_port = Accessor->sockaddr_in6.sin6_port; - break; + case AF_INET6: + sa_port = Accessor->sockaddr_in6.sin6_port; + break; #endif - default: - return OS_ERR_BAD_ADDRESS; - break; - } + default: + return OS_ERR_BAD_ADDRESS; + break; + } - *PortNum = ntohs(sa_port); + *PortNum = ntohs(sa_port); - return OS_SUCCESS; + return OS_SUCCESS; } /* end OS_SocketAddrGetPort_Impl */ - /*---------------------------------------------------------------- * * Function: OS_SocketAddrSetPort_Impl @@ -689,28 +674,25 @@ int32 OS_SocketAddrGetPort_Impl(uint16 *PortNum, const OS_SockAddr_t *Addr) *-----------------------------------------------------------------*/ int32 OS_SocketAddrSetPort_Impl(OS_SockAddr_t *Addr, uint16 PortNum) { - in_port_t sa_port; - OS_SockAddr_Accessor_t *Accessor; + in_port_t sa_port; + OS_SockAddr_Accessor_t *Accessor; - sa_port = htons(PortNum); - Accessor = (OS_SockAddr_Accessor_t *)&Addr->AddrData; + sa_port = htons(PortNum); + Accessor = (OS_SockAddr_Accessor_t *)&Addr->AddrData; - switch(Accessor->sockaddr.sa_family) - { - case AF_INET: - Accessor->sockaddr_in.sin_port = sa_port; - break; + switch (Accessor->sockaddr.sa_family) + { + case AF_INET: + Accessor->sockaddr_in.sin_port = sa_port; + break; #ifdef OS_NETWORK_SUPPORTS_IPV6 - case AF_INET6: - Accessor->sockaddr_in6.sin6_port = sa_port; - break; + case AF_INET6: + Accessor->sockaddr_in6.sin6_port = sa_port; + break; #endif - default: - return OS_ERR_BAD_ADDRESS; - } + default: + return OS_ERR_BAD_ADDRESS; + } - return OS_SUCCESS; + return OS_SUCCESS; } /* end OS_SocketAddrSetPort_Impl */ - - - diff --git a/src/os/portable/os-impl-console-bsp.c b/src/os/portable/os-impl-console-bsp.c index 336a8d9d1..ddc6369eb 100644 --- a/src/os/portable/os-impl-console-bsp.c +++ b/src/os/portable/os-impl-console-bsp.c @@ -44,7 +44,6 @@ CONSOLE OUTPUT ***************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_ConsoleOutput_Impl @@ -53,16 +52,16 @@ * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -void OS_ConsoleOutput_Impl(uint32 local_id) +void OS_ConsoleOutput_Impl(uint32 local_id) { - uint32 StartPos; - uint32 EndPos; - long WriteSize; + uint32 StartPos; + uint32 EndPos; + long WriteSize; OS_console_internal_record_t *console; - console = &OS_console_table[local_id]; + console = &OS_console_table[local_id]; StartPos = console->ReadPos; - EndPos = console->WritePos; + EndPos = console->WritePos; while (StartPos != EndPos) { if (StartPos > EndPos) @@ -75,8 +74,7 @@ void OS_ConsoleOutput_Impl(uint32 local_id) WriteSize = EndPos - StartPos; } - OS_BSP_ConsoleOutput_Impl(&console->BufBase[StartPos], - WriteSize); + OS_BSP_ConsoleOutput_Impl(&console->BufBase[StartPos], WriteSize); StartPos += WriteSize; if (StartPos >= console->BufSize) @@ -89,8 +87,3 @@ void OS_ConsoleOutput_Impl(uint32 local_id) /* Update the global with the new read location */ console->ReadPos = StartPos; } /* end OS_ConsoleOutput_Impl */ - - - - - diff --git a/src/os/portable/os-impl-no-loader.c b/src/os/portable/os-impl-no-loader.c index dca88680c..37713589a 100644 --- a/src/os/portable/os-impl-no-loader.c +++ b/src/os/portable/os-impl-no-loader.c @@ -27,7 +27,6 @@ * for all calls. */ - #include #include "os-shared-module.h" @@ -39,13 +38,12 @@ * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleLoad_Impl ( uint32 module_id, const char *translated_path ) +int32 OS_ModuleLoad_Impl(uint32 module_id, const char *translated_path) { return OS_ERR_NOT_IMPLEMENTED; } /* end OS_ModuleLoad_Impl */ - /*---------------------------------------------------------------- * * Function: OS_ModuleUnload_Impl @@ -54,7 +52,7 @@ int32 OS_ModuleLoad_Impl ( uint32 module_id, const char *translated_path ) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleUnload_Impl ( uint32 module_id ) +int32 OS_ModuleUnload_Impl(uint32 module_id) { return OS_ERR_NOT_IMPLEMENTED; @@ -68,14 +66,8 @@ int32 OS_ModuleUnload_Impl ( uint32 module_id ) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleGetInfo_Impl ( uint32 module_id, OS_module_prop_t *module_prop ) +int32 OS_ModuleGetInfo_Impl(uint32 module_id, OS_module_prop_t *module_prop) { return OS_ERR_NOT_IMPLEMENTED; } /* end OS_ModuleGetInfo_Impl */ - - - - - - diff --git a/src/os/portable/os-impl-no-network.c b/src/os/portable/os-impl-no-network.c index 1b864f85f..b7dba2fb0 100644 --- a/src/os/portable/os-impl-no-network.c +++ b/src/os/portable/os-impl-no-network.c @@ -31,12 +31,10 @@ #include #include "os-shared-network.h" - /**************************************************************************************** Network API ***************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_NetworkGetID_Impl @@ -45,14 +43,11 @@ * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_NetworkGetID_Impl (int32 *IdBuf) +int32 OS_NetworkGetID_Impl(int32 *IdBuf) { return OS_ERR_NOT_IMPLEMENTED; } /* end OS_NetworkGetID_Impl */ - - - /*---------------------------------------------------------------- * * Function: OS_NetworkGetHostName_Impl @@ -61,10 +56,7 @@ int32 OS_NetworkGetID_Impl (int32 *IdBuf) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_NetworkGetHostName_Impl (char *host_name, uint32 name_len) +int32 OS_NetworkGetHostName_Impl(char *host_name, uint32 name_len) { return OS_ERR_NOT_IMPLEMENTED; } /* end OS_NetworkGetHostName_Impl */ - - - diff --git a/src/os/portable/os-impl-no-shell.c b/src/os/portable/os-impl-no-shell.c index c8b5951f7..31bead6e3 100644 --- a/src/os/portable/os-impl-no-shell.c +++ b/src/os/portable/os-impl-no-shell.c @@ -18,7 +18,6 @@ * limitations under the License. */ - /** * \file os-impl-no-shell.c * @@ -35,7 +34,7 @@ * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ShellOutputToFile_Impl(uint32 file_id, const char* Cmd) +int32 OS_ShellOutputToFile_Impl(uint32 file_id, const char *Cmd) { return OS_ERR_NOT_IMPLEMENTED; } diff --git a/src/os/portable/os-impl-no-sockets.c b/src/os/portable/os-impl-no-sockets.c index bf8fb8196..f2ed25204 100644 --- a/src/os/portable/os-impl-no-sockets.c +++ b/src/os/portable/os-impl-no-sockets.c @@ -33,18 +33,14 @@ #include #include "os-shared-sockets.h" - /**************************************************************************************** DEFINES ****************************************************************************************/ - /**************************************************************************************** Socket API ***************************************************************************************/ - - /*---------------------------------------------------------------- * * Function: OS_SocketOpen_Impl @@ -58,7 +54,6 @@ int32 OS_SocketOpen_Impl(uint32 sock_id) return OS_ERR_NOT_IMPLEMENTED; } /* end OS_SocketOpen_Impl */ - /*---------------------------------------------------------------- * * Function: OS_SocketBind_Impl @@ -72,7 +67,6 @@ int32 OS_SocketBind_Impl(uint32 sock_id, const OS_SockAddr_t *Addr) return OS_ERR_NOT_IMPLEMENTED; } /* end OS_SocketBind_Impl */ - /*---------------------------------------------------------------- * * Function: OS_SocketConnect_Impl @@ -86,7 +80,6 @@ int32 OS_SocketConnect_Impl(uint32 sock_id, const OS_SockAddr_t *Addr, int32 tim return OS_ERR_NOT_IMPLEMENTED; } /* end OS_SocketConnect_Impl */ - /*---------------------------------------------------------------- * * Function: OS_SocketAccept_Impl @@ -100,7 +93,6 @@ int32 OS_SocketAccept_Impl(uint32 sock_id, uint32 connsock_id, OS_SockAddr_t *Ad return OS_ERR_NOT_IMPLEMENTED; } /* end OS_SocketAccept_Impl */ - /*---------------------------------------------------------------- * * Function: OS_SocketRecvFrom_Impl @@ -114,7 +106,6 @@ int32 OS_SocketRecvFrom_Impl(uint32 sock_id, void *buffer, uint32 buflen, OS_Soc return OS_ERR_NOT_IMPLEMENTED; } /* end OS_SocketRecvFrom_Impl */ - /*---------------------------------------------------------------- * * Function: OS_SocketSendTo_Impl @@ -128,8 +119,6 @@ int32 OS_SocketSendTo_Impl(uint32 sock_id, const void *buffer, uint32 buflen, co return OS_ERR_NOT_IMPLEMENTED; } /* end OS_SocketSendTo_Impl */ - - /*---------------------------------------------------------------- * * Function: OS_SocketGetInfo_Impl @@ -138,12 +127,11 @@ int32 OS_SocketSendTo_Impl(uint32 sock_id, const void *buffer, uint32 buflen, co * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_SocketGetInfo_Impl (uint32 sock_id, OS_socket_prop_t *sock_prop) +int32 OS_SocketGetInfo_Impl(uint32 sock_id, OS_socket_prop_t *sock_prop) { - return OS_SUCCESS; + return OS_SUCCESS; } /* end OS_SocketGetInfo_Impl */ - /*---------------------------------------------------------------- * * Function: OS_SocketAddrInit_Impl @@ -157,7 +145,6 @@ int32 OS_SocketAddrInit_Impl(OS_SockAddr_t *Addr, OS_SocketDomain_t Domain) return OS_ERR_NOT_IMPLEMENTED; } /* end OS_SocketAddrInit_Impl */ - /*---------------------------------------------------------------- * * Function: OS_SocketAddrToString_Impl @@ -171,7 +158,6 @@ int32 OS_SocketAddrToString_Impl(char *buffer, uint32 buflen, const OS_SockAddr_ return OS_ERR_NOT_IMPLEMENTED; } /* end OS_SocketAddrToString_Impl */ - /*---------------------------------------------------------------- * * Function: OS_SocketAddrFromString_Impl @@ -185,7 +171,6 @@ int32 OS_SocketAddrFromString_Impl(OS_SockAddr_t *Addr, const char *string) return OS_ERR_NOT_IMPLEMENTED; } /* end OS_SocketAddrFromString_Impl */ - /*---------------------------------------------------------------- * * Function: OS_SocketAddrGetPort_Impl @@ -199,7 +184,6 @@ int32 OS_SocketAddrGetPort_Impl(uint16 *PortNum, const OS_SockAddr_t *Addr) return OS_ERR_NOT_IMPLEMENTED; } /* end OS_SocketAddrGetPort_Impl */ - /*---------------------------------------------------------------- * * Function: OS_SocketAddrSetPort_Impl @@ -212,7 +196,3 @@ int32 OS_SocketAddrSetPort_Impl(OS_SockAddr_t *Addr, uint16 PortNum) { return OS_ERR_NOT_IMPLEMENTED; } /* end OS_SocketAddrSetPort_Impl */ - - - - diff --git a/src/os/portable/os-impl-no-symtab.c b/src/os/portable/os-impl-no-symtab.c index c48e0e328..fb602ecae 100644 --- a/src/os/portable/os-impl-no-symtab.c +++ b/src/os/portable/os-impl-no-symtab.c @@ -30,7 +30,6 @@ #include #include "os-shared-module.h" - /*---------------------------------------------------------------- * * Function: OS_SymbolLookup_Impl @@ -39,13 +38,12 @@ * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_SymbolLookup_Impl( cpuaddr *SymbolAddress, const char *SymbolName ) +int32 OS_SymbolLookup_Impl(cpuaddr *SymbolAddress, const char *SymbolName) { return OS_ERR_NOT_IMPLEMENTED; } /* end OS_SymbolLookup_Impl */ - /*---------------------------------------------------------------- * * Function: OS_SymbolTableDump_Impl @@ -54,13 +52,8 @@ int32 OS_SymbolLookup_Impl( cpuaddr *SymbolAddress, const char *SymbolName ) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_SymbolTableDump_Impl ( const char *filename, uint32 SizeLimit ) +int32 OS_SymbolTableDump_Impl(const char *filename, uint32 SizeLimit) { - return(OS_ERR_NOT_IMPLEMENTED); + return (OS_ERR_NOT_IMPLEMENTED); } /* end OS_SymbolTableDump_Impl */ - - - - - diff --git a/src/os/portable/os-impl-posix-dirs.c b/src/os/portable/os-impl-posix-dirs.c index 9a500a017..740a8fb73 100644 --- a/src/os/portable/os-impl-posix-dirs.c +++ b/src/os/portable/os-impl-posix-dirs.c @@ -62,7 +62,6 @@ GLOBAL DATA ***************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_DirCreate_Impl @@ -73,28 +72,28 @@ *-----------------------------------------------------------------*/ int32 OS_DirCreate_Impl(const char *local_path, uint32 access) { - struct stat st; - int32 return_code; - - if ( mkdir(local_path, S_IFDIR |S_IRWXU | S_IRWXG | S_IRWXO) < 0 ) - { - return_code = OS_ERROR; - - if (errno == EEXIST) - { - /* it exists, but not necessarily a directory */ - if ( stat(local_path, &st) == 0 && S_ISDIR(st.st_mode) ) - { - return_code = OS_SUCCESS; - } - } - } - else - { - return_code = OS_SUCCESS; - } - - return return_code; + struct stat st; + int32 return_code; + + if (mkdir(local_path, S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO) < 0) + { + return_code = OS_ERROR; + + if (errno == EEXIST) + { + /* it exists, but not necessarily a directory */ + if (stat(local_path, &st) == 0 && S_ISDIR(st.st_mode)) + { + return_code = OS_SUCCESS; + } + } + } + else + { + return_code = OS_SUCCESS; + } + + return return_code; } /* end OS_DirCreate_Impl */ /*---------------------------------------------------------------- @@ -107,13 +106,13 @@ int32 OS_DirCreate_Impl(const char *local_path, uint32 access) *-----------------------------------------------------------------*/ int32 OS_DirOpen_Impl(uint32 local_id, const char *local_path) { - DIR *dp = opendir(local_path); - if (dp == NULL) - { - return OS_ERROR; - } - OS_impl_dir_table[local_id].dp = dp; - return OS_SUCCESS; + DIR *dp = opendir(local_path); + if (dp == NULL) + { + return OS_ERROR; + } + OS_impl_dir_table[local_id].dp = dp; + return OS_SUCCESS; } /* end OS_DirOpen_Impl */ /*---------------------------------------------------------------- @@ -126,9 +125,9 @@ int32 OS_DirOpen_Impl(uint32 local_id, const char *local_path) *-----------------------------------------------------------------*/ int32 OS_DirClose_Impl(uint32 local_id) { - closedir(OS_impl_dir_table[local_id].dp); - OS_impl_dir_table[local_id].dp = NULL; - return OS_SUCCESS; + closedir(OS_impl_dir_table[local_id].dp); + OS_impl_dir_table[local_id].dp = NULL; + return OS_SUCCESS; } /* end OS_DirClose_Impl */ /*---------------------------------------------------------------- @@ -141,27 +140,27 @@ int32 OS_DirClose_Impl(uint32 local_id) *-----------------------------------------------------------------*/ int32 OS_DirRead_Impl(uint32 local_id, os_dirent_t *dirent) { - struct dirent *de; - - /* NOTE - the readdir() call is non-reentrant .... - * However, this is performed while the global dir table lock is taken. - * Therefore this ensures that only one such call can occur at any given time. - * - * Static analysis tools may warn about this because they do not know - * this function is externally serialized via the global lock. - */ - /* cppcheck-suppress readdirCalled */ - /* cppcheck-suppress nonreentrantFunctionsreaddir */ - de = readdir(OS_impl_dir_table[local_id].dp); - if (de == NULL) - { - return OS_ERROR; - } - - strncpy(dirent->FileName, de->d_name, sizeof(dirent->FileName) - 1); - dirent->FileName[sizeof(dirent->FileName) - 1] = 0; - - return OS_SUCCESS; + struct dirent *de; + + /* NOTE - the readdir() call is non-reentrant .... + * However, this is performed while the global dir table lock is taken. + * Therefore this ensures that only one such call can occur at any given time. + * + * Static analysis tools may warn about this because they do not know + * this function is externally serialized via the global lock. + */ + /* cppcheck-suppress readdirCalled */ + /* cppcheck-suppress nonreentrantFunctionsreaddir */ + de = readdir(OS_impl_dir_table[local_id].dp); + if (de == NULL) + { + return OS_ERROR; + } + + strncpy(dirent->FileName, de->d_name, sizeof(dirent->FileName) - 1); + dirent->FileName[sizeof(dirent->FileName) - 1] = 0; + + return OS_SUCCESS; } /* end OS_DirRead_Impl */ /*---------------------------------------------------------------- @@ -174,8 +173,8 @@ int32 OS_DirRead_Impl(uint32 local_id, os_dirent_t *dirent) *-----------------------------------------------------------------*/ int32 OS_DirRewind_Impl(uint32 local_id) { - rewinddir(OS_impl_dir_table[local_id].dp); - return OS_SUCCESS; + rewinddir(OS_impl_dir_table[local_id].dp); + return OS_SUCCESS; } /* end OS_DirRewind_Impl */ /*---------------------------------------------------------------- @@ -188,10 +187,10 @@ int32 OS_DirRewind_Impl(uint32 local_id) *-----------------------------------------------------------------*/ int32 OS_DirRemove_Impl(const char *local_path) { - if ( rmdir(local_path) < 0 ) - { - return OS_ERROR; - } + if (rmdir(local_path) < 0) + { + return OS_ERROR; + } - return OS_SUCCESS; + return OS_SUCCESS; } /* end OS_DirRemove_Impl */ diff --git a/src/os/portable/os-impl-posix-dl-loader.c b/src/os/portable/os-impl-posix-dl-loader.c index fac9f6684..55aa9ac3c 100644 --- a/src/os/portable/os-impl-posix-dl-loader.c +++ b/src/os/portable/os-impl-posix-dl-loader.c @@ -49,14 +49,10 @@ #include "os-impl-loader.h" #include "os-shared-module.h" - - - /**************************************************************************************** Module Loader API ***************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_ModuleLoad_Impl @@ -65,26 +61,25 @@ * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleLoad_Impl ( uint32 module_id, const char *translated_path ) +int32 OS_ModuleLoad_Impl(uint32 module_id, const char *translated_path) { int32 status = OS_ERROR; - dlerror(); - OS_impl_module_table[module_id].dl_handle = dlopen(translated_path, RTLD_NOW | RTLD_GLOBAL); - if (OS_impl_module_table[module_id].dl_handle != NULL) - { - status = OS_SUCCESS; - } - else - { - OS_DEBUG("Error loading shared library: %s\n", dlerror()); - } + dlerror(); + OS_impl_module_table[module_id].dl_handle = dlopen(translated_path, RTLD_NOW | RTLD_GLOBAL); + if (OS_impl_module_table[module_id].dl_handle != NULL) + { + status = OS_SUCCESS; + } + else + { + OS_DEBUG("Error loading shared library: %s\n", dlerror()); + } - return status; + return status; } /* end OS_ModuleLoad_Impl */ - /*---------------------------------------------------------------- * * Function: OS_ModuleUnload_Impl @@ -93,7 +88,7 @@ int32 OS_ModuleLoad_Impl ( uint32 module_id, const char *translated_path ) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleUnload_Impl ( uint32 module_id ) +int32 OS_ModuleUnload_Impl(uint32 module_id) { int32 status = OS_ERROR; @@ -104,7 +99,7 @@ int32 OS_ModuleUnload_Impl ( uint32 module_id ) if (dlclose(OS_impl_module_table[module_id].dl_handle) == 0) { OS_impl_module_table[module_id].dl_handle = NULL; - status = OS_SUCCESS; + status = OS_SUCCESS; } else { @@ -115,7 +110,6 @@ int32 OS_ModuleUnload_Impl ( uint32 module_id ) } /* end OS_ModuleUnload_Impl */ - /*---------------------------------------------------------------- * * Function: OS_ModuleGetInfo_Impl @@ -124,20 +118,18 @@ int32 OS_ModuleUnload_Impl ( uint32 module_id ) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleGetInfo_Impl ( uint32 module_id, OS_module_prop_t *module_prop ) +int32 OS_ModuleGetInfo_Impl(uint32 module_id, OS_module_prop_t *module_prop) { - /* - * Limiting strictly to POSIX-defined API means there is no defined - * method to get information about a module contents. - * - * The "dlinfo()" function might return some interesting information - * but this is actually a non-posix extension / platform-defined API. - * - * This returns success - although there is no information to add here, - * the parent/shared layer information is still valid. - */ - return(OS_SUCCESS); + /* + * Limiting strictly to POSIX-defined API means there is no defined + * method to get information about a module contents. + * + * The "dlinfo()" function might return some interesting information + * but this is actually a non-posix extension / platform-defined API. + * + * This returns success - although there is no information to add here, + * the parent/shared layer information is still valid. + */ + return (OS_SUCCESS); } /* end OS_ModuleGetInfo_Impl */ - - diff --git a/src/os/portable/os-impl-posix-dl-symtab.c b/src/os/portable/os-impl-posix-dl-symtab.c index c892a33bb..98d861e55 100644 --- a/src/os/portable/os-impl-posix-dl-symtab.c +++ b/src/os/portable/os-impl-posix-dl-symtab.c @@ -66,14 +66,12 @@ */ #ifndef OSAL_DLSYM_DEFAULT_HANDLE #ifdef RTLD_DEFAULT -#define OSAL_DLSYM_DEFAULT_HANDLE RTLD_DEFAULT +#define OSAL_DLSYM_DEFAULT_HANDLE RTLD_DEFAULT #else -#define OSAL_DLSYM_DEFAULT_HANDLE NULL +#define OSAL_DLSYM_DEFAULT_HANDLE NULL #endif #endif - - /**************************************************************************************** Symbol table API ***************************************************************************************/ @@ -86,18 +84,18 @@ * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_SymbolLookup_Impl( cpuaddr *SymbolAddress, const char *SymbolName ) +int32 OS_SymbolLookup_Impl(cpuaddr *SymbolAddress, const char *SymbolName) { - int32 status = OS_ERROR; - const char *dlError; /* Pointer to error string */ - void *Function; + int32 status = OS_ERROR; + const char *dlError; /* Pointer to error string */ + void * Function; /* * call dlerror() to clear any prior error that might have occurred. */ dlerror(); Function = dlsym(OSAL_DLSYM_DEFAULT_HANDLE, SymbolName); - dlError = dlerror(); + dlError = dlerror(); /* * For the POSIX DL implementation, if the symbol does not exist @@ -112,10 +110,10 @@ int32 OS_SymbolLookup_Impl( cpuaddr *SymbolAddress, const char *SymbolName ) * and as such all valid symbols should be non-NULL, so NULL is considered * an error even if the C library doesn't consider this an error. */ - if( dlError == NULL && Function != NULL ) + if (dlError == NULL && Function != NULL) { *SymbolAddress = (cpuaddr)Function; - status = OS_SUCCESS; + status = OS_SUCCESS; } return status; @@ -132,7 +130,7 @@ int32 OS_SymbolLookup_Impl( cpuaddr *SymbolAddress, const char *SymbolName ) * POSIX DL does not provide * *-----------------------------------------------------------------*/ -int32 OS_SymbolTableDump_Impl ( const char *filename, uint32 SizeLimit ) +int32 OS_SymbolTableDump_Impl(const char *filename, uint32 SizeLimit) { /* * Limiting strictly to POSIX-defined API means there is no defined @@ -146,8 +144,6 @@ int32 OS_SymbolTableDump_Impl ( const char *filename, uint32 SizeLimit ) * unimplemented here. */ - return(OS_ERR_NOT_IMPLEMENTED); + return (OS_ERR_NOT_IMPLEMENTED); } /* end OS_SymbolTableDump_Impl */ - - diff --git a/src/os/portable/os-impl-posix-files.c b/src/os/portable/os-impl-posix-files.c index a4dbf9391..365732652 100644 --- a/src/os/portable/os-impl-posix-files.c +++ b/src/os/portable/os-impl-posix-files.c @@ -47,19 +47,14 @@ #include "os-impl-files.h" #include "os-shared-file.h" - /**************************************************************************************** DEFINES ***************************************************************************************/ - /**************************************************************************************** Named File API ***************************************************************************************/ - - - /*---------------------------------------------------------------- * * Function: OS_FileOpen_Impl @@ -70,57 +65,56 @@ *-----------------------------------------------------------------*/ int32 OS_FileOpen_Impl(uint32 local_id, const char *local_path, int32 flags, int32 access) { - int os_perm; - int os_mode; - - /* - ** Check for a valid access mode - ** For creating a file, OS_READ_ONLY does not make sense - */ - switch(access) - { - case OS_WRITE_ONLY: - os_perm = O_WRONLY; - break; - case OS_READ_ONLY: - os_perm = O_RDONLY; - break; - case OS_READ_WRITE: - os_perm = O_RDWR; - break; - default: - return OS_ERROR; - } - - if (flags & OS_FILE_FLAG_CREATE) - { - os_perm |= O_CREAT; - } - if (flags & OS_FILE_FLAG_TRUNCATE) - { - os_perm |= O_TRUNC; - } - - os_perm |= OS_IMPL_REGULAR_FILE_FLAGS; - - os_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; - - OS_impl_filehandle_table[local_id].fd = open(local_path, os_perm, os_mode); - - if (OS_impl_filehandle_table[local_id].fd < 0) - { - OS_DEBUG("open(%s): %s\n", local_path, strerror(errno)); - return OS_ERROR; - } - - /* - * If the flags included O_NONBLOCK, then - * enable the "select" call on this handle. + int os_perm; + int os_mode; + + /* + ** Check for a valid access mode + ** For creating a file, OS_READ_ONLY does not make sense */ - OS_impl_filehandle_table[local_id].selectable = - ((os_perm & O_NONBLOCK) != 0); + switch (access) + { + case OS_WRITE_ONLY: + os_perm = O_WRONLY; + break; + case OS_READ_ONLY: + os_perm = O_RDONLY; + break; + case OS_READ_WRITE: + os_perm = O_RDWR; + break; + default: + return OS_ERROR; + } + + if (flags & OS_FILE_FLAG_CREATE) + { + os_perm |= O_CREAT; + } + if (flags & OS_FILE_FLAG_TRUNCATE) + { + os_perm |= O_TRUNC; + } + + os_perm |= OS_IMPL_REGULAR_FILE_FLAGS; + + os_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; + + OS_impl_filehandle_table[local_id].fd = open(local_path, os_perm, os_mode); - return OS_SUCCESS; + if (OS_impl_filehandle_table[local_id].fd < 0) + { + OS_DEBUG("open(%s): %s\n", local_path, strerror(errno)); + return OS_ERROR; + } + + /* + * If the flags included O_NONBLOCK, then + * enable the "select" call on this handle. + */ + OS_impl_filehandle_table[local_id].selectable = ((os_perm & O_NONBLOCK) != 0); + + return OS_SUCCESS; } /* end OS_FileOpen_Impl */ /*---------------------------------------------------------------- @@ -133,62 +127,61 @@ int32 OS_FileOpen_Impl(uint32 local_id, const char *local_path, int32 flags, int *-----------------------------------------------------------------*/ int32 OS_FileStat_Impl(const char *local_path, os_fstat_t *FileStats) { - struct stat st; - mode_t readbits; - mode_t writebits; - mode_t execbits; - - if ( stat(local_path, &st) < 0 ) - { - return OS_ERROR; - } - - FileStats->FileSize = st.st_size; - FileStats->FileTime = st.st_mtime; - - /* note that the "fst_mode" member is already zeroed by the caller */ - if (S_ISDIR(st.st_mode)) - { - FileStats->FileModeBits |= OS_FILESTAT_MODE_DIR; - } - - /* always check world bits */ - readbits = S_IROTH; - writebits = S_IWOTH; - execbits = S_IXOTH; - - if (OS_IMPL_SELF_EUID == st.st_uid) - { - /* we own the file so use user bits for simplified perms */ - readbits |= S_IRUSR; - writebits |= S_IWUSR; - execbits |= S_IXUSR; - } - - if (OS_IMPL_SELF_EGID == st.st_gid) - { - /* our group owns the file so use group bits for simplified perms */ - readbits |= S_IRGRP; - writebits |= S_IWGRP; - execbits |= S_IXGRP; - } - - if (st.st_mode & readbits) - { - FileStats->FileModeBits |= OS_FILESTAT_MODE_READ; - } - if (st.st_mode & writebits) - { - FileStats->FileModeBits |= OS_FILESTAT_MODE_WRITE; - } - if (st.st_mode & execbits) - { - FileStats->FileModeBits |= OS_FILESTAT_MODE_EXEC; - } - - return OS_SUCCESS; -} /* end OS_FileStat_Impl */ + struct stat st; + mode_t readbits; + mode_t writebits; + mode_t execbits; + + if (stat(local_path, &st) < 0) + { + return OS_ERROR; + } + FileStats->FileSize = st.st_size; + FileStats->FileTime = st.st_mtime; + + /* note that the "fst_mode" member is already zeroed by the caller */ + if (S_ISDIR(st.st_mode)) + { + FileStats->FileModeBits |= OS_FILESTAT_MODE_DIR; + } + + /* always check world bits */ + readbits = S_IROTH; + writebits = S_IWOTH; + execbits = S_IXOTH; + + if (OS_IMPL_SELF_EUID == st.st_uid) + { + /* we own the file so use user bits for simplified perms */ + readbits |= S_IRUSR; + writebits |= S_IWUSR; + execbits |= S_IXUSR; + } + + if (OS_IMPL_SELF_EGID == st.st_gid) + { + /* our group owns the file so use group bits for simplified perms */ + readbits |= S_IRGRP; + writebits |= S_IWGRP; + execbits |= S_IXGRP; + } + + if (st.st_mode & readbits) + { + FileStats->FileModeBits |= OS_FILESTAT_MODE_READ; + } + if (st.st_mode & writebits) + { + FileStats->FileModeBits |= OS_FILESTAT_MODE_WRITE; + } + if (st.st_mode & execbits) + { + FileStats->FileModeBits |= OS_FILESTAT_MODE_EXEC; + } + + return OS_SUCCESS; +} /* end OS_FileStat_Impl */ /*---------------------------------------------------------------- * @@ -200,8 +193,8 @@ int32 OS_FileStat_Impl(const char *local_path, os_fstat_t *FileStats) *-----------------------------------------------------------------*/ int32 OS_FileChmod_Impl(const char *local_path, uint32 access) { - mode_t readbits; - mode_t writebits; + mode_t readbits; + mode_t writebits; struct stat st; /* @@ -213,27 +206,27 @@ int32 OS_FileChmod_Impl(const char *local_path, uint32 access) * which is generally not part of the OSAL API, but * is important for the underlying OS. */ - if ( stat(local_path, &st) < 0 ) + if (stat(local_path, &st) < 0) { - return OS_ERROR; + return OS_ERROR; } /* always check world bits */ - readbits = S_IROTH; + readbits = S_IROTH; writebits = S_IWOTH; if (OS_IMPL_SELF_EUID == st.st_uid) { - /* we own the file so use user bits */ - readbits |= S_IRUSR; - writebits |= S_IWUSR; + /* we own the file so use user bits */ + readbits |= S_IRUSR; + writebits |= S_IWUSR; } if (OS_IMPL_SELF_EGID == st.st_gid) { - /* our group owns the file so use group bits */ - readbits |= S_IRGRP; - writebits |= S_IWGRP; + /* our group owns the file so use group bits */ + readbits |= S_IRGRP; + writebits |= S_IWGRP; } if (access == OS_WRITE_ONLY || access == OS_READ_WRITE) @@ -259,7 +252,7 @@ int32 OS_FileChmod_Impl(const char *local_path, uint32 access) } /* finally, write the modified mode back to the file */ - if ( chmod(local_path, st.st_mode) < 0 ) + if (chmod(local_path, st.st_mode) < 0) { return OS_ERROR; } @@ -278,12 +271,12 @@ int32 OS_FileChmod_Impl(const char *local_path, uint32 access) *-----------------------------------------------------------------*/ int32 OS_FileRemove_Impl(const char *local_path) { - if ( remove (local_path) < 0 ) - { - return OS_ERROR; - } + if (remove(local_path) < 0) + { + return OS_ERROR; + } - return OS_SUCCESS; + return OS_SUCCESS; } /* end OS_FileRemove_Impl */ /*---------------------------------------------------------------- @@ -296,11 +289,10 @@ int32 OS_FileRemove_Impl(const char *local_path) *-----------------------------------------------------------------*/ int32 OS_FileRename_Impl(const char *old_path, const char *new_path) { - if ( rename (old_path, new_path) < 0 ) - { - return OS_ERROR; - } + if (rename(old_path, new_path) < 0) + { + return OS_ERROR; + } - return OS_SUCCESS; + return OS_SUCCESS; } /* end OS_FileRename_Impl */ - diff --git a/src/os/portable/os-impl-posix-gettime.c b/src/os/portable/os-impl-posix-gettime.c index 8557ec782..670a18353 100644 --- a/src/os/portable/os-impl-posix-gettime.c +++ b/src/os/portable/os-impl-posix-gettime.c @@ -51,14 +51,10 @@ #include "os-impl-gettime.h" #include "os-shared-clock.h" - - - /**************************************************************************************** FUNCTIONS ***************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_GetLocalTime_Impl @@ -77,20 +73,19 @@ int32 OS_GetLocalTime_Impl(OS_time_t *time_struct) if (Status == 0) { - time_struct -> seconds = time.tv_sec; - time_struct -> microsecs = time.tv_nsec / 1000; - ReturnCode = OS_SUCCESS; + time_struct->seconds = time.tv_sec; + time_struct->microsecs = time.tv_nsec / 1000; + ReturnCode = OS_SUCCESS; } else { - OS_DEBUG("Error calling clock_gettime: %s\n",strerror(errno)); + OS_DEBUG("Error calling clock_gettime: %s\n", strerror(errno)); ReturnCode = OS_ERROR; } return ReturnCode; } /* end OS_GetLocalTime_Impl */ - /*---------------------------------------------------------------- * * Function: OS_SetLocalTime_Impl @@ -105,8 +100,8 @@ int32 OS_SetLocalTime_Impl(const OS_time_t *time_struct) int32 ReturnCode; struct timespec time; - time.tv_sec = time_struct -> seconds; - time.tv_nsec = (time_struct -> microsecs * 1000); + time.tv_sec = time_struct->seconds; + time.tv_nsec = (time_struct->microsecs * 1000); Status = clock_settime(OSAL_GETTIME_SOURCE_CLOCK, &time); diff --git a/src/os/portable/os-impl-posix-io.c b/src/os/portable/os-impl-posix-io.c index 62578e334..1f9860cb1 100644 --- a/src/os/portable/os-impl-posix-io.c +++ b/src/os/portable/os-impl-posix-io.c @@ -49,7 +49,6 @@ #include "os-shared-file.h" #include "os-shared-select.h" - /* some OS libraries (e.g. VxWorks) do not declare the API to be const-correct * It can still use this generic implementation but the call to write() must be * cast to a void* to avoid a warning. The includer can define this if needed. @@ -59,7 +58,6 @@ #define GENERIC_IO_CONST_DATA_CAST #endif - /*---------------------------------------------------------------- * * Function: OS_GenericClose_Impl @@ -70,26 +68,26 @@ *-----------------------------------------------------------------*/ int32 OS_GenericClose_Impl(uint32 local_id) { - int result; - - result = close (OS_impl_filehandle_table[local_id].fd); - if (result < 0) - { - /* - * close() can technically fail for various reasons, but - * there isn't much recourse if this call fails. Just log - * the failure for debugging. - * - * POSIX also does not specify the state of the filehandle - * after a close() with an error. - * - * At least in Linux/glibc the filehandle is always closed - * in the kernel and should not be used again or re-closed. - */ - OS_DEBUG("close: %s\n",strerror(errno)); - } - OS_impl_filehandle_table[local_id].fd = -1; - return OS_SUCCESS; + int result; + + result = close(OS_impl_filehandle_table[local_id].fd); + if (result < 0) + { + /* + * close() can technically fail for various reasons, but + * there isn't much recourse if this call fails. Just log + * the failure for debugging. + * + * POSIX also does not specify the state of the filehandle + * after a close() with an error. + * + * At least in Linux/glibc the filehandle is always closed + * in the kernel and should not be used again or re-closed. + */ + OS_DEBUG("close: %s\n", strerror(errno)); + } + OS_impl_filehandle_table[local_id].fd = -1; + return OS_SUCCESS; } /* end OS_GenericClose_Impl */ /*---------------------------------------------------------------- @@ -100,51 +98,51 @@ int32 OS_GenericClose_Impl(uint32 local_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_GenericSeek_Impl (uint32 local_id, int32 offset, uint32 whence) +int32 OS_GenericSeek_Impl(uint32 local_id, int32 offset, uint32 whence) { - int where; - int32 result; - - switch(whence) - { - case OS_SEEK_SET: - where = SEEK_SET; - break; - case OS_SEEK_CUR: - where = SEEK_CUR; - break; - case OS_SEEK_END: - where = SEEK_END; - break; - default: - return OS_ERROR; - } - - result = lseek(OS_impl_filehandle_table[local_id].fd, (off_t)offset, where); - if (result < 0) - { - if (errno == ESPIPE) - { - /* - * this means the user tried to seek on a pipe, socket, - * or other fifo-like handle that doesn't support seeking. - * - * Use a different error code to differentiate from an - * error involving a bad whence/offset - */ - result = OS_ERR_NOT_IMPLEMENTED; - } - else - { - /* - * Most likely the "whence" and/or "offset" combo was not valid. - */ - OS_DEBUG("lseek: %s\n",strerror(errno)); - result = OS_ERROR; - } - } - - return result; + int where; + int32 result; + + switch (whence) + { + case OS_SEEK_SET: + where = SEEK_SET; + break; + case OS_SEEK_CUR: + where = SEEK_CUR; + break; + case OS_SEEK_END: + where = SEEK_END; + break; + default: + return OS_ERROR; + } + + result = lseek(OS_impl_filehandle_table[local_id].fd, (off_t)offset, where); + if (result < 0) + { + if (errno == ESPIPE) + { + /* + * this means the user tried to seek on a pipe, socket, + * or other fifo-like handle that doesn't support seeking. + * + * Use a different error code to differentiate from an + * error involving a bad whence/offset + */ + result = OS_ERR_NOT_IMPLEMENTED; + } + else + { + /* + * Most likely the "whence" and/or "offset" combo was not valid. + */ + OS_DEBUG("lseek: %s\n", strerror(errno)); + result = OS_ERROR; + } + } + + return result; } /* end OS_GenericSeek_Impl */ /*---------------------------------------------------------------- @@ -155,47 +153,47 @@ int32 OS_GenericSeek_Impl (uint32 local_id, int32 offset, uint32 whence) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_GenericRead_Impl (uint32 local_id, void *buffer, uint32 nbytes, int32 timeout) +int32 OS_GenericRead_Impl(uint32 local_id, void *buffer, uint32 nbytes, int32 timeout) { - int32 return_code; - int os_result; - uint32 operation; - - return_code = OS_SUCCESS; - - if (nbytes > 0) - { - operation = OS_STREAM_STATE_READABLE; - - /* - * If filehandle is set with O_NONBLOCK, then must call select() here. - * - * The "selectable" field should be set false for those file handles - * which the underlying OS does not support select() on. - * - * Note that a timeout will not work unless selectable is true. - */ - if (OS_impl_filehandle_table[local_id].selectable) - { - return_code = OS_SelectSingle_Impl(local_id, &operation, timeout); - } - - if (return_code == OS_SUCCESS && (operation & OS_STREAM_STATE_READABLE) != 0) - { - os_result = read(OS_impl_filehandle_table[local_id].fd, buffer, nbytes); - if (os_result < 0) - { - OS_DEBUG("read: %s\n",strerror(errno)); - return_code = OS_ERROR; - } - else - { - return_code = os_result; - } - } - } - - return (return_code); + int32 return_code; + int os_result; + uint32 operation; + + return_code = OS_SUCCESS; + + if (nbytes > 0) + { + operation = OS_STREAM_STATE_READABLE; + + /* + * If filehandle is set with O_NONBLOCK, then must call select() here. + * + * The "selectable" field should be set false for those file handles + * which the underlying OS does not support select() on. + * + * Note that a timeout will not work unless selectable is true. + */ + if (OS_impl_filehandle_table[local_id].selectable) + { + return_code = OS_SelectSingle_Impl(local_id, &operation, timeout); + } + + if (return_code == OS_SUCCESS && (operation & OS_STREAM_STATE_READABLE) != 0) + { + os_result = read(OS_impl_filehandle_table[local_id].fd, buffer, nbytes); + if (os_result < 0) + { + OS_DEBUG("read: %s\n", strerror(errno)); + return_code = OS_ERROR; + } + else + { + return_code = os_result; + } + } + } + + return (return_code); } /* end OS_GenericRead_Impl */ /*---------------------------------------------------------------- @@ -208,47 +206,45 @@ int32 OS_GenericRead_Impl (uint32 local_id, void *buffer, uint32 nbytes, int32 t *-----------------------------------------------------------------*/ int32 OS_GenericWrite_Impl(uint32 local_id, const void *buffer, uint32 nbytes, int32 timeout) { - int32 return_code; - int os_result; - uint32 operation; - - return_code = OS_SUCCESS; - - if (nbytes > 0) - { - operation = OS_STREAM_STATE_WRITABLE; - - /* - * If filehandle is set with O_NONBLOCK, then must call select() here. - * - * The "selectable" field should be set false for those file handles - * which the underlying OS does not support select() on. - * - * Note that a timeout will not work unless selectable is true. - */ - if (OS_impl_filehandle_table[local_id].selectable) - { - return_code = OS_SelectSingle_Impl(local_id, &operation, timeout); - } - - if (return_code == OS_SUCCESS && (operation & OS_STREAM_STATE_WRITABLE) != 0) - { - /* on some system libraries for which the write() argument is not - * qualified correctly, it needs to be case to a void* here */ - os_result = write(OS_impl_filehandle_table[local_id].fd, - GENERIC_IO_CONST_DATA_CAST buffer, nbytes); - if (os_result < 0) - { - OS_DEBUG("write: %s\n",strerror(errno)); - return_code = OS_ERROR; - } - else - { - return_code = os_result; - } - } - } - - return (return_code); + int32 return_code; + int os_result; + uint32 operation; + + return_code = OS_SUCCESS; + + if (nbytes > 0) + { + operation = OS_STREAM_STATE_WRITABLE; + + /* + * If filehandle is set with O_NONBLOCK, then must call select() here. + * + * The "selectable" field should be set false for those file handles + * which the underlying OS does not support select() on. + * + * Note that a timeout will not work unless selectable is true. + */ + if (OS_impl_filehandle_table[local_id].selectable) + { + return_code = OS_SelectSingle_Impl(local_id, &operation, timeout); + } + + if (return_code == OS_SUCCESS && (operation & OS_STREAM_STATE_WRITABLE) != 0) + { + /* on some system libraries for which the write() argument is not + * qualified correctly, it needs to be case to a void* here */ + os_result = write(OS_impl_filehandle_table[local_id].fd, GENERIC_IO_CONST_DATA_CAST buffer, nbytes); + if (os_result < 0) + { + OS_DEBUG("write: %s\n", strerror(errno)); + return_code = OS_ERROR; + } + else + { + return_code = os_result; + } + } + } + + return (return_code); } /* end OS_GenericWrite_Impl */ - diff --git a/src/os/portable/os-impl-posix-network.c b/src/os/portable/os-impl-posix-network.c index 29a254267..bd114b645 100644 --- a/src/os/portable/os-impl-posix-network.c +++ b/src/os/portable/os-impl-posix-network.c @@ -58,11 +58,11 @@ * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_NetworkGetHostName_Impl (char *host_name, uint32 name_len) +int32 OS_NetworkGetHostName_Impl(char *host_name, uint32 name_len) { int32 return_code; - if ( gethostname(host_name, name_len) < 0 ) + if (gethostname(host_name, name_len) < 0) { return_code = OS_ERROR; } @@ -73,14 +73,12 @@ int32 OS_NetworkGetHostName_Impl (char *host_name, uint32 name_len) * null terminated, so its worthwhile to ensure it */ host_name[name_len - 1] = 0; - return_code = OS_SUCCESS; + return_code = OS_SUCCESS; } - return(return_code); + return (return_code); } /* end OS_NetworkGetHostName_Impl */ - - /*---------------------------------------------------------------- * * Function: OS_NetworkGetID_Impl @@ -89,11 +87,9 @@ int32 OS_NetworkGetHostName_Impl (char *host_name, uint32 name_len) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_NetworkGetID_Impl (int32 *IdBuf) +int32 OS_NetworkGetID_Impl(int32 *IdBuf) { /* gethostid() has no failure modes */ *IdBuf = gethostid(); return OS_SUCCESS; } /* end OS_NetworkGetID_Impl */ - - diff --git a/src/os/posix/inc/os-impl-binsem.h b/src/os/posix/inc/os-impl-binsem.h index 5bd607fb4..41bb54870 100644 --- a/src/os/posix/inc/os-impl-binsem.h +++ b/src/os/posix/inc/os-impl-binsem.h @@ -35,16 +35,13 @@ /* Binary Semaphores */ typedef struct { - pthread_mutex_t id; - pthread_cond_t cv; - volatile sig_atomic_t flush_request; - volatile sig_atomic_t current_value; + pthread_mutex_t id; + pthread_cond_t cv; + volatile sig_atomic_t flush_request; + volatile sig_atomic_t current_value; } OS_impl_binsem_internal_record_t; /* Tables where the OS object information is stored */ -extern OS_impl_binsem_internal_record_t OS_impl_bin_sem_table [OS_MAX_BIN_SEMAPHORES]; - - - -#endif /* INCLUDE_OS_IMPL_BINSEM_H_ */ +extern OS_impl_binsem_internal_record_t OS_impl_bin_sem_table[OS_MAX_BIN_SEMAPHORES]; +#endif /* INCLUDE_OS_IMPL_BINSEM_H_ */ diff --git a/src/os/posix/inc/os-impl-console.h b/src/os/posix/inc/os-impl-console.h index 84c193edb..82a65ee28 100644 --- a/src/os/posix/inc/os-impl-console.h +++ b/src/os/posix/inc/os-impl-console.h @@ -36,13 +36,10 @@ /* Console device */ typedef struct { - bool is_async; - sem_t data_sem; -}OS_impl_console_internal_record_t; + bool is_async; + sem_t data_sem; +} OS_impl_console_internal_record_t; +extern OS_impl_console_internal_record_t OS_impl_console_table[OS_MAX_CONSOLES]; -extern OS_impl_console_internal_record_t OS_impl_console_table [OS_MAX_CONSOLES]; - - -#endif /* INCLUDE_OS_IMPL_CONSOLE_H_ */ - +#endif /* INCLUDE_OS_IMPL_CONSOLE_H_ */ diff --git a/src/os/posix/inc/os-impl-countsem.h b/src/os/posix/inc/os-impl-countsem.h index 463f91eb3..9c8c2f5e6 100644 --- a/src/os/posix/inc/os-impl-countsem.h +++ b/src/os/posix/inc/os-impl-countsem.h @@ -33,12 +33,10 @@ typedef struct { - sem_t id; + sem_t id; } OS_impl_countsem_internal_record_t; /* Tables where the OS object information is stored */ -extern OS_impl_countsem_internal_record_t OS_impl_count_sem_table [OS_MAX_COUNT_SEMAPHORES]; - - -#endif /* INCLUDE_OS_IMPL_COUNTSEM_H_ */ +extern OS_impl_countsem_internal_record_t OS_impl_count_sem_table[OS_MAX_COUNT_SEMAPHORES]; +#endif /* INCLUDE_OS_IMPL_COUNTSEM_H_ */ diff --git a/src/os/posix/inc/os-impl-dirs.h b/src/os/posix/inc/os-impl-dirs.h index 72bd84ed9..787bb5220 100644 --- a/src/os/posix/inc/os-impl-dirs.h +++ b/src/os/posix/inc/os-impl-dirs.h @@ -40,13 +40,9 @@ typedef struct DIR *dp; } OS_impl_dir_internal_record_t; - /* * The directory handle table. */ extern OS_impl_dir_internal_record_t OS_impl_dir_table[OS_MAX_NUM_OPEN_DIRS]; - - -#endif /* INCLUDE_OS_IMPL_DIRS_H_ */ - +#endif /* INCLUDE_OS_IMPL_DIRS_H_ */ diff --git a/src/os/posix/inc/os-impl-files.h b/src/os/posix/inc/os-impl-files.h index 797a2b60a..fb098aecd 100644 --- a/src/os/posix/inc/os-impl-files.h +++ b/src/os/posix/inc/os-impl-files.h @@ -34,7 +34,6 @@ #include #include - /* * These two constants (EUID and EGID) are local cache of the * euid and egid of the user running the OSAL application. They @@ -47,8 +46,6 @@ extern uid_t OS_IMPL_SELF_EUID; extern gid_t OS_IMPL_SELF_EGID; - extern const int OS_IMPL_REGULAR_FILE_FLAGS; -#endif /* INCLUDE_OS_IMPL_FILES_H_ */ - +#endif /* INCLUDE_OS_IMPL_FILES_H_ */ diff --git a/src/os/posix/inc/os-impl-gettime.h b/src/os/posix/inc/os-impl-gettime.h index 3d4d01acb..491bd27db 100644 --- a/src/os/posix/inc/os-impl-gettime.h +++ b/src/os/posix/inc/os-impl-gettime.h @@ -31,9 +31,6 @@ #include #include +#define OSAL_GETTIME_SOURCE_CLOCK CLOCK_MONOTONIC -#define OSAL_GETTIME_SOURCE_CLOCK CLOCK_MONOTONIC - - -#endif /* INCLUDE_OS_IMPL_GETTIME_H_ */ - +#endif /* INCLUDE_OS_IMPL_GETTIME_H_ */ diff --git a/src/os/posix/inc/os-impl-io.h b/src/os/posix/inc/os-impl-io.h index 603ba15e3..a6154b8ca 100644 --- a/src/os/posix/inc/os-impl-io.h +++ b/src/os/posix/inc/os-impl-io.h @@ -37,7 +37,7 @@ typedef struct { - int fd; + int fd; bool selectable; } OS_Posix_file_internal_record_t; @@ -48,7 +48,4 @@ typedef struct */ extern OS_Posix_file_internal_record_t OS_impl_filehandle_table[OS_MAX_NUM_OPEN_FILES]; - - -#endif /* INCLUDE_OS_IMPL_IO_H_ */ - +#endif /* INCLUDE_OS_IMPL_IO_H_ */ diff --git a/src/os/posix/inc/os-impl-loader.h b/src/os/posix/inc/os-impl-loader.h index 8c70e6f39..d98a72883 100644 --- a/src/os/posix/inc/os-impl-loader.h +++ b/src/os/posix/inc/os-impl-loader.h @@ -52,5 +52,4 @@ typedef struct */ extern OS_impl_module_internal_record_t OS_impl_module_table[OS_MAX_MODULES]; -#endif /* INCLUDE_OS_IMPL_LOADER_H_ */ - +#endif /* INCLUDE_OS_IMPL_LOADER_H_ */ diff --git a/src/os/posix/inc/os-impl-mutex.h b/src/os/posix/inc/os-impl-mutex.h index c8413d5e0..f3014c449 100644 --- a/src/os/posix/inc/os-impl-mutex.h +++ b/src/os/posix/inc/os-impl-mutex.h @@ -38,8 +38,6 @@ typedef struct } OS_impl_mutex_internal_record_t; /* Tables where the OS object information is stored */ -extern OS_impl_mutex_internal_record_t OS_impl_mutex_table [OS_MAX_MUTEXES]; - - -#endif /* INCLUDE_OS_IMPL_MUTEX_H_ */ +extern OS_impl_mutex_internal_record_t OS_impl_mutex_table[OS_MAX_MUTEXES]; +#endif /* INCLUDE_OS_IMPL_MUTEX_H_ */ diff --git a/src/os/posix/inc/os-impl-network.h b/src/os/posix/inc/os-impl-network.h index 380c97066..6a912471c 100644 --- a/src/os/posix/inc/os-impl-network.h +++ b/src/os/posix/inc/os-impl-network.h @@ -30,6 +30,4 @@ #include - -#endif /* INCLUDE_OS_IMPL_NETWORK_H_ */ - +#endif /* INCLUDE_OS_IMPL_NETWORK_H_ */ diff --git a/src/os/posix/inc/os-impl-queues.h b/src/os/posix/inc/os-impl-queues.h index d909c16bc..4f92150ca 100644 --- a/src/os/posix/inc/os-impl-queues.h +++ b/src/os/posix/inc/os-impl-queues.h @@ -38,8 +38,6 @@ typedef struct } OS_impl_queue_internal_record_t; /* Tables where the OS object information is stored */ -extern OS_impl_queue_internal_record_t OS_impl_queue_table [OS_MAX_QUEUES]; - - -#endif /* INCLUDE_OS_IMPL_QUEUES_H_ */ +extern OS_impl_queue_internal_record_t OS_impl_queue_table[OS_MAX_QUEUES]; +#endif /* INCLUDE_OS_IMPL_QUEUES_H_ */ diff --git a/src/os/posix/inc/os-impl-select.h b/src/os/posix/inc/os-impl-select.h index 8d708f985..9b6cc8c34 100644 --- a/src/os/posix/inc/os-impl-select.h +++ b/src/os/posix/inc/os-impl-select.h @@ -33,6 +33,4 @@ #include #include - -#endif /* INCLUDE_OS_IMPL_SELECT_H_ */ - +#endif /* INCLUDE_OS_IMPL_SELECT_H_ */ diff --git a/src/os/posix/inc/os-impl-sockets.h b/src/os/posix/inc/os-impl-sockets.h index bc5239ee5..bf93418b6 100644 --- a/src/os/posix/inc/os-impl-sockets.h +++ b/src/os/posix/inc/os-impl-sockets.h @@ -35,16 +35,12 @@ #include #include - #define OS_NETWORK_SUPPORTS_IPV6 /* * A full POSIX-compliant I/O layer should support using * nonblocking I/O calls in combination with select(). */ -#define OS_IMPL_SOCKET_FLAGS O_NONBLOCK - - - -#endif /* INCLUDE_OS_IMPL_SOCKETS_H_ */ +#define OS_IMPL_SOCKET_FLAGS O_NONBLOCK +#endif /* INCLUDE_OS_IMPL_SOCKETS_H_ */ diff --git a/src/os/posix/inc/os-impl-tasks.h b/src/os/posix/inc/os-impl-tasks.h index 2626c3922..0c8eef544 100644 --- a/src/os/posix/inc/os-impl-tasks.h +++ b/src/os/posix/inc/os-impl-tasks.h @@ -37,10 +37,7 @@ typedef struct pthread_t id; } OS_impl_task_internal_record_t; - /* Tables where the OS object information is stored */ -extern OS_impl_task_internal_record_t OS_impl_task_table [OS_MAX_TASKS]; - - -#endif /* INCLUDE_OS_IMPL_TASKS_H_ */ +extern OS_impl_task_internal_record_t OS_impl_task_table[OS_MAX_TASKS]; +#endif /* INCLUDE_OS_IMPL_TASKS_H_ */ diff --git a/src/os/posix/inc/os-impl-timebase.h b/src/os/posix/inc/os-impl-timebase.h index 4829e6ab9..edd1a4c87 100644 --- a/src/os/posix/inc/os-impl-timebase.h +++ b/src/os/posix/inc/os-impl-timebase.h @@ -32,16 +32,15 @@ #include #include - typedef struct { - pthread_t handler_thread; - pthread_mutex_t handler_mutex; - timer_t host_timerid; - int assigned_signal; - sigset_t sigset; - sig_atomic_t reset_flag; - struct timespec softsleep; + pthread_t handler_thread; + pthread_mutex_t handler_mutex; + timer_t host_timerid; + int assigned_signal; + sigset_t sigset; + sig_atomic_t reset_flag; + struct timespec softsleep; } OS_impl_timebase_internal_record_t; @@ -51,6 +50,4 @@ typedef struct extern OS_impl_timebase_internal_record_t OS_impl_timebase_table[OS_MAX_TIMEBASES]; - -#endif /* INCLUDE_OS_IMPL_TIMEBASE_H_ */ - +#endif /* INCLUDE_OS_IMPL_TIMEBASE_H_ */ diff --git a/src/os/posix/inc/os-posix.h b/src/os/posix/inc/os-posix.h index 79e4a009a..965ba58f5 100644 --- a/src/os/posix/inc/os-posix.h +++ b/src/os/posix/inc/os-posix.h @@ -31,7 +31,6 @@ #ifndef INCLUDE_OS_POSIX_H_ #define INCLUDE_OS_POSIX_H_ - /**************************************************************************************** COMMON INCLUDE FILES ***************************************************************************************/ @@ -64,35 +63,33 @@ TYPEDEFS ***************************************************************************************/ -typedef void * (*PthreadFuncPtr_t)(void *arg); +typedef void *(*PthreadFuncPtr_t)(void *arg); typedef struct { - int PriorityMax; - int PriorityMin; + int PriorityMax; + int PriorityMin; } POSIX_PriorityLimits_t; typedef struct { - bool EnableTaskPriorities; - uint32 TruncateQueueDepth; - uint32 ClockAccuracyNsec; - pthread_key_t ThreadKey; - sigset_t MaximumSigMask; - sigset_t NormalSigMask; - size_t PageSize; - POSIX_PriorityLimits_t PriLimits; - int SelectedRtScheduler; + bool EnableTaskPriorities; + uint32 TruncateQueueDepth; + uint32 ClockAccuracyNsec; + pthread_key_t ThreadKey; + sigset_t MaximumSigMask; + sigset_t NormalSigMask; + size_t PageSize; + POSIX_PriorityLimits_t PriLimits; + int SelectedRtScheduler; } POSIX_GlobalVars_t; - /**************************************************************************************** GLOBAL DATA ***************************************************************************************/ extern POSIX_GlobalVars_t POSIX_GlobalVars; - /**************************************************************************************** POSIX IMPLEMENTATION FUNCTION PROTOTYPES ***************************************************************************************/ @@ -110,9 +107,8 @@ int32 OS_Posix_FileSysAPI_Impl_Init(void); int32 OS_Posix_TableMutex_Init(uint32 idtype); -int32 OS_Posix_InternalTaskCreate_Impl (pthread_t *pthr, uint32 priority, size_t stacksz, PthreadFuncPtr_t entry, void *entry_arg); -void OS_Posix_CompAbsDelayTime( uint32 msecs , struct timespec * tm); - - -#endif /* INCLUDE_OS_POSIX_H_ */ +int32 OS_Posix_InternalTaskCreate_Impl(pthread_t *pthr, uint32 priority, size_t stacksz, PthreadFuncPtr_t entry, + void *entry_arg); +void OS_Posix_CompAbsDelayTime(uint32 msecs, struct timespec *tm); +#endif /* INCLUDE_OS_POSIX_H_ */ diff --git a/src/os/posix/src/os-impl-binsem.c b/src/os/posix/src/os-impl-binsem.c index 0aff787c7..6e27cbb41 100644 --- a/src/os/posix/src/os-impl-binsem.c +++ b/src/os/posix/src/os-impl-binsem.c @@ -48,11 +48,10 @@ * not be relevant in a normally operating system. This only prevents a * deadlock condition in off-nominal circumstances. */ -#define OS_POSIX_BINSEM_MAX_WAIT_SECONDS 2 - +#define OS_POSIX_BINSEM_MAX_WAIT_SECONDS 2 /* Tables where the OS object information is stored */ -OS_impl_binsem_internal_record_t OS_impl_bin_sem_table [OS_MAX_BIN_SEMAPHORES]; +OS_impl_binsem_internal_record_t OS_impl_bin_sem_table[OS_MAX_BIN_SEMAPHORES]; /*--------------------------------------------------------------------------------------- * Helper function for acquiring the mutex when beginning a binary sem operation @@ -107,11 +106,10 @@ void OS_Posix_BinSemReleaseMutex(void *mut) ----------------------------------------------------------------------------------------*/ int32 OS_Posix_BinSemAPI_Impl_Init(void) { - memset(OS_impl_bin_sem_table, 0, sizeof(OS_impl_bin_sem_table)); - return OS_SUCCESS; + memset(OS_impl_bin_sem_table, 0, sizeof(OS_impl_bin_sem_table)); + return OS_SUCCESS; } /* end OS_Posix_BinSemAPI_Impl_Init */ - /*---------------------------------------------------------------- * * Function: OS_BinSemCreate_Impl @@ -120,14 +118,14 @@ int32 OS_Posix_BinSemAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemCreate_Impl (uint32 sem_id, uint32 initial_value, uint32 options) +int32 OS_BinSemCreate_Impl(uint32 sem_id, uint32 initial_value, uint32 options) { - int ret; - int attr_created; - int mutex_created; - int cond_created; - int32 return_code; - pthread_mutexattr_t mutex_attr; + int ret; + int attr_created; + int mutex_created; + int cond_created; + int32 return_code; + pthread_mutexattr_t mutex_attr; OS_impl_binsem_internal_record_t *sem; /* @@ -135,16 +133,16 @@ int32 OS_BinSemCreate_Impl (uint32 sem_id, uint32 initial_value, uint32 options) * if the initial value is greater than 1 it just silently used 1 without error. * (by contrast the counting semaphore will return an error) */ - if ( initial_value > 1 ) + if (initial_value > 1) { initial_value = 1; } - attr_created = 0; + attr_created = 0; mutex_created = 0; - cond_created = 0; - sem = &OS_impl_bin_sem_table[sem_id]; - memset(sem, 0, sizeof (*sem)); + cond_created = 0; + sem = &OS_impl_bin_sem_table[sem_id]; + memset(sem, 0, sizeof(*sem)); do { @@ -154,7 +152,7 @@ int32 OS_BinSemCreate_Impl (uint32 sem_id, uint32 initial_value, uint32 options) ret = pthread_mutexattr_init(&mutex_attr); if (ret != 0) { - OS_DEBUG("Error: pthread_mutexattr_init failed: %s\n",strerror(ret)); + OS_DEBUG("Error: pthread_mutexattr_init failed: %s\n", strerror(ret)); return_code = OS_SEM_FAILURE; break; } @@ -165,10 +163,10 @@ int32 OS_BinSemCreate_Impl (uint32 sem_id, uint32 initial_value, uint32 options) /* ** Use priority inheritance */ - ret = pthread_mutexattr_setprotocol(&mutex_attr,PTHREAD_PRIO_INHERIT); + ret = pthread_mutexattr_setprotocol(&mutex_attr, PTHREAD_PRIO_INHERIT); if (ret != 0) { - OS_DEBUG("Error: pthread_mutexattr_setprotocol failed: %s\n",strerror(ret)); + OS_DEBUG("Error: pthread_mutexattr_setprotocol failed: %s\n", strerror(ret)); return_code = OS_SEM_FAILURE; break; } @@ -177,9 +175,9 @@ int32 OS_BinSemCreate_Impl (uint32 sem_id, uint32 initial_value, uint32 options) ** Initialize the mutex that is used with the condition variable */ ret = pthread_mutex_init(&(sem->id), &mutex_attr); - if (ret != 0) + if (ret != 0) { - OS_DEBUG("Error: pthread_mutex_init failed: %s\n",strerror(ret)); + OS_DEBUG("Error: pthread_mutex_init failed: %s\n", strerror(ret)); return_code = OS_SEM_FAILURE; break; } @@ -192,7 +190,7 @@ int32 OS_BinSemCreate_Impl (uint32 sem_id, uint32 initial_value, uint32 options) ret = pthread_cond_init(&(sem->cv), NULL); if (ret != 0) { - OS_DEBUG("Error: pthread_cond_init failed: %s\n",strerror(ret)); + OS_DEBUG("Error: pthread_cond_init failed: %s\n", strerror(ret)); return_code = OS_SEM_FAILURE; break; } @@ -206,8 +204,7 @@ int32 OS_BinSemCreate_Impl (uint32 sem_id, uint32 initial_value, uint32 options) sem->current_value = initial_value; return_code = OS_SUCCESS; - } - while (0); + } while (0); /* Clean up resources if the operation failed */ if (return_code != OS_SUCCESS) @@ -235,7 +232,6 @@ int32 OS_BinSemCreate_Impl (uint32 sem_id, uint32 initial_value, uint32 options) } /* end OS_BinSemCreate_Impl */ - /*---------------------------------------------------------------- * * Function: OS_BinSemDelete_Impl @@ -244,39 +240,37 @@ int32 OS_BinSemCreate_Impl (uint32 sem_id, uint32 initial_value, uint32 options) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemDelete_Impl (uint32 sem_id) +int32 OS_BinSemDelete_Impl(uint32 sem_id) { OS_impl_binsem_internal_record_t *sem; - int32 return_code; + int32 return_code; sem = &OS_impl_bin_sem_table[sem_id]; if (pthread_cond_destroy(&(sem->cv)) != 0) { - /* sem could be busy, i.e. some task is pending on it already. - * that means it cannot be deleted at this time. */ - return_code = OS_SEM_FAILURE; + /* sem could be busy, i.e. some task is pending on it already. + * that means it cannot be deleted at this time. */ + return_code = OS_SEM_FAILURE; } else { - /* Now that the CV is destroyed this sem is unusable, - * so we must do our best to clean everything else. Even if cleanup - * does not fully work, returning anything other than OS_SUCCESS would - * suggest to the caller that the sem is still usable which it is not. - */ - return_code = OS_SUCCESS; - - /* destroy the associated mutex -- - * Note that this might fail if the mutex is locked, - * but there is no sane way to recover from that (see above). */ - pthread_mutex_destroy(&(sem->id)); + /* Now that the CV is destroyed this sem is unusable, + * so we must do our best to clean everything else. Even if cleanup + * does not fully work, returning anything other than OS_SUCCESS would + * suggest to the caller that the sem is still usable which it is not. + */ + return_code = OS_SUCCESS; + + /* destroy the associated mutex -- + * Note that this might fail if the mutex is locked, + * but there is no sane way to recover from that (see above). */ + pthread_mutex_destroy(&(sem->id)); } return return_code; } /* end OS_BinSemDelete_Impl */ - - /*---------------------------------------------------------------- * * Function: OS_BinSemGive_Impl @@ -285,7 +279,7 @@ int32 OS_BinSemDelete_Impl (uint32 sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemGive_Impl ( uint32 sem_id ) +int32 OS_BinSemGive_Impl(uint32 sem_id) { OS_impl_binsem_internal_record_t *sem; @@ -306,9 +300,9 @@ int32 OS_BinSemGive_Impl ( uint32 sem_id ) */ /* Lock the mutex ( not the table! ) */ - if ( OS_Posix_BinSemAcquireMutex(&sem->id) != OS_SUCCESS ) + if (OS_Posix_BinSemAcquireMutex(&sem->id) != OS_SUCCESS) { - return(OS_SEM_FAILURE); + return (OS_SEM_FAILURE); } /* Binary semaphores are always set as "1" when given */ @@ -322,7 +316,6 @@ int32 OS_BinSemGive_Impl ( uint32 sem_id ) return OS_SUCCESS; } /* end OS_BinSemGive_Impl */ - /*---------------------------------------------------------------- * * Function: OS_BinSemFlush_Impl @@ -331,16 +324,16 @@ int32 OS_BinSemGive_Impl ( uint32 sem_id ) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemFlush_Impl (uint32 sem_id) +int32 OS_BinSemFlush_Impl(uint32 sem_id) { OS_impl_binsem_internal_record_t *sem; sem = &OS_impl_bin_sem_table[sem_id]; /* Lock the mutex ( not the table! ) */ - if ( OS_Posix_BinSemAcquireMutex(&sem->id) != OS_SUCCESS ) + if (OS_Posix_BinSemAcquireMutex(&sem->id) != OS_SUCCESS) { - return(OS_SEM_FAILURE); + return (OS_SEM_FAILURE); } /* increment the flush counter. Any other threads that are @@ -365,81 +358,80 @@ int32 OS_BinSemFlush_Impl (uint32 sem_id) becomes nonzero (via SemGive) or the semaphore gets flushed. ---------------------------------------------------------------------------------------*/ -static int32 OS_GenericBinSemTake_Impl (OS_impl_binsem_internal_record_t *sem, const struct timespec *timeout) +static int32 OS_GenericBinSemTake_Impl(OS_impl_binsem_internal_record_t *sem, const struct timespec *timeout) { - sig_atomic_t flush_count; - int32 return_code; - - /* - * Note - this lock should be quickly available - should not delay here. - * The main delay is in the pthread_cond_wait() below. - */ - /* Lock the mutex ( not the table! ) */ - if ( OS_Posix_BinSemAcquireMutex(&sem->id) != OS_SUCCESS ) - { - return(OS_SEM_FAILURE); - } - - /* because pthread_cond_wait() is also a cancellation point, - * this uses a cleanup handler to ensure that if canceled during this call, - * the mutex is also released */ - pthread_cleanup_push(OS_Posix_BinSemReleaseMutex, &sem->id); - - return_code = OS_SUCCESS; - - /* - * Note that for vxWorks compatibility, we need to stop pending on the semaphore - * and return from this function under two possible circumstances: - * - * a) the semaphore count was nonzero (may be pre-existing or due to a give) - * this is the normal case, we should decrement the count by 1 and return. - * b) the semaphore got "flushed" - * in this case ALL tasks are un-blocked and we do NOT decrement the count. - */ - - /* - * first take a local snapshot of the flush request counter, - * if it changes, we know that someone else called SemFlush. - */ - flush_count = sem->flush_request; - - /* Note - the condition must be checked in a while loop because - * even if pthread_cond_wait() returns, it does NOT guarantee that - * the condition we are looking for has been met. - * - * Also if the current_value is already nonzero we will not wait. - */ - while ( sem->current_value == 0 && sem->flush_request == flush_count ) - { - /* Must pend until something changes */ - if (timeout == NULL) - { - /* wait forever */ - pthread_cond_wait(&(sem->cv),&(sem->id)); - } - else if (pthread_cond_timedwait(&(sem->cv),&(sem->id),timeout) == ETIMEDOUT) - { - return_code = OS_SEM_TIMEOUT; - break; - } - } - - /* If the flush counter did not change, set the value to zero */ - if (return_code == OS_SUCCESS && sem->flush_request == flush_count) - { - sem->current_value = 0; - } - - /* - * Pop the cleanup handler. - * Passing "true" means it will be executed, which - * handles releasing the mutex. - */ - pthread_cleanup_pop(true); - - return return_code; -} /* end OS_GenericBinSemTake_Impl */ + sig_atomic_t flush_count; + int32 return_code; + + /* + * Note - this lock should be quickly available - should not delay here. + * The main delay is in the pthread_cond_wait() below. + */ + /* Lock the mutex ( not the table! ) */ + if (OS_Posix_BinSemAcquireMutex(&sem->id) != OS_SUCCESS) + { + return (OS_SEM_FAILURE); + } + + /* because pthread_cond_wait() is also a cancellation point, + * this uses a cleanup handler to ensure that if canceled during this call, + * the mutex is also released */ + pthread_cleanup_push(OS_Posix_BinSemReleaseMutex, &sem->id); + + return_code = OS_SUCCESS; + + /* + * Note that for vxWorks compatibility, we need to stop pending on the semaphore + * and return from this function under two possible circumstances: + * + * a) the semaphore count was nonzero (may be pre-existing or due to a give) + * this is the normal case, we should decrement the count by 1 and return. + * b) the semaphore got "flushed" + * in this case ALL tasks are un-blocked and we do NOT decrement the count. + */ + /* + * first take a local snapshot of the flush request counter, + * if it changes, we know that someone else called SemFlush. + */ + flush_count = sem->flush_request; + + /* Note - the condition must be checked in a while loop because + * even if pthread_cond_wait() returns, it does NOT guarantee that + * the condition we are looking for has been met. + * + * Also if the current_value is already nonzero we will not wait. + */ + while (sem->current_value == 0 && sem->flush_request == flush_count) + { + /* Must pend until something changes */ + if (timeout == NULL) + { + /* wait forever */ + pthread_cond_wait(&(sem->cv), &(sem->id)); + } + else if (pthread_cond_timedwait(&(sem->cv), &(sem->id), timeout) == ETIMEDOUT) + { + return_code = OS_SEM_TIMEOUT; + break; + } + } + + /* If the flush counter did not change, set the value to zero */ + if (return_code == OS_SUCCESS && sem->flush_request == flush_count) + { + sem->current_value = 0; + } + + /* + * Pop the cleanup handler. + * Passing "true" means it will be executed, which + * handles releasing the mutex. + */ + pthread_cleanup_pop(true); + + return return_code; +} /* end OS_GenericBinSemTake_Impl */ /*---------------------------------------------------------------- * @@ -449,12 +441,11 @@ static int32 OS_GenericBinSemTake_Impl (OS_impl_binsem_internal_record_t *sem, c * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemTake_Impl ( uint32 sem_id ) +int32 OS_BinSemTake_Impl(uint32 sem_id) { - return (OS_GenericBinSemTake_Impl (&OS_impl_bin_sem_table[sem_id], NULL)); + return (OS_GenericBinSemTake_Impl(&OS_impl_bin_sem_table[sem_id], NULL)); } /* end OS_BinSemTake_Impl */ - /*---------------------------------------------------------------- * * Function: OS_BinSemTimedWait_Impl @@ -463,19 +454,18 @@ int32 OS_BinSemTake_Impl ( uint32 sem_id ) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemTimedWait_Impl ( uint32 sem_id, uint32 msecs ) +int32 OS_BinSemTimedWait_Impl(uint32 sem_id, uint32 msecs) { - struct timespec ts; + struct timespec ts; - /* - ** Compute an absolute time for the delay - */ - OS_Posix_CompAbsDelayTime(msecs, &ts); + /* + ** Compute an absolute time for the delay + */ + OS_Posix_CompAbsDelayTime(msecs, &ts); - return (OS_GenericBinSemTake_Impl (&OS_impl_bin_sem_table[sem_id], &ts)); + return (OS_GenericBinSemTake_Impl(&OS_impl_bin_sem_table[sem_id], &ts)); } /* end OS_BinSemTimedWait_Impl */ - /*---------------------------------------------------------------- * * Function: OS_BinSemGetInfo_Impl @@ -484,10 +474,9 @@ int32 OS_BinSemTimedWait_Impl ( uint32 sem_id, uint32 msecs ) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemGetInfo_Impl (uint32 sem_id, OS_bin_sem_prop_t *sem_prop) +int32 OS_BinSemGetInfo_Impl(uint32 sem_id, OS_bin_sem_prop_t *sem_prop) { /* put the info into the stucture */ - sem_prop -> value = OS_impl_bin_sem_table[sem_id].current_value; + sem_prop->value = OS_impl_bin_sem_table[sem_id].current_value; return OS_SUCCESS; } /* end OS_BinSemGetInfo_Impl */ - diff --git a/src/os/posix/src/os-impl-common.c b/src/os/posix/src/os-impl-common.c index fce740cd1..4412dba35 100644 --- a/src/os/posix/src/os-impl-common.c +++ b/src/os/posix/src/os-impl-common.c @@ -42,9 +42,7 @@ #include "os-shared-idmap.h" #include "os-shared-errors.h" - -POSIX_GlobalVars_t POSIX_GlobalVars = { 0 }; - +POSIX_GlobalVars_t POSIX_GlobalVars = {0}; /*--------------------------------------------------------------------------------------- Name: OS_API_Impl_Init @@ -56,7 +54,7 @@ POSIX_GlobalVars_t POSIX_GlobalVars = { 0 }; ---------------------------------------------------------------------------------------*/ int32 OS_API_Impl_Init(uint32 idtype) { - int32 return_code; + int32 return_code; return_code = OS_Posix_TableMutex_Init(idtype); if (return_code != OS_SUCCESS) @@ -64,48 +62,45 @@ int32 OS_API_Impl_Init(uint32 idtype) return return_code; } - - switch(idtype) + switch (idtype) { - case OS_OBJECT_TYPE_OS_TASK: - return_code = OS_Posix_TaskAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_QUEUE: - return_code = OS_Posix_QueueAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_BINSEM: - return_code = OS_Posix_BinSemAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_COUNTSEM: - return_code = OS_Posix_CountSemAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_MUTEX: - return_code = OS_Posix_MutexAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_MODULE: - return_code = OS_Posix_ModuleAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_TIMEBASE: - return_code = OS_Posix_TimeBaseAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_STREAM: - return_code = OS_Posix_StreamAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_DIR: - return_code = OS_Posix_DirAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_FILESYS: - return_code = OS_Posix_FileSysAPI_Impl_Init(); - break; - default: - break; + case OS_OBJECT_TYPE_OS_TASK: + return_code = OS_Posix_TaskAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_QUEUE: + return_code = OS_Posix_QueueAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_BINSEM: + return_code = OS_Posix_BinSemAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_COUNTSEM: + return_code = OS_Posix_CountSemAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_MUTEX: + return_code = OS_Posix_MutexAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_MODULE: + return_code = OS_Posix_ModuleAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_TIMEBASE: + return_code = OS_Posix_TimeBaseAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_STREAM: + return_code = OS_Posix_StreamAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_DIR: + return_code = OS_Posix_DirAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_FILESYS: + return_code = OS_Posix_FileSysAPI_Impl_Init(); + break; + default: + break; } - - return(return_code); + return (return_code); } /* end OS_API_Impl_Init */ - /*---------------------------------------------------------------- * * Function: OS_IdleLoop_Impl @@ -116,18 +111,17 @@ int32 OS_API_Impl_Init(uint32 idtype) *-----------------------------------------------------------------*/ void OS_IdleLoop_Impl(void) { - /* - * Unblock signals and wait for something to occur - * - * Note - "NormalSigMask" was calculated during task init to be the original signal mask - * of the process PLUS all "RT" signals. The RT signals are used by timers, so we want - * to keep them masked here (this is different than the original POSIX impl). The - * timebase objects have a dedicated thread that will be doing "sigwait" on those. - */ - sigsuspend(&POSIX_GlobalVars.NormalSigMask); + /* + * Unblock signals and wait for something to occur + * + * Note - "NormalSigMask" was calculated during task init to be the original signal mask + * of the process PLUS all "RT" signals. The RT signals are used by timers, so we want + * to keep them masked here (this is different than the original POSIX impl). The + * timebase objects have a dedicated thread that will be doing "sigwait" on those. + */ + sigsuspend(&POSIX_GlobalVars.NormalSigMask); } /* end OS_IdleLoop_Impl */ - /*---------------------------------------------------------------- * * Function: OS_ApplicationShutdown_Impl @@ -138,11 +132,11 @@ void OS_IdleLoop_Impl(void) *-----------------------------------------------------------------*/ void OS_ApplicationShutdown_Impl(void) { - /* - * Raise a signal that is unblocked in OS_IdleLoop(), - * which should break it out of the sigsuspend() call. - */ - kill(getpid(), SIGHUP); + /* + * Raise a signal that is unblocked in OS_IdleLoop(), + * which should break it out of the sigsuspend() call. + */ + kill(getpid(), SIGHUP); } /* end OS_ApplicationShutdown_Impl */ /*---------------------------------------------------------------- @@ -156,20 +150,18 @@ void OS_ApplicationShutdown_Impl(void) * The absolute time is programmed into a struct. * *-----------------------------------------------------------------*/ -void OS_Posix_CompAbsDelayTime( uint32 msecs, struct timespec * tm) +void OS_Posix_CompAbsDelayTime(uint32 msecs, struct timespec *tm) { - clock_gettime( CLOCK_REALTIME, tm ); + clock_gettime(CLOCK_REALTIME, tm); /* add the delay to the current time */ - tm->tv_sec += (time_t) (msecs / 1000) ; + tm->tv_sec += (time_t)(msecs / 1000); /* convert residue ( msecs ) to nanoseconds */ - tm->tv_nsec += (msecs % 1000) * 1000000L ; + tm->tv_nsec += (msecs % 1000) * 1000000L; - if(tm->tv_nsec >= 1000000000L ) + if (tm->tv_nsec >= 1000000000L) { - tm->tv_nsec -= 1000000000L ; - tm->tv_sec ++ ; + tm->tv_nsec -= 1000000000L; + tm->tv_sec++; } } /* end OS_CompAbsDelayTime */ - - diff --git a/src/os/posix/src/os-impl-console.c b/src/os/posix/src/os-impl-console.c index 14b8a24c2..a97799683 100644 --- a/src/os/posix/src/os-impl-console.c +++ b/src/os/posix/src/os-impl-console.c @@ -41,13 +41,11 @@ * This option was removed from osconfig.h and now is * assumed to always be on. */ -#define OS_CONSOLE_ASYNC true -#define OS_CONSOLE_TASK_PRIORITY OS_UTILITYTASK_PRIORITY - +#define OS_CONSOLE_ASYNC true +#define OS_CONSOLE_TASK_PRIORITY OS_UTILITYTASK_PRIORITY /* Tables where the OS object information is stored */ -OS_impl_console_internal_record_t OS_impl_console_table [OS_MAX_CONSOLES]; - +OS_impl_console_internal_record_t OS_impl_console_table[OS_MAX_CONSOLES]; /********************************************************************/ /* CONSOLE OUTPUT */ @@ -61,7 +59,7 @@ OS_impl_console_internal_record_t OS_impl_console_table [OS_MAX_CONSOLES * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -void OS_ConsoleWakeup_Impl(uint32 local_id) +void OS_ConsoleWakeup_Impl(uint32 local_id) { OS_impl_console_internal_record_t *local = &OS_impl_console_table[local_id]; @@ -85,13 +83,13 @@ void OS_ConsoleWakeup_Impl(uint32 local_id) * Implements the console output task * *-----------------------------------------------------------------*/ -static void* OS_ConsoleTask_Entry(void* arg) +static void *OS_ConsoleTask_Entry(void *arg) { - OS_U32ValueWrapper_t local_arg; + OS_U32ValueWrapper_t local_arg; OS_impl_console_internal_record_t *local; local_arg.opaque_arg = arg; - local = &OS_impl_console_table[local_arg.value]; + local = &OS_impl_console_table[local_arg.value]; while (true) { OS_ConsoleOutput_Impl(local_arg.value); @@ -111,13 +109,13 @@ static void* OS_ConsoleTask_Entry(void* arg) int32 OS_ConsoleCreate_Impl(uint32 local_id) { OS_impl_console_internal_record_t *local = &OS_impl_console_table[local_id]; - pthread_t consoletask; - int32 return_code; - OS_U32ValueWrapper_t local_arg = { 0 }; + pthread_t consoletask; + int32 return_code; + OS_U32ValueWrapper_t local_arg = {0}; if (local_id == 0) { - return_code = OS_SUCCESS; + return_code = OS_SUCCESS; local->is_async = OS_CONSOLE_ASYNC; if (local->is_async) @@ -129,8 +127,8 @@ int32 OS_ConsoleCreate_Impl(uint32 local_id) else { local_arg.value = local_id; - return_code = OS_Posix_InternalTaskCreate_Impl(&consoletask, OS_CONSOLE_TASK_PRIORITY, 0, - OS_ConsoleTask_Entry, local_arg.opaque_arg); + return_code = OS_Posix_InternalTaskCreate_Impl(&consoletask, OS_CONSOLE_TASK_PRIORITY, 0, + OS_ConsoleTask_Entry, local_arg.opaque_arg); if (return_code != OS_SUCCESS) { @@ -147,4 +145,3 @@ int32 OS_ConsoleCreate_Impl(uint32 local_id) return return_code; } /* end OS_ConsoleCreate_Impl */ - diff --git a/src/os/posix/src/os-impl-countsem.c b/src/os/posix/src/os-impl-countsem.c index a5a9ab4db..22fd5cc71 100644 --- a/src/os/posix/src/os-impl-countsem.c +++ b/src/os/posix/src/os-impl-countsem.c @@ -37,12 +37,11 @@ * Added SEM_VALUE_MAX Define */ #ifndef SEM_VALUE_MAX -#define SEM_VALUE_MAX (UINT32_MAX/2) +#define SEM_VALUE_MAX (UINT32_MAX / 2) #endif /* Tables where the OS object information is stored */ -OS_impl_countsem_internal_record_t OS_impl_count_sem_table [OS_MAX_COUNT_SEMAPHORES]; - +OS_impl_countsem_internal_record_t OS_impl_count_sem_table[OS_MAX_COUNT_SEMAPHORES]; /**************************************************************************************** COUNTING SEMAPHORE API @@ -63,11 +62,10 @@ OS_impl_countsem_internal_record_t OS_impl_count_sem_table [OS_MAX_COUNT_SE ---------------------------------------------------------------------------------------*/ int32 OS_Posix_CountSemAPI_Impl_Init(void) { - memset(OS_impl_count_sem_table, 0, sizeof(OS_impl_count_sem_table)); - return OS_SUCCESS; + memset(OS_impl_count_sem_table, 0, sizeof(OS_impl_count_sem_table)); + return OS_SUCCESS; } /* end OS_Posix_CountSemAPI_Impl_Init */ - /*---------------------------------------------------------------- * * Function: OS_CountSemCreate_Impl @@ -76,7 +74,7 @@ int32 OS_Posix_CountSemAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 options) +int32 OS_CountSemCreate_Impl(uint32 sem_id, uint32 sem_initial_value, uint32 options) { if (sem_initial_value > SEM_VALUE_MAX) { @@ -92,7 +90,6 @@ int32 OS_CountSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 op } /* end OS_CountSemCreate_Impl */ - /*---------------------------------------------------------------- * * Function: OS_CountSemDelete_Impl @@ -101,7 +98,7 @@ int32 OS_CountSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 op * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemDelete_Impl (uint32 sem_id) +int32 OS_CountSemDelete_Impl(uint32 sem_id) { if (sem_destroy(&OS_impl_count_sem_table[sem_id].id) < 0) { @@ -112,7 +109,6 @@ int32 OS_CountSemDelete_Impl (uint32 sem_id) } /* end OS_CountSemDelete_Impl */ - /*---------------------------------------------------------------- * * Function: OS_CountSemGive_Impl @@ -121,7 +117,7 @@ int32 OS_CountSemDelete_Impl (uint32 sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemGive_Impl ( uint32 sem_id ) +int32 OS_CountSemGive_Impl(uint32 sem_id) { if (sem_post(&OS_impl_count_sem_table[sem_id].id) < 0) { @@ -132,7 +128,6 @@ int32 OS_CountSemGive_Impl ( uint32 sem_id ) } /* end OS_CountSemGive_Impl */ - /*---------------------------------------------------------------- * * Function: OS_CountSemTake_Impl @@ -141,7 +136,7 @@ int32 OS_CountSemGive_Impl ( uint32 sem_id ) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemTake_Impl ( uint32 sem_id ) +int32 OS_CountSemTake_Impl(uint32 sem_id) { if (sem_wait(&OS_impl_count_sem_table[sem_id].id) < 0) { @@ -151,7 +146,6 @@ int32 OS_CountSemTake_Impl ( uint32 sem_id ) return OS_SUCCESS; } /* end OS_CountSemTake_Impl */ - /*---------------------------------------------------------------- * * Function: OS_CountSemTimedWait_Impl @@ -160,33 +154,32 @@ int32 OS_CountSemTake_Impl ( uint32 sem_id ) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemTimedWait_Impl ( uint32 sem_id, uint32 msecs ) +int32 OS_CountSemTimedWait_Impl(uint32 sem_id, uint32 msecs) { - struct timespec ts; - int result; - - /* - ** Compute an absolute time for the delay - */ - OS_Posix_CompAbsDelayTime(msecs, &ts); - - if (sem_timedwait(&OS_impl_count_sem_table[sem_id].id, &ts) == 0) - { - result = OS_SUCCESS; - } - else if (errno == ETIMEDOUT) - { - result = OS_SEM_TIMEOUT; - } - else - { - /* unspecified failure */ - result = OS_SEM_FAILURE; - } - - return result; -} /* end OS_CountSemTimedWait_Impl */ + struct timespec ts; + int result; + + /* + ** Compute an absolute time for the delay + */ + OS_Posix_CompAbsDelayTime(msecs, &ts); + if (sem_timedwait(&OS_impl_count_sem_table[sem_id].id, &ts) == 0) + { + result = OS_SUCCESS; + } + else if (errno == ETIMEDOUT) + { + result = OS_SEM_TIMEOUT; + } + else + { + /* unspecified failure */ + result = OS_SEM_FAILURE; + } + + return result; +} /* end OS_CountSemTimedWait_Impl */ /*---------------------------------------------------------------- * @@ -196,7 +189,7 @@ int32 OS_CountSemTimedWait_Impl ( uint32 sem_id, uint32 msecs ) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemGetInfo_Impl (uint32 sem_id, OS_count_sem_prop_t *count_prop) +int32 OS_CountSemGetInfo_Impl(uint32 sem_id, OS_count_sem_prop_t *count_prop) { int sval; @@ -206,7 +199,6 @@ int32 OS_CountSemGetInfo_Impl (uint32 sem_id, OS_count_sem_prop_t *count_prop) } /* put the info into the stucture */ - count_prop -> value = sval; + count_prop->value = sval; return OS_SUCCESS; } /* end OS_CountSemGetInfo_Impl */ - diff --git a/src/os/posix/src/os-impl-dirs.c b/src/os/posix/src/os-impl-dirs.c index f6c2b2b21..0e5b9b644 100644 --- a/src/os/posix/src/os-impl-dirs.c +++ b/src/os/posix/src/os-impl-dirs.c @@ -62,7 +62,6 @@ OS_impl_dir_internal_record_t OS_impl_dir_table[OS_MAX_NUM_OPEN_DIRS]; ---------------------------------------------------------------------------------------*/ int32 OS_Posix_DirAPI_Impl_Init(void) { - memset(OS_impl_dir_table, 0, sizeof(OS_impl_dir_table)); - return OS_SUCCESS; + memset(OS_impl_dir_table, 0, sizeof(OS_impl_dir_table)); + return OS_SUCCESS; } /* end OS_Posix_DirAPI_Impl_Init */ - diff --git a/src/os/posix/src/os-impl-errors.c b/src/os/posix/src/os-impl-errors.c index d02f6582a..4b32d8207 100644 --- a/src/os/posix/src/os-impl-errors.c +++ b/src/os/posix/src/os-impl-errors.c @@ -33,5 +33,4 @@ #include "os-shared-errors.h" -const OS_ErrorTable_Entry_t OS_IMPL_ERROR_NAME_TABLE[] = { { 0, NULL } }; - +const OS_ErrorTable_Entry_t OS_IMPL_ERROR_NAME_TABLE[] = {{0, NULL}}; diff --git a/src/os/posix/src/os-impl-files.c b/src/os/posix/src/os-impl-files.c index e5b63dc0b..320867963 100644 --- a/src/os/posix/src/os-impl-files.c +++ b/src/os/posix/src/os-impl-files.c @@ -50,7 +50,6 @@ */ OS_Posix_file_internal_record_t OS_impl_filehandle_table[OS_MAX_NUM_OPEN_FILES]; - /* * These two constants (EUID and EGID) are local cache of the * euid and egid of the user running the OSAL application. They @@ -72,7 +71,6 @@ gid_t OS_IMPL_SELF_EGID = 0; */ const int OS_IMPL_REGULAR_FILE_FLAGS = O_NONBLOCK; - /**************************************************************************************** IMPLEMENTATION-SPECIFIC ROUTINES These are specific to this particular operating system @@ -93,7 +91,7 @@ int32 OS_Posix_StreamAPI_Impl_Init(void) * init all filehandles to -1, which is always invalid. * this isn't strictly necessary but helps when debugging. */ - for (local_id = 0; local_id < OS_MAX_NUM_OPEN_FILES; ++local_id) + for (local_id = 0; local_id < OS_MAX_NUM_OPEN_FILES; ++local_id) { OS_impl_filehandle_table[local_id].fd = -1; } @@ -103,4 +101,3 @@ int32 OS_Posix_StreamAPI_Impl_Init(void) return OS_SUCCESS; } /* end OS_Posix_StreamAPI_Impl_Init */ - diff --git a/src/os/posix/src/os-impl-filesys.c b/src/os/posix/src/os-impl-filesys.c index bd29c12f0..bd67779cb 100644 --- a/src/os/posix/src/os-impl-filesys.c +++ b/src/os/posix/src/os-impl-filesys.c @@ -29,7 +29,6 @@ INCLUDE FILES ***************************************************************************************/ - #include #include #include @@ -46,7 +45,6 @@ #include "os-posix.h" #include "os-shared-filesys.h" - /**************************************************************************************** DEFINES ***************************************************************************************/ @@ -72,12 +70,10 @@ int32 OS_Posix_FileSysAPI_Impl_Init(void) return OS_SUCCESS; } /* end OS_Posix_FileSysAPI_Impl_Init */ - /* * System Level API */ - /*---------------------------------------------------------------- * * Function: OS_FileSysStartVolume_Impl @@ -86,12 +82,12 @@ int32 OS_Posix_FileSysAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysStartVolume_Impl (uint32 filesys_id) +int32 OS_FileSysStartVolume_Impl(uint32 filesys_id) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; - struct stat stat_buf; - const char *tmpdir; - uint32 i; + OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; + struct stat stat_buf; + const char * tmpdir; + uint32 i; enum { VOLATILE_DISK_LOC_DEV_SHM, @@ -105,7 +101,7 @@ int32 OS_FileSysStartVolume_Impl (uint32 filesys_id) * Determine basic type of filesystem, if not already known */ if (local->fstype == OS_FILESYS_TYPE_UNKNOWN && - strncmp(local->device_name, OS_POSIX_DEVICEFILE_PREFIX, sizeof(OS_POSIX_DEVICEFILE_PREFIX)-1) == 0) + strncmp(local->device_name, OS_POSIX_DEVICEFILE_PREFIX, sizeof(OS_POSIX_DEVICEFILE_PREFIX) - 1) == 0) { /* * If referring to a real device in the /dev filesystem, @@ -129,37 +125,37 @@ int32 OS_FileSysStartVolume_Impl (uint32 filesys_id) if (local->fstype == OS_FILESYS_TYPE_VOLATILE_DISK) { /* find a suitable location to keep the volatile disk */ - for (i=0; i <= VOLATILE_DISK_LOC_MAX; ++i) + for (i = 0; i <= VOLATILE_DISK_LOC_MAX; ++i) { - switch(i) + switch (i) { - case VOLATILE_DISK_LOC_DEV_SHM: - /* This is most preferable because it should actually be a ramdisk */ - tmpdir = "/dev/shm"; - break; - case VOLATILE_DISK_LOC_ENV: - /* try the TMPDIR environment variable, if set */ - tmpdir = getenv("TMPDIR"); - break; - case VOLATILE_DISK_LOC_VARTMP: - /* try /var/tmp directory */ - tmpdir = "/var/tmp"; - break; - case VOLATILE_DISK_LOC_TMP: - /* use /tmp directory as a last resort */ - tmpdir = "/tmp"; - break; - default: - tmpdir = NULL; - break; + case VOLATILE_DISK_LOC_DEV_SHM: + /* This is most preferable because it should actually be a ramdisk */ + tmpdir = "/dev/shm"; + break; + case VOLATILE_DISK_LOC_ENV: + /* try the TMPDIR environment variable, if set */ + tmpdir = getenv("TMPDIR"); + break; + case VOLATILE_DISK_LOC_VARTMP: + /* try /var/tmp directory */ + tmpdir = "/var/tmp"; + break; + case VOLATILE_DISK_LOC_TMP: + /* use /tmp directory as a last resort */ + tmpdir = "/tmp"; + break; + default: + tmpdir = NULL; + break; } if (tmpdir != NULL && stat(tmpdir, &stat_buf) == 0) { /* check if the user has write permission to the directory */ - if ( (stat_buf.st_mode & S_IWOTH) != 0 || - ((stat_buf.st_mode & S_IWGRP) != 0 && stat_buf.st_gid == getegid()) || - ((stat_buf.st_mode & S_IWUSR) != 0 && stat_buf.st_uid == geteuid())) + if ((stat_buf.st_mode & S_IWOTH) != 0 || + ((stat_buf.st_mode & S_IWGRP) != 0 && stat_buf.st_gid == getegid()) || + ((stat_buf.st_mode & S_IWUSR) != 0 && stat_buf.st_uid == geteuid())) { break; } @@ -173,15 +169,13 @@ int32 OS_FileSysStartVolume_Impl (uint32 filesys_id) return OS_FS_ERR_DRIVE_NOT_CREATED; } - snprintf(local->system_mountpt, sizeof(local->system_mountpt), - "%s/osal:%s", tmpdir, local->volume_name); + snprintf(local->system_mountpt, sizeof(local->system_mountpt), "%s/osal:%s", tmpdir, local->volume_name); } return OS_SUCCESS; } /* end OS_FileSysStartVolume_Impl */ - /*---------------------------------------------------------------- * * Function: OS_FileSysStopVolume_Impl @@ -190,7 +184,7 @@ int32 OS_FileSysStartVolume_Impl (uint32 filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysStopVolume_Impl (uint32 filesys_id) +int32 OS_FileSysStopVolume_Impl(uint32 filesys_id) { /* * This is a no-op. @@ -213,7 +207,7 @@ int32 OS_FileSysStopVolume_Impl (uint32 filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysFormatVolume_Impl (uint32 filesys_id) +int32 OS_FileSysFormatVolume_Impl(uint32 filesys_id) { /* * In theory, this should wipe any existing files in the ramdisk, @@ -228,7 +222,6 @@ int32 OS_FileSysFormatVolume_Impl (uint32 filesys_id) } /* end OS_FileSysFormatVolume_Impl */ - /*---------------------------------------------------------------- * * Function: OS_FileSysMountVolume_Impl @@ -237,10 +230,10 @@ int32 OS_FileSysFormatVolume_Impl (uint32 filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysMountVolume_Impl (uint32 filesys_id) +int32 OS_FileSysMountVolume_Impl(uint32 filesys_id) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; - struct stat stat_buf; + OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; + struct stat stat_buf; /* * This will do a mkdir() for the mount point if it does @@ -250,15 +243,13 @@ int32 OS_FileSysMountVolume_Impl (uint32 filesys_id) { if (mkdir(local->system_mountpt, 0700) < 0) { - OS_DEBUG("ERROR: Cannot create mount point %s: %s", - local->system_mountpt, strerror(errno)); + OS_DEBUG("ERROR: Cannot create mount point %s: %s", local->system_mountpt, strerror(errno)); return OS_FS_ERR_DRIVE_NOT_CREATED; } } - else if (!S_ISDIR(stat_buf.st_mode) ) + else if (!S_ISDIR(stat_buf.st_mode)) { - OS_DEBUG("ERROR: Volume %s exists and is not a directory", - local->system_mountpt); + OS_DEBUG("ERROR: Volume %s exists and is not a directory", local->system_mountpt); return OS_FS_ERR_DRIVE_NOT_CREATED; } @@ -273,14 +264,12 @@ int32 OS_FileSysMountVolume_Impl (uint32 filesys_id) * mount point exists. For any other FS type, trigger an * error to indicate that it is not implemented in this OSAL. */ - if (local->fstype != OS_FILESYS_TYPE_VOLATILE_DISK && - local->fstype != OS_FILESYS_TYPE_FS_BASED) + if (local->fstype != OS_FILESYS_TYPE_VOLATILE_DISK && local->fstype != OS_FILESYS_TYPE_FS_BASED) { /* the mount command is not implemented for this FS type */ return OS_ERR_NOT_IMPLEMENTED; } - return OS_SUCCESS; } /* end OS_FileSysMountVolume_Impl */ @@ -293,7 +282,7 @@ int32 OS_FileSysMountVolume_Impl (uint32 filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysUnmountVolume_Impl (uint32 filesys_id) +int32 OS_FileSysUnmountVolume_Impl(uint32 filesys_id) { /* * NOTE: Mounting/Unmounting on POSIX is not implemented. @@ -314,24 +303,23 @@ int32 OS_FileSysUnmountVolume_Impl (uint32 filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysStatVolume_Impl (uint32 filesys_id, OS_statvfs_t *result) +int32 OS_FileSysStatVolume_Impl(uint32 filesys_id, OS_statvfs_t *result) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; - struct statvfs stat_buf; + OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; + struct statvfs stat_buf; - if ( statvfs(local->system_mountpt, &stat_buf) != 0 ) - { - return OS_ERROR; - } + if (statvfs(local->system_mountpt, &stat_buf) != 0) + { + return OS_ERROR; + } - result->block_size = stat_buf.f_bsize; - result->blocks_free = stat_buf.f_bfree; - result->total_blocks = stat_buf.f_blocks; + result->block_size = stat_buf.f_bsize; + result->blocks_free = stat_buf.f_bfree; + result->total_blocks = stat_buf.f_blocks; - return(OS_SUCCESS); + return (OS_SUCCESS); } /* end OS_FileSysStatVolume_Impl */ - /*---------------------------------------------------------------- * * Function: OS_FileSysCheckVolume_Impl @@ -340,8 +328,7 @@ int32 OS_FileSysStatVolume_Impl (uint32 filesys_id, OS_statvfs_t *result) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysCheckVolume_Impl (uint32 filesys_id, bool repair) +int32 OS_FileSysCheckVolume_Impl(uint32 filesys_id, bool repair) { return OS_ERR_NOT_IMPLEMENTED; } /* end OS_FileSysCheckVolume_Impl */ - diff --git a/src/os/posix/src/os-impl-heap.c b/src/os/posix/src/os-impl-heap.c index 90279b547..db330bc1a 100644 --- a/src/os/posix/src/os-impl-heap.c +++ b/src/os/posix/src/os-impl-heap.c @@ -47,4 +47,3 @@ int32 OS_HeapGetInfo_Impl(OS_heap_prop_t *heap_prop) */ return (OS_ERR_NOT_IMPLEMENTED); } /* end OS_HeapGetInfo_Impl */ - diff --git a/src/os/posix/src/os-impl-idmap.c b/src/os/posix/src/os-impl-idmap.c index 5aca36291..233d81d15 100644 --- a/src/os/posix/src/os-impl-idmap.c +++ b/src/os/posix/src/os-impl-idmap.c @@ -37,8 +37,8 @@ typedef struct { - pthread_mutex_t mutex; - sigset_t sigmask; + pthread_mutex_t mutex; + sigset_t sigmask; } POSIX_GlobalLock_t; static POSIX_GlobalLock_t OS_global_task_table_mut; @@ -54,26 +54,25 @@ static POSIX_GlobalLock_t OS_module_table_mut; static POSIX_GlobalLock_t OS_filesys_table_mut; static POSIX_GlobalLock_t OS_console_mut; -static POSIX_GlobalLock_t * const MUTEX_TABLE[] = - { - [OS_OBJECT_TYPE_UNDEFINED] = NULL, - [OS_OBJECT_TYPE_OS_TASK] = &OS_global_task_table_mut, - [OS_OBJECT_TYPE_OS_QUEUE] = &OS_queue_table_mut, - [OS_OBJECT_TYPE_OS_COUNTSEM] = &OS_count_sem_table_mut, - [OS_OBJECT_TYPE_OS_BINSEM] = &OS_bin_sem_table_mut, - [OS_OBJECT_TYPE_OS_MUTEX] = &OS_mutex_table_mut, - [OS_OBJECT_TYPE_OS_STREAM] = &OS_stream_table_mut, - [OS_OBJECT_TYPE_OS_DIR] = &OS_dir_table_mut, - [OS_OBJECT_TYPE_OS_TIMEBASE] = &OS_timebase_table_mut, - [OS_OBJECT_TYPE_OS_TIMECB] = &OS_timecb_table_mut, - [OS_OBJECT_TYPE_OS_MODULE] = &OS_module_table_mut, - [OS_OBJECT_TYPE_OS_FILESYS] = &OS_filesys_table_mut, - [OS_OBJECT_TYPE_OS_CONSOLE] = &OS_console_mut, - }; +static POSIX_GlobalLock_t *const MUTEX_TABLE[] = { + [OS_OBJECT_TYPE_UNDEFINED] = NULL, + [OS_OBJECT_TYPE_OS_TASK] = &OS_global_task_table_mut, + [OS_OBJECT_TYPE_OS_QUEUE] = &OS_queue_table_mut, + [OS_OBJECT_TYPE_OS_COUNTSEM] = &OS_count_sem_table_mut, + [OS_OBJECT_TYPE_OS_BINSEM] = &OS_bin_sem_table_mut, + [OS_OBJECT_TYPE_OS_MUTEX] = &OS_mutex_table_mut, + [OS_OBJECT_TYPE_OS_STREAM] = &OS_stream_table_mut, + [OS_OBJECT_TYPE_OS_DIR] = &OS_dir_table_mut, + [OS_OBJECT_TYPE_OS_TIMEBASE] = &OS_timebase_table_mut, + [OS_OBJECT_TYPE_OS_TIMECB] = &OS_timecb_table_mut, + [OS_OBJECT_TYPE_OS_MODULE] = &OS_module_table_mut, + [OS_OBJECT_TYPE_OS_FILESYS] = &OS_filesys_table_mut, + [OS_OBJECT_TYPE_OS_CONSOLE] = &OS_console_mut, +}; enum { - MUTEX_TABLE_SIZE = (sizeof(MUTEX_TABLE) / sizeof(MUTEX_TABLE[0])) + MUTEX_TABLE_SIZE = (sizeof(MUTEX_TABLE) / sizeof(MUTEX_TABLE[0])) }; /*---------------------------------------------------------------- @@ -86,33 +85,32 @@ enum *-----------------------------------------------------------------*/ int32 OS_Lock_Global_Impl(uint32 idtype) { - POSIX_GlobalLock_t *mut; - sigset_t previous; + POSIX_GlobalLock_t *mut; + sigset_t previous; - mut = MUTEX_TABLE[idtype]; + mut = MUTEX_TABLE[idtype]; - if (mut == NULL) - { - return OS_ERROR; - } + if (mut == NULL) + { + return OS_ERROR; + } - if (pthread_sigmask(SIG_SETMASK, &POSIX_GlobalVars.MaximumSigMask, &previous) != 0) - { - return OS_ERROR; - } + if (pthread_sigmask(SIG_SETMASK, &POSIX_GlobalVars.MaximumSigMask, &previous) != 0) + { + return OS_ERROR; + } - if (pthread_mutex_lock(&mut->mutex) != 0) - { - return OS_ERROR; - } + if (pthread_mutex_lock(&mut->mutex) != 0) + { + return OS_ERROR; + } - /* Only set values inside the GlobalLock _after_ it is locked */ - mut->sigmask = previous; + /* Only set values inside the GlobalLock _after_ it is locked */ + mut->sigmask = previous; - return OS_SUCCESS; + return OS_SUCCESS; } /* end OS_Lock_Global_Impl */ - /*---------------------------------------------------------------- * * Function: OS_Unlock_Global_Impl @@ -123,36 +121,35 @@ int32 OS_Lock_Global_Impl(uint32 idtype) *-----------------------------------------------------------------*/ int32 OS_Unlock_Global_Impl(uint32 idtype) { - POSIX_GlobalLock_t *mut; - sigset_t previous; - - if (idtype < MUTEX_TABLE_SIZE) - { - mut = MUTEX_TABLE[idtype]; - } - else - { - mut = NULL; - } - - if (mut == NULL) - { - return OS_ERROR; - } - - /* Only get values inside the GlobalLock _before_ it is unlocked */ - previous = mut->sigmask; - - if (pthread_mutex_unlock(&mut->mutex) != 0) - { - return OS_ERROR; - } - - pthread_sigmask(SIG_SETMASK, &previous, NULL); - - return OS_SUCCESS; -} /* end OS_Unlock_Global_Impl */ + POSIX_GlobalLock_t *mut; + sigset_t previous; + + if (idtype < MUTEX_TABLE_SIZE) + { + mut = MUTEX_TABLE[idtype]; + } + else + { + mut = NULL; + } + if (mut == NULL) + { + return OS_ERROR; + } + + /* Only get values inside the GlobalLock _before_ it is unlocked */ + previous = mut->sigmask; + + if (pthread_mutex_unlock(&mut->mutex) != 0) + { + return OS_ERROR; + } + + pthread_sigmask(SIG_SETMASK, &previous, NULL); + + return OS_SUCCESS; +} /* end OS_Unlock_Global_Impl */ /*--------------------------------------------------------------------------------------- Name: OS_Posix_TableMutex_Init @@ -184,9 +181,9 @@ int32 OS_Posix_TableMutex_Init(uint32 idtype) ** initialize the pthread mutex attribute structure with default values */ ret = pthread_mutexattr_init(&mutex_attr); - if ( ret != 0 ) + if (ret != 0) { - OS_DEBUG("Error: pthread_mutexattr_init failed: %s\n",strerror(ret)); + OS_DEBUG("Error: pthread_mutexattr_init failed: %s\n", strerror(ret)); return_code = OS_ERROR; break; } @@ -194,10 +191,10 @@ int32 OS_Posix_TableMutex_Init(uint32 idtype) /* ** Allow the mutex to use priority inheritance */ - ret = pthread_mutexattr_setprotocol(&mutex_attr,PTHREAD_PRIO_INHERIT) ; - if ( ret != 0 ) + ret = pthread_mutexattr_setprotocol(&mutex_attr, PTHREAD_PRIO_INHERIT); + if (ret != 0) { - OS_DEBUG("Error: pthread_mutexattr_setprotocol failed: %s\n",strerror(ret)); + OS_DEBUG("Error: pthread_mutexattr_setprotocol failed: %s\n", strerror(ret)); return_code = OS_ERROR; break; } @@ -207,24 +204,21 @@ int32 OS_Posix_TableMutex_Init(uint32 idtype) ** TBD - not sure if this is really desired, but keep it for now. */ ret = pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE); - if ( ret != 0 ) + if (ret != 0) { - OS_DEBUG("Error: pthread_mutexattr_settype failed: %s\n",strerror(ret)); + OS_DEBUG("Error: pthread_mutexattr_settype failed: %s\n", strerror(ret)); return_code = OS_ERROR; break; } ret = pthread_mutex_init(&MUTEX_TABLE[idtype]->mutex, &mutex_attr); - if ( ret != 0 ) + if (ret != 0) { - OS_DEBUG("Error: pthread_mutex_init failed: %s\n",strerror(ret)); + OS_DEBUG("Error: pthread_mutex_init failed: %s\n", strerror(ret)); return_code = OS_ERROR; break; } - } - while (0); + } while (0); - - return(return_code); + return (return_code); } /* end OS_Posix_TableMutex_Init */ - diff --git a/src/os/posix/src/os-impl-loader.c b/src/os/posix/src/os-impl-loader.c index fc1708cf6..8e8f7f606 100644 --- a/src/os/posix/src/os-impl-loader.c +++ b/src/os/posix/src/os-impl-loader.c @@ -45,8 +45,6 @@ OS_impl_module_internal_record_t OS_impl_module_table[OS_MAX_MODULES]; *-----------------------------------------------------------------*/ int32 OS_Posix_ModuleAPI_Impl_Init(void) { - memset(OS_impl_module_table, 0, sizeof(OS_impl_module_table)); - return(OS_SUCCESS); + memset(OS_impl_module_table, 0, sizeof(OS_impl_module_table)); + return (OS_SUCCESS); } /* end OS_Posix_ModuleAPI_Impl_Init */ - - diff --git a/src/os/posix/src/os-impl-mutex.c b/src/os/posix/src/os-impl-mutex.c index fdc6b7285..3fbd17479 100644 --- a/src/os/posix/src/os-impl-mutex.c +++ b/src/os/posix/src/os-impl-mutex.c @@ -33,16 +33,13 @@ #include "os-shared-mutex.h" #include "os-impl-mutex.h" - /* Tables where the OS object information is stored */ -OS_impl_mutex_internal_record_t OS_impl_mutex_table [OS_MAX_MUTEXES]; - +OS_impl_mutex_internal_record_t OS_impl_mutex_table[OS_MAX_MUTEXES]; /**************************************************************************************** MUTEX API ***************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_Posix_MutexAPI_Impl_Init @@ -52,11 +49,10 @@ OS_impl_mutex_internal_record_t OS_impl_mutex_table [OS_MAX_MUTEXES]; *-----------------------------------------------------------------*/ int32 OS_Posix_MutexAPI_Impl_Init(void) { - memset(OS_impl_mutex_table, 0, sizeof(OS_impl_mutex_table)); - return OS_SUCCESS; + memset(OS_impl_mutex_table, 0, sizeof(OS_impl_mutex_table)); + return OS_SUCCESS; } /* end OS_Posix_MutexAPI_Impl_Init */ - /*---------------------------------------------------------------- * * Function: OS_MutSemCreate_Impl @@ -65,7 +61,7 @@ int32 OS_Posix_MutexAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemCreate_Impl (uint32 sem_id, uint32 options) +int32 OS_MutSemCreate_Impl(uint32 sem_id, uint32 options) { int return_code; pthread_mutexattr_t mutex_attr; @@ -74,51 +70,49 @@ int32 OS_MutSemCreate_Impl (uint32 sem_id, uint32 options) ** initialize the attribute with default values */ return_code = pthread_mutexattr_init(&mutex_attr); - if ( return_code != 0 ) + if (return_code != 0) { - OS_DEBUG("Error: Mutex could not be created. pthread_mutexattr_init failed ID = %u: %s\n", - (unsigned int)sem_id,strerror(return_code)); - return OS_SEM_FAILURE; + OS_DEBUG("Error: Mutex could not be created. pthread_mutexattr_init failed ID = %u: %s\n", (unsigned int)sem_id, + strerror(return_code)); + return OS_SEM_FAILURE; } /* ** Allow the mutex to use priority inheritance */ - return_code = pthread_mutexattr_setprotocol(&mutex_attr,PTHREAD_PRIO_INHERIT); - if ( return_code != 0 ) + return_code = pthread_mutexattr_setprotocol(&mutex_attr, PTHREAD_PRIO_INHERIT); + if (return_code != 0) { - OS_DEBUG("Error: Mutex could not be created. pthread_mutexattr_setprotocol failed ID = %u: %s\n", - (unsigned int)sem_id,strerror(return_code)); - return OS_SEM_FAILURE; + OS_DEBUG("Error: Mutex could not be created. pthread_mutexattr_setprotocol failed ID = %u: %s\n", + (unsigned int)sem_id, strerror(return_code)); + return OS_SEM_FAILURE; } /* ** Set the mutex type to RECURSIVE so a thread can do nested locks */ return_code = pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE); - if ( return_code != 0 ) + if (return_code != 0) { - OS_DEBUG("Error: Mutex could not be created. pthread_mutexattr_settype failed ID = %u: %s\n", - (unsigned int)sem_id,strerror(return_code)); - return OS_SEM_FAILURE; + OS_DEBUG("Error: Mutex could not be created. pthread_mutexattr_settype failed ID = %u: %s\n", + (unsigned int)sem_id, strerror(return_code)); + return OS_SEM_FAILURE; } /* ** create the mutex ** upon successful initialization, the state of the mutex becomes initialized and unlocked */ - return_code = pthread_mutex_init(&OS_impl_mutex_table[sem_id].id,&mutex_attr); - if ( return_code != 0 ) + return_code = pthread_mutex_init(&OS_impl_mutex_table[sem_id].id, &mutex_attr); + if (return_code != 0) { - OS_DEBUG("Error: Mutex could not be created. ID = %u: %s\n", - (unsigned int)sem_id,strerror(return_code)); - return OS_SEM_FAILURE; + OS_DEBUG("Error: Mutex could not be created. ID = %u: %s\n", (unsigned int)sem_id, strerror(return_code)); + return OS_SEM_FAILURE; } return OS_SUCCESS; } /* end OS_MutSemCreate_Impl */ - /*---------------------------------------------------------------- * * Function: OS_MutSemDelete_Impl @@ -127,11 +121,11 @@ int32 OS_MutSemCreate_Impl (uint32 sem_id, uint32 options) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemDelete_Impl (uint32 sem_id) +int32 OS_MutSemDelete_Impl(uint32 sem_id) { int status; - status = pthread_mutex_destroy( &(OS_impl_mutex_table[sem_id].id)); /* 0 = success */ + status = pthread_mutex_destroy(&(OS_impl_mutex_table[sem_id].id)); /* 0 = success */ if (status != 0) { @@ -142,7 +136,6 @@ int32 OS_MutSemDelete_Impl (uint32 sem_id) } /* end OS_MutSemDelete_Impl */ - /*---------------------------------------------------------------- * * Function: OS_MutSemGive_Impl @@ -151,23 +144,22 @@ int32 OS_MutSemDelete_Impl (uint32 sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemGive_Impl ( uint32 sem_id ) +int32 OS_MutSemGive_Impl(uint32 sem_id) { - int status; + int status; - /* - ** Unlock the mutex - */ - status = pthread_mutex_unlock(&(OS_impl_mutex_table[sem_id].id)); - if(status != 0) - { - return OS_SEM_FAILURE; - } + /* + ** Unlock the mutex + */ + status = pthread_mutex_unlock(&(OS_impl_mutex_table[sem_id].id)); + if (status != 0) + { + return OS_SEM_FAILURE; + } - return OS_SUCCESS; + return OS_SUCCESS; } /* end OS_MutSemGive_Impl */ - /*---------------------------------------------------------------- * * Function: OS_MutSemTake_Impl @@ -176,7 +168,7 @@ int32 OS_MutSemGive_Impl ( uint32 sem_id ) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemTake_Impl ( uint32 sem_id ) +int32 OS_MutSemTake_Impl(uint32 sem_id) { int status; @@ -184,7 +176,7 @@ int32 OS_MutSemTake_Impl ( uint32 sem_id ) ** Lock the mutex */ status = pthread_mutex_lock(&(OS_impl_mutex_table[sem_id].id)); - if( status != 0 ) + if (status != 0) { return OS_SEM_FAILURE; } @@ -192,7 +184,6 @@ int32 OS_MutSemTake_Impl ( uint32 sem_id ) return OS_SUCCESS; } /* end OS_MutSemTake_Impl */ - /*---------------------------------------------------------------- * * Function: OS_MutSemGetInfo_Impl @@ -201,9 +192,8 @@ int32 OS_MutSemTake_Impl ( uint32 sem_id ) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemGetInfo_Impl (uint32 sem_id, OS_mut_sem_prop_t *mut_prop) +int32 OS_MutSemGetInfo_Impl(uint32 sem_id, OS_mut_sem_prop_t *mut_prop) { return OS_SUCCESS; } /* end OS_MutSemGetInfo_Impl */ - diff --git a/src/os/posix/src/os-impl-no-module.c b/src/os/posix/src/os-impl-no-module.c index 61871c751..5d9eda065 100644 --- a/src/os/posix/src/os-impl-no-module.c +++ b/src/os/posix/src/os-impl-no-module.c @@ -45,7 +45,5 @@ int32 OS_Posix_ModuleAPI_Impl_Init(void) { /* nothing to init in this mode */ - return(OS_SUCCESS); + return (OS_SUCCESS); } /* end OS_Posix_ModuleAPI_Impl_Init */ - - diff --git a/src/os/posix/src/os-impl-queues.c b/src/os/posix/src/os-impl-queues.c index eac3ffe8a..bb5f505d8 100644 --- a/src/os/posix/src/os-impl-queues.c +++ b/src/os/posix/src/os-impl-queues.c @@ -37,7 +37,7 @@ #include "os-shared-idmap.h" /* Tables where the OS object information is stored */ -OS_impl_queue_internal_record_t OS_impl_queue_table [OS_MAX_QUEUES]; +OS_impl_queue_internal_record_t OS_impl_queue_table[OS_MAX_QUEUES]; /**************************************************************************************** MESSAGE QUEUE API @@ -51,30 +51,28 @@ OS_impl_queue_internal_record_t OS_impl_queue_table [OS_MAX_QUEUES]; ----------------------------------------------------------------------------------------*/ int32 OS_Posix_QueueAPI_Impl_Init(void) { - memset(OS_impl_queue_table, 0, sizeof(OS_impl_queue_table)); + memset(OS_impl_queue_table, 0, sizeof(OS_impl_queue_table)); - /* - * Automatic truncation is dependent on the OSAL_CONFIG_DEBUG_PERMISSIVE_MODE compile-time define - so - * creating a too-large message queue on a target without OSAL_CONFIG_DEBUG_PERMISSIVE_MODE will fail - * with an OS error as intended. - */ + /* + * Automatic truncation is dependent on the OSAL_CONFIG_DEBUG_PERMISSIVE_MODE compile-time define - so + * creating a too-large message queue on a target without OSAL_CONFIG_DEBUG_PERMISSIVE_MODE will fail + * with an OS error as intended. + */ #ifdef OSAL_CONFIG_DEBUG_PERMISSIVE_MODE - /* - * Use the BSP-provided limit - */ - POSIX_GlobalVars.TruncateQueueDepth = OS_BSP_Global.MaxQueueDepth; + /* + * Use the BSP-provided limit + */ + POSIX_GlobalVars.TruncateQueueDepth = OS_BSP_Global.MaxQueueDepth; #else - /* - * Initialize this to zero to indicate no limit - */ - POSIX_GlobalVars.TruncateQueueDepth = 0; + /* + * Initialize this to zero to indicate no limit + */ + POSIX_GlobalVars.TruncateQueueDepth = 0; #endif - return OS_SUCCESS; + return OS_SUCCESS; } /* end OS_Posix_QueueAPI_Impl_Init */ - - /*---------------------------------------------------------------- * * Function: OS_QueueCreate_Impl @@ -83,77 +81,75 @@ int32 OS_Posix_QueueAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueueCreate_Impl (uint32 queue_id, uint32 flags) +int32 OS_QueueCreate_Impl(uint32 queue_id, uint32 flags) { - int return_code; - mqd_t queueDesc; - struct mq_attr queueAttr; - char name[OS_MAX_API_NAME * 2]; - - /* set queue attributes */ - memset(&queueAttr, 0, sizeof(queueAttr)); - queueAttr.mq_maxmsg = OS_queue_table[queue_id].max_depth; - queueAttr.mq_msgsize = OS_queue_table[queue_id].max_size; - - /* - * The "TruncateQueueDepth" indicates a soft limit to the size of a queue. - * If nonzero, anything larger than this will be silently truncated - * (Supports running applications as non-root) - */ - if (POSIX_GlobalVars.TruncateQueueDepth > 0 && - POSIX_GlobalVars.TruncateQueueDepth < queueAttr.mq_maxmsg) - { - queueAttr.mq_maxmsg = POSIX_GlobalVars.TruncateQueueDepth; - } + int return_code; + mqd_t queueDesc; + struct mq_attr queueAttr; + char name[OS_MAX_API_NAME * 2]; + + /* set queue attributes */ + memset(&queueAttr, 0, sizeof(queueAttr)); + queueAttr.mq_maxmsg = OS_queue_table[queue_id].max_depth; + queueAttr.mq_msgsize = OS_queue_table[queue_id].max_size; + + /* + * The "TruncateQueueDepth" indicates a soft limit to the size of a queue. + * If nonzero, anything larger than this will be silently truncated + * (Supports running applications as non-root) + */ + if (POSIX_GlobalVars.TruncateQueueDepth > 0 && POSIX_GlobalVars.TruncateQueueDepth < queueAttr.mq_maxmsg) + { + queueAttr.mq_maxmsg = POSIX_GlobalVars.TruncateQueueDepth; + } /* ** Construct the queue name: ** The name will consist of "/.queue_name" */ - snprintf(name, sizeof(name), "/%d.%s", (int)getpid(), OS_global_queue_table[queue_id].name_entry); + snprintf(name, sizeof(name), "/%d.%s", (int)getpid(), OS_global_queue_table[queue_id].name_entry); - /* - ** create message queue - */ - queueDesc = mq_open(name, O_CREAT | O_RDWR, 0666, &queueAttr); - if ( queueDesc == (mqd_t)(-1) ) - { - OS_DEBUG("OS_QueueCreate Error. errno = %d (%s)\n",errno,strerror(errno)); - if( errno == EINVAL ) - { - OS_DEBUG("Your queue depth may be too large for the\n"); - OS_DEBUG("OS to handle. Please check the msg_max\n"); - OS_DEBUG("parameter located in /proc/sys/fs/mqueue/msg_max\n"); - OS_DEBUG("on your Linux file system and raise it if you\n"); - OS_DEBUG(" need to or run as root\n"); - } - return_code = OS_ERROR; - } - else - { - OS_impl_queue_table[queue_id].id = queueDesc; - return_code = OS_SUCCESS; - - /* - * Unlink the queue right now -- - * queues have kernel persistence and if we do a lot of restarts (i.e. during debugging) - * a lot of stale message queues will collect in the system. It is OK to unlink right now - * as this only affects the ability of another process to open the same queue, but we do - * not need that to happen anyway. - */ - if(mq_unlink(name) != 0) - { - OS_DEBUG("OS_QueueDelete Error during mq_unlink(). errno = %d (%s)\n",errno,strerror(errno)); - /* Note - since the queue is already closed, we cannot really handle this failure gracefully, - * The queue is no longer usable so we can't return an error and go back to the way things were. - * In this case we need to return OS_SUCCESS so the rest of the entry will be cleaned up. - */ - } - } - - return return_code; -} /* end OS_QueueCreate_Impl */ + /* + ** create message queue + */ + queueDesc = mq_open(name, O_CREAT | O_RDWR, 0666, &queueAttr); + if (queueDesc == (mqd_t)(-1)) + { + OS_DEBUG("OS_QueueCreate Error. errno = %d (%s)\n", errno, strerror(errno)); + if (errno == EINVAL) + { + OS_DEBUG("Your queue depth may be too large for the\n"); + OS_DEBUG("OS to handle. Please check the msg_max\n"); + OS_DEBUG("parameter located in /proc/sys/fs/mqueue/msg_max\n"); + OS_DEBUG("on your Linux file system and raise it if you\n"); + OS_DEBUG(" need to or run as root\n"); + } + return_code = OS_ERROR; + } + else + { + OS_impl_queue_table[queue_id].id = queueDesc; + return_code = OS_SUCCESS; + + /* + * Unlink the queue right now -- + * queues have kernel persistence and if we do a lot of restarts (i.e. during debugging) + * a lot of stale message queues will collect in the system. It is OK to unlink right now + * as this only affects the ability of another process to open the same queue, but we do + * not need that to happen anyway. + */ + if (mq_unlink(name) != 0) + { + OS_DEBUG("OS_QueueDelete Error during mq_unlink(). errno = %d (%s)\n", errno, strerror(errno)); + /* Note - since the queue is already closed, we cannot really handle this failure gracefully, + * The queue is no longer usable so we can't return an error and go back to the way things were. + * In this case we need to return OS_SUCCESS so the rest of the entry will be cleaned up. + */ + } + } + return return_code; +} /* end OS_QueueCreate_Impl */ /*---------------------------------------------------------------- * @@ -163,25 +159,24 @@ int32 OS_QueueCreate_Impl (uint32 queue_id, uint32 flags) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueueDelete_Impl (uint32 queue_id) +int32 OS_QueueDelete_Impl(uint32 queue_id) { - int32 return_code; - - /* Try to delete and unlink the queue */ - if (mq_close(OS_impl_queue_table[queue_id].id) != 0) - { - OS_DEBUG("OS_QueueDelete Error during mq_close(). errno = %d (%s)\n",errno,strerror(errno)); - return_code = OS_ERROR; - } - else - { - return_code = OS_SUCCESS; - } + int32 return_code; + + /* Try to delete and unlink the queue */ + if (mq_close(OS_impl_queue_table[queue_id].id) != 0) + { + OS_DEBUG("OS_QueueDelete Error during mq_close(). errno = %d (%s)\n", errno, strerror(errno)); + return_code = OS_ERROR; + } + else + { + return_code = OS_SUCCESS; + } return return_code; } /* end OS_QueueDelete_Impl */ - /*---------------------------------------------------------------- * * Function: OS_QueueGet_Impl @@ -190,97 +185,93 @@ int32 OS_QueueDelete_Impl (uint32 queue_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueueGet_Impl (uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout) +int32 OS_QueueGet_Impl(uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout) { - int32 return_code; - ssize_t sizeCopied; - struct timespec ts; + int32 return_code; + ssize_t sizeCopied; + struct timespec ts; - /* - ** Read the message queue for data - */ - sizeCopied = -1; - if (timeout == OS_PEND) - { - /* - ** A signal can interrupt the mq_receive call, so the call has to be done with - ** a loop - */ - do - { - sizeCopied = mq_receive(OS_impl_queue_table[queue_id].id, data, size, NULL); - } - while ( sizeCopied < 0 && errno == EINTR ); - - } - else - { - /* - * NOTE - a prior implementation of OS_CHECK would check the mq_attr for a nonzero depth - * and then call mq_receive(). This is insufficient since another thread might do the same - * thing at the same time in which case one thread will read and the other will block. - * - * Calling mq_timedreceive with a zero timeout effectively does the same thing in the typical - * case, but for the case where two threads do a simultaneous read, one will get the message - * while the other will NOT block (as expected). - */ - if (timeout == OS_CHECK) - { - memset(&ts, 0, sizeof(ts)); - } - else - { - OS_Posix_CompAbsDelayTime( timeout, &ts); - } - - /* - ** If the mq_timedreceive call is interrupted by a system call or signal, - ** call it again. - */ - do - { - sizeCopied = mq_timedreceive(OS_impl_queue_table[queue_id].id, data, size, NULL, &ts); - } - while ( timeout != OS_CHECK && sizeCopied < 0 && errno == EINTR ); - - } /* END timeout */ - - /* Figure out the return code */ - if(sizeCopied == -1) - { - *size_copied = 0; - - /* Map the system errno to the most appropriate OSAL return code */ - if (errno == EMSGSIZE) - { - return_code = OS_QUEUE_INVALID_SIZE; - } - else if (timeout == OS_PEND || errno != ETIMEDOUT) - { - /* OS_PEND was supposed to pend forever until a message arrived - * so something else is wrong. Otherwise, at this point the only - * "acceptable" errno is TIMEDOUT for the other cases. - */ - return_code = OS_ERROR; - } - else if (timeout == OS_CHECK) - { - return_code = OS_QUEUE_EMPTY; - } - else - { - return_code = OS_QUEUE_TIMEOUT; - } - } - else - { - *size_copied = sizeCopied; - return_code = OS_SUCCESS; - } - - return return_code; -} /* end OS_QueueGet_Impl */ + /* + ** Read the message queue for data + */ + sizeCopied = -1; + if (timeout == OS_PEND) + { + /* + ** A signal can interrupt the mq_receive call, so the call has to be done with + ** a loop + */ + do + { + sizeCopied = mq_receive(OS_impl_queue_table[queue_id].id, data, size, NULL); + } while (sizeCopied < 0 && errno == EINTR); + } + else + { + /* + * NOTE - a prior implementation of OS_CHECK would check the mq_attr for a nonzero depth + * and then call mq_receive(). This is insufficient since another thread might do the same + * thing at the same time in which case one thread will read and the other will block. + * + * Calling mq_timedreceive with a zero timeout effectively does the same thing in the typical + * case, but for the case where two threads do a simultaneous read, one will get the message + * while the other will NOT block (as expected). + */ + if (timeout == OS_CHECK) + { + memset(&ts, 0, sizeof(ts)); + } + else + { + OS_Posix_CompAbsDelayTime(timeout, &ts); + } + + /* + ** If the mq_timedreceive call is interrupted by a system call or signal, + ** call it again. + */ + do + { + sizeCopied = mq_timedreceive(OS_impl_queue_table[queue_id].id, data, size, NULL, &ts); + } while (timeout != OS_CHECK && sizeCopied < 0 && errno == EINTR); + + } /* END timeout */ + + /* Figure out the return code */ + if (sizeCopied == -1) + { + *size_copied = 0; + + /* Map the system errno to the most appropriate OSAL return code */ + if (errno == EMSGSIZE) + { + return_code = OS_QUEUE_INVALID_SIZE; + } + else if (timeout == OS_PEND || errno != ETIMEDOUT) + { + /* OS_PEND was supposed to pend forever until a message arrived + * so something else is wrong. Otherwise, at this point the only + * "acceptable" errno is TIMEDOUT for the other cases. + */ + return_code = OS_ERROR; + } + else if (timeout == OS_CHECK) + { + return_code = OS_QUEUE_EMPTY; + } + else + { + return_code = OS_QUEUE_TIMEOUT; + } + } + else + { + *size_copied = sizeCopied; + return_code = OS_SUCCESS; + } + return return_code; +} /* end OS_QueueGet_Impl */ /*---------------------------------------------------------------- * @@ -290,43 +281,40 @@ int32 OS_QueueGet_Impl (uint32 queue_id, void *data, uint32 size, uint32 *size_c * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueuePut_Impl (uint32 queue_id, const void *data, uint32 size, uint32 flags) +int32 OS_QueuePut_Impl(uint32 queue_id, const void *data, uint32 size, uint32 flags) { - int32 return_code; - int result; - struct timespec ts; - - /* - * NOTE - using a zero timeout here for the same reason that QueueGet does --- - * checking the attributes and doing the actual send is non-atomic, and if - * two threads call QueuePut() at the same time on a nearly-full queue, - * one could block. - */ - memset(&ts, 0, sizeof(ts)); - - /* send message */ - do - { - result = mq_timedsend(OS_impl_queue_table[queue_id].id, data, size, 1, &ts); - } - while ( result == -1 && errno == EINTR ); - - if(result == 0) - { - return_code = OS_SUCCESS; - } - else if (errno == ETIMEDOUT) - { - return_code = OS_QUEUE_FULL; - } - else - { - /* Something else went wrong */ - return_code = OS_ERROR; - } - - return return_code; + int32 return_code; + int result; + struct timespec ts; -} /* end OS_QueuePut_Impl */ + /* + * NOTE - using a zero timeout here for the same reason that QueueGet does --- + * checking the attributes and doing the actual send is non-atomic, and if + * two threads call QueuePut() at the same time on a nearly-full queue, + * one could block. + */ + memset(&ts, 0, sizeof(ts)); + + /* send message */ + do + { + result = mq_timedsend(OS_impl_queue_table[queue_id].id, data, size, 1, &ts); + } while (result == -1 && errno == EINTR); + + if (result == 0) + { + return_code = OS_SUCCESS; + } + else if (errno == ETIMEDOUT) + { + return_code = OS_QUEUE_FULL; + } + else + { + /* Something else went wrong */ + return_code = OS_ERROR; + } + return return_code; +} /* end OS_QueuePut_Impl */ diff --git a/src/os/posix/src/os-impl-shell.c b/src/os/posix/src/os-impl-shell.c index f5029c638..76cb1538c 100644 --- a/src/os/posix/src/os-impl-shell.c +++ b/src/os/posix/src/os-impl-shell.c @@ -44,14 +44,11 @@ GLOBALS ***************************************************************************************/ - - /**************************************************************************************** IMPLEMENTATION-SPECIFIC ROUTINES These are specific to this particular operating system ****************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_ShellOutputToFile_Impl @@ -60,56 +57,55 @@ * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ShellOutputToFile_Impl(uint32 file_id, const char* Cmd) +int32 OS_ShellOutputToFile_Impl(uint32 file_id, const char *Cmd) { - pid_t cpid; - uint32 local_id; - int wstat; - const char *shell = getenv("SHELL"); - - if (shell == NULL) - { - shell = "/bin/sh"; - } - - cpid = fork(); - if (cpid < 0) - { - OS_DEBUG("%s(): Error during fork(): %s\n", __func__, strerror(errno)); - return OS_ERROR; - } - - if (cpid == 0) - { - /* child process */ - dup2(OS_impl_filehandle_table[file_id].fd, STDOUT_FILENO); - dup2(OS_impl_filehandle_table[file_id].fd, STDERR_FILENO); - - /* close all _other_ filehandles */ - for (local_id = 0; local_id < OS_MAX_NUM_OPEN_FILES; ++local_id) - { - if (OS_global_stream_table[local_id].active_id != 0) - { - close(OS_impl_filehandle_table[local_id].fd); - } - } - - execl(shell, "sh", "-c", Cmd, NULL); /* does not return if successful */ - exit(EXIT_FAILURE); - } - - if (waitpid(cpid, &wstat, 0) != cpid) - { - OS_DEBUG("%s(): Error during waitpid(): %s\n", __func__, strerror(errno)); - return OS_ERROR; - } - - if (!WIFEXITED(wstat) || WEXITSTATUS(wstat) != 0) - { - OS_DEBUG("%s(): Error from child process: %d\n", __func__, wstat); - return OS_ERROR; - } - - return OS_SUCCESS; + pid_t cpid; + uint32 local_id; + int wstat; + const char *shell = getenv("SHELL"); + + if (shell == NULL) + { + shell = "/bin/sh"; + } + + cpid = fork(); + if (cpid < 0) + { + OS_DEBUG("%s(): Error during fork(): %s\n", __func__, strerror(errno)); + return OS_ERROR; + } + + if (cpid == 0) + { + /* child process */ + dup2(OS_impl_filehandle_table[file_id].fd, STDOUT_FILENO); + dup2(OS_impl_filehandle_table[file_id].fd, STDERR_FILENO); + + /* close all _other_ filehandles */ + for (local_id = 0; local_id < OS_MAX_NUM_OPEN_FILES; ++local_id) + { + if (OS_global_stream_table[local_id].active_id != 0) + { + close(OS_impl_filehandle_table[local_id].fd); + } + } + + execl(shell, "sh", "-c", Cmd, NULL); /* does not return if successful */ + exit(EXIT_FAILURE); + } + + if (waitpid(cpid, &wstat, 0) != cpid) + { + OS_DEBUG("%s(): Error during waitpid(): %s\n", __func__, strerror(errno)); + return OS_ERROR; + } + + if (!WIFEXITED(wstat) || WEXITSTATUS(wstat) != 0) + { + OS_DEBUG("%s(): Error from child process: %d\n", __func__, wstat); + return OS_ERROR; + } + + return OS_SUCCESS; } /* end OS_ShellOutputToFile_Impl */ - diff --git a/src/os/posix/src/os-impl-tasks.c b/src/os/posix/src/os-impl-tasks.c index 73cae66dc..ab6cdf4aa 100644 --- a/src/os/posix/src/os-impl-tasks.c +++ b/src/os/posix/src/os-impl-tasks.c @@ -42,11 +42,11 @@ * Defines */ #ifndef PTHREAD_STACK_MIN -#define PTHREAD_STACK_MIN (8*1024) +#define PTHREAD_STACK_MIN (8 * 1024) #endif /* Tables where the OS object information is stored */ -OS_impl_task_internal_record_t OS_impl_task_table [OS_MAX_TASKS]; +OS_impl_task_internal_record_t OS_impl_task_table[OS_MAX_TASKS]; /* * Local Function Prototypes @@ -94,8 +94,6 @@ static int OS_PriorityRemap(uint32 InputPri) return OutputPri; } /* end OS_PriorityRemap */ - - /*---------------------------------------------------------------- * * Function: OS_NoopSigHandler @@ -104,11 +102,7 @@ static int OS_PriorityRemap(uint32 InputPri) * A POSIX signal handler that does nothing * *-----------------------------------------------------------------*/ -static void OS_NoopSigHandler (int signal) -{ -} /* end OS_NoopSigHandler */ - - +static void OS_NoopSigHandler(int signal) {} /* end OS_NoopSigHandler */ /*--------------------------------------------------------------------------------------- Name: OS_PthreadEntry @@ -122,12 +116,12 @@ static void OS_NoopSigHandler (int signal) ---------------------------------------------------------------------------------------*/ static void *OS_PthreadTaskEntry(void *arg) { - OS_U32ValueWrapper_t local_arg; + OS_U32ValueWrapper_t local_arg; - local_arg.opaque_arg = arg; - OS_TaskEntryPoint(local_arg.id); /* Never returns */ + local_arg.opaque_arg = arg; + OS_TaskEntryPoint(local_arg.id); /* Never returns */ - return NULL; + return NULL; } /*--------------------------------------------------------------------------------------- @@ -186,14 +180,14 @@ static bool OS_Posix_GetSchedulerParams(int sched_policy, POSIX_PriorityLimits_t */ if ((PriLim->PriorityMax - PriLim->PriorityMin) < 4) { - OS_DEBUG("Policy %d: Insufficient spread between priority min-max: %d-%d\n", - sched_policy, (int)PriLim->PriorityMin, (int)PriLim->PriorityMax); + OS_DEBUG("Policy %d: Insufficient spread between priority min-max: %d-%d\n", sched_policy, + (int)PriLim->PriorityMin, (int)PriLim->PriorityMax); return false; } /* If we get here, then the sched_policy is potentially valid */ - OS_DEBUG("Policy %d: available, min-max: %d-%d\n", sched_policy, - (int)PriLim->PriorityMin, (int)PriLim->PriorityMax); + OS_DEBUG("Policy %d: available, min-max: %d-%d\n", sched_policy, (int)PriLim->PriorityMin, + (int)PriLim->PriorityMax); return true; } /* end OS_Posix_GetSchedulerParams */ @@ -211,224 +205,223 @@ static bool OS_Posix_GetSchedulerParams(int sched_policy, POSIX_PriorityLimits_t ----------------------------------------------------------------------------------------*/ int32 OS_Posix_TaskAPI_Impl_Init(void) { - int ret; - int sig; - struct sched_param sched_param; - int sched_policy; - POSIX_PriorityLimits_t sched_fifo_limits; - bool sched_fifo_valid; - POSIX_PriorityLimits_t sched_rr_limits; - bool sched_rr_valid; - - /* Initialize Local Tables */ - memset(OS_impl_task_table, 0, sizeof(OS_impl_task_table)); - - /* Clear the "limits" structs otherwise the compiler may warn - * about possibly being used uninitialized (false warning) - */ - memset(&sched_fifo_limits, 0, sizeof(sched_fifo_limits)); - memset(&sched_rr_limits, 0, sizeof(sched_rr_limits)); + int ret; + int sig; + struct sched_param sched_param; + int sched_policy; + POSIX_PriorityLimits_t sched_fifo_limits; + bool sched_fifo_valid; + POSIX_PriorityLimits_t sched_rr_limits; + bool sched_rr_valid; + + /* Initialize Local Tables */ + memset(OS_impl_task_table, 0, sizeof(OS_impl_task_table)); + + /* Clear the "limits" structs otherwise the compiler may warn + * about possibly being used uninitialized (false warning) + */ + memset(&sched_fifo_limits, 0, sizeof(sched_fifo_limits)); + memset(&sched_rr_limits, 0, sizeof(sched_rr_limits)); - /* - * Create the key used to store OSAL task IDs - */ - ret = pthread_key_create(&POSIX_GlobalVars.ThreadKey, NULL ); - if ( ret != 0 ) - { - OS_DEBUG("Error creating thread key: %s (%d)\n",strerror(ret),ret); - return OS_ERROR; - } - - /* - ** Disable Signals to parent thread and therefore all - ** child threads create will block all signals - ** Note: Timers will not work in the application unless - ** threads are spawned in OS_Application_Startup. - */ - sigfillset(&POSIX_GlobalVars.MaximumSigMask); - - /* - * Keep these signals unblocked so the process can be interrupted - */ - sigdelset(&POSIX_GlobalVars.MaximumSigMask, SIGINT); /* CTRL+C */ - sigdelset(&POSIX_GlobalVars.MaximumSigMask, SIGABRT); /* Abort */ - - /* - * One should not typically block ANY of the synchronous error - * signals, i.e. SIGSEGV, SIGFPE, SIGILL, SIGBUS - * - * The kernel generates these signals in response to hardware events - * and they get routed to the _specific thread_ that was executing when - * the problem occurred. - * - * While it is technically possible to block these signals, the result is - * undefined, and it makes debugging _REALLY_ hard. If the kernel ever does - * send one it means there really is a major problem, best to listen to it, - * and not ignore it. - */ - sigdelset(&POSIX_GlobalVars.MaximumSigMask, SIGSEGV); /* Segfault */ - sigdelset(&POSIX_GlobalVars.MaximumSigMask, SIGILL); /* Illegal instruction */ - sigdelset(&POSIX_GlobalVars.MaximumSigMask, SIGBUS); /* Bus Error */ - sigdelset(&POSIX_GlobalVars.MaximumSigMask, SIGFPE); /* Floating Point Exception */ + /* + * Create the key used to store OSAL task IDs + */ + ret = pthread_key_create(&POSIX_GlobalVars.ThreadKey, NULL); + if (ret != 0) + { + OS_DEBUG("Error creating thread key: %s (%d)\n", strerror(ret), ret); + return OS_ERROR; + } - /* - * Set the mask and store the original (default) mask in the POSIX_GlobalVars.NormalSigMask + /* + ** Disable Signals to parent thread and therefore all + ** child threads create will block all signals + ** Note: Timers will not work in the application unless + ** threads are spawned in OS_Application_Startup. */ - sigprocmask(SIG_SETMASK, &POSIX_GlobalVars.MaximumSigMask, &POSIX_GlobalVars.NormalSigMask); + sigfillset(&POSIX_GlobalVars.MaximumSigMask); + + /* + * Keep these signals unblocked so the process can be interrupted + */ + sigdelset(&POSIX_GlobalVars.MaximumSigMask, SIGINT); /* CTRL+C */ + sigdelset(&POSIX_GlobalVars.MaximumSigMask, SIGABRT); /* Abort */ + + /* + * One should not typically block ANY of the synchronous error + * signals, i.e. SIGSEGV, SIGFPE, SIGILL, SIGBUS + * + * The kernel generates these signals in response to hardware events + * and they get routed to the _specific thread_ that was executing when + * the problem occurred. + * + * While it is technically possible to block these signals, the result is + * undefined, and it makes debugging _REALLY_ hard. If the kernel ever does + * send one it means there really is a major problem, best to listen to it, + * and not ignore it. + */ + sigdelset(&POSIX_GlobalVars.MaximumSigMask, SIGSEGV); /* Segfault */ + sigdelset(&POSIX_GlobalVars.MaximumSigMask, SIGILL); /* Illegal instruction */ + sigdelset(&POSIX_GlobalVars.MaximumSigMask, SIGBUS); /* Bus Error */ + sigdelset(&POSIX_GlobalVars.MaximumSigMask, SIGFPE); /* Floating Point Exception */ + + /* + * Set the mask and store the original (default) mask in the POSIX_GlobalVars.NormalSigMask + */ + sigprocmask(SIG_SETMASK, &POSIX_GlobalVars.MaximumSigMask, &POSIX_GlobalVars.NormalSigMask); + + /* + * Add all "RT" signals into the POSIX_GlobalVars.NormalSigMask + * This will be used for the signal mask of the main thread + * (This way it will end up as the default/original signal mask plus all RT sigs) + */ + for (sig = SIGRTMIN; sig <= SIGRTMAX; ++sig) + { + sigaddset(&POSIX_GlobalVars.NormalSigMask, sig); + } + + /* + * SIGHUP is used to wake up the main thread when necessary, + * so make sure it is NOT in the set. + */ + sigdelset(&POSIX_GlobalVars.NormalSigMask, SIGHUP); - /* - * Add all "RT" signals into the POSIX_GlobalVars.NormalSigMask - * This will be used for the signal mask of the main thread - * (This way it will end up as the default/original signal mask plus all RT sigs) + /* + ** Install noop as the signal handler for SIGUP. */ - for (sig = SIGRTMIN; sig <= SIGRTMAX; ++sig) - { - sigaddset(&POSIX_GlobalVars.NormalSigMask, sig); - } - - /* - * SIGHUP is used to wake up the main thread when necessary, - * so make sure it is NOT in the set. + signal(SIGHUP, OS_NoopSigHandler); + + /* + ** Raise the priority of the current (main) thread so that subsequent + ** application initialization will complete. This had previously been + ** done by the BSP and but it is moved here. + ** + ** This will only work if the user owning this process has permission + ** to create real time threads. Otherwise, the default priority will + ** be retained. Typically this is only the root user, but finer grained + ** permission controls are out there. So if it works, great, but if + ** a permission denied error is generated, that is OK too - this allows + ** easily debugging code as a normal user. */ - sigdelset(&POSIX_GlobalVars.NormalSigMask, SIGHUP); - - /* - ** Install noop as the signal handler for SIGUP. - */ - signal(SIGHUP, OS_NoopSigHandler); - - /* - ** Raise the priority of the current (main) thread so that subsequent - ** application initialization will complete. This had previously been - ** done by the BSP and but it is moved here. - ** - ** This will only work if the user owning this process has permission - ** to create real time threads. Otherwise, the default priority will - ** be retained. Typically this is only the root user, but finer grained - ** permission controls are out there. So if it works, great, but if - ** a permission denied error is generated, that is OK too - this allows - ** easily debugging code as a normal user. - */ - ret = pthread_getschedparam(pthread_self(), &sched_policy, &sched_param); - if (ret == 0) - { - POSIX_GlobalVars.SelectedRtScheduler = sched_policy; /* Fallback/default */ - do - { - sched_fifo_valid = OS_Posix_GetSchedulerParams(SCHED_FIFO, &sched_fifo_limits); - sched_rr_valid = OS_Posix_GetSchedulerParams(SCHED_RR, &sched_rr_limits); - - /* - * If both policies are valid, choose the best. In general, FIFO is preferred - * since it is simpler. - * - * But, RR is preferred if mapping several OSAL priority levels into the - * same local priority level. For instance, if 2 OSAL tasks are created at priorities - * "2" and "1", both may get mapped to local priority 98, and if using FIFO then the - * task at priority "2" could run indefinitely, never letting priority "1" execute. - * - * This violates the original intent, which would be to have priority "1" preempt - * priority "2" tasks. RR is less bad since it at least guarantees both tasks some - * CPU time, - */ - if (sched_fifo_valid && sched_rr_valid) - { - /* - * If the spread from min->max is greater than what OSAL actually needs, - * then FIFO is the preferred scheduler. Must take into account one extra level - * for the root task. - */ - if ((sched_fifo_limits.PriorityMax - sched_fifo_limits.PriorityMin) > OS_MAX_TASK_PRIORITY) - { - sched_policy = SCHED_FIFO; - POSIX_GlobalVars.PriLimits = sched_fifo_limits; - } - else - { - sched_policy = SCHED_RR; - POSIX_GlobalVars.PriLimits = sched_rr_limits; - } - - } - else if (sched_fifo_valid) - { - /* only FIFO is available */ - sched_policy = SCHED_FIFO; - POSIX_GlobalVars.PriLimits = sched_fifo_limits; - } - else if (sched_rr_valid) - { - /* only RR is available */ - sched_policy = SCHED_RR; - POSIX_GlobalVars.PriLimits = sched_rr_limits; - } - else - { - /* Nothing is valid, use default */ - break; - } - - /* - * This OSAL POSIX implementation will reserve the absolute highest priority - * for the root thread, which ultimately will just pend in sigsuspend() so - * it will not actually DO anything, except if sent a signal. This way, - * that thread will still be able to preempt a high-priority user thread that - * has gone awry (i.e. using 100% cpu in FIFO mode). - */ - sched_param.sched_priority = POSIX_GlobalVars.PriLimits.PriorityMax; - --POSIX_GlobalVars.PriLimits.PriorityMax; - - OS_DEBUG("Selected policy %d for RT tasks, root task = %d\n", sched_policy, (int)sched_param.sched_priority); - - /* - * If the spread from min->max is greater than what OSAL actually needs, - * then truncate it at the number of OSAL priorities. This will end up mapping 1:1. - * and leaving the highest priority numbers unused. - */ - if ((POSIX_GlobalVars.PriLimits.PriorityMax - POSIX_GlobalVars.PriLimits.PriorityMin) > OS_MAX_TASK_PRIORITY) - { - POSIX_GlobalVars.PriLimits.PriorityMax = POSIX_GlobalVars.PriLimits.PriorityMin + OS_MAX_TASK_PRIORITY; - } - - ret = pthread_setschedparam(pthread_self(), sched_policy, &sched_param); - if (ret != 0) - { - OS_DEBUG("Could not setschedparam in main thread: %s (%d)\n",strerror(ret),ret); - break; - } - - /* - * Set the boolean to indicate that "setschedparam" worked -- - * This means that it is also expected to work for future calls. - */ - POSIX_GlobalVars.SelectedRtScheduler = sched_policy; - POSIX_GlobalVars.EnableTaskPriorities = true; - } - while (0); - } - else - { - OS_DEBUG("Could not getschedparam in main thread: %s (%d)\n",strerror(ret),ret); - } + ret = pthread_getschedparam(pthread_self(), &sched_policy, &sched_param); + if (ret == 0) + { + POSIX_GlobalVars.SelectedRtScheduler = sched_policy; /* Fallback/default */ + do + { + sched_fifo_valid = OS_Posix_GetSchedulerParams(SCHED_FIFO, &sched_fifo_limits); + sched_rr_valid = OS_Posix_GetSchedulerParams(SCHED_RR, &sched_rr_limits); + + /* + * If both policies are valid, choose the best. In general, FIFO is preferred + * since it is simpler. + * + * But, RR is preferred if mapping several OSAL priority levels into the + * same local priority level. For instance, if 2 OSAL tasks are created at priorities + * "2" and "1", both may get mapped to local priority 98, and if using FIFO then the + * task at priority "2" could run indefinitely, never letting priority "1" execute. + * + * This violates the original intent, which would be to have priority "1" preempt + * priority "2" tasks. RR is less bad since it at least guarantees both tasks some + * CPU time, + */ + if (sched_fifo_valid && sched_rr_valid) + { + /* + * If the spread from min->max is greater than what OSAL actually needs, + * then FIFO is the preferred scheduler. Must take into account one extra level + * for the root task. + */ + if ((sched_fifo_limits.PriorityMax - sched_fifo_limits.PriorityMin) > OS_MAX_TASK_PRIORITY) + { + sched_policy = SCHED_FIFO; + POSIX_GlobalVars.PriLimits = sched_fifo_limits; + } + else + { + sched_policy = SCHED_RR; + POSIX_GlobalVars.PriLimits = sched_rr_limits; + } + } + else if (sched_fifo_valid) + { + /* only FIFO is available */ + sched_policy = SCHED_FIFO; + POSIX_GlobalVars.PriLimits = sched_fifo_limits; + } + else if (sched_rr_valid) + { + /* only RR is available */ + sched_policy = SCHED_RR; + POSIX_GlobalVars.PriLimits = sched_rr_limits; + } + else + { + /* Nothing is valid, use default */ + break; + } + + /* + * This OSAL POSIX implementation will reserve the absolute highest priority + * for the root thread, which ultimately will just pend in sigsuspend() so + * it will not actually DO anything, except if sent a signal. This way, + * that thread will still be able to preempt a high-priority user thread that + * has gone awry (i.e. using 100% cpu in FIFO mode). + */ + sched_param.sched_priority = POSIX_GlobalVars.PriLimits.PriorityMax; + --POSIX_GlobalVars.PriLimits.PriorityMax; + + OS_DEBUG("Selected policy %d for RT tasks, root task = %d\n", sched_policy, + (int)sched_param.sched_priority); + + /* + * If the spread from min->max is greater than what OSAL actually needs, + * then truncate it at the number of OSAL priorities. This will end up mapping 1:1. + * and leaving the highest priority numbers unused. + */ + if ((POSIX_GlobalVars.PriLimits.PriorityMax - POSIX_GlobalVars.PriLimits.PriorityMin) > + OS_MAX_TASK_PRIORITY) + { + POSIX_GlobalVars.PriLimits.PriorityMax = POSIX_GlobalVars.PriLimits.PriorityMin + OS_MAX_TASK_PRIORITY; + } + + ret = pthread_setschedparam(pthread_self(), sched_policy, &sched_param); + if (ret != 0) + { + OS_DEBUG("Could not setschedparam in main thread: %s (%d)\n", strerror(ret), ret); + break; + } + + /* + * Set the boolean to indicate that "setschedparam" worked -- + * This means that it is also expected to work for future calls. + */ + POSIX_GlobalVars.SelectedRtScheduler = sched_policy; + POSIX_GlobalVars.EnableTaskPriorities = true; + } while (0); + } + else + { + OS_DEBUG("Could not getschedparam in main thread: %s (%d)\n", strerror(ret), ret); + } #if !defined(OSAL_CONFIG_DEBUG_PERMISSIVE_MODE) - /* - * In strict (non-permissive) mode, if the task priority setting did not work, fail with an error. - * This would be used on a real target where it needs to be ensured that priorities are active - * and the "silent fallback" of debug mode operation is not desired. - */ - if (!POSIX_GlobalVars.EnableTaskPriorities) - { - return OS_ERROR; - } + /* + * In strict (non-permissive) mode, if the task priority setting did not work, fail with an error. + * This would be used on a real target where it needs to be ensured that priorities are active + * and the "silent fallback" of debug mode operation is not desired. + */ + if (!POSIX_GlobalVars.EnableTaskPriorities) + { + return OS_ERROR; + } #endif - POSIX_GlobalVars.PageSize = sysconf(_SC_PAGESIZE); + POSIX_GlobalVars.PageSize = sysconf(_SC_PAGESIZE); - return OS_SUCCESS; + return OS_SUCCESS; } /* end OS_Posix_TaskAPI_Impl_Init */ - /*---------------------------------------------------------------- * * Function: OS_Posix_InternalTaskCreate_Impl @@ -436,23 +429,23 @@ int32 OS_Posix_TaskAPI_Impl_Init(void) * Purpose: Local helper routine, not part of OSAL API. * *-----------------------------------------------------------------*/ -int32 OS_Posix_InternalTaskCreate_Impl(pthread_t *pthr, uint32 priority, size_t stacksz, PthreadFuncPtr_t entry, void *entry_arg) +int32 OS_Posix_InternalTaskCreate_Impl(pthread_t *pthr, uint32 priority, size_t stacksz, PthreadFuncPtr_t entry, + void *entry_arg) { int return_code = 0; pthread_attr_t custom_attr; struct sched_param priority_holder; - /* ** Initialize the pthread_attr structure. ** The structure is used to set the stack and priority */ memset(&custom_attr, 0, sizeof(custom_attr)); return_code = pthread_attr_init(&custom_attr); - if(return_code != 0) + if (return_code != 0) { - OS_DEBUG("pthread_attr_init error in OS_TaskCreate: %s\n",strerror(return_code)); - return(OS_ERROR); + OS_DEBUG("pthread_attr_init error in OS_TaskCreate: %s\n", strerror(return_code)); + return (OS_ERROR); } /* @@ -480,8 +473,8 @@ int32 OS_Posix_InternalTaskCreate_Impl(pthread_t *pthr, uint32 priority, size_t return_code = pthread_attr_setstacksize(&custom_attr, stacksz); if (return_code != 0) { - OS_DEBUG("pthread_attr_setstacksize error in OS_TaskCreate: %s\n",strerror(return_code)); - return(OS_ERROR); + OS_DEBUG("pthread_attr_setstacksize error in OS_TaskCreate: %s\n", strerror(return_code)); + return (OS_ERROR); } /* @@ -495,41 +488,40 @@ int32 OS_Posix_InternalTaskCreate_Impl(pthread_t *pthr, uint32 priority, size_t ** Set the scheduling inherit attribute to EXPLICIT */ return_code = pthread_attr_setinheritsched(&custom_attr, PTHREAD_EXPLICIT_SCHED); - if ( return_code != 0 ) + if (return_code != 0) + { + OS_DEBUG("pthread_attr_setinheritsched error in OS_TaskCreate, errno = %s\n", strerror(return_code)); + return (OS_ERROR); + } + + /* + ** Set the scheduling policy + ** The best policy is determined during initialization + */ + return_code = pthread_attr_setschedpolicy(&custom_attr, POSIX_GlobalVars.SelectedRtScheduler); + if (return_code != 0) { - OS_DEBUG("pthread_attr_setinheritsched error in OS_TaskCreate, errno = %s\n",strerror(return_code)); - return(OS_ERROR); + OS_DEBUG("pthread_attr_setschedpolity error in OS_TaskCreate: %s\n", strerror(return_code)); + return (OS_ERROR); } + /* + ** Set priority + */ + return_code = pthread_attr_getschedparam(&custom_attr, &priority_holder); + if (return_code != 0) + { + OS_DEBUG("pthread_attr_getschedparam error in OS_TaskCreate: %s\n", strerror(return_code)); + return (OS_ERROR); + } - /* - ** Set the scheduling policy - ** The best policy is determined during initialization - */ - return_code = pthread_attr_setschedpolicy(&custom_attr, POSIX_GlobalVars.SelectedRtScheduler); - if (return_code != 0) - { - OS_DEBUG("pthread_attr_setschedpolity error in OS_TaskCreate: %s\n",strerror(return_code)); - return(OS_ERROR); - } - - /* - ** Set priority - */ - return_code = pthread_attr_getschedparam(&custom_attr, &priority_holder); - if (return_code != 0) - { - OS_DEBUG("pthread_attr_getschedparam error in OS_TaskCreate: %s\n",strerror(return_code)); - return(OS_ERROR); - } - - priority_holder.sched_priority = OS_PriorityRemap(priority); - return_code = pthread_attr_setschedparam(&custom_attr,&priority_holder); - if(return_code != 0) - { - OS_DEBUG("pthread_attr_setschedparam error in OS_TaskCreate: %s\n",strerror(return_code)); - return(OS_ERROR); - } + priority_holder.sched_priority = OS_PriorityRemap(priority); + return_code = pthread_attr_setschedparam(&custom_attr, &priority_holder); + if (return_code != 0) + { + OS_DEBUG("pthread_attr_setschedparam error in OS_TaskCreate: %s\n", strerror(return_code)); + return (OS_ERROR); + } } /* End if user is root */ @@ -539,8 +531,8 @@ int32 OS_Posix_InternalTaskCreate_Impl(pthread_t *pthr, uint32 priority, size_t return_code = pthread_create(pthr, &custom_attr, entry, entry_arg); if (return_code != 0) { - OS_DEBUG("pthread_create error in OS_TaskCreate: %s\n",strerror(return_code)); - return(OS_ERROR); + OS_DEBUG("pthread_create error in OS_TaskCreate: %s\n", strerror(return_code)); + return (OS_ERROR); } /* @@ -552,19 +544,18 @@ int32 OS_Posix_InternalTaskCreate_Impl(pthread_t *pthr, uint32 priority, size_t return_code = pthread_detach(*pthr); if (return_code != 0) { - OS_DEBUG("pthread_detach error in OS_TaskCreate: %s\n",strerror(return_code)); + OS_DEBUG("pthread_detach error in OS_TaskCreate: %s\n", strerror(return_code)); } return_code = pthread_attr_destroy(&custom_attr); if (return_code != 0) { - OS_DEBUG("pthread_attr_destroy error in OS_TaskCreate: %s\n",strerror(return_code)); + OS_DEBUG("pthread_attr_destroy error in OS_TaskCreate: %s\n", strerror(return_code)); } return OS_SUCCESS; } /* end OS_Posix_InternalTaskCreate_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TaskCreate_Impl @@ -573,25 +564,21 @@ int32 OS_Posix_InternalTaskCreate_Impl(pthread_t *pthr, uint32 priority, size_t * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskCreate_Impl (uint32 task_id, uint32 flags) +int32 OS_TaskCreate_Impl(uint32 task_id, uint32 flags) { OS_U32ValueWrapper_t arg; - int32 return_code; + int32 return_code; arg.opaque_arg = NULL; - arg.id = OS_global_task_table[task_id].active_id; + arg.id = OS_global_task_table[task_id].active_id; - return_code = OS_Posix_InternalTaskCreate_Impl( - &OS_impl_task_table[task_id].id, - OS_task_table[task_id].priority, - OS_task_table[task_id].stack_size, - OS_PthreadTaskEntry, - arg.opaque_arg); + return_code = + OS_Posix_InternalTaskCreate_Impl(&OS_impl_task_table[task_id].id, OS_task_table[task_id].priority, + OS_task_table[task_id].stack_size, OS_PthreadTaskEntry, arg.opaque_arg); - return return_code; + return return_code; } /* end OS_TaskCreate_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TaskMatch_Impl @@ -602,15 +589,14 @@ int32 OS_TaskCreate_Impl (uint32 task_id, uint32 flags) *-----------------------------------------------------------------*/ int32 OS_TaskMatch_Impl(uint32 task_id) { - if (pthread_equal(pthread_self(), OS_impl_task_table[task_id].id) == 0) - { - return OS_ERROR; - } + if (pthread_equal(pthread_self(), OS_impl_task_table[task_id].id) == 0) + { + return OS_ERROR; + } - return OS_SUCCESS; + return OS_SUCCESS; } /* end OS_TaskMatch_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TaskDelete_Impl @@ -619,7 +605,7 @@ int32 OS_TaskMatch_Impl(uint32 task_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskDelete_Impl (uint32 task_id) +int32 OS_TaskDelete_Impl(uint32 task_id) { /* ** Try to delete the task @@ -632,7 +618,6 @@ int32 OS_TaskDelete_Impl (uint32 task_id) } /* end OS_TaskDelete_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TaskExit_Impl @@ -647,7 +632,6 @@ void OS_TaskExit_Impl() } /* end OS_TaskExit_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TaskDelay_Impl @@ -658,35 +642,33 @@ void OS_TaskExit_Impl() *-----------------------------------------------------------------*/ int32 OS_TaskDelay_Impl(uint32 millisecond) { - struct timespec sleep_end; - int status; - - clock_gettime(CLOCK_MONOTONIC, &sleep_end); - sleep_end.tv_sec += millisecond / 1000; - sleep_end.tv_nsec += 1000000 * (millisecond % 1000); - - if (sleep_end.tv_nsec >= 1000000000) - { - sleep_end.tv_nsec -= 1000000000; - ++sleep_end.tv_sec; - } - - do - { - status = clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &sleep_end, NULL); - } - while (status == EINTR); - - if (status != 0) - { - return OS_ERROR; - } - else - { - return OS_SUCCESS; - } -} /* end OS_TaskDelay_Impl */ + struct timespec sleep_end; + int status; + clock_gettime(CLOCK_MONOTONIC, &sleep_end); + sleep_end.tv_sec += millisecond / 1000; + sleep_end.tv_nsec += 1000000 * (millisecond % 1000); + + if (sleep_end.tv_nsec >= 1000000000) + { + sleep_end.tv_nsec -= 1000000000; + ++sleep_end.tv_sec; + } + + do + { + status = clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &sleep_end, NULL); + } while (status == EINTR); + + if (status != 0) + { + return OS_ERROR; + } + else + { + return OS_SUCCESS; + } +} /* end OS_TaskDelay_Impl */ /*---------------------------------------------------------------- * @@ -696,32 +678,31 @@ int32 OS_TaskDelay_Impl(uint32 millisecond) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskSetPriority_Impl (uint32 task_id, uint32 new_priority) +int32 OS_TaskSetPriority_Impl(uint32 task_id, uint32 new_priority) { - int os_priority; - int ret; + int os_priority; + int ret; if (POSIX_GlobalVars.EnableTaskPriorities) { - /* Change OSAL priority into a priority that will work for this OS */ - os_priority = OS_PriorityRemap(new_priority); - - /* - ** Set priority - */ - ret = pthread_setschedprio(OS_impl_task_table[task_id].id, os_priority); - if( ret != 0 ) - { - OS_DEBUG("pthread_setschedprio: Task ID = %u, prio = %d, err = %s\n", - (unsigned int)task_id,os_priority,strerror(ret)); - return(OS_ERROR); - } + /* Change OSAL priority into a priority that will work for this OS */ + os_priority = OS_PriorityRemap(new_priority); + + /* + ** Set priority + */ + ret = pthread_setschedprio(OS_impl_task_table[task_id].id, os_priority); + if (ret != 0) + { + OS_DEBUG("pthread_setschedprio: Task ID = %u, prio = %d, err = %s\n", (unsigned int)task_id, os_priority, + strerror(ret)); + return (OS_ERROR); + } } - return OS_SUCCESS; + return OS_SUCCESS; } /* end OS_TaskSetPriority_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TaskRegister_Impl @@ -732,26 +713,25 @@ int32 OS_TaskSetPriority_Impl (uint32 task_id, uint32 new_priority) *-----------------------------------------------------------------*/ int32 OS_TaskRegister_Impl(osal_id_t global_task_id) { - int32 return_code; - OS_U32ValueWrapper_t arg; - - arg.opaque_arg = 0; - arg.id = global_task_id; - - return_code = pthread_setspecific(POSIX_GlobalVars.ThreadKey, arg.opaque_arg); - if (return_code == 0) - { - return_code = OS_SUCCESS; - } - else - { - OS_DEBUG("OS_TaskRegister_Impl failed during pthread_setspecific() error=%s\n",strerror(return_code)); - return_code = OS_ERROR; - } - - return return_code; -} /* end OS_TaskRegister_Impl */ + int32 return_code; + OS_U32ValueWrapper_t arg; + arg.opaque_arg = 0; + arg.id = global_task_id; + + return_code = pthread_setspecific(POSIX_GlobalVars.ThreadKey, arg.opaque_arg); + if (return_code == 0) + { + return_code = OS_SUCCESS; + } + else + { + OS_DEBUG("OS_TaskRegister_Impl failed during pthread_setspecific() error=%s\n", strerror(return_code)); + return_code = OS_ERROR; + } + + return return_code; +} /* end OS_TaskRegister_Impl */ /*---------------------------------------------------------------- * @@ -761,16 +741,15 @@ int32 OS_TaskRegister_Impl(osal_id_t global_task_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -osal_id_t OS_TaskGetId_Impl (void) +osal_id_t OS_TaskGetId_Impl(void) { - OS_U32ValueWrapper_t self_record; + OS_U32ValueWrapper_t self_record; - self_record.opaque_arg = pthread_getspecific(POSIX_GlobalVars.ThreadKey); + self_record.opaque_arg = pthread_getspecific(POSIX_GlobalVars.ThreadKey); - return(self_record.id); + return (self_record.id); } /* end OS_TaskGetId_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TaskGetInfo_Impl @@ -779,12 +758,11 @@ osal_id_t OS_TaskGetId_Impl (void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskGetInfo_Impl (uint32 task_id, OS_task_prop_t *task_prop) +int32 OS_TaskGetInfo_Impl(uint32 task_id, OS_task_prop_t *task_prop) { - return OS_SUCCESS; + return OS_SUCCESS; } /* end OS_TaskGetInfo_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TaskIdMatchSystemData_Impl @@ -816,6 +794,3 @@ int32 OS_TaskValidateSystemData_Impl(const void *sysdata, uint32 sysdata_size) } return OS_SUCCESS; } - - - diff --git a/src/os/posix/src/os-impl-timebase.c b/src/os/posix/src/os-impl-timebase.c index 9c7c23642..c4c23b13e 100644 --- a/src/os/posix/src/os-impl-timebase.c +++ b/src/os/posix/src/os-impl-timebase.c @@ -41,7 +41,6 @@ #include "os-shared-idmap.h" #include "os-shared-common.h" - /**************************************************************************************** EXTERNAL FUNCTION PROTOTYPES ***************************************************************************************/ @@ -50,7 +49,7 @@ INTERNAL FUNCTION PROTOTYPES ***************************************************************************************/ -static void OS_UsecToTimespec(uint32 usecs, struct timespec *time_spec); +static void OS_UsecToTimespec(uint32 usecs, struct timespec *time_spec); /**************************************************************************************** DEFINES @@ -61,10 +60,10 @@ static void OS_UsecToTimespec(uint32 usecs, struct timespec *time_spec); * the time like the REALTIME clock will. */ #ifndef OS_PREFERRED_CLOCK -#ifdef _POSIX_MONOTONIC_CLOCK -#define OS_PREFERRED_CLOCK CLOCK_MONOTONIC +#ifdef _POSIX_MONOTONIC_CLOCK +#define OS_PREFERRED_CLOCK CLOCK_MONOTONIC #else -#define OS_PREFERRED_CLOCK CLOCK_REALTIME +#define OS_PREFERRED_CLOCK CLOCK_REALTIME #endif #endif @@ -78,7 +77,6 @@ OS_impl_timebase_internal_record_t OS_impl_timebase_table[OS_MAX_TIMEBASES]; INTERNAL FUNCTIONS ***************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_UsecToTimespec @@ -90,16 +88,16 @@ OS_impl_timebase_internal_record_t OS_impl_timebase_table[OS_MAX_TIMEBASES]; static void OS_UsecToTimespec(uint32 usecs, struct timespec *time_spec) { - if ( usecs < 1000000 ) - { - time_spec->tv_nsec = (usecs * 1000); - time_spec->tv_sec = 0; - } - else - { - time_spec->tv_sec = usecs / 1000000; - time_spec->tv_nsec = (usecs % 1000000) * 1000; - } + if (usecs < 1000000) + { + time_spec->tv_nsec = (usecs * 1000); + time_spec->tv_sec = 0; + } + else + { + time_spec->tv_sec = usecs / 1000000; + time_spec->tv_nsec = (usecs % 1000000) * 1000; + } } /* end OS_UsecToTimespec */ /*---------------------------------------------------------------- @@ -128,7 +126,6 @@ void OS_TimeBaseUnlock_Impl(uint32 local_id) pthread_mutex_unlock(&OS_impl_timebase_table[local_id].handler_mutex); } /* end OS_TimeBaseUnlock_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TimeBase_SoftWaitImpl @@ -138,10 +135,10 @@ void OS_TimeBaseUnlock_Impl(uint32 local_id) *-----------------------------------------------------------------*/ static uint32 OS_TimeBase_SigWaitImpl(uint32 timer_id) { - int ret; + int ret; OS_impl_timebase_internal_record_t *local; - uint32 interval_time; - int sig; + uint32 interval_time; + int sig; local = &OS_impl_timebase_table[timer_id]; @@ -170,14 +167,13 @@ static uint32 OS_TimeBase_SigWaitImpl(uint32 timer_id) * timer_set() was invoked since the previous interval occurred (if any). * interval_time reflects the configured start time. */ - interval_time = OS_timebase_table[timer_id].nominal_start_time; + interval_time = OS_timebase_table[timer_id].nominal_start_time; local->reset_flag = 0; } return interval_time; } /* end OS_TimeBase_SoftWaitImpl */ - /**************************************************************************************** INITIALIZATION FUNCTION ***************************************************************************************/ @@ -193,110 +189,108 @@ static uint32 OS_TimeBase_SigWaitImpl(uint32 timer_id) */ int32 OS_Posix_TimeBaseAPI_Impl_Init(void) { - int status; - int i; - pthread_mutexattr_t mutex_attr; - struct timespec clock_resolution; - int32 return_code; - - return_code = OS_SUCCESS; - - do - { - /* - ** Mark all timers as available - */ - memset(OS_impl_timebase_table, 0, sizeof(OS_impl_timebase_table)); - - /* - ** get the resolution of the selected clock - */ - status = clock_getres(OS_PREFERRED_CLOCK, &clock_resolution); - if ( status != 0 ) - { - OS_DEBUG("failed in clock_getres: %s\n",strerror(status)); - return_code = OS_ERROR; - break; - } - - /* - ** Convert to microseconds - ** Note that the resolution MUST be in the sub-second range, if not then - ** it looks like the POSIX timer API in the C library is broken. - ** Note for any flavor of RTOS we would expect <= 1ms. Even a "desktop" - ** linux or development system should be <= 100ms absolute worst-case. - */ - if ( clock_resolution.tv_sec > 0 ) - { - return_code = OS_TIMER_ERR_INTERNAL; - break; - } - - /* Round to the nearest microsecond */ - POSIX_GlobalVars.ClockAccuracyNsec = (uint32)(clock_resolution.tv_nsec); - - /* - ** initialize the attribute with default values - */ - status = pthread_mutexattr_init(&mutex_attr); - if ( status != 0 ) - { - OS_DEBUG("Error: pthread_mutexattr_init failed: %s\n",strerror(status)); - return_code = OS_ERROR; - break; - } - - /* - ** Allow the mutex to use priority inheritance - */ - status = pthread_mutexattr_setprotocol(&mutex_attr,PTHREAD_PRIO_INHERIT); - if ( status != 0 ) - { - OS_DEBUG("Error: pthread_mutexattr_setprotocol failed: %s\n",strerror(status)); - return_code = OS_ERROR; - break; - } - - for (i = 0; i < OS_MAX_TIMEBASES; ++i) - { - /* - ** create the timebase sync mutex - ** This gives a mechanism to synchronize updates to the timer chain with the - ** expiration of the timer and processing the chain. - */ - status = pthread_mutex_init(&OS_impl_timebase_table[i].handler_mutex, &mutex_attr); - if ( status != 0 ) - { - OS_DEBUG("Error: Mutex could not be created: %s\n",strerror(status)); - return_code = OS_ERROR; - break; - } - } - - /* - * Pre-calculate the clock tick to microsecond conversion factor. + int status; + int i; + pthread_mutexattr_t mutex_attr; + struct timespec clock_resolution; + int32 return_code; + + return_code = OS_SUCCESS; + + do + { + /* + ** Mark all timers as available */ - OS_SharedGlobalVars.TicksPerSecond = sysconf(_SC_CLK_TCK); - if (OS_SharedGlobalVars.TicksPerSecond <= 0) - { - OS_DEBUG("Error: Unable to determine OS ticks per second: %s\n",strerror(errno)); - return_code = OS_ERROR; - break; - } - - /* - * Calculate microseconds per tick - * - If the ratio is not an integer, this will round to the nearest integer value - * - This is used internally for reporting accuracy, - * - TicksPerSecond values over 2M will return zero + memset(OS_impl_timebase_table, 0, sizeof(OS_impl_timebase_table)); + + /* + ** get the resolution of the selected clock */ - OS_SharedGlobalVars.MicroSecPerTick = (1000000 + (OS_SharedGlobalVars.TicksPerSecond / 2)) / - OS_SharedGlobalVars.TicksPerSecond; - } - while(0); + status = clock_getres(OS_PREFERRED_CLOCK, &clock_resolution); + if (status != 0) + { + OS_DEBUG("failed in clock_getres: %s\n", strerror(status)); + return_code = OS_ERROR; + break; + } + /* + ** Convert to microseconds + ** Note that the resolution MUST be in the sub-second range, if not then + ** it looks like the POSIX timer API in the C library is broken. + ** Note for any flavor of RTOS we would expect <= 1ms. Even a "desktop" + ** linux or development system should be <= 100ms absolute worst-case. + */ + if (clock_resolution.tv_sec > 0) + { + return_code = OS_TIMER_ERR_INTERNAL; + break; + } - return(return_code); + /* Round to the nearest microsecond */ + POSIX_GlobalVars.ClockAccuracyNsec = (uint32)(clock_resolution.tv_nsec); + + /* + ** initialize the attribute with default values + */ + status = pthread_mutexattr_init(&mutex_attr); + if (status != 0) + { + OS_DEBUG("Error: pthread_mutexattr_init failed: %s\n", strerror(status)); + return_code = OS_ERROR; + break; + } + + /* + ** Allow the mutex to use priority inheritance + */ + status = pthread_mutexattr_setprotocol(&mutex_attr, PTHREAD_PRIO_INHERIT); + if (status != 0) + { + OS_DEBUG("Error: pthread_mutexattr_setprotocol failed: %s\n", strerror(status)); + return_code = OS_ERROR; + break; + } + + for (i = 0; i < OS_MAX_TIMEBASES; ++i) + { + /* + ** create the timebase sync mutex + ** This gives a mechanism to synchronize updates to the timer chain with the + ** expiration of the timer and processing the chain. + */ + status = pthread_mutex_init(&OS_impl_timebase_table[i].handler_mutex, &mutex_attr); + if (status != 0) + { + OS_DEBUG("Error: Mutex could not be created: %s\n", strerror(status)); + return_code = OS_ERROR; + break; + } + } + + /* + * Pre-calculate the clock tick to microsecond conversion factor. + */ + OS_SharedGlobalVars.TicksPerSecond = sysconf(_SC_CLK_TCK); + if (OS_SharedGlobalVars.TicksPerSecond <= 0) + { + OS_DEBUG("Error: Unable to determine OS ticks per second: %s\n", strerror(errno)); + return_code = OS_ERROR; + break; + } + + /* + * Calculate microseconds per tick + * - If the ratio is not an integer, this will round to the nearest integer value + * - This is used internally for reporting accuracy, + * - TicksPerSecond values over 2M will return zero + */ + OS_SharedGlobalVars.MicroSecPerTick = + (1000000 + (OS_SharedGlobalVars.TicksPerSecond / 2)) / OS_SharedGlobalVars.TicksPerSecond; + } while (0); + + return (return_code); } /* end OS_Posix_TimeBaseAPI_Impl_Init */ /**************************************************************************************** @@ -322,17 +316,16 @@ static void *OS_TimeBasePthreadEntry(void *arg) *-----------------------------------------------------------------*/ int32 OS_TimeBaseCreate_Impl(uint32 timer_id) { - int32 return_code; - int status; - int i; - struct sigevent evp; - struct timespec ts; + int32 return_code; + int status; + int i; + struct sigevent evp; + struct timespec ts; OS_impl_timebase_internal_record_t *local; - OS_common_record_t *global; - OS_U32ValueWrapper_t arg; - + OS_common_record_t * global; + OS_U32ValueWrapper_t arg; - local = &OS_impl_timebase_table[timer_id]; + local = &OS_impl_timebase_table[timer_id]; global = &OS_global_timebase_table[timer_id]; /* @@ -346,8 +339,9 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id) * the global table lock. */ arg.opaque_arg = NULL; - arg.id = global->active_id; - return_code = OS_Posix_InternalTaskCreate_Impl(&local->handler_thread, 0, 0, OS_TimeBasePthreadEntry, arg.opaque_arg); + arg.id = global->active_id; + return_code = + OS_Posix_InternalTaskCreate_Impl(&local->handler_thread, 0, 0, OS_TimeBasePthreadEntry, arg.opaque_arg); if (return_code != OS_SUCCESS) { return return_code; @@ -374,17 +368,16 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id) * This is all done while the global lock is held so no chance of the * underlying tables changing */ - for(i = 0; i < OS_MAX_TIMEBASES; ++i) + for (i = 0; i < OS_MAX_TIMEBASES; ++i) { - if (i != timer_id && - OS_ObjectIdDefined(OS_global_timebase_table[i].active_id) && - OS_impl_timebase_table[i].assigned_signal != 0) + if (i != timer_id && OS_ObjectIdDefined(OS_global_timebase_table[i].active_id) && + OS_impl_timebase_table[i].assigned_signal != 0) { sigaddset(&local->sigset, OS_impl_timebase_table[i].assigned_signal); } } - for(i = SIGRTMIN; i <= SIGRTMAX; ++i) + for (i = SIGRTMIN; i <= SIGRTMAX; ++i) { if (!sigismember(&local->sigset, i)) { @@ -419,10 +412,10 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id) * The output is irrelevant here; the objective is to just ensure * that the signal is not already pending. */ - i = sysconf( _SC_SIGQUEUE_MAX); + i = sysconf(_SC_SIGQUEUE_MAX); do { - ts.tv_sec = 0; + ts.tv_sec = 0; ts.tv_nsec = 0; if (sigtimedwait(&local->sigset, NULL, &ts) < 0) { @@ -430,15 +423,14 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id) break; } --i; - } - while(i > 0); + } while (i > 0); /* ** Initialize the sigevent structures for the handler. */ memset((void *)&evp, 0, sizeof(evp)); evp.sigev_notify = SIGEV_SIGNAL; - evp.sigev_signo = local->assigned_signal; + evp.sigev_signo = local->assigned_signal; /* * Pass the Timer Index value of the object ID to the signal handler -- @@ -461,9 +453,7 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id) } OS_timebase_table[timer_id].external_sync = OS_TimeBase_SigWaitImpl; - } - while (0); - + } while (0); } if (return_code != OS_SUCCESS) @@ -492,11 +482,11 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id) int32 OS_TimeBaseSet_Impl(uint32 timer_id, int32 start_time, int32 interval_time) { OS_impl_timebase_internal_record_t *local; - struct itimerspec timeout; - int32 return_code; - int status; + struct itimerspec timeout; + int32 return_code; + int status; - local = &OS_impl_timebase_table[timer_id]; + local = &OS_impl_timebase_table[timer_id]; return_code = OS_SUCCESS; /* There is only something to do here if we are generating a simulated tick */ @@ -512,14 +502,13 @@ int32 OS_TimeBaseSet_Impl(uint32 timer_id, int32 start_time, int32 interval_time /* ** Program the real timer */ - status = timer_settime(local->host_timerid, - 0, /* Flags field can be zero */ - &timeout, /* struct itimerspec */ - NULL); /* Oldvalue */ + status = timer_settime(local->host_timerid, 0, /* Flags field can be zero */ + &timeout, /* struct itimerspec */ + NULL); /* Oldvalue */ if (status < 0) { - OS_DEBUG("Error in timer_settime: %s\n",strerror(errno)); + OS_DEBUG("Error in timer_settime: %s\n", strerror(errno)); return_code = OS_TIMER_ERR_INTERNAL; } else if (interval_time > 0) @@ -536,8 +525,6 @@ int32 OS_TimeBaseSet_Impl(uint32 timer_id, int32 start_time, int32 interval_time return return_code; } /* end OS_TimeBaseSet_Impl */ - - /*---------------------------------------------------------------- * * Function: OS_TimeBaseDelete_Impl @@ -549,7 +536,7 @@ int32 OS_TimeBaseSet_Impl(uint32 timer_id, int32 start_time, int32 interval_time int32 OS_TimeBaseDelete_Impl(uint32 timer_id) { OS_impl_timebase_internal_record_t *local; - int status; + int status; local = &OS_impl_timebase_table[timer_id]; @@ -563,8 +550,8 @@ int32 OS_TimeBaseDelete_Impl(uint32 timer_id) status = timer_delete(OS_impl_timebase_table[timer_id].host_timerid); if (status < 0) { - OS_DEBUG("Error deleting timer: %s\n",strerror(errno)); - return ( OS_TIMER_ERR_INTERNAL); + OS_DEBUG("Error deleting timer: %s\n", strerror(errno)); + return (OS_TIMER_ERR_INTERNAL); } local->assigned_signal = 0; @@ -573,7 +560,6 @@ int32 OS_TimeBaseDelete_Impl(uint32 timer_id) return OS_SUCCESS; } /* end OS_TimeBaseDelete_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TimeBaseGetInfo_Impl @@ -582,9 +568,8 @@ int32 OS_TimeBaseDelete_Impl(uint32 timer_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TimeBaseGetInfo_Impl (uint32 timer_id, OS_timebase_prop_t *timer_prop) +int32 OS_TimeBaseGetInfo_Impl(uint32 timer_id, OS_timebase_prop_t *timer_prop) { return OS_SUCCESS; } /* end OS_TimeBaseGetInfo_Impl */ - diff --git a/src/os/rtems/inc/os-impl-binsem.h b/src/os/rtems/inc/os-impl-binsem.h index 39f1788ab..5b0324cac 100644 --- a/src/os/rtems/inc/os-impl-binsem.h +++ b/src/os/rtems/inc/os-impl-binsem.h @@ -37,9 +37,6 @@ typedef struct } OS_impl_binsem_internal_record_t; /* Tables where the OS object information is stored */ -extern OS_impl_binsem_internal_record_t OS_impl_bin_sem_table [OS_MAX_BIN_SEMAPHORES]; - - - -#endif /* INCLUDE_OS_IMPL_BINSEM_H_ */ +extern OS_impl_binsem_internal_record_t OS_impl_bin_sem_table[OS_MAX_BIN_SEMAPHORES]; +#endif /* INCLUDE_OS_IMPL_BINSEM_H_ */ diff --git a/src/os/rtems/inc/os-impl-console.h b/src/os/rtems/inc/os-impl-console.h index ae2fa9420..b74d52b00 100644 --- a/src/os/rtems/inc/os-impl-console.h +++ b/src/os/rtems/inc/os-impl-console.h @@ -36,12 +36,10 @@ /* Console device */ typedef struct { - bool is_async; - sem_t data_sem; -}OS_impl_console_internal_record_t; + bool is_async; + sem_t data_sem; +} OS_impl_console_internal_record_t; +extern OS_impl_console_internal_record_t OS_impl_console_table[OS_MAX_CONSOLES]; -extern OS_impl_console_internal_record_t OS_impl_console_table [OS_MAX_CONSOLES]; - -#endif /* INCLUDE_OS_IMPL_CONSOLE_H_ */ - +#endif /* INCLUDE_OS_IMPL_CONSOLE_H_ */ diff --git a/src/os/rtems/inc/os-impl-countsem.h b/src/os/rtems/inc/os-impl-countsem.h index 8ed22a22d..fc3cf73a7 100644 --- a/src/os/rtems/inc/os-impl-countsem.h +++ b/src/os/rtems/inc/os-impl-countsem.h @@ -37,8 +37,6 @@ typedef struct } OS_impl_countsem_internal_record_t; /* Tables where the OS object information is stored */ -extern OS_impl_countsem_internal_record_t OS_impl_count_sem_table [OS_MAX_COUNT_SEMAPHORES]; - - -#endif /* INCLUDE_OS_IMPL_COUNTSEM_H_ */ +extern OS_impl_countsem_internal_record_t OS_impl_count_sem_table[OS_MAX_COUNT_SEMAPHORES]; +#endif /* INCLUDE_OS_IMPL_COUNTSEM_H_ */ diff --git a/src/os/rtems/inc/os-impl-dirs.h b/src/os/rtems/inc/os-impl-dirs.h index 18f8d16a4..82bca79b3 100644 --- a/src/os/rtems/inc/os-impl-dirs.h +++ b/src/os/rtems/inc/os-impl-dirs.h @@ -40,12 +40,9 @@ typedef struct DIR *dp; } OS_impl_dir_internal_record_t; - /* * The directory handle table. */ extern OS_impl_dir_internal_record_t OS_impl_dir_table[OS_MAX_NUM_OPEN_DIRS]; - -#endif /* INCLUDE_OS_IMPL_DIRS_H_ */ - +#endif /* INCLUDE_OS_IMPL_DIRS_H_ */ diff --git a/src/os/rtems/inc/os-impl-files.h b/src/os/rtems/inc/os-impl-files.h index ab4df4cb6..a5d5ea848 100644 --- a/src/os/rtems/inc/os-impl-files.h +++ b/src/os/rtems/inc/os-impl-files.h @@ -37,10 +37,9 @@ /* * RTEMS does not have UID/GID so these are defined as 0. */ -#define OS_IMPL_SELF_EUID 0 -#define OS_IMPL_SELF_EGID 0 +#define OS_IMPL_SELF_EUID 0 +#define OS_IMPL_SELF_EGID 0 -#define OS_IMPL_REGULAR_FILE_FLAGS 0 - -#endif /* INCLUDE_OS_IMPL_FILES_H_ */ +#define OS_IMPL_REGULAR_FILE_FLAGS 0 +#endif /* INCLUDE_OS_IMPL_FILES_H_ */ diff --git a/src/os/rtems/inc/os-impl-gettime.h b/src/os/rtems/inc/os-impl-gettime.h index 2d899bde3..166a125d2 100644 --- a/src/os/rtems/inc/os-impl-gettime.h +++ b/src/os/rtems/inc/os-impl-gettime.h @@ -31,9 +31,6 @@ #include #include +#define OSAL_GETTIME_SOURCE_CLOCK CLOCK_MONOTONIC -#define OSAL_GETTIME_SOURCE_CLOCK CLOCK_MONOTONIC - - -#endif /* INCLUDE_OS_IMPL_GETTIME_H_ */ - +#endif /* INCLUDE_OS_IMPL_GETTIME_H_ */ diff --git a/src/os/rtems/inc/os-impl-io.h b/src/os/rtems/inc/os-impl-io.h index 8813762f8..9fc1893c1 100644 --- a/src/os/rtems/inc/os-impl-io.h +++ b/src/os/rtems/inc/os-impl-io.h @@ -34,7 +34,7 @@ typedef struct { - int fd; + int fd; bool selectable; } OS_Rtems_filehandle_entry_t; @@ -46,6 +46,4 @@ typedef struct */ extern OS_Rtems_filehandle_entry_t OS_impl_filehandle_table[OS_MAX_NUM_OPEN_FILES]; - -#endif /* INCLUDE_OS_IMPL_IO_H_ */ - +#endif /* INCLUDE_OS_IMPL_IO_H_ */ diff --git a/src/os/rtems/inc/os-impl-loader.h b/src/os/rtems/inc/os-impl-loader.h index a6d824046..53c964630 100644 --- a/src/os/rtems/inc/os-impl-loader.h +++ b/src/os/rtems/inc/os-impl-loader.h @@ -34,7 +34,6 @@ #include #include - /**************************************************************************************** GLOBAL DATA ***************************************************************************************/ @@ -51,7 +50,4 @@ typedef struct extern OS_impl_module_internal_record_t OS_impl_module_table[OS_MAX_MODULES]; - - -#endif /* INCLUDE_OS_IMPL_LOADER_H_ */ - +#endif /* INCLUDE_OS_IMPL_LOADER_H_ */ diff --git a/src/os/rtems/inc/os-impl-mutex.h b/src/os/rtems/inc/os-impl-mutex.h index 4dab47d9d..df247192e 100644 --- a/src/os/rtems/inc/os-impl-mutex.h +++ b/src/os/rtems/inc/os-impl-mutex.h @@ -37,8 +37,6 @@ typedef struct } OS_impl_mutex_internal_record_t; /* Tables where the OS object information is stored */ -extern OS_impl_mutex_internal_record_t OS_impl_mutex_table [OS_MAX_MUTEXES]; - - -#endif /* INCLUDE_OS_IMPL_MUTEX_H_ */ +extern OS_impl_mutex_internal_record_t OS_impl_mutex_table[OS_MAX_MUTEXES]; +#endif /* INCLUDE_OS_IMPL_MUTEX_H_ */ diff --git a/src/os/rtems/inc/os-impl-queues.h b/src/os/rtems/inc/os-impl-queues.h index 5a1f48523..cf47ff9e4 100644 --- a/src/os/rtems/inc/os-impl-queues.h +++ b/src/os/rtems/inc/os-impl-queues.h @@ -36,11 +36,7 @@ typedef struct rtems_id id; } OS_impl_queue_internal_record_t; - - /* Tables where the OS object information is stored */ -extern OS_impl_queue_internal_record_t OS_impl_queue_table [OS_MAX_QUEUES]; - - -#endif /* INCLUDE_OS_IMPL_QUEUES_H_ */ +extern OS_impl_queue_internal_record_t OS_impl_queue_table[OS_MAX_QUEUES]; +#endif /* INCLUDE_OS_IMPL_QUEUES_H_ */ diff --git a/src/os/rtems/inc/os-impl-select.h b/src/os/rtems/inc/os-impl-select.h index 549d111bc..a2080c79c 100644 --- a/src/os/rtems/inc/os-impl-select.h +++ b/src/os/rtems/inc/os-impl-select.h @@ -33,6 +33,4 @@ #include #include - -#endif /* INCLUDE_OS_IMPL_SELECT_H_ */ - +#endif /* INCLUDE_OS_IMPL_SELECT_H_ */ diff --git a/src/os/rtems/inc/os-impl-sockets.h b/src/os/rtems/inc/os-impl-sockets.h index 11111d6fa..1144bc383 100644 --- a/src/os/rtems/inc/os-impl-sockets.h +++ b/src/os/rtems/inc/os-impl-sockets.h @@ -41,9 +41,6 @@ * A RTEMS socket I/O layer should support using * nonblocking I/O calls in combination with select(). */ -#define OS_IMPL_SOCKET_FLAGS O_NONBLOCK - - - -#endif /* INCLUDE_OS_IMPL_SOCKETS_H_ */ +#define OS_IMPL_SOCKET_FLAGS O_NONBLOCK +#endif /* INCLUDE_OS_IMPL_SOCKETS_H_ */ diff --git a/src/os/rtems/inc/os-impl-tasks.h b/src/os/rtems/inc/os-impl-tasks.h index 0e3550825..f1e648c08 100644 --- a/src/os/rtems/inc/os-impl-tasks.h +++ b/src/os/rtems/inc/os-impl-tasks.h @@ -36,10 +36,7 @@ typedef struct rtems_id id; } OS_impl_task_internal_record_t; - /* Tables where the OS object information is stored */ -extern OS_impl_task_internal_record_t OS_impl_task_table [OS_MAX_TASKS]; - - -#endif /* INCLUDE_OS_IMPL_TASKS_H_ */ +extern OS_impl_task_internal_record_t OS_impl_task_table[OS_MAX_TASKS]; +#endif /* INCLUDE_OS_IMPL_TASKS_H_ */ diff --git a/src/os/rtems/inc/os-impl-timebase.h b/src/os/rtems/inc/os-impl-timebase.h index ed1da72e1..86853f96c 100644 --- a/src/os/rtems/inc/os-impl-timebase.h +++ b/src/os/rtems/inc/os-impl-timebase.h @@ -32,16 +32,15 @@ #include #include - typedef struct { - pthread_t handler_thread; - pthread_mutex_t handler_mutex; - timer_t host_timerid; - int assigned_signal; - sigset_t sigset; - sig_atomic_t reset_flag; - struct timespec softsleep; + pthread_t handler_thread; + pthread_mutex_t handler_mutex; + timer_t host_timerid; + int assigned_signal; + sigset_t sigset; + sig_atomic_t reset_flag; + struct timespec softsleep; } OS_impl_timebase_internal_record_t; @@ -51,6 +50,4 @@ typedef struct extern OS_impl_timebase_internal_record_t OS_impl_timebase_table[OS_MAX_TIMEBASES]; - -#endif /* INCLUDE_OS_IMPL_TIMEBASE_H_ */ - +#endif /* INCLUDE_OS_IMPL_TIMEBASE_H_ */ diff --git a/src/os/rtems/inc/os-rtems.h b/src/os/rtems/inc/os-rtems.h index 07d199c46..c8cf01159 100644 --- a/src/os/rtems/inc/os-rtems.h +++ b/src/os/rtems/inc/os-rtems.h @@ -31,7 +31,6 @@ #ifndef INCLUDE_OS_RTEMS_H_ #define INCLUDE_OS_RTEMS_H_ - /**************************************************************************************** COMMON INCLUDE FILES ***************************************************************************************/ @@ -60,18 +59,16 @@ typedef struct { - uint32 ClockAccuracyNsec; - rtems_id IdleTaskId; + uint32 ClockAccuracyNsec; + rtems_id IdleTaskId; } RTEMS_GlobalVars_t; - /**************************************************************************************** GLOBAL DATA ***************************************************************************************/ extern RTEMS_GlobalVars_t RTEMS_GlobalVars; - /**************************************************************************************** RTEMS IMPLEMENTATION FUNCTION PROTOTYPES ***************************************************************************************/ @@ -87,9 +84,6 @@ int32 OS_Rtems_StreamAPI_Impl_Init(void); int32 OS_Rtems_DirAPI_Impl_Init(void); int32 OS_Rtems_FileSysAPI_Impl_Init(void); - int32 OS_Rtems_TableMutex_Init(uint32 idtype); - -#endif /* INCLUDE_OS_RTEMS_H_ */ - +#endif /* INCLUDE_OS_RTEMS_H_ */ diff --git a/src/os/rtems/src/os-impl-binsem.c b/src/os/rtems/src/os-impl-binsem.c index 38000a4ef..5d34c2079 100644 --- a/src/os/rtems/src/os-impl-binsem.c +++ b/src/os/rtems/src/os-impl-binsem.c @@ -41,7 +41,6 @@ #include "os-shared-idmap.h" #include "os-shared-timebase.h" - /**************************************************************************************** DEFINES ***************************************************************************************/ @@ -55,23 +54,18 @@ #define OSAL_BINARY_SEM_ATTRIBS (RTEMS_SIMPLE_BINARY_SEMAPHORE | RTEMS_PRIORITY) - - /**************************************************************************************** GLOBAL DATA ***************************************************************************************/ /* tables for the properties of objects */ - /* Tables where the OS object information is stored */ -OS_impl_binsem_internal_record_t OS_impl_bin_sem_table [OS_MAX_BIN_SEMAPHORES]; - +OS_impl_binsem_internal_record_t OS_impl_bin_sem_table[OS_MAX_BIN_SEMAPHORES]; /**************************************************************************************** SEMAPHORE API ***************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_Rtems_BinSemAPI_Impl_Init @@ -85,7 +79,6 @@ int32 OS_Rtems_BinSemAPI_Impl_Init(void) return (OS_SUCCESS); } /* end OS_Rtems_BinSemAPI_Impl_Init */ - /*---------------------------------------------------------------- * * Function: OS_BinSemCreate_Impl @@ -94,7 +87,7 @@ int32 OS_Rtems_BinSemAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 options) +int32 OS_BinSemCreate_Impl(uint32 sem_id, uint32 sem_initial_value, uint32 options) { rtems_status_code status; rtems_name r_name; @@ -113,15 +106,13 @@ int32 OS_BinSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 opti } /* Create RTEMS Semaphore */ - status = rtems_semaphore_create( r_name, sem_initial_value, - OSAL_BINARY_SEM_ATTRIBS, - 0, - &(OS_impl_bin_sem_table[sem_id].id)); + status = rtems_semaphore_create(r_name, sem_initial_value, OSAL_BINARY_SEM_ATTRIBS, 0, + &(OS_impl_bin_sem_table[sem_id].id)); /* check if Create failed */ - if ( status != RTEMS_SUCCESSFUL ) + if (status != RTEMS_SUCCESSFUL) { - OS_DEBUG("Unhandled semaphore_create error: %s\n",rtems_status_text(status)); + OS_DEBUG("Unhandled semaphore_create error: %s\n", rtems_status_text(status)); return OS_SEM_FAILURE; } @@ -129,8 +120,6 @@ int32 OS_BinSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 opti } /* end OS_BinSemCreate_Impl */ - - /*---------------------------------------------------------------- * * Function: OS_BinSemDelete_Impl @@ -139,14 +128,14 @@ int32 OS_BinSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 opti * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemDelete_Impl (uint32 sem_id) +int32 OS_BinSemDelete_Impl(uint32 sem_id) { rtems_status_code status; status = rtems_semaphore_delete(OS_impl_bin_sem_table[sem_id].id); - if(status != RTEMS_SUCCESSFUL) + if (status != RTEMS_SUCCESSFUL) { - OS_DEBUG("Unhandled semaphore_delete error: %s\n",rtems_status_text(status)); + OS_DEBUG("Unhandled semaphore_delete error: %s\n", rtems_status_text(status)); return OS_SEM_FAILURE; } @@ -154,7 +143,6 @@ int32 OS_BinSemDelete_Impl (uint32 sem_id) } /* end OS_BinSemDelete_Impl */ - /*---------------------------------------------------------------- * * Function: OS_BinSemGive_Impl @@ -163,21 +151,20 @@ int32 OS_BinSemDelete_Impl (uint32 sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemGive_Impl (uint32 sem_id) +int32 OS_BinSemGive_Impl(uint32 sem_id) { rtems_status_code status; status = rtems_semaphore_release(OS_impl_bin_sem_table[sem_id].id); - if(status != RTEMS_SUCCESSFUL) + if (status != RTEMS_SUCCESSFUL) { - OS_DEBUG("Unhandled semaphore_release error: %s\n",rtems_status_text(status)); + OS_DEBUG("Unhandled semaphore_release error: %s\n", rtems_status_text(status)); return OS_SEM_FAILURE; } - return OS_SUCCESS; + return OS_SUCCESS; } /* end OS_BinSemGive_Impl */ - /*---------------------------------------------------------------- * * Function: OS_BinSemFlush_Impl @@ -186,23 +173,22 @@ int32 OS_BinSemGive_Impl (uint32 sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemFlush_Impl (uint32 sem_id) +int32 OS_BinSemFlush_Impl(uint32 sem_id) { rtems_status_code status; /* Give Semaphore */ status = rtems_semaphore_flush(OS_impl_bin_sem_table[sem_id].id); - if(status != RTEMS_SUCCESSFUL) + if (status != RTEMS_SUCCESSFUL) { - OS_DEBUG("Unhandled semaphore_flush error: %s\n",rtems_status_text(status)); + OS_DEBUG("Unhandled semaphore_flush error: %s\n", rtems_status_text(status)); return OS_SEM_FAILURE; } - return OS_SUCCESS; + return OS_SUCCESS; } /* end OS_BinSemFlush_Impl */ - /*---------------------------------------------------------------- * * Function: OS_BinSemTake_Impl @@ -211,7 +197,7 @@ int32 OS_BinSemFlush_Impl (uint32 sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemTake_Impl (uint32 sem_id) +int32 OS_BinSemTake_Impl(uint32 sem_id) { rtems_status_code status; @@ -224,9 +210,9 @@ int32 OS_BinSemTake_Impl (uint32 sem_id) ** I currently do not know of any other reasons this call would return ** RTEMS_UNSATISFIED, so I think it is OK. */ - if ( status != RTEMS_SUCCESSFUL && status != RTEMS_UNSATISFIED ) + if (status != RTEMS_SUCCESSFUL && status != RTEMS_UNSATISFIED) { - OS_DEBUG("Unhandled semaphore_obtain error: %s\n",rtems_status_text(status)); + OS_DEBUG("Unhandled semaphore_obtain error: %s\n", rtems_status_text(status)); return OS_SEM_FAILURE; } @@ -242,7 +228,7 @@ int32 OS_BinSemTake_Impl (uint32 sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemTimedWait_Impl (uint32 sem_id, uint32 msecs) +int32 OS_BinSemTimedWait_Impl(uint32 sem_id, uint32 msecs) { rtems_status_code status; int TimeInTicks; @@ -252,17 +238,17 @@ int32 OS_BinSemTimedWait_Impl (uint32 sem_id, uint32 msecs) return OS_ERROR; } - status = rtems_semaphore_obtain(OS_impl_bin_sem_table[sem_id].id, RTEMS_WAIT, TimeInTicks) ; + status = rtems_semaphore_obtain(OS_impl_bin_sem_table[sem_id].id, RTEMS_WAIT, TimeInTicks); - if ( status == RTEMS_TIMEOUT ) + if (status == RTEMS_TIMEOUT) { return OS_SEM_TIMEOUT; } /* See BinSemWait regarding UNSATISFIED */ - if ( status != RTEMS_SUCCESSFUL && status != RTEMS_UNSATISFIED ) + if (status != RTEMS_SUCCESSFUL && status != RTEMS_UNSATISFIED) { - OS_DEBUG("Unhandled semaphore_obtain error: %s\n",rtems_status_text(status)); + OS_DEBUG("Unhandled semaphore_obtain error: %s\n", rtems_status_text(status)); return OS_SEM_FAILURE; } @@ -270,7 +256,6 @@ int32 OS_BinSemTimedWait_Impl (uint32 sem_id, uint32 msecs) } /* end OS_BinSemTimedWait_Impl */ - /*---------------------------------------------------------------- * * Function: OS_BinSemGetInfo_Impl @@ -279,9 +264,8 @@ int32 OS_BinSemTimedWait_Impl (uint32 sem_id, uint32 msecs) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemGetInfo_Impl (uint32 sem_id, OS_bin_sem_prop_t *bin_prop) +int32 OS_BinSemGetInfo_Impl(uint32 sem_id, OS_bin_sem_prop_t *bin_prop) { /* RTEMS has no API for obtaining the current value of a semaphore */ return OS_SUCCESS; } /* end OS_BinSemGetInfo_Impl */ - diff --git a/src/os/rtems/src/os-impl-common.c b/src/os/rtems/src/os-impl-common.c index 4d39cfc4c..2d396901b 100644 --- a/src/os/rtems/src/os-impl-common.c +++ b/src/os/rtems/src/os-impl-common.c @@ -38,7 +38,7 @@ #include "os-rtems.h" #include "os-shared-common.h" -RTEMS_GlobalVars_t RTEMS_GlobalVars = { 0 }; +RTEMS_GlobalVars_t RTEMS_GlobalVars = {0}; /**************************************************************************************** INITIALIZATION FUNCTION @@ -54,54 +54,53 @@ RTEMS_GlobalVars_t RTEMS_GlobalVars = { 0 }; ---------------------------------------------------------------------------------------*/ int32 OS_API_Impl_Init(uint32 idtype) { - int32 return_code; - - return_code = OS_Rtems_TableMutex_Init(idtype); - if (return_code != OS_SUCCESS) - { - return return_code; - } - - switch(idtype) - { - case OS_OBJECT_TYPE_OS_TASK: - return_code = OS_Rtems_TaskAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_QUEUE: - return_code = OS_Rtems_QueueAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_BINSEM: - return_code = OS_Rtems_BinSemAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_COUNTSEM: - return_code = OS_Rtems_CountSemAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_MUTEX: - return_code = OS_Rtems_MutexAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_MODULE: - return_code = OS_Rtems_ModuleAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_TIMEBASE: - return_code = OS_Rtems_TimeBaseAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_STREAM: - return_code = OS_Rtems_StreamAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_DIR: - return_code = OS_Rtems_DirAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_FILESYS: - return_code = OS_Rtems_FileSysAPI_Impl_Init(); - break; - default: - break; - } - - return(return_code); + int32 return_code; + + return_code = OS_Rtems_TableMutex_Init(idtype); + if (return_code != OS_SUCCESS) + { + return return_code; + } + + switch (idtype) + { + case OS_OBJECT_TYPE_OS_TASK: + return_code = OS_Rtems_TaskAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_QUEUE: + return_code = OS_Rtems_QueueAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_BINSEM: + return_code = OS_Rtems_BinSemAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_COUNTSEM: + return_code = OS_Rtems_CountSemAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_MUTEX: + return_code = OS_Rtems_MutexAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_MODULE: + return_code = OS_Rtems_ModuleAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_TIMEBASE: + return_code = OS_Rtems_TimeBaseAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_STREAM: + return_code = OS_Rtems_StreamAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_DIR: + return_code = OS_Rtems_DirAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_FILESYS: + return_code = OS_Rtems_FileSysAPI_Impl_Init(); + break; + default: + break; + } + + return (return_code); } /* end OS_API_Impl_Init */ - /*---------------------------------------------------------------- * * Function: OS_IdleLoop_Impl @@ -116,7 +115,6 @@ void OS_IdleLoop_Impl() rtems_task_suspend(RTEMS_SELF); } /* end OS_IdleLoop_Impl */ - /*---------------------------------------------------------------- * * Function: OS_ApplicationShutdown_Impl @@ -127,11 +125,9 @@ void OS_IdleLoop_Impl() *-----------------------------------------------------------------*/ void OS_ApplicationShutdown_Impl() { - /* Note that setting the IdleTaskId and suspending - * the idle task is not an atomic operation, so there - * is a remote chance that this could attempt to - * resume a task that is not yet suspended. */ - rtems_task_resume(RTEMS_GlobalVars.IdleTaskId); + /* Note that setting the IdleTaskId and suspending + * the idle task is not an atomic operation, so there + * is a remote chance that this could attempt to + * resume a task that is not yet suspended. */ + rtems_task_resume(RTEMS_GlobalVars.IdleTaskId); } /* end OS_ApplicationShutdown_Impl */ - - diff --git a/src/os/rtems/src/os-impl-console.c b/src/os/rtems/src/os-impl-console.c index 5a64f6a39..84c84ae0c 100644 --- a/src/os/rtems/src/os-impl-console.c +++ b/src/os/rtems/src/os-impl-console.c @@ -43,11 +43,11 @@ DEFINES ***************************************************************************************/ -#define OSAL_CONSOLE_STREAM stdout +#define OSAL_CONSOLE_STREAM stdout /* * By default use the stdout stream for the console (OS_printf) */ -#define OSAL_CONSOLE_FILENO STDOUT_FILENO +#define OSAL_CONSOLE_FILENO STDOUT_FILENO /* * By default the console output is always asynchronous @@ -56,10 +56,9 @@ * This option was removed from osconfig.h and now is * assumed to always be on. */ -#define OS_CONSOLE_ASYNC true -#define OS_CONSOLE_TASK_PRIORITY OS_UTILITYTASK_PRIORITY -#define OS_CONSOLE_TASK_STACKSIZE OS_UTILITYTASK_STACK_SIZE - +#define OS_CONSOLE_ASYNC true +#define OS_CONSOLE_TASK_PRIORITY OS_UTILITYTASK_PRIORITY +#define OS_CONSOLE_TASK_STACKSIZE OS_UTILITYTASK_STACK_SIZE /**************************************************************************************** GLOBAL DATA @@ -67,15 +66,13 @@ /* Console device */ typedef struct { - bool is_async; - rtems_id data_sem; - int out_fd; + bool is_async; + rtems_id data_sem; + int out_fd; } OS_impl_console_internal_record_t; - /* Tables where the OS object information is stored */ -OS_impl_console_internal_record_t OS_impl_console_table [OS_MAX_CONSOLES]; - +OS_impl_console_internal_record_t OS_impl_console_table[OS_MAX_CONSOLES]; /********************************************************************/ /* CONSOLE OUTPUT */ @@ -89,7 +86,7 @@ OS_impl_console_internal_record_t OS_impl_console_table [OS_MAX_CONSOLES * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -void OS_ConsoleWakeup_Impl(uint32 local_id) +void OS_ConsoleWakeup_Impl(uint32 local_id) { OS_impl_console_internal_record_t *local = &OS_impl_console_table[local_id]; @@ -105,7 +102,6 @@ void OS_ConsoleWakeup_Impl(uint32 local_id) } } /* end OS_ConsoleWakeup_Impl */ - /*---------------------------------------------------------------- * * Function: OS_ConsoleTask_Entry @@ -115,7 +111,7 @@ void OS_ConsoleWakeup_Impl(uint32 local_id) *-----------------------------------------------------------------*/ static void OS_ConsoleTask_Entry(rtems_task_argument arg) { - uint32 local_id = arg; + uint32 local_id = arg; OS_impl_console_internal_record_t *local; local = &OS_impl_console_table[local_id]; @@ -137,16 +133,16 @@ static void OS_ConsoleTask_Entry(rtems_task_argument arg) int32 OS_ConsoleCreate_Impl(uint32 local_id) { OS_impl_console_internal_record_t *local = &OS_impl_console_table[local_id]; - int32 return_code; - rtems_name r_name; - rtems_id r_task_id; - rtems_status_code status; + int32 return_code; + rtems_name r_name; + rtems_id r_task_id; + rtems_status_code status; if (local_id == 0) { - return_code = OS_SUCCESS; + return_code = OS_SUCCESS; local->is_async = OS_CONSOLE_ASYNC; - local->out_fd = OSAL_CONSOLE_FILENO; + local->out_fd = OSAL_CONSOLE_FILENO; if (local->is_async) { @@ -157,26 +153,19 @@ int32 OS_ConsoleCreate_Impl(uint32 local_id) ** and trying to use the real name would be less than useful (only 4 chars) */ r_name = OS_ObjectIdToInteger(OS_global_console_table[local_id].active_id); - status = rtems_semaphore_create( r_name, 0, - RTEMS_PRIORITY, - 0, - &local->data_sem); + status = rtems_semaphore_create(r_name, 0, RTEMS_PRIORITY, 0, &local->data_sem); if (status != RTEMS_SUCCESSFUL) { return_code = OS_SEM_FAILURE; } else { - status = rtems_task_create( - r_name, - OS_CONSOLE_TASK_PRIORITY, - OS_CONSOLE_TASK_STACKSIZE, - RTEMS_PREEMPT | RTEMS_NO_ASR | RTEMS_NO_TIMESLICE | RTEMS_INTERRUPT_LEVEL(0), - RTEMS_LOCAL, - &r_task_id); + status = rtems_task_create(r_name, OS_CONSOLE_TASK_PRIORITY, OS_CONSOLE_TASK_STACKSIZE, + RTEMS_PREEMPT | RTEMS_NO_ASR | RTEMS_NO_TIMESLICE | RTEMS_INTERRUPT_LEVEL(0), + RTEMS_LOCAL, &r_task_id); /* check if task_create failed */ - if (status != RTEMS_SUCCESSFUL ) + if (status != RTEMS_SUCCESSFUL) { /* Provide some freedback as to why this failed */ OS_DEBUG("rtems_task_create failed: %s\n", rtems_status_text(status)); @@ -186,11 +175,11 @@ int32 OS_ConsoleCreate_Impl(uint32 local_id) else { /* will place the task in 'ready for scheduling' state */ - status = rtems_task_start (r_task_id, /*rtems task id*/ - OS_ConsoleTask_Entry, /* task entry point */ - (rtems_task_argument)local_id ); /* passed argument */ + status = rtems_task_start(r_task_id, /*rtems task id*/ + OS_ConsoleTask_Entry, /* task entry point */ + (rtems_task_argument)local_id); /* passed argument */ - if (status != RTEMS_SUCCESSFUL ) + if (status != RTEMS_SUCCESSFUL) { OS_printf("rtems_task_start failed: %s\n", rtems_status_text(status)); rtems_task_delete(r_task_id); @@ -209,5 +198,3 @@ int32 OS_ConsoleCreate_Impl(uint32 local_id) return return_code; } /* end OS_ConsoleCreate_Impl */ - - diff --git a/src/os/rtems/src/os-impl-countsem.c b/src/os/rtems/src/os-impl-countsem.c index d85837762..21b3caeee 100644 --- a/src/os/rtems/src/os-impl-countsem.c +++ b/src/os/rtems/src/os-impl-countsem.c @@ -46,7 +46,7 @@ DEFINES ***************************************************************************************/ -#define MAX_SEM_VALUE 0x7FFFFFFF +#define MAX_SEM_VALUE 0x7FFFFFFF /* * Define all of the RTEMS semaphore attributes @@ -56,14 +56,12 @@ #define OSAL_COUNT_SEM_ATTRIBS (RTEMS_PRIORITY) - /**************************************************************************************** GLOBAL DATA ***************************************************************************************/ /* tables for the properties of objects */ -OS_impl_countsem_internal_record_t OS_impl_count_sem_table [OS_MAX_COUNT_SEMAPHORES]; - +OS_impl_countsem_internal_record_t OS_impl_count_sem_table[OS_MAX_COUNT_SEMAPHORES]; /*---------------------------------------------------------------- * @@ -78,8 +76,6 @@ int32 OS_Rtems_CountSemAPI_Impl_Init(void) return (OS_SUCCESS); } /* end OS_Rtems_CountSemAPI_Impl_Init */ - - /*---------------------------------------------------------------- * * Function: OS_CountSemCreate_Impl @@ -88,7 +84,7 @@ int32 OS_Rtems_CountSemAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 options) +int32 OS_CountSemCreate_Impl(uint32 sem_id, uint32 sem_initial_value, uint32 options) { rtems_status_code status; rtems_name r_name; @@ -96,7 +92,7 @@ int32 OS_CountSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 op /* ** Verify that the semaphore maximum value is not too high */ - if ( sem_initial_value > MAX_SEM_VALUE ) + if (sem_initial_value > MAX_SEM_VALUE) { return OS_INVALID_SEM_VALUE; } @@ -107,15 +103,13 @@ int32 OS_CountSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 op ** and trying to use the real name would be less than useful (only 4 chars) */ r_name = OS_ObjectIdToInteger(OS_global_count_sem_table[sem_id].active_id); - status = rtems_semaphore_create( r_name, sem_initial_value, - OSAL_COUNT_SEM_ATTRIBS, - 0, - &(OS_impl_count_sem_table[sem_id].id)); + status = rtems_semaphore_create(r_name, sem_initial_value, OSAL_COUNT_SEM_ATTRIBS, 0, + &(OS_impl_count_sem_table[sem_id].id)); /* check if Create failed */ - if ( status != RTEMS_SUCCESSFUL ) + if (status != RTEMS_SUCCESSFUL) { - OS_DEBUG("Unhandled semaphore_create error: %s\n",rtems_status_text(status)); + OS_DEBUG("Unhandled semaphore_create error: %s\n", rtems_status_text(status)); return OS_SEM_FAILURE; } @@ -123,7 +117,6 @@ int32 OS_CountSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 op } /* end OS_CountSemCreate_Impl */ - /*---------------------------------------------------------------- * * Function: OS_CountSemDelete_Impl @@ -132,14 +125,14 @@ int32 OS_CountSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 op * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemDelete_Impl (uint32 sem_id) +int32 OS_CountSemDelete_Impl(uint32 sem_id) { rtems_status_code status; - status = rtems_semaphore_delete( OS_impl_count_sem_table[sem_id].id); + status = rtems_semaphore_delete(OS_impl_count_sem_table[sem_id].id); if (status != RTEMS_SUCCESSFUL) { - OS_DEBUG("Unhandled semaphore_delete error: %s\n",rtems_status_text(status)); + OS_DEBUG("Unhandled semaphore_delete error: %s\n", rtems_status_text(status)); return OS_SEM_FAILURE; } @@ -147,7 +140,6 @@ int32 OS_CountSemDelete_Impl (uint32 sem_id) } /* end OS_CountSemDelete_Impl */ - /*---------------------------------------------------------------- * * Function: OS_CountSemGive_Impl @@ -156,22 +148,21 @@ int32 OS_CountSemDelete_Impl (uint32 sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemGive_Impl (uint32 sem_id) +int32 OS_CountSemGive_Impl(uint32 sem_id) { rtems_status_code status; status = rtems_semaphore_release(OS_impl_count_sem_table[sem_id].id); - if(status != RTEMS_SUCCESSFUL) + if (status != RTEMS_SUCCESSFUL) { - OS_DEBUG("Unhandled semaphore_release error: %s\n",rtems_status_text(status)); + OS_DEBUG("Unhandled semaphore_release error: %s\n", rtems_status_text(status)); return OS_SEM_FAILURE; } - return(OS_SUCCESS); + return (OS_SUCCESS); } /* end OS_CountSemGive_Impl */ - /*---------------------------------------------------------------- * * Function: OS_CountSemTake_Impl @@ -180,14 +171,14 @@ int32 OS_CountSemGive_Impl (uint32 sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemTake_Impl (uint32 sem_id) +int32 OS_CountSemTake_Impl(uint32 sem_id) { rtems_status_code status; status = rtems_semaphore_obtain(OS_impl_count_sem_table[sem_id].id, RTEMS_WAIT, RTEMS_NO_TIMEOUT); if (status != RTEMS_SUCCESSFUL) { - OS_DEBUG("Unhandled semaphore_obtain error: %s\n",rtems_status_text(status)); + OS_DEBUG("Unhandled semaphore_obtain error: %s\n", rtems_status_text(status)); return OS_SEM_FAILURE; } @@ -195,8 +186,6 @@ int32 OS_CountSemTake_Impl (uint32 sem_id) } /* end OS_CountSemTake_Impl */ - - /*---------------------------------------------------------------- * * Function: OS_CountSemTimedWait_Impl @@ -205,7 +194,7 @@ int32 OS_CountSemTake_Impl (uint32 sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemTimedWait_Impl (uint32 sem_id, uint32 msecs) +int32 OS_CountSemTimedWait_Impl(uint32 sem_id, uint32 msecs) { rtems_status_code status; int TimeInTicks; @@ -223,7 +212,7 @@ int32 OS_CountSemTimedWait_Impl (uint32 sem_id, uint32 msecs) if (status != RTEMS_SUCCESSFUL) { - OS_DEBUG("Unhandled semaphore_obtain error: %s\n",rtems_status_text(status)); + OS_DEBUG("Unhandled semaphore_obtain error: %s\n", rtems_status_text(status)); return OS_SEM_FAILURE; } @@ -231,7 +220,6 @@ int32 OS_CountSemTimedWait_Impl (uint32 sem_id, uint32 msecs) } /* end OS_CountSemTimedWait_Impl */ - /*---------------------------------------------------------------- * * Function: OS_CountSemGetInfo_Impl @@ -240,10 +228,9 @@ int32 OS_CountSemTimedWait_Impl (uint32 sem_id, uint32 msecs) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemGetInfo_Impl (uint32 sem_id, OS_count_sem_prop_t *count_prop) +int32 OS_CountSemGetInfo_Impl(uint32 sem_id, OS_count_sem_prop_t *count_prop) { /* RTEMS does not provide an API to get the value */ return OS_SUCCESS; } /* end OS_CountSemGetInfo_Impl */ - diff --git a/src/os/rtems/src/os-impl-dirs.c b/src/os/rtems/src/os-impl-dirs.c index 520d86cb6..e5ede708b 100644 --- a/src/os/rtems/src/os-impl-dirs.c +++ b/src/os/rtems/src/os-impl-dirs.c @@ -40,7 +40,6 @@ DEFINES ***************************************************************************************/ - /**************************************************************************************** GLOBALS ***************************************************************************************/ @@ -50,7 +49,6 @@ */ DIR *OS_impl_dir_table[OS_MAX_NUM_OPEN_DIRS]; - /**************************************************************************************** IMPLEMENTATION-SPECIFIC ROUTINES These are specific to this particular operating system @@ -65,8 +63,6 @@ DIR *OS_impl_dir_table[OS_MAX_NUM_OPEN_DIRS]; ---------------------------------------------------------------------------------------*/ int32 OS_Rtems_DirAPI_Impl_Init(void) { - memset(OS_impl_dir_table, 0, sizeof(OS_impl_dir_table)); - return OS_SUCCESS; + memset(OS_impl_dir_table, 0, sizeof(OS_impl_dir_table)); + return OS_SUCCESS; } /* end OS_Rtems_DirAPI_Impl_Init */ - - diff --git a/src/os/rtems/src/os-impl-errors.c b/src/os/rtems/src/os-impl-errors.c index ec396a8d9..c0f59f2c8 100644 --- a/src/os/rtems/src/os-impl-errors.c +++ b/src/os/rtems/src/os-impl-errors.c @@ -34,5 +34,4 @@ #include "os-rtems.h" #include "os-shared-errors.h" -const OS_ErrorTable_Entry_t OS_IMPL_ERROR_NAME_TABLE[] = { { 0, NULL } }; - +const OS_ErrorTable_Entry_t OS_IMPL_ERROR_NAME_TABLE[] = {{0, NULL}}; diff --git a/src/os/rtems/src/os-impl-files.c b/src/os/rtems/src/os-impl-files.c index e4152d288..d82de88fe 100644 --- a/src/os/rtems/src/os-impl-files.c +++ b/src/os/rtems/src/os-impl-files.c @@ -37,7 +37,6 @@ DEFINES ***************************************************************************************/ - /**************************************************************************************** GLOBALS ***************************************************************************************/ @@ -50,8 +49,6 @@ /* The file/stream table is referenced by multiple entities, i.e. sockets, select, etc */ OS_Rtems_filehandle_entry_t OS_impl_filehandle_table[OS_MAX_NUM_OPEN_FILES]; - - /**************************************************************************************** IMPLEMENTATION-SPECIFIC ROUTINES These are specific to this particular operating system @@ -72,11 +69,10 @@ int32 OS_Rtems_StreamAPI_Impl_Init(void) * init all filehandles to -1, which is always invalid. * this isn't strictly necessary but helps when debugging. */ - for (local_id = 0; local_id < OS_MAX_NUM_OPEN_FILES; ++local_id) + for (local_id = 0; local_id < OS_MAX_NUM_OPEN_FILES; ++local_id) { OS_impl_filehandle_table[local_id].fd = -1; } return OS_SUCCESS; } /* end OS_Rtems_StreamAPI_Impl_Init */ - diff --git a/src/os/rtems/src/os-impl-filesys.c b/src/os/rtems/src/os-impl-filesys.c index 37045be0b..1ad989e03 100644 --- a/src/os/rtems/src/os-impl-filesys.c +++ b/src/os/rtems/src/os-impl-filesys.c @@ -57,9 +57,9 @@ typedef struct struct ramdisk *allocated_disk; /* other data to pass to "mount" when mounting this disk */ - const char *mount_fstype; + const char * mount_fstype; rtems_filesystem_options_t mount_options; - const void *mount_data; + const void * mount_data; } OS_impl_filesys_internal_record_t; @@ -96,8 +96,6 @@ int32 OS_Rtems_FileSysAPI_Impl_Init(void) return OS_SUCCESS; } /* end OS_Rtems_FileSysAPI_Impl_Init */ - - /*---------------------------------------------------------------- * * Function: OS_FileSysStartVolume_Impl @@ -106,21 +104,21 @@ int32 OS_Rtems_FileSysAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysStartVolume_Impl (uint32 filesys_id) +int32 OS_FileSysStartVolume_Impl(uint32 filesys_id) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; - OS_impl_filesys_internal_record_t *impl = &OS_impl_filesys_table[filesys_id]; - rtems_status_code sc; - int32 return_code; + OS_filesys_internal_record_t * local = &OS_filesys_table[filesys_id]; + OS_impl_filesys_internal_record_t *impl = &OS_impl_filesys_table[filesys_id]; + rtems_status_code sc; + int32 return_code; return_code = OS_ERR_NOT_IMPLEMENTED; - memset(impl,0,sizeof(*impl)); + memset(impl, 0, sizeof(*impl)); /* * Determine basic type of filesystem, if not already known */ if (local->fstype == OS_FILESYS_TYPE_UNKNOWN && - strncmp(local->device_name, OS_RTEMS_DEVICEFILE_PREFIX, sizeof(OS_RTEMS_DEVICEFILE_PREFIX)-1) == 0) + strncmp(local->device_name, OS_RTEMS_DEVICEFILE_PREFIX, sizeof(OS_RTEMS_DEVICEFILE_PREFIX) - 1) == 0) { /* * If referring to a real device in the /dev filesystem, @@ -134,65 +132,54 @@ int32 OS_FileSysStartVolume_Impl (uint32 filesys_id) */ switch (local->fstype) { - case OS_FILESYS_TYPE_FS_BASED: - { - /* - * This "mount" type is basically not a mount at all, - * No new filesystem is created, just put the files in a - * directory under the root FS. - * - * This is basically a pass-thru/no-op mode for compatibility - * with FS_BASED entries in existing volume tables. - */ - return_code = OS_SUCCESS; - break; - } - case OS_FILESYS_TYPE_VOLATILE_DISK: - { - OS_DEBUG("No RAMDISK available at address %p\n", local->address); - - impl->allocated_disk = ramdisk_allocate( - local->address, - local->blocksize, - local->numblocks, - false - ); - - if (impl->allocated_disk == NULL) + case OS_FILESYS_TYPE_FS_BASED: { - OS_DEBUG("ramdisk_allocate() failed\n"); - return_code = OS_INVALID_POINTER; + /* + * This "mount" type is basically not a mount at all, + * No new filesystem is created, just put the files in a + * directory under the root FS. + * + * This is basically a pass-thru/no-op mode for compatibility + * with FS_BASED entries in existing volume tables. + */ + return_code = OS_SUCCESS; break; } - - impl->mount_fstype = RTEMS_FILESYSTEM_TYPE_RFS; - impl->mount_options = RTEMS_FILESYSTEM_READ_WRITE; - snprintf(impl->blockdev_name, sizeof(impl->blockdev_name), "%s%c", RAMDISK_DEVICE_BASE_NAME, (int)filesys_id + 'a'); - - sc = rtems_blkdev_create( - impl->blockdev_name, - local->blocksize, - local->numblocks, - ramdisk_ioctl, - impl->allocated_disk - ); - if (sc != RTEMS_SUCCESSFUL) + case OS_FILESYS_TYPE_VOLATILE_DISK: { - OS_DEBUG("rtems_blkdev_create() failed: %s.\n", rtems_status_text(sc)); - return_code = OS_ERROR; - } + OS_DEBUG("No RAMDISK available at address %p\n", local->address); + impl->allocated_disk = ramdisk_allocate(local->address, local->blocksize, local->numblocks, false); - OS_DEBUG("RAM disk initialized: volume=%s device=%s address=0x%08lX\n", - local->volume_name, impl->blockdev_name, (unsigned long)local->address); + if (impl->allocated_disk == NULL) + { + OS_DEBUG("ramdisk_allocate() failed\n"); + return_code = OS_INVALID_POINTER; + break; + } - return_code = OS_SUCCESS; - break; - } - default: - break; - } + impl->mount_fstype = RTEMS_FILESYSTEM_TYPE_RFS; + impl->mount_options = RTEMS_FILESYSTEM_READ_WRITE; + snprintf(impl->blockdev_name, sizeof(impl->blockdev_name), "%s%c", RAMDISK_DEVICE_BASE_NAME, + (int)filesys_id + 'a'); + + sc = rtems_blkdev_create(impl->blockdev_name, local->blocksize, local->numblocks, ramdisk_ioctl, + impl->allocated_disk); + if (sc != RTEMS_SUCCESSFUL) + { + OS_DEBUG("rtems_blkdev_create() failed: %s.\n", rtems_status_text(sc)); + return_code = OS_ERROR; + } + OS_DEBUG("RAM disk initialized: volume=%s device=%s address=0x%08lX\n", local->volume_name, + impl->blockdev_name, (unsigned long)local->address); + + return_code = OS_SUCCESS; + break; + } + default: + break; + } /* * If the operation was generally successful but a (real) FS @@ -203,17 +190,13 @@ int32 OS_FileSysStartVolume_Impl (uint32 filesys_id) if (return_code == OS_SUCCESS && local->system_mountpt[0] == 0) { snprintf(local->system_mountpt, sizeof(local->system_mountpt), "/%s", local->volume_name); - OS_DEBUG("OSAL: using mount point %s for %s\n", - local->system_mountpt, local->volume_name); + OS_DEBUG("OSAL: using mount point %s for %s\n", local->system_mountpt, local->volume_name); } - return return_code; } /* end OS_FileSysStartVolume_Impl */ - - /*---------------------------------------------------------------- * * Function: OS_FileSysStopVolume_Impl @@ -222,7 +205,7 @@ int32 OS_FileSysStartVolume_Impl (uint32 filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysStopVolume_Impl (uint32 filesys_id) +int32 OS_FileSysStopVolume_Impl(uint32 filesys_id) { OS_impl_filesys_internal_record_t *impl = &OS_impl_filesys_table[filesys_id]; @@ -238,7 +221,6 @@ int32 OS_FileSysStopVolume_Impl (uint32 filesys_id) } /* end OS_FileSysStopVolume_Impl */ - /*---------------------------------------------------------------- * * Function: OS_FileSysFormatVolume_Impl @@ -247,63 +229,60 @@ int32 OS_FileSysStopVolume_Impl (uint32 filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysFormatVolume_Impl (uint32 filesys_id) +int32 OS_FileSysFormatVolume_Impl(uint32 filesys_id) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; - OS_impl_filesys_internal_record_t *impl = &OS_impl_filesys_table[filesys_id]; - rtems_rfs_format_config config; - int32 return_code; - int sc; + OS_filesys_internal_record_t * local = &OS_filesys_table[filesys_id]; + OS_impl_filesys_internal_record_t *impl = &OS_impl_filesys_table[filesys_id]; + rtems_rfs_format_config config; + int32 return_code; + int sc; return_code = OS_ERR_NOT_IMPLEMENTED; - switch(local->fstype) - { - case OS_FILESYS_TYPE_FS_BASED: - { - /* - * In this mode a format is a no-op, as it is simply a directory - * within an already existing and mounted filesystem. - * - * This needs to return success for backward compatibility even - * though it is inappropriate to "format" this type of FS. - * - * It could clear the directory, but that might risk deleting - * something unintentional, so it is better to leave it alone. - */ - return_code = OS_SUCCESS; - break; - } - case OS_FILESYS_TYPE_VOLATILE_DISK: + switch (local->fstype) { - /* - ** Format the RAM disk with the RFS file system - */ - memset (&config, 0, sizeof(config)); - config.inode_overhead = 30; - sc = rtems_rfs_format(impl->blockdev_name, &config); - if ( sc < 0 ) + case OS_FILESYS_TYPE_FS_BASED: { - OS_DEBUG("OSAL: Error: RFS format of %s failed: %s\n", - impl->blockdev_name, strerror(errno)); - return_code = OS_FS_ERR_DRIVE_NOT_CREATED; + /* + * In this mode a format is a no-op, as it is simply a directory + * within an already existing and mounted filesystem. + * + * This needs to return success for backward compatibility even + * though it is inappropriate to "format" this type of FS. + * + * It could clear the directory, but that might risk deleting + * something unintentional, so it is better to leave it alone. + */ + return_code = OS_SUCCESS; + break; } - else + case OS_FILESYS_TYPE_VOLATILE_DISK: { - return_code = OS_SUCCESS; + /* + ** Format the RAM disk with the RFS file system + */ + memset(&config, 0, sizeof(config)); + config.inode_overhead = 30; + sc = rtems_rfs_format(impl->blockdev_name, &config); + if (sc < 0) + { + OS_DEBUG("OSAL: Error: RFS format of %s failed: %s\n", impl->blockdev_name, strerror(errno)); + return_code = OS_FS_ERR_DRIVE_NOT_CREATED; + } + else + { + return_code = OS_SUCCESS; + } + break; } - break; - } - default: - break; + default: + break; } return return_code; } /* end OS_FileSysFormatVolume_Impl */ - - /*---------------------------------------------------------------- * * Function: OS_FileSysMountVolume_Impl @@ -312,11 +291,11 @@ int32 OS_FileSysFormatVolume_Impl (uint32 filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysMountVolume_Impl (uint32 filesys_id) +int32 OS_FileSysMountVolume_Impl(uint32 filesys_id) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; - OS_impl_filesys_internal_record_t *impl = &OS_impl_filesys_table[filesys_id]; - struct stat stat_buf; + OS_filesys_internal_record_t * local = &OS_filesys_table[filesys_id]; + OS_impl_filesys_internal_record_t *impl = &OS_impl_filesys_table[filesys_id]; + struct stat stat_buf; /* * This will do a mkdir() for the mount point if it does @@ -324,17 +303,15 @@ int32 OS_FileSysMountVolume_Impl (uint32 filesys_id) */ if (stat(local->system_mountpt, &stat_buf) != 0) { - if (mkdir(local->system_mountpt, S_IFDIR |S_IRWXU | S_IRWXG | S_IRWXO) < 0) + if (mkdir(local->system_mountpt, S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO) < 0) { - OS_DEBUG("ERROR: Cannot create mount point %s: %s\n", - local->system_mountpt, strerror(errno)); + OS_DEBUG("ERROR: Cannot create mount point %s: %s\n", local->system_mountpt, strerror(errno)); return OS_FS_ERR_DRIVE_NOT_CREATED; } } - else if (!S_ISDIR(stat_buf.st_mode) ) + else if (!S_ISDIR(stat_buf.st_mode)) { - OS_DEBUG("ERROR: Volume %s exists and is not a directory\n", - local->system_mountpt); + OS_DEBUG("ERROR: Volume %s exists and is not a directory\n", local->system_mountpt); return OS_FS_ERR_DRIVE_NOT_CREATED; } @@ -342,17 +319,16 @@ int32 OS_FileSysMountVolume_Impl (uint32 filesys_id) * Only do the mount() syscall for real devices. * For other types of filesystem mounts (e.g. FS_BASED), this is a no-op */ - if (local->fstype == OS_FILESYS_TYPE_VOLATILE_DISK || - local->fstype == OS_FILESYS_TYPE_NORMAL_DISK) + if (local->fstype == OS_FILESYS_TYPE_VOLATILE_DISK || local->fstype == OS_FILESYS_TYPE_NORMAL_DISK) { /* ** Mount the Disk */ - if ( mount(impl->blockdev_name, local->system_mountpt, - impl->mount_fstype, impl->mount_options, impl->mount_data) != 0 ) + if (mount(impl->blockdev_name, local->system_mountpt, impl->mount_fstype, impl->mount_options, + impl->mount_data) != 0) { - OS_DEBUG("OSAL: Error: mount of %s to %s failed: %s\n", - impl->blockdev_name, local->system_mountpt, strerror(errno)); + OS_DEBUG("OSAL: Error: mount of %s to %s failed: %s\n", impl->blockdev_name, local->system_mountpt, + strerror(errno)); return OS_ERROR; } } @@ -361,7 +337,6 @@ int32 OS_FileSysMountVolume_Impl (uint32 filesys_id) } /* end OS_FileSysMountVolume_Impl */ - /*---------------------------------------------------------------- * * Function: OS_FileSysUnmountVolume_Impl @@ -370,20 +345,19 @@ int32 OS_FileSysMountVolume_Impl (uint32 filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysUnmountVolume_Impl (uint32 filesys_id) +int32 OS_FileSysUnmountVolume_Impl(uint32 filesys_id) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; + OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; - if (local->fstype == OS_FILESYS_TYPE_VOLATILE_DISK || - local->fstype == OS_FILESYS_TYPE_NORMAL_DISK) + if (local->fstype == OS_FILESYS_TYPE_VOLATILE_DISK || local->fstype == OS_FILESYS_TYPE_NORMAL_DISK) { /* ** Try to unmount the disk */ - if ( unmount(local->system_mountpt) < 0) + if (unmount(local->system_mountpt) < 0) { - OS_DEBUG("OSAL: RTEMS unmount of %s failed :%s\n",local->system_mountpt, strerror(errno)); - return OS_ERROR; + OS_DEBUG("OSAL: RTEMS unmount of %s failed :%s\n", local->system_mountpt, strerror(errno)); + return OS_ERROR; } } @@ -391,7 +365,6 @@ int32 OS_FileSysUnmountVolume_Impl (uint32 filesys_id) } /* end OS_FileSysUnmountVolume_Impl */ - /*---------------------------------------------------------------- * * Function: OS_FileSysStatVolume_Impl @@ -400,41 +373,39 @@ int32 OS_FileSysUnmountVolume_Impl (uint32 filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysStatVolume_Impl (uint32 filesys_id, OS_statvfs_t *result) +int32 OS_FileSysStatVolume_Impl(uint32 filesys_id, OS_statvfs_t *result) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; - struct statvfs stat_buf; - int32 return_code; - - if ( statvfs(local->system_mountpt, &stat_buf) != 0 ) - { - /* - * The ENOSYS error means it is not implemented at the system level. - * This should translate to the OS_ERR_NOT_IMPLEMENTED OSAL code. - */ - if (errno == ENOSYS) - { - return_code = OS_ERR_NOT_IMPLEMENTED; - } - else - { - OS_DEBUG("%s: %s\n", local->system_mountpt, strerror(errno)); - return_code = OS_ERROR; - } - } - else - { - result->block_size = stat_buf.f_bsize; - result->blocks_free = stat_buf.f_bfree; - result->total_blocks = stat_buf.f_blocks; - - return_code = OS_SUCCESS; - } - - return (return_code); -} /* end OS_FileSysStatVolume_Impl */ + OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; + struct statvfs stat_buf; + int32 return_code; + if (statvfs(local->system_mountpt, &stat_buf) != 0) + { + /* + * The ENOSYS error means it is not implemented at the system level. + * This should translate to the OS_ERR_NOT_IMPLEMENTED OSAL code. + */ + if (errno == ENOSYS) + { + return_code = OS_ERR_NOT_IMPLEMENTED; + } + else + { + OS_DEBUG("%s: %s\n", local->system_mountpt, strerror(errno)); + return_code = OS_ERROR; + } + } + else + { + result->block_size = stat_buf.f_bsize; + result->blocks_free = stat_buf.f_bfree; + result->total_blocks = stat_buf.f_blocks; + return_code = OS_SUCCESS; + } + + return (return_code); +} /* end OS_FileSysStatVolume_Impl */ /*---------------------------------------------------------------- * @@ -444,12 +415,7 @@ int32 OS_FileSysStatVolume_Impl (uint32 filesys_id, OS_statvfs_t *result) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysCheckVolume_Impl (uint32 filesys_id, bool repair) +int32 OS_FileSysCheckVolume_Impl(uint32 filesys_id, bool repair) { return OS_ERR_NOT_IMPLEMENTED; } /* end OS_FileSysCheckVolume_Impl */ - - - - - diff --git a/src/os/rtems/src/os-impl-heap.c b/src/os/rtems/src/os-impl-heap.c index bfa77c525..17addccc0 100644 --- a/src/os/rtems/src/os-impl-heap.c +++ b/src/os/rtems/src/os-impl-heap.c @@ -32,12 +32,10 @@ #include "os-rtems.h" #include "os-shared-heap.h" - /**************************************************************************************** HEAP API ***************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_HeapGetInfo_Impl @@ -46,22 +44,21 @@ * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_HeapGetInfo_Impl (OS_heap_prop_t *heap_prop) +int32 OS_HeapGetInfo_Impl(OS_heap_prop_t *heap_prop) { region_information_block info; int status; - status = malloc_info( &info ); + status = malloc_info(&info); - if ( status != 0 ) + if (status != 0) { - return(OS_ERROR); + return (OS_ERROR); } - heap_prop->free_bytes = (uint32) info.Free.total; - heap_prop->free_blocks = (uint32) info.Free.number; - heap_prop->largest_free_block = (uint32) info.Free.largest; + heap_prop->free_bytes = (uint32)info.Free.total; + heap_prop->free_blocks = (uint32)info.Free.number; + heap_prop->largest_free_block = (uint32)info.Free.largest; return (OS_SUCCESS); } /* end OS_HeapGetInfo_Impl */ - diff --git a/src/os/rtems/src/os-impl-idmap.c b/src/os/rtems/src/os-impl-idmap.c index bf0237e48..6d6b15f00 100644 --- a/src/os/rtems/src/os-impl-idmap.c +++ b/src/os/rtems/src/os-impl-idmap.c @@ -38,45 +38,44 @@ DEFINES ***************************************************************************************/ -#define OSAL_TABLE_MUTEX_ATTRIBS (RTEMS_PRIORITY | RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY) +#define OSAL_TABLE_MUTEX_ATTRIBS (RTEMS_PRIORITY | RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY) /**************************************************************************************** GLOBALS ***************************************************************************************/ -rtems_id OS_task_table_sem; -rtems_id OS_queue_table_sem; -rtems_id OS_bin_sem_table_sem; -rtems_id OS_mutex_table_sem; -rtems_id OS_count_sem_table_sem; -rtems_id OS_stream_table_mut; -rtems_id OS_dir_table_mut; -rtems_id OS_timebase_table_mut; -rtems_id OS_timecb_table_mut; -rtems_id OS_module_table_mut; -rtems_id OS_filesys_table_mut; -rtems_id OS_console_mut; - -static rtems_id * const MUTEX_TABLE[] = - { - [OS_OBJECT_TYPE_UNDEFINED] = NULL, - [OS_OBJECT_TYPE_OS_TASK] = &OS_task_table_sem, - [OS_OBJECT_TYPE_OS_QUEUE] = &OS_queue_table_sem, - [OS_OBJECT_TYPE_OS_COUNTSEM] = &OS_count_sem_table_sem, - [OS_OBJECT_TYPE_OS_BINSEM] = &OS_bin_sem_table_sem, - [OS_OBJECT_TYPE_OS_MUTEX] = &OS_mutex_table_sem, - [OS_OBJECT_TYPE_OS_STREAM] = &OS_stream_table_mut, - [OS_OBJECT_TYPE_OS_DIR] = &OS_dir_table_mut, - [OS_OBJECT_TYPE_OS_TIMEBASE] = &OS_timebase_table_mut, - [OS_OBJECT_TYPE_OS_TIMECB] = &OS_timecb_table_mut, - [OS_OBJECT_TYPE_OS_MODULE] = &OS_module_table_mut, - [OS_OBJECT_TYPE_OS_FILESYS] = &OS_filesys_table_mut, - [OS_OBJECT_TYPE_OS_CONSOLE] = &OS_console_mut, - }; +rtems_id OS_task_table_sem; +rtems_id OS_queue_table_sem; +rtems_id OS_bin_sem_table_sem; +rtems_id OS_mutex_table_sem; +rtems_id OS_count_sem_table_sem; +rtems_id OS_stream_table_mut; +rtems_id OS_dir_table_mut; +rtems_id OS_timebase_table_mut; +rtems_id OS_timecb_table_mut; +rtems_id OS_module_table_mut; +rtems_id OS_filesys_table_mut; +rtems_id OS_console_mut; + +static rtems_id *const MUTEX_TABLE[] = { + [OS_OBJECT_TYPE_UNDEFINED] = NULL, + [OS_OBJECT_TYPE_OS_TASK] = &OS_task_table_sem, + [OS_OBJECT_TYPE_OS_QUEUE] = &OS_queue_table_sem, + [OS_OBJECT_TYPE_OS_COUNTSEM] = &OS_count_sem_table_sem, + [OS_OBJECT_TYPE_OS_BINSEM] = &OS_bin_sem_table_sem, + [OS_OBJECT_TYPE_OS_MUTEX] = &OS_mutex_table_sem, + [OS_OBJECT_TYPE_OS_STREAM] = &OS_stream_table_mut, + [OS_OBJECT_TYPE_OS_DIR] = &OS_dir_table_mut, + [OS_OBJECT_TYPE_OS_TIMEBASE] = &OS_timebase_table_mut, + [OS_OBJECT_TYPE_OS_TIMECB] = &OS_timecb_table_mut, + [OS_OBJECT_TYPE_OS_MODULE] = &OS_module_table_mut, + [OS_OBJECT_TYPE_OS_FILESYS] = &OS_filesys_table_mut, + [OS_OBJECT_TYPE_OS_CONSOLE] = &OS_console_mut, +}; enum { - MUTEX_TABLE_SIZE = (sizeof(MUTEX_TABLE) / sizeof(MUTEX_TABLE[0])) + MUTEX_TABLE_SIZE = (sizeof(MUTEX_TABLE) / sizeof(MUTEX_TABLE[0])) }; /*---------------------------------------------------------------- @@ -89,28 +88,28 @@ enum *-----------------------------------------------------------------*/ int32 OS_Lock_Global_Impl(uint32 idtype) { - rtems_id *mut; - - if (idtype < MUTEX_TABLE_SIZE) - { - mut = MUTEX_TABLE[idtype]; - } - else - { - mut = NULL; - } - - if (mut == NULL) - { - return OS_ERROR; - } - - if (rtems_semaphore_obtain(*mut, RTEMS_WAIT, RTEMS_NO_TIMEOUT) != 0) - { - return OS_ERROR; - } - - return OS_SUCCESS; + rtems_id *mut; + + if (idtype < MUTEX_TABLE_SIZE) + { + mut = MUTEX_TABLE[idtype]; + } + else + { + mut = NULL; + } + + if (mut == NULL) + { + return OS_ERROR; + } + + if (rtems_semaphore_obtain(*mut, RTEMS_WAIT, RTEMS_NO_TIMEOUT) != 0) + { + return OS_ERROR; + } + + return OS_SUCCESS; } /* end OS_Lock_Global_Impl */ /*---------------------------------------------------------------- @@ -123,31 +122,29 @@ int32 OS_Lock_Global_Impl(uint32 idtype) *-----------------------------------------------------------------*/ int32 OS_Unlock_Global_Impl(uint32 idtype) { - rtems_id *mut; - - if (idtype < MUTEX_TABLE_SIZE) - { - mut = MUTEX_TABLE[idtype]; - } - else - { - mut = NULL; - } - - if (mut == NULL) - { - return OS_ERROR; - } - - if (rtems_semaphore_release(*mut) != 0) - { - return OS_ERROR; - } - - return OS_SUCCESS; -} /* end OS_Unlock_Global_Impl */ + rtems_id *mut; + + if (idtype < MUTEX_TABLE_SIZE) + { + mut = MUTEX_TABLE[idtype]; + } + else + { + mut = NULL; + } + if (mut == NULL) + { + return OS_ERROR; + } + + if (rtems_semaphore_release(*mut) != 0) + { + return OS_ERROR; + } + return OS_SUCCESS; +} /* end OS_Unlock_Global_Impl */ /**************************************************************************************** INITIALIZATION FUNCTION @@ -163,22 +160,20 @@ int32 OS_Unlock_Global_Impl(uint32 idtype) ---------------------------------------------------------------------------------------*/ int32 OS_Rtems_TableMutex_Init(uint32 idtype) { - int32 return_code = OS_SUCCESS; - rtems_status_code rtems_sc; + int32 return_code = OS_SUCCESS; + rtems_status_code rtems_sc; /* Initialize the table mutex for the given idtype */ if (idtype < MUTEX_TABLE_SIZE && MUTEX_TABLE[idtype] != NULL) { - rtems_sc = rtems_semaphore_create (idtype, - 1, OSAL_TABLE_MUTEX_ATTRIBS, 0, - MUTEX_TABLE[idtype]); + rtems_sc = rtems_semaphore_create(idtype, 1, OSAL_TABLE_MUTEX_ATTRIBS, 0, MUTEX_TABLE[idtype]); - if ( rtems_sc != RTEMS_SUCCESSFUL ) + if (rtems_sc != RTEMS_SUCCESSFUL) { OS_DEBUG("Error: rtems_semaphore_create failed: %s\n", rtems_status_text(rtems_sc)); return_code = OS_ERROR; } } - return(return_code); + return (return_code); } /* end OS_Rtems_TableMutex_Init */ diff --git a/src/os/rtems/src/os-impl-loader.c b/src/os/rtems/src/os-impl-loader.c index 2001a9d4c..89fbbedce 100644 --- a/src/os/rtems/src/os-impl-loader.c +++ b/src/os/rtems/src/os-impl-loader.c @@ -41,7 +41,6 @@ OS_impl_module_internal_record_t OS_impl_module_table[OS_MAX_MODULES]; - /**************************************************************************************** INITIALIZATION FUNCTION ***************************************************************************************/ @@ -55,11 +54,10 @@ OS_impl_module_internal_record_t OS_impl_module_table[OS_MAX_MODULES]; *-----------------------------------------------------------------*/ int32 OS_Rtems_ModuleAPI_Impl_Init(void) { - memset(OS_impl_module_table, 0, sizeof(OS_impl_module_table)); - return(OS_SUCCESS); + memset(OS_impl_module_table, 0, sizeof(OS_impl_module_table)); + return (OS_SUCCESS); } /* end OS_Rtems_ModuleAPI_Impl_Init */ - /**************************************************************************************** HELPER ROUTINES ***************************************************************************************/ @@ -75,32 +73,29 @@ int32 OS_Rtems_ModuleAPI_Impl_Init(void) * This could be fine-tuned later. * *-----------------------------------------------------------------*/ -static bool OS_rtems_rtl_check_unresolved (rtems_rtl_unresolv_rec_t* rec, - void* data) +static bool OS_rtems_rtl_check_unresolved(rtems_rtl_unresolv_rec_t *rec, void *data) { int32 *status = data; - switch(rec->type) + switch (rec->type) { - case rtems_rtl_unresolved_name: - OS_DEBUG("unresolved name: %s\n", rec->rec.name.name); - *status = OS_ERROR; - break; - case rtems_rtl_unresolved_reloc: - *status = OS_ERROR; - break; - default: - break; + case rtems_rtl_unresolved_name: + OS_DEBUG("unresolved name: %s\n", rec->rec.name.name); + *status = OS_ERROR; + break; + case rtems_rtl_unresolved_reloc: + *status = OS_ERROR; + break; + default: + break; } return false; } /* end OS_rtems_rtl_check_unresolved */ - /**************************************************************************************** Module Loader API ***************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_ModuleLoad_Impl @@ -109,10 +104,10 @@ static bool OS_rtems_rtl_check_unresolved (rtems_rtl_unresolv_rec_t* rec, * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleLoad_Impl ( uint32 module_id, const char *translated_path ) +int32 OS_ModuleLoad_Impl(uint32 module_id, const char *translated_path) { int32 status = OS_ERROR; - int unresolved; + int unresolved; void *dl_handle; dlerror(); @@ -122,7 +117,7 @@ int32 OS_ModuleLoad_Impl ( uint32 module_id, const char *translated_path ) OS_DEBUG("Error loading shared library: %s\n", dlerror()); status = OS_ERROR; } - else if (dlinfo (dl_handle, RTLD_DI_UNRESOLVED, &unresolved) < 0) + else if (dlinfo(dl_handle, RTLD_DI_UNRESOLVED, &unresolved) < 0) { /* should never happen */ OS_DEBUG("dlinfo error checking unresolved status\n"); @@ -147,14 +142,13 @@ int32 OS_ModuleLoad_Impl ( uint32 module_id, const char *translated_path ) OS_DEBUG("module has has unresolved externals\n"); status = OS_SUCCESS; /* note - not final, probably overridden */ - rtems_rtl_unresolved_interate (OS_rtems_rtl_check_unresolved, &status); + rtems_rtl_unresolved_interate(OS_rtems_rtl_check_unresolved, &status); } else { status = OS_SUCCESS; } - if (status == OS_SUCCESS) { /* success: save for future use */ @@ -175,7 +169,6 @@ int32 OS_ModuleLoad_Impl ( uint32 module_id, const char *translated_path ) } /* end OS_ModuleLoad_Impl */ - /*---------------------------------------------------------------- * * Function: OS_ModuleUnload_Impl @@ -184,7 +177,7 @@ int32 OS_ModuleLoad_Impl ( uint32 module_id, const char *translated_path ) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleUnload_Impl ( uint32 module_id ) +int32 OS_ModuleUnload_Impl(uint32 module_id) { int32 status = OS_ERROR; @@ -195,7 +188,7 @@ int32 OS_ModuleUnload_Impl ( uint32 module_id ) if (dlclose(OS_impl_module_table[module_id].dl_handle) == 0) { OS_impl_module_table[module_id].dl_handle = NULL; - status = OS_SUCCESS; + status = OS_SUCCESS; } else { @@ -206,7 +199,6 @@ int32 OS_ModuleUnload_Impl ( uint32 module_id ) } /* end OS_ModuleUnload_Impl */ - /*---------------------------------------------------------------- * * Function: OS_ModuleGetInfo_Impl @@ -215,14 +207,12 @@ int32 OS_ModuleUnload_Impl ( uint32 module_id ) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleGetInfo_Impl ( uint32 module_id, OS_module_prop_t *module_prop ) +int32 OS_ModuleGetInfo_Impl(uint32 module_id, OS_module_prop_t *module_prop) { - /* - ** RTEMS does not specify a way to get these values - ** Everything left at zero - */ - return(OS_SUCCESS); + /* + ** RTEMS does not specify a way to get these values + ** Everything left at zero + */ + return (OS_SUCCESS); } /* end OS_ModuleGetInfo_Impl */ - - diff --git a/src/os/rtems/src/os-impl-mutex.c b/src/os/rtems/src/os-impl-mutex.c index 66d4009b7..4ae538954 100644 --- a/src/os/rtems/src/os-impl-mutex.c +++ b/src/os/rtems/src/os-impl-mutex.c @@ -45,30 +45,25 @@ DEFINES ***************************************************************************************/ - /* * Define all of the RTEMS semaphore attributes * In RTEMS, a MUTEX is defined as a binary semaphore * It allows nested locks, priority wait order, and supports priority inheritance */ -#define OSAL_MUTEX_ATTRIBS (RTEMS_PRIORITY | RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY) - +#define OSAL_MUTEX_ATTRIBS (RTEMS_PRIORITY | RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY) /**************************************************************************************** GLOBAL DATA ***************************************************************************************/ /* Tables where the OS object information is stored */ -OS_impl_mutex_internal_record_t OS_impl_mutex_table [OS_MAX_MUTEXES]; - +OS_impl_mutex_internal_record_t OS_impl_mutex_table[OS_MAX_MUTEXES]; /**************************************************************************************** MUTEX API ***************************************************************************************/ - - /*---------------------------------------------------------------- * * Function: OS_Rtems_MutexAPI_Impl_Init @@ -82,7 +77,6 @@ int32 OS_Rtems_MutexAPI_Impl_Init(void) return (OS_SUCCESS); } /* end OS_Rtems_MutexAPI_Impl_Init */ - /*---------------------------------------------------------------- * * Function: OS_MutSemCreate_Impl @@ -91,23 +85,20 @@ int32 OS_Rtems_MutexAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemCreate_Impl (uint32 sem_id, uint32 options) +int32 OS_MutSemCreate_Impl(uint32 sem_id, uint32 options) { - rtems_status_code status; - rtems_name r_name; + rtems_status_code status; + rtems_name r_name; /* ** Try to create the mutex */ r_name = OS_ObjectIdToInteger(OS_global_mutex_table[sem_id].active_id); - status = rtems_semaphore_create ( r_name, 1, - OSAL_MUTEX_ATTRIBS , - 0, - &OS_impl_mutex_table[sem_id].id ); + status = rtems_semaphore_create(r_name, 1, OSAL_MUTEX_ATTRIBS, 0, &OS_impl_mutex_table[sem_id].id); - if ( status != RTEMS_SUCCESSFUL ) + if (status != RTEMS_SUCCESSFUL) { - OS_DEBUG("Unhandled semaphore_create error: %s\n",rtems_status_text(status)); + OS_DEBUG("Unhandled semaphore_create error: %s\n", rtems_status_text(status)); return OS_SEM_FAILURE; } @@ -115,7 +106,6 @@ int32 OS_MutSemCreate_Impl (uint32 sem_id, uint32 options) } /* end OS_MutSemCreate_Impl */ - /*---------------------------------------------------------------- * * Function: OS_MutSemDelete_Impl @@ -124,15 +114,15 @@ int32 OS_MutSemCreate_Impl (uint32 sem_id, uint32 options) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemDelete_Impl (uint32 sem_id) +int32 OS_MutSemDelete_Impl(uint32 sem_id) { rtems_status_code status; - status = rtems_semaphore_delete( OS_impl_mutex_table[sem_id].id); + status = rtems_semaphore_delete(OS_impl_mutex_table[sem_id].id); if (status != RTEMS_SUCCESSFUL) { /* clean up? */ - OS_DEBUG("Unhandled semaphore_delete error: %s\n",rtems_status_text(status)); + OS_DEBUG("Unhandled semaphore_delete error: %s\n", rtems_status_text(status)); return OS_SEM_FAILURE; } @@ -140,8 +130,6 @@ int32 OS_MutSemDelete_Impl (uint32 sem_id) } /* end OS_MutSemDelete_Impl */ - - /*---------------------------------------------------------------- * * Function: OS_MutSemGive_Impl @@ -150,24 +138,23 @@ int32 OS_MutSemDelete_Impl (uint32 sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemGive_Impl (uint32 sem_id) +int32 OS_MutSemGive_Impl(uint32 sem_id) { rtems_status_code status; /* Give the mutex */ status = rtems_semaphore_release(OS_impl_mutex_table[sem_id].id); - if(status != RTEMS_SUCCESSFUL) + if (status != RTEMS_SUCCESSFUL) { - OS_DEBUG("Unhandled semaphore_release error: %s\n",rtems_status_text(status)); + OS_DEBUG("Unhandled semaphore_release error: %s\n", rtems_status_text(status)); return OS_SEM_FAILURE; } - return OS_SUCCESS; + return OS_SUCCESS; } /* end OS_MutSemGive_Impl */ - /*---------------------------------------------------------------- * * Function: OS_MutSemTake_Impl @@ -176,7 +163,7 @@ int32 OS_MutSemGive_Impl (uint32 sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemTake_Impl (uint32 sem_id) +int32 OS_MutSemTake_Impl(uint32 sem_id) { rtems_status_code status; @@ -184,7 +171,7 @@ int32 OS_MutSemTake_Impl (uint32 sem_id) if (status != RTEMS_SUCCESSFUL) { - OS_DEBUG("Unhandled semaphore_obtain error: %s\n",rtems_status_text(status)); + OS_DEBUG("Unhandled semaphore_obtain error: %s\n", rtems_status_text(status)); return OS_SEM_FAILURE; } @@ -192,7 +179,6 @@ int32 OS_MutSemTake_Impl (uint32 sem_id) } /* end OS_MutSemTake_Impl */ - /*---------------------------------------------------------------- * * Function: OS_MutSemGetInfo_Impl @@ -201,10 +187,9 @@ int32 OS_MutSemTake_Impl (uint32 sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemGetInfo_Impl (uint32 sem_id, OS_mut_sem_prop_t *mut_prop) +int32 OS_MutSemGetInfo_Impl(uint32 sem_id, OS_mut_sem_prop_t *mut_prop) { /* RTEMS provides no additional info */ return OS_SUCCESS; } /* end OS_MutSemGetInfo_Impl */ - diff --git a/src/os/rtems/src/os-impl-network.c b/src/os/rtems/src/os-impl-network.c index b6916ab7c..c5a8a20ef 100644 --- a/src/os/rtems/src/os-impl-network.c +++ b/src/os/rtems/src/os-impl-network.c @@ -33,7 +33,6 @@ #include "os-impl-sockets.h" #include "os-shared-network.h" - /*---------------------------------------------------------------- * * Function: OS_NetworkGetID_Impl @@ -42,7 +41,7 @@ * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_NetworkGetID_Impl (int32 *IdBuf) +int32 OS_NetworkGetID_Impl(int32 *IdBuf) { /* RTEMS does not have the GetHostId call - * it is deprecated in other OS's anyway and not a good idea to use it @@ -50,7 +49,6 @@ int32 OS_NetworkGetID_Impl (int32 *IdBuf) return OS_ERR_NOT_IMPLEMENTED; } /* end OS_NetworkGetID_Impl */ - /*---------------------------------------------------------------- * * Function: OS_NetworkGetHostName_Impl @@ -59,11 +57,11 @@ int32 OS_NetworkGetID_Impl (int32 *IdBuf) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_NetworkGetHostName_Impl (char *host_name, uint32 name_len) +int32 OS_NetworkGetHostName_Impl(char *host_name, uint32 name_len) { int32 return_code; - if ( gethostname(host_name, name_len) < 0 ) + if (gethostname(host_name, name_len) < 0) { return_code = OS_ERROR; } @@ -74,10 +72,8 @@ int32 OS_NetworkGetHostName_Impl (char *host_name, uint32 name_len) * null terminated, so its worthwhile to ensure it */ host_name[name_len - 1] = 0; - return_code = OS_SUCCESS; + return_code = OS_SUCCESS; } - return(return_code); + return (return_code); } /* end OS_NetworkGetHostName_Impl */ - - diff --git a/src/os/rtems/src/os-impl-no-module.c b/src/os/rtems/src/os-impl-no-module.c index e34fe29cc..c70a0e8be 100644 --- a/src/os/rtems/src/os-impl-no-module.c +++ b/src/os/rtems/src/os-impl-no-module.c @@ -33,7 +33,6 @@ #include "os-rtems.h" - /**************************************************************************************** INITIALIZATION FUNCTION ***************************************************************************************/ @@ -48,7 +47,5 @@ int32 OS_Rtems_ModuleAPI_Impl_Init(void) { /* nothing to init, but needs to return SUCCESS to allow the rest of OSAL to work */ - return(OS_SUCCESS); + return (OS_SUCCESS); } /* end OS_Rtems_ModuleAPI_Impl_Init */ - - diff --git a/src/os/rtems/src/os-impl-queues.c b/src/os/rtems/src/os-impl-queues.c index 24efdb454..dcd9ddbe8 100644 --- a/src/os/rtems/src/os-impl-queues.c +++ b/src/os/rtems/src/os-impl-queues.c @@ -42,25 +42,21 @@ #include "os-shared-idmap.h" #include "os-shared-timebase.h" - /**************************************************************************************** DEFINES ***************************************************************************************/ - /**************************************************************************************** GLOBAL DATA ***************************************************************************************/ /* Tables where the OS object information is stored */ -OS_impl_queue_internal_record_t OS_impl_queue_table [OS_MAX_QUEUES]; - +OS_impl_queue_internal_record_t OS_impl_queue_table[OS_MAX_QUEUES]; /**************************************************************************************** MESSAGE QUEUE API ***************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_Rtems_QueueAPI_Impl_Init @@ -74,7 +70,6 @@ int32 OS_Rtems_QueueAPI_Impl_Init(void) return (OS_SUCCESS); } /* end OS_Rtems_QueueAPI_Impl_Init */ - /*---------------------------------------------------------------- * * Function: OS_QueueCreate_Impl @@ -83,11 +78,10 @@ int32 OS_Rtems_QueueAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueueCreate_Impl (uint32 queue_id, uint32 flags) +int32 OS_QueueCreate_Impl(uint32 queue_id, uint32 flags) { - rtems_status_code status; - rtems_name r_name; - + rtems_status_code status; + rtems_name r_name; /* ** RTEMS task names are 4 byte integers. @@ -103,11 +97,11 @@ int32 OS_QueueCreate_Impl (uint32 queue_id, uint32 flags) ** on each queue. */ status = rtems_message_queue_create( - r_name, /* 32-bit RTEMS object name; not used */ - OS_queue_table[queue_id].max_depth, /* maximum number of messages in queue (queue depth) */ - OS_queue_table[queue_id].max_size, /* maximum size in bytes of a message */ - RTEMS_FIFO|RTEMS_LOCAL, /* attributes (default) */ - &(OS_impl_queue_table[queue_id].id) /* object ID returned for queue */ + r_name, /* 32-bit RTEMS object name; not used */ + OS_queue_table[queue_id].max_depth, /* maximum number of messages in queue (queue depth) */ + OS_queue_table[queue_id].max_size, /* maximum size in bytes of a message */ + RTEMS_FIFO | RTEMS_LOCAL, /* attributes (default) */ + &(OS_impl_queue_table[queue_id].id) /* object ID returned for queue */ ); /* @@ -115,15 +109,14 @@ int32 OS_QueueCreate_Impl (uint32 queue_id, uint32 flags) */ if (status != RTEMS_SUCCESSFUL) { - OS_DEBUG("Unhandled queue_create error: %s\n",rtems_status_text(status)); - return OS_ERROR; + OS_DEBUG("Unhandled queue_create error: %s\n", rtems_status_text(status)); + return OS_ERROR; } return OS_SUCCESS; } /* end OS_QueueCreate_Impl */ - /*---------------------------------------------------------------- * * Function: OS_QueueDelete_Impl @@ -132,15 +125,15 @@ int32 OS_QueueCreate_Impl (uint32 queue_id, uint32 flags) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueueDelete_Impl (uint32 queue_id) +int32 OS_QueueDelete_Impl(uint32 queue_id) { rtems_status_code status; /* Try to delete the queue */ status = rtems_message_queue_delete(OS_impl_queue_table[queue_id].id); - if(status != RTEMS_SUCCESSFUL) + if (status != RTEMS_SUCCESSFUL) { - OS_DEBUG("Unhandled queue_delete error: %s\n",rtems_status_text(status)); + OS_DEBUG("Unhandled queue_delete error: %s\n", rtems_status_text(status)); return OS_ERROR; } @@ -148,8 +141,6 @@ int32 OS_QueueDelete_Impl (uint32 queue_id) } /* end OS_QueueDelete_Impl */ - - /*---------------------------------------------------------------- * * Function: OS_QueueGet_Impl @@ -158,16 +149,15 @@ int32 OS_QueueDelete_Impl (uint32 queue_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueueGet_Impl (uint32 queue_id, void *data, uint32 size, uint32 *size_copied, - int32 timeout) +int32 OS_QueueGet_Impl(uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout) { - int32 return_code; - rtems_status_code status; - rtems_interval ticks; - int tick_count; - rtems_option option_set; - size_t rtems_size; - rtems_id rtems_queue_id; + int32 return_code; + rtems_status_code status; + rtems_interval ticks; + int tick_count; + rtems_option option_set; + size_t rtems_size; + rtems_id rtems_queue_id; rtems_queue_id = OS_impl_queue_table[queue_id].id; @@ -175,12 +165,12 @@ int32 OS_QueueGet_Impl (uint32 queue_id, void *data, uint32 size, uint32 *size_c if (timeout == OS_PEND) { option_set = RTEMS_WAIT; - ticks = RTEMS_NO_TIMEOUT; + ticks = RTEMS_NO_TIMEOUT; } else if (timeout == OS_CHECK) { option_set = RTEMS_NO_WAIT; - ticks = RTEMS_NO_TIMEOUT; + ticks = RTEMS_NO_TIMEOUT; } else { @@ -198,12 +188,11 @@ int32 OS_QueueGet_Impl (uint32 queue_id, void *data, uint32 size, uint32 *size_c /* ** Pend until a message arrives. */ - status = rtems_message_queue_receive( - rtems_queue_id, /* message queue descriptor */ - data, /* pointer to message buffer */ - &rtems_size, /* returned size of message */ - option_set, /* wait option */ - ticks /* timeout */ + status = rtems_message_queue_receive(rtems_queue_id, /* message queue descriptor */ + data, /* pointer to message buffer */ + &rtems_size, /* returned size of message */ + option_set, /* wait option */ + ticks /* timeout */ ); if (status == RTEMS_SUCCESSFUL) @@ -219,10 +208,10 @@ int32 OS_QueueGet_Impl (uint32 queue_id, void *data, uint32 size, uint32 *size_c return_code = OS_QUEUE_EMPTY; } else - { - /* Something else went wrong */ - return_code = OS_ERROR; - OS_DEBUG("Unhandled queue_receive error: %s\n",rtems_status_text(status)); + { + /* Something else went wrong */ + return_code = OS_ERROR; + OS_DEBUG("Unhandled queue_receive error: %s\n", rtems_status_text(status)); } /* @@ -246,7 +235,6 @@ int32 OS_QueueGet_Impl (uint32 queue_id, void *data, uint32 size, uint32 *size_c return return_code; } /* end OS_QueueGet_Impl */ - /*---------------------------------------------------------------- * * Function: OS_QueuePut_Impl @@ -255,20 +243,19 @@ int32 OS_QueueGet_Impl (uint32 queue_id, void *data, uint32 size, uint32 *size_c * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueuePut_Impl (uint32 queue_id, const void *data, uint32 size, uint32 flags) +int32 OS_QueuePut_Impl(uint32 queue_id, const void *data, uint32 size, uint32 flags) { - rtems_status_code status; - rtems_id rtems_queue_id; + rtems_status_code status; + rtems_id rtems_queue_id; rtems_queue_id = OS_impl_queue_table[queue_id].id; /* Write the buffer pointer to the queue. If an error occurred, report it ** with the corresponding SB status code. */ - status = rtems_message_queue_send( - rtems_queue_id, /* message queue descriptor */ - data, /* pointer to message */ - size /* length of message */ + status = rtems_message_queue_send(rtems_queue_id, /* message queue descriptor */ + data, /* pointer to message */ + size /* length of message */ ); if (status == RTEMS_TOO_MANY) @@ -284,7 +271,7 @@ int32 OS_QueuePut_Impl (uint32 queue_id, const void *data, uint32 size, uint32 f /* ** Unexpected error while writing to queue. */ - OS_DEBUG("Unhandled queue_send error: %s\n",rtems_status_text(status)); + OS_DEBUG("Unhandled queue_send error: %s\n", rtems_status_text(status)); return OS_ERROR; } @@ -292,7 +279,6 @@ int32 OS_QueuePut_Impl (uint32 queue_id, const void *data, uint32 size, uint32 f } /* end OS_QueuePut_Impl */ - /*---------------------------------------------------------------- * * Function: OS_QueueGetInfo_Impl @@ -301,10 +287,9 @@ int32 OS_QueuePut_Impl (uint32 queue_id, const void *data, uint32 size, uint32 f * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueueGetInfo_Impl (uint32 queue_id, OS_queue_prop_t *queue_prop) +int32 OS_QueueGetInfo_Impl(uint32 queue_id, OS_queue_prop_t *queue_prop) { /* No extra info for queues in the OS implementation */ return OS_SUCCESS; } /* end OS_QueueGetInfo_Impl */ - diff --git a/src/os/rtems/src/os-impl-shell.c b/src/os/rtems/src/os-impl-shell.c index dc7f49b41..7e2f775fb 100644 --- a/src/os/rtems/src/os-impl-shell.c +++ b/src/os/rtems/src/os-impl-shell.c @@ -37,16 +37,13 @@ DEFINES ***************************************************************************************/ -#define OS_REDIRECTSTRSIZE 15 - - +#define OS_REDIRECTSTRSIZE 15 /**************************************************************************************** IMPLEMENTATION-SPECIFIC ROUTINES These are specific to this particular operating system ****************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_ShellOutputToFile_Impl @@ -57,35 +54,32 @@ *-----------------------------------------------------------------*/ int32 OS_ShellOutputToFile_Impl(uint32 file_id, const char *Cmd) { - /* - ** this is a #define to avoid a 'variable length array' warning - ** 15 is for the size of the redirection string that is added - ** to the command - */ - char LocalCmd [OS_MAX_CMD_LEN + OS_REDIRECTSTRSIZE]; - int32 Result; - - strncpy(LocalCmd,Cmd,OS_MAX_CMD_LEN +OS_REDIRECTSTRSIZE); - - /* Make sure that we are able to access this file */ - fchmod(OS_impl_filehandle_table[file_id].fd, 0666); - - /* - ** add in the extra chars necessary to perform the redirection - ** 1 for stdout and 2 for stderr. they are redirected to the - ** file descriptor passed in - */ - snprintf(LocalCmd, sizeof(LocalCmd), "%s 1>&%d 2>&%d", - Cmd, - OS_impl_filehandle_table[file_id].fd, - OS_impl_filehandle_table[file_id].fd); - - Result = system(LocalCmd); - - if (Result != 0) - { - return OS_ERROR; - } - return OS_SUCCESS; + /* + ** this is a #define to avoid a 'variable length array' warning + ** 15 is for the size of the redirection string that is added + ** to the command + */ + char LocalCmd[OS_MAX_CMD_LEN + OS_REDIRECTSTRSIZE]; + int32 Result; + + strncpy(LocalCmd, Cmd, OS_MAX_CMD_LEN + OS_REDIRECTSTRSIZE); + + /* Make sure that we are able to access this file */ + fchmod(OS_impl_filehandle_table[file_id].fd, 0666); + + /* + ** add in the extra chars necessary to perform the redirection + ** 1 for stdout and 2 for stderr. they are redirected to the + ** file descriptor passed in + */ + snprintf(LocalCmd, sizeof(LocalCmd), "%s 1>&%d 2>&%d", Cmd, OS_impl_filehandle_table[file_id].fd, + OS_impl_filehandle_table[file_id].fd); + + Result = system(LocalCmd); + + if (Result != 0) + { + return OS_ERROR; + } + return OS_SUCCESS; } /* end OS_ShellOutputToFile_Impl */ - diff --git a/src/os/rtems/src/os-impl-tasks.c b/src/os/rtems/src/os-impl-tasks.c index a689aa63f..8db7432fe 100644 --- a/src/os/rtems/src/os-impl-tasks.c +++ b/src/os/rtems/src/os-impl-tasks.c @@ -50,8 +50,7 @@ GLOBAL DATA ***************************************************************************************/ /* Tables where the OS object information is stored */ -OS_impl_task_internal_record_t OS_impl_task_table [OS_MAX_TASKS]; - +OS_impl_task_internal_record_t OS_impl_task_table[OS_MAX_TASKS]; /*--------------------------------------------------------------------------------------- Name: OS_RtemsEntry @@ -66,13 +65,10 @@ static rtems_task OS_RtemsEntry(rtems_task_argument arg) OS_TaskEntryPoint(OS_ObjectIdFromInteger(arg)); } /* end OS_RtemsEntry */ - - /**************************************************************************************** TASK API ***************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_Rtems_TaskAPI_Impl_Init @@ -86,7 +82,6 @@ int32 OS_Rtems_TaskAPI_Impl_Init(void) return (OS_SUCCESS); } /* end OS_Rtems_TaskAPI_Impl_Init */ - /*---------------------------------------------------------------- * * Function: OS_TaskCreate_Impl @@ -95,12 +90,12 @@ int32 OS_Rtems_TaskAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskCreate_Impl (uint32 task_id, uint32 flags) +int32 OS_TaskCreate_Impl(uint32 task_id, uint32 flags) { - rtems_status_code status; - rtems_name r_name; - rtems_mode r_mode; - rtems_attribute r_attributes; + rtems_status_code status; + rtems_name r_name; + rtems_mode r_mode; + rtems_attribute r_attributes; /* ** RTEMS task names are 4 byte integers. @@ -120,16 +115,11 @@ int32 OS_TaskCreate_Impl (uint32 task_id, uint32 flags) r_attributes |= RTEMS_FLOATING_POINT; } - status = rtems_task_create( - r_name, - OS_task_table[task_id].priority, - OS_task_table[task_id].stack_size, - r_mode, - r_attributes, - &OS_impl_task_table[task_id].id); + status = rtems_task_create(r_name, OS_task_table[task_id].priority, OS_task_table[task_id].stack_size, r_mode, + r_attributes, &OS_impl_task_table[task_id].id); /* check if task_create failed */ - if (status != RTEMS_SUCCESSFUL ) + if (status != RTEMS_SUCCESSFUL) { /* Provide some freedback as to why this failed */ OS_printf("rtems_task_create failed: %s\n", rtems_status_text(status)); @@ -137,11 +127,12 @@ int32 OS_TaskCreate_Impl (uint32 task_id, uint32 flags) } /* will place the task in 'ready for scheduling' state */ - status = rtems_task_start (OS_impl_task_table[task_id].id, /*rtems task id*/ - (rtems_task_entry) OS_RtemsEntry, /* task entry point */ - (rtems_task_argument) OS_ObjectIdToInteger(OS_global_task_table[task_id].active_id) ); /* passed argument */ + status = rtems_task_start( + OS_impl_task_table[task_id].id, /*rtems task id*/ + (rtems_task_entry)OS_RtemsEntry, /* task entry point */ + (rtems_task_argument)OS_ObjectIdToInteger(OS_global_task_table[task_id].active_id)); /* passed argument */ - if (status != RTEMS_SUCCESSFUL ) + if (status != RTEMS_SUCCESSFUL) { OS_printf("rtems_task_start failed: %s\n", rtems_status_text(status)); rtems_task_delete(OS_impl_task_table[task_id].id); @@ -152,7 +143,6 @@ int32 OS_TaskCreate_Impl (uint32 task_id, uint32 flags) } /* end OS_TaskCreate_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TaskDelete_Impl @@ -161,7 +151,7 @@ int32 OS_TaskCreate_Impl (uint32 task_id, uint32 flags) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskDelete_Impl (uint32 task_id) +int32 OS_TaskDelete_Impl(uint32 task_id) { /* ** Try to delete the task @@ -174,7 +164,6 @@ int32 OS_TaskDelete_Impl (uint32 task_id) return OS_SUCCESS; } /* end OS_TaskDelete_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TaskExit_Impl @@ -189,7 +178,6 @@ void OS_TaskExit_Impl() } /* end OS_TaskExit_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TaskDelay_Impl @@ -198,10 +186,10 @@ void OS_TaskExit_Impl() * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskDelay_Impl (uint32 milli_second) +int32 OS_TaskDelay_Impl(uint32 milli_second) { - int tick_count; - int32 return_code; + int tick_count; + int32 return_code; return_code = OS_Milli2Ticks(milli_second, &tick_count); @@ -225,7 +213,6 @@ int32 OS_TaskDelay_Impl (uint32 milli_second) } /* end OS_TaskDelay_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TaskSetPriority_Impl @@ -234,16 +221,16 @@ int32 OS_TaskDelay_Impl (uint32 milli_second) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskSetPriority_Impl (uint32 task_id, uint32 new_priority) +int32 OS_TaskSetPriority_Impl(uint32 task_id, uint32 new_priority) { rtems_task_priority old_pri; - rtems_status_code status; + rtems_status_code status; /* Set RTEMS Task Priority */ status = rtems_task_set_priority(OS_impl_task_table[task_id].id, new_priority, &old_pri); if (status != RTEMS_SUCCESSFUL) { - OS_DEBUG("Unhandled task_set_priority error: %s\n",rtems_status_text(status)); + OS_DEBUG("Unhandled task_set_priority error: %s\n", rtems_status_text(status)); return OS_ERROR; } @@ -251,7 +238,6 @@ int32 OS_TaskSetPriority_Impl (uint32 task_id, uint32 new_priority) } /* end OS_TaskSetPriority_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TaskMatch_Impl @@ -265,16 +251,14 @@ int32 OS_TaskMatch_Impl(uint32 task_id) /* ** Get RTEMS Task Id */ - if ( rtems_task_self() != OS_impl_task_table[task_id].id ) + if (rtems_task_self() != OS_impl_task_table[task_id].id) { - return(OS_ERROR); + return (OS_ERROR); } - - return OS_SUCCESS; + return OS_SUCCESS; } /* end OS_TaskMatch_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TaskRegister_Impl @@ -283,7 +267,7 @@ int32 OS_TaskMatch_Impl(uint32 task_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskRegister_Impl (osal_id_t global_task_id) +int32 OS_TaskRegister_Impl(osal_id_t global_task_id) { /* * This is supposed to maintain the "reverse lookup" information used @@ -305,7 +289,6 @@ int32 OS_TaskRegister_Impl (osal_id_t global_task_id) } /* end OS_TaskRegister_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TaskGetId_Impl @@ -314,7 +297,7 @@ int32 OS_TaskRegister_Impl (osal_id_t global_task_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -osal_id_t OS_TaskGetId_Impl (void) +osal_id_t OS_TaskGetId_Impl(void) { osal_id_t global_task_id; rtems_id task_self; @@ -338,7 +321,6 @@ osal_id_t OS_TaskGetId_Impl (void) } /* end OS_TaskGetId_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TaskGetInfo_Impl @@ -347,7 +329,7 @@ osal_id_t OS_TaskGetId_Impl (void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskGetInfo_Impl (uint32 task_id, OS_task_prop_t *task_prop) +int32 OS_TaskGetInfo_Impl(uint32 task_id, OS_task_prop_t *task_prop) { return OS_SUCCESS; @@ -384,4 +366,3 @@ bool OS_TaskIdMatchSystemData_Impl(void *ref, uint32 local_id, const OS_common_r return (*target == OS_impl_task_table[local_id].id); } - diff --git a/src/os/rtems/src/os-impl-timebase.c b/src/os/rtems/src/os-impl-timebase.c index a167ae1ab..8d047ec75 100644 --- a/src/os/rtems/src/os-impl-timebase.c +++ b/src/os/rtems/src/os-impl-timebase.c @@ -40,7 +40,7 @@ INTERNAL FUNCTION PROTOTYPES ***************************************************************************************/ -void OS_UsecsToTicks(uint32 usecs, rtems_interval *ticks); +void OS_UsecsToTicks(uint32 usecs, rtems_interval *ticks); /**************************************************************************************** DEFINES @@ -51,30 +51,28 @@ void OS_UsecsToTicks(uint32 usecs, rtems_interval *ticks); * the time like the REALTIME clock will. */ #ifndef OS_PREFERRED_CLOCK -#ifdef _POSIX_MONOTONIC_CLOCK -#define OS_PREFERRED_CLOCK CLOCK_MONOTONIC +#ifdef _POSIX_MONOTONIC_CLOCK +#define OS_PREFERRED_CLOCK CLOCK_MONOTONIC #else -#define OS_PREFERRED_CLOCK CLOCK_REALTIME +#define OS_PREFERRED_CLOCK CLOCK_REALTIME #endif #endif - - /**************************************************************************************** LOCAL TYPEDEFS ***************************************************************************************/ typedef struct { - rtems_id rtems_timer_id; - rtems_id tick_sem; - rtems_id handler_mutex; - rtems_id handler_task; - uint8 simulate_flag; - uint8 reset_flag; - rtems_interval interval_ticks; - uint32 configured_start_time; - uint32 configured_interval_time; + rtems_id rtems_timer_id; + rtems_id tick_sem; + rtems_id handler_mutex; + rtems_id handler_task; + uint8 simulate_flag; + uint8 reset_flag; + rtems_interval interval_ticks; + uint32 configured_start_time; + uint32 configured_interval_time; } OS_impl_timebase_internal_record_t; /**************************************************************************************** @@ -109,7 +107,6 @@ void OS_TimeBaseUnlock_Impl(uint32 local_id) rtems_semaphore_release(OS_impl_timebase_table[local_id].handler_mutex); } /* end OS_TimeBaseUnlock_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TimeBase_ISR @@ -121,8 +118,8 @@ void OS_TimeBaseUnlock_Impl(uint32 local_id) *-----------------------------------------------------------------*/ static rtems_timer_service_routine OS_TimeBase_ISR(rtems_id rtems_timer_id, void *arg) { - OS_U32ValueWrapper_t user_data; - uint32 local_id; + OS_U32ValueWrapper_t user_data; + uint32 local_id; OS_impl_timebase_internal_record_t *local; user_data.opaque_arg = arg; @@ -135,8 +132,7 @@ static rtems_timer_service_routine OS_TimeBase_ISR(rtems_id rtems_timer_id, void */ if (local->interval_ticks > 0) { - rtems_timer_fire_after(rtems_timer_id, local->interval_ticks, - OS_TimeBase_ISR, user_data.opaque_arg); + rtems_timer_fire_after(rtems_timer_id, local->interval_ticks, OS_TimeBase_ISR, user_data.opaque_arg); } /* @@ -150,7 +146,6 @@ static rtems_timer_service_routine OS_TimeBase_ISR(rtems_id rtems_timer_id, void } /* end OS_TimeBase_ISR */ - /*---------------------------------------------------------------- * * Function: OS_TimeBase_WaitImpl @@ -162,7 +157,7 @@ static rtems_timer_service_routine OS_TimeBase_ISR(rtems_id rtems_timer_id, void static uint32 OS_TimeBase_WaitImpl(uint32 local_id) { OS_impl_timebase_internal_record_t *local; - uint32 tick_time; + uint32 tick_time; local = &OS_impl_timebase_table[local_id]; @@ -184,15 +179,13 @@ static uint32 OS_TimeBase_WaitImpl(uint32 local_id) } else { - tick_time = local->configured_start_time; + tick_time = local->configured_start_time; local->reset_flag = 0; } - return tick_time; } /* end OS_TimeBase_WaitImpl */ - /**************************************************************************************** INITIALIZATION FUNCTION ***************************************************************************************/ @@ -204,47 +197,45 @@ static uint32 OS_TimeBase_WaitImpl(uint32 local_id) * Purpose: Local helper routine, not part of OSAL API. * *-----------------------------------------------------------------*/ -int32 OS_Rtems_TimeBaseAPI_Impl_Init ( void ) +int32 OS_Rtems_TimeBaseAPI_Impl_Init(void) { - /* - ** Store the clock accuracy for 1 tick. - */ - rtems_interval ticks_per_sec = rtems_clock_get_ticks_per_second(); - - if (ticks_per_sec <= 0) - { - return OS_ERROR; - } - - /* - * For the global ticks per second, use the value direct from RTEMS + /* + ** Store the clock accuracy for 1 tick. */ - OS_SharedGlobalVars.TicksPerSecond = (int32)ticks_per_sec; + rtems_interval ticks_per_sec = rtems_clock_get_ticks_per_second(); - /* - * Compute the clock accuracy in Nanoseconds (ns per tick) - * This really should be an exact/whole number result; otherwise this - * will round to the nearest nanosecond. - */ - RTEMS_GlobalVars.ClockAccuracyNsec = (1000000000 + (OS_SharedGlobalVars.TicksPerSecond / 2)) / - OS_SharedGlobalVars.TicksPerSecond; + if (ticks_per_sec <= 0) + { + return OS_ERROR; + } + /* + * For the global ticks per second, use the value direct from RTEMS + */ + OS_SharedGlobalVars.TicksPerSecond = (int32)ticks_per_sec; - /* - * Finally compute the Microseconds per tick - * This must further round again to the nearest microsecond, so it is undesirable to use - * this for time computations if the result is not exact. - */ - OS_SharedGlobalVars.MicroSecPerTick = (RTEMS_GlobalVars.ClockAccuracyNsec + 500) / 1000; + /* + * Compute the clock accuracy in Nanoseconds (ns per tick) + * This really should be an exact/whole number result; otherwise this + * will round to the nearest nanosecond. + */ + RTEMS_GlobalVars.ClockAccuracyNsec = + (1000000000 + (OS_SharedGlobalVars.TicksPerSecond / 2)) / OS_SharedGlobalVars.TicksPerSecond; + + /* + * Finally compute the Microseconds per tick + * This must further round again to the nearest microsecond, so it is undesirable to use + * this for time computations if the result is not exact. + */ + OS_SharedGlobalVars.MicroSecPerTick = (RTEMS_GlobalVars.ClockAccuracyNsec + 500) / 1000; - return(OS_SUCCESS); + return (OS_SUCCESS); } /* end OS_Rtems_TimeBaseAPI_Impl_Init */ /**************************************************************************************** INTERNAL FUNCTIONS ***************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_UsecsToTicks @@ -252,38 +243,34 @@ int32 OS_Rtems_TimeBaseAPI_Impl_Init ( void ) * Purpose: Convert Microseconds to a number of ticks. * *-----------------------------------------------------------------*/ -void OS_UsecsToTicks(uint32 usecs, rtems_interval *ticks) +void OS_UsecsToTicks(uint32 usecs, rtems_interval *ticks) { - uint32 result; - - /* - * In order to compute without overflowing a 32 bit integer, - * this is done in 2 parts - - * the fractional seconds first then add any whole seconds. - * the fractions are rounded UP so that this is guaranteed to produce - * a nonzero number of ticks for a nonzero number of microseconds. - */ - - result = (1000 * (usecs % 1000000) + RTEMS_GlobalVars.ClockAccuracyNsec - 1) / - RTEMS_GlobalVars.ClockAccuracyNsec; + uint32 result; - if (usecs >= 1000000) - { - result += (usecs / 1000000) * OS_SharedGlobalVars.TicksPerSecond; - } + /* + * In order to compute without overflowing a 32 bit integer, + * this is done in 2 parts - + * the fractional seconds first then add any whole seconds. + * the fractions are rounded UP so that this is guaranteed to produce + * a nonzero number of ticks for a nonzero number of microseconds. + */ - *ticks = (rtems_interval)result; -} /* end OS_UsecsToTicks */ + result = (1000 * (usecs % 1000000) + RTEMS_GlobalVars.ClockAccuracyNsec - 1) / RTEMS_GlobalVars.ClockAccuracyNsec; + if (usecs >= 1000000) + { + result += (usecs / 1000000) * OS_SharedGlobalVars.TicksPerSecond; + } + *ticks = (rtems_interval)result; +} /* end OS_UsecsToTicks */ /**************************************************************************************** Time Base API ***************************************************************************************/ /* The user may specify whether to use priority inheritance on mutexes via osconfig.h */ -#define OSAL_TIMEBASE_MUTEX_ATTRIBS RTEMS_PRIORITY | RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY - +#define OSAL_TIMEBASE_MUTEX_ATTRIBS RTEMS_PRIORITY | RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY /*---------------------------------------------------------------- * @@ -295,16 +282,15 @@ void OS_UsecsToTicks(uint32 usecs, rtems_interval *ticks) *-----------------------------------------------------------------*/ int32 OS_TimeBaseCreate_Impl(uint32 timer_id) { - int32 return_code; - rtems_status_code rtems_sc; + int32 return_code; + rtems_status_code rtems_sc; OS_impl_timebase_internal_record_t *local; - OS_common_record_t *global; - rtems_name r_name; - + OS_common_record_t * global; + rtems_name r_name; return_code = OS_SUCCESS; - local = &OS_impl_timebase_table[timer_id]; - global = &OS_global_timebase_table[timer_id]; + local = &OS_impl_timebase_table[timer_id]; + global = &OS_global_timebase_table[timer_id]; /* * The RTEMS classic name for dependent resources @@ -329,33 +315,32 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id) * The tick_sem is a simple semaphore posted by the ISR and taken by the * timebase helper task (created later). */ - rtems_sc = rtems_semaphore_create (r_name, 0, RTEMS_SIMPLE_BINARY_SEMAPHORE | RTEMS_PRIORITY, 0, - &local->tick_sem); - if ( rtems_sc != RTEMS_SUCCESSFUL ) + rtems_sc = + rtems_semaphore_create(r_name, 0, RTEMS_SIMPLE_BINARY_SEMAPHORE | RTEMS_PRIORITY, 0, &local->tick_sem); + if (rtems_sc != RTEMS_SUCCESSFUL) { - OS_DEBUG("Error: Tick Sem could not be created: %d\n",(int)rtems_sc); + OS_DEBUG("Error: Tick Sem could not be created: %d\n", (int)rtems_sc); return_code = OS_TIMER_ERR_INTERNAL; } /* * The handler_mutex is deals with access to the callback list for this timebase */ - rtems_sc = rtems_semaphore_create (r_name, 1, OSAL_TIMEBASE_MUTEX_ATTRIBS, 0, - &local->handler_mutex); + rtems_sc = rtems_semaphore_create(r_name, 1, OSAL_TIMEBASE_MUTEX_ATTRIBS, 0, &local->handler_mutex); - if ( rtems_sc != RTEMS_SUCCESSFUL ) + if (rtems_sc != RTEMS_SUCCESSFUL) { - OS_DEBUG("Error: Handler Mutex could not be created: %d\n",(int)rtems_sc); - rtems_semaphore_delete (local->tick_sem); + OS_DEBUG("Error: Handler Mutex could not be created: %d\n", (int)rtems_sc); + rtems_semaphore_delete(local->tick_sem); return_code = OS_TIMER_ERR_INTERNAL; } rtems_sc = rtems_timer_create(r_name, &local->rtems_timer_id); - if ( rtems_sc != RTEMS_SUCCESSFUL ) + if (rtems_sc != RTEMS_SUCCESSFUL) { - OS_DEBUG("Error: Timer object could not be created: %d\n",(int)rtems_sc); - rtems_semaphore_delete (local->handler_mutex); - rtems_semaphore_delete (local->tick_sem); + OS_DEBUG("Error: Timer object could not be created: %d\n", (int)rtems_sc); + rtems_semaphore_delete(local->handler_mutex); + rtems_semaphore_delete(local->tick_sem); return_code = OS_TIMER_ERR_UNAVAILABLE; } } @@ -377,16 +362,12 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id) * Using "RTEMS_MINIMUM_PRIORITY + 1" because rtems seems to not schedule it at all if * the priority is set to RTEMS_MINIMUM_PRIORITY. */ - rtems_sc = rtems_task_create( - r_name, - RTEMS_MINIMUM_PRIORITY + 1, - 0, - RTEMS_PREEMPT | RTEMS_NO_ASR | RTEMS_NO_TIMESLICE | RTEMS_INTERRUPT_LEVEL(0), - RTEMS_LOCAL, - &local->handler_task); + rtems_sc = rtems_task_create(r_name, RTEMS_MINIMUM_PRIORITY + 1, 0, + RTEMS_PREEMPT | RTEMS_NO_ASR | RTEMS_NO_TIMESLICE | RTEMS_INTERRUPT_LEVEL(0), + RTEMS_LOCAL, &local->handler_task); /* check if task_create failed */ - if (rtems_sc != RTEMS_SUCCESSFUL ) + if (rtems_sc != RTEMS_SUCCESSFUL) { /* Provide some freedback as to why this failed */ OS_printf("rtems_task_create failed: %s\n", rtems_status_text(rtems_sc)); @@ -395,11 +376,12 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id) else { /* will place the task in 'ready for scheduling' state */ - rtems_sc = rtems_task_start (local->handler_task, /*rtems task id*/ - (rtems_task_entry) OS_TimeBase_CallbackThread, /* task entry point */ - (rtems_task_argument) OS_ObjectIdToInteger(global->active_id) ); /* passed argument */ + rtems_sc = + rtems_task_start(local->handler_task, /*rtems task id*/ + (rtems_task_entry)OS_TimeBase_CallbackThread, /* task entry point */ + (rtems_task_argument)OS_ObjectIdToInteger(global->active_id)); /* passed argument */ - if (rtems_sc != RTEMS_SUCCESSFUL ) + if (rtems_sc != RTEMS_SUCCESSFUL) { OS_printf("rtems_task_start failed: %s\n", rtems_status_text(rtems_sc)); rtems_task_delete(local->handler_task); @@ -411,8 +393,8 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id) { /* Also delete the resources we allocated earlier */ rtems_timer_delete(local->rtems_timer_id); - rtems_semaphore_delete (local->handler_mutex); - rtems_semaphore_delete (local->tick_sem); + rtems_semaphore_delete(local->handler_mutex); + rtems_semaphore_delete(local->tick_sem); return return_code; } } @@ -420,7 +402,6 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id) return return_code; } /* end OS_TimeBaseCreate_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TimeBaseSet_Impl @@ -431,13 +412,13 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id) *-----------------------------------------------------------------*/ int32 OS_TimeBaseSet_Impl(uint32 timer_id, int32 start_time, int32 interval_time) { - OS_U32ValueWrapper_t user_data; + OS_U32ValueWrapper_t user_data; OS_impl_timebase_internal_record_t *local; - int32 return_code; - int status; - rtems_interval start_ticks; + int32 return_code; + int status; + rtems_interval start_ticks; - local = &OS_impl_timebase_table[timer_id]; + local = &OS_impl_timebase_table[timer_id]; return_code = OS_SUCCESS; /* There is only something to do here if we are generating a simulated tick */ @@ -453,7 +434,7 @@ int32 OS_TimeBaseSet_Impl(uint32 timer_id, int32 start_time, int32 interval_time if (start_time <= 0) { - interval_time = 0; /* cannot have interval without start */ + interval_time = 0; /* cannot have interval without start */ } if (interval_time <= 0) @@ -469,53 +450,50 @@ int32 OS_TimeBaseSet_Impl(uint32 timer_id, int32 start_time, int32 interval_time ** The defined behavior is to not arm the timer if the start time is zero ** If the interval time is zero, then the timer will not be re-armed. */ - if ( start_time > 0 ) + if (start_time > 0) { - /* - ** Convert from Microseconds to the timeout - */ - OS_UsecsToTicks(start_time, &start_ticks); - - user_data.opaque_arg = NULL; - user_data.id = OS_global_timebase_table[timer_id].active_id; - - status = rtems_timer_fire_after(local->rtems_timer_id, start_ticks, - OS_TimeBase_ISR, user_data.opaque_arg ); - if ( status != RTEMS_SUCCESSFUL ) - { - return_code = OS_TIMER_ERR_INTERNAL; - } - else - { - local->configured_start_time = (10000 * start_ticks) / OS_SharedGlobalVars.TicksPerSecond; - local->configured_interval_time = (10000 * local->interval_ticks) / OS_SharedGlobalVars.TicksPerSecond; - local->configured_start_time *= 100; - local->configured_interval_time *= 100; - - if (local->configured_start_time != start_time) - { - OS_DEBUG("WARNING: timer %lu start_time requested=%luus, configured=%luus\n", - (unsigned long)timer_id, - (unsigned long)start_time, - (unsigned long)local->configured_start_time); - } - if (local->configured_interval_time != interval_time) - { - OS_DEBUG("WARNING: timer %lu interval_time requested=%luus, configured=%luus\n", - (unsigned long)timer_id, - (unsigned long)interval_time, - (unsigned long)local->configured_interval_time); - } - - if (local->interval_ticks > 0) - { - OS_timebase_table[timer_id].accuracy_usec = local->configured_interval_time; - } - else - { - OS_timebase_table[timer_id].accuracy_usec = local->configured_start_time; - } - } + /* + ** Convert from Microseconds to the timeout + */ + OS_UsecsToTicks(start_time, &start_ticks); + + user_data.opaque_arg = NULL; + user_data.id = OS_global_timebase_table[timer_id].active_id; + + status = rtems_timer_fire_after(local->rtems_timer_id, start_ticks, OS_TimeBase_ISR, user_data.opaque_arg); + if (status != RTEMS_SUCCESSFUL) + { + return_code = OS_TIMER_ERR_INTERNAL; + } + else + { + local->configured_start_time = (10000 * start_ticks) / OS_SharedGlobalVars.TicksPerSecond; + local->configured_interval_time = (10000 * local->interval_ticks) / OS_SharedGlobalVars.TicksPerSecond; + local->configured_start_time *= 100; + local->configured_interval_time *= 100; + + if (local->configured_start_time != start_time) + { + OS_DEBUG("WARNING: timer %lu start_time requested=%luus, configured=%luus\n", + (unsigned long)timer_id, (unsigned long)start_time, + (unsigned long)local->configured_start_time); + } + if (local->configured_interval_time != interval_time) + { + OS_DEBUG("WARNING: timer %lu interval_time requested=%luus, configured=%luus\n", + (unsigned long)timer_id, (unsigned long)interval_time, + (unsigned long)local->configured_interval_time); + } + + if (local->interval_ticks > 0) + { + OS_timebase_table[timer_id].accuracy_usec = local->configured_interval_time; + } + else + { + OS_timebase_table[timer_id].accuracy_usec = local->configured_start_time; + } + } } } @@ -526,8 +504,6 @@ int32 OS_TimeBaseSet_Impl(uint32 timer_id, int32 start_time, int32 interval_time return return_code; } /* end OS_TimeBaseSet_Impl */ - - /*---------------------------------------------------------------- * * Function: OS_TimeBaseDelete_Impl @@ -538,11 +514,11 @@ int32 OS_TimeBaseSet_Impl(uint32 timer_id, int32 start_time, int32 interval_time *-----------------------------------------------------------------*/ int32 OS_TimeBaseDelete_Impl(uint32 timer_id) { - rtems_status_code rtems_sc; + rtems_status_code rtems_sc; OS_impl_timebase_internal_record_t *local; - int32 return_code; + int32 return_code; - local = &OS_impl_timebase_table[timer_id]; + local = &OS_impl_timebase_table[timer_id]; return_code = OS_SUCCESS; /* @@ -572,7 +548,7 @@ int32 OS_TimeBaseDelete_Impl(uint32 timer_id) */ if (return_code == OS_SUCCESS) { - rtems_sc = rtems_semaphore_delete (local->handler_mutex); + rtems_sc = rtems_semaphore_delete(local->handler_mutex); if (rtems_sc != RTEMS_SUCCESSFUL) { OS_DEBUG("Error deleting handler mutex: %s\n", rtems_status_text(rtems_sc)); @@ -580,7 +556,7 @@ int32 OS_TimeBaseDelete_Impl(uint32 timer_id) if (local->simulate_flag) { - rtems_sc = rtems_semaphore_delete (local->tick_sem); + rtems_sc = rtems_semaphore_delete(local->tick_sem); if (rtems_sc != RTEMS_SUCCESSFUL) { OS_DEBUG("Error deleting tick semaphore: %s\n", rtems_status_text(rtems_sc)); @@ -592,7 +568,6 @@ int32 OS_TimeBaseDelete_Impl(uint32 timer_id) return return_code; } /* end OS_TimeBaseDelete_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TimeBaseGetInfo_Impl @@ -601,9 +576,8 @@ int32 OS_TimeBaseDelete_Impl(uint32 timer_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TimeBaseGetInfo_Impl (uint32 timer_id, OS_timebase_prop_t *timer_prop) +int32 OS_TimeBaseGetInfo_Impl(uint32 timer_id, OS_timebase_prop_t *timer_prop) { return OS_SUCCESS; } /* end OS_TimeBaseGetInfo_Impl */ - diff --git a/src/os/shared/inc/os-shared-binsem.h b/src/os/shared/inc/os-shared-binsem.h index 454ea755e..8304d2b2e 100644 --- a/src/os/shared/inc/os-shared-binsem.h +++ b/src/os/shared/inc/os-shared-binsem.h @@ -33,16 +33,14 @@ /* other objects that have only an API name and no other data */ typedef struct { - char obj_name[OS_MAX_API_NAME]; + char obj_name[OS_MAX_API_NAME]; } OS_bin_sem_internal_record_t; - - /* * These record types have extra information with each entry. These tables are used * to share extra data between the common layer and the OS-specific implementation. */ -extern OS_bin_sem_internal_record_t OS_bin_sem_table[OS_MAX_BIN_SEMAPHORES]; +extern OS_bin_sem_internal_record_t OS_bin_sem_table[OS_MAX_BIN_SEMAPHORES]; /**************************************************************************************** SEMAPHORE API LOW-LEVEL IMPLEMENTATION FUNCTIONS @@ -55,8 +53,7 @@ extern OS_bin_sem_internal_record_t OS_bin_sem_table[OS_MAX_BIN_SEMAPHORE returns: OS_SUCCESS on success, or relevant error code ---------------------------------------------------------------------------------------*/ -int32 OS_BinSemAPI_Init (void); - +int32 OS_BinSemAPI_Init(void); /*---------------------------------------------------------------- Function: OS_BinSemCreate_Impl @@ -65,7 +62,7 @@ int32 OS_BinSemAPI_Init (void); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_BinSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 options); +int32 OS_BinSemCreate_Impl(uint32 sem_id, uint32 sem_initial_value, uint32 options); /*---------------------------------------------------------------- Function: OS_BinSemFlush_Impl @@ -75,7 +72,7 @@ int32 OS_BinSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, ui Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_BinSemFlush_Impl (uint32 sem_id); +int32 OS_BinSemFlush_Impl(uint32 sem_id); /*---------------------------------------------------------------- Function: OS_BinSemGive_Impl @@ -84,7 +81,7 @@ int32 OS_BinSemFlush_Impl (uint32 sem_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_BinSemGive_Impl (uint32 sem_id); +int32 OS_BinSemGive_Impl(uint32 sem_id); /*---------------------------------------------------------------- Function: OS_BinSemTake_Impl @@ -94,7 +91,7 @@ int32 OS_BinSemGive_Impl (uint32 sem_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_BinSemTake_Impl (uint32 sem_id); +int32 OS_BinSemTake_Impl(uint32 sem_id); /*---------------------------------------------------------------- Function: OS_BinSemTimedWait_Impl @@ -104,7 +101,7 @@ int32 OS_BinSemTake_Impl (uint32 sem_id); Returns: OS_SUCCESS on success, or relevant error code OS_SEM_TIMEOUT must be returned if the time limit was reached ------------------------------------------------------------------*/ -int32 OS_BinSemTimedWait_Impl (uint32 sem_id, uint32 msecs); +int32 OS_BinSemTimedWait_Impl(uint32 sem_id, uint32 msecs); /*---------------------------------------------------------------- Function: OS_BinSemDelete_Impl @@ -113,7 +110,7 @@ int32 OS_BinSemTimedWait_Impl (uint32 sem_id, uint32 msecs); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_BinSemDelete_Impl (uint32 sem_id); +int32 OS_BinSemDelete_Impl(uint32 sem_id); /*---------------------------------------------------------------- Function: OS_BinSemGetInfo_Impl @@ -122,8 +119,6 @@ int32 OS_BinSemDelete_Impl (uint32 sem_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_BinSemGetInfo_Impl (uint32 sem_id, OS_bin_sem_prop_t *bin_prop); - - -#endif /* INCLUDE_OS_SHARED_BINSEM_H_ */ +int32 OS_BinSemGetInfo_Impl(uint32 sem_id, OS_bin_sem_prop_t *bin_prop); +#endif /* INCLUDE_OS_SHARED_BINSEM_H_ */ diff --git a/src/os/shared/inc/os-shared-clock.h b/src/os/shared/inc/os-shared-clock.h index 36d568ac1..60cada199 100644 --- a/src/os/shared/inc/os-shared-clock.h +++ b/src/os/shared/inc/os-shared-clock.h @@ -30,7 +30,6 @@ #include - /* * Clock API low-level handlers * These simply get/set the kernel RTC (if it has one) @@ -54,6 +53,4 @@ int32 OS_GetLocalTime_Impl(OS_time_t *time_struct); ------------------------------------------------------------------*/ int32 OS_SetLocalTime_Impl(const OS_time_t *time_struct); - -#endif /* INCLUDE_OS_SHARED_CLOCK_H_ */ - +#endif /* INCLUDE_OS_SHARED_CLOCK_H_ */ diff --git a/src/os/shared/inc/os-shared-common.h b/src/os/shared/inc/os-shared-common.h index 6f5ba6a86..e98858a33 100644 --- a/src/os/shared/inc/os-shared-common.h +++ b/src/os/shared/inc/os-shared-common.h @@ -34,42 +34,38 @@ * A "magic number" that when written to the "ShutdownFlag" member * of the global state structure indicates an active shutdown request. */ -#define OS_SHUTDOWN_MAGIC_NUMBER 0xABADC0DE - - +#define OS_SHUTDOWN_MAGIC_NUMBER 0xABADC0DE /* Global variables that are common between implementations */ struct OS_shared_global_vars { - bool Initialized; - - /* - * The console device ID used for OS_printf() calls - */ - osal_id_t PrintfConsoleId; - - /* - * PrintfEnabled and ShutdownFlag are marked "volatile" - * because they are updated and read by different threads - */ - volatile bool PrintfEnabled; - volatile uint32 ShutdownFlag; - int32 MicroSecPerTick; - int32 TicksPerSecond; - - /* - * The event handler is an application-defined callback - * that gets invoked as resources are created/configured/deleted. - */ - OS_EventHandler_t EventHandler; + bool Initialized; + + /* + * The console device ID used for OS_printf() calls + */ + osal_id_t PrintfConsoleId; + + /* + * PrintfEnabled and ShutdownFlag are marked "volatile" + * because they are updated and read by different threads + */ + volatile bool PrintfEnabled; + volatile uint32 ShutdownFlag; + int32 MicroSecPerTick; + int32 TicksPerSecond; + + /* + * The event handler is an application-defined callback + * that gets invoked as resources are created/configured/deleted. + */ + OS_EventHandler_t EventHandler; #ifdef OSAL_CONFIG_DEBUG_PRINTF - uint8 DebugLevel; + uint8 DebugLevel; #endif - }; - /* * Shared data structure for global values */ @@ -84,7 +80,6 @@ extern OS_SharedGlobalVars_t OS_SharedGlobalVars; ---------------------------------------------------------------------------------------*/ int32 OS_NotifyEvent(OS_Event_t event, osal_id_t object_id, void *data); - /*--------------------------------------------------------------------------------------- Name: OS_API_Impl_Init @@ -92,9 +87,7 @@ int32 OS_NotifyEvent(OS_Event_t event, osal_id_t object_id, void *data); returns: OS_SUCCESS on success, or relevant error code ---------------------------------------------------------------------------------------*/ -int32 OS_API_Impl_Init (uint32 idtype); - - +int32 OS_API_Impl_Init(uint32 idtype); /* * This functions implement a the OS-specific portion @@ -102,7 +95,6 @@ int32 OS_API_Impl_Init (uint32 idtype); * OS-specific source files. */ - /*---------------------------------------------------------------- Function: OS_IdleLoop_Impl @@ -116,7 +108,7 @@ int32 OS_API_Impl_Init (uint32 idtype); event happens. ------------------------------------------------------------------*/ -void OS_IdleLoop_Impl (void); +void OS_IdleLoop_Impl(void); /*---------------------------------------------------------------- @@ -133,7 +125,6 @@ void OS_IdleLoop_Impl (void); depending on priority levels. ------------------------------------------------------------------*/ -void OS_ApplicationShutdown_Impl (void); - -#endif /* INCLUDE_OS_SHARED_COMMON_H_ */ +void OS_ApplicationShutdown_Impl(void); +#endif /* INCLUDE_OS_SHARED_COMMON_H_ */ diff --git a/src/os/shared/inc/os-shared-countsem.h b/src/os/shared/inc/os-shared-countsem.h index 650435aa8..8298aad38 100644 --- a/src/os/shared/inc/os-shared-countsem.h +++ b/src/os/shared/inc/os-shared-countsem.h @@ -30,19 +30,17 @@ #include - /* other objects that have only an API name and no other data */ typedef struct { - char obj_name[OS_MAX_API_NAME]; + char obj_name[OS_MAX_API_NAME]; } OS_count_sem_internal_record_t; - /* * These record types have extra information with each entry. These tables are used * to share extra data between the common layer and the OS-specific implementation. */ -extern OS_count_sem_internal_record_t OS_count_sem_table[OS_MAX_COUNT_SEMAPHORES]; +extern OS_count_sem_internal_record_t OS_count_sem_table[OS_MAX_COUNT_SEMAPHORES]; /**************************************************************************************** IMPLEMENTATION FUNCTIONS @@ -55,8 +53,7 @@ extern OS_count_sem_internal_record_t OS_count_sem_table[OS_MAX_COUNT_SEM returns: OS_SUCCESS on success, or relevant error code ---------------------------------------------------------------------------------------*/ -int32 OS_CountSemAPI_Init (void); - +int32 OS_CountSemAPI_Init(void); /*---------------------------------------------------------------- Function: OS_CountSemCreate_Impl @@ -65,7 +62,7 @@ int32 OS_CountSemAPI_Init (void); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_CountSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 options); +int32 OS_CountSemCreate_Impl(uint32 sem_id, uint32 sem_initial_value, uint32 options); /*---------------------------------------------------------------- Function: OS_CountSemGive_Impl @@ -74,7 +71,7 @@ int32 OS_CountSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_CountSemGive_Impl (uint32 sem_id); +int32 OS_CountSemGive_Impl(uint32 sem_id); /*---------------------------------------------------------------- Function: OS_CountSemTake_Impl @@ -84,7 +81,7 @@ int32 OS_CountSemGive_Impl (uint32 sem_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_CountSemTake_Impl (uint32 sem_id); +int32 OS_CountSemTake_Impl(uint32 sem_id); /*---------------------------------------------------------------- Function: OS_CountSemTimedWait_Impl @@ -94,7 +91,7 @@ int32 OS_CountSemTake_Impl (uint32 sem_id); Returns: OS_SUCCESS on success, or relevant error code OS_SEM_TIMEOUT must be returned if the time limit was reached ------------------------------------------------------------------*/ -int32 OS_CountSemTimedWait_Impl (uint32 sem_id, uint32 msecs); +int32 OS_CountSemTimedWait_Impl(uint32 sem_id, uint32 msecs); /*---------------------------------------------------------------- Function: OS_CountSemDelete_Impl @@ -103,7 +100,7 @@ int32 OS_CountSemTimedWait_Impl (uint32 sem_id, uint32 msecs); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_CountSemDelete_Impl (uint32 sem_id); +int32 OS_CountSemDelete_Impl(uint32 sem_id); /*---------------------------------------------------------------- Function: OS_CountSemGetInfo_Impl @@ -112,8 +109,6 @@ int32 OS_CountSemDelete_Impl (uint32 sem_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_CountSemGetInfo_Impl (uint32 sem_id, OS_count_sem_prop_t *count_prop); - - -#endif /* INCLUDE_OS_SHARED_COUNTSEM_H_ */ +int32 OS_CountSemGetInfo_Impl(uint32 sem_id, OS_count_sem_prop_t *count_prop); +#endif /* INCLUDE_OS_SHARED_COUNTSEM_H_ */ diff --git a/src/os/shared/inc/os-shared-dir.h b/src/os/shared/inc/os-shared-dir.h index 0ab885ffd..79d783e86 100644 --- a/src/os/shared/inc/os-shared-dir.h +++ b/src/os/shared/inc/os-shared-dir.h @@ -33,16 +33,14 @@ /* directory objects */ typedef struct { - char dir_name[OS_MAX_PATH_LEN]; + char dir_name[OS_MAX_PATH_LEN]; } OS_dir_internal_record_t; - /* * These record types have extra information with each entry. These tables are used * to share extra data between the common layer and the OS-specific implementation. */ -extern OS_dir_internal_record_t OS_dir_table[OS_MAX_NUM_OPEN_DIRS]; - +extern OS_dir_internal_record_t OS_dir_table[OS_MAX_NUM_OPEN_DIRS]; /* * Directory API abstraction layer @@ -56,9 +54,7 @@ extern OS_dir_internal_record_t OS_dir_table[OS_MAX_NUM_OPEN_DIRS]; returns: OS_SUCCESS on success, or relevant error code ---------------------------------------------------------------------------------------*/ -int32 OS_DirAPI_Init (void); - - +int32 OS_DirAPI_Init(void); /*---------------------------------------------------------------- Function: OS_DirCreate_Impl @@ -114,5 +110,4 @@ int32 OS_DirRewind_Impl(uint32 local_id); ------------------------------------------------------------------*/ int32 OS_DirRemove_Impl(const char *local_path); -#endif /* INCLUDE_OS_SHARED_DIR_H_ */ - +#endif /* INCLUDE_OS_SHARED_DIR_H_ */ diff --git a/src/os/shared/inc/os-shared-errors.h b/src/os/shared/inc/os-shared-errors.h index 38061e326..0b4968f62 100644 --- a/src/os/shared/inc/os-shared-errors.h +++ b/src/os/shared/inc/os-shared-errors.h @@ -30,15 +30,13 @@ #include - /* Mapping of integer error number to name */ typedef struct { - int32 Number; - const char *Name; + int32 Number; + const char *Name; } OS_ErrorTable_Entry_t; -extern const OS_ErrorTable_Entry_t OS_IMPL_ERROR_NAME_TABLE[]; - -#endif /* INCLUDE_OS_SHARED_ERRORS_H_ */ +extern const OS_ErrorTable_Entry_t OS_IMPL_ERROR_NAME_TABLE[]; +#endif /* INCLUDE_OS_SHARED_ERRORS_H_ */ diff --git a/src/os/shared/inc/os-shared-file.h b/src/os/shared/inc/os-shared-file.h index f3cd7f07a..75c8fc912 100644 --- a/src/os/shared/inc/os-shared-file.h +++ b/src/os/shared/inc/os-shared-file.h @@ -30,23 +30,19 @@ #include - typedef struct { - char stream_name[OS_MAX_PATH_LEN]; - uint8 socket_domain; - uint8 socket_type; - uint16 stream_state; + char stream_name[OS_MAX_PATH_LEN]; + uint8 socket_domain; + uint8 socket_type; + uint16 stream_state; } OS_stream_internal_record_t; /* * These record types have extra information with each entry. These tables are used * to share extra data between the common layer and the OS-specific implementation. */ -extern OS_stream_internal_record_t OS_stream_table[OS_MAX_NUM_OPEN_FILES]; - - - +extern OS_stream_internal_record_t OS_stream_table[OS_MAX_NUM_OPEN_FILES]; /**************************************************************************************** FILE / DIRECTORY API LOW-LEVEL IMPLEMENTATION FUNCTIONS @@ -59,8 +55,7 @@ extern OS_stream_internal_record_t OS_stream_table[OS_MAX_NUM_OPEN_FILES returns: OS_SUCCESS on success, or relevant error code ---------------------------------------------------------------------------------------*/ -int32 OS_FileAPI_Init (void); - +int32 OS_FileAPI_Init(void); /* * Generic stream manipulation implementation @@ -83,7 +78,7 @@ int32 OS_FileAPI_Init (void); Returns: File position (non-negative) on success, or relevant error code (negative) ------------------------------------------------------------------*/ -int32 OS_GenericSeek_Impl (uint32 local_id, int32 offset, uint32 whence); +int32 OS_GenericSeek_Impl(uint32 local_id, int32 offset, uint32 whence); /*---------------------------------------------------------------- Function: OS_GenericRead_Impl @@ -93,7 +88,7 @@ int32 OS_GenericSeek_Impl (uint32 local_id, int32 offset, uint32 whence); Returns: Number of bytes read (non-negative) on success, or relevant error code (negative) ------------------------------------------------------------------*/ -int32 OS_GenericRead_Impl (uint32 local_id, void *buffer, uint32 nbytes, int32 timeout); +int32 OS_GenericRead_Impl(uint32 local_id, void *buffer, uint32 nbytes, int32 timeout); /*---------------------------------------------------------------- Function: OS_GenericWrite_Impl @@ -105,7 +100,6 @@ int32 OS_GenericRead_Impl (uint32 local_id, void *buffer, uint32 nbytes, int32 t ------------------------------------------------------------------*/ int32 OS_GenericWrite_Impl(uint32 local_id, const void *buffer, uint32 nbytes, int32 timeout); - /*---------------------------------------------------------------- Function: OS_GenericClose_Impl @@ -133,15 +127,12 @@ int32 OS_FileOpen_Impl(uint32 local_id, const char *local_path, int32 flags, int Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_ShellOutputToFile_Impl(uint32 stream_id, const char* Cmd); - - +int32 OS_ShellOutputToFile_Impl(uint32 stream_id, const char *Cmd); /**************************************************************************************** Filename-based Operations ***************************************************************************************/ - /* * These FileXXX_Impl calls are usable for things that operate on pathnames, * that is to say they appear in the file system in some way. @@ -191,5 +182,4 @@ int32 OS_FileRename_Impl(const char *old_path, const char *new_path); ------------------------------------------------------------------*/ int32 OS_FileChmod_Impl(const char *local_path, uint32 access); -#endif /* INCLUDE_OS_SHARED_FILE_H_ */ - +#endif /* INCLUDE_OS_SHARED_FILE_H_ */ diff --git a/src/os/shared/inc/os-shared-filesys.h b/src/os/shared/inc/os-shared-filesys.h index 6e74a00d5..c4227ce59 100644 --- a/src/os/shared/inc/os-shared-filesys.h +++ b/src/os/shared/inc/os-shared-filesys.h @@ -38,8 +38,7 @@ * The filesystem should be configured and mounted at the right * spot prior to starting OSAL. */ -#define OS_FILESYS_FLAG_IS_FIXED 0x01 - +#define OS_FILESYS_FLAG_IS_FIXED 0x01 /** * This flag will be set on the internal record to indicate @@ -51,21 +50,21 @@ * On VxWorks, this means that the low-level block device * is registered in the kernel and XBD layers. */ -#define OS_FILESYS_FLAG_IS_READY 0x02 +#define OS_FILESYS_FLAG_IS_READY 0x02 /** * This flag will be set on the internal record to indicate * that the file system is accessible within the underlying * operating system, i.e. that the system_mountpt is valid. */ -#define OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM 0x10 +#define OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM 0x10 /** * This flag will be set on the internal record to indicate * that the file system is mounted within the virtualized * file system exposed to applications. */ -#define OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL 0x20 +#define OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL 0x20 /** * These definitions apply to the "type" field within @@ -76,11 +75,11 @@ */ enum { - OS_FILESYS_TYPE_UNKNOWN = 0, /**< Unspecified or unknown file system type */ - OS_FILESYS_TYPE_FS_BASED, /**< A emulated virtual file system that maps to another file system location */ - OS_FILESYS_TYPE_NORMAL_DISK, /**< A traditional disk drive or something that emulates one */ - OS_FILESYS_TYPE_VOLATILE_DISK, /**< A temporary/volatile file system or RAM disk */ - OS_FILESYS_TYPE_MTD, /**< A "memory technology device" such as FLASH or EEPROM */ + OS_FILESYS_TYPE_UNKNOWN = 0, /**< Unspecified or unknown file system type */ + OS_FILESYS_TYPE_FS_BASED, /**< A emulated virtual file system that maps to another file system location */ + OS_FILESYS_TYPE_NORMAL_DISK, /**< A traditional disk drive or something that emulates one */ + OS_FILESYS_TYPE_VOLATILE_DISK, /**< A temporary/volatile file system or RAM disk */ + OS_FILESYS_TYPE_MTD, /**< A "memory technology device" such as FLASH or EEPROM */ OS_FILESYS_TYPE_MAX }; @@ -100,26 +99,26 @@ typedef struct uint64 blocks_free; } OS_statvfs_t; - typedef struct { - char device_name[OS_FS_DEV_NAME_LEN]; /**< The name of the underlying block device, if applicable */ + char device_name[OS_FS_DEV_NAME_LEN]; /**< The name of the underlying block device, if applicable */ char volume_name[OS_FS_VOL_NAME_LEN]; - char system_mountpt[OS_MAX_LOCAL_PATH_LEN]; /**< The name/prefix where the contents are accessible in the host operating system */ - char virtual_mountpt[OS_MAX_PATH_LEN]; /**< The name/prefix in the OSAL Virtual File system exposed to applications */ - char *address; + char system_mountpt[OS_MAX_LOCAL_PATH_LEN]; /**< The name/prefix where the contents are accessible in the host + operating system */ + char virtual_mountpt[OS_MAX_PATH_LEN]; /**< The name/prefix in the OSAL Virtual File system exposed to applications + */ + char * address; uint32 blocksize; uint32 numblocks; - uint8 flags; - uint8 fstype; + uint8 flags; + uint8 fstype; } OS_filesys_internal_record_t; /* * These record types have extra information with each entry. These tables are used * to share extra data between the common layer and the OS-specific implementation. */ -extern OS_filesys_internal_record_t OS_filesys_table[OS_MAX_FILE_SYSTEMS]; - +extern OS_filesys_internal_record_t OS_filesys_table[OS_MAX_FILE_SYSTEMS]; /* * File system abstraction layer @@ -132,9 +131,7 @@ extern OS_filesys_internal_record_t OS_filesys_table[OS_MAX_FILE_SYSTEMS] returns: OS_SUCCESS on success, or relevant error code ---------------------------------------------------------------------------------------*/ -int32 OS_FileSysAPI_Init (void); - - +int32 OS_FileSysAPI_Init(void); /*---------------------------------------------------------------- Function: OS_FileSysStartVolume_Impl @@ -143,7 +140,7 @@ int32 OS_FileSysAPI_Init (void); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_FileSysStartVolume_Impl (uint32 filesys_id); +int32 OS_FileSysStartVolume_Impl(uint32 filesys_id); /*---------------------------------------------------------------- Function: OS_FileSysStopVolume_Impl @@ -152,7 +149,7 @@ int32 OS_FileSysStartVolume_Impl (uint32 filesys_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_FileSysStopVolume_Impl (uint32 filesys_id); +int32 OS_FileSysStopVolume_Impl(uint32 filesys_id); /*---------------------------------------------------------------- Function: OS_FileSysFormatVolume_Impl @@ -161,7 +158,7 @@ int32 OS_FileSysStopVolume_Impl (uint32 filesys_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_FileSysFormatVolume_Impl (uint32 filesys_id); +int32 OS_FileSysFormatVolume_Impl(uint32 filesys_id); /*---------------------------------------------------------------- Function: OS_FileSysCheckVolume_Impl @@ -170,7 +167,7 @@ int32 OS_FileSysFormatVolume_Impl (uint32 filesys_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_FileSysCheckVolume_Impl (uint32 filesys_id, bool repair); +int32 OS_FileSysCheckVolume_Impl(uint32 filesys_id, bool repair); /*---------------------------------------------------------------- Function: OS_FileSysStatVolume_Impl @@ -179,7 +176,7 @@ int32 OS_FileSysCheckVolume_Impl (uint32 filesys_id, bool repair); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_FileSysStatVolume_Impl (uint32 filesys_id, OS_statvfs_t *result); +int32 OS_FileSysStatVolume_Impl(uint32 filesys_id, OS_statvfs_t *result); /*---------------------------------------------------------------- Function: OS_FileSysMountVolume_Impl @@ -188,7 +185,7 @@ int32 OS_FileSysStatVolume_Impl (uint32 filesys_id, OS_statvfs_t *result); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_FileSysMountVolume_Impl (uint32 filesys_id); +int32 OS_FileSysMountVolume_Impl(uint32 filesys_id); /*---------------------------------------------------------------- Function: OS_FileSysUnmountVolume_Impl @@ -197,8 +194,7 @@ int32 OS_FileSysMountVolume_Impl (uint32 filesys_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_FileSysUnmountVolume_Impl (uint32 filesys_id); - +int32 OS_FileSysUnmountVolume_Impl(uint32 filesys_id); /* * Internal helper functions @@ -206,9 +202,8 @@ int32 OS_FileSysUnmountVolume_Impl (uint32 filesys_id); * Not normally invoked outside this unit, except for unit testing */ -bool OS_FileSys_FindVirtMountPoint(void *ref, uint32 local_id, const OS_common_record_t *obj); -int32 OS_FileSys_Initialize(char *address, const char *fsdevname, const char * fsvolname, uint32 blocksize, - uint32 numblocks, bool should_format); - -#endif /* INCLUDE_OS_SHARED_FILESYS_H_ */ +bool OS_FileSys_FindVirtMountPoint(void *ref, uint32 local_id, const OS_common_record_t *obj); +int32 OS_FileSys_Initialize(char *address, const char *fsdevname, const char *fsvolname, uint32 blocksize, + uint32 numblocks, bool should_format); +#endif /* INCLUDE_OS_SHARED_FILESYS_H_ */ diff --git a/src/os/shared/inc/os-shared-globaldefs.h b/src/os/shared/inc/os-shared-globaldefs.h index 71c1f16aa..cbca0704c 100644 --- a/src/os/shared/inc/os-shared-globaldefs.h +++ b/src/os/shared/inc/os-shared-globaldefs.h @@ -56,16 +56,14 @@ typedef struct OS_shared_global_vars OS_SharedGlobalVars_t; */ typedef union { - void *opaque_arg; - OS_ArgCallback_t arg_callback_func; - OS_TimerCallback_t timer_callback_func; - osal_task_entry entry_func; - osal_id_t id; - uint32 value; + void * opaque_arg; + OS_ArgCallback_t arg_callback_func; + OS_TimerCallback_t timer_callback_func; + osal_task_entry entry_func; + osal_id_t id; + uint32 value; } OS_U32ValueWrapper_t; - - /* * The "OS_DEBUG" is a no-op unless OSAL_CONFIG_DEBUG_PRINTF is enabled. * When enabled, it is a macro that includes function/line number info. @@ -74,14 +72,11 @@ typedef union extern void OS_DebugPrintf(uint32 Level, const char *Func, uint32 Line, const char *Format, ...); /* Debug printfs are compiled in, but also can be disabled by a run-time flag. * Note that the ##__VA_ARGS__ syntax works on GCC but might need tweaks for other compilers... */ -#define OS_DEBUG_LEV(l,...) OS_DebugPrintf(l, __func__, __LINE__, __VA_ARGS__); -#define OS_DEBUG(...) OS_DEBUG_LEV(1,__VA_ARGS__) +#define OS_DEBUG_LEV(l, ...) OS_DebugPrintf(l, __func__, __LINE__, __VA_ARGS__); +#define OS_DEBUG(...) OS_DEBUG_LEV(1, __VA_ARGS__) #else /* Debug printfs are not compiled in at all */ #define OS_DEBUG(...) #endif - - -#endif /* INCLUDE_OS_SHARED_GLOBALDEFS_H_ */ - +#endif /* INCLUDE_OS_SHARED_GLOBALDEFS_H_ */ diff --git a/src/os/shared/inc/os-shared-heap.h b/src/os/shared/inc/os-shared-heap.h index 3b088d1f0..510eb432c 100644 --- a/src/os/shared/inc/os-shared-heap.h +++ b/src/os/shared/inc/os-shared-heap.h @@ -30,7 +30,6 @@ #include - /**************************************************************************************** MEMORY HEAP API LOW-LEVEL IMPLEMENTATION FUNCTIONS ****************************************************************************************/ @@ -48,5 +47,4 @@ ------------------------------------------------------------------*/ int32 OS_HeapGetInfo_Impl(OS_heap_prop_t *heap_prop); -#endif /* INCLUDE_OS_SHARED_HEAP_H_ */ - +#endif /* INCLUDE_OS_SHARED_HEAP_H_ */ diff --git a/src/os/shared/inc/os-shared-idmap.h b/src/os/shared/inc/os-shared-idmap.h index df27d5d74..30f128bc2 100644 --- a/src/os/shared/inc/os-shared-idmap.h +++ b/src/os/shared/inc/os-shared-idmap.h @@ -30,36 +30,33 @@ #include +#define OS_OBJECT_EXCL_REQ_FLAG 0x0001 -#define OS_OBJECT_EXCL_REQ_FLAG 0x0001 - -#define OS_OBJECT_ID_RESERVED ((osal_id_t){0xFFFFFFFF}) +#define OS_OBJECT_ID_RESERVED ((osal_id_t) {0xFFFFFFFF}) /* * This supplies a non-abstract definition of "OS_common_record_t" */ struct OS_common_record { - const char *name_entry; - osal_id_t active_id; - osal_id_t creator; - uint16 refcount; - uint16 flags; + const char *name_entry; + osal_id_t active_id; + osal_id_t creator; + uint16 refcount; + uint16 flags; }; - /* * Type of locking that should occur when checking IDs. */ typedef enum { - OS_LOCK_MODE_NONE, /**< Do not lock global table at all (use with caution) */ - OS_LOCK_MODE_GLOBAL, /**< Lock during operation, and if successful, leave global table locked */ - OS_LOCK_MODE_EXCLUSIVE, /**< Like OS_LOCK_MODE_GLOBAL but must be exclusive (refcount == zero) */ - OS_LOCK_MODE_REFCOUNT, /**< If operation succeeds, increment refcount and unlock global table */ + OS_LOCK_MODE_NONE, /**< Do not lock global table at all (use with caution) */ + OS_LOCK_MODE_GLOBAL, /**< Lock during operation, and if successful, leave global table locked */ + OS_LOCK_MODE_EXCLUSIVE, /**< Like OS_LOCK_MODE_GLOBAL but must be exclusive (refcount == zero) */ + OS_LOCK_MODE_REFCOUNT, /**< If operation succeeds, increment refcount and unlock global table */ } OS_lock_mode_t; - /* * A function to perform arbitrary record matching. * @@ -74,21 +71,18 @@ typedef bool (*OS_ObjectMatchFunc_t)(void *ref, uint32 local_id, const OS_common * Global instantiations */ /* The following are quick-access pointers to the various sections of the common table */ -extern OS_common_record_t * const OS_global_task_table; -extern OS_common_record_t * const OS_global_queue_table; -extern OS_common_record_t * const OS_global_bin_sem_table; -extern OS_common_record_t * const OS_global_count_sem_table; -extern OS_common_record_t * const OS_global_mutex_table; -extern OS_common_record_t * const OS_global_stream_table; -extern OS_common_record_t * const OS_global_dir_table; -extern OS_common_record_t * const OS_global_timebase_table; -extern OS_common_record_t * const OS_global_timecb_table; -extern OS_common_record_t * const OS_global_module_table; -extern OS_common_record_t * const OS_global_filesys_table; -extern OS_common_record_t * const OS_global_console_table; - - - +extern OS_common_record_t *const OS_global_task_table; +extern OS_common_record_t *const OS_global_queue_table; +extern OS_common_record_t *const OS_global_bin_sem_table; +extern OS_common_record_t *const OS_global_count_sem_table; +extern OS_common_record_t *const OS_global_mutex_table; +extern OS_common_record_t *const OS_global_stream_table; +extern OS_common_record_t *const OS_global_dir_table; +extern OS_common_record_t *const OS_global_timebase_table; +extern OS_common_record_t *const OS_global_timecb_table; +extern OS_common_record_t *const OS_global_module_table; +extern OS_common_record_t *const OS_global_filesys_table; +extern OS_common_record_t *const OS_global_console_table; /**************************************************************************************** ID MAPPING FUNCTIONS @@ -101,15 +95,13 @@ extern OS_common_record_t * const OS_global_console_table; returns: OS_SUCCESS on success, or relevant error code ---------------------------------------------------------------------------------------*/ -int32 OS_ObjectIdInit (void); - +int32 OS_ObjectIdInit(void); /* * Table locking and unlocking for global objects can be done at the shared code * layer but the actual implementation is OS-specific */ - /*---------------------------------------------------------------- Function: OS_Lock_Global @@ -137,7 +129,6 @@ int32 OS_Lock_Global_Impl(uint32 idtype); ------------------------------------------------------------------*/ void OS_Unlock_Global(uint32 idtype); - /*---------------------------------------------------------------- Function: OS_Unlock_Global @@ -147,8 +138,6 @@ void OS_Unlock_Global(uint32 idtype); ------------------------------------------------------------------*/ int32 OS_Unlock_Global_Impl(uint32 idtype); - - /* Function prototypes for routines implemented in common layers but private to OSAL @@ -177,7 +166,6 @@ static inline uint32 OS_ObjectIdToType_Impl(osal_id_t id) return (OS_ObjectIdToInteger(id) >> OS_OBJECT_TYPE_SHIFT); } - /*---------------------------------------------------------------- Function: OS_ObjectIdCompose @@ -188,7 +176,6 @@ static inline void OS_ObjectIdCompose_Impl(uint32 idtype, uint32 idserial, osal_ *result = OS_ObjectIdFromInteger((idtype << OS_OBJECT_TYPE_SHIFT) | idserial); } - /*---------------------------------------------------------------- Function: OS_GetMaxForObjectType @@ -214,7 +201,7 @@ uint32 OS_GetBaseForObjectType(uint32 idtype); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_ObjectIdFindByName (uint32 idtype, const char *name, osal_id_t *object_id); +int32 OS_ObjectIdFindByName(uint32 idtype, const char *name, osal_id_t *object_id); /*---------------------------------------------------------------- Function: OS_ObjectIdGetBySearch @@ -225,7 +212,8 @@ int32 OS_ObjectIdFindByName (uint32 idtype, const char *name, osal_id_t *object_ Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_ObjectIdGetBySearch(OS_lock_mode_t lock_mode, uint32 idtype, OS_ObjectMatchFunc_t MatchFunc, void *arg, OS_common_record_t **record); +int32 OS_ObjectIdGetBySearch(OS_lock_mode_t lock_mode, uint32 idtype, OS_ObjectMatchFunc_t MatchFunc, void *arg, + OS_common_record_t **record); /*---------------------------------------------------------------- Function: OS_ObjectIdGetByName @@ -235,7 +223,7 @@ int32 OS_ObjectIdGetBySearch(OS_lock_mode_t lock_mode, uint32 idtype, OS_ObjectM Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_ObjectIdGetByName (OS_lock_mode_t lock_mode, uint32 idtype, const char *name, OS_common_record_t **record); +int32 OS_ObjectIdGetByName(OS_lock_mode_t lock_mode, uint32 idtype, const char *name, OS_common_record_t **record); /*---------------------------------------------------------------- Function: OS_ObjectIdGetById @@ -245,7 +233,8 @@ int32 OS_ObjectIdGetByName (OS_lock_mode_t lock_mode, uint32 idtype, const char Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_ObjectIdGetById(OS_lock_mode_t lock_mode, uint32 idtype, osal_id_t id, uint32 *array_index, OS_common_record_t **record); +int32 OS_ObjectIdGetById(OS_lock_mode_t lock_mode, uint32 idtype, osal_id_t id, uint32 *array_index, + OS_common_record_t **record); /*---------------------------------------------------------------- Function: OS_ObjectIdAllocateNew @@ -283,7 +272,6 @@ int32 OS_ObjectIdFinalizeNew(int32 operation_status, OS_common_record_t *record, ------------------------------------------------------------------*/ int32 OS_ObjectIdFinalizeDelete(int32 operation_status, OS_common_record_t *record); - /*---------------------------------------------------------------- Function: OS_ObjectIdRefcountDecr @@ -299,11 +287,10 @@ int32 OS_ObjectIdRefcountDecr(OS_common_record_t *record); * These are not normally called outside this unit, but need * to be exposed for unit testing. */ -bool OS_ObjectNameMatch(void *ref, uint32 local_id, const OS_common_record_t *obj); -void OS_ObjectIdInitiateLock(OS_lock_mode_t lock_mode, uint32 idtype); +bool OS_ObjectNameMatch(void *ref, uint32 local_id, const OS_common_record_t *obj); +void OS_ObjectIdInitiateLock(OS_lock_mode_t lock_mode, uint32 idtype); int32 OS_ObjectIdConvertLock(OS_lock_mode_t lock_mode, uint32 idtype, osal_id_t reference_id, OS_common_record_t *obj); int32 OS_ObjectIdSearch(uint32 idtype, OS_ObjectMatchFunc_t MatchFunc, void *arg, OS_common_record_t **record); int32 OS_ObjectIdFindNext(uint32 idtype, uint32 *array_index, OS_common_record_t **record); -#endif /* INCLUDE_OS_SHARED_IDMAP_H_ */ - +#endif /* INCLUDE_OS_SHARED_IDMAP_H_ */ diff --git a/src/os/shared/inc/os-shared-module.h b/src/os/shared/inc/os-shared-module.h index 14d81b1a9..3c93c2345 100644 --- a/src/os/shared/inc/os-shared-module.h +++ b/src/os/shared/inc/os-shared-module.h @@ -30,21 +30,19 @@ #include - typedef struct { - char module_name[OS_MAX_API_NAME]; - char file_name[OS_MAX_PATH_LEN]; - uint32 flags; - cpuaddr entry_point; + char module_name[OS_MAX_API_NAME]; + char file_name[OS_MAX_PATH_LEN]; + uint32 flags; + cpuaddr entry_point; } OS_module_internal_record_t; - /* * These record types have extra information with each entry. These tables are used * to share extra data between the common layer and the OS-specific implementation. */ -extern OS_module_internal_record_t OS_module_table[OS_MAX_MODULES]; +extern OS_module_internal_record_t OS_module_table[OS_MAX_MODULES]; /**************************************************************************************** MODULE LOADER API LOW-LEVEL IMPLEMENTATION FUNCTIONS @@ -57,8 +55,7 @@ extern OS_module_internal_record_t OS_module_table[OS_MAX_MODULES]; returns: OS_SUCCESS on success, or relevant error code ---------------------------------------------------------------------------------------*/ -int32 OS_ModuleAPI_Init (void); - +int32 OS_ModuleAPI_Init(void); /*---------------------------------------------------------------- Function: OS_ModuleLoad_Impl @@ -67,7 +64,7 @@ int32 OS_ModuleAPI_Init (void); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_ModuleLoad_Impl ( uint32 module_id, const char *translated_path ); +int32 OS_ModuleLoad_Impl(uint32 module_id, const char *translated_path); /*---------------------------------------------------------------- @@ -77,7 +74,7 @@ int32 OS_ModuleLoad_Impl ( uint32 module_id, const char *translated_path ); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_ModuleUnload_Impl ( uint32 module_id ); +int32 OS_ModuleUnload_Impl(uint32 module_id); /*---------------------------------------------------------------- Function: OS_ModuleGetInfo_Impl @@ -86,7 +83,7 @@ int32 OS_ModuleUnload_Impl ( uint32 module_id ); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_ModuleGetInfo_Impl ( uint32 module_id, OS_module_prop_t *module_prop ); +int32 OS_ModuleGetInfo_Impl(uint32 module_id, OS_module_prop_t *module_prop); /*---------------------------------------------------------------- Function: OS_SymbolLookup_Impl @@ -96,7 +93,7 @@ int32 OS_ModuleGetInfo_Impl ( uint32 module_id, OS_module_prop_t *module_prop ); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_SymbolLookup_Impl ( cpuaddr *SymbolAddress, const char *SymbolName ); +int32 OS_SymbolLookup_Impl(cpuaddr *SymbolAddress, const char *SymbolName); /*---------------------------------------------------------------- Function: OS_SymbolTableDump_Impl @@ -105,8 +102,7 @@ int32 OS_SymbolLookup_Impl ( cpuaddr *SymbolAddress, const char *SymbolName ); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_SymbolTableDump_Impl ( const char *filename, uint32 size_limit ); - +int32 OS_SymbolTableDump_Impl(const char *filename, uint32 size_limit); /* * Helper functions within the shared layer that are not normally invoked outside the local module @@ -115,5 +111,4 @@ int32 OS_SymbolTableDump_Impl ( const char *filename, uint32 size_limit ); int32 OS_ModuleLoad_Static(const char *ModuleName); int32 OS_SymbolLookup_Static(cpuaddr *SymbolAddress, const char *SymbolName); -#endif /* INCLUDE_OS_SHARED_MODULE_H_ */ - +#endif /* INCLUDE_OS_SHARED_MODULE_H_ */ diff --git a/src/os/shared/inc/os-shared-mutex.h b/src/os/shared/inc/os-shared-mutex.h index cb452bbd8..3f8af42b0 100644 --- a/src/os/shared/inc/os-shared-mutex.h +++ b/src/os/shared/inc/os-shared-mutex.h @@ -30,17 +30,16 @@ #include - typedef struct { - char obj_name[OS_MAX_API_NAME]; + char obj_name[OS_MAX_API_NAME]; } OS_mutex_internal_record_t; /* * These record types have extra information with each entry. These tables are used * to share extra data between the common layer and the OS-specific implementation. */ -extern OS_mutex_internal_record_t OS_mutex_table[OS_MAX_MUTEXES]; +extern OS_mutex_internal_record_t OS_mutex_table[OS_MAX_MUTEXES]; /*--------------------------------------------------------------------------------------- Name: OS_MutexAPI_Init @@ -49,8 +48,7 @@ extern OS_mutex_internal_record_t OS_mutex_table[OS_MAX_MUTEXES]; returns: OS_SUCCESS on success, or relevant error code ---------------------------------------------------------------------------------------*/ -int32 OS_MutexAPI_Init (void); - +int32 OS_MutexAPI_Init(void); /*---------------------------------------------------------------- Function: OS_MutSemCreate_Impl @@ -59,7 +57,7 @@ int32 OS_MutexAPI_Init (void); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_MutSemCreate_Impl (uint32 sem_id, uint32 options); +int32 OS_MutSemCreate_Impl(uint32 sem_id, uint32 options); /*---------------------------------------------------------------- Function: OS_MutSemGive_Impl @@ -68,7 +66,7 @@ int32 OS_MutSemCreate_Impl (uint32 sem_id, uint32 options); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_MutSemGive_Impl (uint32 sem_id); +int32 OS_MutSemGive_Impl(uint32 sem_id); /*---------------------------------------------------------------- Function: OS_MutSemTake_Impl @@ -77,7 +75,7 @@ int32 OS_MutSemGive_Impl (uint32 sem_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_MutSemTake_Impl (uint32 sem_id); +int32 OS_MutSemTake_Impl(uint32 sem_id); /*---------------------------------------------------------------- Function: OS_MutSemDelete_Impl @@ -86,7 +84,7 @@ int32 OS_MutSemTake_Impl (uint32 sem_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_MutSemDelete_Impl (uint32 sem_id); +int32 OS_MutSemDelete_Impl(uint32 sem_id); /*---------------------------------------------------------------- Function: OS_MutSemGetInfo_Impl @@ -95,8 +93,6 @@ int32 OS_MutSemDelete_Impl (uint32 sem_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_MutSemGetInfo_Impl (uint32 sem_id, OS_mut_sem_prop_t *mut_prop); - - -#endif /* INCLUDE_OS_SHARED_MUTEX_H_ */ +int32 OS_MutSemGetInfo_Impl(uint32 sem_id, OS_mut_sem_prop_t *mut_prop); +#endif /* INCLUDE_OS_SHARED_MUTEX_H_ */ diff --git a/src/os/shared/inc/os-shared-network.h b/src/os/shared/inc/os-shared-network.h index 1ed494f52..818f8ea84 100644 --- a/src/os/shared/inc/os-shared-network.h +++ b/src/os/shared/inc/os-shared-network.h @@ -30,8 +30,6 @@ #include - - /**************************************************************************************** NETWORK / SOCKET API LOW-LEVEL IMPLEMENTATION FUNCTIONS ****************************************************************************************/ @@ -43,8 +41,7 @@ returns: OS_SUCCESS on success, or relevant error code ---------------------------------------------------------------------------------------*/ -int32 OS_NetworkAPI_Init (void); - +int32 OS_NetworkAPI_Init(void); /*---------------------------------------------------------------- @@ -54,7 +51,7 @@ int32 OS_NetworkAPI_Init (void); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_NetworkGetHostName_Impl (char *host_name, uint32 name_len); +int32 OS_NetworkGetHostName_Impl(char *host_name, uint32 name_len); /*---------------------------------------------------------------- Function: OS_NetworkGetID_Impl @@ -63,7 +60,6 @@ int32 OS_NetworkGetHostName_Impl (char *host_name, uint32 name_len); Returns: the ID value on success, or -1 on error. ------------------------------------------------------------------*/ -int32 OS_NetworkGetID_Impl (int32 *IdBuf); - -#endif /* INCLUDE_OS_SHARED_NETWORK_H_ */ +int32 OS_NetworkGetID_Impl(int32 *IdBuf); +#endif /* INCLUDE_OS_SHARED_NETWORK_H_ */ diff --git a/src/os/shared/inc/os-shared-printf.h b/src/os/shared/inc/os-shared-printf.h index 71f51b791..b4f0e3d86 100644 --- a/src/os/shared/inc/os-shared-printf.h +++ b/src/os/shared/inc/os-shared-printf.h @@ -44,18 +44,15 @@ typedef struct { char device_name[OS_MAX_API_NAME]; - char *BufBase; /**< Start of the buffer memory */ - uint32 BufSize; /**< Total size of the buffer */ - volatile uint32 ReadPos; /**< Offset of next byte to read */ - volatile uint32 WritePos; /**< Offset of next byte to write */ - uint32 OverflowEvents; /**< Number of lines dropped due to overflow */ + char * BufBase; /**< Start of the buffer memory */ + uint32 BufSize; /**< Total size of the buffer */ + volatile uint32 ReadPos; /**< Offset of next byte to read */ + volatile uint32 WritePos; /**< Offset of next byte to write */ + uint32 OverflowEvents; /**< Number of lines dropped due to overflow */ } OS_console_internal_record_t; - -extern OS_console_internal_record_t OS_console_table[OS_MAX_CONSOLES]; - - +extern OS_console_internal_record_t OS_console_table[OS_MAX_CONSOLES]; /**************************************************************************************** CONSOLE / DEBUG API LOW-LEVEL IMPLEMENTATION FUNCTIONS @@ -68,9 +65,7 @@ extern OS_console_internal_record_t OS_console_table[OS_MAX_CONSOLES]; returns: OS_SUCCESS on success, or relevant error code ---------------------------------------------------------------------------------------*/ -int32 OS_ConsoleAPI_Init (void); - - +int32 OS_ConsoleAPI_Init(void); /*---------------------------------------------------------------- Function: OS_ConsoleCreate_Impl @@ -90,7 +85,7 @@ int32 OS_ConsoleCreate_Impl(uint32 local_id); The data is already formatted, this just writes the characters. ------------------------------------------------------------------*/ -void OS_ConsoleOutput_Impl(uint32 local_id); +void OS_ConsoleOutput_Impl(uint32 local_id); /*---------------------------------------------------------------- Function: OS_ConsoleOutput_Impl @@ -105,8 +100,6 @@ void OS_ConsoleOutput_Impl(uint32 local_id); service, this should wakeup the actual console servicing thread. ------------------------------------------------------------------*/ -void OS_ConsoleWakeup_Impl(uint32 local_id); - - -#endif /* INCLUDE_OS_SHARED_PRINTF_H_ */ +void OS_ConsoleWakeup_Impl(uint32 local_id); +#endif /* INCLUDE_OS_SHARED_PRINTF_H_ */ diff --git a/src/os/shared/inc/os-shared-queue.h b/src/os/shared/inc/os-shared-queue.h index 0290ab936..b60e4a279 100644 --- a/src/os/shared/inc/os-shared-queue.h +++ b/src/os/shared/inc/os-shared-queue.h @@ -30,22 +30,18 @@ #include - typedef struct { - char queue_name[OS_MAX_API_NAME]; - uint32 max_size; - uint32 max_depth; + char queue_name[OS_MAX_API_NAME]; + uint32 max_size; + uint32 max_depth; } OS_queue_internal_record_t; - /* * These record types have extra information with each entry. These tables are used * to share extra data between the common layer and the OS-specific implementation. */ -extern OS_queue_internal_record_t OS_queue_table[OS_MAX_QUEUES]; - - +extern OS_queue_internal_record_t OS_queue_table[OS_MAX_QUEUES]; /**************************************************************************************** MESSAGE QUEUE API LOW-LEVEL IMPLEMENTATION FUNCTIONS @@ -58,8 +54,7 @@ extern OS_queue_internal_record_t OS_queue_table[OS_MAX_QUEUES]; returns: OS_SUCCESS on success, or relevant error code ---------------------------------------------------------------------------------------*/ -int32 OS_QueueAPI_Init (void); - +int32 OS_QueueAPI_Init(void); /*---------------------------------------------------------------- Function: OS_QueueCreate_Impl @@ -68,7 +63,7 @@ int32 OS_QueueAPI_Init (void); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_QueueCreate_Impl (uint32 queue_id, uint32 flags); +int32 OS_QueueCreate_Impl(uint32 queue_id, uint32 flags); /*---------------------------------------------------------------- Function: OS_QueueDelete_Impl @@ -77,7 +72,7 @@ int32 OS_QueueCreate_Impl (uint32 queue_id, uint32 flags); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_QueueDelete_Impl (uint32 queue_id); +int32 OS_QueueDelete_Impl(uint32 queue_id); /*---------------------------------------------------------------- Function: OS_QueueGet_Impl @@ -90,7 +85,7 @@ int32 OS_QueueDelete_Impl (uint32 queue_id); OS_QUEUE_EMPTY must be returned if the queue is empty when polled (OS_CHECK) OS_QUEUE_INVALID_SIZE must be returned if the supplied buffer is too small ------------------------------------------------------------------*/ -int32 OS_QueueGet_Impl (uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout); +int32 OS_QueueGet_Impl(uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout); /*---------------------------------------------------------------- Function: OS_QueuePut_Impl @@ -100,7 +95,7 @@ int32 OS_QueueGet_Impl (uint32 queue_id, void *data, uint32 size, u Returns: OS_SUCCESS on success, or relevant error code OS_QUEUE_FULL must be returned if the queue is full. ------------------------------------------------------------------*/ -int32 OS_QueuePut_Impl (uint32 queue_id, const void *data, uint32 size, uint32 flags); +int32 OS_QueuePut_Impl(uint32 queue_id, const void *data, uint32 size, uint32 flags); /*---------------------------------------------------------------- Function: OS_QueueGetInfo_Impl @@ -109,8 +104,6 @@ int32 OS_QueuePut_Impl (uint32 queue_id, const void *data, uint32 s Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_QueueGetInfo_Impl (uint32 queue_id, OS_queue_prop_t *queue_prop); - - -#endif /* INCLUDE_OS_SHARED_QUEUE_H_ */ +int32 OS_QueueGetInfo_Impl(uint32 queue_id, OS_queue_prop_t *queue_prop); +#endif /* INCLUDE_OS_SHARED_QUEUE_H_ */ diff --git a/src/os/shared/inc/os-shared-select.h b/src/os/shared/inc/os-shared-select.h index 85f62e29c..b2bc847a5 100644 --- a/src/os/shared/inc/os-shared-select.h +++ b/src/os/shared/inc/os-shared-select.h @@ -30,7 +30,6 @@ #include - /* * Select API * Blocks until specified readable/writable conditions @@ -78,6 +77,4 @@ int32 OS_SelectSingle_Impl(uint32 stream_id, uint32 *SelectFlags, int32 msecs); ------------------------------------------------------------------*/ int32 OS_SelectMultiple_Impl(OS_FdSet *ReadSet, OS_FdSet *WriteSet, int32 msecs); - -#endif /* INCLUDE_OS_SHARED_SELECT_H_ */ - +#endif /* INCLUDE_OS_SHARED_SELECT_H_ */ diff --git a/src/os/shared/inc/os-shared-shell.h b/src/os/shared/inc/os-shared-shell.h index 2d9d7a700..582f1e3fa 100644 --- a/src/os/shared/inc/os-shared-shell.h +++ b/src/os/shared/inc/os-shared-shell.h @@ -30,14 +30,10 @@ #include - - - /**************************************************************************************** SHELL API LOW-LEVEL IMPLEMENTATION FUNCTIONS ****************************************************************************************/ - /*---------------------------------------------------------------- Function: OS_ShellOutputToFile_Impl @@ -45,7 +41,6 @@ Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_ShellOutputToFile_Impl(uint32 stream_id, const char* Cmd); - -#endif /* INCLUDE_OS_SHARED_SHELL_H_ */ +int32 OS_ShellOutputToFile_Impl(uint32 stream_id, const char *Cmd); +#endif /* INCLUDE_OS_SHARED_SHELL_H_ */ diff --git a/src/os/shared/inc/os-shared-sockets.h b/src/os/shared/inc/os-shared-sockets.h index 80c952a57..a50e0a45c 100644 --- a/src/os/shared/inc/os-shared-sockets.h +++ b/src/os/shared/inc/os-shared-sockets.h @@ -41,7 +41,7 @@ returns: OS_SUCCESS on success, or relevant error code ---------------------------------------------------------------------------------------*/ -int32 OS_SocketAPI_Init (void); +int32 OS_SocketAPI_Init(void); /*---------------------------------------------------------------- Function: OS_SocketOpen_Impl @@ -114,7 +114,7 @@ int32 OS_SocketSendTo_Impl(uint32 sock_id, const void *buffer, uint32 buflen, co Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_SocketGetInfo_Impl (uint32 sock_id, OS_socket_prop_t *sock_prop); +int32 OS_SocketGetInfo_Impl(uint32 sock_id, OS_socket_prop_t *sock_prop); /*---------------------------------------------------------------- @@ -176,5 +176,4 @@ int32 OS_SocketAddrSetPort_Impl(OS_SockAddr_t *Addr, uint16 PortNum); */ void OS_CreateSocketName(uint32 local_id, const OS_SockAddr_t *Addr, const char *parent_name); -#endif /* INCLUDE_OS_SHARED_SOCKETS_H_ */ - +#endif /* INCLUDE_OS_SHARED_SOCKETS_H_ */ diff --git a/src/os/shared/inc/os-shared-task.h b/src/os/shared/inc/os-shared-task.h index 7f4dc79e2..4adb87fe2 100644 --- a/src/os/shared/inc/os-shared-task.h +++ b/src/os/shared/inc/os-shared-task.h @@ -33,22 +33,20 @@ /*tasks */ typedef struct { - char task_name[OS_MAX_API_NAME]; - uint32 stack_size; - uint32 priority; - osal_task_entry entry_function_pointer; - osal_task_entry delete_hook_pointer; - void *entry_arg; - uint32 *stack_pointer; -}OS_task_internal_record_t; + char task_name[OS_MAX_API_NAME]; + uint32 stack_size; + uint32 priority; + osal_task_entry entry_function_pointer; + osal_task_entry delete_hook_pointer; + void * entry_arg; + uint32 * stack_pointer; +} OS_task_internal_record_t; /* * These record types have extra information with each entry. These tables are used * to share extra data between the common layer and the OS-specific implementation. */ -extern OS_task_internal_record_t OS_task_table[OS_MAX_TASKS]; - - +extern OS_task_internal_record_t OS_task_table[OS_MAX_TASKS]; /**************************************************************************************** TASK API LOW-LEVEL IMPLEMENTATION FUNCTIONS @@ -61,8 +59,7 @@ extern OS_task_internal_record_t OS_task_table[OS_MAX_TASKS]; returns: OS_SUCCESS on success, or relevant error code ---------------------------------------------------------------------------------------*/ -int32 OS_TaskAPI_Init (void); - +int32 OS_TaskAPI_Init(void); /*---------------------------------------------------------------- Function: OS_TaskEntryPoint @@ -75,7 +72,7 @@ int32 OS_TaskAPI_Init (void); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -void OS_TaskEntryPoint (osal_id_t global_task_id); +void OS_TaskEntryPoint(osal_id_t global_task_id); /*---------------------------------------------------------------- Function: OS_TaskMatch_Impl @@ -84,7 +81,7 @@ void OS_TaskEntryPoint (osal_id_t global_task_id); Returns: OS_SUCCESS on match, any other code on non-match ------------------------------------------------------------------*/ -int32 OS_TaskMatch_Impl (uint32 task_id); +int32 OS_TaskMatch_Impl(uint32 task_id); /*---------------------------------------------------------------- @@ -95,7 +92,7 @@ int32 OS_TaskMatch_Impl (uint32 task_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_TaskCreate_Impl (uint32 task_id, uint32 flags); +int32 OS_TaskCreate_Impl(uint32 task_id, uint32 flags); /*---------------------------------------------------------------- Function: OS_TaskDelete_Impl @@ -104,7 +101,7 @@ int32 OS_TaskCreate_Impl (uint32 task_id, uint32 flags); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_TaskDelete_Impl (uint32 task_id); +int32 OS_TaskDelete_Impl(uint32 task_id); /*---------------------------------------------------------------- Function: OS_TaskExit_Impl @@ -113,7 +110,7 @@ int32 OS_TaskDelete_Impl (uint32 task_id); This function does not return ------------------------------------------------------------------*/ -void OS_TaskExit_Impl (void); +void OS_TaskExit_Impl(void); /*---------------------------------------------------------------- Function: OS_TaskDelay_Impl @@ -122,7 +119,7 @@ void OS_TaskExit_Impl (void); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_TaskDelay_Impl (uint32 millisecond); +int32 OS_TaskDelay_Impl(uint32 millisecond); /*---------------------------------------------------------------- Function: OS_TaskSetPriority_Impl @@ -131,7 +128,7 @@ int32 OS_TaskDelay_Impl (uint32 millisecond); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_TaskSetPriority_Impl (uint32 task_id, uint32 new_priority); +int32 OS_TaskSetPriority_Impl(uint32 task_id, uint32 new_priority); /*---------------------------------------------------------------- Function: OS_TaskGetId_Impl @@ -140,7 +137,7 @@ int32 OS_TaskSetPriority_Impl (uint32 task_id, uint32 new_priority); Returns: The OSAL ID of the calling task, or zero if not registered ------------------------------------------------------------------*/ -osal_id_t OS_TaskGetId_Impl (void); +osal_id_t OS_TaskGetId_Impl(void); /*---------------------------------------------------------------- Function: OS_TaskGetInfo_Impl @@ -149,7 +146,7 @@ osal_id_t OS_TaskGetId_Impl (void); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_TaskGetInfo_Impl (uint32 task_id, OS_task_prop_t *task_prop); +int32 OS_TaskGetInfo_Impl(uint32 task_id, OS_task_prop_t *task_prop); /*---------------------------------------------------------------- @@ -162,8 +159,7 @@ int32 OS_TaskGetInfo_Impl (uint32 task_id, OS_task_prop_t *task_prop) Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_TaskRegister_Impl (osal_id_t global_task_id); - +int32 OS_TaskRegister_Impl(osal_id_t global_task_id); /*---------------------------------------------------------------- @@ -185,6 +181,4 @@ bool OS_TaskIdMatchSystemData_Impl(void *ref, uint32 local_id, const OS_common_r ------------------------------------------------------------------*/ int32 OS_TaskValidateSystemData_Impl(const void *sysdata, uint32 sysdata_size); - -#endif /* INCLUDE_OS_SHARED_TASK_H_ */ - +#endif /* INCLUDE_OS_SHARED_TASK_H_ */ diff --git a/src/os/shared/inc/os-shared-time.h b/src/os/shared/inc/os-shared-time.h index 3827dcf5a..f8397cd54 100644 --- a/src/os/shared/inc/os-shared-time.h +++ b/src/os/shared/inc/os-shared-time.h @@ -30,29 +30,27 @@ #include - -#define TIMECB_FLAG_DEDICATED_TIMEBASE 0x1 +#define TIMECB_FLAG_DEDICATED_TIMEBASE 0x1 typedef struct { - char timer_name[OS_MAX_API_NAME]; - uint32 flags; - uint32 timebase_ref; - uint32 prev_ref; - uint32 next_ref; - uint32 backlog_resets; - int32 wait_time; - int32 interval_time; - OS_ArgCallback_t callback_ptr; - void *callback_arg; + char timer_name[OS_MAX_API_NAME]; + uint32 flags; + uint32 timebase_ref; + uint32 prev_ref; + uint32 next_ref; + uint32 backlog_resets; + int32 wait_time; + int32 interval_time; + OS_ArgCallback_t callback_ptr; + void * callback_arg; } OS_timecb_internal_record_t; - /* * These record types have extra information with each entry. These tables are used * to share extra data between the common layer and the OS-specific implementation. */ -extern OS_timecb_internal_record_t OS_timecb_table[OS_MAX_TIMERS]; +extern OS_timecb_internal_record_t OS_timecb_table[OS_MAX_TIMERS]; /*--------------------------------------------------------------------------------------- Name: OS_TimerCbAPI_Init @@ -61,8 +59,6 @@ extern OS_timecb_internal_record_t OS_timecb_table[OS_MAX_TIMERS]; returns: OS_SUCCESS on success, or relevant error code ---------------------------------------------------------------------------------------*/ -int32 OS_TimerCbAPI_Init (void); - - -#endif /* INCLUDE_OS_SHARED_TIME_H_ */ +int32 OS_TimerCbAPI_Init(void); +#endif /* INCLUDE_OS_SHARED_TIME_H_ */ diff --git a/src/os/shared/inc/os-shared-timebase.h b/src/os/shared/inc/os-shared-timebase.h index dd43e36f2..cf88e82a2 100644 --- a/src/os/shared/inc/os-shared-timebase.h +++ b/src/os/shared/inc/os-shared-timebase.h @@ -30,23 +30,22 @@ #include - typedef struct { - char timebase_name[OS_MAX_API_NAME]; - OS_TimerSync_t external_sync; - uint32 accuracy_usec; - osal_id_t first_cb; - uint32 freerun_time; - uint32 nominal_start_time; - uint32 nominal_interval_time; + char timebase_name[OS_MAX_API_NAME]; + OS_TimerSync_t external_sync; + uint32 accuracy_usec; + osal_id_t first_cb; + uint32 freerun_time; + uint32 nominal_start_time; + uint32 nominal_interval_time; } OS_timebase_internal_record_t; /* * These record types have extra information with each entry. These tables are used * to share extra data between the common layer and the OS-specific implementation. */ -extern OS_timebase_internal_record_t OS_timebase_table[OS_MAX_TIMEBASES]; +extern OS_timebase_internal_record_t OS_timebase_table[OS_MAX_TIMEBASES]; /**************************************************************************************** CLOCK / TIME API LOW-LEVEL IMPLEMENTATION FUNCTIONS @@ -59,8 +58,7 @@ extern OS_timebase_internal_record_t OS_timebase_table[OS_MAX_TIMEBASES]; returns: OS_SUCCESS on success, or relevant error code ---------------------------------------------------------------------------------------*/ -int32 OS_TimeBaseAPI_Init (void); - +int32 OS_TimeBaseAPI_Init(void); /* * TimeBase routines implement a low-level timer tick/interrupt; @@ -75,7 +73,7 @@ int32 OS_TimeBaseAPI_Init (void); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_TimeBaseCreate_Impl (uint32 timebase_id); +int32 OS_TimeBaseCreate_Impl(uint32 timebase_id); /*---------------------------------------------------------------- Function: OS_TimeBaseSet_Impl @@ -84,7 +82,7 @@ int32 OS_TimeBaseCreate_Impl (uint32 timebase_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_TimeBaseSet_Impl (uint32 timebase_id, int32 start_time, int32 interval_time); +int32 OS_TimeBaseSet_Impl(uint32 timebase_id, int32 start_time, int32 interval_time); /*---------------------------------------------------------------- Function: OS_TimeBaseDelete_Impl @@ -93,21 +91,19 @@ int32 OS_TimeBaseSet_Impl (uint32 timebase_id, int32 start_time, int32 Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_TimeBaseDelete_Impl (uint32 timebase_id); - +int32 OS_TimeBaseDelete_Impl(uint32 timebase_id); /**************************************************************************************** INTERNAL FUNCTIONS ****************************************************************************************/ - /*---------------------------------------------------------------- Function: OS_TimeBaseLock_Impl Purpose: Get exclusive access to the given timebase Add/remove of application callbacks is prevented ------------------------------------------------------------------*/ -void OS_TimeBaseLock_Impl (uint32 timebase_id); +void OS_TimeBaseLock_Impl(uint32 timebase_id); /*---------------------------------------------------------------- Function: OS_TimeBaseLock_Impl @@ -115,7 +111,7 @@ void OS_TimeBaseLock_Impl (uint32 timebase_id); Purpose: Release exclusive access to the given timebase Add/remove of application callbacks is allowed ------------------------------------------------------------------*/ -void OS_TimeBaseUnlock_Impl (uint32 timebase_id); +void OS_TimeBaseUnlock_Impl(uint32 timebase_id); /*---------------------------------------------------------------- Function: OS_TimeBaseGetInfo_Impl @@ -124,7 +120,7 @@ void OS_TimeBaseUnlock_Impl (uint32 timebase_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_TimeBaseGetInfo_Impl (uint32 timer_id, OS_timebase_prop_t *timer_prop); +int32 OS_TimeBaseGetInfo_Impl(uint32 timer_id, OS_timebase_prop_t *timer_prop); /*---------------------------------------------------------------- Function: OS_TimeBase_CallbackThread @@ -132,7 +128,7 @@ int32 OS_TimeBaseGetInfo_Impl (uint32 timer_id, OS_timebase_prop_t *timer_ Purpose: Implement the time base helper thread This is the context for providing application callbacks ------------------------------------------------------------------*/ -void OS_TimeBase_CallbackThread (osal_id_t timebase_id); +void OS_TimeBase_CallbackThread(osal_id_t timebase_id); /*---------------------------------------------------------------- Function: OS_Milli2Ticks @@ -141,5 +137,4 @@ void OS_TimeBase_CallbackThread (osal_id_t timebase_id); ------------------------------------------------------------------*/ int32 OS_Milli2Ticks(uint32 milli_seconds, int *ticks); -#endif /* INCLUDE_OS_SHARED_TIMEBASE_H_ */ - +#endif /* INCLUDE_OS_SHARED_TIMEBASE_H_ */ diff --git a/src/os/shared/src/osapi-binsem.c b/src/os/shared/src/osapi-binsem.c index ce1a2f5d5..3cb6dbfc6 100644 --- a/src/os/shared/src/osapi-binsem.c +++ b/src/os/shared/src/osapi-binsem.c @@ -35,7 +35,6 @@ #include #include - /* * User defined include files */ @@ -50,18 +49,16 @@ #error "osconfig.h must define OS_MAX_BIN_SEMAPHORES to a valid value" #endif - /* * Global data for the API */ enum { - LOCAL_NUM_OBJECTS = OS_MAX_BIN_SEMAPHORES, - LOCAL_OBJID_TYPE = OS_OBJECT_TYPE_OS_BINSEM + LOCAL_NUM_OBJECTS = OS_MAX_BIN_SEMAPHORES, + LOCAL_OBJID_TYPE = OS_OBJECT_TYPE_OS_BINSEM }; -OS_bin_sem_internal_record_t OS_bin_sem_table [LOCAL_NUM_OBJECTS]; - +OS_bin_sem_internal_record_t OS_bin_sem_table[LOCAL_NUM_OBJECTS]; /**************************************************************************************** SEMAPHORE API @@ -85,12 +82,10 @@ OS_bin_sem_internal_record_t OS_bin_sem_table [LOCAL_NUM_OBJECTS]; *-----------------------------------------------------------------*/ int32 OS_BinSemAPI_Init(void) { - memset(OS_bin_sem_table, 0, sizeof(OS_bin_sem_table)); - return OS_SUCCESS; + memset(OS_bin_sem_table, 0, sizeof(OS_bin_sem_table)); + return OS_SUCCESS; } /* end OS_BinSemAPI_Init */ - - /*---------------------------------------------------------------- * * Function: OS_BinSemCreate @@ -99,45 +94,42 @@ int32 OS_BinSemAPI_Init(void) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemCreate (osal_id_t *sem_id, const char *sem_name, uint32 sem_initial_value, - uint32 options) +int32 OS_BinSemCreate(osal_id_t *sem_id, const char *sem_name, uint32 sem_initial_value, uint32 options) { - OS_common_record_t *record; - int32 return_code; - uint32 local_id; - - /* Check for NULL pointers */ - if (sem_id == NULL || sem_name == NULL) - { - return OS_INVALID_POINTER; - } + OS_common_record_t *record; + int32 return_code; + uint32 local_id; - if ( strlen (sem_name) >= OS_MAX_API_NAME ) - { - return OS_ERR_NAME_TOO_LONG; - } + /* Check for NULL pointers */ + if (sem_id == NULL || sem_name == NULL) + { + return OS_INVALID_POINTER; + } + if (strlen(sem_name) >= OS_MAX_API_NAME) + { + return OS_ERR_NAME_TOO_LONG; + } - /* Note - the common ObjectIdAllocate routine will lock the object type and leave it locked. */ - return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, sem_name, &local_id, &record); - if(return_code == OS_SUCCESS) - { - /* Save all the data to our own internal table */ - strcpy(OS_bin_sem_table[local_id].obj_name, sem_name); - record->name_entry = OS_bin_sem_table[local_id].obj_name; + /* Note - the common ObjectIdAllocate routine will lock the object type and leave it locked. */ + return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, sem_name, &local_id, &record); + if (return_code == OS_SUCCESS) + { + /* Save all the data to our own internal table */ + strcpy(OS_bin_sem_table[local_id].obj_name, sem_name); + record->name_entry = OS_bin_sem_table[local_id].obj_name; - /* Now call the OS-specific implementation. This reads info from the table. */ - return_code = OS_BinSemCreate_Impl(local_id, sem_initial_value, options); + /* Now call the OS-specific implementation. This reads info from the table. */ + return_code = OS_BinSemCreate_Impl(local_id, sem_initial_value, options); - /* Check result, finalize record, and unlock global table. */ - return_code = OS_ObjectIdFinalizeNew(return_code, record, sem_id); - } + /* Check result, finalize record, and unlock global table. */ + return_code = OS_ObjectIdFinalizeNew(return_code, record, sem_id); + } - return return_code; + return return_code; } /* end OS_BinSemCreate */ - /*---------------------------------------------------------------- * * Function: OS_BinSemDelete @@ -146,27 +138,25 @@ int32 OS_BinSemCreate (osal_id_t *sem_id, const char *sem_name, uint32 sem_initi * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemDelete (osal_id_t sem_id) +int32 OS_BinSemDelete(osal_id_t sem_id) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; + OS_common_record_t *record; + uint32 local_id; + int32 return_code; - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - return_code = OS_BinSemDelete_Impl(local_id); + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + return_code = OS_BinSemDelete_Impl(local_id); - /* Complete the operation via the common routine */ - return_code = OS_ObjectIdFinalizeDelete(return_code, record); - } + /* Complete the operation via the common routine */ + return_code = OS_ObjectIdFinalizeDelete(return_code, record); + } - return return_code; + return return_code; } /* end OS_BinSemDelete */ - - /*---------------------------------------------------------------- * * Function: OS_BinSemGive @@ -175,24 +165,23 @@ int32 OS_BinSemDelete (osal_id_t sem_id) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemGive ( osal_id_t sem_id ) +int32 OS_BinSemGive(osal_id_t sem_id) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; + OS_common_record_t *record; + uint32 local_id; + int32 return_code; /* Check Parameters */ return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); if (return_code == OS_SUCCESS) { - return_code = OS_BinSemGive_Impl (local_id); + return_code = OS_BinSemGive_Impl(local_id); } return return_code; } /* end OS_BinSemGive */ - /*---------------------------------------------------------------- * * Function: OS_BinSemFlush @@ -201,22 +190,21 @@ int32 OS_BinSemGive ( osal_id_t sem_id ) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemFlush (osal_id_t sem_id) +int32 OS_BinSemFlush(osal_id_t sem_id) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; - - /* Check Parameters */ - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - return_code = OS_BinSemFlush_Impl (local_id); - } - - return return_code; -} /* end OS_BinSemFlush */ + OS_common_record_t *record; + uint32 local_id; + int32 return_code; + + /* Check Parameters */ + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + return_code = OS_BinSemFlush_Impl(local_id); + } + return return_code; +} /* end OS_BinSemFlush */ /*---------------------------------------------------------------- * @@ -226,22 +214,21 @@ int32 OS_BinSemFlush (osal_id_t sem_id) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemTake ( osal_id_t sem_id ) +int32 OS_BinSemTake(osal_id_t sem_id) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; - - /* Check Parameters */ - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - return_code = OS_BinSemTake_Impl (local_id); - } - - return return_code; -} /* end OS_BinSemTake */ + OS_common_record_t *record; + uint32 local_id; + int32 return_code; + /* Check Parameters */ + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + return_code = OS_BinSemTake_Impl(local_id); + } + + return return_code; +} /* end OS_BinSemTake */ /*---------------------------------------------------------------- * @@ -251,20 +238,20 @@ int32 OS_BinSemTake ( osal_id_t sem_id ) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemTimedWait ( osal_id_t sem_id, uint32 msecs ) +int32 OS_BinSemTimedWait(osal_id_t sem_id, uint32 msecs) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; - - /* Check Parameters */ - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - return_code = OS_BinSemTimedWait_Impl (local_id, msecs); - } - - return return_code; + OS_common_record_t *record; + uint32 local_id; + int32 return_code; + + /* Check Parameters */ + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + return_code = OS_BinSemTimedWait_Impl(local_id, msecs); + } + + return return_code; } /* end OS_BinSemTimedWait */ /*---------------------------------------------------------------- @@ -275,21 +262,20 @@ int32 OS_BinSemTimedWait ( osal_id_t sem_id, uint32 msecs ) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemGetIdByName (osal_id_t *sem_id, const char *sem_name) +int32 OS_BinSemGetIdByName(osal_id_t *sem_id, const char *sem_name) { - int32 return_code; + int32 return_code; - if (sem_id == NULL || sem_name == NULL) - { - return OS_INVALID_POINTER; - } + if (sem_id == NULL || sem_name == NULL) + { + return OS_INVALID_POINTER; + } - return_code = OS_ObjectIdFindByName(LOCAL_OBJID_TYPE, sem_name, sem_id); + return_code = OS_ObjectIdFindByName(LOCAL_OBJID_TYPE, sem_name, sem_id); - return return_code; + return return_code; } /* end OS_BinSemGetIdByName */ - /*---------------------------------------------------------------- * * Function: OS_BinSemGetInfo @@ -298,30 +284,29 @@ int32 OS_BinSemGetIdByName (osal_id_t *sem_id, const char *sem_name) * 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_BinSemGetInfo(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; - - /* Check parameters */ - if (bin_prop == NULL) - { - return OS_INVALID_POINTER; - } - - memset(bin_prop, 0, sizeof(OS_bin_sem_prop_t)); - - /* Check Parameters */ - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - strncpy(bin_prop->name, record->name_entry, OS_MAX_API_NAME - 1); - bin_prop->creator = record->creator; - return_code = OS_BinSemGetInfo_Impl (local_id, bin_prop); - OS_Unlock_Global(LOCAL_OBJID_TYPE); - } - - return return_code; -} /* end OS_BinSemGetInfo */ + OS_common_record_t *record; + uint32 local_id; + int32 return_code; + + /* Check parameters */ + if (bin_prop == NULL) + { + return OS_INVALID_POINTER; + } + memset(bin_prop, 0, sizeof(OS_bin_sem_prop_t)); + + /* Check Parameters */ + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + strncpy(bin_prop->name, record->name_entry, OS_MAX_API_NAME - 1); + bin_prop->creator = record->creator; + return_code = OS_BinSemGetInfo_Impl(local_id, bin_prop); + OS_Unlock_Global(LOCAL_OBJID_TYPE); + } + + return return_code; +} /* end OS_BinSemGetInfo */ diff --git a/src/os/shared/src/osapi-clock.c b/src/os/shared/src/osapi-clock.c index 6a924d480..7cd2c8c17 100644 --- a/src/os/shared/src/osapi-clock.c +++ b/src/os/shared/src/osapi-clock.c @@ -35,13 +35,11 @@ #include #include - /* * User defined include files */ #include "os-shared-clock.h" - /*---------------------------------------------------------------- * * Function: OS_GetLocalTime @@ -54,14 +52,13 @@ int32 OS_GetLocalTime(OS_time_t *time_struct) { if (time_struct == NULL) { - return OS_INVALID_POINTER; + return OS_INVALID_POINTER; } return OS_GetLocalTime_Impl(time_struct); } /* end OS_GetLocalTime */ - /*---------------------------------------------------------------- * * Function: OS_SetLocalTime @@ -74,7 +71,7 @@ int32 OS_SetLocalTime(OS_time_t *time_struct) { if (time_struct == NULL) { - return OS_INVALID_POINTER; + return OS_INVALID_POINTER; } return OS_SetLocalTime_Impl(time_struct); diff --git a/src/os/shared/src/osapi-common.c b/src/os/shared/src/osapi-common.c index af3569a2f..c6f317625 100644 --- a/src/os/shared/src/osapi-common.c +++ b/src/os/shared/src/osapi-common.c @@ -37,7 +37,6 @@ #include #include - /* * User defined include files */ @@ -58,19 +57,17 @@ #include "os-shared-timebase.h" #include "os-shared-time.h" -OS_SharedGlobalVars_t OS_SharedGlobalVars = - { - .Initialized = false, - .PrintfEnabled = false, - .ShutdownFlag = 0, - .MicroSecPerTick = 0, /* invalid, _must_ be set by implementation init */ - .TicksPerSecond = 0, /* invalid, _must_ be set by implementation init */ - .EventHandler = NULL, +OS_SharedGlobalVars_t OS_SharedGlobalVars = { + .Initialized = false, + .PrintfEnabled = false, + .ShutdownFlag = 0, + .MicroSecPerTick = 0, /* invalid, _must_ be set by implementation init */ + .TicksPerSecond = 0, /* invalid, _must_ be set by implementation init */ + .EventHandler = NULL, #if defined(OSAL_CONFIG_DEBUG_PRINTF) - .DebugLevel = 1, + .DebugLevel = 1, #endif - }; - +}; /*---------------------------------------------------------------- * @@ -101,8 +98,6 @@ int32 OS_NotifyEvent(OS_Event_t event, osal_id_t object_id, void *data) ********************************************************************************* */ - - /*---------------------------------------------------------------- * * Function: OS_API_Init @@ -113,115 +108,115 @@ int32 OS_NotifyEvent(OS_Event_t event, osal_id_t object_id, void *data) *-----------------------------------------------------------------*/ int32 OS_API_Init(void) { - int32 return_code = OS_SUCCESS; - uint32 idtype; - uint32 microSecPerSec; - - if (OS_SharedGlobalVars.Initialized != false) - { - OS_DEBUG("WARNING: BUG - initialization function called multiple times\n"); - return OS_ERROR; - } - - OS_SharedGlobalVars.Initialized = true; - - /* Initialize the common table that everything shares */ - return_code = OS_ObjectIdInit(); - if (return_code != OS_SUCCESS) - { - return return_code; - } - - for (idtype = 0; idtype < OS_OBJECT_TYPE_USER; ++idtype) - { - /* Initialize the implementation first, as the shared layer depends on it */ - return_code = OS_API_Impl_Init(idtype); - if (return_code != OS_SUCCESS) - { - OS_DEBUG("OS_API_Impl_Init(0x%x) failed to initialize: %d\n",(unsigned int)idtype,(int)return_code); - break; - } - - switch(idtype) - { - case OS_OBJECT_TYPE_OS_TASK: - return_code = OS_TaskAPI_Init(); - break; - case OS_OBJECT_TYPE_OS_QUEUE: - return_code = OS_QueueAPI_Init(); - break; - case OS_OBJECT_TYPE_OS_BINSEM: - return_code = OS_BinSemAPI_Init(); - break; - case OS_OBJECT_TYPE_OS_COUNTSEM: - return_code = OS_CountSemAPI_Init(); - break; - case OS_OBJECT_TYPE_OS_MUTEX: - return_code = OS_MutexAPI_Init(); - break; - case OS_OBJECT_TYPE_OS_MODULE: - return_code = OS_ModuleAPI_Init(); - break; - case OS_OBJECT_TYPE_OS_TIMEBASE: - return_code = OS_TimeBaseAPI_Init(); - break; - case OS_OBJECT_TYPE_OS_TIMECB: - return_code = OS_TimerCbAPI_Init(); - break; - case OS_OBJECT_TYPE_OS_STREAM: - return_code = OS_FileAPI_Init(); - break; - case OS_OBJECT_TYPE_OS_DIR: - return_code = OS_DirAPI_Init(); - break; - case OS_OBJECT_TYPE_OS_FILESYS: - return_code = OS_FileSysAPI_Init(); - break; - case OS_OBJECT_TYPE_OS_CONSOLE: - return_code = OS_ConsoleAPI_Init(); - break; - default: - break; - } - if (return_code != OS_SUCCESS) - { - OS_DEBUG("ID type 0x%x shared layer failed to initialize: %d\n",(unsigned int)idtype,(int)return_code); - break; - } - - } - - if (return_code == OS_SUCCESS) - { - return_code = OS_NetworkAPI_Init(); - } - - if (return_code == OS_SUCCESS) - { - return_code = OS_SocketAPI_Init(); - } - - /* - * Confirm that somewhere during initialization, - * the time variables got set to something valid - */ - if (return_code == OS_SUCCESS && - (OS_SharedGlobalVars.MicroSecPerTick == 0 || - OS_SharedGlobalVars.TicksPerSecond == 0)) - { - OS_DEBUG("Implementation failed to initialize tick time globals\n"); - return_code = OS_ERROR; - } - - microSecPerSec = OS_SharedGlobalVars.MicroSecPerTick * OS_SharedGlobalVars.TicksPerSecond; - - if ( microSecPerSec != 1000000 ) - { - OS_DEBUG("Warning: Microsecs per sec value of %lu does not equal 1000000 (MicroSecPerTick: %ld TicksPerSecond: %ld)\n", - (unsigned long) microSecPerSec, (long) OS_SharedGlobalVars.MicroSecPerTick, (long) OS_SharedGlobalVars.TicksPerSecond); - } - - return(return_code); + int32 return_code = OS_SUCCESS; + uint32 idtype; + uint32 microSecPerSec; + + if (OS_SharedGlobalVars.Initialized != false) + { + OS_DEBUG("WARNING: BUG - initialization function called multiple times\n"); + return OS_ERROR; + } + + OS_SharedGlobalVars.Initialized = true; + + /* Initialize the common table that everything shares */ + return_code = OS_ObjectIdInit(); + if (return_code != OS_SUCCESS) + { + return return_code; + } + + for (idtype = 0; idtype < OS_OBJECT_TYPE_USER; ++idtype) + { + /* Initialize the implementation first, as the shared layer depends on it */ + return_code = OS_API_Impl_Init(idtype); + if (return_code != OS_SUCCESS) + { + OS_DEBUG("OS_API_Impl_Init(0x%x) failed to initialize: %d\n", (unsigned int)idtype, (int)return_code); + break; + } + + switch (idtype) + { + case OS_OBJECT_TYPE_OS_TASK: + return_code = OS_TaskAPI_Init(); + break; + case OS_OBJECT_TYPE_OS_QUEUE: + return_code = OS_QueueAPI_Init(); + break; + case OS_OBJECT_TYPE_OS_BINSEM: + return_code = OS_BinSemAPI_Init(); + break; + case OS_OBJECT_TYPE_OS_COUNTSEM: + return_code = OS_CountSemAPI_Init(); + break; + case OS_OBJECT_TYPE_OS_MUTEX: + return_code = OS_MutexAPI_Init(); + break; + case OS_OBJECT_TYPE_OS_MODULE: + return_code = OS_ModuleAPI_Init(); + break; + case OS_OBJECT_TYPE_OS_TIMEBASE: + return_code = OS_TimeBaseAPI_Init(); + break; + case OS_OBJECT_TYPE_OS_TIMECB: + return_code = OS_TimerCbAPI_Init(); + break; + case OS_OBJECT_TYPE_OS_STREAM: + return_code = OS_FileAPI_Init(); + break; + case OS_OBJECT_TYPE_OS_DIR: + return_code = OS_DirAPI_Init(); + break; + case OS_OBJECT_TYPE_OS_FILESYS: + return_code = OS_FileSysAPI_Init(); + break; + case OS_OBJECT_TYPE_OS_CONSOLE: + return_code = OS_ConsoleAPI_Init(); + break; + default: + break; + } + if (return_code != OS_SUCCESS) + { + OS_DEBUG("ID type 0x%x shared layer failed to initialize: %d\n", (unsigned int)idtype, (int)return_code); + break; + } + } + + if (return_code == OS_SUCCESS) + { + return_code = OS_NetworkAPI_Init(); + } + + if (return_code == OS_SUCCESS) + { + return_code = OS_SocketAPI_Init(); + } + + /* + * Confirm that somewhere during initialization, + * the time variables got set to something valid + */ + if (return_code == OS_SUCCESS && + (OS_SharedGlobalVars.MicroSecPerTick == 0 || OS_SharedGlobalVars.TicksPerSecond == 0)) + { + OS_DEBUG("Implementation failed to initialize tick time globals\n"); + return_code = OS_ERROR; + } + + microSecPerSec = OS_SharedGlobalVars.MicroSecPerTick * OS_SharedGlobalVars.TicksPerSecond; + + if (microSecPerSec != 1000000) + { + OS_DEBUG("Warning: Microsecs per sec value of %lu does not equal 1000000 (MicroSecPerTick: %ld " + "TicksPerSecond: %ld)\n", + (unsigned long)microSecPerSec, (long)OS_SharedGlobalVars.MicroSecPerTick, + (long)OS_SharedGlobalVars.TicksPerSecond); + } + + return (return_code); } /* end OS_API_Init */ /*---------------------------------------------------------------- @@ -232,7 +227,7 @@ int32 OS_API_Init(void) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_RegisterEventHandler (OS_EventHandler_t handler) +int32 OS_RegisterEventHandler(OS_EventHandler_t handler) { if (handler == NULL) { @@ -253,14 +248,14 @@ int32 OS_RegisterEventHandler (OS_EventHandler_t handler) *-----------------------------------------------------------------*/ void OS_ApplicationExit(int32 Status) { - if (Status == OS_SUCCESS) - { - exit(EXIT_SUCCESS); - } - else - { - exit(EXIT_FAILURE); - } + if (Status == OS_SUCCESS) + { + exit(EXIT_SUCCESS); + } + else + { + exit(EXIT_FAILURE); + } } /* end OS_ApplicationExit */ /*--------------------------------------------------------------------------------------- @@ -286,44 +281,43 @@ void OS_CleanUpObject(osal_id_t object_id, void *arg) ObjectCount = (uint32 *)arg; ++(*ObjectCount); - switch(OS_IdentifyObject(object_id)) + switch (OS_IdentifyObject(object_id)) { - case OS_OBJECT_TYPE_OS_TASK: - OS_TaskDelete(object_id); - break; - case OS_OBJECT_TYPE_OS_QUEUE: - OS_QueueDelete(object_id); - break; - case OS_OBJECT_TYPE_OS_BINSEM: - OS_BinSemDelete(object_id); - break; - case OS_OBJECT_TYPE_OS_COUNTSEM: - OS_CountSemDelete(object_id); - break; - case OS_OBJECT_TYPE_OS_MUTEX: - OS_MutSemDelete(object_id); - break; - case OS_OBJECT_TYPE_OS_MODULE: - OS_ModuleUnload(object_id); - break; - case OS_OBJECT_TYPE_OS_TIMEBASE: - OS_TimeBaseDelete(object_id); - break; - case OS_OBJECT_TYPE_OS_TIMECB: - OS_TimerDelete(object_id); - break; - case OS_OBJECT_TYPE_OS_STREAM: - OS_close(object_id); - break; - case OS_OBJECT_TYPE_OS_DIR: - OS_DirectoryClose(object_id); - break; - default: - break; + case OS_OBJECT_TYPE_OS_TASK: + OS_TaskDelete(object_id); + break; + case OS_OBJECT_TYPE_OS_QUEUE: + OS_QueueDelete(object_id); + break; + case OS_OBJECT_TYPE_OS_BINSEM: + OS_BinSemDelete(object_id); + break; + case OS_OBJECT_TYPE_OS_COUNTSEM: + OS_CountSemDelete(object_id); + break; + case OS_OBJECT_TYPE_OS_MUTEX: + OS_MutSemDelete(object_id); + break; + case OS_OBJECT_TYPE_OS_MODULE: + OS_ModuleUnload(object_id); + break; + case OS_OBJECT_TYPE_OS_TIMEBASE: + OS_TimeBaseDelete(object_id); + break; + case OS_OBJECT_TYPE_OS_TIMECB: + OS_TimerDelete(object_id); + break; + case OS_OBJECT_TYPE_OS_STREAM: + OS_close(object_id); + break; + case OS_OBJECT_TYPE_OS_DIR: + OS_DirectoryClose(object_id); + break; + default: + break; } } /* end OS_CleanUpObject */ - /*---------------------------------------------------------------- * * Function: OS_DeleteAllObjects @@ -342,21 +336,21 @@ void OS_DeleteAllObjects(void) * and you will not be able to delete the object until the ref count becomes zero. */ TryCount = 0; - while(true) + while (true) { ObjectCount = 0; ++TryCount; OS_ForEachObject(OS_OBJECT_CREATOR_ANY, OS_CleanUpObject, &ObjectCount); if (ObjectCount == 0 || TryCount > 4) { - break; + break; } OS_TaskDelay(5); } - while (ObjectCount > 0 && TryCount < 5); + while (ObjectCount > 0 && TryCount < 5) + ; } /* end OS_DeleteAllObjects */ - /*---------------------------------------------------------------- * * Function: OS_IdleLoop @@ -372,14 +366,12 @@ void OS_IdleLoop() * In most "real" embedded systems, this will never happen. * However it will happen in debugging situations (CTRL+C, etc). */ - while (OS_SharedGlobalVars.ShutdownFlag != OS_SHUTDOWN_MAGIC_NUMBER) - { - OS_IdleLoop_Impl(); - } + while (OS_SharedGlobalVars.ShutdownFlag != OS_SHUTDOWN_MAGIC_NUMBER) + { + OS_IdleLoop_Impl(); + } } /* end OS_IdleLoop */ - - /*---------------------------------------------------------------- * * Function: OS_ApplicationShutdown @@ -390,16 +382,15 @@ void OS_IdleLoop() *-----------------------------------------------------------------*/ void OS_ApplicationShutdown(uint8 flag) { - if (flag == true) - { - OS_SharedGlobalVars.ShutdownFlag = OS_SHUTDOWN_MAGIC_NUMBER; - } - - /* - * Hook to allow the underlying implementation to do something. - * Assuming the main task is sitting in OS_IdleLoop(), this implementation - * should do whatever is needed to wake that task up. - */ - OS_ApplicationShutdown_Impl(); -} /* end OS_ApplicationShutdown */ + if (flag == true) + { + OS_SharedGlobalVars.ShutdownFlag = OS_SHUTDOWN_MAGIC_NUMBER; + } + /* + * Hook to allow the underlying implementation to do something. + * Assuming the main task is sitting in OS_IdleLoop(), this implementation + * should do whatever is needed to wake that task up. + */ + OS_ApplicationShutdown_Impl(); +} /* end OS_ApplicationShutdown */ diff --git a/src/os/shared/src/osapi-countsem.c b/src/os/shared/src/osapi-countsem.c index 56688b6b4..00cd9d930 100644 --- a/src/os/shared/src/osapi-countsem.c +++ b/src/os/shared/src/osapi-countsem.c @@ -35,14 +35,12 @@ #include #include - /* * User defined include files */ #include "os-shared-countsem.h" #include "os-shared-idmap.h" - /* * Sanity checks on the user-supplied configuration * The relevent OS_MAX limit should be defined and greater than zero @@ -51,24 +49,21 @@ #error "osconfig.h must define OS_MAX_COUNT_SEMAPHORES to a valid value" #endif - /* * Global data for the API */ enum { - LOCAL_NUM_OBJECTS = OS_MAX_COUNT_SEMAPHORES, - LOCAL_OBJID_TYPE = OS_OBJECT_TYPE_OS_COUNTSEM + LOCAL_NUM_OBJECTS = OS_MAX_COUNT_SEMAPHORES, + LOCAL_OBJID_TYPE = OS_OBJECT_TYPE_OS_COUNTSEM }; -OS_count_sem_internal_record_t OS_count_sem_table [LOCAL_NUM_OBJECTS]; - +OS_count_sem_internal_record_t OS_count_sem_table[LOCAL_NUM_OBJECTS]; /**************************************************************************************** SEMAPHORE API ***************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_CountSemAPI_Init @@ -79,12 +74,10 @@ OS_count_sem_internal_record_t OS_count_sem_table [LOCAL_NUM_OBJECTS *-----------------------------------------------------------------*/ int32 OS_CountSemAPI_Init(void) { - memset(OS_count_sem_table, 0, sizeof(OS_count_sem_table)); - return OS_SUCCESS; + memset(OS_count_sem_table, 0, sizeof(OS_count_sem_table)); + return OS_SUCCESS; } /* end OS_CountSemAPI_Init */ - - /*---------------------------------------------------------------- * * Function: OS_CountSemCreate @@ -93,43 +86,41 @@ int32 OS_CountSemAPI_Init(void) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemCreate (osal_id_t *sem_id, const char *sem_name, uint32 sem_initial_value, - uint32 options) +int32 OS_CountSemCreate(osal_id_t *sem_id, const char *sem_name, uint32 sem_initial_value, uint32 options) { - OS_common_record_t *record; - int32 return_code; - uint32 local_id; - - /* Check for NULL pointers */ - if (sem_id == NULL || sem_name == NULL) - { - return OS_INVALID_POINTER; - } - - if ( strlen (sem_name) >= OS_MAX_API_NAME ) - { - return OS_ERR_NAME_TOO_LONG; - } - - /* Note - the common ObjectIdAllocate routine will lock the object type and leave it locked. */ - return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, sem_name, &local_id, &record); - if(return_code == OS_SUCCESS) - { - /* Save all the data to our own internal table */ - strcpy(OS_count_sem_table[local_id].obj_name, sem_name); - record->name_entry = OS_count_sem_table[local_id].obj_name; - - /* Now call the OS-specific implementation. This reads info from the table. */ - return_code = OS_CountSemCreate_Impl(local_id, sem_initial_value, options); - - /* Check result, finalize record, and unlock global table. */ - return_code = OS_ObjectIdFinalizeNew(return_code, record, sem_id); - } - - return return_code; + OS_common_record_t *record; + int32 return_code; + uint32 local_id; -} /* end OS_CountSemCreate */ + /* Check for NULL pointers */ + if (sem_id == NULL || sem_name == NULL) + { + return OS_INVALID_POINTER; + } + + if (strlen(sem_name) >= OS_MAX_API_NAME) + { + return OS_ERR_NAME_TOO_LONG; + } + + /* Note - the common ObjectIdAllocate routine will lock the object type and leave it locked. */ + return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, sem_name, &local_id, &record); + if (return_code == OS_SUCCESS) + { + /* Save all the data to our own internal table */ + strcpy(OS_count_sem_table[local_id].obj_name, sem_name); + record->name_entry = OS_count_sem_table[local_id].obj_name; + /* Now call the OS-specific implementation. This reads info from the table. */ + return_code = OS_CountSemCreate_Impl(local_id, sem_initial_value, options); + + /* Check result, finalize record, and unlock global table. */ + return_code = OS_ObjectIdFinalizeNew(return_code, record, sem_id); + } + + return return_code; + +} /* end OS_CountSemCreate */ /*---------------------------------------------------------------- * @@ -139,27 +130,25 @@ int32 OS_CountSemCreate (osal_id_t *sem_id, const char *sem_name, uint32 sem_ini * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemDelete (osal_id_t sem_id) +int32 OS_CountSemDelete(osal_id_t sem_id) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; + OS_common_record_t *record; + uint32 local_id; + int32 return_code; - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - return_code = OS_CountSemDelete_Impl(local_id); + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + return_code = OS_CountSemDelete_Impl(local_id); - /* Complete the operation via the common routine */ - return_code = OS_ObjectIdFinalizeDelete(return_code, record); - } + /* Complete the operation via the common routine */ + return_code = OS_ObjectIdFinalizeDelete(return_code, record); + } - return return_code; + return return_code; } /* end OS_CountSemDelete */ - - /*---------------------------------------------------------------- * * Function: OS_CountSemGive @@ -168,24 +157,23 @@ int32 OS_CountSemDelete (osal_id_t sem_id) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemGive ( osal_id_t sem_id ) +int32 OS_CountSemGive(osal_id_t sem_id) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; + OS_common_record_t *record; + uint32 local_id; + int32 return_code; /* Check Parameters */ return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); if (return_code == OS_SUCCESS) { - return_code = OS_CountSemGive_Impl (local_id); + return_code = OS_CountSemGive_Impl(local_id); } return return_code; } /* end OS_CountSemGive */ - /*---------------------------------------------------------------- * * Function: OS_CountSemTake @@ -194,22 +182,21 @@ int32 OS_CountSemGive ( osal_id_t sem_id ) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemTake ( osal_id_t sem_id ) +int32 OS_CountSemTake(osal_id_t sem_id) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; - - /* Check Parameters */ - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - return_code = OS_CountSemTake_Impl (local_id); - } - - return return_code; -} /* end OS_CountSemTake */ + OS_common_record_t *record; + uint32 local_id; + int32 return_code; + + /* Check Parameters */ + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + return_code = OS_CountSemTake_Impl(local_id); + } + return return_code; +} /* end OS_CountSemTake */ /*---------------------------------------------------------------- * @@ -219,22 +206,21 @@ int32 OS_CountSemTake ( osal_id_t sem_id ) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemTimedWait ( osal_id_t sem_id, uint32 msecs ) +int32 OS_CountSemTimedWait(osal_id_t sem_id, uint32 msecs) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; - - /* Check Parameters */ - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - return_code = OS_CountSemTimedWait_Impl (local_id, msecs); - } - - return return_code; -} /* end OS_CountSemTimedWait */ + OS_common_record_t *record; + uint32 local_id; + int32 return_code; + + /* Check Parameters */ + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + return_code = OS_CountSemTimedWait_Impl(local_id, msecs); + } + return return_code; +} /* end OS_CountSemTimedWait */ /*---------------------------------------------------------------- * @@ -244,21 +230,20 @@ int32 OS_CountSemTimedWait ( osal_id_t sem_id, uint32 msecs ) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemGetIdByName (osal_id_t *sem_id, const char *sem_name) +int32 OS_CountSemGetIdByName(osal_id_t *sem_id, const char *sem_name) { - int32 return_code; + int32 return_code; - if (sem_id == NULL || sem_name == NULL) - { - return OS_INVALID_POINTER; - } + if (sem_id == NULL || sem_name == NULL) + { + return OS_INVALID_POINTER; + } - return_code = OS_ObjectIdFindByName(LOCAL_OBJID_TYPE, sem_name, sem_id); + return_code = OS_ObjectIdFindByName(LOCAL_OBJID_TYPE, sem_name, sem_id); - return return_code; + return return_code; } /* end OS_CountSemGetIdByName */ - /*---------------------------------------------------------------- * * Function: OS_CountSemGetInfo @@ -267,31 +252,30 @@ int32 OS_CountSemGetIdByName (osal_id_t *sem_id, const char *sem_name) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemGetInfo (osal_id_t sem_id, OS_count_sem_prop_t *count_prop) +int32 OS_CountSemGetInfo(osal_id_t sem_id, OS_count_sem_prop_t *count_prop) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; - - /* Check parameters */ - if (count_prop == NULL) - { - return OS_INVALID_POINTER; - } - - memset(count_prop,0,sizeof(OS_count_sem_prop_t)); - - /* Check Parameters */ - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - strncpy(count_prop->name, record->name_entry, OS_MAX_API_NAME - 1); - count_prop->creator = record->creator; - - return_code = OS_CountSemGetInfo_Impl (local_id, count_prop); - OS_Unlock_Global(LOCAL_OBJID_TYPE); - } - - return return_code; -} /* end OS_CountSemGetInfo */ + OS_common_record_t *record; + uint32 local_id; + int32 return_code; + + /* Check parameters */ + if (count_prop == NULL) + { + return OS_INVALID_POINTER; + } + + memset(count_prop, 0, sizeof(OS_count_sem_prop_t)); + /* Check Parameters */ + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + strncpy(count_prop->name, record->name_entry, OS_MAX_API_NAME - 1); + count_prop->creator = record->creator; + + return_code = OS_CountSemGetInfo_Impl(local_id, count_prop); + OS_Unlock_Global(LOCAL_OBJID_TYPE); + } + + return return_code; +} /* end OS_CountSemGetInfo */ diff --git a/src/os/shared/src/osapi-debug.c b/src/os/shared/src/osapi-debug.c index c80b40dae..f6eef77ac 100644 --- a/src/os/shared/src/osapi-debug.c +++ b/src/os/shared/src/osapi-debug.c @@ -36,16 +36,13 @@ #include #include - /* * User defined include files */ #include "os-shared-globaldefs.h" #include "os-shared-common.h" -#define OS_DEBUG_OUTPUT_STREAM stdout - - +#define OS_DEBUG_OUTPUT_STREAM stdout /*---------------------------------------------------------------- * @@ -61,10 +58,9 @@ void OS_DebugPrintf(uint32 Level, const char *Func, uint32 Line, const char *For if (OS_SharedGlobalVars.DebugLevel >= Level) { va_start(va, Format); - fprintf(OS_DEBUG_OUTPUT_STREAM, "%s():%lu:",Func,(unsigned long)Line); + fprintf(OS_DEBUG_OUTPUT_STREAM, "%s():%lu:", Func, (unsigned long)Line); vfprintf(OS_DEBUG_OUTPUT_STREAM, Format, va); va_end(va); } } /* end OS_DebugPrintf */ - diff --git a/src/os/shared/src/osapi-dir.c b/src/os/shared/src/osapi-dir.c index 6f20a0404..42153431e 100644 --- a/src/os/shared/src/osapi-dir.c +++ b/src/os/shared/src/osapi-dir.c @@ -35,14 +35,12 @@ #include #include - /* * User defined include files */ #include "os-shared-dir.h" #include "os-shared-idmap.h" - /* * Sanity checks on the user-supplied configuration * The relevent OS_MAX limit should be defined and greater than zero @@ -51,25 +49,21 @@ #error "osconfig.h must define OS_MAX_NUM_OPEN_DIRS to a valid value" #endif - /* * Global data for the API */ enum { - LOCAL_NUM_OBJECTS = OS_MAX_NUM_OPEN_DIRS, - LOCAL_OBJID_TYPE = OS_OBJECT_TYPE_OS_DIR + LOCAL_NUM_OBJECTS = OS_MAX_NUM_OPEN_DIRS, + LOCAL_OBJID_TYPE = OS_OBJECT_TYPE_OS_DIR }; -OS_dir_internal_record_t OS_dir_table [LOCAL_NUM_OBJECTS]; - - +OS_dir_internal_record_t OS_dir_table[LOCAL_NUM_OBJECTS]; /**************************************************************************************** DIRECTORY API ***************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_DirAPI_Init @@ -80,11 +74,10 @@ OS_dir_internal_record_t OS_dir_table [LOCAL_NUM_OBJECTS]; *-----------------------------------------------------------------*/ int32 OS_DirAPI_Init(void) { - memset(OS_dir_table, 0, sizeof(OS_dir_table)); - return OS_SUCCESS; + memset(OS_dir_table, 0, sizeof(OS_dir_table)); + return OS_SUCCESS; } /* end OS_DirAPI_Init */ - /*---------------------------------------------------------------- * * Function: OS_mkdir @@ -93,22 +86,21 @@ int32 OS_DirAPI_Init(void) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_mkdir (const char *path, uint32 access) +int32 OS_mkdir(const char *path, uint32 access) { - int32 return_code; - char local_path[OS_MAX_LOCAL_PATH_LEN]; + int32 return_code; + char local_path[OS_MAX_LOCAL_PATH_LEN]; - return_code = OS_TranslatePath(path, local_path); - if (return_code == OS_SUCCESS) - { - return_code = OS_DirCreate_Impl(local_path, access); - } + return_code = OS_TranslatePath(path, local_path); + if (return_code == OS_SUCCESS) + { + return_code = OS_DirCreate_Impl(local_path, access); + } - return return_code; + return return_code; } /* end OS_mkdir */ - /*---------------------------------------------------------------- * * Function: OS_DirectoryOpen @@ -119,10 +111,10 @@ int32 OS_mkdir (const char *path, uint32 access) *-----------------------------------------------------------------*/ int32 OS_DirectoryOpen(osal_id_t *dir_id, const char *path) { - char local_path[OS_MAX_LOCAL_PATH_LEN]; + char local_path[OS_MAX_LOCAL_PATH_LEN]; OS_common_record_t *record; - uint32 local_id; - int32 return_code; + uint32 local_id; + int32 return_code; if (dir_id == NULL || path == NULL) { @@ -132,27 +124,25 @@ int32 OS_DirectoryOpen(osal_id_t *dir_id, const char *path) return_code = OS_TranslatePath(path, local_path); if (return_code == OS_SUCCESS) { - /* Note - the common ObjectIdAllocate routine will lock the object type and leave it locked. */ - return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, NULL, &local_id, &record); - if(return_code == OS_SUCCESS) - { - /* Save all the data to our own internal table */ - memset(&OS_dir_table[local_id], 0, sizeof (OS_dir_internal_record_t)); - strncpy(OS_dir_table[local_id].dir_name, path, OS_MAX_PATH_LEN - 1); - - /* Now call the OS-specific implementation. */ - return_code = OS_DirOpen_Impl(local_id, local_path); - - /* Check result, finalize record, and unlock global table. */ - return_code = OS_ObjectIdFinalizeNew(return_code, record, dir_id); - } + /* Note - the common ObjectIdAllocate routine will lock the object type and leave it locked. */ + return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, NULL, &local_id, &record); + if (return_code == OS_SUCCESS) + { + /* Save all the data to our own internal table */ + memset(&OS_dir_table[local_id], 0, sizeof(OS_dir_internal_record_t)); + strncpy(OS_dir_table[local_id].dir_name, path, OS_MAX_PATH_LEN - 1); + + /* Now call the OS-specific implementation. */ + return_code = OS_DirOpen_Impl(local_id, local_path); + + /* Check result, finalize record, and unlock global table. */ + return_code = OS_ObjectIdFinalizeNew(return_code, record, dir_id); + } } return return_code; } /* end OS_DirectoryOpen */ - - /*---------------------------------------------------------------- * * Function: OS_DirectoryClose @@ -163,24 +153,23 @@ int32 OS_DirectoryOpen(osal_id_t *dir_id, const char *path) *-----------------------------------------------------------------*/ int32 OS_DirectoryClose(osal_id_t dir_id) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; + OS_common_record_t *record; + uint32 local_id; + int32 return_code; - /* Make sure the file descriptor is legit before using it */ - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, dir_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - return_code = OS_DirClose_Impl(local_id); + /* Make sure the file descriptor is legit before using it */ + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, dir_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + return_code = OS_DirClose_Impl(local_id); - /* Complete the operation via the common routine */ - return_code = OS_ObjectIdFinalizeDelete(return_code, record); - } + /* Complete the operation via the common routine */ + return_code = OS_ObjectIdFinalizeDelete(return_code, record); + } - return return_code; + return return_code; } /* end OS_DirectoryClose */ - /*---------------------------------------------------------------- * * Function: OS_DirectoryRead @@ -191,38 +180,37 @@ int32 OS_DirectoryClose(osal_id_t dir_id) *-----------------------------------------------------------------*/ int32 OS_DirectoryRead(osal_id_t dir_id, os_dirent_t *dirent) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; - - if (dirent == NULL) - { - return OS_INVALID_POINTER; - } - - /* Make sure the file descriptor is legit before using it */ - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, dir_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - /* - * Call the underlying implementation to perform the read - * - * NOTE: This does not map "virtual mount points" that - * may appear in the dir listing back to the virtualized - * name. For instance, if the (real) /eeprom directory - * is virtualized to /cf via the OS_VolumeTable, and one - * reads the "/" directory, the application will see the - * real name (eeprom) and not the virtualized name (cf). - */ - return_code = OS_DirRead_Impl(local_id, dirent); - - OS_Unlock_Global(LOCAL_OBJID_TYPE); - } - - return return_code; + OS_common_record_t *record; + uint32 local_id; + int32 return_code; -} /* end OS_DirectoryRead */ + if (dirent == NULL) + { + return OS_INVALID_POINTER; + } + /* Make sure the file descriptor is legit before using it */ + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, dir_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + /* + * Call the underlying implementation to perform the read + * + * NOTE: This does not map "virtual mount points" that + * may appear in the dir listing back to the virtualized + * name. For instance, if the (real) /eeprom directory + * is virtualized to /cf via the OS_VolumeTable, and one + * reads the "/" directory, the application will see the + * real name (eeprom) and not the virtualized name (cf). + */ + return_code = OS_DirRead_Impl(local_id, dirent); + + OS_Unlock_Global(LOCAL_OBJID_TYPE); + } + + return return_code; + +} /* end OS_DirectoryRead */ /*---------------------------------------------------------------- * @@ -234,20 +222,19 @@ int32 OS_DirectoryRead(osal_id_t dir_id, os_dirent_t *dirent) *-----------------------------------------------------------------*/ int32 OS_DirectoryRewind(osal_id_t dir_id) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; - - /* Make sure the file descriptor is legit before using it */ - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, dir_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - return_code = OS_DirRewind_Impl(local_id); - } - - return return_code; -} /* end OS_DirectoryRewind */ + OS_common_record_t *record; + uint32 local_id; + int32 return_code; + /* Make sure the file descriptor is legit before using it */ + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, dir_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + return_code = OS_DirRewind_Impl(local_id); + } + + return return_code; +} /* end OS_DirectoryRewind */ /*---------------------------------------------------------------- * @@ -257,18 +244,17 @@ int32 OS_DirectoryRewind(osal_id_t dir_id) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_rmdir (const char *path) +int32 OS_rmdir(const char *path) { - int32 return_code; - char local_path [OS_MAX_LOCAL_PATH_LEN]; + int32 return_code; + char local_path[OS_MAX_LOCAL_PATH_LEN]; - return_code = OS_TranslatePath(path, local_path); - if (return_code == OS_SUCCESS) - { - OS_DirRemove_Impl(local_path); - } + return_code = OS_TranslatePath(path, local_path); + if (return_code == OS_SUCCESS) + { + OS_DirRemove_Impl(local_path); + } - return return_code; + return return_code; } /* end OS_rmdir */ - diff --git a/src/os/shared/src/osapi-errors.c b/src/os/shared/src/osapi-errors.c index fef7f1863..a8e077fb3 100644 --- a/src/os/shared/src/osapi-errors.c +++ b/src/os/shared/src/osapi-errors.c @@ -34,7 +34,6 @@ #include #include - /* * User defined include files */ @@ -49,41 +48,39 @@ * The low level implementation can extend this with * additional codes if necessary (but they may not be consistent). */ -static const OS_ErrorTable_Entry_t OS_GLOBAL_ERROR_NAME_TABLE[] = - { - { OS_SUCCESS, "OS_SUCCESS" }, - { OS_ERROR, "OS_ERROR" }, - { OS_INVALID_POINTER, "OS_INVALID_POINTER" }, - { OS_ERROR_ADDRESS_MISALIGNED, "OS_ADDRESS_MISALIGNED" }, - { OS_ERROR_TIMEOUT,"OS_ERROR_TIMEOUT" }, - { OS_INVALID_INT_NUM,"OS_INVALID_INT_NUM" }, - { OS_SEM_FAILURE,"OS_SEM_FAILURE" }, - { OS_SEM_TIMEOUT,"OS_SEM_TIMEOUT" }, - { OS_QUEUE_EMPTY,"OS_QUEUE_EMPTY" }, - { OS_QUEUE_FULL,"OS_QUEUE_FULL" }, - { OS_QUEUE_TIMEOUT,"OS_QUEUE_TIMEOUT" }, - { OS_QUEUE_INVALID_SIZE,"OS_QUEUE_INVALID_SIZE" }, - { OS_QUEUE_ID_ERROR,"OS_QUEUE_ID_ERROR" }, - { OS_ERR_NAME_TOO_LONG,"OS_ERR_NAME_TOO_LONG" }, - { OS_ERR_NO_FREE_IDS,"OS_ERR_NO_FREE_IDS" }, - { OS_ERR_NAME_TAKEN,"OS_ERR_NAME_TAKEN" }, - { OS_ERR_INVALID_ID,"OS_ERR_INVALID_ID" }, - { OS_ERR_NAME_NOT_FOUND,"OS_ERR_NAME_NOT_FOUND" }, - { OS_ERR_SEM_NOT_FULL,"OS_ERR_SEM_NOT_FULL" }, - { OS_ERR_INVALID_PRIORITY,"OS_ERR_INVALID_PRIORITY" }, - { OS_ERR_OBJECT_IN_USE,"OS_ERR_OBJECT_IN_USE" }, - { OS_ERR_BAD_ADDRESS,"OS_ERR_BAD_ADDRESS" }, - { OS_ERR_INCORRECT_OBJ_STATE,"OS_ERR_INCORRECT_OBJ_STATE" }, - { OS_ERR_INCORRECT_OBJ_TYPE,"OS_ERR_INCORRECT_OBJ_TYPE" }, - { OS_FS_ERR_PATH_TOO_LONG, "OS_FS_ERR_PATH_TOO_LONG" }, - { OS_FS_ERR_NAME_TOO_LONG, "OS_FS_ERR_NAME_TOO_LONG" }, - { OS_FS_ERR_DRIVE_NOT_CREATED, "OS_FS_ERR_DRIVE_NOT_CREATED" }, - { OS_FS_ERR_DEVICE_NOT_FREE, "OS_FS_ERR_DEVICE_NOT_FREE" }, - { OS_FS_ERR_PATH_INVALID, "OS_FS_ERR_PATH_INVALID" }, - - { 0, NULL } /* End of table marker */ - }; - +static const OS_ErrorTable_Entry_t OS_GLOBAL_ERROR_NAME_TABLE[] = { + {OS_SUCCESS, "OS_SUCCESS"}, + {OS_ERROR, "OS_ERROR"}, + {OS_INVALID_POINTER, "OS_INVALID_POINTER"}, + {OS_ERROR_ADDRESS_MISALIGNED, "OS_ADDRESS_MISALIGNED"}, + {OS_ERROR_TIMEOUT, "OS_ERROR_TIMEOUT"}, + {OS_INVALID_INT_NUM, "OS_INVALID_INT_NUM"}, + {OS_SEM_FAILURE, "OS_SEM_FAILURE"}, + {OS_SEM_TIMEOUT, "OS_SEM_TIMEOUT"}, + {OS_QUEUE_EMPTY, "OS_QUEUE_EMPTY"}, + {OS_QUEUE_FULL, "OS_QUEUE_FULL"}, + {OS_QUEUE_TIMEOUT, "OS_QUEUE_TIMEOUT"}, + {OS_QUEUE_INVALID_SIZE, "OS_QUEUE_INVALID_SIZE"}, + {OS_QUEUE_ID_ERROR, "OS_QUEUE_ID_ERROR"}, + {OS_ERR_NAME_TOO_LONG, "OS_ERR_NAME_TOO_LONG"}, + {OS_ERR_NO_FREE_IDS, "OS_ERR_NO_FREE_IDS"}, + {OS_ERR_NAME_TAKEN, "OS_ERR_NAME_TAKEN"}, + {OS_ERR_INVALID_ID, "OS_ERR_INVALID_ID"}, + {OS_ERR_NAME_NOT_FOUND, "OS_ERR_NAME_NOT_FOUND"}, + {OS_ERR_SEM_NOT_FULL, "OS_ERR_SEM_NOT_FULL"}, + {OS_ERR_INVALID_PRIORITY, "OS_ERR_INVALID_PRIORITY"}, + {OS_ERR_OBJECT_IN_USE, "OS_ERR_OBJECT_IN_USE"}, + {OS_ERR_BAD_ADDRESS, "OS_ERR_BAD_ADDRESS"}, + {OS_ERR_INCORRECT_OBJ_STATE, "OS_ERR_INCORRECT_OBJ_STATE"}, + {OS_ERR_INCORRECT_OBJ_TYPE, "OS_ERR_INCORRECT_OBJ_TYPE"}, + {OS_FS_ERR_PATH_TOO_LONG, "OS_FS_ERR_PATH_TOO_LONG"}, + {OS_FS_ERR_NAME_TOO_LONG, "OS_FS_ERR_NAME_TOO_LONG"}, + {OS_FS_ERR_DRIVE_NOT_CREATED, "OS_FS_ERR_DRIVE_NOT_CREATED"}, + {OS_FS_ERR_DEVICE_NOT_FREE, "OS_FS_ERR_DEVICE_NOT_FREE"}, + {OS_FS_ERR_PATH_INVALID, "OS_FS_ERR_PATH_INVALID"}, + + {0, NULL} /* End of table marker */ +}; /* ********************************************************************************* @@ -91,8 +88,6 @@ static const OS_ErrorTable_Entry_t OS_GLOBAL_ERROR_NAME_TABLE[] = ********************************************************************************* */ - - /*---------------------------------------------------------------- * * Function: OS_GetErrorName @@ -101,9 +96,9 @@ static const OS_ErrorTable_Entry_t OS_GLOBAL_ERROR_NAME_TABLE[] = * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_GetErrorName(int32 error_num, os_err_name_t* err_name) +int32 OS_GetErrorName(int32 error_num, os_err_name_t *err_name) { - uint32 return_code; + uint32 return_code; const OS_ErrorTable_Entry_t *Error; if (err_name == NULL) @@ -114,31 +109,30 @@ int32 OS_GetErrorName(int32 error_num, os_err_name_t* err_name) Error = OS_GLOBAL_ERROR_NAME_TABLE; while (Error->Name != NULL && Error->Number != error_num) { - ++Error; + ++Error; } if (Error->Number != error_num) { - Error = OS_IMPL_ERROR_NAME_TABLE; - while (Error->Name != NULL && Error->Number != error_num) - { - ++Error; - } + Error = OS_IMPL_ERROR_NAME_TABLE; + while (Error->Name != NULL && Error->Number != error_num) + { + ++Error; + } } if (Error->Number == error_num && Error->Name != NULL) { - strncpy(*err_name, Error->Name, OS_ERROR_NAME_LENGTH - 1); - return_code = OS_SUCCESS; + strncpy(*err_name, Error->Name, OS_ERROR_NAME_LENGTH - 1); + return_code = OS_SUCCESS; } else { - snprintf(*err_name, OS_ERROR_NAME_LENGTH, "OS_UNKNOWN(%d)", (int)error_num); - return_code = OS_ERROR; + snprintf(*err_name, OS_ERROR_NAME_LENGTH, "OS_UNKNOWN(%d)", (int)error_num); + return_code = OS_ERROR; } (*err_name)[OS_ERROR_NAME_LENGTH - 1] = '\0'; return return_code; } /* end OS_GetErrorName */ - diff --git a/src/os/shared/src/osapi-file.c b/src/os/shared/src/osapi-file.c index d054696f5..37837b9e2 100644 --- a/src/os/shared/src/osapi-file.c +++ b/src/os/shared/src/osapi-file.c @@ -41,7 +41,6 @@ #include "os-shared-file.h" #include "os-shared-idmap.h" - /* * Sanity checks on the user-supplied configuration * The relevent OS_MAX limit should be defined and greater than zero @@ -50,24 +49,21 @@ #error "osconfig.h must define OS_MAX_NUM_OPEN_FILES to a valid value" #endif - /* * Global data for the API */ enum { - LOCAL_NUM_OBJECTS = OS_MAX_NUM_OPEN_FILES, - LOCAL_OBJID_TYPE = OS_OBJECT_TYPE_OS_STREAM + LOCAL_NUM_OBJECTS = OS_MAX_NUM_OPEN_FILES, + LOCAL_OBJID_TYPE = OS_OBJECT_TYPE_OS_STREAM }; -OS_stream_internal_record_t OS_stream_table[OS_MAX_NUM_OPEN_FILES]; - +OS_stream_internal_record_t OS_stream_table[OS_MAX_NUM_OPEN_FILES]; /**************************************************************************************** FILE API ***************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_FileAPI_Init @@ -78,11 +74,10 @@ OS_stream_internal_record_t OS_stream_table[OS_MAX_NUM_OPEN_FILES]; *-----------------------------------------------------------------*/ int32 OS_FileAPI_Init(void) { - memset(OS_stream_table, 0, sizeof(OS_stream_table)); - return OS_SUCCESS; + memset(OS_stream_table, 0, sizeof(OS_stream_table)); + return OS_SUCCESS; } /* end OS_FileAPI_Init */ - /*---------------------------------------------------------------- * * Function: OS_OpenCreate @@ -94,53 +89,50 @@ int32 OS_FileAPI_Init(void) *-----------------------------------------------------------------*/ int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 access) { - int32 return_code; - uint32 local_id; - OS_common_record_t *record; - char local_path[OS_MAX_LOCAL_PATH_LEN]; - - if (filedes == NULL) - { - return OS_INVALID_POINTER; - } - - /* - ** Check for a valid access mode - */ - if (access != OS_WRITE_ONLY && - access != OS_READ_ONLY && - access != OS_READ_WRITE) - { - return OS_ERROR; - } - - /* - * Translate the path + int32 return_code; + uint32 local_id; + OS_common_record_t *record; + char local_path[OS_MAX_LOCAL_PATH_LEN]; + + if (filedes == NULL) + { + return OS_INVALID_POINTER; + } + + /* + ** Check for a valid access mode */ - return_code = OS_TranslatePath(path, (char *)local_path); - - if (return_code == OS_SUCCESS) - { - /* Note - the common ObjectIdAllocate routine will lock the object type and leave it locked. */ - return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, NULL, &local_id, &record); - if(return_code == OS_SUCCESS) - { - /* Save all the data to our own internal table */ - memset(&OS_stream_table[local_id], 0, sizeof(OS_stream_internal_record_t)); - strcpy(OS_stream_table[local_id].stream_name, path); - record->name_entry = OS_stream_table[local_id].stream_name; - - /* Now call the OS-specific implementation. */ - return_code = OS_FileOpen_Impl(local_id, local_path, flags, access); - - /* Check result, finalize record, and unlock global table. */ - return_code = OS_ObjectIdFinalizeNew(return_code, record, filedes); - } - } - - return return_code; -} /* end OS_OpenCreate */ + if (access != OS_WRITE_ONLY && access != OS_READ_ONLY && access != OS_READ_WRITE) + { + return OS_ERROR; + } + /* + * Translate the path + */ + return_code = OS_TranslatePath(path, (char *)local_path); + + if (return_code == OS_SUCCESS) + { + /* Note - the common ObjectIdAllocate routine will lock the object type and leave it locked. */ + return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, NULL, &local_id, &record); + if (return_code == OS_SUCCESS) + { + /* Save all the data to our own internal table */ + memset(&OS_stream_table[local_id], 0, sizeof(OS_stream_internal_record_t)); + strcpy(OS_stream_table[local_id].stream_name, path); + record->name_entry = OS_stream_table[local_id].stream_name; + + /* Now call the OS-specific implementation. */ + return_code = OS_FileOpen_Impl(local_id, local_path, flags, access); + + /* Check result, finalize record, and unlock global table. */ + return_code = OS_ObjectIdFinalizeNew(return_code, record, filedes); + } + } + + return return_code; +} /* end OS_OpenCreate */ /* * The OS_open and OS_creat functions are deprecated, replaced by @@ -156,37 +148,35 @@ int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 acc * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_creat (const char *path, int32 access) +int32 OS_creat(const char *path, int32 access) { - osal_id_t filedes; - int32 return_code; - - /* - ** Check for a valid access mode - */ - switch(access) - { - case OS_WRITE_ONLY: - case OS_READ_WRITE: - break; - case OS_READ_ONLY: - default: - /* Read only does not make sense for creat() */ - return OS_ERROR; - } - - - return_code = OS_OpenCreate(&filedes, path, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, access); - if (return_code == OS_SUCCESS) - { - /* for backward compatibility, on success return the ID as an int32. - * This will always within the positive range */ - return_code = (int32)OS_ObjectIdToInteger(filedes); - } - - return return_code; -} /* end OS_creat */ + osal_id_t filedes; + int32 return_code; + + /* + ** Check for a valid access mode + */ + switch (access) + { + case OS_WRITE_ONLY: + case OS_READ_WRITE: + break; + case OS_READ_ONLY: + default: + /* Read only does not make sense for creat() */ + return OS_ERROR; + } + + return_code = OS_OpenCreate(&filedes, path, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, access); + if (return_code == OS_SUCCESS) + { + /* for backward compatibility, on success return the ID as an int32. + * This will always within the positive range */ + return_code = (int32)OS_ObjectIdToInteger(filedes); + } + return return_code; +} /* end OS_creat */ /*---------------------------------------------------------------- * @@ -196,34 +186,33 @@ int32 OS_creat (const char *path, int32 access) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_open (const char *path, int32 access, uint32 mode) +int32 OS_open(const char *path, int32 access, uint32 mode) { - osal_id_t filedes; - int32 return_code; - - /* - ** Check for a valid access mode - */ - switch(access) - { - case OS_WRITE_ONLY: - case OS_READ_WRITE: - case OS_READ_ONLY: - break; - default: - return OS_ERROR; - } - - - return_code = OS_OpenCreate(&filedes, path, OS_FILE_FLAG_NONE, access); - if (return_code == OS_SUCCESS) - { - /* for backward compatibility, on success return the ID as an int32. - * This will always within the positive range */ - return_code = (int32)OS_ObjectIdToInteger(filedes); - } - - return return_code; + osal_id_t filedes; + int32 return_code; + + /* + ** Check for a valid access mode + */ + switch (access) + { + case OS_WRITE_ONLY: + case OS_READ_WRITE: + case OS_READ_ONLY: + break; + default: + return OS_ERROR; + } + + return_code = OS_OpenCreate(&filedes, path, OS_FILE_FLAG_NONE, access); + if (return_code == OS_SUCCESS) + { + /* for backward compatibility, on success return the ID as an int32. + * This will always within the positive range */ + return_code = (int32)OS_ObjectIdToInteger(filedes); + } + + return return_code; } /* end OS_open */ #endif @@ -236,11 +225,11 @@ int32 OS_open (const char *path, int32 access, uint32 mode) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_close (osal_id_t filedes) +int32 OS_close(osal_id_t filedes) { OS_common_record_t *record; - uint32 local_id; - int32 return_code; + uint32 local_id; + int32 return_code; /* Make sure the file descriptor is legit before using it */ return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, filedes, &local_id, &record); @@ -256,7 +245,6 @@ int32 OS_close (osal_id_t filedes) } /* end OS_close */ - /*---------------------------------------------------------------- * * Function: OS_TimedRead @@ -265,28 +253,27 @@ int32 OS_close (osal_id_t filedes) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_TimedRead(osal_id_t filedes, void *buffer, uint32 nbytes, int32 timeout) +int32 OS_TimedRead(osal_id_t filedes, void *buffer, uint32 nbytes, int32 timeout) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; - - /* Check Parameters */ - if (buffer == NULL || nbytes == 0) - { - return OS_INVALID_POINTER; - } - - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, LOCAL_OBJID_TYPE, filedes, &local_id, &record); - if (return_code == OS_SUCCESS) - { - return_code = OS_GenericRead_Impl (local_id, buffer, nbytes, timeout); - OS_ObjectIdRefcountDecr(record); - } - - return return_code; -} /* end OS_TimedRead */ + OS_common_record_t *record; + uint32 local_id; + int32 return_code; + + /* Check Parameters */ + if (buffer == NULL || nbytes == 0) + { + return OS_INVALID_POINTER; + } + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, LOCAL_OBJID_TYPE, filedes, &local_id, &record); + if (return_code == OS_SUCCESS) + { + return_code = OS_GenericRead_Impl(local_id, buffer, nbytes, timeout); + OS_ObjectIdRefcountDecr(record); + } + + return return_code; +} /* end OS_TimedRead */ /*---------------------------------------------------------------- * @@ -296,28 +283,27 @@ int32 OS_TimedRead(osal_id_t filedes, void *buffer, uint32 nbytes, int32 timeou * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_TimedWrite(osal_id_t filedes, const void *buffer, uint32 nbytes, int32 timeout) +int32 OS_TimedWrite(osal_id_t filedes, const void *buffer, uint32 nbytes, int32 timeout) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; - - /* Check Parameters */ - if (buffer == NULL || nbytes == 0) - { - return OS_INVALID_POINTER; - } - - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, LOCAL_OBJID_TYPE, filedes, &local_id, &record); - if (return_code == OS_SUCCESS) - { - return_code = OS_GenericWrite_Impl (local_id, buffer, nbytes, timeout); - OS_ObjectIdRefcountDecr(record); - } - - return return_code; -} /* end OS_TimedWrite */ + OS_common_record_t *record; + uint32 local_id; + int32 return_code; + + /* Check Parameters */ + if (buffer == NULL || nbytes == 0) + { + return OS_INVALID_POINTER; + } + + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, LOCAL_OBJID_TYPE, filedes, &local_id, &record); + if (return_code == OS_SUCCESS) + { + return_code = OS_GenericWrite_Impl(local_id, buffer, nbytes, timeout); + OS_ObjectIdRefcountDecr(record); + } + return return_code; +} /* end OS_TimedWrite */ /*---------------------------------------------------------------- * @@ -327,12 +313,11 @@ int32 OS_TimedWrite(osal_id_t filedes, const void *buffer, uint32 nbytes, int32 * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_read (osal_id_t filedes, void *buffer, uint32 nbytes) +int32 OS_read(osal_id_t filedes, void *buffer, uint32 nbytes) { - return OS_TimedRead(filedes, buffer, nbytes, OS_PEND); + return OS_TimedRead(filedes, buffer, nbytes, OS_PEND); } /* end OS_read */ - /*---------------------------------------------------------------- * * Function: OS_write @@ -341,13 +326,11 @@ int32 OS_read (osal_id_t filedes, void *buffer, uint32 nbytes) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_write (osal_id_t filedes, const void *buffer, uint32 nbytes) +int32 OS_write(osal_id_t filedes, const void *buffer, uint32 nbytes) { return OS_TimedWrite(filedes, buffer, nbytes, OS_PEND); } /* end OS_write */ - - /*---------------------------------------------------------------- * * Function: OS_chmod @@ -356,22 +339,21 @@ int32 OS_write (osal_id_t filedes, const void *buffer, uint32 nbytes) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_chmod (const char *path, uint32 access) +int32 OS_chmod(const char *path, uint32 access) { - char local_path[OS_MAX_LOCAL_PATH_LEN]; + char local_path[OS_MAX_LOCAL_PATH_LEN]; int32 return_code; return_code = OS_TranslatePath(path, local_path); if (return_code == OS_SUCCESS) { - return_code = OS_FileChmod_Impl(local_path, access); + return_code = OS_FileChmod_Impl(local_path, access); } return return_code; } /* end OS_chmod */ - /*---------------------------------------------------------------- * * Function: OS_stat @@ -380,28 +362,27 @@ int32 OS_chmod (const char *path, uint32 access) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_stat (const char *path, os_fstat_t *filestats) +int32 OS_stat(const char *path, os_fstat_t *filestats) { - int32 return_code; - char local_path[OS_MAX_LOCAL_PATH_LEN]; + int32 return_code; + char local_path[OS_MAX_LOCAL_PATH_LEN]; - if (filestats == NULL) - { - return OS_INVALID_POINTER; - } + if (filestats == NULL) + { + return OS_INVALID_POINTER; + } - memset(filestats, 0, sizeof(*filestats)); + memset(filestats, 0, sizeof(*filestats)); - return_code = OS_TranslatePath(path, local_path); - if (return_code == OS_SUCCESS) - { - return_code = OS_FileStat_Impl(local_path, filestats); - } + return_code = OS_TranslatePath(path, local_path); + if (return_code == OS_SUCCESS) + { + return_code = OS_FileStat_Impl(local_path, filestats); + } - return return_code; + return return_code; } /* end OS_stat */ - /*---------------------------------------------------------------- * * Function: OS_lseek @@ -410,23 +391,22 @@ int32 OS_stat (const char *path, os_fstat_t *filestats) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_lseek (osal_id_t filedes, int32 offset, uint32 whence) +int32 OS_lseek(osal_id_t filedes, int32 offset, uint32 whence) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; - - /* Make sure the file descriptor is legit before using it */ - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, LOCAL_OBJID_TYPE, filedes, &local_id, &record); - if (return_code == OS_SUCCESS) - { - return_code = OS_GenericSeek_Impl (local_id, offset, whence); - OS_ObjectIdRefcountDecr(record); - } - - return return_code; -} /* end OS_lseek */ + OS_common_record_t *record; + uint32 local_id; + int32 return_code; + /* Make sure the file descriptor is legit before using it */ + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, LOCAL_OBJID_TYPE, filedes, &local_id, &record); + if (return_code == OS_SUCCESS) + { + return_code = OS_GenericSeek_Impl(local_id, offset, whence); + OS_ObjectIdRefcountDecr(record); + } + + return return_code; +} /* end OS_lseek */ /*---------------------------------------------------------------- * @@ -436,22 +416,21 @@ int32 OS_lseek (osal_id_t filedes, int32 offset, uint32 whence) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_remove (const char *path) +int32 OS_remove(const char *path) { - int32 return_code; - char local_path[OS_MAX_LOCAL_PATH_LEN]; + int32 return_code; + char local_path[OS_MAX_LOCAL_PATH_LEN]; - return_code = OS_TranslatePath(path, local_path); - if (return_code == OS_SUCCESS) - { - return_code = OS_FileRemove_Impl(local_path); - } + return_code = OS_TranslatePath(path, local_path); + if (return_code == OS_SUCCESS) + { + return_code = OS_FileRemove_Impl(local_path); + } - return return_code; + return return_code; } /* end OS_remove */ - /*---------------------------------------------------------------- * * Function: OS_rename @@ -460,44 +439,43 @@ int32 OS_remove (const char *path) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_rename (const char *old, const char *new) +int32 OS_rename(const char *old, const char *new) { - int i; - 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); - if (return_code == OS_SUCCESS) - { - return_code = OS_TranslatePath(new, new_path); - } - - if (return_code == OS_SUCCESS) - { - return_code = OS_FileRename_Impl(old_path, new_path); - } - - if (return_code == OS_SUCCESS) - { - OS_Lock_Global(LOCAL_OBJID_TYPE); - for ( i =0; i < OS_MAX_NUM_OPEN_FILES; i++) - { - if (OS_ObjectIdDefined(OS_global_stream_table[i].active_id) && - OS_stream_table[i].socket_domain == OS_SocketDomain_INVALID && - strcmp(OS_stream_table[i].stream_name, old) == 0) - { - strcpy (OS_stream_table[i].stream_name, new); - } - } - OS_Unlock_Global(LOCAL_OBJID_TYPE); + int i; + 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); + if (return_code == OS_SUCCESS) + { + return_code = OS_TranslatePath(new, new_path); + } + + if (return_code == OS_SUCCESS) + { + return_code = OS_FileRename_Impl(old_path, new_path); + } + + if (return_code == OS_SUCCESS) + { + OS_Lock_Global(LOCAL_OBJID_TYPE); + for (i = 0; i < OS_MAX_NUM_OPEN_FILES; i++) + { + if (OS_ObjectIdDefined(OS_global_stream_table[i].active_id) && + OS_stream_table[i].socket_domain == OS_SocketDomain_INVALID && + strcmp(OS_stream_table[i].stream_name, old) == 0) + { + strcpy(OS_stream_table[i].stream_name, new); + } + } + OS_Unlock_Global(LOCAL_OBJID_TYPE); } return return_code; } /* end OS_rename */ - /*---------------------------------------------------------------- * * Function: OS_cp @@ -506,68 +484,67 @@ int32 OS_rename (const char *old, const char *new) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_cp (const char *src, const char *dest) +int32 OS_cp(const char *src, const char *dest) { - int32 return_code; - int32 rd_size; - int32 wr_size; - int32 wr_total; + int32 return_code; + int32 rd_size; + int32 wr_size; + int32 wr_total; osal_id_t file1; osal_id_t file2; - uint8 copyblock[512]; + uint8 copyblock[512]; if (src == NULL || dest == NULL) { return OS_INVALID_POINTER; } - file1 = OS_OBJECT_ID_UNDEFINED; - file2 = OS_OBJECT_ID_UNDEFINED; + file1 = OS_OBJECT_ID_UNDEFINED; + file2 = OS_OBJECT_ID_UNDEFINED; return_code = OS_OpenCreate(&file1, src, OS_FILE_FLAG_NONE, OS_READ_ONLY); if (return_code == OS_SUCCESS) { - return_code = OS_OpenCreate(&file2, dest, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); + return_code = OS_OpenCreate(&file2, dest, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); } while (return_code == OS_SUCCESS) { - rd_size = OS_read(file1, copyblock, sizeof(copyblock)); - if (rd_size < 0) - { - return_code = rd_size; - break; - } - if (rd_size == 0) - { - break; - } - wr_total = 0; - while (wr_total < rd_size) - { - wr_size = OS_write(file2, ©block[wr_total], rd_size - wr_total); - if (wr_size < 0) - { - return_code = wr_size; - break; - } - wr_total += wr_size; - } + rd_size = OS_read(file1, copyblock, sizeof(copyblock)); + if (rd_size < 0) + { + return_code = rd_size; + break; + } + if (rd_size == 0) + { + break; + } + wr_total = 0; + while (wr_total < rd_size) + { + wr_size = OS_write(file2, ©block[wr_total], rd_size - wr_total); + if (wr_size < 0) + { + return_code = wr_size; + break; + } + wr_total += wr_size; + } } if (OS_ObjectIdDefined(file1)) { - OS_close(file1); + OS_close(file1); } if (OS_ObjectIdDefined(file2)) { - OS_close(file2); + OS_close(file2); } return return_code; } /* end OS_cp */ - /*---------------------------------------------------------------- * * Function: OS_mv @@ -576,28 +553,25 @@ int32 OS_cp (const char *src, const char *dest) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_mv (const char *src, const char *dest) +int32 OS_mv(const char *src, const char *dest) { - int32 return_code; + int32 return_code; - /* First try rename - this only works if it is on the same filesystem */ - return_code = OS_rename(src, dest); - if (return_code != OS_SUCCESS) - { - return_code = OS_cp(src, dest); - if (return_code == OS_SUCCESS) - { - OS_remove(src); - } - } + /* First try rename - this only works if it is on the same filesystem */ + return_code = OS_rename(src, dest); + if (return_code != OS_SUCCESS) + { + return_code = OS_cp(src, dest); + if (return_code == OS_SUCCESS) + { + OS_remove(src); + } + } - return (return_code); + return (return_code); } /* end OS_mv */ - - - /*---------------------------------------------------------------- * * Function: OS_FDGetInfo @@ -606,34 +580,33 @@ int32 OS_mv (const char *src, const char *dest) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_FDGetInfo (osal_id_t filedes, OS_file_prop_t *fd_prop) +int32 OS_FDGetInfo(osal_id_t filedes, OS_file_prop_t *fd_prop) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; - - /* Check parameters */ - if (fd_prop == NULL) - { - return(OS_INVALID_POINTER); - } - - memset(fd_prop,0,sizeof(OS_file_prop_t)); - - /* Check Parameters */ - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, filedes, &local_id, &record); - if (return_code == OS_SUCCESS) - { - strncpy(fd_prop->Path, record->name_entry, OS_MAX_PATH_LEN - 1); - fd_prop->User = record->creator; - fd_prop->IsValid = true; - OS_Unlock_Global(LOCAL_OBJID_TYPE); - } - - return return_code; + OS_common_record_t *record; + uint32 local_id; + int32 return_code; -} /* end OS_FDGetInfo */ + /* Check parameters */ + if (fd_prop == NULL) + { + return (OS_INVALID_POINTER); + } + + memset(fd_prop, 0, sizeof(OS_file_prop_t)); + + /* Check Parameters */ + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, filedes, &local_id, &record); + if (return_code == OS_SUCCESS) + { + strncpy(fd_prop->Path, record->name_entry, OS_MAX_PATH_LEN - 1); + fd_prop->User = record->creator; + fd_prop->IsValid = true; + OS_Unlock_Global(LOCAL_OBJID_TYPE); + } + return return_code; + +} /* end OS_FDGetInfo */ /*---------------------------------------------------------------- * @@ -645,36 +618,34 @@ int32 OS_FDGetInfo (osal_id_t filedes, OS_file_prop_t *fd_prop) *-----------------------------------------------------------------*/ int32 OS_FileOpenCheck(const char *Filename) { - int32 return_code; - uint32 i; + int32 return_code; + uint32 i; - if (Filename == NULL) - { - return(OS_INVALID_POINTER); - } + if (Filename == NULL) + { + return (OS_INVALID_POINTER); + } - return_code = OS_ERROR; + return_code = OS_ERROR; - OS_Lock_Global(LOCAL_OBJID_TYPE); + OS_Lock_Global(LOCAL_OBJID_TYPE); - for ( i = 0; i < OS_MAX_NUM_OPEN_FILES; i++) - { - if (OS_ObjectIdDefined(OS_global_stream_table[i].active_id) && + for (i = 0; i < OS_MAX_NUM_OPEN_FILES; i++) + { + if (OS_ObjectIdDefined(OS_global_stream_table[i].active_id) && OS_stream_table[i].socket_domain == OS_SocketDomain_INVALID && (strcmp(OS_stream_table[i].stream_name, Filename) == 0)) - { - return_code = OS_SUCCESS; - break; - } - }/* end for */ + { + return_code = OS_SUCCESS; + break; + } + } /* end for */ - OS_Unlock_Global(LOCAL_OBJID_TYPE); + OS_Unlock_Global(LOCAL_OBJID_TYPE); - return return_code; + return return_code; } /* end OS_FileOpenCheck */ - - /*---------------------------------------------------------------- * * Function: OS_CloseFileByName @@ -685,44 +656,43 @@ int32 OS_FileOpenCheck(const char *Filename) *-----------------------------------------------------------------*/ int32 OS_CloseFileByName(const char *Filename) { - int32 return_code; - int32 close_code; - uint32 i; + int32 return_code; + int32 close_code; + uint32 i; - if (Filename == NULL) - { - return(OS_INVALID_POINTER); - } + if (Filename == NULL) + { + return (OS_INVALID_POINTER); + } - return_code = OS_FS_ERR_PATH_INVALID; + return_code = OS_FS_ERR_PATH_INVALID; - OS_Lock_Global(LOCAL_OBJID_TYPE); + OS_Lock_Global(LOCAL_OBJID_TYPE); - for ( i = 0; i < OS_MAX_NUM_OPEN_FILES; i++) - { - if (OS_ObjectIdDefined(OS_global_stream_table[i].active_id) && + for (i = 0; i < OS_MAX_NUM_OPEN_FILES; i++) + { + if (OS_ObjectIdDefined(OS_global_stream_table[i].active_id) && OS_stream_table[i].socket_domain == OS_SocketDomain_INVALID && (strcmp(OS_stream_table[i].stream_name, Filename) == 0)) - { - close_code = OS_GenericClose_Impl(i); - if (close_code == OS_SUCCESS) - { - OS_global_stream_table[i].active_id = OS_OBJECT_ID_UNDEFINED; - } - if (return_code == OS_FS_ERR_PATH_INVALID || close_code != OS_SUCCESS) - { - return_code = close_code; - } - } - }/* end for */ - - OS_Unlock_Global(LOCAL_OBJID_TYPE); - - return (return_code); + { + close_code = OS_GenericClose_Impl(i); + if (close_code == OS_SUCCESS) + { + OS_global_stream_table[i].active_id = OS_OBJECT_ID_UNDEFINED; + } + if (return_code == OS_FS_ERR_PATH_INVALID || close_code != OS_SUCCESS) + { + return_code = close_code; + } + } + } /* end for */ + + OS_Unlock_Global(LOCAL_OBJID_TYPE); + + return (return_code); } /* end OS_CloseFileByName */ - /*---------------------------------------------------------------- * * Function: OS_CloseAllFiles @@ -733,33 +703,32 @@ int32 OS_CloseFileByName(const char *Filename) *-----------------------------------------------------------------*/ int32 OS_CloseAllFiles(void) { - int32 return_code; - int32 close_code; - uint32 i; - - return_code = OS_SUCCESS; - - OS_Lock_Global(LOCAL_OBJID_TYPE); - - for ( i = 0; i < OS_MAX_NUM_OPEN_FILES; i++) - { - if (OS_ObjectIdDefined(OS_global_stream_table[i].active_id)) - { - close_code = OS_GenericClose_Impl(i); - if (close_code == OS_SUCCESS) - { - OS_global_stream_table[i].active_id = OS_OBJECT_ID_UNDEFINED; - } - if (close_code != OS_SUCCESS) - { - return_code = close_code; - } - } - }/* end for */ - - OS_Unlock_Global(LOCAL_OBJID_TYPE); - - return (return_code); + int32 return_code; + int32 close_code; + uint32 i; -} /* end OS_CloseAllFiles */ + return_code = OS_SUCCESS; + OS_Lock_Global(LOCAL_OBJID_TYPE); + + for (i = 0; i < OS_MAX_NUM_OPEN_FILES; i++) + { + if (OS_ObjectIdDefined(OS_global_stream_table[i].active_id)) + { + close_code = OS_GenericClose_Impl(i); + if (close_code == OS_SUCCESS) + { + OS_global_stream_table[i].active_id = OS_OBJECT_ID_UNDEFINED; + } + if (close_code != OS_SUCCESS) + { + return_code = close_code; + } + } + } /* end for */ + + OS_Unlock_Global(LOCAL_OBJID_TYPE); + + return (return_code); + +} /* end OS_CloseAllFiles */ diff --git a/src/os/shared/src/osapi-filesys.c b/src/os/shared/src/osapi-filesys.c index 27ba47e5c..9179dbd81 100644 --- a/src/os/shared/src/osapi-filesys.c +++ b/src/os/shared/src/osapi-filesys.c @@ -45,11 +45,10 @@ enum { - LOCAL_NUM_OBJECTS = OS_MAX_FILE_SYSTEMS, - LOCAL_OBJID_TYPE = OS_OBJECT_TYPE_OS_FILESYS + LOCAL_NUM_OBJECTS = OS_MAX_FILE_SYSTEMS, + LOCAL_OBJID_TYPE = OS_OBJECT_TYPE_OS_FILESYS }; - /* * Internal filesystem state table entries */ @@ -77,9 +76,9 @@ const char OS_FILESYS_RAMDISK_VOLNAME_PREFIX[] = "RAM"; *-----------------------------------------------------------------*/ bool OS_FileSys_FindVirtMountPoint(void *ref, uint32 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; - size_t mplen; + OS_filesys_internal_record_t *rec = &OS_filesys_table[local_id]; + const char * target = (const char *)ref; + size_t mplen; if ((rec->flags & OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL) == 0) { @@ -91,7 +90,6 @@ bool OS_FileSys_FindVirtMountPoint(void *ref, uint32 local_id, const OS_common_r (target[mplen] == '/' || target[mplen] == 0)); } /* end OS_FileSys_FindVirtMountPoint */ - /*---------------------------------------------------------------- * * Function: OS_FileSys_Initialize @@ -103,31 +101,30 @@ bool OS_FileSys_FindVirtMountPoint(void *ref, uint32 local_id, const OS_common_r * Returns: OS_SUCCESS on creating the disk, or appropriate error code. * *-----------------------------------------------------------------*/ -int32 OS_FileSys_Initialize(char *address, const char *fsdevname, const char * fsvolname, uint32 blocksize, - uint32 numblocks, bool should_format) +int32 OS_FileSys_Initialize(char *address, const char *fsdevname, const char *fsvolname, uint32 blocksize, + uint32 numblocks, bool should_format) { - OS_common_record_t *global; + OS_common_record_t * global; OS_filesys_internal_record_t *local; - int32 return_code; - uint32 local_id; + int32 return_code; + uint32 local_id; /* ** Check parameters */ - if ( fsdevname == NULL || fsvolname == NULL ) + if (fsdevname == NULL || fsvolname == NULL) { return OS_INVALID_POINTER; } /* check names are not empty strings */ - if( fsdevname[0] == 0 || fsvolname[0] == 0) + if (fsdevname[0] == 0 || fsvolname[0] == 0) { return OS_FS_ERR_PATH_INVALID; } /* check names are not excessively long strings */ - if( strlen(fsdevname) >= sizeof(local->device_name) || - strlen(fsvolname) >= sizeof(local->volume_name)) + if (strlen(fsdevname) >= sizeof(local->device_name) || strlen(fsvolname) >= sizeof(local->volume_name)) { return OS_FS_ERR_PATH_TOO_LONG; } @@ -145,20 +142,19 @@ int32 OS_FileSys_Initialize(char *address, const char *fsdevname, const char * f * so the implementation can reference this info if necessary */ local->blocksize = blocksize; local->numblocks = numblocks; - local->address = address; + local->address = address; strcpy(local->volume_name, fsvolname); /* * Determine basic type of filesystem, if not already known * - * if either an address was supplied, or if the volume name + * 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 (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)) + (local->address != NULL || strncmp(local->volume_name, OS_FILESYS_RAMDISK_VOLNAME_PREFIX, + sizeof(OS_FILESYS_RAMDISK_VOLNAME_PREFIX) - 1) == 0)) { local->fstype = OS_FILESYS_TYPE_VOLATILE_DISK; } @@ -190,19 +186,16 @@ int32 OS_FileSys_Initialize(char *address, const char *fsdevname, const char * f /* Check result, finalize record, and unlock global table. */ return_code = OS_ObjectIdFinalizeNew(return_code, global, NULL); - } return return_code; } /* end OS_FileSys_Initialize */ - /**************************************************************************************** INITIALIZATION ***************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_FileSysAPI_Init @@ -219,7 +212,6 @@ int32 OS_FileSysAPI_Init(void) return return_code; } /* end OS_FileSysAPI_Init */ - /*---------------------------------------------------------------- * * Function: OS_FileSysAddFixedMap @@ -230,12 +222,11 @@ int32 OS_FileSysAPI_Init(void) *-----------------------------------------------------------------*/ int32 OS_FileSysAddFixedMap(osal_id_t *filesys_id, const char *phys_path, const char *virt_path) { - OS_common_record_t *global; + OS_common_record_t * global; OS_filesys_internal_record_t *local; - int32 return_code; - uint32 local_id; - const char *dev_name; - + int32 return_code; + uint32 local_id; + const char * dev_name; /* * Validate inputs @@ -245,8 +236,7 @@ int32 OS_FileSysAddFixedMap(osal_id_t *filesys_id, const char *phys_path, const return OS_INVALID_POINTER; } - if (strlen(phys_path) >= OS_MAX_LOCAL_PATH_LEN || - strlen(virt_path) >= OS_MAX_PATH_LEN) + if (strlen(phys_path) >= OS_MAX_LOCAL_PATH_LEN || strlen(virt_path) >= OS_MAX_PATH_LEN) { return OS_ERR_NAME_TOO_LONG; } @@ -276,16 +266,16 @@ int32 OS_FileSysAddFixedMap(osal_id_t *filesys_id, const char *phys_path, const memset(local, 0, sizeof(*local)); global->name_entry = local->device_name; - strncpy(local->device_name, dev_name, sizeof(local->device_name)-1); - 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(local->device_name, dev_name, sizeof(local->device_name) - 1); + 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); /* * mark the entry that it is a fixed disk */ local->fstype = OS_FILESYS_TYPE_FS_BASED; - local->flags = OS_FILESYS_FLAG_IS_FIXED; + local->flags = OS_FILESYS_FLAG_IS_FIXED; /* * The "mount" implementation is required as it will @@ -304,20 +294,16 @@ 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; + local->flags |= OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; } /* Check result, finalize record, and unlock global table. */ return_code = OS_ObjectIdFinalizeNew(return_code, global, filesys_id); - } return return_code; } /* end OS_FileSysAddFixedMap */ - /*---------------------------------------------------------------- * * Function: OS_mkfs @@ -326,15 +312,13 @@ int32 OS_FileSysAddFixedMap(osal_id_t *filesys_id, const char *phys_path, const * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_mkfs (char *address, const char *devname, const char * volname, uint32 blocksize, - uint32 numblocks) +int32 OS_mkfs(char *address, const char *devname, const char *volname, uint32 blocksize, uint32 numblocks) { int32 return_code; return_code = OS_FileSys_Initialize(address, devname, volname, blocksize, numblocks, true); - if (return_code == OS_ERR_INCORRECT_OBJ_STATE || - return_code == OS_ERR_NO_FREE_IDS) + if (return_code == OS_ERR_INCORRECT_OBJ_STATE || return_code == OS_ERR_NO_FREE_IDS) { /* * This is the historic filesystem-specific error code generated when @@ -350,7 +334,6 @@ int32 OS_mkfs (char *address, const char *devname, const char * volname, uint32 } /* end OS_mkfs */ - /*---------------------------------------------------------------- * * Function: OS_rmfs @@ -359,23 +342,23 @@ int32 OS_mkfs (char *address, const char *devname, const char * volname, uint32 * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_rmfs (const char *devname) +int32 OS_rmfs(const char *devname) { - int32 return_code; - uint32 local_id; + int32 return_code; + uint32 local_id; OS_common_record_t *global; - if ( devname == NULL ) + if (devname == NULL) { return OS_INVALID_POINTER; } - if ( strlen(devname) >= OS_MAX_API_NAME ) + if (strlen(devname) >= OS_MAX_API_NAME) { return OS_FS_ERR_PATH_TOO_LONG; } - return_code = OS_ObjectIdGetByName (OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, devname, &global); + return_code = OS_ObjectIdGetByName(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, devname, &global); if (return_code == OS_SUCCESS) { OS_ObjectIdToArrayIndex(LOCAL_OBJID_TYPE, global->active_id, &local_id); @@ -393,8 +376,8 @@ int32 OS_rmfs (const char *devname) /* Free the entry in the master table now while still locked */ if (return_code == OS_SUCCESS) { - /* Only need to clear the ID as zero is the "unused" flag */ - global->active_id = OS_OBJECT_ID_UNDEFINED; + /* Only need to clear the ID as zero is the "unused" flag */ + global->active_id = OS_OBJECT_ID_UNDEFINED; } OS_Unlock_Global(LOCAL_OBJID_TYPE); @@ -407,7 +390,6 @@ int32 OS_rmfs (const char *devname) return return_code; } /* end OS_rmfs */ - /*---------------------------------------------------------------- * * Function: OS_initfs @@ -416,15 +398,13 @@ int32 OS_rmfs (const char *devname) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_initfs (char *address,const char *devname, const char *volname, - uint32 blocksize, uint32 numblocks) +int32 OS_initfs(char *address, const char *devname, const char *volname, uint32 blocksize, uint32 numblocks) { int32 return_code; return_code = OS_FileSys_Initialize(address, devname, volname, blocksize, numblocks, false); - if (return_code == OS_ERR_INCORRECT_OBJ_STATE || - return_code == OS_ERR_NO_FREE_IDS) + if (return_code == OS_ERR_INCORRECT_OBJ_STATE || return_code == OS_ERR_NO_FREE_IDS) { /* * This is the historic filesystem-specific error code generated when @@ -440,7 +420,6 @@ int32 OS_initfs (char *address,const char *devname, const char *volname, } /* end OS_initfs */ - /*---------------------------------------------------------------- * * Function: OS_mount @@ -449,27 +428,25 @@ int32 OS_initfs (char *address,const char *devname, const char *volname, * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_mount (const char *devname, const char* mountpoint) +int32 OS_mount(const char *devname, const char *mountpoint) { - int32 return_code; - uint32 local_id; - OS_common_record_t *global; + int32 return_code; + uint32 local_id; + OS_common_record_t * global; OS_filesys_internal_record_t *local; - /* Check parameters */ - if ( devname == NULL || mountpoint == NULL ) + if (devname == NULL || mountpoint == NULL) { return OS_INVALID_POINTER; } - if( strlen(devname) >= sizeof(local->device_name) || - strlen(mountpoint) >= sizeof(local->virtual_mountpt) ) + if (strlen(devname) >= sizeof(local->device_name) || strlen(mountpoint) >= sizeof(local->virtual_mountpt)) { return OS_FS_ERR_PATH_TOO_LONG; } - return_code = OS_ObjectIdGetByName (OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, devname, &global); + return_code = OS_ObjectIdGetByName(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, devname, &global); if (return_code == OS_SUCCESS) { OS_ObjectIdToArrayIndex(LOCAL_OBJID_TYPE, global->active_id, &local_id); @@ -510,7 +487,6 @@ int32 OS_mount (const char *devname, const char* mountpoint) OS_Unlock_Global(LOCAL_OBJID_TYPE); } - if (return_code != OS_SUCCESS) { return_code = OS_ERR_NAME_NOT_FOUND; @@ -520,7 +496,6 @@ int32 OS_mount (const char *devname, const char* mountpoint) } /* end OS_mount */ - /*---------------------------------------------------------------- * * Function: OS_unmount @@ -529,26 +504,26 @@ int32 OS_mount (const char *devname, const char* mountpoint) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_unmount (const char *mountpoint) +int32 OS_unmount(const char *mountpoint) { - int32 return_code; - uint32 local_id; - OS_common_record_t *global; + int32 return_code; + uint32 local_id; + OS_common_record_t * global; OS_filesys_internal_record_t *local; /* Check parameters */ - if ( mountpoint == NULL ) + if (mountpoint == NULL) { return OS_INVALID_POINTER; } - if( strlen(mountpoint) >= sizeof(local->virtual_mountpt) ) + if (strlen(mountpoint) >= sizeof(local->virtual_mountpt)) { return OS_FS_ERR_PATH_TOO_LONG; } - return_code = OS_ObjectIdGetBySearch(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, - OS_FileSys_FindVirtMountPoint, (void*)mountpoint, &global); + return_code = OS_ObjectIdGetBySearch(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, OS_FileSys_FindVirtMountPoint, + (void *)mountpoint, &global); if (return_code == OS_SUCCESS) { @@ -563,7 +538,7 @@ int32 OS_unmount (const char *mountpoint) * The FIXED flag is not enforced to support abstraction. */ if ((local->flags & ~OS_FILESYS_FLAG_IS_FIXED) != - (OS_FILESYS_FLAG_IS_READY | OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL)) + (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 */ return_code = OS_ERR_INCORRECT_OBJ_STATE; @@ -583,7 +558,6 @@ int32 OS_unmount (const char *mountpoint) OS_Unlock_Global(LOCAL_OBJID_TYPE); } - if (return_code != OS_SUCCESS) { return_code = OS_ERR_NAME_NOT_FOUND; @@ -592,7 +566,6 @@ int32 OS_unmount (const char *mountpoint) return return_code; } /* end OS_unmount */ - /*---------------------------------------------------------------- * * Function: OS_fsBlocksFree @@ -601,25 +574,25 @@ int32 OS_unmount (const char *mountpoint) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_fsBlocksFree (const char *name) +int32 OS_fsBlocksFree(const char *name) { - int32 return_code; - OS_statvfs_t statfs; - uint32 local_id; + int32 return_code; + OS_statvfs_t statfs; + uint32 local_id; OS_common_record_t *global; - if ( name == NULL ) + if (name == NULL) { - return(OS_INVALID_POINTER); + return (OS_INVALID_POINTER); } - if( strlen(name) >= OS_MAX_PATH_LEN ) + if (strlen(name) >= OS_MAX_PATH_LEN) { return OS_FS_ERR_PATH_TOO_LONG; } - return_code = OS_ObjectIdGetBySearch(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, - OS_FileSys_FindVirtMountPoint, (void*)name, &global); + return_code = OS_ObjectIdGetBySearch(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, OS_FileSys_FindVirtMountPoint, + (void *)name, &global); if (return_code == OS_SUCCESS) { @@ -644,7 +617,6 @@ int32 OS_fsBlocksFree (const char *name) } /* end OS_fsBlocksFree */ - /*---------------------------------------------------------------- * * Function: OS_fsBytesFree @@ -653,25 +625,25 @@ int32 OS_fsBlocksFree (const char *name) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_fsBytesFree (const char *name, uint64 *bytes_free) +int32 OS_fsBytesFree(const char *name, uint64 *bytes_free) { - int32 return_code; - OS_statvfs_t statfs; - uint32 local_id; + int32 return_code; + OS_statvfs_t statfs; + uint32 local_id; OS_common_record_t *global; - if ( name == NULL || bytes_free == NULL ) + if (name == NULL || bytes_free == NULL) { - return(OS_INVALID_POINTER); + return (OS_INVALID_POINTER); } - if( strlen(name) >= OS_MAX_PATH_LEN ) + if (strlen(name) >= OS_MAX_PATH_LEN) { return OS_FS_ERR_PATH_TOO_LONG; } - return_code = OS_ObjectIdGetBySearch(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, - OS_FileSys_FindVirtMountPoint, (void*)name, &global); + return_code = OS_ObjectIdGetBySearch(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, OS_FileSys_FindVirtMountPoint, + (void *)name, &global); if (return_code == OS_SUCCESS) { @@ -696,8 +668,6 @@ int32 OS_fsBytesFree (const char *name, uint64 *bytes_free) } /* end OS_fsBytesFree */ - - /*---------------------------------------------------------------- * * Function: OS_chkfs @@ -706,10 +676,10 @@ int32 OS_fsBytesFree (const char *name, uint64 *bytes_free) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_chkfs (const char *name, bool repair) +int32 OS_chkfs(const char *name, bool repair) { - uint32 local_id; - int32 return_code; + uint32 local_id; + int32 return_code; OS_common_record_t *global; /* @@ -723,14 +693,14 @@ int32 OS_chkfs (const char *name, bool repair) /* ** Check the length of the volume name */ - if ( strlen(name) >= OS_MAX_PATH_LEN ) + if (strlen(name) >= OS_MAX_PATH_LEN) { - return(OS_FS_ERR_PATH_TOO_LONG); + return (OS_FS_ERR_PATH_TOO_LONG); } /* Get a reference lock, as a filesystem check could take some time. */ - return_code = OS_ObjectIdGetBySearch(OS_LOCK_MODE_REFCOUNT, LOCAL_OBJID_TYPE, - OS_FileSys_FindVirtMountPoint, (void*)name, &global); + return_code = OS_ObjectIdGetBySearch(OS_LOCK_MODE_REFCOUNT, LOCAL_OBJID_TYPE, OS_FileSys_FindVirtMountPoint, + (void *)name, &global); if (return_code == OS_SUCCESS) { @@ -745,7 +715,6 @@ int32 OS_chkfs (const char *name, bool repair) } /* end OS_chkfs */ - /*---------------------------------------------------------------- * * Function: OS_FS_GetPhysDriveName @@ -754,11 +723,11 @@ int32 OS_chkfs (const char *name, bool repair) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_FS_GetPhysDriveName(char * PhysDriveName, const char * MountPoint) +int32 OS_FS_GetPhysDriveName(char *PhysDriveName, const char *MountPoint) { - uint32 local_id; - int32 return_code; - OS_common_record_t *global; + uint32 local_id; + int32 return_code; + OS_common_record_t * global; OS_filesys_internal_record_t *local; if (MountPoint == NULL || PhysDriveName == NULL) @@ -766,14 +735,14 @@ int32 OS_FS_GetPhysDriveName(char * PhysDriveName, const char * MountPoint) return OS_INVALID_POINTER; } - if( strlen(MountPoint) >= OS_MAX_PATH_LEN ) + if (strlen(MountPoint) >= OS_MAX_PATH_LEN) { return OS_FS_ERR_PATH_TOO_LONG; } /* Get a reference lock, as a filesystem check could take some time. */ - return_code = OS_ObjectIdGetBySearch(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, - OS_FileSys_FindVirtMountPoint, (void*)MountPoint, &global); + return_code = OS_ObjectIdGetBySearch(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, OS_FileSys_FindVirtMountPoint, + (void *)MountPoint, &global); if (return_code == OS_SUCCESS) { @@ -782,8 +751,8 @@ int32 OS_FS_GetPhysDriveName(char * PhysDriveName, const char * MountPoint) if ((local->flags & OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM) != 0) { - strncpy(PhysDriveName, local->system_mountpt, OS_FS_PHYS_NAME_LEN-1); - PhysDriveName[OS_FS_PHYS_NAME_LEN-1] = 0; + strncpy(PhysDriveName, local->system_mountpt, OS_FS_PHYS_NAME_LEN - 1); + PhysDriveName[OS_FS_PHYS_NAME_LEN - 1] = 0; } else { @@ -797,12 +766,9 @@ int32 OS_FS_GetPhysDriveName(char * PhysDriveName, const char * MountPoint) return_code = OS_ERR_NAME_NOT_FOUND; } - return return_code; } /* end OS_FS_GetPhysDriveName */ - - /*---------------------------------------------------------------- * * Function: OS_GetFsInfo @@ -811,51 +777,50 @@ int32 OS_FS_GetPhysDriveName(char * PhysDriveName, const char * MountPoint) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_GetFsInfo(os_fsinfo_t *filesys_info) +int32 OS_GetFsInfo(os_fsinfo_t *filesys_info) { - int i; + int i; - /* - ** Check to see if the file pointers are NULL - */ - if (filesys_info == NULL) - { - return OS_INVALID_POINTER; - } + /* + ** Check to see if the file pointers are NULL + */ + if (filesys_info == NULL) + { + return OS_INVALID_POINTER; + } - memset(filesys_info, 0, sizeof(*filesys_info)); + memset(filesys_info, 0, sizeof(*filesys_info)); - filesys_info->MaxFds = OS_MAX_NUM_OPEN_FILES; - filesys_info->MaxVolumes = OS_MAX_FILE_SYSTEMS; + filesys_info->MaxFds = OS_MAX_NUM_OPEN_FILES; + filesys_info->MaxVolumes = OS_MAX_FILE_SYSTEMS; - OS_Lock_Global(OS_OBJECT_TYPE_OS_STREAM); + OS_Lock_Global(OS_OBJECT_TYPE_OS_STREAM); - for ( i = 0; i < OS_MAX_NUM_OPEN_FILES; i++ ) - { - if ( !OS_ObjectIdDefined(OS_global_stream_table[i].active_id) ) - { - filesys_info->FreeFds++; - } - } + for (i = 0; i < OS_MAX_NUM_OPEN_FILES; i++) + { + if (!OS_ObjectIdDefined(OS_global_stream_table[i].active_id)) + { + filesys_info->FreeFds++; + } + } - OS_Unlock_Global(OS_OBJECT_TYPE_OS_STREAM); + OS_Unlock_Global(OS_OBJECT_TYPE_OS_STREAM); - OS_Lock_Global(OS_OBJECT_TYPE_OS_FILESYS); + OS_Lock_Global(OS_OBJECT_TYPE_OS_FILESYS); - for ( i = 0; i < OS_MAX_FILE_SYSTEMS; i++ ) - { - if ( !OS_ObjectIdDefined(OS_global_filesys_table[i].active_id) ) - { - filesys_info->FreeVolumes++; - } - } + for (i = 0; i < OS_MAX_FILE_SYSTEMS; i++) + { + if (!OS_ObjectIdDefined(OS_global_filesys_table[i].active_id)) + { + filesys_info->FreeVolumes++; + } + } - OS_Unlock_Global(OS_OBJECT_TYPE_OS_FILESYS); + OS_Unlock_Global(OS_OBJECT_TYPE_OS_FILESYS); - return(OS_SUCCESS); + return (OS_SUCCESS); } /* end OS_GetFsInfo */ - /*---------------------------------------------------------------- * * Function: OS_TranslatePath @@ -866,14 +831,14 @@ int32 OS_GetFsInfo(os_fsinfo_t *filesys_info) *-----------------------------------------------------------------*/ int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath) { - uint32 local_id; - int32 return_code; - const char *name_ptr; - OS_common_record_t *global; + uint32 local_id; + int32 return_code; + const char * name_ptr; + OS_common_record_t * global; OS_filesys_internal_record_t *local; - size_t SysMountPointLen; - size_t VirtPathLen; - size_t VirtPathBegin; + size_t SysMountPointLen; + size_t VirtPathLen; + size_t VirtPathBegin; /* ** Check to see if the path pointers are NULL @@ -907,19 +872,19 @@ int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath) } SysMountPointLen = 0; - VirtPathBegin = VirtPathLen; + VirtPathBegin = VirtPathLen; /* ** All valid Virtual paths must start with a '/' character */ - if ( VirtualPath[0] != '/' ) + if (VirtualPath[0] != '/') { - return OS_FS_ERR_PATH_INVALID; + return OS_FS_ERR_PATH_INVALID; } /* Get a reference lock, as a filesystem check could take some time. */ - return_code = OS_ObjectIdGetBySearch(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, - OS_FileSys_FindVirtMountPoint, (void*)VirtualPath, &global); + return_code = OS_ObjectIdGetBySearch(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, OS_FileSys_FindVirtMountPoint, + (void *)VirtualPath, &global); if (return_code != OS_SUCCESS) { @@ -933,7 +898,7 @@ int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath) if ((local->flags & OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM) != 0) { SysMountPointLen = strlen(local->system_mountpt); - VirtPathBegin = strlen(local->virtual_mountpt); + VirtPathBegin = strlen(local->virtual_mountpt); if (SysMountPointLen < OS_MAX_LOCAL_PATH_LEN) { memcpy(LocalPath, local->system_mountpt, SysMountPointLen); @@ -958,7 +923,7 @@ int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath) VirtPathLen -= VirtPathBegin; if ((SysMountPointLen + VirtPathLen) < OS_MAX_LOCAL_PATH_LEN) { - memcpy(&LocalPath[SysMountPointLen],&VirtualPath[VirtPathBegin], VirtPathLen); + memcpy(&LocalPath[SysMountPointLen], &VirtualPath[VirtPathBegin], VirtPathLen); LocalPath[SysMountPointLen + VirtPathLen] = 0; } else @@ -971,4 +936,3 @@ int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath) return return_code; } /* end OS_TranslatePath */ - diff --git a/src/os/shared/src/osapi-heap.c b/src/os/shared/src/osapi-heap.c index dc7c8d298..ed833f814 100644 --- a/src/os/shared/src/osapi-heap.c +++ b/src/os/shared/src/osapi-heap.c @@ -35,14 +35,11 @@ #include #include - /* * User defined include files */ #include "os-shared-heap.h" - - /*---------------------------------------------------------------- * * Function: OS_HeapGetInfo @@ -51,7 +48,7 @@ * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_HeapGetInfo (OS_heap_prop_t *heap_prop) +int32 OS_HeapGetInfo(OS_heap_prop_t *heap_prop) { if (heap_prop == NULL) { @@ -60,4 +57,3 @@ int32 OS_HeapGetInfo (OS_heap_prop_t *heap_prop) return OS_HeapGetInfo_Impl(heap_prop); } /* end OS_HeapGetInfo */ - diff --git a/src/os/shared/src/osapi-idmap.c b/src/os/shared/src/osapi-idmap.c index 0a36db01b..0c0bf1af7 100644 --- a/src/os/shared/src/osapi-idmap.c +++ b/src/os/shared/src/osapi-idmap.c @@ -58,22 +58,21 @@ typedef enum { - OS_TASK_BASE = 0, - OS_QUEUE_BASE = OS_TASK_BASE + OS_MAX_TASKS, - OS_BINSEM_BASE = OS_QUEUE_BASE + OS_MAX_QUEUES, - OS_COUNTSEM_BASE = OS_BINSEM_BASE + OS_MAX_BIN_SEMAPHORES, - OS_MUTEX_BASE = OS_COUNTSEM_BASE + OS_MAX_COUNT_SEMAPHORES, - OS_STREAM_BASE = OS_MUTEX_BASE + OS_MAX_MUTEXES, - OS_DIR_BASE = OS_STREAM_BASE + OS_MAX_NUM_OPEN_FILES, - OS_TIMEBASE_BASE = OS_DIR_BASE + OS_MAX_NUM_OPEN_DIRS, - OS_TIMECB_BASE = OS_TIMEBASE_BASE + OS_MAX_TIMEBASES, - OS_MODULE_BASE = OS_TIMECB_BASE + OS_MAX_TIMERS, - OS_FILESYS_BASE = OS_MODULE_BASE + OS_MAX_MODULES, - OS_CONSOLE_BASE = OS_FILESYS_BASE + OS_MAX_FILE_SYSTEMS, - OS_MAX_TOTAL_RECORDS = OS_CONSOLE_BASE + OS_MAX_CONSOLES + OS_TASK_BASE = 0, + OS_QUEUE_BASE = OS_TASK_BASE + OS_MAX_TASKS, + OS_BINSEM_BASE = OS_QUEUE_BASE + OS_MAX_QUEUES, + OS_COUNTSEM_BASE = OS_BINSEM_BASE + OS_MAX_BIN_SEMAPHORES, + OS_MUTEX_BASE = OS_COUNTSEM_BASE + OS_MAX_COUNT_SEMAPHORES, + OS_STREAM_BASE = OS_MUTEX_BASE + OS_MAX_MUTEXES, + OS_DIR_BASE = OS_STREAM_BASE + OS_MAX_NUM_OPEN_FILES, + OS_TIMEBASE_BASE = OS_DIR_BASE + OS_MAX_NUM_OPEN_DIRS, + OS_TIMECB_BASE = OS_TIMEBASE_BASE + OS_MAX_TIMEBASES, + OS_MODULE_BASE = OS_TIMECB_BASE + OS_MAX_TIMERS, + OS_FILESYS_BASE = OS_MODULE_BASE + OS_MAX_MODULES, + OS_CONSOLE_BASE = OS_FILESYS_BASE + OS_MAX_FILE_SYSTEMS, + OS_MAX_TOTAL_RECORDS = OS_CONSOLE_BASE + OS_MAX_CONSOLES } OS_ObjectIndex_t; - /* * Global ID storage tables */ @@ -92,19 +91,18 @@ typedef struct OS_objtype_state_t OS_objtype_state[OS_OBJECT_TYPE_USER]; - -OS_common_record_t * const OS_global_task_table = &OS_common_table[OS_TASK_BASE]; -OS_common_record_t * const OS_global_queue_table = &OS_common_table[OS_QUEUE_BASE]; -OS_common_record_t * const OS_global_bin_sem_table = &OS_common_table[OS_BINSEM_BASE]; -OS_common_record_t * const OS_global_count_sem_table = &OS_common_table[OS_COUNTSEM_BASE]; -OS_common_record_t * const OS_global_mutex_table = &OS_common_table[OS_MUTEX_BASE]; -OS_common_record_t * const OS_global_stream_table = &OS_common_table[OS_STREAM_BASE]; -OS_common_record_t * const OS_global_dir_table = &OS_common_table[OS_DIR_BASE]; -OS_common_record_t * const OS_global_timebase_table = &OS_common_table[OS_TIMEBASE_BASE]; -OS_common_record_t * const OS_global_timecb_table = &OS_common_table[OS_TIMECB_BASE]; -OS_common_record_t * const OS_global_module_table = &OS_common_table[OS_MODULE_BASE]; -OS_common_record_t * const OS_global_filesys_table = &OS_common_table[OS_FILESYS_BASE]; -OS_common_record_t * const OS_global_console_table = &OS_common_table[OS_CONSOLE_BASE]; +OS_common_record_t *const OS_global_task_table = &OS_common_table[OS_TASK_BASE]; +OS_common_record_t *const OS_global_queue_table = &OS_common_table[OS_QUEUE_BASE]; +OS_common_record_t *const OS_global_bin_sem_table = &OS_common_table[OS_BINSEM_BASE]; +OS_common_record_t *const OS_global_count_sem_table = &OS_common_table[OS_COUNTSEM_BASE]; +OS_common_record_t *const OS_global_mutex_table = &OS_common_table[OS_MUTEX_BASE]; +OS_common_record_t *const OS_global_stream_table = &OS_common_table[OS_STREAM_BASE]; +OS_common_record_t *const OS_global_dir_table = &OS_common_table[OS_DIR_BASE]; +OS_common_record_t *const OS_global_timebase_table = &OS_common_table[OS_TIMEBASE_BASE]; +OS_common_record_t *const OS_global_timecb_table = &OS_common_table[OS_TIMECB_BASE]; +OS_common_record_t *const OS_global_module_table = &OS_common_table[OS_MODULE_BASE]; +OS_common_record_t *const OS_global_filesys_table = &OS_common_table[OS_FILESYS_BASE]; +OS_common_record_t *const OS_global_console_table = &OS_common_table[OS_CONSOLE_BASE]; /* ********************************************************************************* @@ -136,25 +134,37 @@ int32 OS_ObjectIdInit(void) *-----------------------------------------------------------------*/ uint32 OS_GetMaxForObjectType(uint32 idtype) { - switch(idtype) - { - case OS_OBJECT_TYPE_OS_TASK: return OS_MAX_TASKS; - case OS_OBJECT_TYPE_OS_QUEUE: return OS_MAX_QUEUES; - case OS_OBJECT_TYPE_OS_BINSEM: return OS_MAX_BIN_SEMAPHORES; - case OS_OBJECT_TYPE_OS_COUNTSEM: return OS_MAX_COUNT_SEMAPHORES; - case OS_OBJECT_TYPE_OS_MUTEX: return OS_MAX_MUTEXES; - case OS_OBJECT_TYPE_OS_STREAM: return OS_MAX_NUM_OPEN_FILES; - case OS_OBJECT_TYPE_OS_DIR: return OS_MAX_NUM_OPEN_DIRS; - case OS_OBJECT_TYPE_OS_TIMEBASE: return OS_MAX_TIMEBASES; - case OS_OBJECT_TYPE_OS_TIMECB: return OS_MAX_TIMERS; - case OS_OBJECT_TYPE_OS_MODULE: return OS_MAX_MODULES; - case OS_OBJECT_TYPE_OS_FILESYS: return OS_MAX_FILE_SYSTEMS; - case OS_OBJECT_TYPE_OS_CONSOLE: return OS_MAX_CONSOLES; - default: return 0; - } + switch (idtype) + { + case OS_OBJECT_TYPE_OS_TASK: + return OS_MAX_TASKS; + case OS_OBJECT_TYPE_OS_QUEUE: + return OS_MAX_QUEUES; + case OS_OBJECT_TYPE_OS_BINSEM: + return OS_MAX_BIN_SEMAPHORES; + case OS_OBJECT_TYPE_OS_COUNTSEM: + return OS_MAX_COUNT_SEMAPHORES; + case OS_OBJECT_TYPE_OS_MUTEX: + return OS_MAX_MUTEXES; + case OS_OBJECT_TYPE_OS_STREAM: + return OS_MAX_NUM_OPEN_FILES; + case OS_OBJECT_TYPE_OS_DIR: + return OS_MAX_NUM_OPEN_DIRS; + case OS_OBJECT_TYPE_OS_TIMEBASE: + return OS_MAX_TIMEBASES; + case OS_OBJECT_TYPE_OS_TIMECB: + return OS_MAX_TIMERS; + case OS_OBJECT_TYPE_OS_MODULE: + return OS_MAX_MODULES; + case OS_OBJECT_TYPE_OS_FILESYS: + return OS_MAX_FILE_SYSTEMS; + case OS_OBJECT_TYPE_OS_CONSOLE: + return OS_MAX_CONSOLES; + default: + return 0; + } } /* end OS_GetMaxForObjectType */ - /*---------------------------------------------------------------- * * Function: OS_GetBaseForObjectType @@ -164,22 +174,35 @@ uint32 OS_GetMaxForObjectType(uint32 idtype) *-----------------------------------------------------------------*/ uint32 OS_GetBaseForObjectType(uint32 idtype) { - switch(idtype) - { - case OS_OBJECT_TYPE_OS_TASK: return OS_TASK_BASE; - case OS_OBJECT_TYPE_OS_QUEUE: return OS_QUEUE_BASE; - case OS_OBJECT_TYPE_OS_BINSEM: return OS_BINSEM_BASE; - case OS_OBJECT_TYPE_OS_COUNTSEM: return OS_COUNTSEM_BASE; - case OS_OBJECT_TYPE_OS_MUTEX: return OS_MUTEX_BASE; - case OS_OBJECT_TYPE_OS_STREAM: return OS_STREAM_BASE; - case OS_OBJECT_TYPE_OS_DIR: return OS_DIR_BASE; - case OS_OBJECT_TYPE_OS_TIMEBASE: return OS_TIMEBASE_BASE; - case OS_OBJECT_TYPE_OS_TIMECB: return OS_TIMECB_BASE; - case OS_OBJECT_TYPE_OS_MODULE: return OS_MODULE_BASE; - case OS_OBJECT_TYPE_OS_FILESYS: return OS_FILESYS_BASE; - case OS_OBJECT_TYPE_OS_CONSOLE: return OS_CONSOLE_BASE; - default: return 0; - } + switch (idtype) + { + case OS_OBJECT_TYPE_OS_TASK: + return OS_TASK_BASE; + case OS_OBJECT_TYPE_OS_QUEUE: + return OS_QUEUE_BASE; + case OS_OBJECT_TYPE_OS_BINSEM: + return OS_BINSEM_BASE; + case OS_OBJECT_TYPE_OS_COUNTSEM: + return OS_COUNTSEM_BASE; + case OS_OBJECT_TYPE_OS_MUTEX: + return OS_MUTEX_BASE; + case OS_OBJECT_TYPE_OS_STREAM: + return OS_STREAM_BASE; + case OS_OBJECT_TYPE_OS_DIR: + return OS_DIR_BASE; + case OS_OBJECT_TYPE_OS_TIMEBASE: + return OS_TIMEBASE_BASE; + case OS_OBJECT_TYPE_OS_TIMECB: + return OS_TIMECB_BASE; + case OS_OBJECT_TYPE_OS_MODULE: + return OS_MODULE_BASE; + case OS_OBJECT_TYPE_OS_FILESYS: + return OS_FILESYS_BASE; + case OS_OBJECT_TYPE_OS_CONSOLE: + return OS_CONSOLE_BASE; + default: + return 0; + } } /* end OS_GetBaseForObjectType */ /************************************************************** @@ -187,7 +210,6 @@ uint32 OS_GetBaseForObjectType(uint32 idtype) * (not used outside of this unit) **************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_ObjectNameMatch @@ -204,11 +226,9 @@ uint32 OS_GetBaseForObjectType(uint32 idtype) *-----------------------------------------------------------------*/ bool OS_ObjectNameMatch(void *ref, uint32 local_id, const OS_common_record_t *obj) { - return (obj->name_entry != NULL && - strcmp((const char*)ref, obj->name_entry) == 0); + return (obj->name_entry != NULL && strcmp((const char *)ref, obj->name_entry) == 0); } /* end OS_ObjectNameMatch */ - /*---------------------------------------------------------------- * * Function: OS_ObjectIdInitiateLock @@ -233,7 +253,6 @@ void OS_ObjectIdInitiateLock(OS_lock_mode_t lock_mode, uint32 idtype) } } /* end OS_ObjectIdInitiateLock */ - /*---------------------------------------------------------------- * * Function: OS_ObjectIdConvertLock @@ -274,11 +293,11 @@ void OS_ObjectIdInitiateLock(OS_lock_mode_t lock_mode, uint32 idtype) *-----------------------------------------------------------------*/ int32 OS_ObjectIdConvertLock(OS_lock_mode_t lock_mode, uint32 idtype, osal_id_t reference_id, OS_common_record_t *obj) { - int32 return_code = OS_ERROR; + int32 return_code = OS_ERROR; uint32 exclusive_bits = 0; - uint32 attempts = 0; + uint32 attempts = 0; - while(true) + while (true) { /* Validate the integrity of the ID. As the "active_id" is a single * integer, we can do this check regardless of whether global is locked or not. */ @@ -335,7 +354,6 @@ int32 OS_ObjectIdConvertLock(OS_lock_mode_t lock_mode, uint32 idtype, osal_id_t break; } - /* * If we get this far, it means there is contention for access to the object. * a) we want to increment refcount but an exclusive is pending @@ -378,8 +396,7 @@ int32 OS_ObjectIdConvertLock(OS_lock_mode_t lock_mode, uint32 idtype, osal_id_t * style lock. For other styles (GLOBAL or EXCLUSIVE) the global lock * should be maintained and returned to the caller. */ - if (return_code != OS_SUCCESS || - lock_mode == OS_LOCK_MODE_REFCOUNT) + if (return_code != OS_SUCCESS || lock_mode == OS_LOCK_MODE_REFCOUNT) { OS_Unlock_Global(idtype); } @@ -405,15 +422,15 @@ int32 OS_ObjectIdConvertLock(OS_lock_mode_t lock_mode, uint32 idtype, osal_id_t *-----------------------------------------------------------------*/ int32 OS_ObjectIdSearch(uint32 idtype, OS_ObjectMatchFunc_t MatchFunc, void *arg, OS_common_record_t **record) { - int32 return_code; - uint32 obj_count; - uint32 local_id; + int32 return_code; + uint32 obj_count; + uint32 local_id; OS_common_record_t *obj; return_code = OS_ERR_NAME_NOT_FOUND; - obj = &OS_common_table[OS_GetBaseForObjectType(idtype)]; - obj_count = OS_GetMaxForObjectType(idtype); - local_id = 0; + obj = &OS_common_table[OS_GetBaseForObjectType(idtype)]; + obj_count = OS_GetMaxForObjectType(idtype); + local_id = 0; while (true) { @@ -424,8 +441,7 @@ int32 OS_ObjectIdSearch(uint32 idtype, OS_ObjectMatchFunc_t MatchFunc, void *arg } --obj_count; - if ( OS_ObjectIdDefined(obj->active_id) && - MatchFunc(arg, local_id, obj)) + if (OS_ObjectIdDefined(obj->active_id) && MatchFunc(arg, local_id, obj)) { return_code = OS_SUCCESS; break; @@ -461,76 +477,75 @@ int32 OS_ObjectIdSearch(uint32 idtype, OS_ObjectMatchFunc_t MatchFunc, void *arg *-----------------------------------------------------------------*/ int32 OS_ObjectIdFindNext(uint32 idtype, uint32 *array_index, OS_common_record_t **record) { - uint32 max_id; - uint32 base_id; - uint32 local_id = 0; - uint32 idvalue; - uint32 i; - int32 return_code; - OS_common_record_t *obj = NULL; - - base_id = OS_GetBaseForObjectType(idtype); - max_id = OS_GetMaxForObjectType(idtype); - - if (max_id == 0) - { - /* if the max id is zero, then this build of OSAL - * does not include any support for that object type. - * Return the "not implemented" to differentiate between - * this case vs. running out of valid slots */ - return_code = OS_ERR_NOT_IMPLEMENTED; - idvalue = 0; - } - else - { - return_code = OS_ERR_NO_FREE_IDS; - idvalue = OS_ObjectIdToSerialNumber_Impl(OS_objtype_state[idtype].last_id_issued); - } - - for (i = 0; i < max_id; ++i) - { - local_id = (++idvalue) % max_id; - if (idvalue >= OS_OBJECT_INDEX_MASK) - { - /* reset to beginning of ID space */ - idvalue = local_id; - } - obj = &OS_common_table[local_id + base_id]; - if (!OS_ObjectIdDefined(obj->active_id)) - { - return_code = OS_SUCCESS; - break; - } - } - - if(return_code == OS_SUCCESS) - { - OS_ObjectIdCompose_Impl(idtype, idvalue, &obj->active_id); - - /* Ensure any data in the record has been cleared */ - obj->name_entry = NULL; - obj->creator = OS_TaskGetId(); - obj->refcount = 0; - } - - if(return_code != OS_SUCCESS) - { - obj = NULL; - local_id = 0; - } - - if (array_index != NULL) - { - *array_index = local_id; - } - if (record != NULL) - { - *record = obj; - } - - return return_code; -} /* end OS_ObjectIdFindNext */ + uint32 max_id; + uint32 base_id; + uint32 local_id = 0; + uint32 idvalue; + uint32 i; + int32 return_code; + OS_common_record_t *obj = NULL; + + base_id = OS_GetBaseForObjectType(idtype); + max_id = OS_GetMaxForObjectType(idtype); + + if (max_id == 0) + { + /* if the max id is zero, then this build of OSAL + * does not include any support for that object type. + * Return the "not implemented" to differentiate between + * this case vs. running out of valid slots */ + return_code = OS_ERR_NOT_IMPLEMENTED; + idvalue = 0; + } + else + { + return_code = OS_ERR_NO_FREE_IDS; + idvalue = OS_ObjectIdToSerialNumber_Impl(OS_objtype_state[idtype].last_id_issued); + } + + for (i = 0; i < max_id; ++i) + { + local_id = (++idvalue) % max_id; + if (idvalue >= OS_OBJECT_INDEX_MASK) + { + /* reset to beginning of ID space */ + idvalue = local_id; + } + obj = &OS_common_table[local_id + base_id]; + if (!OS_ObjectIdDefined(obj->active_id)) + { + return_code = OS_SUCCESS; + break; + } + } + + if (return_code == OS_SUCCESS) + { + OS_ObjectIdCompose_Impl(idtype, idvalue, &obj->active_id); + + /* Ensure any data in the record has been cleared */ + obj->name_entry = NULL; + obj->creator = OS_TaskGetId(); + obj->refcount = 0; + } + + if (return_code != OS_SUCCESS) + { + obj = NULL; + local_id = 0; + } + + if (array_index != NULL) + { + *array_index = local_id; + } + if (record != NULL) + { + *record = obj; + } + return return_code; +} /* end OS_ObjectIdFindNext */ /* ********************************************************************************* @@ -548,13 +563,13 @@ int32 OS_ObjectIdFindNext(uint32 idtype, uint32 *array_index, OS_common_record_t ------------------------------------------------------------------*/ void OS_Lock_Global(uint32 idtype) { - int32 return_code; - osal_id_t self_task_id; + int32 return_code; + osal_id_t self_task_id; OS_objtype_state_t *objtype; if (idtype < OS_OBJECT_TYPE_USER) { - objtype = &OS_objtype_state[idtype]; + objtype = &OS_objtype_state[idtype]; self_task_id = OS_TaskGetId_Impl(); return_code = OS_Lock_Global_Impl(idtype); @@ -568,7 +583,7 @@ void OS_Lock_Global(uint32 idtype) * This is done after successfully locking, so this has exclusive access * to the state object. */ - if ( !OS_ObjectIdDefined(self_task_id) ) + if (!OS_ObjectIdDefined(self_task_id)) { /* * This just means the calling context is not an OSAL-created task. @@ -578,13 +593,12 @@ void OS_Lock_Global(uint32 idtype) self_task_id = OS_OBJECT_ID_RESERVED; /* nonzero, but also won't alias a known task */ } - if ( OS_ObjectIdDefined(objtype->table_owner) ) + if (OS_ObjectIdDefined(objtype->table_owner)) { /* this is almost certainly a bug */ OS_DEBUG("ERROR: global %u acquired by task 0x%lx when already owned by task 0x%lx\n", - (unsigned int)idtype, - OS_ObjectIdToInteger(self_task_id), - OS_ObjectIdToInteger(objtype->table_owner)); + (unsigned int)idtype, OS_ObjectIdToInteger(self_task_id), + OS_ObjectIdToInteger(objtype->table_owner)); } else { @@ -610,13 +624,13 @@ void OS_Lock_Global(uint32 idtype) ------------------------------------------------------------------*/ void OS_Unlock_Global(uint32 idtype) { - int32 return_code; - osal_id_t self_task_id; + int32 return_code; + osal_id_t self_task_id; OS_objtype_state_t *objtype; if (idtype < OS_OBJECT_TYPE_USER) { - objtype = &OS_objtype_state[idtype]; + objtype = &OS_objtype_state[idtype]; self_task_id = OS_TaskGetId_Impl(); /* @@ -627,7 +641,7 @@ void OS_Unlock_Global(uint32 idtype) * This is done before unlocking, while this has exclusive access * to the state object. */ - if ( !OS_ObjectIdDefined(self_task_id) ) + if (!OS_ObjectIdDefined(self_task_id)) { /* * This just means the calling context is not an OSAL-created task. @@ -637,13 +651,11 @@ void OS_Unlock_Global(uint32 idtype) self_task_id = OS_OBJECT_ID_RESERVED; /* nonzero, but also won't alias a known task */ } - if ( !OS_ObjectIdEqual(objtype->table_owner, self_task_id) ) + if (!OS_ObjectIdEqual(objtype->table_owner, self_task_id)) { /* this is almost certainly a bug */ - OS_DEBUG("ERROR: global %u released by task 0x%lx when owned by task 0x%lx\n", - (unsigned int)idtype, - OS_ObjectIdToInteger(self_task_id), - OS_ObjectIdToInteger(objtype->table_owner)); + OS_DEBUG("ERROR: global %u released by task 0x%lx when owned by task 0x%lx\n", (unsigned int)idtype, + OS_ObjectIdToInteger(self_task_id), OS_ObjectIdToInteger(objtype->table_owner)); } else { @@ -683,7 +695,7 @@ void OS_Unlock_Global(uint32 idtype) *-----------------------------------------------------------------*/ int32 OS_ObjectIdFinalizeNew(int32 operation_status, OS_common_record_t *record, osal_id_t *outid) { - uint32 idtype = OS_ObjectIdToType_Impl(record->active_id); + uint32 idtype = OS_ObjectIdToType_Impl(record->active_id); osal_id_t callback_id; /* if operation was unsuccessful, then clear @@ -700,7 +712,7 @@ int32 OS_ObjectIdFinalizeNew(int32 operation_status, OS_common_record_t *record, else if (idtype == 0 || idtype >= OS_OBJECT_TYPE_USER) { /* should never happen - indicates a bug. */ - operation_status = OS_ERR_INVALID_ID; + operation_status = OS_ERR_INVALID_ID; record->active_id = OS_OBJECT_ID_UNDEFINED; } else @@ -738,13 +750,13 @@ int32 OS_ObjectIdFinalizeNew(int32 operation_status, OS_common_record_t *record, ------------------------------------------------------------------*/ int32 OS_ObjectIdFinalizeDelete(int32 operation_status, OS_common_record_t *record) { - uint32 idtype = OS_ObjectIdToType_Impl(record->active_id); + uint32 idtype = OS_ObjectIdToType_Impl(record->active_id); osal_id_t callback_id; /* Clear the OSAL ID if successful - this returns the record to the pool */ if (operation_status == OS_SUCCESS) { - callback_id = record->active_id; + callback_id = record->active_id; record->active_id = OS_OBJECT_ID_UNDEFINED; } else @@ -764,7 +776,6 @@ int32 OS_ObjectIdFinalizeDelete(int32 operation_status, OS_common_record_t *reco return operation_status; } - /*---------------------------------------------------------------- * * Function: OS_ObjectIdGetBySearch @@ -779,9 +790,10 @@ int32 OS_ObjectIdFinalizeDelete(int32 operation_status, OS_common_record_t *reco * returns: OS_ERR_NAME_NOT_FOUND if not found, OS_SUCCESS if match is found * *-----------------------------------------------------------------*/ -int32 OS_ObjectIdGetBySearch(OS_lock_mode_t lock_mode, uint32 idtype, OS_ObjectMatchFunc_t MatchFunc, void *arg, OS_common_record_t **record) +int32 OS_ObjectIdGetBySearch(OS_lock_mode_t lock_mode, uint32 idtype, OS_ObjectMatchFunc_t MatchFunc, void *arg, + OS_common_record_t **record) { - int32 return_code; + int32 return_code; OS_common_record_t *obj; OS_ObjectIdInitiateLock(lock_mode, idtype); @@ -810,7 +822,6 @@ int32 OS_ObjectIdGetBySearch(OS_lock_mode_t lock_mode, uint32 idtype, OS_ObjectM return return_code; } /* end OS_ObjectIdGetBySearch */ - /*---------------------------------------------------------------- * * Function: OS_ObjectIdGetByName @@ -825,9 +836,9 @@ int32 OS_ObjectIdGetBySearch(OS_lock_mode_t lock_mode, uint32 idtype, OS_ObjectM * returns: OS_ERR_NAME_NOT_FOUND if not found, OS_SUCCESS if match is found * *-----------------------------------------------------------------*/ -int32 OS_ObjectIdGetByName (OS_lock_mode_t lock_mode, uint32 idtype, const char *name, OS_common_record_t **record) +int32 OS_ObjectIdGetByName(OS_lock_mode_t lock_mode, uint32 idtype, const char *name, OS_common_record_t **record) { - return OS_ObjectIdGetBySearch(lock_mode, idtype, OS_ObjectNameMatch, (void*)name, record); + return OS_ObjectIdGetBySearch(lock_mode, idtype, OS_ObjectNameMatch, (void *)name, record); } /* end OS_ObjectIdGetByName */ @@ -842,9 +853,9 @@ int32 OS_ObjectIdGetByName (OS_lock_mode_t lock_mode, uint32 idtype, const char * returns: OS_ERR_NAME_NOT_FOUND if not found, OS_SUCCESS if match is found * *-----------------------------------------------------------------*/ -int32 OS_ObjectIdFindByName (uint32 idtype, const char *name, osal_id_t *object_id) +int32 OS_ObjectIdFindByName(uint32 idtype, const char *name, osal_id_t *object_id) { - int32 return_code; + int32 return_code; OS_common_record_t *global; /* @@ -873,8 +884,6 @@ int32 OS_ObjectIdFindByName (uint32 idtype, const char *name, osal_id_t *object_ } /* end OS_ObjectIdFindByName */ - - /*---------------------------------------------------------------- * * Function: OS_ObjectIdGetById @@ -891,50 +900,47 @@ int32 OS_ObjectIdFindByName (uint32 idtype, const char *name, osal_id_t *object_ * If this returns something other than OS_SUCCESS then the global is NOT locked. * *-----------------------------------------------------------------*/ -int32 OS_ObjectIdGetById(OS_lock_mode_t lock_mode, uint32 idtype, osal_id_t id, uint32 *array_index, OS_common_record_t **record) +int32 OS_ObjectIdGetById(OS_lock_mode_t lock_mode, uint32 idtype, osal_id_t id, uint32 *array_index, + OS_common_record_t **record) { - int32 return_code; - - if (OS_SharedGlobalVars.Initialized == false) - { - return OS_ERROR; - } - - /* - * Special case to allow only OS_LOCK_MODE_EXCLUSIVE during shutdowns - * (This is the lock mode used to delete objects) - */ - if (OS_SharedGlobalVars.ShutdownFlag == OS_SHUTDOWN_MAGIC_NUMBER && - lock_mode != OS_LOCK_MODE_EXCLUSIVE) - { - return OS_ERR_INCORRECT_OBJ_STATE; - } - - - return_code = OS_ObjectIdToArrayIndex(idtype, id, array_index); - if (return_code != OS_SUCCESS) - { - return return_code; - } - - - *record = &OS_common_table[*array_index + OS_GetBaseForObjectType(idtype)]; - - OS_ObjectIdInitiateLock(lock_mode, idtype); - - /* - * The "ConvertLock" routine will return with the global lock - * in a state appropriate for returning to the caller, as indicated - * by the "check_mode" paramter. - * - * Note If this operation fails, then it always unlocks the global for - * all check_mode's other than NONE. - */ - return_code = OS_ObjectIdConvertLock(lock_mode, idtype, id, *record); - - return return_code; -} /* end OS_ObjectIdGetById */ + int32 return_code; + if (OS_SharedGlobalVars.Initialized == false) + { + return OS_ERROR; + } + + /* + * Special case to allow only OS_LOCK_MODE_EXCLUSIVE during shutdowns + * (This is the lock mode used to delete objects) + */ + if (OS_SharedGlobalVars.ShutdownFlag == OS_SHUTDOWN_MAGIC_NUMBER && lock_mode != OS_LOCK_MODE_EXCLUSIVE) + { + return OS_ERR_INCORRECT_OBJ_STATE; + } + + return_code = OS_ObjectIdToArrayIndex(idtype, id, array_index); + if (return_code != OS_SUCCESS) + { + return return_code; + } + + *record = &OS_common_table[*array_index + OS_GetBaseForObjectType(idtype)]; + + OS_ObjectIdInitiateLock(lock_mode, idtype); + + /* + * The "ConvertLock" routine will return with the global lock + * in a state appropriate for returning to the caller, as indicated + * by the "check_mode" paramter. + * + * Note If this operation fails, then it always unlocks the global for + * all check_mode's other than NONE. + */ + return_code = OS_ObjectIdConvertLock(lock_mode, idtype, id, *record); + + return return_code; +} /* end OS_ObjectIdGetById */ /*---------------------------------------------------------------- * @@ -949,31 +955,31 @@ int32 OS_ObjectIdGetById(OS_lock_mode_t lock_mode, uint32 idtype, osal_id_t id, *-----------------------------------------------------------------*/ int32 OS_ObjectIdRefcountDecr(OS_common_record_t *record) { - int32 return_code; - uint32 idtype = OS_ObjectIdToType_Impl(record->active_id); - - if (idtype == 0 || !OS_ObjectIdDefined(record->active_id)) - { - return_code = OS_ERR_INVALID_ID; - } - else - { - OS_Lock_Global(idtype); - - if (record->refcount > 0) - { - --record->refcount; - return_code = OS_SUCCESS; - } - else - { - return_code = OS_ERR_INCORRECT_OBJ_STATE; - } - - OS_Unlock_Global(idtype); - } - - return return_code; + int32 return_code; + uint32 idtype = OS_ObjectIdToType_Impl(record->active_id); + + if (idtype == 0 || !OS_ObjectIdDefined(record->active_id)) + { + return_code = OS_ERR_INVALID_ID; + } + else + { + OS_Lock_Global(idtype); + + if (record->refcount > 0) + { + --record->refcount; + return_code = OS_SUCCESS; + } + else + { + return_code = OS_ERR_INCORRECT_OBJ_STATE; + } + + OS_Unlock_Global(idtype); + } + + return return_code; } /* end OS_ObjectIdRefcountDecr */ /*---------------------------------------------------------------- @@ -1008,56 +1014,55 @@ int32 OS_ObjectIdRefcountDecr(OS_common_record_t *record) *-----------------------------------------------------------------*/ int32 OS_ObjectIdAllocateNew(uint32 idtype, const char *name, uint32 *array_index, OS_common_record_t **record) { - int32 return_code; - - if (OS_SharedGlobalVars.Initialized == false || - OS_SharedGlobalVars.ShutdownFlag == OS_SHUTDOWN_MAGIC_NUMBER) - { - return OS_ERROR; - } - - if (idtype >= OS_OBJECT_TYPE_USER) - { - return OS_ERR_INCORRECT_OBJ_TYPE; - } - - OS_Lock_Global(idtype); - - /* - * Check if an object of the same name already exits. - * If so, a new object cannot be allocated. - */ - if (name != NULL) - { - return_code = OS_ObjectIdSearch(idtype, OS_ObjectNameMatch, (void*)name, record); - } - else - { - return_code = OS_ERR_NAME_NOT_FOUND; - } - - if (return_code == OS_SUCCESS) - { - return_code = OS_ERR_NAME_TAKEN; - } - else - { - return_code = OS_ObjectIdFindNext(idtype, array_index, record); - } - - if (return_code == OS_SUCCESS) - { - return_code = OS_NotifyEvent(OS_EVENT_RESOURCE_ALLOCATED, (*record)->active_id, NULL); - } - - /* If allocation failed for any reason, unlock the global. - * otherwise the global should stay locked so remaining initialization can be done */ - if (return_code != OS_SUCCESS) - { - OS_Unlock_Global(idtype); - } - - return return_code; + int32 return_code; + + if (OS_SharedGlobalVars.Initialized == false || OS_SharedGlobalVars.ShutdownFlag == OS_SHUTDOWN_MAGIC_NUMBER) + { + return OS_ERROR; + } + + if (idtype >= OS_OBJECT_TYPE_USER) + { + return OS_ERR_INCORRECT_OBJ_TYPE; + } + + OS_Lock_Global(idtype); + + /* + * Check if an object of the same name already exits. + * If so, a new object cannot be allocated. + */ + if (name != NULL) + { + return_code = OS_ObjectIdSearch(idtype, OS_ObjectNameMatch, (void *)name, record); + } + else + { + return_code = OS_ERR_NAME_NOT_FOUND; + } + + if (return_code == OS_SUCCESS) + { + return_code = OS_ERR_NAME_TAKEN; + } + else + { + return_code = OS_ObjectIdFindNext(idtype, array_index, record); + } + + if (return_code == OS_SUCCESS) + { + return_code = OS_NotifyEvent(OS_EVENT_RESOURCE_ALLOCATED, (*record)->active_id, NULL); + } + + /* If allocation failed for any reason, unlock the global. + * otherwise the global should stay locked so remaining initialization can be done */ + if (return_code != OS_SUCCESS) + { + OS_Unlock_Global(idtype); + } + + return return_code; } /* end OS_ObjectIdAllocateNew */ /* @@ -1080,7 +1085,6 @@ int32 OS_ConvertToArrayIndex(osal_id_t object_id, uint32 *ArrayIndex) return OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_UNDEFINED, object_id, ArrayIndex); } /* end OS_ConvertToArrayIndex */ - /*---------------------------------------------------------------- * * Function: OS_ForEachObject @@ -1089,7 +1093,7 @@ int32 OS_ConvertToArrayIndex(osal_id_t object_id, uint32 *ArrayIndex) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -void OS_ForEachObject (osal_id_t creator_id, OS_ArgCallback_t callback_ptr, void *callback_arg) +void OS_ForEachObject(osal_id_t creator_id, OS_ArgCallback_t callback_ptr, void *callback_arg) { uint32 idtype; @@ -1107,10 +1111,10 @@ void OS_ForEachObject (osal_id_t creator_id, OS_ArgCallback_t callback_ptr, void * See description in API and header file for detail * *-----------------------------------------------------------------*/ -void OS_ForEachObjectOfType (uint32 idtype, osal_id_t creator_id, OS_ArgCallback_t callback_ptr, void *callback_arg) +void OS_ForEachObjectOfType(uint32 idtype, osal_id_t creator_id, OS_ArgCallback_t callback_ptr, void *callback_arg) { - uint32 obj_index; - uint32 obj_max; + uint32 obj_index; + uint32 obj_max; osal_id_t obj_id; obj_max = OS_GetMaxForObjectType(idtype); @@ -1125,9 +1129,8 @@ void OS_ForEachObjectOfType (uint32 idtype, osal_id_t creator_id, OS_ArgCall * the specified creator_id */ obj_id = OS_common_table[obj_index].active_id; - if (OS_ObjectIdDefined(obj_id) && - !OS_ObjectIdEqual(creator_id, OS_OBJECT_CREATOR_ANY) && - !OS_ObjectIdEqual(OS_common_table[obj_index].creator, creator_id)) + if (OS_ObjectIdDefined(obj_id) && !OS_ObjectIdEqual(creator_id, OS_OBJECT_CREATOR_ANY) && + !OS_ObjectIdEqual(OS_common_table[obj_index].creator, creator_id)) { /* valid object but not a creator match - * skip the callback for this object */ @@ -1167,7 +1170,7 @@ void OS_ForEachObjectOfType (uint32 idtype, osal_id_t creator_id, OS_ArgCall * See description in API and header file for detail * *-----------------------------------------------------------------*/ -uint32 OS_IdentifyObject (osal_id_t object_id) +uint32 OS_IdentifyObject(osal_id_t object_id) { return OS_ObjectIdToType_Impl(object_id); } /* end OS_IdentifyObject */ @@ -1182,11 +1185,11 @@ uint32 OS_IdentifyObject (osal_id_t object_id) *-----------------------------------------------------------------*/ int32 OS_GetResourceName(osal_id_t object_id, char *buffer, uint32 buffer_size) { - uint32 idtype; + uint32 idtype; OS_common_record_t *record; - int32 return_code; - uint32 name_len; - uint32 local_id; + int32 return_code; + uint32 name_len; + uint32 local_id; /* sanity check the passed-in buffer and size */ if (buffer == NULL || buffer_size == 0) @@ -1201,7 +1204,7 @@ int32 OS_GetResourceName(osal_id_t object_id, char *buffer, uint32 buffer_size) */ buffer[0] = 0; - idtype = OS_ObjectIdToType_Impl(object_id); + idtype = OS_ObjectIdToType_Impl(object_id); return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, idtype, object_id, &local_id, &record); if (return_code == OS_SUCCESS) { @@ -1212,7 +1215,7 @@ int32 OS_GetResourceName(osal_id_t object_id, char *buffer, uint32 buffer_size) { /* indicates the name does not fit into supplied buffer */ return_code = OS_ERR_NAME_TOO_LONG; - name_len = buffer_size - 1; + name_len = buffer_size - 1; } memcpy(buffer, record->name_entry, name_len); buffer[name_len] = 0; @@ -1223,7 +1226,6 @@ int32 OS_GetResourceName(osal_id_t object_id, char *buffer, uint32 buffer_size) return return_code; } /* end OS_GetResourceName */ - /*---------------------------------------------------------------- * * Function: OS_ObjectIdToArrayIndex @@ -1241,37 +1243,35 @@ int32 OS_GetResourceName(osal_id_t object_id, char *buffer, uint32 buffer_size) *-----------------------------------------------------------------*/ int32 OS_ObjectIdToArrayIndex(uint32 idtype, osal_id_t object_id, uint32 *ArrayIndex) { - uint32 max_id; - uint32 obj_index; - uint32 actual_type; - int32 return_code; - - obj_index = OS_ObjectIdToSerialNumber_Impl(object_id); - actual_type = OS_ObjectIdToType_Impl(object_id); - - /* - * If requested by the caller, enforce that the ID is of the correct type. - * If the caller passed OS_OBJECT_TYPE_UNDEFINED, then anything is allowed. - */ - if (idtype != OS_OBJECT_TYPE_UNDEFINED && actual_type != idtype) - { - return_code = OS_ERR_INVALID_ID; - } - else - { - max_id = OS_GetMaxForObjectType(actual_type); - if (max_id == 0) - { - return_code = OS_ERR_INVALID_ID; - } - else - { - return_code = OS_SUCCESS; - *ArrayIndex = obj_index % max_id; - } - } - - return return_code; -} /* end OS_ObjectIdToArrayIndex */ + uint32 max_id; + uint32 obj_index; + uint32 actual_type; + int32 return_code; + obj_index = OS_ObjectIdToSerialNumber_Impl(object_id); + actual_type = OS_ObjectIdToType_Impl(object_id); + /* + * If requested by the caller, enforce that the ID is of the correct type. + * If the caller passed OS_OBJECT_TYPE_UNDEFINED, then anything is allowed. + */ + if (idtype != OS_OBJECT_TYPE_UNDEFINED && actual_type != idtype) + { + return_code = OS_ERR_INVALID_ID; + } + else + { + max_id = OS_GetMaxForObjectType(actual_type); + if (max_id == 0) + { + return_code = OS_ERR_INVALID_ID; + } + else + { + return_code = OS_SUCCESS; + *ArrayIndex = obj_index % max_id; + } + } + + return return_code; +} /* end OS_ObjectIdToArrayIndex */ diff --git a/src/os/shared/src/osapi-module.c b/src/os/shared/src/osapi-module.c index ac46c62d2..8b690e7d4 100644 --- a/src/os/shared/src/osapi-module.c +++ b/src/os/shared/src/osapi-module.c @@ -52,11 +52,10 @@ #error "osconfig.h must define OS_MAX_MODULES to a valid value" #endif - enum { - LOCAL_NUM_OBJECTS = OS_MAX_MODULES, - LOCAL_OBJID_TYPE = OS_OBJECT_TYPE_OS_MODULE + LOCAL_NUM_OBJECTS = OS_MAX_MODULES, + LOCAL_OBJID_TYPE = OS_OBJECT_TYPE_OS_MODULE }; OS_module_internal_record_t OS_module_table[OS_MAX_MODULES]; @@ -72,7 +71,7 @@ OS_module_internal_record_t OS_module_table[OS_MAX_MODULES]; */ #if !defined(OS_STATIC_SYMTABLE_SOURCE) && defined(OSAL_CONFIG_INCLUDE_STATIC_LOADER) /* use default symbol name for static table */ -#define OS_STATIC_SYMTABLE_SOURCE OS_STATIC_SYMBOL_TABLE +#define OS_STATIC_SYMTABLE_SOURCE OS_STATIC_SYMBOL_TABLE #endif #ifdef OS_STATIC_SYMTABLE_SOURCE @@ -80,7 +79,7 @@ OS_module_internal_record_t OS_module_table[OS_MAX_MODULES]; extern OS_static_symbol_record_t OS_STATIC_SYMTABLE_SOURCE[]; #else /* there is no static symbol table, use NULL */ -#define OS_STATIC_SYMTABLE_SOURCE NULL +#define OS_STATIC_SYMTABLE_SOURCE NULL #endif /* OS_STATIC_SYMTABLE_SOURCE */ /*---------------------------------------------------------------- @@ -93,8 +92,8 @@ extern OS_static_symbol_record_t OS_STATIC_SYMTABLE_SOURCE[]; *-----------------------------------------------------------------*/ int32 OS_SymbolLookup_Static(cpuaddr *SymbolAddress, const char *SymbolName) { - int32 return_code = OS_ERR_NOT_IMPLEMENTED; - OS_static_symbol_record_t *StaticSym = OS_STATIC_SYMTABLE_SOURCE; + int32 return_code = OS_ERR_NOT_IMPLEMENTED; + OS_static_symbol_record_t *StaticSym = OS_STATIC_SYMTABLE_SOURCE; while (StaticSym != NULL) { @@ -110,7 +109,7 @@ int32 OS_SymbolLookup_Static(cpuaddr *SymbolAddress, const char *SymbolName) { /* found matching symbol */ *SymbolAddress = (cpuaddr)StaticSym->Address; - return_code = OS_SUCCESS; + return_code = OS_SUCCESS; break; } @@ -120,7 +119,6 @@ int32 OS_SymbolLookup_Static(cpuaddr *SymbolAddress, const char *SymbolName) return return_code; } /* end OS_SymbolLookup_Static */ - /*---------------------------------------------------------------- * * Function: OS_ModuleLoad_Static @@ -131,8 +129,8 @@ int32 OS_SymbolLookup_Static(cpuaddr *SymbolAddress, const char *SymbolName) *-----------------------------------------------------------------*/ int32 OS_ModuleLoad_Static(const char *ModuleName) { - int32 return_code = OS_ERR_NAME_NOT_FOUND; - OS_static_symbol_record_t *StaticSym = OS_STATIC_SYMTABLE_SOURCE; + int32 return_code = OS_ERR_NAME_NOT_FOUND; + OS_static_symbol_record_t *StaticSym = OS_STATIC_SYMTABLE_SOURCE; while (StaticSym != NULL) { @@ -141,8 +139,7 @@ int32 OS_ModuleLoad_Static(const char *ModuleName) /* end of list */ break; } - if (StaticSym->Module != NULL && - strcmp(StaticSym->Module, ModuleName) == 0) + if (StaticSym->Module != NULL && strcmp(StaticSym->Module, ModuleName) == 0) { /* found matching module name */ return_code = OS_SUCCESS; @@ -159,7 +156,6 @@ int32 OS_ModuleLoad_Static(const char *ModuleName) Module API ***************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_ModuleAPI_Init @@ -170,11 +166,10 @@ int32 OS_ModuleLoad_Static(const char *ModuleName) *-----------------------------------------------------------------*/ int32 OS_ModuleAPI_Init(void) { - memset(OS_module_table, 0, sizeof(OS_module_table)); - return OS_SUCCESS; + memset(OS_module_table, 0, sizeof(OS_module_table)); + return OS_SUCCESS; } /* end OS_ModuleAPI_Init */ - /*---------------------------------------------------------------- * * Function: OS_ModuleLoad @@ -183,12 +178,12 @@ int32 OS_ModuleAPI_Init(void) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleLoad ( osal_id_t *module_id, const char *module_name, const char *filename ) +int32 OS_ModuleLoad(osal_id_t *module_id, const char *module_name, const char *filename) { - char translated_path[OS_MAX_LOCAL_PATH_LEN]; - int32 return_code; - int32 filename_status; - uint32 local_id; + char translated_path[OS_MAX_LOCAL_PATH_LEN]; + int32 return_code; + int32 filename_status; + uint32 local_id; OS_common_record_t *record; /* @@ -197,14 +192,14 @@ int32 OS_ModuleLoad ( osal_id_t *module_id, const char *module_name, const char ** Note "filename" is not checked, because in certain configurations it can be validly ** null. filename is checked for NULL-ness by the OS_TranslatePath() later. */ - if ((module_id == NULL ) || (module_name == NULL)) + if ((module_id == NULL) || (module_name == NULL)) { - return(OS_INVALID_POINTER); + return (OS_INVALID_POINTER); } if (strlen(module_name) >= OS_MAX_API_NAME) { - return(OS_ERR_NAME_TOO_LONG); + return (OS_ERR_NAME_TOO_LONG); } /* @@ -220,7 +215,7 @@ int32 OS_ModuleLoad ( osal_id_t *module_id, const char *module_name, const char /* Note - the common ObjectIdAllocate routine will lock the object type and leave it locked. */ return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, module_name, &local_id, &record); - if(return_code == OS_SUCCESS) + if (return_code == OS_SUCCESS) { memset(&OS_module_table[local_id], 0, sizeof(OS_module_internal_record_t)); strncpy(OS_module_table[local_id].module_name, module_name, OS_MAX_API_NAME); @@ -263,7 +258,7 @@ int32 OS_ModuleLoad ( osal_id_t *module_id, const char *module_name, const char return_code = OS_ObjectIdFinalizeNew(return_code, record, module_id); } - return(return_code); + return (return_code); } /* end OS_ModuleLoad */ @@ -275,13 +270,13 @@ int32 OS_ModuleLoad ( osal_id_t *module_id, const char *module_name, const char * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleUnload ( osal_id_t module_id ) +int32 OS_ModuleUnload(osal_id_t module_id) { OS_common_record_t *record; - int32 return_code; - uint32 local_id; + int32 return_code; + uint32 local_id; - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE,LOCAL_OBJID_TYPE, module_id, &local_id, &record); + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, module_id, &local_id, &record); if (return_code == OS_SUCCESS) { /* @@ -304,11 +299,11 @@ int32 OS_ModuleUnload ( osal_id_t module_id ) * 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_prop) { OS_common_record_t *record; - int32 return_code; - uint32 local_id; + int32 return_code; + uint32 local_id; /* Check parameters */ if (module_prop == NULL) @@ -316,9 +311,9 @@ int32 OS_ModuleInfo ( osal_id_t module_id, OS_module_prop_t *module_prop ) return OS_INVALID_POINTER; } - memset(module_prop,0,sizeof(OS_module_prop_t)); + memset(module_prop, 0, sizeof(OS_module_prop_t)); - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL,LOCAL_OBJID_TYPE, module_id, &local_id, &record); + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, module_id, &local_id, &record); if (return_code == OS_SUCCESS) { strncpy(module_prop->name, record->name_entry, OS_MAX_API_NAME - 1); @@ -333,7 +328,6 @@ int32 OS_ModuleInfo ( osal_id_t module_id, OS_module_prop_t *module_prop ) } /* end OS_ModuleInfo */ - /*---------------------------------------------------------------- * * Function: OS_SymbolLookup @@ -342,7 +336,7 @@ int32 OS_ModuleInfo ( osal_id_t module_id, OS_module_prop_t *module_prop ) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_SymbolLookup( cpuaddr *SymbolAddress, const char *SymbolName ) +int32 OS_SymbolLookup(cpuaddr *SymbolAddress, const char *SymbolName) { int32 return_code; int32 status; @@ -350,9 +344,9 @@ int32 OS_SymbolLookup( cpuaddr *SymbolAddress, const char *SymbolName ) /* ** Check parameters */ - if (( SymbolAddress == NULL ) || (SymbolName == NULL )) + if ((SymbolAddress == NULL) || (SymbolName == NULL)) { - return(OS_INVALID_POINTER); + return (OS_INVALID_POINTER); } /* @@ -378,8 +372,7 @@ int32 OS_SymbolLookup( cpuaddr *SymbolAddress, const char *SymbolName ) * If either of these are implemented then the returned * value should be OS_ERROR for a not-found result. */ - if (status == OS_SUCCESS || - return_code == OS_ERR_NOT_IMPLEMENTED) + if (status == OS_SUCCESS || return_code == OS_ERR_NOT_IMPLEMENTED) { return_code = status; } @@ -397,29 +390,28 @@ int32 OS_SymbolLookup( cpuaddr *SymbolAddress, const char *SymbolName ) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_SymbolTableDump ( const char *filename, uint32 SizeLimit ) +int32 OS_SymbolTableDump(const char *filename, uint32 SizeLimit) { int32 return_code; - char translated_path[OS_MAX_LOCAL_PATH_LEN]; + char translated_path[OS_MAX_LOCAL_PATH_LEN]; /* ** Check parameters */ if (filename == NULL) { - return(OS_INVALID_POINTER); + return (OS_INVALID_POINTER); } /* ** Translate the filename to the Host System */ return_code = OS_TranslatePath(filename, translated_path); - if ( return_code != OS_SUCCESS ) + if (return_code != OS_SUCCESS) { - return(return_code); + return (return_code); } - /* * Locking the global ensures only one symbol table dump * can be executing. It also prevents module loading/unloading @@ -435,9 +427,6 @@ int32 OS_SymbolTableDump ( const char *filename, uint32 SizeLimit ) OS_Unlock_Global(LOCAL_OBJID_TYPE); - return(return_code); + return (return_code); } /* end OS_SymbolTableDump */ - - - diff --git a/src/os/shared/src/osapi-mutex.c b/src/os/shared/src/osapi-mutex.c index f33ff7fad..53a52a377 100644 --- a/src/os/shared/src/osapi-mutex.c +++ b/src/os/shared/src/osapi-mutex.c @@ -35,14 +35,12 @@ #include #include - /* * User defined include files */ #include "os-shared-idmap.h" #include "os-shared-mutex.h" - /* * Sanity checks on the user-supplied configuration * The relevent OS_MAX limit should be defined and greater than zero @@ -56,12 +54,11 @@ */ enum { - LOCAL_NUM_OBJECTS = OS_MAX_MUTEXES, - LOCAL_OBJID_TYPE = OS_OBJECT_TYPE_OS_MUTEX + LOCAL_NUM_OBJECTS = OS_MAX_MUTEXES, + LOCAL_OBJID_TYPE = OS_OBJECT_TYPE_OS_MUTEX }; -OS_mutex_internal_record_t OS_mutex_table [LOCAL_NUM_OBJECTS]; - +OS_mutex_internal_record_t OS_mutex_table[LOCAL_NUM_OBJECTS]; /**************************************************************************************** MUTEX API @@ -77,11 +74,10 @@ OS_mutex_internal_record_t OS_mutex_table [LOCAL_NUM_OBJECTS]; *-----------------------------------------------------------------*/ int32 OS_MutexAPI_Init(void) { - memset(OS_mutex_table, 0, sizeof(OS_mutex_table)); - return OS_SUCCESS; + memset(OS_mutex_table, 0, sizeof(OS_mutex_table)); + return OS_SUCCESS; } /* end OS_MutexAPI_Init */ - /*---------------------------------------------------------------- * * Function: OS_MutSemCreate @@ -90,39 +86,39 @@ int32 OS_MutexAPI_Init(void) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemCreate (osal_id_t *sem_id, const char *sem_name, uint32 options) +int32 OS_MutSemCreate(osal_id_t *sem_id, const char *sem_name, uint32 options) { - OS_common_record_t *record; - int32 return_code; - uint32 local_id; - - /* Check for NULL pointers */ - if (sem_id == NULL || sem_name == NULL) - { - return OS_INVALID_POINTER; - } - - if ( strlen (sem_name) >= OS_MAX_API_NAME ) - { - return OS_ERR_NAME_TOO_LONG; - } - - /* Note - the common ObjectIdAllocate routine will lock the object type and leave it locked. */ - return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, sem_name, &local_id, &record); - if(return_code == OS_SUCCESS) - { - /* Save all the data to our own internal table */ - strcpy(OS_mutex_table[local_id].obj_name, sem_name); - record->name_entry = OS_mutex_table[local_id].obj_name; - - /* Now call the OS-specific implementation. This reads info from the table. */ - return_code = OS_MutSemCreate_Impl(local_id, options); - - /* Check result, finalize record, and unlock global table. */ - return_code = OS_ObjectIdFinalizeNew(return_code, record, sem_id); - } - - return return_code; + OS_common_record_t *record; + int32 return_code; + uint32 local_id; + + /* Check for NULL pointers */ + if (sem_id == NULL || sem_name == NULL) + { + return OS_INVALID_POINTER; + } + + if (strlen(sem_name) >= OS_MAX_API_NAME) + { + return OS_ERR_NAME_TOO_LONG; + } + + /* Note - the common ObjectIdAllocate routine will lock the object type and leave it locked. */ + return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, sem_name, &local_id, &record); + if (return_code == OS_SUCCESS) + { + /* Save all the data to our own internal table */ + strcpy(OS_mutex_table[local_id].obj_name, sem_name); + record->name_entry = OS_mutex_table[local_id].obj_name; + + /* Now call the OS-specific implementation. This reads info from the table. */ + return_code = OS_MutSemCreate_Impl(local_id, options); + + /* Check result, finalize record, and unlock global table. */ + return_code = OS_ObjectIdFinalizeNew(return_code, record, sem_id); + } + + return return_code; } /* end OS_MutSemCreate */ @@ -134,26 +130,25 @@ int32 OS_MutSemCreate (osal_id_t *sem_id, const char *sem_name, uint32 options) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemDelete (osal_id_t sem_id) +int32 OS_MutSemDelete(osal_id_t sem_id) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; + OS_common_record_t *record; + uint32 local_id; + int32 return_code; - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - return_code = OS_MutSemDelete_Impl(local_id); + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + return_code = OS_MutSemDelete_Impl(local_id); - /* Complete the operation via the common routine */ - return_code = OS_ObjectIdFinalizeDelete(return_code, record); - } + /* Complete the operation via the common routine */ + return_code = OS_ObjectIdFinalizeDelete(return_code, record); + } - return return_code; + return return_code; } /* end OS_MutSemDelete */ - /*---------------------------------------------------------------- * * Function: OS_MutSemGive @@ -162,24 +157,23 @@ int32 OS_MutSemDelete (osal_id_t sem_id) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemGive ( osal_id_t sem_id ) +int32 OS_MutSemGive(osal_id_t sem_id) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; + OS_common_record_t *record; + uint32 local_id; + int32 return_code; /* Check Parameters */ return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); if (return_code == OS_SUCCESS) { - return_code = OS_MutSemGive_Impl (local_id); + return_code = OS_MutSemGive_Impl(local_id); } return return_code; } /* end OS_MutSemGive */ - /*---------------------------------------------------------------- * * Function: OS_MutSemTake @@ -188,17 +182,17 @@ int32 OS_MutSemGive ( osal_id_t sem_id ) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemTake ( osal_id_t sem_id ) +int32 OS_MutSemTake(osal_id_t sem_id) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; + OS_common_record_t *record; + uint32 local_id; + int32 return_code; /* Check Parameters */ return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); if (return_code == OS_SUCCESS) { - return_code = OS_MutSemTake_Impl (local_id); + return_code = OS_MutSemTake_Impl(local_id); } return return_code; @@ -213,22 +207,21 @@ int32 OS_MutSemTake ( osal_id_t sem_id ) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemGetIdByName (osal_id_t *sem_id, const char *sem_name) +int32 OS_MutSemGetIdByName(osal_id_t *sem_id, const char *sem_name) { - int32 return_code; + int32 return_code; - if (sem_id == NULL || sem_name == NULL) - { - return OS_INVALID_POINTER; - } + if (sem_id == NULL || sem_name == NULL) + { + return OS_INVALID_POINTER; + } - return_code = OS_ObjectIdFindByName(LOCAL_OBJID_TYPE, sem_name, sem_id); + return_code = OS_ObjectIdFindByName(LOCAL_OBJID_TYPE, sem_name, sem_id); - return return_code; + return return_code; } /* end OS_MutSemGetIdByName */ - /*---------------------------------------------------------------- * * Function: OS_MutSemGetInfo @@ -237,33 +230,31 @@ int32 OS_MutSemGetIdByName (osal_id_t *sem_id, const char *sem_name) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemGetInfo (osal_id_t sem_id, OS_mut_sem_prop_t *mut_prop) +int32 OS_MutSemGetInfo(osal_id_t sem_id, OS_mut_sem_prop_t *mut_prop) { - OS_common_record_t *record; - int32 return_code; - uint32 local_id; + OS_common_record_t *record; + int32 return_code; + uint32 local_id; - /* Check parameters */ - if (mut_prop == NULL) - { - return OS_INVALID_POINTER; - } + /* Check parameters */ + if (mut_prop == NULL) + { + return OS_INVALID_POINTER; + } - memset(mut_prop,0,sizeof(OS_mut_sem_prop_t)); + memset(mut_prop, 0, sizeof(OS_mut_sem_prop_t)); - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL,LOCAL_OBJID_TYPE, sem_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - strncpy(mut_prop->name, record->name_entry, OS_MAX_API_NAME - 1); - mut_prop->creator = record->creator; + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, sem_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + strncpy(mut_prop->name, record->name_entry, OS_MAX_API_NAME - 1); + mut_prop->creator = record->creator; - return_code = OS_MutSemGetInfo_Impl(local_id, mut_prop); + return_code = OS_MutSemGetInfo_Impl(local_id, mut_prop); - OS_Unlock_Global(LOCAL_OBJID_TYPE); - } + OS_Unlock_Global(LOCAL_OBJID_TYPE); + } - return return_code; + return return_code; } /* end OS_MutSemGetInfo */ - - diff --git a/src/os/shared/src/osapi-network.c b/src/os/shared/src/osapi-network.c index 20bc99b97..3864288e3 100644 --- a/src/os/shared/src/osapi-network.c +++ b/src/os/shared/src/osapi-network.c @@ -34,13 +34,11 @@ #include #include - /* * User defined include files */ #include "os-shared-network.h" - /**************************************************************************************** NETWORK API ***************************************************************************************/ @@ -57,8 +55,6 @@ int32 OS_NetworkAPI_Init(void) return OS_SUCCESS; } /* end OS_NetworkAPI_Init */ - - /*---------------------------------------------------------------- * * Function: OS_NetworkGetHostName @@ -67,36 +63,33 @@ int32 OS_NetworkAPI_Init(void) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_NetworkGetHostName (char *host_name, uint32 name_len) +int32 OS_NetworkGetHostName(char *host_name, uint32 name_len) { - uint32 return_code; + uint32 return_code; - if ( host_name == NULL) - { - return_code = OS_INVALID_POINTER; - } - else if ( name_len == 0 ) - { - return_code = OS_ERROR; - } - else - { - /* delegate to low-level API */ - return_code = OS_NetworkGetHostName_Impl(host_name, name_len); - - if (return_code != OS_SUCCESS) - { - /* return an empty string on failure, just in case */ - host_name[0] = 0; - } - } + if (host_name == NULL) + { + return_code = OS_INVALID_POINTER; + } + else if (name_len == 0) + { + return_code = OS_ERROR; + } + else + { + /* delegate to low-level API */ + return_code = OS_NetworkGetHostName_Impl(host_name, name_len); + + if (return_code != OS_SUCCESS) + { + /* return an empty string on failure, just in case */ + host_name[0] = 0; + } + } - return(return_code); + return (return_code); } /* end OS_NetworkGetHostName */ - - - /*---------------------------------------------------------------- * * Function: OS_NetworkGetID @@ -105,7 +98,7 @@ int32 OS_NetworkGetHostName (char *host_name, uint32 name_len) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_NetworkGetID (void) +int32 OS_NetworkGetID(void) { int32 IdBuf; @@ -119,5 +112,3 @@ int32 OS_NetworkGetID (void) return IdBuf; } /* end OS_NetworkGetID */ - - diff --git a/src/os/shared/src/osapi-printf.c b/src/os/shared/src/osapi-printf.c index 81c4ef625..e420dfeab 100644 --- a/src/os/shared/src/osapi-printf.c +++ b/src/os/shared/src/osapi-printf.c @@ -48,7 +48,6 @@ #include #include - /* * User defined include files */ @@ -56,12 +55,11 @@ #include "os-shared-idmap.h" #include "os-shared-printf.h" - /* reserve buffer memory for the printf console device */ static char OS_printf_buffer_mem[(sizeof(OS_PRINTF_CONSOLE_NAME) + OS_BUFFER_SIZE) * OS_BUFFER_MSG_DEPTH]; /* The global console state table */ -OS_console_internal_record_t OS_console_table[OS_MAX_CONSOLES]; +OS_console_internal_record_t OS_console_table[OS_MAX_CONSOLES]; /* ********************************************************************************* @@ -69,7 +67,6 @@ OS_console_internal_record_t OS_console_table[OS_MAX_CONSOLES]; ********************************************************************************* */ - /*---------------------------------------------------------------- * * Function: OS_ConsoleAPI_Init @@ -80,13 +77,12 @@ OS_console_internal_record_t OS_console_table[OS_MAX_CONSOLES]; int32 OS_ConsoleAPI_Init(void) { OS_console_internal_record_t *console; - int32 return_code; - uint32 local_id; - OS_common_record_t *record; + int32 return_code; + uint32 local_id; + OS_common_record_t * record; memset(&OS_console_table, 0, sizeof(OS_console_table)); - /* * Configure a console device to be used for OS_printf() calls. */ @@ -96,8 +92,8 @@ int32 OS_ConsoleAPI_Init(void) console = &OS_console_table[local_id]; record->name_entry = console->device_name; - strncpy(console->device_name, OS_PRINTF_CONSOLE_NAME, sizeof(console->device_name)-1); - console->device_name[sizeof(console->device_name)-1] = 0; + strncpy(console->device_name, OS_PRINTF_CONSOLE_NAME, sizeof(console->device_name) - 1); + console->device_name[sizeof(console->device_name) - 1] = 0; /* * Initialize the ring buffer pointers @@ -144,11 +140,11 @@ int32 OS_ConsoleAPI_Init(void) static int32 OS_Console_CopyOut(OS_console_internal_record_t *console, const char *Str, uint32 *NextWritePos) { const char *pmsg; - uint32 WriteOffset; - int32 return_code; + uint32 WriteOffset; + int32 return_code; return_code = OS_ERROR; - pmsg = Str; + pmsg = Str; WriteOffset = *NextWritePos; while (true) { @@ -156,11 +152,11 @@ static int32 OS_Console_CopyOut(OS_console_internal_record_t *console, const cha { /* String is complete */ *NextWritePos = WriteOffset; - return_code = OS_SUCCESS; + return_code = OS_SUCCESS; break; } console->BufBase[WriteOffset] = *pmsg; - WriteOffset = WriteOffset + 1; + WriteOffset = WriteOffset + 1; if (WriteOffset >= console->BufSize) { WriteOffset = 0; @@ -185,7 +181,6 @@ static int32 OS_Console_CopyOut(OS_console_internal_record_t *console, const cha ********************************************************************************* */ - /*---------------------------------------------------------------- * * Function: OS_ConsoleWrite @@ -196,11 +191,11 @@ static int32 OS_Console_CopyOut(OS_console_internal_record_t *console, const cha *-----------------------------------------------------------------*/ int32 OS_ConsoleWrite(osal_id_t console_id, const char *Str) { - int32 return_code; - OS_common_record_t *record; - uint32 local_id; + int32 return_code; + OS_common_record_t * record; + uint32 local_id; OS_console_internal_record_t *console; - uint32 PendingWritePos; + uint32 PendingWritePos; return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, OS_OBJECT_TYPE_OS_CONSOLE, console_id, &local_id, &record); if (return_code == OS_SUCCESS) @@ -246,12 +241,9 @@ int32 OS_ConsoleWrite(osal_id_t console_id, const char *Str) OS_Unlock_Global(OS_OBJECT_TYPE_OS_CONSOLE); } - return return_code; } /* end OS_ConsoleWrite */ - - /*---------------------------------------------------------------- * * Function: OS_printf @@ -260,13 +252,13 @@ int32 OS_ConsoleWrite(osal_id_t console_id, const char *Str) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -void OS_printf( const char *String, ...) +void OS_printf(const char *String, ...) { va_list va; - char msg_buffer [OS_BUFFER_SIZE]; - int actualsz; + char msg_buffer[OS_BUFFER_SIZE]; + int actualsz; - if ( !OS_SharedGlobalVars.Initialized ) + if (!OS_SharedGlobalVars.Initialized) { /* * Catch some historical mis-use of the OS_printf() call. @@ -287,13 +279,13 @@ void OS_printf( const char *String, ...) */ OS_DEBUG("BUG: OS_printf() called before init: %s", String); } - else if ( OS_SharedGlobalVars.PrintfEnabled ) + else if (OS_SharedGlobalVars.PrintfEnabled) { /* * Call vsnprintf() to determine the actual size of the * string we are going to write to the buffer after formatting. */ - va_start(va,String); + va_start(va, String); actualsz = vsnprintf(msg_buffer, sizeof(msg_buffer), String, va); va_end(va); @@ -305,7 +297,7 @@ void OS_printf( const char *String, ...) else if (actualsz >= OS_BUFFER_SIZE) { /* truncate */ - actualsz = OS_BUFFER_SIZE-1; + actualsz = OS_BUFFER_SIZE - 1; } msg_buffer[actualsz] = 0; @@ -315,7 +307,6 @@ void OS_printf( const char *String, ...) } /* end OS_printf */ - /*---------------------------------------------------------------- * * Function: OS_printf_disable @@ -326,10 +317,9 @@ void OS_printf( const char *String, ...) *-----------------------------------------------------------------*/ void OS_printf_disable(void) { - OS_SharedGlobalVars.PrintfEnabled = false; + OS_SharedGlobalVars.PrintfEnabled = false; } /* end OS_printf_disable */ - /*---------------------------------------------------------------- * * Function: OS_printf_enable @@ -340,6 +330,5 @@ void OS_printf_disable(void) *-----------------------------------------------------------------*/ void OS_printf_enable(void) { - OS_SharedGlobalVars.PrintfEnabled = true; + OS_SharedGlobalVars.PrintfEnabled = true; } /* end OS_printf_enable */ - diff --git a/src/os/shared/src/osapi-queue.c b/src/os/shared/src/osapi-queue.c index 36f838361..9400f0f3b 100644 --- a/src/os/shared/src/osapi-queue.c +++ b/src/os/shared/src/osapi-queue.c @@ -39,7 +39,6 @@ #include #include - /* * User defined include files */ @@ -54,16 +53,13 @@ #error "osconfig.h must define OS_MAX_QUEUES to a valid value" #endif - - enum { - LOCAL_NUM_OBJECTS = OS_MAX_QUEUES, - LOCAL_OBJID_TYPE = OS_OBJECT_TYPE_OS_QUEUE + LOCAL_NUM_OBJECTS = OS_MAX_QUEUES, + LOCAL_OBJID_TYPE = OS_OBJECT_TYPE_OS_QUEUE }; -OS_queue_internal_record_t OS_queue_table [LOCAL_NUM_OBJECTS]; - +OS_queue_internal_record_t OS_queue_table[LOCAL_NUM_OBJECTS]; /**************************************************************************************** MESSAGE QUEUE API @@ -79,12 +75,10 @@ OS_queue_internal_record_t OS_queue_table [LOCAL_NUM_OBJECTS]; *-----------------------------------------------------------------*/ int32 OS_QueueAPI_Init(void) { - memset(OS_queue_table, 0, sizeof(OS_queue_table)); - return OS_SUCCESS; + memset(OS_queue_table, 0, sizeof(OS_queue_table)); + return OS_SUCCESS; } /* end OS_QueueAPI_Init */ - - /*---------------------------------------------------------------- * * Function: OS_QueueCreate @@ -93,50 +87,48 @@ int32 OS_QueueAPI_Init(void) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_QueueCreate (osal_id_t *queue_id, const char *queue_name, uint32 queue_depth, uint32 data_size, uint32 flags) +int32 OS_QueueCreate(osal_id_t *queue_id, const char *queue_name, uint32 queue_depth, uint32 data_size, uint32 flags) { - OS_common_record_t *record; - int32 return_code; - uint32 local_id; - - if ( queue_name == NULL || queue_id == NULL ) - { - return OS_INVALID_POINTER; - } - - if ( strlen (queue_name) >= OS_MAX_API_NAME ) - { - return OS_ERR_NAME_TOO_LONG; - } - - if ( queue_depth > OS_QUEUE_MAX_DEPTH ) - { - return OS_QUEUE_INVALID_SIZE; - } - - /* Note - the common ObjectIdAllocate routine will lock the object type and leave it locked. */ - return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, queue_name, &local_id, &record); - if(return_code == OS_SUCCESS) - { - /* Save all the data to our own internal queue table */ - strcpy(OS_queue_table[local_id].queue_name, queue_name); - record->name_entry = OS_queue_table[local_id].queue_name; - OS_queue_table[local_id].max_depth = queue_depth; - OS_queue_table[local_id].max_size = data_size; - - - /* Now call the OS-specific implementation. This reads info from the queue table. */ - return_code = OS_QueueCreate_Impl(local_id, flags); - - /* Check result, finalize record, and unlock global table. */ - return_code = OS_ObjectIdFinalizeNew(return_code, record, queue_id); - } - - return return_code; + OS_common_record_t *record; + int32 return_code; + uint32 local_id; + + if (queue_name == NULL || queue_id == NULL) + { + return OS_INVALID_POINTER; + } + + if (strlen(queue_name) >= OS_MAX_API_NAME) + { + return OS_ERR_NAME_TOO_LONG; + } + + if (queue_depth > OS_QUEUE_MAX_DEPTH) + { + return OS_QUEUE_INVALID_SIZE; + } + + /* Note - the common ObjectIdAllocate routine will lock the object type and leave it locked. */ + return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, queue_name, &local_id, &record); + if (return_code == OS_SUCCESS) + { + /* Save all the data to our own internal queue table */ + strcpy(OS_queue_table[local_id].queue_name, queue_name); + record->name_entry = OS_queue_table[local_id].queue_name; + OS_queue_table[local_id].max_depth = queue_depth; + OS_queue_table[local_id].max_size = data_size; + + /* Now call the OS-specific implementation. This reads info from the queue table. */ + return_code = OS_QueueCreate_Impl(local_id, flags); + + /* Check result, finalize record, and unlock global table. */ + return_code = OS_ObjectIdFinalizeNew(return_code, record, queue_id); + } + + return return_code; } /* end OS_QueueCreate */ - /*---------------------------------------------------------------- * * Function: OS_QueueDelete @@ -145,26 +137,25 @@ int32 OS_QueueCreate (osal_id_t *queue_id, const char *queue_name, uint32 queue_ * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_QueueDelete (osal_id_t queue_id) +int32 OS_QueueDelete(osal_id_t queue_id) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; + OS_common_record_t *record; + uint32 local_id; + int32 return_code; - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, queue_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - return_code = OS_QueueDelete_Impl(local_id); + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, queue_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + return_code = OS_QueueDelete_Impl(local_id); - /* Complete the operation via the common routine */ - return_code = OS_ObjectIdFinalizeDelete(return_code, record); - } + /* Complete the operation via the common routine */ + return_code = OS_ObjectIdFinalizeDelete(return_code, record); + } - return return_code; + return return_code; } /* end OS_QueueDelete */ - /*---------------------------------------------------------------- * * Function: OS_QueueGet @@ -173,41 +164,40 @@ int32 OS_QueueDelete (osal_id_t queue_id) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_QueueGet (osal_id_t queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout) +int32 OS_QueueGet(osal_id_t queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; - - /* Check Parameters */ - if (data == NULL || size_copied == NULL) - { - return_code = OS_INVALID_POINTER; - } - else - { - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, queue_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - if (size < OS_queue_table[local_id].max_size) - { - /* - ** The buffer that the user is passing in is potentially too small - */ - *size_copied = 0; - return_code = OS_QUEUE_INVALID_SIZE; - } - else - { - return_code = OS_QueueGet_Impl (local_id, data, size, size_copied, timeout); - } - } - } - - return return_code; + OS_common_record_t *record; + uint32 local_id; + int32 return_code; + + /* Check Parameters */ + if (data == NULL || size_copied == NULL) + { + return_code = OS_INVALID_POINTER; + } + else + { + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, queue_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + if (size < OS_queue_table[local_id].max_size) + { + /* + ** The buffer that the user is passing in is potentially too small + */ + *size_copied = 0; + return_code = OS_QUEUE_INVALID_SIZE; + } + else + { + return_code = OS_QueueGet_Impl(local_id, data, size, size_copied, timeout); + } + } + } + + return return_code; } /* end OS_QueueGet */ - /*---------------------------------------------------------------- * * Function: OS_QueuePut @@ -216,31 +206,29 @@ int32 OS_QueueGet (osal_id_t queue_id, void *data, uint32 size, uint32 *size_cop * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_QueuePut (osal_id_t queue_id, const void *data, uint32 size, uint32 flags) +int32 OS_QueuePut(osal_id_t queue_id, const void *data, uint32 size, uint32 flags) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; - - /* Check Parameters */ - if (data == NULL) - { - return_code = OS_INVALID_POINTER; - } - else - { - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, queue_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - return_code = OS_QueuePut_Impl (local_id, data, size, flags); - } - } - - return return_code; + OS_common_record_t *record; + uint32 local_id; + int32 return_code; + + /* Check Parameters */ + if (data == NULL) + { + return_code = OS_INVALID_POINTER; + } + else + { + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, queue_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + return_code = OS_QueuePut_Impl(local_id, data, size, flags); + } + } + + return return_code; } /* end OS_QueuePut */ - - /*---------------------------------------------------------------- * * Function: OS_QueueGetIdByName @@ -249,22 +237,21 @@ int32 OS_QueuePut (osal_id_t queue_id, const void *data, uint32 size, uint32 fla * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_QueueGetIdByName (osal_id_t *queue_id, const char *queue_name) +int32 OS_QueueGetIdByName(osal_id_t *queue_id, const char *queue_name) { - int32 return_code; + int32 return_code; - if (queue_id == NULL || queue_name == NULL) - { - return OS_INVALID_POINTER; - } + if (queue_id == NULL || queue_name == NULL) + { + return OS_INVALID_POINTER; + } - return_code = OS_ObjectIdFindByName(LOCAL_OBJID_TYPE, queue_name, queue_id); + return_code = OS_ObjectIdFindByName(LOCAL_OBJID_TYPE, queue_name, queue_id); - return return_code; + return return_code; } /* end OS_QueueGetIdByName */ - /*---------------------------------------------------------------- * * Function: OS_QueueGetInfo @@ -273,35 +260,34 @@ int32 OS_QueueGetIdByName (osal_id_t *queue_id, const char *queue_name) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_QueueGetInfo (osal_id_t queue_id, OS_queue_prop_t *queue_prop) +int32 OS_QueueGetInfo(osal_id_t queue_id, OS_queue_prop_t *queue_prop) { - OS_common_record_t *record; - int32 return_code; - uint32 local_id; + OS_common_record_t *record; + int32 return_code; + uint32 local_id; - /* Check parameters */ - if (queue_prop == NULL) - { - return OS_INVALID_POINTER; - } + /* Check parameters */ + if (queue_prop == NULL) + { + return OS_INVALID_POINTER; + } - memset(queue_prop,0,sizeof(OS_queue_prop_t)); + memset(queue_prop, 0, sizeof(OS_queue_prop_t)); - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL,LOCAL_OBJID_TYPE, queue_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - strncpy(queue_prop->name, record->name_entry, OS_MAX_API_NAME - 1); - queue_prop->creator = record->creator; + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, queue_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + strncpy(queue_prop->name, record->name_entry, OS_MAX_API_NAME - 1); + queue_prop->creator = record->creator; - /* - * Currently there are no additional queue details provided by the impl layer - - * But this could be added in the future (i.e. current/max depth, msg size, etc) - */ + /* + * Currently there are no additional queue details provided by the impl layer - + * But this could be added in the future (i.e. current/max depth, msg size, etc) + */ - OS_Unlock_Global(LOCAL_OBJID_TYPE); - } + OS_Unlock_Global(LOCAL_OBJID_TYPE); + } - return return_code; + return return_code; } /* end OS_QueueGetInfo */ - diff --git a/src/os/shared/src/osapi-select.c b/src/os/shared/src/osapi-select.c index 66a9b75bd..161e4b04b 100644 --- a/src/os/shared/src/osapi-select.c +++ b/src/os/shared/src/osapi-select.c @@ -38,14 +38,12 @@ #include #include - /* * User defined include files */ #include "os-shared-idmap.h" #include "os-shared-select.h" - /* ********************************************************************************* * SELECT API @@ -62,20 +60,21 @@ *-----------------------------------------------------------------*/ int32 OS_SelectSingle(osal_id_t objid, uint32 *StateFlags, int32 msecs) { - int32 return_code; - uint32 local_id; - OS_common_record_t *record; + int32 return_code; + uint32 local_id; + OS_common_record_t *record; - if(StateFlags == NULL) return OS_INVALID_POINTER; + if (StateFlags == NULL) + return OS_INVALID_POINTER; - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, OS_OBJECT_TYPE_OS_STREAM, objid, &local_id, &record); - if (return_code == OS_SUCCESS) - { - return_code = OS_SelectSingle_Impl(local_id, StateFlags, msecs); - OS_ObjectIdRefcountDecr(record); - } + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, OS_OBJECT_TYPE_OS_STREAM, objid, &local_id, &record); + if (return_code == OS_SUCCESS) + { + return_code = OS_SelectSingle_Impl(local_id, StateFlags, msecs); + OS_ObjectIdRefcountDecr(record); + } - return return_code; + return return_code; } /* end OS_SelectSingle */ /*---------------------------------------------------------------- @@ -111,10 +110,11 @@ int32 OS_SelectMultiple(OS_FdSet *ReadSet, OS_FdSet *WriteSet, int32 msecs) *-----------------------------------------------------------------*/ int32 OS_SelectFdZero(OS_FdSet *Set) { - if (Set == NULL) return OS_INVALID_POINTER; + if (Set == NULL) + return OS_INVALID_POINTER; - memset(Set,0,sizeof(OS_FdSet)); - return OS_SUCCESS; + memset(Set, 0, sizeof(OS_FdSet)); + return OS_SUCCESS; } /* end OS_SelectFdZero */ /*---------------------------------------------------------------- @@ -127,18 +127,19 @@ int32 OS_SelectFdZero(OS_FdSet *Set) *-----------------------------------------------------------------*/ int32 OS_SelectFdAdd(OS_FdSet *Set, osal_id_t objid) { - int32 return_code; - uint32 local_id; + int32 return_code; + uint32 local_id; - if(Set == NULL) return OS_INVALID_POINTER; + if (Set == NULL) + return OS_INVALID_POINTER; - return_code = OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_STREAM, objid, &local_id); - if (return_code == OS_SUCCESS) - { - Set->object_ids[local_id >> 3] |= 1 << (local_id & 0x7); - } + return_code = OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_STREAM, objid, &local_id); + if (return_code == OS_SUCCESS) + { + Set->object_ids[local_id >> 3] |= 1 << (local_id & 0x7); + } - return return_code; + return return_code; } /* end OS_SelectFdAdd */ /*---------------------------------------------------------------- @@ -151,18 +152,19 @@ int32 OS_SelectFdAdd(OS_FdSet *Set, osal_id_t objid) *-----------------------------------------------------------------*/ int32 OS_SelectFdClear(OS_FdSet *Set, osal_id_t objid) { - int32 return_code; - uint32 local_id; + int32 return_code; + uint32 local_id; - if(Set == NULL) return OS_INVALID_POINTER; + if (Set == NULL) + return OS_INVALID_POINTER; - return_code = OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_STREAM, objid, &local_id); - if (return_code == OS_SUCCESS) - { - Set->object_ids[local_id >> 3] &= ~(1 << (local_id & 0x7)); - } + return_code = OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_STREAM, objid, &local_id); + if (return_code == OS_SUCCESS) + { + Set->object_ids[local_id >> 3] &= ~(1 << (local_id & 0x7)); + } - return return_code; + return return_code; } /* end OS_SelectFdClear */ /*---------------------------------------------------------------- @@ -175,18 +177,17 @@ int32 OS_SelectFdClear(OS_FdSet *Set, osal_id_t objid) *-----------------------------------------------------------------*/ bool OS_SelectFdIsSet(OS_FdSet *Set, osal_id_t objid) { - int32 return_code; - uint32 local_id; + int32 return_code; + uint32 local_id; - if(Set == NULL) return false; + if (Set == NULL) + return false; - return_code = OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_STREAM, objid, &local_id); - if (return_code != OS_SUCCESS) - { - return false; - } + return_code = OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_STREAM, objid, &local_id); + if (return_code != OS_SUCCESS) + { + return false; + } - return ((Set->object_ids[local_id >> 3] >> (local_id & 0x7)) & 0x1); + return ((Set->object_ids[local_id >> 3] >> (local_id & 0x7)) & 0x1); } /* end OS_SelectFdIsSet */ - - diff --git a/src/os/shared/src/osapi-shell.c b/src/os/shared/src/osapi-shell.c index 86782aaf3..d59668210 100644 --- a/src/os/shared/src/osapi-shell.c +++ b/src/os/shared/src/osapi-shell.c @@ -42,8 +42,6 @@ #include "os-shared-file.h" #include "os-shared-idmap.h" - - /*---------------------------------------------------------------- * * Function: OS_ShellOutputToFile @@ -52,25 +50,24 @@ * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_ShellOutputToFile(const char* Cmd, osal_id_t filedes) +int32 OS_ShellOutputToFile(const char *Cmd, osal_id_t filedes) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; + OS_common_record_t *record; + uint32 local_id; + int32 return_code; - /* Check Parameters */ - if (Cmd == NULL) - { - return OS_INVALID_POINTER; - } + /* Check Parameters */ + if (Cmd == NULL) + { + return OS_INVALID_POINTER; + } - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, OS_OBJECT_TYPE_OS_STREAM, filedes, &local_id, &record); - if (return_code == OS_SUCCESS) - { - return_code = OS_ShellOutputToFile_Impl(local_id, Cmd); - OS_ObjectIdRefcountDecr(record); - } + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, OS_OBJECT_TYPE_OS_STREAM, filedes, &local_id, &record); + if (return_code == OS_SUCCESS) + { + return_code = OS_ShellOutputToFile_Impl(local_id, Cmd); + OS_ObjectIdRefcountDecr(record); + } - return return_code; + return return_code; } /* end OS_ShellOutputToFile */ - diff --git a/src/os/shared/src/osapi-sockets.c b/src/os/shared/src/osapi-sockets.c index b846b260c..4a66c5fdb 100644 --- a/src/os/shared/src/osapi-sockets.c +++ b/src/os/shared/src/osapi-sockets.c @@ -36,7 +36,6 @@ #include #include - /* * User defined include files */ @@ -44,21 +43,19 @@ #include "os-shared-file.h" #include "os-shared-sockets.h" - /* * Global data for the API */ enum { - LOCAL_NUM_OBJECTS = OS_MAX_NUM_OPEN_FILES, - LOCAL_OBJID_TYPE = OS_OBJECT_TYPE_OS_STREAM + LOCAL_NUM_OBJECTS = OS_MAX_NUM_OPEN_FILES, + LOCAL_OBJID_TYPE = OS_OBJECT_TYPE_OS_STREAM }; /**************************************************************************************** Init Functions ***************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_SocketAPI_Init @@ -80,7 +77,6 @@ int32 OS_SocketAPI_Init(void) Local Helper Functions ***************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_CreateSocketName @@ -90,30 +86,29 @@ int32 OS_SocketAPI_Init(void) *-----------------------------------------------------------------*/ void OS_CreateSocketName(uint32 local_id, const OS_SockAddr_t *Addr, const char *parent_name) { - int32 len; - uint16 port; - OS_stream_internal_record_t *sock = &OS_stream_table[local_id]; - - if (OS_SocketAddrToString_Impl(sock->stream_name, OS_MAX_API_NAME, Addr) != OS_SUCCESS) - { - sock->stream_name[0] = 0; - } - if (OS_SocketAddrGetPort_Impl(&port, Addr) == OS_SUCCESS) - { - len = strlen(sock->stream_name); - snprintf(&sock->stream_name[len], OS_MAX_API_NAME - len, ":%u", (unsigned int)port); - } - sock->stream_name[OS_MAX_API_NAME - 1] = 0; - - if (parent_name) - { - /* Append the name from the parent socket. */ - len = strlen(sock->stream_name); - snprintf(&sock->stream_name[len], sizeof(sock->stream_name) - len, "-%s", parent_name); - sock->stream_name[sizeof(sock->stream_name) - 1] = 0; - } -} /* end OS_CreateSocketName */ + int32 len; + uint16 port; + OS_stream_internal_record_t *sock = &OS_stream_table[local_id]; + if (OS_SocketAddrToString_Impl(sock->stream_name, OS_MAX_API_NAME, Addr) != OS_SUCCESS) + { + sock->stream_name[0] = 0; + } + if (OS_SocketAddrGetPort_Impl(&port, Addr) == OS_SUCCESS) + { + len = strlen(sock->stream_name); + snprintf(&sock->stream_name[len], OS_MAX_API_NAME - len, ":%u", (unsigned int)port); + } + sock->stream_name[OS_MAX_API_NAME - 1] = 0; + + if (parent_name) + { + /* Append the name from the parent socket. */ + len = strlen(sock->stream_name); + snprintf(&sock->stream_name[len], sizeof(sock->stream_name) - len, "-%s", parent_name); + sock->stream_name[sizeof(sock->stream_name) - 1] = 0; + } +} /* end OS_CreateSocketName */ /*---------------------------------------------------------------- * @@ -125,34 +120,33 @@ void OS_CreateSocketName(uint32 local_id, const OS_SockAddr_t *Addr, const char *-----------------------------------------------------------------*/ int32 OS_SocketOpen(osal_id_t *sock_id, OS_SocketDomain_t Domain, OS_SocketType_t Type) { - OS_common_record_t *record; - int32 return_code; - uint32 local_id; - - /* Check for NULL pointers */ - if (sock_id == NULL) - { - return OS_INVALID_POINTER; - } - - /* Note - the common ObjectIdAllocate routine will lock the object type and leave it locked. */ - return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, NULL, &local_id, &record); - if(return_code == OS_SUCCESS) - { - /* Save all the data to our own internal table */ - memset(&OS_stream_table[local_id], 0, sizeof(OS_stream_internal_record_t)); - OS_stream_table[local_id].socket_domain = Domain; - OS_stream_table[local_id].socket_type = Type; - - - /* Now call the OS-specific implementation. This reads info from the table. */ - return_code = OS_SocketOpen_Impl(local_id); - - /* Check result, finalize record, and unlock global table. */ - return_code = OS_ObjectIdFinalizeNew(return_code, record, sock_id); - } - - return return_code; + OS_common_record_t *record; + int32 return_code; + uint32 local_id; + + /* Check for NULL pointers */ + if (sock_id == NULL) + { + return OS_INVALID_POINTER; + } + + /* Note - the common ObjectIdAllocate routine will lock the object type and leave it locked. */ + return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, NULL, &local_id, &record); + if (return_code == OS_SUCCESS) + { + /* Save all the data to our own internal table */ + memset(&OS_stream_table[local_id], 0, sizeof(OS_stream_internal_record_t)); + OS_stream_table[local_id].socket_domain = Domain; + OS_stream_table[local_id].socket_type = Type; + + /* Now call the OS-specific implementation. This reads info from the table. */ + return_code = OS_SocketOpen_Impl(local_id); + + /* Check result, finalize record, and unlock global table. */ + return_code = OS_ObjectIdFinalizeNew(return_code, record, sock_id); + } + + return return_code; } /* end OS_SocketOpen */ /*---------------------------------------------------------------- @@ -165,46 +159,46 @@ int32 OS_SocketOpen(osal_id_t *sock_id, OS_SocketDomain_t Domain, OS_SocketType_ *-----------------------------------------------------------------*/ int32 OS_SocketBind(osal_id_t sock_id, const OS_SockAddr_t *Addr) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; - - /* Check Parameters */ - if (Addr == NULL) - { - return OS_INVALID_POINTER; - } - - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, sock_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - if (OS_stream_table[local_id].socket_domain == OS_SocketDomain_INVALID) - { - /* Not a socket */ - return_code = OS_ERR_INCORRECT_OBJ_TYPE; - } - else if (record->refcount != 0 || - (OS_stream_table[local_id].stream_state & (OS_STREAM_STATE_BOUND | OS_STREAM_STATE_CONNECTED)) != 0) - { - /* Socket must be neither bound nor connected */ - return_code = OS_ERR_INCORRECT_OBJ_STATE; - } - else - { - return_code = OS_SocketBind_Impl (local_id, Addr); - - if (return_code == OS_SUCCESS) - { - OS_CreateSocketName(local_id, Addr, NULL); - record->name_entry = OS_stream_table[local_id].stream_name; - OS_stream_table[local_id].stream_state |= OS_STREAM_STATE_BOUND; - } - } - - OS_Unlock_Global(LOCAL_OBJID_TYPE); - } - - return return_code; + OS_common_record_t *record; + uint32 local_id; + int32 return_code; + + /* Check Parameters */ + if (Addr == NULL) + { + return OS_INVALID_POINTER; + } + + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, sock_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + if (OS_stream_table[local_id].socket_domain == OS_SocketDomain_INVALID) + { + /* Not a socket */ + return_code = OS_ERR_INCORRECT_OBJ_TYPE; + } + else if (record->refcount != 0 || + (OS_stream_table[local_id].stream_state & (OS_STREAM_STATE_BOUND | OS_STREAM_STATE_CONNECTED)) != 0) + { + /* Socket must be neither bound nor connected */ + return_code = OS_ERR_INCORRECT_OBJ_STATE; + } + else + { + return_code = OS_SocketBind_Impl(local_id, Addr); + + if (return_code == OS_SUCCESS) + { + OS_CreateSocketName(local_id, Addr, NULL); + record->name_entry = OS_stream_table[local_id].stream_name; + OS_stream_table[local_id].stream_state |= OS_STREAM_STATE_BOUND; + } + } + + OS_Unlock_Global(LOCAL_OBJID_TYPE); + } + + return return_code; } /* end OS_SocketBind */ @@ -218,90 +212,91 @@ int32 OS_SocketBind(osal_id_t sock_id, const OS_SockAddr_t *Addr) *-----------------------------------------------------------------*/ int32 OS_SocketAccept(osal_id_t sock_id, osal_id_t *connsock_id, OS_SockAddr_t *Addr, int32 timeout) { - OS_common_record_t *record; - OS_common_record_t *connrecord; - uint32 local_id; - uint32 conn_id = 0; - int32 return_code; - - /* Check Parameters */ - if (Addr == NULL || connsock_id == NULL) - { - return OS_INVALID_POINTER; - } - - /* - * Note: setting "connrecord" here avoids a false warning - * from static analysis tools about the value being - * possibly used uninitialized (it cannot be, because - * return_code is checked, and return_code is only - * set to OS_SUCCESS when connrecord is also initialized) - */ - connrecord = NULL; - - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, LOCAL_OBJID_TYPE, sock_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - if (OS_stream_table[local_id].socket_type != OS_SocketType_STREAM) - { - /* Socket must be of the STREAM variety */ - return_code = OS_ERR_INCORRECT_OBJ_TYPE; - } - else if ((OS_stream_table[local_id].stream_state & (OS_STREAM_STATE_BOUND | OS_STREAM_STATE_CONNECTED)) != OS_STREAM_STATE_BOUND) - { - /* Socket must be bound but not connected */ - return_code = OS_ERR_INCORRECT_OBJ_STATE; - } - else - { - /* Now create a unique ID for the connection */ - return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, NULL, &conn_id, &connrecord); - if(return_code == OS_SUCCESS) - { - /* Incr the refcount to record the fact that an operation is pending on this */ - memset(&OS_stream_table[conn_id], 0, sizeof(OS_stream_internal_record_t)); - OS_stream_table[conn_id].socket_domain = OS_stream_table[local_id].socket_domain; - OS_stream_table[conn_id].socket_type = OS_stream_table[local_id].socket_type; - ++connrecord->refcount; - return_code = OS_ObjectIdFinalizeNew(return_code, connrecord, connsock_id); - } - } - - /* If failure happened here, decrement the refcount of the listening socket now */ - if (return_code != OS_SUCCESS) - { - OS_ObjectIdRefcountDecr(record); - } - } - - if (return_code == OS_SUCCESS) - { - OS_SocketAddrInit_Impl(Addr, OS_stream_table[local_id].socket_domain); - - /* The actual accept impl is done without global table lock, only refcount lock */ - return_code = OS_SocketAccept_Impl(local_id, conn_id, Addr, timeout); - - OS_Lock_Global(LOCAL_OBJID_TYPE); - if (return_code == OS_SUCCESS) - { - /* Generate an entry name based on the remote address */ - OS_CreateSocketName(conn_id, Addr, record->name_entry); - connrecord->name_entry = OS_stream_table[conn_id].stream_name; - OS_stream_table[conn_id].stream_state |= OS_STREAM_STATE_CONNECTED; - } - else - { - /* Clear the connrecord */ - connrecord->active_id = OS_OBJECT_ID_UNDEFINED; - } - - /* Decrement both ref counters that were increased earlier */ - --record->refcount; - --connrecord->refcount; - OS_Unlock_Global(LOCAL_OBJID_TYPE); - } - - return return_code; + OS_common_record_t *record; + OS_common_record_t *connrecord; + uint32 local_id; + uint32 conn_id = 0; + int32 return_code; + + /* Check Parameters */ + if (Addr == NULL || connsock_id == NULL) + { + return OS_INVALID_POINTER; + } + + /* + * Note: setting "connrecord" here avoids a false warning + * from static analysis tools about the value being + * possibly used uninitialized (it cannot be, because + * return_code is checked, and return_code is only + * set to OS_SUCCESS when connrecord is also initialized) + */ + connrecord = NULL; + + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, LOCAL_OBJID_TYPE, sock_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + if (OS_stream_table[local_id].socket_type != OS_SocketType_STREAM) + { + /* Socket must be of the STREAM variety */ + return_code = OS_ERR_INCORRECT_OBJ_TYPE; + } + else if ((OS_stream_table[local_id].stream_state & (OS_STREAM_STATE_BOUND | OS_STREAM_STATE_CONNECTED)) != + OS_STREAM_STATE_BOUND) + { + /* Socket must be bound but not connected */ + return_code = OS_ERR_INCORRECT_OBJ_STATE; + } + else + { + /* Now create a unique ID for the connection */ + return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, NULL, &conn_id, &connrecord); + if (return_code == OS_SUCCESS) + { + /* Incr the refcount to record the fact that an operation is pending on this */ + memset(&OS_stream_table[conn_id], 0, sizeof(OS_stream_internal_record_t)); + OS_stream_table[conn_id].socket_domain = OS_stream_table[local_id].socket_domain; + OS_stream_table[conn_id].socket_type = OS_stream_table[local_id].socket_type; + ++connrecord->refcount; + return_code = OS_ObjectIdFinalizeNew(return_code, connrecord, connsock_id); + } + } + + /* If failure happened here, decrement the refcount of the listening socket now */ + if (return_code != OS_SUCCESS) + { + OS_ObjectIdRefcountDecr(record); + } + } + + if (return_code == OS_SUCCESS) + { + OS_SocketAddrInit_Impl(Addr, OS_stream_table[local_id].socket_domain); + + /* The actual accept impl is done without global table lock, only refcount lock */ + return_code = OS_SocketAccept_Impl(local_id, conn_id, Addr, timeout); + + OS_Lock_Global(LOCAL_OBJID_TYPE); + if (return_code == OS_SUCCESS) + { + /* Generate an entry name based on the remote address */ + OS_CreateSocketName(conn_id, Addr, record->name_entry); + connrecord->name_entry = OS_stream_table[conn_id].stream_name; + OS_stream_table[conn_id].stream_state |= OS_STREAM_STATE_CONNECTED; + } + else + { + /* Clear the connrecord */ + connrecord->active_id = OS_OBJECT_ID_UNDEFINED; + } + + /* Decrement both ref counters that were increased earlier */ + --record->refcount; + --connrecord->refcount; + OS_Unlock_Global(LOCAL_OBJID_TYPE); + } + + return return_code; } /* end OS_SocketAccept */ /*---------------------------------------------------------------- @@ -314,51 +309,51 @@ int32 OS_SocketAccept(osal_id_t sock_id, osal_id_t *connsock_id, OS_SockAddr_t * *-----------------------------------------------------------------*/ int32 OS_SocketConnect(osal_id_t sock_id, const OS_SockAddr_t *Addr, int32 Timeout) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; - - /* Check Parameters */ - if (Addr == NULL) - { - return OS_INVALID_POINTER; - } - - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, sock_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - if (OS_stream_table[local_id].socket_domain == OS_SocketDomain_INVALID) - { - return_code = OS_ERR_INCORRECT_OBJ_TYPE; - } - else if (OS_stream_table[local_id].socket_type == OS_SocketType_STREAM && - (OS_stream_table[local_id].stream_state & OS_STREAM_STATE_CONNECTED) != 0) - { - /* Stream socket must not be connected */ - return_code = OS_ERR_INCORRECT_OBJ_STATE; - } - else - { - ++record->refcount; - } - OS_Unlock_Global(LOCAL_OBJID_TYPE); - } - - if (return_code == OS_SUCCESS) - { - return_code = OS_SocketConnect_Impl (local_id, Addr, Timeout); - - OS_Lock_Global(LOCAL_OBJID_TYPE); - if (return_code == OS_SUCCESS) - { - OS_stream_table[local_id].stream_state |= OS_STREAM_STATE_CONNECTED | OS_STREAM_STATE_READABLE | OS_STREAM_STATE_WRITABLE; - } - --record->refcount; - OS_Unlock_Global(LOCAL_OBJID_TYPE); - } - - - return return_code; + OS_common_record_t *record; + uint32 local_id; + int32 return_code; + + /* Check Parameters */ + if (Addr == NULL) + { + return OS_INVALID_POINTER; + } + + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, sock_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + if (OS_stream_table[local_id].socket_domain == OS_SocketDomain_INVALID) + { + return_code = OS_ERR_INCORRECT_OBJ_TYPE; + } + else if (OS_stream_table[local_id].socket_type == OS_SocketType_STREAM && + (OS_stream_table[local_id].stream_state & OS_STREAM_STATE_CONNECTED) != 0) + { + /* Stream socket must not be connected */ + return_code = OS_ERR_INCORRECT_OBJ_STATE; + } + else + { + ++record->refcount; + } + OS_Unlock_Global(LOCAL_OBJID_TYPE); + } + + if (return_code == OS_SUCCESS) + { + return_code = OS_SocketConnect_Impl(local_id, Addr, Timeout); + + OS_Lock_Global(LOCAL_OBJID_TYPE); + if (return_code == OS_SUCCESS) + { + OS_stream_table[local_id].stream_state |= + OS_STREAM_STATE_CONNECTED | OS_STREAM_STATE_READABLE | OS_STREAM_STATE_WRITABLE; + } + --record->refcount; + OS_Unlock_Global(LOCAL_OBJID_TYPE); + } + + return return_code; } /* end OS_SocketConnect */ /*---------------------------------------------------------------- @@ -371,37 +366,37 @@ int32 OS_SocketConnect(osal_id_t sock_id, const OS_SockAddr_t *Addr, int32 Timeo *-----------------------------------------------------------------*/ int32 OS_SocketRecvFrom(osal_id_t sock_id, void *buffer, uint32 buflen, OS_SockAddr_t *RemoteAddr, int32 timeout) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; - - /* Check Parameters */ - if (buffer == NULL || buflen == 0) - { - return OS_INVALID_POINTER; - } - - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, LOCAL_OBJID_TYPE, sock_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - if (OS_stream_table[local_id].socket_type != OS_SocketType_DATAGRAM) - { - return_code = OS_ERR_INCORRECT_OBJ_TYPE; - } - else if ((OS_stream_table[local_id].stream_state & OS_STREAM_STATE_BOUND) == 0) - { - /* Socket needs to be bound first */ - return_code = OS_ERR_INCORRECT_OBJ_STATE; - } - else - { - return_code = OS_SocketRecvFrom_Impl (local_id, buffer, buflen, RemoteAddr, timeout); - } - - OS_ObjectIdRefcountDecr(record); - } - - return return_code; + OS_common_record_t *record; + uint32 local_id; + int32 return_code; + + /* Check Parameters */ + if (buffer == NULL || buflen == 0) + { + return OS_INVALID_POINTER; + } + + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, LOCAL_OBJID_TYPE, sock_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + if (OS_stream_table[local_id].socket_type != OS_SocketType_DATAGRAM) + { + return_code = OS_ERR_INCORRECT_OBJ_TYPE; + } + else if ((OS_stream_table[local_id].stream_state & OS_STREAM_STATE_BOUND) == 0) + { + /* Socket needs to be bound first */ + return_code = OS_ERR_INCORRECT_OBJ_STATE; + } + else + { + return_code = OS_SocketRecvFrom_Impl(local_id, buffer, buflen, RemoteAddr, timeout); + } + + OS_ObjectIdRefcountDecr(record); + } + + return return_code; } /* end OS_SocketRecvFrom */ /*---------------------------------------------------------------- @@ -414,34 +409,33 @@ int32 OS_SocketRecvFrom(osal_id_t sock_id, void *buffer, uint32 buflen, OS_SockA *-----------------------------------------------------------------*/ int32 OS_SocketSendTo(osal_id_t sock_id, const void *buffer, uint32 buflen, const OS_SockAddr_t *RemoteAddr) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; - - /* Check Parameters */ - if (buffer == NULL || buflen == 0) - { - return OS_INVALID_POINTER; - } - - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, LOCAL_OBJID_TYPE, sock_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - if (OS_stream_table[local_id].socket_type != OS_SocketType_DATAGRAM) - { - return_code = OS_ERR_INCORRECT_OBJ_TYPE; - } - else - { - return_code = OS_SocketSendTo_Impl (local_id, buffer, buflen, RemoteAddr); - } - - OS_ObjectIdRefcountDecr(record); - } - - return return_code; -} /* end OS_SocketSendTo */ + OS_common_record_t *record; + uint32 local_id; + int32 return_code; + /* Check Parameters */ + if (buffer == NULL || buflen == 0) + { + return OS_INVALID_POINTER; + } + + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, LOCAL_OBJID_TYPE, sock_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + if (OS_stream_table[local_id].socket_type != OS_SocketType_DATAGRAM) + { + return_code = OS_ERR_INCORRECT_OBJ_TYPE; + } + else + { + return_code = OS_SocketSendTo_Impl(local_id, buffer, buflen, RemoteAddr); + } + + OS_ObjectIdRefcountDecr(record); + } + + return return_code; +} /* end OS_SocketSendTo */ /*---------------------------------------------------------------- * @@ -451,21 +445,20 @@ int32 OS_SocketSendTo(osal_id_t sock_id, const void *buffer, uint32 buflen, cons * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_SocketGetIdByName (osal_id_t *sock_id, const char *sock_name) +int32 OS_SocketGetIdByName(osal_id_t *sock_id, const char *sock_name) { - int32 return_code; + int32 return_code; - if (sock_id == NULL || sock_name == NULL) - { - return OS_INVALID_POINTER; - } + if (sock_id == NULL || sock_name == NULL) + { + return OS_INVALID_POINTER; + } - return_code = OS_ObjectIdFindByName(LOCAL_OBJID_TYPE, sock_name, sock_id); + return_code = OS_ObjectIdFindByName(LOCAL_OBJID_TYPE, sock_name, sock_id); - return return_code; + return return_code; } /* end OS_SocketGetIdByName */ - /*---------------------------------------------------------------- * * Function: OS_SocketGetInfo @@ -474,31 +467,31 @@ int32 OS_SocketGetIdByName (osal_id_t *sock_id, const char *sock_name) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_SocketGetInfo (osal_id_t sock_id, OS_socket_prop_t *sock_prop) +int32 OS_SocketGetInfo(osal_id_t sock_id, OS_socket_prop_t *sock_prop) { - OS_common_record_t *record; - uint32 local_id; - int32 return_code; - - /* Check parameters */ - if (sock_prop == NULL) - { - return OS_INVALID_POINTER; - } - - memset(sock_prop,0,sizeof(OS_socket_prop_t)); - - /* Check Parameters */ - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, sock_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - strncpy(sock_prop->name, record->name_entry, OS_MAX_API_NAME - 1); - sock_prop->creator = record->creator; - return_code = OS_SocketGetInfo_Impl (local_id, sock_prop); - OS_Unlock_Global(LOCAL_OBJID_TYPE); - } - - return return_code; + OS_common_record_t *record; + uint32 local_id; + int32 return_code; + + /* Check parameters */ + if (sock_prop == NULL) + { + return OS_INVALID_POINTER; + } + + memset(sock_prop, 0, sizeof(OS_socket_prop_t)); + + /* Check Parameters */ + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, sock_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + strncpy(sock_prop->name, record->name_entry, OS_MAX_API_NAME - 1); + sock_prop->creator = record->creator; + return_code = OS_SocketGetInfo_Impl(local_id, sock_prop); + OS_Unlock_Global(LOCAL_OBJID_TYPE); + } + + return return_code; } /* end OS_SocketGetInfo */ /*---------------------------------------------------------------- @@ -590,4 +583,3 @@ int32 OS_SocketAddrSetPort(OS_SockAddr_t *Addr, uint16 PortNum) return OS_SocketAddrSetPort_Impl(Addr, PortNum); } /* end OS_SocketAddrSetPort */ - diff --git a/src/os/shared/src/osapi-task.c b/src/os/shared/src/osapi-task.c index 58e44190e..05817443e 100644 --- a/src/os/shared/src/osapi-task.c +++ b/src/os/shared/src/osapi-task.c @@ -40,7 +40,6 @@ #include #include - /* * User defined include files */ @@ -48,7 +47,6 @@ #include "os-shared-common.h" #include "os-shared-idmap.h" - /* * Sanity checks on the user-supplied configuration * The relevent OS_MAX limit should be defined and greater than zero @@ -57,15 +55,13 @@ #error "osconfig.h must define OS_MAX_TASKS to a valid value" #endif - enum { - LOCAL_NUM_OBJECTS = OS_MAX_TASKS, - LOCAL_OBJID_TYPE = OS_OBJECT_TYPE_OS_TASK + LOCAL_NUM_OBJECTS = OS_MAX_TASKS, + LOCAL_OBJID_TYPE = OS_OBJECT_TYPE_OS_TASK }; -OS_task_internal_record_t OS_task_table [LOCAL_NUM_OBJECTS]; - +OS_task_internal_record_t OS_task_table[LOCAL_NUM_OBJECTS]; /*---------------------------------------------------------------- * @@ -85,53 +81,53 @@ OS_task_internal_record_t OS_task_table [LOCAL_NUM_OBJECTS]; *-----------------------------------------------------------------*/ static int32 OS_TaskPrepare(osal_id_t task_id, osal_task_entry *entrypt) { - int32 return_code; - uint32 local_id; - - return_code = OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_TASK, task_id, &local_id); - if (return_code == OS_SUCCESS) - { - /* - * Take our own task table lock. - * - * This ensures that the parent thread's OS_TaskCreate() call is fully completed, - * and that nobody can call OS_TaskDelete() and possibly overwrite this data. - */ - OS_Lock_Global(OS_OBJECT_TYPE_OS_TASK); - - /* - * Verify that we still appear to own the table entry - */ - if ( !OS_ObjectIdEqual(OS_global_task_table[local_id].active_id, task_id) ) - { - return_code = OS_ERR_INVALID_ID; - } - else - { - return_code = OS_TaskMatch_Impl(local_id); - *entrypt = OS_task_table[local_id].entry_function_pointer; - } - - OS_Unlock_Global(OS_OBJECT_TYPE_OS_TASK); - } - - if (return_code == OS_SUCCESS) - { - return_code = OS_TaskRegister_Impl(task_id); - } - - if (return_code == OS_SUCCESS) - { - /* Give event callback to the application */ - return_code = OS_NotifyEvent(OS_EVENT_TASK_STARTUP, task_id, NULL); - } - - if (return_code != OS_SUCCESS) - { - *entrypt = NULL; - } - - return return_code; + int32 return_code; + uint32 local_id; + + return_code = OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_TASK, task_id, &local_id); + if (return_code == OS_SUCCESS) + { + /* + * Take our own task table lock. + * + * This ensures that the parent thread's OS_TaskCreate() call is fully completed, + * and that nobody can call OS_TaskDelete() and possibly overwrite this data. + */ + OS_Lock_Global(OS_OBJECT_TYPE_OS_TASK); + + /* + * Verify that we still appear to own the table entry + */ + if (!OS_ObjectIdEqual(OS_global_task_table[local_id].active_id, task_id)) + { + return_code = OS_ERR_INVALID_ID; + } + else + { + return_code = OS_TaskMatch_Impl(local_id); + *entrypt = OS_task_table[local_id].entry_function_pointer; + } + + OS_Unlock_Global(OS_OBJECT_TYPE_OS_TASK); + } + + if (return_code == OS_SUCCESS) + { + return_code = OS_TaskRegister_Impl(task_id); + } + + if (return_code == OS_SUCCESS) + { + /* Give event callback to the application */ + return_code = OS_NotifyEvent(OS_EVENT_TASK_STARTUP, task_id, NULL); + } + + if (return_code != OS_SUCCESS) + { + *entrypt = NULL; + } + + return return_code; } /* end OS_TaskPrepare */ /*---------------------------------------------------------------- @@ -150,16 +146,16 @@ void OS_TaskEntryPoint(osal_id_t task_id) { osal_task_entry task_entry; - if (OS_TaskPrepare(task_id, &task_entry) == OS_SUCCESS) - { - if (task_entry != NULL) - { - (*task_entry)(); - } - } + if (OS_TaskPrepare(task_id, &task_entry) == OS_SUCCESS) + { + if (task_entry != NULL) + { + (*task_entry)(); + } + } - /* If the function returns, treat as a normal exit and do the proper cleanup */ - OS_TaskExit(); + /* If the function returns, treat as a normal exit and do the proper cleanup */ + OS_TaskExit(); } /* end OS_TaskEntryPoint */ /* @@ -178,12 +174,10 @@ void OS_TaskEntryPoint(osal_id_t task_id) *-----------------------------------------------------------------*/ int32 OS_TaskAPI_Init(void) { - memset(OS_task_table, 0, sizeof(OS_task_table)); - return OS_SUCCESS; + memset(OS_task_table, 0, sizeof(OS_task_table)); + return OS_SUCCESS; } /* end OS_TaskAPI_Init */ - - /*---------------------------------------------------------------- * * Function: OS_TaskCreate @@ -192,66 +186,62 @@ int32 OS_TaskAPI_Init(void) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_TaskCreate (osal_id_t *task_id, const char *task_name, osal_task_entry function_pointer, - uint32 *stack_pointer, uint32 stack_size, uint32 priority, uint32 flags) +int32 OS_TaskCreate(osal_id_t *task_id, const char *task_name, osal_task_entry function_pointer, uint32 *stack_pointer, + uint32 stack_size, uint32 priority, uint32 flags) { - OS_common_record_t *record; - int32 return_code; - uint32 local_id; - - /* Check for bad priority */ - if (priority > OS_MAX_TASK_PRIORITY) - { - return OS_ERR_INVALID_PRIORITY; - } - - /* Check for NULL pointers */ - if (task_name == NULL || task_id == NULL || function_pointer == NULL) - { - return OS_INVALID_POINTER; - } - - /* Check for bad stack size. Note that NULL stack_pointer is - * OK (impl will allocate) but size must be nonzero. */ - if (stack_size == 0) - { - return OS_ERROR; - } - - /* we don't want to allow names too long*/ - /* if truncated, two names might be the same */ - if (strlen(task_name) >= OS_MAX_API_NAME) - { - return OS_ERR_NAME_TOO_LONG; - } - - /* Note - the common ObjectIdAllocate routine will lock the object type and leave it locked. */ - return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, task_name, &local_id, &record); - if(return_code == OS_SUCCESS) - { - /* Save all the data to our own internal task table */ - memset(&OS_task_table[local_id], 0, sizeof(OS_task_internal_record_t)); - - strncpy(OS_task_table[local_id].task_name, task_name, OS_MAX_API_NAME); - record->name_entry = OS_task_table[local_id].task_name; - OS_task_table[local_id].stack_size = stack_size; - OS_task_table[local_id].priority = priority; - OS_task_table[local_id].entry_function_pointer = function_pointer; - OS_task_table[local_id].stack_pointer = stack_pointer; - - /* Now call the OS-specific implementation. This reads info from the task table. */ - return_code = OS_TaskCreate_Impl(local_id, flags); - - /* Check result, finalize record, and unlock global table. */ - return_code = OS_ObjectIdFinalizeNew(return_code, record, task_id); - } - - - - return return_code; -} /* end OS_TaskCreate */ + OS_common_record_t *record; + int32 return_code; + uint32 local_id; + + /* Check for bad priority */ + if (priority > OS_MAX_TASK_PRIORITY) + { + return OS_ERR_INVALID_PRIORITY; + } + + /* Check for NULL pointers */ + if (task_name == NULL || task_id == NULL || function_pointer == NULL) + { + return OS_INVALID_POINTER; + } + /* Check for bad stack size. Note that NULL stack_pointer is + * OK (impl will allocate) but size must be nonzero. */ + if (stack_size == 0) + { + return OS_ERROR; + } + /* we don't want to allow names too long*/ + /* if truncated, two names might be the same */ + if (strlen(task_name) >= OS_MAX_API_NAME) + { + return OS_ERR_NAME_TOO_LONG; + } + + /* Note - the common ObjectIdAllocate routine will lock the object type and leave it locked. */ + return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, task_name, &local_id, &record); + if (return_code == OS_SUCCESS) + { + /* Save all the data to our own internal task table */ + memset(&OS_task_table[local_id], 0, sizeof(OS_task_internal_record_t)); + + strncpy(OS_task_table[local_id].task_name, task_name, OS_MAX_API_NAME); + record->name_entry = OS_task_table[local_id].task_name; + OS_task_table[local_id].stack_size = stack_size; + OS_task_table[local_id].priority = priority; + OS_task_table[local_id].entry_function_pointer = function_pointer; + OS_task_table[local_id].stack_pointer = stack_pointer; + + /* Now call the OS-specific implementation. This reads info from the task table. */ + return_code = OS_TaskCreate_Impl(local_id, flags); + + /* Check result, finalize record, and unlock global table. */ + return_code = OS_ObjectIdFinalizeNew(return_code, record, task_id); + } + + return return_code; +} /* end OS_TaskCreate */ /*---------------------------------------------------------------- * @@ -261,37 +251,36 @@ int32 OS_TaskCreate (osal_id_t *task_id, const char *task_name, osal_task_entry * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_TaskDelete (osal_id_t task_id) +int32 OS_TaskDelete(osal_id_t task_id) { - OS_common_record_t *record; - int32 return_code; - uint32 local_id; - osal_task_entry delete_hook; - - delete_hook = NULL; - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, task_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - /* Save the delete hook, as we do not want to call it while locked */ - delete_hook = OS_task_table[local_id].delete_hook_pointer; - - return_code = OS_TaskDelete_Impl(local_id); - - /* Complete the operation via the common routine */ - return_code = OS_ObjectIdFinalizeDelete(return_code, record); - } - - /* - ** Call the thread Delete hook if there is one. - */ - if (return_code == OS_SUCCESS && delete_hook != NULL) - { - delete_hook(); - } - - return return_code; -} /* end OS_TaskDelete */ + OS_common_record_t *record; + int32 return_code; + uint32 local_id; + osal_task_entry delete_hook; + + delete_hook = NULL; + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, task_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + /* Save the delete hook, as we do not want to call it while locked */ + delete_hook = OS_task_table[local_id].delete_hook_pointer; + return_code = OS_TaskDelete_Impl(local_id); + + /* Complete the operation via the common routine */ + return_code = OS_ObjectIdFinalizeDelete(return_code, record); + } + + /* + ** Call the thread Delete hook if there is one. + */ + if (return_code == OS_SUCCESS && delete_hook != NULL) + { + delete_hook(); + } + + return return_code; +} /* end OS_TaskDelete */ /*---------------------------------------------------------------- * @@ -303,24 +292,23 @@ int32 OS_TaskDelete (osal_id_t task_id) *-----------------------------------------------------------------*/ void OS_TaskExit() { - OS_common_record_t *record; - osal_id_t task_id; - uint32 local_id; + OS_common_record_t *record; + osal_id_t task_id; + uint32 local_id; - task_id = OS_TaskGetId_Impl(); - if (OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, task_id, &local_id, &record) == OS_SUCCESS) - { - /* Complete the operation via the common routine */ - OS_ObjectIdFinalizeDelete(OS_SUCCESS, record); - } + task_id = OS_TaskGetId_Impl(); + if (OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, task_id, &local_id, &record) == OS_SUCCESS) + { + /* Complete the operation via the common routine */ + OS_ObjectIdFinalizeDelete(OS_SUCCESS, record); + } - /* call the implementation */ - OS_TaskExit_Impl(); + /* call the implementation */ + OS_TaskExit_Impl(); - /* Impl function never returns */ + /* Impl function never returns */ } /* end OS_TaskExit */ - /*---------------------------------------------------------------- * * Function: OS_TaskDelay @@ -331,11 +319,10 @@ void OS_TaskExit() *-----------------------------------------------------------------*/ int32 OS_TaskDelay(uint32 millisecond) { - /* just call the implementation */ - return OS_TaskDelay_Impl(millisecond); + /* just call the implementation */ + return OS_TaskDelay_Impl(millisecond); } /* end OS_TaskDelay */ - /*---------------------------------------------------------------- * * Function: OS_TaskSetPriority @@ -344,39 +331,37 @@ int32 OS_TaskDelay(uint32 millisecond) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_TaskSetPriority (osal_id_t task_id, uint32 new_priority) +int32 OS_TaskSetPriority(osal_id_t task_id, uint32 new_priority) { - OS_common_record_t *record; - int32 return_code; - uint32 local_id; - - if (new_priority > OS_MAX_TASK_PRIORITY) - { - return_code = OS_ERR_INVALID_PRIORITY; - } - else - { - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL,LOCAL_OBJID_TYPE, task_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - return_code = OS_TaskSetPriority_Impl(local_id, new_priority); - - if (return_code == OS_SUCCESS) - { - /* Use the abstracted priority, not the OS one */ - /* Change the priority in the table as well */ - OS_task_table[local_id].priority = new_priority; - } - - /* Unlock the global from OS_ObjectIdGetAndLock() */ - OS_Unlock_Global(LOCAL_OBJID_TYPE); - } - } - - return return_code; -} /* end OS_TaskSetPriority */ + OS_common_record_t *record; + int32 return_code; + uint32 local_id; + if (new_priority > OS_MAX_TASK_PRIORITY) + { + return_code = OS_ERR_INVALID_PRIORITY; + } + else + { + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, task_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + return_code = OS_TaskSetPriority_Impl(local_id, new_priority); + + if (return_code == OS_SUCCESS) + { + /* Use the abstracted priority, not the OS one */ + /* Change the priority in the table as well */ + OS_task_table[local_id].priority = new_priority; + } + + /* Unlock the global from OS_ObjectIdGetAndLock() */ + OS_Unlock_Global(LOCAL_OBJID_TYPE); + } + } + return return_code; +} /* end OS_TaskSetPriority */ /*---------------------------------------------------------------- * @@ -386,10 +371,10 @@ int32 OS_TaskSetPriority (osal_id_t task_id, uint32 new_priority) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_TaskRegister (void) +int32 OS_TaskRegister(void) { OS_common_record_t *record; - uint32 local_id; + uint32 local_id; /* * Just to retain compatibility (really, only the unit test cares) @@ -398,7 +383,6 @@ int32 OS_TaskRegister (void) return OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, OS_TaskGetId_Impl(), &local_id, &record); } /* end OS_TaskRegister */ - /*---------------------------------------------------------------- * * Function: OS_TaskGetId @@ -407,25 +391,24 @@ int32 OS_TaskRegister (void) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -osal_id_t OS_TaskGetId (void) +osal_id_t OS_TaskGetId(void) { - OS_common_record_t *record; - uint32 local_id; - osal_id_t task_id; + OS_common_record_t *record; + uint32 local_id; + osal_id_t task_id; - task_id = OS_TaskGetId_Impl(); + task_id = OS_TaskGetId_Impl(); - /* Confirm the task master table entry matches the expected. - * If not it means we have some stale/leftover value */ - if (OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, task_id, &local_id, &record) != OS_SUCCESS) - { - task_id = OS_OBJECT_ID_UNDEFINED; - } + /* Confirm the task master table entry matches the expected. + * If not it means we have some stale/leftover value */ + if (OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, task_id, &local_id, &record) != OS_SUCCESS) + { + task_id = OS_OBJECT_ID_UNDEFINED; + } - return(task_id); + return (task_id); } /* end OS_TaskGetId */ - /*---------------------------------------------------------------- * * Function: OS_TaskGetIdByName @@ -434,22 +417,21 @@ osal_id_t OS_TaskGetId (void) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_TaskGetIdByName (osal_id_t *task_id, const char *task_name) +int32 OS_TaskGetIdByName(osal_id_t *task_id, const char *task_name) { - int32 return_code; + int32 return_code; - if (task_id == NULL || task_name == NULL) - { - return OS_INVALID_POINTER; - } + if (task_id == NULL || task_name == NULL) + { + return OS_INVALID_POINTER; + } - return_code = OS_ObjectIdFindByName(LOCAL_OBJID_TYPE, task_name, task_id); + return_code = OS_ObjectIdFindByName(LOCAL_OBJID_TYPE, task_name, task_id); - return return_code; + return return_code; } /* end OS_TaskGetIdByName */ - /*---------------------------------------------------------------- * * Function: OS_TaskGetInfo @@ -458,42 +440,41 @@ int32 OS_TaskGetIdByName (osal_id_t *task_id, const char *task_name) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_TaskGetInfo (osal_id_t task_id, OS_task_prop_t *task_prop) +int32 OS_TaskGetInfo(osal_id_t task_id, OS_task_prop_t *task_prop) { - OS_common_record_t *record; - int32 return_code; - uint32 local_id; + OS_common_record_t *record; + int32 return_code; + uint32 local_id; - /* Check parameters */ - if (task_prop == NULL) - { - return OS_INVALID_POINTER; - } + /* Check parameters */ + if (task_prop == NULL) + { + return OS_INVALID_POINTER; + } - memset(task_prop,0,sizeof(OS_task_prop_t)); + memset(task_prop, 0, sizeof(OS_task_prop_t)); - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL,LOCAL_OBJID_TYPE, task_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - if (record->name_entry != NULL) - { - strncpy(task_prop->name, record->name_entry, sizeof(task_prop->name)-1); - task_prop->name[sizeof(task_prop->name)-1] = 0; - } - task_prop->creator = record->creator; - task_prop->stack_size = OS_task_table[local_id].stack_size; - task_prop->priority = OS_task_table[local_id].priority; + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, task_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + if (record->name_entry != NULL) + { + strncpy(task_prop->name, record->name_entry, sizeof(task_prop->name) - 1); + task_prop->name[sizeof(task_prop->name) - 1] = 0; + } + task_prop->creator = record->creator; + task_prop->stack_size = OS_task_table[local_id].stack_size; + task_prop->priority = OS_task_table[local_id].priority; - return_code = OS_TaskGetInfo_Impl(local_id, task_prop); + return_code = OS_TaskGetInfo_Impl(local_id, task_prop); - OS_Unlock_Global(LOCAL_OBJID_TYPE); - } + OS_Unlock_Global(LOCAL_OBJID_TYPE); + } - return return_code; + return return_code; } /* end OS_TaskGetInfo */ - /*---------------------------------------------------------------- * * Function: OS_TaskInstallDeleteHandler @@ -504,24 +485,24 @@ int32 OS_TaskGetInfo (osal_id_t task_id, OS_task_prop_t *task_prop) *-----------------------------------------------------------------*/ int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer) { - OS_common_record_t *record; - int32 return_code; - uint32 local_id; - osal_id_t task_id; - - task_id = OS_TaskGetId_Impl(); - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, task_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - /* - ** Install the pointer - */ - OS_task_table[local_id].delete_hook_pointer = function_pointer; - - OS_Unlock_Global(LOCAL_OBJID_TYPE); - } - - return return_code; + OS_common_record_t *record; + int32 return_code; + uint32 local_id; + osal_id_t task_id; + + task_id = OS_TaskGetId_Impl(); + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, task_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + /* + ** Install the pointer + */ + OS_task_table[local_id].delete_hook_pointer = function_pointer; + + OS_Unlock_Global(LOCAL_OBJID_TYPE); + } + + return return_code; } /* end OS_TaskInstallDeleteHandler */ /*---------------------------------------------------------------- @@ -534,13 +515,13 @@ int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer) *-----------------------------------------------------------------*/ int32 OS_TaskFindIdBySystemData(osal_id_t *task_id, const void *sysdata, size_t sysdata_size) { - int32 return_code; + int32 return_code; OS_common_record_t *record; /* Check parameters */ if (task_id == NULL) { - return OS_INVALID_POINTER; + return OS_INVALID_POINTER; } /* The "sysdata" and "sysdata_size" must be passed to the underlying impl for validation */ @@ -550,7 +531,8 @@ int32 OS_TaskFindIdBySystemData(osal_id_t *task_id, const void *sysdata, size_t return return_code; } - return_code = OS_ObjectIdGetBySearch(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, OS_TaskIdMatchSystemData_Impl, (void*)sysdata, &record); + return_code = OS_ObjectIdGetBySearch(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, OS_TaskIdMatchSystemData_Impl, + (void *)sysdata, &record); if (return_code == OS_SUCCESS) { *task_id = record->active_id; @@ -559,5 +541,3 @@ int32 OS_TaskFindIdBySystemData(osal_id_t *task_id, const void *sysdata, size_t return return_code; } /* end OS_TaskFindIdBySystemData */ - - diff --git a/src/os/shared/src/osapi-time.c b/src/os/shared/src/osapi-time.c index f4c4b7300..93b71532f 100644 --- a/src/os/shared/src/osapi-time.c +++ b/src/os/shared/src/osapi-time.c @@ -37,7 +37,6 @@ #include #include - /* * User defined include files */ @@ -47,7 +46,6 @@ #include "os-shared-time.h" #include "os-shared-task.h" - /* * Sanity checks on the user-supplied configuration * The relevent OS_MAX limit should be defined and greater than zero @@ -56,10 +54,7 @@ #error "osconfig.h must define OS_MAX_TIMERS to a valid value" #endif - - -OS_timecb_internal_record_t OS_timecb_table [OS_MAX_TIMERS]; - +OS_timecb_internal_record_t OS_timecb_table[OS_MAX_TIMERS]; /**************************************************************************************** Timer API @@ -75,11 +70,10 @@ OS_timecb_internal_record_t OS_timecb_table [OS_MAX_TIMERS]; *-----------------------------------------------------------------*/ int32 OS_TimerCbAPI_Init(void) { - memset(OS_timecb_table, 0, sizeof(OS_timecb_table)); - return OS_SUCCESS; + memset(OS_timecb_table, 0, sizeof(OS_timecb_table)); + return OS_SUCCESS; } /* end OS_TimerCbAPI_Init */ - /*---------------------------------------------------------------- * * Function: OS_DoTimerAdd @@ -93,21 +87,22 @@ int32 OS_TimerCbAPI_Init(void) * Return: OS_SUCCESS or error code * *-----------------------------------------------------------------*/ -static int32 OS_DoTimerAdd(osal_id_t *timer_id, const char *timer_name, osal_id_t timebase_ref_id, OS_ArgCallback_t callback_ptr, void *callback_arg, uint32 flags) +static int32 OS_DoTimerAdd(osal_id_t *timer_id, const char *timer_name, osal_id_t timebase_ref_id, + OS_ArgCallback_t callback_ptr, void *callback_arg, uint32 flags) { - OS_common_record_t *timebase; - OS_common_record_t *record; + OS_common_record_t * timebase; + OS_common_record_t * record; OS_timecb_internal_record_t *local; - int32 return_code; - uint32 local_id; - uint32 timebase_local_id; - osal_id_t cb_list; - uint32 attach_id; + int32 return_code; + uint32 local_id; + uint32 timebase_local_id; + osal_id_t cb_list; + uint32 attach_id; /* ** Check Parameters */ - if ( timer_id == NULL || timer_name == NULL) + if (timer_id == NULL || timer_name == NULL) { return OS_INVALID_POINTER; } @@ -124,7 +119,7 @@ static int32 OS_DoTimerAdd(osal_id_t *timer_id, const char *timer_name, osal_id_ /* ** Verify callback parameter */ - if (callback_ptr == NULL ) + if (callback_ptr == NULL) { return OS_TIMER_ERR_INVALID_ARGS; } @@ -144,7 +139,8 @@ static int32 OS_DoTimerAdd(osal_id_t *timer_id, const char *timer_name, osal_id_ * If successful, then after this statement, we MUST decrement the refcount * if we leave this routine with an error. */ - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, OS_OBJECT_TYPE_OS_TIMEBASE, timebase_ref_id, &timebase_local_id, &timebase); + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, OS_OBJECT_TYPE_OS_TIMEBASE, timebase_ref_id, + &timebase_local_id, &timebase); if (return_code != OS_SUCCESS) { return return_code; @@ -152,44 +148,44 @@ static int32 OS_DoTimerAdd(osal_id_t *timer_id, const char *timer_name, osal_id_ /* Note - the common ObjectIdAllocate routine will lock the object type and leave it locked. */ return_code = OS_ObjectIdAllocateNew(OS_OBJECT_TYPE_OS_TIMECB, timer_name, &local_id, &record); - if(return_code == OS_SUCCESS) + if (return_code == OS_SUCCESS) { - /* Save all the data to our own internal timer table */ - local = &OS_timecb_table[local_id]; - - memset(local, 0, sizeof(OS_timecb_internal_record_t)); - - strncpy(local->timer_name, timer_name, OS_MAX_API_NAME - 1); - record->name_entry = local->timer_name; - local->callback_ptr = callback_ptr; - local->callback_arg = callback_arg; - local->timebase_ref = timebase_local_id; - local->flags = flags; - local->prev_ref = local_id; - local->next_ref = local_id; - - /* - * Now we need to add it to the time base callback ring, so take the - * timebase-specific lock to prevent a tick from being processed at this moment. - */ - OS_TimeBaseLock_Impl(timebase_local_id); - - cb_list = OS_timebase_table[timebase_local_id].first_cb; - OS_timebase_table[timebase_local_id].first_cb = record->active_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 = local_id; - OS_timecb_table[local->next_ref].prev_ref = local_id; - } - - OS_TimeBaseUnlock_Impl(timebase_local_id); - - /* Check result, finalize record, and unlock global table. */ - return_code = OS_ObjectIdFinalizeNew(return_code, record, timer_id); + /* Save all the data to our own internal timer table */ + local = &OS_timecb_table[local_id]; + + memset(local, 0, sizeof(OS_timecb_internal_record_t)); + + strncpy(local->timer_name, timer_name, OS_MAX_API_NAME - 1); + record->name_entry = local->timer_name; + local->callback_ptr = callback_ptr; + local->callback_arg = callback_arg; + local->timebase_ref = timebase_local_id; + local->flags = flags; + local->prev_ref = local_id; + local->next_ref = local_id; + + /* + * Now we need to add it to the time base callback ring, so take the + * timebase-specific lock to prevent a tick from being processed at this moment. + */ + OS_TimeBaseLock_Impl(timebase_local_id); + + cb_list = OS_timebase_table[timebase_local_id].first_cb; + OS_timebase_table[timebase_local_id].first_cb = record->active_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 = local_id; + OS_timecb_table[local->next_ref].prev_ref = local_id; + } + + OS_TimeBaseUnlock_Impl(timebase_local_id); + + /* Check result, finalize record, and unlock global table. */ + return_code = OS_ObjectIdFinalizeNew(return_code, record, timer_id); } else { @@ -199,7 +195,6 @@ static int32 OS_DoTimerAdd(osal_id_t *timer_id, const char *timer_name, osal_id_ return return_code; } /* end OS_DoTimerAdd */ - /*---------------------------------------------------------------- * * Function: OS_TimerAdd @@ -208,13 +203,12 @@ static int32 OS_DoTimerAdd(osal_id_t *timer_id, const char *timer_name, osal_id_ * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_TimerAdd(osal_id_t *timer_id, const char *timer_name, osal_id_t timebase_ref_id, OS_ArgCallback_t callback_ptr, void *callback_arg) +int32 OS_TimerAdd(osal_id_t *timer_id, const char *timer_name, osal_id_t timebase_ref_id, OS_ArgCallback_t callback_ptr, + void *callback_arg) { return (OS_DoTimerAdd(timer_id, timer_name, timebase_ref_id, callback_ptr, callback_arg, 0)); } /* end OS_TimerAdd */ - - /*---------------------------------------------------------------- * * Function: OS_Timer_NoArgCallback @@ -226,15 +220,14 @@ static void OS_Timer_NoArgCallback(osal_id_t objid, void *arg) { OS_U32ValueWrapper_t Conv; - /* - * Note - did not write this as simply *((OS_SimpleCallback_t)arg) because - * technically you cannot cast a void * to a function pointer. - */ - Conv.opaque_arg = arg; - (*Conv.timer_callback_func)(objid); + /* + * Note - did not write this as simply *((OS_SimpleCallback_t)arg) because + * technically you cannot cast a void * to a function pointer. + */ + Conv.opaque_arg = arg; + (*Conv.timer_callback_func)(objid); } /* end OS_Timer_NoArgCallback */ - /*---------------------------------------------------------------- * * Function: OS_TimerCreate @@ -243,10 +236,10 @@ static void OS_Timer_NoArgCallback(osal_id_t objid, void *arg) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_TimerCreate(osal_id_t *timer_id, const char *timer_name, uint32 *accuracy, OS_TimerCallback_t callback_ptr) +int32 OS_TimerCreate(osal_id_t *timer_id, const char *timer_name, uint32 *accuracy, OS_TimerCallback_t callback_ptr) { - int32 return_code; - osal_id_t timebase_ref_id; + int32 return_code; + osal_id_t timebase_ref_id; OS_U32ValueWrapper_t Conv; /* @@ -262,7 +255,7 @@ int32 OS_TimerCreate(osal_id_t *timer_id, const char *timer_name, uint32 *accura /* ** Verify callback parameter */ - if (callback_ptr == NULL ) + if (callback_ptr == NULL) { return OS_TIMER_ERR_INVALID_ARGS; } @@ -286,9 +279,10 @@ int32 OS_TimerCreate(osal_id_t *timer_id, const char *timer_name, uint32 *accura * because it is already verified by a CompileTimeAssert that * sizeof(OS_TimerCallback_t) <= sizeof(void*) on this platform. */ - Conv.opaque_arg = NULL; + Conv.opaque_arg = NULL; Conv.timer_callback_func = callback_ptr; - return_code = OS_DoTimerAdd(timer_id, timer_name, timebase_ref_id, OS_Timer_NoArgCallback, Conv.opaque_arg, TIMECB_FLAG_DEDICATED_TIMEBASE); + return_code = OS_DoTimerAdd(timer_id, timer_name, timebase_ref_id, OS_Timer_NoArgCallback, Conv.opaque_arg, + TIMECB_FLAG_DEDICATED_TIMEBASE); /* * If returning from this call unsuccessfully, then we need to delete the @@ -306,8 +300,6 @@ int32 OS_TimerCreate(osal_id_t *timer_id, const char *timer_name, uint32 *accura return return_code; } /* end OS_TimerCreate */ - - /*---------------------------------------------------------------- * * Function: OS_TimerSet @@ -318,77 +310,74 @@ 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_common_record_t *record; - OS_timecb_internal_record_t *local; - int32 return_code; - uint32 local_id; - osal_id_t dedicated_timebase_id; - - dedicated_timebase_id = OS_OBJECT_ID_UNDEFINED; - - if (start_time >= (UINT32_MAX/2) || interval_time >= (UINT32_MAX/2)) - { - return OS_TIMER_ERR_INVALID_ARGS; - } - - if (start_time == 0 && interval_time == 0) - { - return OS_ERROR; - } - - /* - * Check our context. Not allowed to use the timer API from a timer callback. - * Just interested in the object type returned. - */ - local_id = OS_ObjectIdToType_Impl(OS_TaskGetId_Impl()); - if (local_id == OS_OBJECT_TYPE_OS_TIMEBASE) - { - return OS_ERR_INCORRECT_OBJ_STATE; - } - - - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL,OS_OBJECT_TYPE_OS_TIMECB, timer_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - local = &OS_timecb_table[local_id]; - - OS_TimeBaseLock_Impl(local->timebase_ref); - - if ((local->flags & TIMECB_FLAG_DEDICATED_TIMEBASE) != 0) - { - dedicated_timebase_id = OS_global_timebase_table[local->timebase_ref].active_id; - } - - local->wait_time = (int32)start_time; - local->interval_time = (int32)interval_time; - - OS_TimeBaseUnlock_Impl(local->timebase_ref); - - /* Unlock the global from OS_ObjectIdCheck() */ - OS_Unlock_Global(OS_OBJECT_TYPE_OS_TIMECB); - } - - /* - * If the timer uses a dedicated time base, then also change that to the same interval. - * - * This is not perfect in the sense that the update is not all done atomically. If this - * is not the first call to TimerSet, then weirdness can happen: - * - a timer tick could occur between setting the callback times above and now - * - the call to OS_TimeBaseSet() could fail leaving us in a mixed state - * - * However, the notion of multiple TimerSet() calls is a gray area to begin with, since - * timer ticks can occur at any moment - there is never a guarantee your new TimerSet values - * will get applied before the old timer expires. Therefore by definition an application - * MUST be able to handle a possible "spurious" callback in these circumstances. - */ - if (return_code == OS_SUCCESS && OS_ObjectIdDefined(dedicated_timebase_id)) - { - return_code = OS_TimeBaseSet(dedicated_timebase_id, start_time, interval_time); - } - return return_code; -} /* end OS_TimerSet */ + OS_common_record_t * record; + OS_timecb_internal_record_t *local; + int32 return_code; + uint32 local_id; + osal_id_t dedicated_timebase_id; + dedicated_timebase_id = OS_OBJECT_ID_UNDEFINED; + + if (start_time >= (UINT32_MAX / 2) || interval_time >= (UINT32_MAX / 2)) + { + return OS_TIMER_ERR_INVALID_ARGS; + } + if (start_time == 0 && interval_time == 0) + { + return OS_ERROR; + } + + /* + * Check our context. Not allowed to use the timer API from a timer callback. + * Just interested in the object type returned. + */ + local_id = OS_ObjectIdToType_Impl(OS_TaskGetId_Impl()); + if (local_id == OS_OBJECT_TYPE_OS_TIMEBASE) + { + return OS_ERR_INCORRECT_OBJ_STATE; + } + + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, OS_OBJECT_TYPE_OS_TIMECB, timer_id, &local_id, &record); + if (return_code == OS_SUCCESS) + { + local = &OS_timecb_table[local_id]; + + OS_TimeBaseLock_Impl(local->timebase_ref); + + if ((local->flags & TIMECB_FLAG_DEDICATED_TIMEBASE) != 0) + { + dedicated_timebase_id = OS_global_timebase_table[local->timebase_ref].active_id; + } + + local->wait_time = (int32)start_time; + local->interval_time = (int32)interval_time; + + OS_TimeBaseUnlock_Impl(local->timebase_ref); + + /* Unlock the global from OS_ObjectIdCheck() */ + OS_Unlock_Global(OS_OBJECT_TYPE_OS_TIMECB); + } + + /* + * If the timer uses a dedicated time base, then also change that to the same interval. + * + * This is not perfect in the sense that the update is not all done atomically. If this + * is not the first call to TimerSet, then weirdness can happen: + * - a timer tick could occur between setting the callback times above and now + * - the call to OS_TimeBaseSet() could fail leaving us in a mixed state + * + * However, the notion of multiple TimerSet() calls is a gray area to begin with, since + * timer ticks can occur at any moment - there is never a guarantee your new TimerSet values + * will get applied before the old timer expires. Therefore by definition an application + * MUST be able to handle a possible "spurious" callback in these circumstances. + */ + if (return_code == OS_SUCCESS && OS_ObjectIdDefined(dedicated_timebase_id)) + { + return_code = OS_TimeBaseSet(dedicated_timebase_id, start_time, interval_time); + } + return return_code; +} /* end OS_TimerSet */ /*---------------------------------------------------------------- * @@ -401,11 +390,11 @@ 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; - OS_common_record_t *record; - OS_common_record_t *timebase = NULL; - int32 return_code; - uint32 local_id; - osal_id_t dedicated_timebase_id; + OS_common_record_t * record; + OS_common_record_t * timebase = NULL; + int32 return_code; + uint32 local_id; + osal_id_t dedicated_timebase_id; dedicated_timebase_id = OS_OBJECT_ID_UNDEFINED; @@ -419,11 +408,10 @@ 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, &local_id, &record); if (return_code == OS_SUCCESS) { - local = &OS_timecb_table[local_id]; + local = &OS_timecb_table[local_id]; timebase = &OS_global_timebase_table[local->timebase_ref]; OS_TimeBaseLock_Impl(local->timebase_ref); @@ -443,7 +431,8 @@ int32 OS_TimerDelete(osal_id_t timer_id) { if (local->next_ref != local_id) { - OS_ObjectIdCompose_Impl(OS_OBJECT_TYPE_OS_TIMEBASE, local->next_ref, &OS_timebase_table[local->timebase_ref].first_cb); + OS_ObjectIdCompose_Impl(OS_OBJECT_TYPE_OS_TIMEBASE, local->next_ref, + &OS_timebase_table[local->timebase_ref].first_cb); } else { @@ -456,8 +445,8 @@ int32 OS_TimerDelete(osal_id_t timer_id) 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 = local_id; - local->prev_ref = local_id; + local->next_ref = local_id; + local->prev_ref = local_id; OS_TimeBaseUnlock_Impl(local->timebase_ref); @@ -475,7 +464,7 @@ int32 OS_TimerDelete(osal_id_t timer_id) if (return_code == OS_SUCCESS) { OS_ObjectIdRefcountDecr(timebase); - if ( OS_ObjectIdDefined(dedicated_timebase_id) ) + if (OS_ObjectIdDefined(dedicated_timebase_id)) { OS_TimeBaseDelete(dedicated_timebase_id); } @@ -484,7 +473,6 @@ int32 OS_TimerDelete(osal_id_t timer_id) return return_code; } /* end OS_TimerDelete */ - /*---------------------------------------------------------------- * * Function: OS_TimerGetIdByName @@ -493,9 +481,9 @@ int32 OS_TimerDelete(osal_id_t timer_id) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_TimerGetIdByName (osal_id_t *timer_id, const char *timer_name) +int32 OS_TimerGetIdByName(osal_id_t *timer_id, const char *timer_name) { - int32 return_code; + int32 return_code; uint32 local_id; if (timer_id == NULL || timer_name == NULL) @@ -513,13 +501,11 @@ int32 OS_TimerGetIdByName (osal_id_t *timer_id, const char *timer_name) return OS_ERR_INCORRECT_OBJ_STATE; } - return_code = OS_ObjectIdFindByName(OS_OBJECT_TYPE_OS_TIMECB, timer_name, timer_id); return return_code; } /* end OS_TimerGetIdByName */ - /*---------------------------------------------------------------- * * Function: OS_TimerGetInfo @@ -528,16 +514,16 @@ int32 OS_TimerGetIdByName (osal_id_t *timer_id, const char *timer_name) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_TimerGetInfo (osal_id_t timer_id, OS_timer_prop_t *timer_prop) +int32 OS_TimerGetInfo(osal_id_t timer_id, OS_timer_prop_t *timer_prop) { OS_common_record_t *record; - int32 return_code; - uint32 local_id; + int32 return_code; + uint32 local_id; /* Check parameters */ if (timer_prop == NULL) { - return OS_INVALID_POINTER; + return OS_INVALID_POINTER; } /* @@ -550,19 +536,18 @@ int32 OS_TimerGetInfo (osal_id_t timer_id, OS_timer_prop_t *timer_prop) return OS_ERR_INCORRECT_OBJ_STATE; } - memset(timer_prop,0,sizeof(OS_timer_prop_t)); + memset(timer_prop, 0, sizeof(OS_timer_prop_t)); - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL,OS_OBJECT_TYPE_OS_TIMECB, timer_id, &local_id, &record); + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, OS_OBJECT_TYPE_OS_TIMECB, timer_id, &local_id, &record); if (return_code == OS_SUCCESS) { - strncpy(timer_prop->name, record->name_entry, OS_MAX_API_NAME - 1); - timer_prop->creator = record->creator; - timer_prop->interval_time = (uint32)OS_timecb_table[local_id].interval_time; - timer_prop->accuracy = OS_timebase_table[OS_timecb_table[local_id].timebase_ref].accuracy_usec; + strncpy(timer_prop->name, record->name_entry, OS_MAX_API_NAME - 1); + timer_prop->creator = record->creator; + timer_prop->interval_time = (uint32)OS_timecb_table[local_id].interval_time; + timer_prop->accuracy = OS_timebase_table[OS_timecb_table[local_id].timebase_ref].accuracy_usec; - OS_Unlock_Global(OS_OBJECT_TYPE_OS_TIMECB); + OS_Unlock_Global(OS_OBJECT_TYPE_OS_TIMECB); } return return_code; } /* end OS_TimerGetInfo */ - diff --git a/src/os/shared/src/osapi-timebase.c b/src/os/shared/src/osapi-timebase.c index 475a7d994..e881954b7 100644 --- a/src/os/shared/src/osapi-timebase.c +++ b/src/os/shared/src/osapi-timebase.c @@ -48,7 +48,6 @@ #include "os-shared-task.h" #include "os-shared-time.h" - /* * Sanity checks on the user-supplied configuration * The relevent OS_MAX limit should be defined and greater than zero @@ -57,28 +56,24 @@ #error "osconfig.h must define OS_MAX_TIMEBASES to a valid value" #endif - - enum { - LOCAL_NUM_OBJECTS = OS_MAX_TIMEBASES, - LOCAL_OBJID_TYPE = OS_OBJECT_TYPE_OS_TIMEBASE + LOCAL_NUM_OBJECTS = OS_MAX_TIMEBASES, + LOCAL_OBJID_TYPE = OS_OBJECT_TYPE_OS_TIMEBASE }; -OS_timebase_internal_record_t OS_timebase_table [OS_MAX_TIMEBASES]; - +OS_timebase_internal_record_t OS_timebase_table[OS_MAX_TIMEBASES]; /* * Limit to the number of times that the OS timebase servicing thread * is allowed to spin without achieving external sync. */ -#define OS_TIMEBASE_SPIN_LIMIT 4 +#define OS_TIMEBASE_SPIN_LIMIT 4 /**************************************************************************************** TimeBase API ***************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_TimeBaseAPI_Init @@ -93,8 +88,6 @@ int32 OS_TimeBaseAPI_Init(void) return OS_SUCCESS; } /* end OS_TimeBaseAPI_Init */ - - /*---------------------------------------------------------------- * * Function: OS_TimeBaseCreate @@ -106,8 +99,8 @@ int32 OS_TimeBaseAPI_Init(void) int32 OS_TimeBaseCreate(osal_id_t *timer_id, const char *timebase_name, OS_TimerSync_t external_sync) { OS_common_record_t *record; - int32 return_code; - uint32 local_id; + int32 return_code; + uint32 local_id; /* * Specifying a NULL sync function means the timebase is not externally synchronized. @@ -117,7 +110,7 @@ int32 OS_TimeBaseCreate(osal_id_t *timer_id, const char *timebase_name, OS_Timer /* ** Check Parameters */ - if ( timer_id == NULL || timebase_name == NULL) + if (timer_id == NULL || timebase_name == NULL) { return OS_INVALID_POINTER; } @@ -143,28 +136,28 @@ int32 OS_TimeBaseCreate(osal_id_t *timer_id, const char *timebase_name, OS_Timer /* Note - the common ObjectIdAllocate routine will lock the object type and leave it locked. */ return_code = OS_ObjectIdAllocateNew(OS_OBJECT_TYPE_OS_TIMEBASE, timebase_name, &local_id, &record); - if(return_code == OS_SUCCESS) + if (return_code == OS_SUCCESS) { - /* Save all the data to our own internal timer table */ - memset(&OS_timebase_table[local_id], 0, sizeof(OS_timebase_internal_record_t)); - - strncpy(OS_timebase_table[local_id].timebase_name, timebase_name, OS_MAX_API_NAME - 1); - record->name_entry = OS_timebase_table[local_id].timebase_name; - OS_timebase_table[local_id].external_sync = external_sync; - if (external_sync == NULL) - { - OS_timebase_table[local_id].accuracy_usec = OS_SharedGlobalVars.MicroSecPerTick; - } - else - { - OS_timebase_table[local_id].accuracy_usec = 0; - } - - /* Now call the OS-specific implementation. This reads info from the timer table. */ - return_code = OS_TimeBaseCreate_Impl(local_id); - - /* Check result, finalize record, and unlock global table. */ - return_code = OS_ObjectIdFinalizeNew(return_code, record, timer_id); + /* Save all the data to our own internal timer table */ + memset(&OS_timebase_table[local_id], 0, sizeof(OS_timebase_internal_record_t)); + + strncpy(OS_timebase_table[local_id].timebase_name, timebase_name, OS_MAX_API_NAME - 1); + record->name_entry = OS_timebase_table[local_id].timebase_name; + OS_timebase_table[local_id].external_sync = external_sync; + if (external_sync == NULL) + { + OS_timebase_table[local_id].accuracy_usec = OS_SharedGlobalVars.MicroSecPerTick; + } + else + { + OS_timebase_table[local_id].accuracy_usec = 0; + } + + /* Now call the OS-specific implementation. This reads info from the timer table. */ + return_code = OS_TimeBaseCreate_Impl(local_id); + + /* Check result, finalize record, and unlock global table. */ + return_code = OS_ObjectIdFinalizeNew(return_code, record, timer_id); } return return_code; @@ -181,8 +174,8 @@ int32 OS_TimeBaseCreate(osal_id_t *timer_id, const char *timebase_name, OS_Timer int32 OS_TimeBaseSet(osal_id_t timer_id, uint32 start_time, uint32 interval_time) { OS_common_record_t *record; - int32 return_code; - uint32 local_id; + int32 return_code; + uint32 local_id; /* * Internally the implementation represents the interval as a @@ -217,8 +210,8 @@ int32 OS_TimeBaseSet(osal_id_t timer_id, uint32 start_time, uint32 interval_time if (return_code == OS_SUCCESS) { - /* Save the value since we were successful */ - OS_timebase_table[local_id].nominal_start_time = start_time; + /* Save the value since we were successful */ + OS_timebase_table[local_id].nominal_start_time = start_time; OS_timebase_table[local_id].nominal_interval_time = interval_time; } @@ -230,7 +223,6 @@ int32 OS_TimeBaseSet(osal_id_t timer_id, uint32 start_time, uint32 interval_time return return_code; } /* end OS_TimeBaseSet */ - /*---------------------------------------------------------------- * * Function: OS_TimeBaseDelete @@ -242,8 +234,8 @@ int32 OS_TimeBaseSet(osal_id_t timer_id, uint32 start_time, uint32 interval_time int32 OS_TimeBaseDelete(osal_id_t timer_id) { OS_common_record_t *record; - int32 return_code; - uint32 local_id; + int32 return_code; + uint32 local_id; /* * Check our context. Not allowed to use the timer API from a timer callback. @@ -267,7 +259,6 @@ int32 OS_TimeBaseDelete(osal_id_t timer_id) return return_code; } /* end OS_TimeBaseDelete */ - /*---------------------------------------------------------------- * * Function: OS_TimeBaseGetIdByName @@ -276,9 +267,9 @@ int32 OS_TimeBaseDelete(osal_id_t timer_id) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_TimeBaseGetIdByName (osal_id_t *timer_id, const char *timebase_name) +int32 OS_TimeBaseGetIdByName(osal_id_t *timer_id, const char *timebase_name) { - int32 return_code; + int32 return_code; uint32 local_id; if (timer_id == NULL || timebase_name == NULL) @@ -296,13 +287,11 @@ int32 OS_TimeBaseGetIdByName (osal_id_t *timer_id, const char *timebase_name) return OS_ERR_INCORRECT_OBJ_STATE; } - return_code = OS_ObjectIdFindByName(OS_OBJECT_TYPE_OS_TIMEBASE, timebase_name, timer_id); return return_code; } /* end OS_TimeBaseGetIdByName */ - /*---------------------------------------------------------------- * * Function: OS_TimeBaseGetInfo @@ -311,16 +300,16 @@ int32 OS_TimeBaseGetIdByName (osal_id_t *timer_id, const char *timebase_name) * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_TimeBaseGetInfo (osal_id_t timebase_id, OS_timebase_prop_t *timebase_prop) +int32 OS_TimeBaseGetInfo(osal_id_t timebase_id, OS_timebase_prop_t *timebase_prop) { OS_common_record_t *record; - int32 return_code; - uint32 local_id; + int32 return_code; + uint32 local_id; /* Check parameters */ if (timebase_prop == NULL) { - return OS_INVALID_POINTER; + return OS_INVALID_POINTER; } /* @@ -333,26 +322,25 @@ int32 OS_TimeBaseGetInfo (osal_id_t timebase_id, OS_timebase_prop_t *timebase_pr return OS_ERR_INCORRECT_OBJ_STATE; } - memset(timebase_prop,0,sizeof(OS_timebase_prop_t)); + memset(timebase_prop, 0, sizeof(OS_timebase_prop_t)); - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL,LOCAL_OBJID_TYPE, timebase_id, &local_id, &record); + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, timebase_id, &local_id, &record); if (return_code == OS_SUCCESS) { - strncpy(timebase_prop->name, record->name_entry, OS_MAX_API_NAME - 1); - timebase_prop->creator = record->creator; - timebase_prop->nominal_interval_time = OS_timebase_table[local_id].nominal_interval_time; - timebase_prop->freerun_time = OS_timebase_table[local_id].freerun_time; - timebase_prop->accuracy = OS_timebase_table[local_id].accuracy_usec; + strncpy(timebase_prop->name, record->name_entry, OS_MAX_API_NAME - 1); + timebase_prop->creator = record->creator; + timebase_prop->nominal_interval_time = OS_timebase_table[local_id].nominal_interval_time; + timebase_prop->freerun_time = OS_timebase_table[local_id].freerun_time; + timebase_prop->accuracy = OS_timebase_table[local_id].accuracy_usec; - return_code = OS_TimeBaseGetInfo_Impl(local_id, timebase_prop); + return_code = OS_TimeBaseGetInfo_Impl(local_id, timebase_prop); - OS_Unlock_Global(LOCAL_OBJID_TYPE); + OS_Unlock_Global(LOCAL_OBJID_TYPE); } return return_code; } /* end OS_TimeBaseGetInfo */ - /*---------------------------------------------------------------- * * Function: OS_TimeBaseGetFreeRun @@ -361,17 +349,17 @@ int32 OS_TimeBaseGetInfo (osal_id_t timebase_id, OS_timebase_prop_t *timebase_pr * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_TimeBaseGetFreeRun (osal_id_t timebase_id, uint32 *freerun_val) +int32 OS_TimeBaseGetFreeRun(osal_id_t timebase_id, uint32 *freerun_val) { OS_common_record_t *record; - int32 return_code; - uint32 local_id; + int32 return_code; + uint32 local_id; /* Check parameters */ - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE,LOCAL_OBJID_TYPE, timebase_id, &local_id, &record); + return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, timebase_id, &local_id, &record); if (return_code == OS_SUCCESS) { - *freerun_val = OS_timebase_table[local_id].freerun_time; + *freerun_val = OS_timebase_table[local_id].freerun_time; } return return_code; @@ -398,17 +386,17 @@ int32 OS_TimeBaseGetFreeRun (osal_id_t timebase_id, uint32 *freerun_val) *-----------------------------------------------------------------*/ void OS_TimeBase_CallbackThread(osal_id_t timebase_id) { - OS_TimerSync_t syncfunc; + OS_TimerSync_t syncfunc; OS_timebase_internal_record_t *timebase; - OS_timecb_internal_record_t *timecb; - OS_common_record_t *record; - uint32 local_id; - uint32 timer_id; - uint32 curr_cb_local_id; - osal_id_t curr_cb_public_id; - uint32 tick_time; - uint32 spin_cycles; - int32 saved_wait_time; + OS_timecb_internal_record_t * timecb; + OS_common_record_t * record; + uint32 local_id; + uint32 timer_id; + uint32 curr_cb_local_id; + osal_id_t curr_cb_public_id; + uint32 tick_time; + uint32 spin_cycles; + int32 saved_wait_time; /* * Register this task as a time base handler. @@ -425,8 +413,8 @@ void OS_TimeBase_CallbackThread(osal_id_t timebase_id) return; } - timebase = &OS_timebase_table[local_id]; - syncfunc = timebase->external_sync; + timebase = &OS_timebase_table[local_id]; + syncfunc = timebase->external_sync; spin_cycles = 0; OS_Unlock_Global(OS_OBJECT_TYPE_OS_TIMEBASE); @@ -485,7 +473,7 @@ void OS_TimeBase_CallbackThread(osal_id_t timebase_id) * After waiting, check that our ID still matches * If not then it means this time base got deleted.... */ - if ( !OS_ObjectIdEqual(timebase_id, record->active_id) ) + if (!OS_ObjectIdEqual(timebase_id, record->active_id)) { OS_TimeBaseUnlock_Impl(local_id); break; @@ -498,8 +486,8 @@ void OS_TimeBase_CallbackThread(osal_id_t timebase_id) do { curr_cb_public_id = OS_global_timecb_table[curr_cb_local_id].active_id; - timecb = &OS_timecb_table[curr_cb_local_id]; - saved_wait_time = timecb->wait_time; + timecb = &OS_timecb_table[curr_cb_local_id]; + saved_wait_time = timecb->wait_time; timecb->wait_time -= tick_time; while (timecb->wait_time <= 0) { @@ -536,12 +524,10 @@ void OS_TimeBase_CallbackThread(osal_id_t timebase_id) } } curr_cb_local_id = timecb->next_ref; - } - while (curr_cb_local_id != timer_id); + } while (curr_cb_local_id != timer_id); } OS_TimeBaseUnlock_Impl(local_id); - } } /* end OS_TimeBase_CallbackThread */ @@ -569,7 +555,7 @@ int32 OS_Milli2Ticks(uint32 milli_seconds, int *ticks) else { return_code = OS_ERROR; - *ticks = 0; + *ticks = 0; } return return_code; diff --git a/src/os/vxworks/inc/os-impl-binsem.h b/src/os/vxworks/inc/os-impl-binsem.h index be6defb3a..3da1e1a97 100644 --- a/src/os/vxworks/inc/os-impl-binsem.h +++ b/src/os/vxworks/inc/os-impl-binsem.h @@ -39,7 +39,6 @@ typedef struct } OS_impl_binsem_internal_record_t; /* Tables where the OS object information is stored */ -extern OS_impl_binsem_internal_record_t OS_impl_bin_sem_table [OS_MAX_BIN_SEMAPHORES]; - -#endif /* INCLUDE_OS_IMPL_BINSEM_H_ */ +extern OS_impl_binsem_internal_record_t OS_impl_bin_sem_table[OS_MAX_BIN_SEMAPHORES]; +#endif /* INCLUDE_OS_IMPL_BINSEM_H_ */ diff --git a/src/os/vxworks/inc/os-impl-console.h b/src/os/vxworks/inc/os-impl-console.h index 6e54ab7c8..e10f88534 100644 --- a/src/os/vxworks/inc/os-impl-console.h +++ b/src/os/vxworks/inc/os-impl-console.h @@ -37,13 +37,11 @@ typedef struct { VX_COUNTING_SEMAPHORE(cmem); - bool is_async; - SEM_ID datasem; - TASK_ID taskid; + bool is_async; + SEM_ID datasem; + TASK_ID taskid; } OS_impl_console_internal_record_t; +extern OS_impl_console_internal_record_t OS_impl_console_table[OS_MAX_CONSOLES]; -extern OS_impl_console_internal_record_t OS_impl_console_table [OS_MAX_CONSOLES]; - -#endif /* INCLUDE_OS_IMPL_CONSOLE_H_ */ - +#endif /* INCLUDE_OS_IMPL_CONSOLE_H_ */ diff --git a/src/os/vxworks/inc/os-impl-countsem.h b/src/os/vxworks/inc/os-impl-countsem.h index 2998827ad..4698756c3 100644 --- a/src/os/vxworks/inc/os-impl-countsem.h +++ b/src/os/vxworks/inc/os-impl-countsem.h @@ -39,8 +39,6 @@ typedef struct } OS_impl_countsem_internal_record_t; /* Tables where the OS object information is stored */ -extern OS_impl_countsem_internal_record_t OS_impl_count_sem_table [OS_MAX_COUNT_SEMAPHORES]; - - -#endif /* INCLUDE_OS_IMPL_COUNTSEM_H_ */ +extern OS_impl_countsem_internal_record_t OS_impl_count_sem_table[OS_MAX_COUNT_SEMAPHORES]; +#endif /* INCLUDE_OS_IMPL_COUNTSEM_H_ */ diff --git a/src/os/vxworks/inc/os-impl-dirs.h b/src/os/vxworks/inc/os-impl-dirs.h index 53ef03135..e391792c1 100644 --- a/src/os/vxworks/inc/os-impl-dirs.h +++ b/src/os/vxworks/inc/os-impl-dirs.h @@ -38,12 +38,9 @@ typedef struct DIR *dp; } OS_impl_dir_internal_record_t; - /* * The directory handle table. */ extern OS_impl_dir_internal_record_t OS_impl_dir_table[OS_MAX_NUM_OPEN_DIRS]; - -#endif /* INCLUDE_OS_IMPL_DIRS_H_ */ - +#endif /* INCLUDE_OS_IMPL_DIRS_H_ */ diff --git a/src/os/vxworks/inc/os-impl-files.h b/src/os/vxworks/inc/os-impl-files.h index 45d8a8ecc..d32892dec 100644 --- a/src/os/vxworks/inc/os-impl-files.h +++ b/src/os/vxworks/inc/os-impl-files.h @@ -42,12 +42,9 @@ #define OS_IMPL_SELF_EUID 0 #define OS_IMPL_SELF_EGID 0 - /* * Do not set any additional flags for regular files */ -#define OS_IMPL_REGULAR_FILE_FLAGS 0 - - -#endif /* INCLUDE_OS_IMPL_FILES_H_ */ +#define OS_IMPL_REGULAR_FILE_FLAGS 0 +#endif /* INCLUDE_OS_IMPL_FILES_H_ */ diff --git a/src/os/vxworks/inc/os-impl-filesys.h b/src/os/vxworks/inc/os-impl-filesys.h index e80b6e7db..d0649d348 100644 --- a/src/os/vxworks/inc/os-impl-filesys.h +++ b/src/os/vxworks/inc/os-impl-filesys.h @@ -35,14 +35,11 @@ typedef struct { - BLK_DEV *blkDev; - device_t xbd; - uint32 xbdMaxPartitions; + BLK_DEV *blkDev; + device_t xbd; + uint32 xbdMaxPartitions; } OS_impl_filesys_internal_record_t; - extern OS_impl_filesys_internal_record_t OS_impl_filesys_table[OS_MAX_FILE_SYSTEMS]; - -#endif /* INCLUDE_OS_IMPL_FILESYS_H_ */ - +#endif /* INCLUDE_OS_IMPL_FILESYS_H_ */ diff --git a/src/os/vxworks/inc/os-impl-gettime.h b/src/os/vxworks/inc/os-impl-gettime.h index 6c2083a67..c0e7a5f44 100644 --- a/src/os/vxworks/inc/os-impl-gettime.h +++ b/src/os/vxworks/inc/os-impl-gettime.h @@ -31,8 +31,6 @@ #include #include +#define OSAL_GETTIME_SOURCE_CLOCK CLOCK_MONOTONIC -#define OSAL_GETTIME_SOURCE_CLOCK CLOCK_MONOTONIC - -#endif /* INCLUDE_OS_IMPL_GETTIME_H_ */ - +#endif /* INCLUDE_OS_IMPL_GETTIME_H_ */ diff --git a/src/os/vxworks/inc/os-impl-io.h b/src/os/vxworks/inc/os-impl-io.h index 804410988..0bf73c3bc 100644 --- a/src/os/vxworks/inc/os-impl-io.h +++ b/src/os/vxworks/inc/os-impl-io.h @@ -36,7 +36,7 @@ typedef struct { - int fd; + int fd; bool selectable; } OS_VxWorks_filehandle_entry_t; @@ -53,8 +53,6 @@ extern OS_VxWorks_filehandle_entry_t OS_impl_filehandle_table[OS_MAX_NUM_OPEN_FI * This can be turned off in a future version if the vendor fixes the * prototype to be standards-compliant */ -#define GENERIC_IO_CONST_DATA_CAST (void*) - - -#endif /* INCLUDE_OS_IMPL_IO_H_ */ +#define GENERIC_IO_CONST_DATA_CAST (void *) +#endif /* INCLUDE_OS_IMPL_IO_H_ */ diff --git a/src/os/vxworks/inc/os-impl-loader.h b/src/os/vxworks/inc/os-impl-loader.h index c9b386e57..05da9da70 100644 --- a/src/os/vxworks/inc/os-impl-loader.h +++ b/src/os/vxworks/inc/os-impl-loader.h @@ -51,6 +51,4 @@ typedef struct */ extern OS_impl_module_internal_record_t OS_impl_module_table[OS_MAX_MODULES]; - -#endif /* INCLUDE_OS_IMPL_LOADER_H_ */ - +#endif /* INCLUDE_OS_IMPL_LOADER_H_ */ diff --git a/src/os/vxworks/inc/os-impl-mutex.h b/src/os/vxworks/inc/os-impl-mutex.h index 563cb62bf..91c1d93a6 100644 --- a/src/os/vxworks/inc/os-impl-mutex.h +++ b/src/os/vxworks/inc/os-impl-mutex.h @@ -38,8 +38,6 @@ typedef struct } OS_impl_mutsem_internal_record_t; /* Tables where the OS object information is stored */ -extern OS_impl_mutsem_internal_record_t OS_impl_mutex_table [OS_MAX_MUTEXES]; - - -#endif /* INCLUDE_OS_IMPL_MUTEX_H_ */ +extern OS_impl_mutsem_internal_record_t OS_impl_mutex_table[OS_MAX_MUTEXES]; +#endif /* INCLUDE_OS_IMPL_MUTEX_H_ */ diff --git a/src/os/vxworks/inc/os-impl-network.h b/src/os/vxworks/inc/os-impl-network.h index 4d6ca2eca..5f7943edf 100644 --- a/src/os/vxworks/inc/os-impl-network.h +++ b/src/os/vxworks/inc/os-impl-network.h @@ -36,6 +36,4 @@ #include #include - -#endif /* INCLUDE_OS_IMPL_NETWORK_H_ */ - +#endif /* INCLUDE_OS_IMPL_NETWORK_H_ */ diff --git a/src/os/vxworks/inc/os-impl-queues.h b/src/os/vxworks/inc/os-impl-queues.h index dbabba178..48a47269a 100644 --- a/src/os/vxworks/inc/os-impl-queues.h +++ b/src/os/vxworks/inc/os-impl-queues.h @@ -37,8 +37,6 @@ typedef struct } OS_impl_queue_internal_record_t; /* Tables where the OS object information is stored */ -extern OS_impl_queue_internal_record_t OS_impl_queue_table [OS_MAX_QUEUES]; - - -#endif /* INCLUDE_OS_IMPL_QUEUES_H_ */ +extern OS_impl_queue_internal_record_t OS_impl_queue_table[OS_MAX_QUEUES]; +#endif /* INCLUDE_OS_IMPL_QUEUES_H_ */ diff --git a/src/os/vxworks/inc/os-impl-select.h b/src/os/vxworks/inc/os-impl-select.h index 871d4090d..fd88d6e8e 100644 --- a/src/os/vxworks/inc/os-impl-select.h +++ b/src/os/vxworks/inc/os-impl-select.h @@ -31,6 +31,4 @@ #include "os-impl-io.h" #include - -#endif /* INCLUDE_OS_IMPL_SELECT_H_ */ - +#endif /* INCLUDE_OS_IMPL_SELECT_H_ */ diff --git a/src/os/vxworks/inc/os-impl-sockets.h b/src/os/vxworks/inc/os-impl-sockets.h index 4861cf23f..8c17d2254 100644 --- a/src/os/vxworks/inc/os-impl-sockets.h +++ b/src/os/vxworks/inc/os-impl-sockets.h @@ -41,12 +41,9 @@ /* * Use the O_NONBLOCK flag on sockets */ -#define OS_IMPL_SOCKET_FLAGS O_NONBLOCK - +#define OS_IMPL_SOCKET_FLAGS O_NONBLOCK /* The "in.h" header file supplied in VxWorks 6.9 is missing the "in_port_t" typedef */ typedef u_short in_port_t; - -#endif /* INCLUDE_OS_IMPL_SOCKETS_H_ */ - +#endif /* INCLUDE_OS_IMPL_SOCKETS_H_ */ diff --git a/src/os/vxworks/inc/os-impl-symtab.h b/src/os/vxworks/inc/os-impl-symtab.h index 7e2696dab..373d9b60c 100644 --- a/src/os/vxworks/inc/os-impl-symtab.h +++ b/src/os/vxworks/inc/os-impl-symtab.h @@ -33,17 +33,15 @@ typedef struct { - uint32 Sizelimit; - uint32 CurrSize; - int32 StatusCode; - int fd; + uint32 Sizelimit; + uint32 CurrSize; + int32 StatusCode; + int fd; } SymbolDumpState_t; - /* A global for storing the state in a SymbolDump call */ extern SymbolDumpState_t OS_VxWorks_SymbolDumpState; -BOOL OS_SymTableIterator_Impl ( char *name, SYM_VALUE val, SYM_TYPE type, _Vx_usr_arg_t arg, SYM_GROUP group ); - -#endif /* INCLUDE_OS_IMPL_SYMTAB_H_ */ +BOOL OS_SymTableIterator_Impl(char *name, SYM_VALUE val, SYM_TYPE type, _Vx_usr_arg_t arg, SYM_GROUP group); +#endif /* INCLUDE_OS_IMPL_SYMTAB_H_ */ diff --git a/src/os/vxworks/inc/os-impl-tasks.h b/src/os/vxworks/inc/os-impl-tasks.h index b02cc261a..87cb15818 100644 --- a/src/os/vxworks/inc/os-impl-tasks.h +++ b/src/os/vxworks/inc/os-impl-tasks.h @@ -31,19 +31,16 @@ #include #include - /*tasks */ typedef struct { - WIND_TCB tcb; /* Must be first */ - TASK_ID vxid; - void *heap_block; /* set non-null if the stack was obtained with malloc() */ - long heap_block_size; + WIND_TCB tcb; /* Must be first */ + TASK_ID vxid; + void * heap_block; /* set non-null if the stack was obtained with malloc() */ + long heap_block_size; } OS_impl_task_internal_record_t; - /* Tables where the OS object information is stored */ -extern OS_impl_task_internal_record_t OS_impl_task_table [OS_MAX_TASKS]; - -#endif /* INCLUDE_OS_IMPL_TASKS_H_ */ +extern OS_impl_task_internal_record_t OS_impl_task_table[OS_MAX_TASKS]; +#endif /* INCLUDE_OS_IMPL_TASKS_H_ */ diff --git a/src/os/vxworks/inc/os-impl-timebase.h b/src/os/vxworks/inc/os-impl-timebase.h index 02a2b0bc6..2c3afab8b 100644 --- a/src/os/vxworks/inc/os-impl-timebase.h +++ b/src/os/vxworks/inc/os-impl-timebase.h @@ -44,24 +44,21 @@ enum OS_TimerState typedef struct { VX_MUTEX_SEMAPHORE(mmem); - SEM_ID handler_mutex; - int assigned_signal; - sigset_t timer_sigset; - TASK_ID handler_task; - timer_t host_timerid; - enum OS_TimerState timer_state; - uint32 configured_start_time; - uint32 configured_interval_time; - bool reset_flag; + SEM_ID handler_mutex; + int assigned_signal; + sigset_t timer_sigset; + TASK_ID handler_task; + timer_t host_timerid; + enum OS_TimerState timer_state; + uint32 configured_start_time; + uint32 configured_interval_time; + bool reset_flag; } OS_impl_timebase_internal_record_t; - /**************************************************************************************** GLOBAL DATA ***************************************************************************************/ extern OS_impl_timebase_internal_record_t OS_impl_timebase_table[OS_MAX_TIMEBASES]; - -#endif /* INCLUDE_OS_IMPL_TIMEBASE_H_ */ - +#endif /* INCLUDE_OS_IMPL_TIMEBASE_H_ */ diff --git a/src/os/vxworks/inc/os-vxworks.h b/src/os/vxworks/inc/os-vxworks.h index 0cfe299f5..9b993db96 100644 --- a/src/os/vxworks/inc/os-vxworks.h +++ b/src/os/vxworks/inc/os-vxworks.h @@ -28,7 +28,6 @@ #ifndef INCLUDE_OS_VXWORKS_H_ #define INCLUDE_OS_VXWORKS_H_ - /**************************************************************************************** COMMON INCLUDE FILES ****************************************************************************************/ @@ -44,7 +43,6 @@ #include - /**************************************************************************************** DEFINES ****************************************************************************************/ @@ -55,8 +53,8 @@ typedef struct { - void * const mem; - SEM_ID vxid; + void *const mem; + SEM_ID vxid; } VxWorks_GlobalMutex_t; /* @@ -68,17 +66,15 @@ typedef struct typedef union { osal_id_t id; - int arg; + int arg; } VxWorks_ID_Buffer_t; - /**************************************************************************************** GLOBAL DATA ****************************************************************************************/ extern VxWorks_GlobalMutex_t VX_MUTEX_TABLE[]; - /**************************************************************************************** VXWORKS IMPLEMENTATION FUNCTION PROTOTYPES ****************************************************************************************/ @@ -97,15 +93,13 @@ int OS_VxWorks_TaskEntry(int arg); int OS_VxWorks_ConsoleTask_Entry(int arg); uint32 OS_VxWorks_SigWait(uint32 local_id); -int OS_VxWorks_TimeBaseTask(int arg); -void OS_VxWorks_RegisterTimer(uint32 local_id); -void OS_VxWorks_UsecToTimespec(uint32 usecs, struct timespec *time_spec); +int OS_VxWorks_TimeBaseTask(int arg); +void OS_VxWorks_RegisterTimer(uint32 local_id); +void OS_VxWorks_UsecToTimespec(uint32 usecs, struct timespec *time_spec); int32 OS_VxWorks_GenericSemTake(SEM_ID vxid, int sys_ticks); int32 OS_VxWorks_GenericSemGive(SEM_ID vxid); - int32 OS_VxWorks_TableMutex_Init(uint32 idtype); -#endif /* INCLUDE_OS_VXWORKS_H_ */ - +#endif /* INCLUDE_OS_VXWORKS_H_ */ diff --git a/src/os/vxworks/src/os-impl-binsem.c b/src/os/vxworks/src/os-impl-binsem.c index 60f527ec7..c2c0c4e96 100644 --- a/src/os/vxworks/src/os-impl-binsem.c +++ b/src/os/vxworks/src/os-impl-binsem.c @@ -38,14 +38,12 @@ DEFINES ****************************************************************************************/ - /**************************************************************************************** GLOBAL DATA ****************************************************************************************/ /* Tables where the OS object information is stored */ -OS_impl_binsem_internal_record_t OS_impl_bin_sem_table [OS_MAX_BIN_SEMAPHORES]; - +OS_impl_binsem_internal_record_t OS_impl_bin_sem_table[OS_MAX_BIN_SEMAPHORES]; /**************************************************************************************** BINARY SEMAPHORE API @@ -64,7 +62,6 @@ int32 OS_VxWorks_BinSemAPI_Impl_Init(void) return (OS_SUCCESS); } /* end OS_VxWorks_BinSemAPI_Impl_Init */ - /*---------------------------------------------------------------- * * Function: OS_BinSemCreate_Impl @@ -73,7 +70,7 @@ int32 OS_VxWorks_BinSemAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 options) +int32 OS_BinSemCreate_Impl(uint32 sem_id, uint32 sem_initial_value, uint32 options) { SEM_ID tmp_sem_id; @@ -82,9 +79,9 @@ int32 OS_BinSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 opti tmp_sem_id = semBInitialize(OS_impl_bin_sem_table[sem_id].bmem, SEM_Q_PRIORITY, sem_initial_value); /* check if semBInitialize failed */ - if(tmp_sem_id == (SEM_ID)0) + if (tmp_sem_id == (SEM_ID)0) { - OS_DEBUG("semBInitialize() - vxWorks errno %d\n",errno); + OS_DEBUG("semBInitialize() - vxWorks errno %d\n", errno); return OS_SEM_FAILURE; } @@ -93,8 +90,6 @@ int32 OS_BinSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 opti } /* end OS_BinSemCreate_Impl */ - - /*---------------------------------------------------------------- * * Function: OS_BinSemDelete_Impl @@ -103,7 +98,7 @@ int32 OS_BinSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 opti * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemDelete_Impl (uint32 sem_id) +int32 OS_BinSemDelete_Impl(uint32 sem_id) { /* * As the memory for the sem is statically allocated, delete is a no-op. @@ -113,7 +108,6 @@ int32 OS_BinSemDelete_Impl (uint32 sem_id) } /* end OS_BinSemDelete_Impl */ - /*---------------------------------------------------------------- * * Function: OS_BinSemGive_Impl @@ -122,13 +116,12 @@ int32 OS_BinSemDelete_Impl (uint32 sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemGive_Impl (uint32 sem_id) +int32 OS_BinSemGive_Impl(uint32 sem_id) { /* Use common routine */ return OS_VxWorks_GenericSemGive(OS_impl_bin_sem_table[sem_id].vxid); } /* end OS_BinSemGive_Impl */ - /*---------------------------------------------------------------- * * Function: OS_BinSemFlush_Impl @@ -137,19 +130,18 @@ int32 OS_BinSemGive_Impl (uint32 sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemFlush_Impl (uint32 sem_id) +int32 OS_BinSemFlush_Impl(uint32 sem_id) { /* Flush VxWorks Semaphore */ - if(semFlush(OS_impl_bin_sem_table[sem_id].vxid) != OK) + if (semFlush(OS_impl_bin_sem_table[sem_id].vxid) != OK) { - OS_DEBUG("semFlush() - vxWorks errno %d\n",errno); + OS_DEBUG("semFlush() - vxWorks errno %d\n", errno); return OS_SEM_FAILURE; } return OS_SUCCESS; } /* end OS_BinSemFlush_Impl */ - /*---------------------------------------------------------------- * * Function: OS_BinSemTake_Impl @@ -158,14 +150,13 @@ int32 OS_BinSemFlush_Impl (uint32 sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemTake_Impl (uint32 sem_id) +int32 OS_BinSemTake_Impl(uint32 sem_id) { /* Use common routine */ return OS_VxWorks_GenericSemTake(OS_impl_bin_sem_table[sem_id].vxid, WAIT_FOREVER); } /* end OS_BinSemTake_Impl */ - /*---------------------------------------------------------------- * * Function: OS_BinSemTimedWait_Impl @@ -174,7 +165,7 @@ int32 OS_BinSemTake_Impl (uint32 sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemTimedWait_Impl (uint32 sem_id, uint32 msecs) +int32 OS_BinSemTimedWait_Impl(uint32 sem_id, uint32 msecs) { int ticks; int32 status; @@ -189,7 +180,6 @@ int32 OS_BinSemTimedWait_Impl (uint32 sem_id, uint32 msecs) return status; } /* end OS_BinSemTimedWait_Impl */ - /*---------------------------------------------------------------- * * Function: OS_BinSemGetInfo_Impl @@ -198,10 +188,8 @@ int32 OS_BinSemTimedWait_Impl (uint32 sem_id, uint32 msecs) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemGetInfo_Impl (uint32 sem_id, OS_bin_sem_prop_t *bin_prop) +int32 OS_BinSemGetInfo_Impl(uint32 sem_id, OS_bin_sem_prop_t *bin_prop) { /* VxWorks has no API for obtaining the current value of a semaphore */ return OS_SUCCESS; } /* end OS_BinSemGetInfo_Impl */ - - diff --git a/src/os/vxworks/src/os-impl-common.c b/src/os/vxworks/src/os-impl-common.c index 127c74f17..6c3dc4aa8 100644 --- a/src/os/vxworks/src/os-impl-common.c +++ b/src/os/vxworks/src/os-impl-common.c @@ -46,9 +46,7 @@ GLOBAL DATA ****************************************************************************************/ - -static TASK_ID OS_idle_task_id; - +static TASK_ID OS_idle_task_id; /**************************************************************************************** INITIALIZATION FUNCTION @@ -64,7 +62,7 @@ static TASK_ID OS_idle_task_id; *-----------------------------------------------------------------*/ int32 OS_API_Impl_Init(uint32 idtype) { - int32 return_code; + int32 return_code; return_code = OS_VxWorks_TableMutex_Init(idtype); if (return_code != OS_SUCCESS) @@ -72,43 +70,42 @@ int32 OS_API_Impl_Init(uint32 idtype) return return_code; } - switch(idtype) + switch (idtype) { - case OS_OBJECT_TYPE_OS_TASK: - return_code = OS_VxWorks_TaskAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_QUEUE: - return_code = OS_VxWorks_QueueAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_BINSEM: - return_code = OS_VxWorks_BinSemAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_COUNTSEM: - return_code = OS_VxWorks_CountSemAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_MUTEX: - return_code = OS_VxWorks_MutexAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_MODULE: - return_code = OS_VxWorks_ModuleAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_TIMEBASE: - return_code = OS_VxWorks_TimeBaseAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_STREAM: - return_code = OS_VxWorks_StreamAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_DIR: - return_code = OS_VxWorks_DirAPI_Impl_Init(); - break; - default: - break; + case OS_OBJECT_TYPE_OS_TASK: + return_code = OS_VxWorks_TaskAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_QUEUE: + return_code = OS_VxWorks_QueueAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_BINSEM: + return_code = OS_VxWorks_BinSemAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_COUNTSEM: + return_code = OS_VxWorks_CountSemAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_MUTEX: + return_code = OS_VxWorks_MutexAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_MODULE: + return_code = OS_VxWorks_ModuleAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_TIMEBASE: + return_code = OS_VxWorks_TimeBaseAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_STREAM: + return_code = OS_VxWorks_StreamAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_DIR: + return_code = OS_VxWorks_DirAPI_Impl_Init(); + break; + default: + break; } - return(return_code); + return (return_code); } /* end OS_API_Impl_Init */ - /*---------------------------------------------------------------- * * Function: OS_IdleLoop_Impl @@ -119,12 +116,11 @@ int32 OS_API_Impl_Init(uint32 idtype) *-----------------------------------------------------------------*/ void OS_IdleLoop_Impl(void) { - TASK_ID tid = taskIdSelf(); + TASK_ID tid = taskIdSelf(); OS_idle_task_id = tid; taskSuspend(tid); } /* end OS_IdleLoop_Impl */ - /*---------------------------------------------------------------- * * Function: OS_ApplicationShutdown_Impl @@ -138,9 +134,6 @@ void OS_ApplicationShutdown_Impl(void) taskResume(OS_idle_task_id); } /* end OS_ApplicationShutdown_Impl */ - - - /**************************************************************************************** GENERIC SEMAPHORE API ****************************************************************************************/ @@ -164,15 +157,14 @@ void OS_ApplicationShutdown_Impl(void) int32 OS_VxWorks_GenericSemGive(SEM_ID vxid) { /* Give VxWorks Semaphore */ - if(semGive(vxid) != OK) + if (semGive(vxid) != OK) { - OS_DEBUG("semGive() - vxWorks errno %d\n",errno); + OS_DEBUG("semGive() - vxWorks errno %d\n", errno); return OS_SEM_FAILURE; } return OS_SUCCESS; } /* end OS_VxWorks_GenericSemGive */ - /*---------------------------------------------------------------- * * Function: OS_VxWorks_GenericSemTake @@ -195,13 +187,12 @@ int32 OS_VxWorks_GenericSemTake(SEM_ID vxid, int sys_ticks) */ if (errno == S_objLib_OBJ_TIMEOUT) { - return OS_SEM_TIMEOUT; + return OS_SEM_TIMEOUT; } - OS_DEBUG("semTake() - vxWorks errno %d\n",errno); + OS_DEBUG("semTake() - vxWorks errno %d\n", errno); return OS_SEM_FAILURE; } return OS_SUCCESS; } /* end OS_VxWorks_GenericSemTake */ - diff --git a/src/os/vxworks/src/os-impl-console.c b/src/os/vxworks/src/os-impl-console.c index cb9b323c1..52f82aa64 100644 --- a/src/os/vxworks/src/os-impl-console.c +++ b/src/os/vxworks/src/os-impl-console.c @@ -43,25 +43,21 @@ * This option was removed from osconfig.h and now is * assumed to always be on. */ -#define OS_CONSOLE_ASYNC true -#define OS_CONSOLE_TASK_PRIORITY OS_UTILITYTASK_PRIORITY -#define OS_CONSOLE_TASK_STACKSIZE OS_UTILITYTASK_STACK_SIZE - +#define OS_CONSOLE_ASYNC true +#define OS_CONSOLE_TASK_PRIORITY OS_UTILITYTASK_PRIORITY +#define OS_CONSOLE_TASK_STACKSIZE OS_UTILITYTASK_STACK_SIZE /**************************************************************************************** GLOBAL DATA ****************************************************************************************/ /* Tables where the OS object information is stored */ -OS_impl_console_internal_record_t OS_impl_console_table [OS_MAX_CONSOLES]; - +OS_impl_console_internal_record_t OS_impl_console_table[OS_MAX_CONSOLES]; /********************************************************************/ /* CONSOLE OUTPUT */ /********************************************************************/ - - /*---------------------------------------------------------------- * * Function: OS_ConsoleWakeup_Impl @@ -70,16 +66,16 @@ OS_impl_console_internal_record_t OS_impl_console_table [OS_MAX_CONSOLES * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -void OS_ConsoleWakeup_Impl(uint32 local_id) +void OS_ConsoleWakeup_Impl(uint32 local_id) { OS_impl_console_internal_record_t *local = &OS_impl_console_table[local_id]; if (local->is_async) { /* post the sem for the utility task to run */ - if(semGive(local->datasem) == ERROR) + if (semGive(local->datasem) == ERROR) { - OS_DEBUG("semGive() - vxWorks errno %d\n",errno); + OS_DEBUG("semGive() - vxWorks errno %d\n", errno); } } else @@ -89,7 +85,6 @@ void OS_ConsoleWakeup_Impl(uint32 local_id) } } /* end OS_ConsoleWakeup_Impl */ - /*---------------------------------------------------------------- * * Function: OS_ConsoleTask_Entry @@ -99,16 +94,16 @@ void OS_ConsoleWakeup_Impl(uint32 local_id) *-----------------------------------------------------------------*/ int OS_VxWorks_ConsoleTask_Entry(int arg) { - uint32 local_id = arg; + uint32 local_id = arg; OS_impl_console_internal_record_t *local; local = &OS_impl_console_table[local_id]; while (true) { OS_ConsoleOutput_Impl(local_id); - if(semTake(local->datasem, WAIT_FOREVER) == ERROR) + if (semTake(local->datasem, WAIT_FOREVER) == ERROR) { - OS_DEBUG("semTake() - vxWorks errno %d\n",errno); + OS_DEBUG("semTake() - vxWorks errno %d\n", errno); break; } } @@ -127,11 +122,11 @@ int OS_VxWorks_ConsoleTask_Entry(int arg) int32 OS_ConsoleCreate_Impl(uint32 local_id) { OS_impl_console_internal_record_t *local = &OS_impl_console_table[local_id]; - int32 return_code; + int32 return_code; if (local_id == 0) { - return_code = OS_SUCCESS; + return_code = OS_SUCCESS; local->is_async = OS_CONSOLE_ASYNC; if (local->is_async) @@ -143,23 +138,20 @@ int32 OS_ConsoleCreate_Impl(uint32 local_id) local->datasem = semCInitialize(local->cmem, SEM_Q_PRIORITY, 0); /* check if semCInitialize failed */ - if(local->datasem == (SEM_ID)0) + if (local->datasem == (SEM_ID)0) { - OS_DEBUG("semCInitialize() - vxWorks errno %d\n",errno); + OS_DEBUG("semCInitialize() - vxWorks errno %d\n", errno); return OS_SEM_FAILURE; } /* spawn the async output helper task */ - local->taskid = taskSpawn(OS_console_table[local_id].device_name, - OS_CONSOLE_TASK_PRIORITY, - 0, - OS_CONSOLE_TASK_STACKSIZE , - (FUNCPTR)OS_VxWorks_ConsoleTask_Entry, - local_id,0,0,0,0,0,0,0,0,0); + local->taskid = taskSpawn(OS_console_table[local_id].device_name, OS_CONSOLE_TASK_PRIORITY, 0, + OS_CONSOLE_TASK_STACKSIZE, (FUNCPTR)OS_VxWorks_ConsoleTask_Entry, local_id, 0, 0, + 0, 0, 0, 0, 0, 0, 0); if (local->taskid == (TASK_ID)ERROR) { - OS_DEBUG("taskSpawn() - vxWorks errno %d\n",errno); + OS_DEBUG("taskSpawn() - vxWorks errno %d\n", errno); return_code = OS_ERROR; } } @@ -172,6 +164,3 @@ int32 OS_ConsoleCreate_Impl(uint32 local_id) return return_code; } /* end OS_ConsoleCreate_Impl */ - - - diff --git a/src/os/vxworks/src/os-impl-countsem.c b/src/os/vxworks/src/os-impl-countsem.c index d4416a3d7..c22f847d4 100644 --- a/src/os/vxworks/src/os-impl-countsem.c +++ b/src/os/vxworks/src/os-impl-countsem.c @@ -37,20 +37,17 @@ DEFINES ****************************************************************************************/ - /**************************************************************************************** GLOBAL DATA ****************************************************************************************/ - /* Tables where the OS object information is stored */ -OS_impl_countsem_internal_record_t OS_impl_count_sem_table [OS_MAX_COUNT_SEMAPHORES]; +OS_impl_countsem_internal_record_t OS_impl_count_sem_table[OS_MAX_COUNT_SEMAPHORES]; /**************************************************************************************** COUNTING SEMAPHORE API ****************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_VxWorks_CountSemAPI_Impl_Init @@ -64,8 +61,6 @@ int32 OS_VxWorks_CountSemAPI_Impl_Init(void) return (OS_SUCCESS); } /* end OS_VxWorks_CountSemAPI_Impl_Init */ - - /*---------------------------------------------------------------- * * Function: OS_CountSemCreate_Impl @@ -74,7 +69,7 @@ int32 OS_VxWorks_CountSemAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 options) +int32 OS_CountSemCreate_Impl(uint32 sem_id, uint32 sem_initial_value, uint32 options) { SEM_ID tmp_sem_id; @@ -83,9 +78,9 @@ int32 OS_CountSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 op tmp_sem_id = semCInitialize(OS_impl_count_sem_table[sem_id].cmem, SEM_Q_PRIORITY, sem_initial_value); /* check if semCInitialize failed */ - if(tmp_sem_id == (SEM_ID)0) + if (tmp_sem_id == (SEM_ID)0) { - OS_DEBUG("semCInitialize() - vxWorks errno %d\n",errno); + OS_DEBUG("semCInitialize() - vxWorks errno %d\n", errno); return OS_SEM_FAILURE; } @@ -94,7 +89,6 @@ int32 OS_CountSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 op } /* end OS_CountSemCreate_Impl */ - /*---------------------------------------------------------------- * * Function: OS_CountSemDelete_Impl @@ -103,7 +97,7 @@ int32 OS_CountSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 op * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemDelete_Impl (uint32 sem_id) +int32 OS_CountSemDelete_Impl(uint32 sem_id) { /* * As the memory for the sem is statically allocated, delete is a no-op. @@ -113,7 +107,6 @@ int32 OS_CountSemDelete_Impl (uint32 sem_id) } /* end OS_CountSemDelete_Impl */ - /*---------------------------------------------------------------- * * Function: OS_CountSemGive_Impl @@ -122,13 +115,12 @@ int32 OS_CountSemDelete_Impl (uint32 sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemGive_Impl (uint32 sem_id) +int32 OS_CountSemGive_Impl(uint32 sem_id) { /* Give VxWorks Semaphore */ return OS_VxWorks_GenericSemGive(OS_impl_count_sem_table[sem_id].vxid); } /* end OS_CountSemGive_Impl */ - /*---------------------------------------------------------------- * * Function: OS_CountSemTake_Impl @@ -137,13 +129,11 @@ int32 OS_CountSemGive_Impl (uint32 sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemTake_Impl (uint32 sem_id) +int32 OS_CountSemTake_Impl(uint32 sem_id) { return OS_VxWorks_GenericSemTake(OS_impl_count_sem_table[sem_id].vxid, WAIT_FOREVER); } /* end OS_CountSemTake_Impl */ - - /*---------------------------------------------------------------- * * Function: OS_CountSemTimedWait_Impl @@ -152,9 +142,9 @@ int32 OS_CountSemTake_Impl (uint32 sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemTimedWait_Impl (uint32 sem_id, uint32 msecs) +int32 OS_CountSemTimedWait_Impl(uint32 sem_id, uint32 msecs) { - int ticks; + int ticks; int32 status; status = OS_Milli2Ticks(msecs, &ticks); @@ -167,7 +157,6 @@ int32 OS_CountSemTimedWait_Impl (uint32 sem_id, uint32 msecs) return status; } /* end OS_CountSemTimedWait_Impl */ - /*---------------------------------------------------------------- * * Function: OS_CountSemGetInfo_Impl @@ -176,10 +165,9 @@ int32 OS_CountSemTimedWait_Impl (uint32 sem_id, uint32 msecs) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemGetInfo_Impl (uint32 sem_id, OS_count_sem_prop_t *count_prop) +int32 OS_CountSemGetInfo_Impl(uint32 sem_id, OS_count_sem_prop_t *count_prop) { /* VxWorks does not provide an API to get the value */ return OS_SUCCESS; } /* end OS_CountSemGetInfo_Impl */ - diff --git a/src/os/vxworks/src/os-impl-dirs.c b/src/os/vxworks/src/os-impl-dirs.c index 81978e194..9e6cff52f 100644 --- a/src/os/vxworks/src/os-impl-dirs.c +++ b/src/os/vxworks/src/os-impl-dirs.c @@ -33,13 +33,11 @@ #include "os-impl-dirs.h" #include "os-shared-dir.h" - /* * The directory handle table. */ OS_impl_dir_internal_record_t OS_impl_dir_table[OS_MAX_NUM_OPEN_DIRS]; - /*---------------------------------------------------------------- * * Function: OS_VxWorks_DirAPI_Impl_Init @@ -49,12 +47,10 @@ OS_impl_dir_internal_record_t OS_impl_dir_table[OS_MAX_NUM_OPEN_DIRS]; *-----------------------------------------------------------------*/ int32 OS_VxWorks_DirAPI_Impl_Init(void) { - memset(OS_impl_dir_table, 0, sizeof(OS_impl_dir_table)); - return OS_SUCCESS; + memset(OS_impl_dir_table, 0, sizeof(OS_impl_dir_table)); + return OS_SUCCESS; } /* end OS_VxWorks_DirAPI_Impl_Init */ - - /*---------------------------------------------------------------- * * Function: OS_DirCreate_Impl @@ -65,18 +61,18 @@ int32 OS_VxWorks_DirAPI_Impl_Init(void) *-----------------------------------------------------------------*/ int32 OS_DirCreate_Impl(const char *local_path, uint32 access) { - int32 return_code; - - if ( mkdir(local_path) != OK ) - { - return_code = OS_ERROR; - } - else - { - return_code = OS_SUCCESS; - } - - return return_code; + int32 return_code; + + if (mkdir(local_path) != OK) + { + return_code = OS_ERROR; + } + else + { + return_code = OS_SUCCESS; + } + + return return_code; } /* end OS_DirCreate_Impl */ /*---------------------------------------------------------------- @@ -89,12 +85,12 @@ int32 OS_DirCreate_Impl(const char *local_path, uint32 access) *-----------------------------------------------------------------*/ int32 OS_DirOpen_Impl(uint32 local_id, const char *local_path) { - OS_impl_dir_table[local_id].dp = opendir(local_path); - if (OS_impl_dir_table[local_id].dp == NULL) - { - return OS_ERROR; - } - return OS_SUCCESS; + OS_impl_dir_table[local_id].dp = opendir(local_path); + if (OS_impl_dir_table[local_id].dp == NULL) + { + return OS_ERROR; + } + return OS_SUCCESS; } /* end OS_DirOpen_Impl */ /*---------------------------------------------------------------- @@ -107,9 +103,9 @@ int32 OS_DirOpen_Impl(uint32 local_id, const char *local_path) *-----------------------------------------------------------------*/ int32 OS_DirClose_Impl(uint32 local_id) { - closedir(OS_impl_dir_table[local_id].dp); - OS_impl_dir_table[local_id].dp = NULL; - return OS_SUCCESS; + closedir(OS_impl_dir_table[local_id].dp); + OS_impl_dir_table[local_id].dp = NULL; + return OS_SUCCESS; } /* end OS_DirClose_Impl */ /*---------------------------------------------------------------- @@ -122,27 +118,27 @@ int32 OS_DirClose_Impl(uint32 local_id) *-----------------------------------------------------------------*/ int32 OS_DirRead_Impl(uint32 local_id, os_dirent_t *dirent) { - struct dirent *de; - - /* NOTE - the readdir() call is non-reentrant .... - * However, this is performed while the global dir table lock is taken. - * Therefore this ensures that only one such call can occur at any given time. - * - * Static analysis tools may warn about this because they do not know - * this function is externally serialized via the global lock. - */ - /* cppcheck-suppress readdirCalled */ - /* cppcheck-suppress nonreentrantFunctionsreaddir */ - de = readdir(OS_impl_dir_table[local_id].dp); - if (de == NULL) - { - return OS_ERROR; - } - - strncpy(dirent->FileName, de->d_name, sizeof(dirent->FileName)-1); - dirent->FileName[sizeof(dirent->FileName)-1] = 0; - - return OS_SUCCESS; + struct dirent *de; + + /* NOTE - the readdir() call is non-reentrant .... + * However, this is performed while the global dir table lock is taken. + * Therefore this ensures that only one such call can occur at any given time. + * + * Static analysis tools may warn about this because they do not know + * this function is externally serialized via the global lock. + */ + /* cppcheck-suppress readdirCalled */ + /* cppcheck-suppress nonreentrantFunctionsreaddir */ + de = readdir(OS_impl_dir_table[local_id].dp); + if (de == NULL) + { + return OS_ERROR; + } + + strncpy(dirent->FileName, de->d_name, sizeof(dirent->FileName) - 1); + dirent->FileName[sizeof(dirent->FileName) - 1] = 0; + + return OS_SUCCESS; } /* end OS_DirRead_Impl */ /*---------------------------------------------------------------- @@ -155,8 +151,8 @@ int32 OS_DirRead_Impl(uint32 local_id, os_dirent_t *dirent) *-----------------------------------------------------------------*/ int32 OS_DirRewind_Impl(uint32 local_id) { - rewinddir(OS_impl_dir_table[local_id].dp); - return OS_SUCCESS; + rewinddir(OS_impl_dir_table[local_id].dp); + return OS_SUCCESS; } /* end OS_DirRewind_Impl */ /*---------------------------------------------------------------- @@ -169,11 +165,10 @@ int32 OS_DirRewind_Impl(uint32 local_id) *-----------------------------------------------------------------*/ int32 OS_DirRemove_Impl(const char *local_path) { - if ( rmdir(local_path) < 0 ) - { - return OS_ERROR; - } + if (rmdir(local_path) < 0) + { + return OS_ERROR; + } - return OS_SUCCESS; + return OS_SUCCESS; } /* end OS_DirRemove_Impl */ - diff --git a/src/os/vxworks/src/os-impl-errors.c b/src/os/vxworks/src/os-impl-errors.c index 88393c9bf..e98cf9bf6 100644 --- a/src/os/vxworks/src/os-impl-errors.c +++ b/src/os/vxworks/src/os-impl-errors.c @@ -39,5 +39,4 @@ GLOBAL DATA ****************************************************************************************/ -const OS_ErrorTable_Entry_t OS_IMPL_ERROR_NAME_TABLE[] = { { 0, NULL } }; - +const OS_ErrorTable_Entry_t OS_IMPL_ERROR_NAME_TABLE[] = {{0, NULL}}; diff --git a/src/os/vxworks/src/os-impl-files.c b/src/os/vxworks/src/os-impl-files.c index 1d2183a59..cb024ebd1 100644 --- a/src/os/vxworks/src/os-impl-files.c +++ b/src/os/vxworks/src/os-impl-files.c @@ -40,7 +40,6 @@ */ OS_VxWorks_filehandle_entry_t OS_impl_filehandle_table[OS_MAX_NUM_OPEN_FILES]; - /*---------------------------------------------------------------- * * Function: OS_VxWorks_StreamAPI_Impl_Init @@ -56,13 +55,11 @@ int32 OS_VxWorks_StreamAPI_Impl_Init(void) * init all filehandles to -1, which is always invalid. * this isn't strictly necessary but helps when debugging. */ - for (local_id = 0; local_id < OS_MAX_NUM_OPEN_FILES; ++local_id) + for (local_id = 0; local_id < OS_MAX_NUM_OPEN_FILES; ++local_id) { - OS_impl_filehandle_table[local_id].fd = -1; + OS_impl_filehandle_table[local_id].fd = -1; OS_impl_filehandle_table[local_id].selectable = false; } return OS_SUCCESS; } /* end OS_VxWorks_StreamAPI_Impl_Init */ - - diff --git a/src/os/vxworks/src/os-impl-filesys.c b/src/os/vxworks/src/os-impl-filesys.c index b2d14efb1..1a3a3ff32 100644 --- a/src/os/vxworks/src/os-impl-filesys.c +++ b/src/os/vxworks/src/os-impl-filesys.c @@ -35,7 +35,6 @@ #include "os-shared-filesys.h" #include "os-shared-idmap.h" - #include #include #include @@ -69,7 +68,6 @@ OS_impl_filesys_internal_record_t OS_impl_filesys_table[OS_MAX_FILE_SYSTEMS]; Filesys API ****************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_FileSysStartVolume_Impl @@ -78,55 +76,55 @@ OS_impl_filesys_internal_record_t OS_impl_filesys_table[OS_MAX_FILE_SYSTEMS]; * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysStartVolume_Impl (uint32 filesys_id) +int32 OS_FileSysStartVolume_Impl(uint32 filesys_id) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; - OS_impl_filesys_internal_record_t *impl = &OS_impl_filesys_table[filesys_id]; - int32 return_code; + OS_filesys_internal_record_t * local = &OS_filesys_table[filesys_id]; + OS_impl_filesys_internal_record_t *impl = &OS_impl_filesys_table[filesys_id]; + int32 return_code; - memset(impl, 0, sizeof (*impl)); + memset(impl, 0, sizeof(*impl)); return_code = OS_ERR_NOT_IMPLEMENTED; - switch(local->fstype) - { - case OS_FILESYS_TYPE_FS_BASED: + switch (local->fstype) { - /* pass through for FS_BASED volumes, assume already mounted */ - OS_DEBUG("OSAL: Mapping an FS_BASED disk at: %s\n",(unsigned long)local->system_mountpt ); - return_code = OS_SUCCESS; - break; - } + case OS_FILESYS_TYPE_FS_BASED: + { + /* pass through for FS_BASED volumes, assume already mounted */ + OS_DEBUG("OSAL: Mapping an FS_BASED disk at: %s\n", (unsigned long)local->system_mountpt); + return_code = OS_SUCCESS; + break; + } - case OS_FILESYS_TYPE_VOLATILE_DISK: - { - OS_DEBUG("OSAL: Starting a RAM disk at: 0x%08lX\n",(unsigned long)local->address ); + case OS_FILESYS_TYPE_VOLATILE_DISK: + { + OS_DEBUG("OSAL: Starting a RAM disk at: 0x%08lX\n", (unsigned long)local->address); - /* - ** Create the ram disk device - ** The 32 is the number of blocks per track. - ** Other values dont seem to work here - */ - impl->blkDev = ramDevCreate (local->address, local->blocksize , 32 , local->numblocks, 0); - impl->xbdMaxPartitions = 1; - break; - } + /* + ** Create the ram disk device + ** The 32 is the number of blocks per track. + ** Other values dont seem to work here + */ + impl->blkDev = ramDevCreate(local->address, local->blocksize, 32, local->numblocks, 0); + impl->xbdMaxPartitions = 1; + break; + } #ifdef USE_VXWORKS_ATA_DRIVER - case OS_FILESYS_TYPE_NORMAL_DISK: - { - /* - ** Create the Flash disk device - ** This code requires an ATA driver in the BSP, so it must be - ** left out of the compilation BSPs without. - */ - OS_DEBUG("OSAL: Starting an ATA DISK: %s\n", local->volume_name); - impl->xbdMaxPartitions = 4; - impl->blkDev = ataDevCreate(0, 0, 0, 0); - break; - } + case OS_FILESYS_TYPE_NORMAL_DISK: + { + /* + ** Create the Flash disk device + ** This code requires an ATA driver in the BSP, so it must be + ** left out of the compilation BSPs without. + */ + OS_DEBUG("OSAL: Starting an ATA DISK: %s\n", local->volume_name); + impl->xbdMaxPartitions = 4; + impl->blkDev = ataDevCreate(0, 0, 0, 0); + break; + } #endif - default: - break; + default: + break; } if (impl->xbdMaxPartitions > 0) @@ -175,8 +173,7 @@ int32 OS_FileSysStartVolume_Impl (uint32 filesys_id) * (i.e. if a partition was formatted manually and then the software * restarted, a different block device might get mounted the second time) */ - snprintf(local->system_mountpt, sizeof(local->system_mountpt), - "%s:0", local->volume_name); + snprintf(local->system_mountpt, sizeof(local->system_mountpt), "%s:0", local->volume_name); return_code = OS_SUCCESS; } @@ -187,8 +184,6 @@ int32 OS_FileSysStartVolume_Impl (uint32 filesys_id) } /* end OS_FileSysStartVolume_Impl */ - - /*---------------------------------------------------------------- * * Function: OS_FileSysStopVolume_Impl @@ -197,26 +192,26 @@ int32 OS_FileSysStartVolume_Impl (uint32 filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysStopVolume_Impl (uint32 filesys_id) +int32 OS_FileSysStopVolume_Impl(uint32 filesys_id) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; - OS_impl_filesys_internal_record_t *impl = &OS_impl_filesys_table[filesys_id]; + OS_filesys_internal_record_t * local = &OS_filesys_table[filesys_id]; + OS_impl_filesys_internal_record_t *impl = &OS_impl_filesys_table[filesys_id]; - switch(local->fstype) + switch (local->fstype) { - case OS_FILESYS_TYPE_VOLATILE_DISK: - case OS_FILESYS_TYPE_NORMAL_DISK: - { - if (impl->xbdMaxPartitions > 0 && impl->xbd != NULLDEV) + case OS_FILESYS_TYPE_VOLATILE_DISK: + case OS_FILESYS_TYPE_NORMAL_DISK: { - xbdBlkDevDelete(impl->xbd, NULL); - impl->xbd = NULLDEV; - impl->xbdMaxPartitions = 0; + if (impl->xbdMaxPartitions > 0 && impl->xbd != NULLDEV) + { + xbdBlkDevDelete(impl->xbd, NULL); + impl->xbd = NULLDEV; + impl->xbdMaxPartitions = 0; + } + break; } - break; - } - default: - break; + default: + break; } /* @@ -228,7 +223,6 @@ int32 OS_FileSysStopVolume_Impl (uint32 filesys_id) } /* end OS_FileSysStopVolume_Impl */ - /*---------------------------------------------------------------- * * Function: OS_FileSysFormatVolume_Impl @@ -237,51 +231,49 @@ int32 OS_FileSysStopVolume_Impl (uint32 filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysFormatVolume_Impl (uint32 filesys_id) +int32 OS_FileSysFormatVolume_Impl(uint32 filesys_id) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; - int32 return_code = OS_ERR_NOT_IMPLEMENTED; - int status; + OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; + int32 return_code = OS_ERR_NOT_IMPLEMENTED; + int status; - switch(local->fstype) - { - case OS_FILESYS_TYPE_FS_BASED: - { - /* - * The "format" operation is a no-op on FS_BASED types. - * Return success to allow the operation to continue. - */ - return_code = OS_SUCCESS; - break; - } - case OS_FILESYS_TYPE_VOLATILE_DISK: - case OS_FILESYS_TYPE_NORMAL_DISK: + switch (local->fstype) { - /* - ** Call the dos format routine - */ - status = dosFsVolFormat(local->system_mountpt, DOS_OPT_BLANK, NULL); - if ( status == -1 ) + case OS_FILESYS_TYPE_FS_BASED: { - OS_DEBUG("OSAL: dosFsVolFormat failed. Errno = %d\n",errnoGet()); - return_code = OS_FS_ERR_DRIVE_NOT_CREATED; + /* + * The "format" operation is a no-op on FS_BASED types. + * Return success to allow the operation to continue. + */ + return_code = OS_SUCCESS; + break; } - else + case OS_FILESYS_TYPE_VOLATILE_DISK: + case OS_FILESYS_TYPE_NORMAL_DISK: { - return_code = OS_SUCCESS; + /* + ** Call the dos format routine + */ + status = dosFsVolFormat(local->system_mountpt, DOS_OPT_BLANK, NULL); + if (status == -1) + { + OS_DEBUG("OSAL: dosFsVolFormat failed. Errno = %d\n", errnoGet()); + return_code = OS_FS_ERR_DRIVE_NOT_CREATED; + } + else + { + return_code = OS_SUCCESS; + } + break; } - break; - } - default: - break; + default: + break; } return return_code; } /* end OS_FileSysFormatVolume_Impl */ - - /*---------------------------------------------------------------- * * Function: OS_FileSysMountVolume_Impl @@ -290,18 +282,18 @@ int32 OS_FileSysFormatVolume_Impl (uint32 filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysMountVolume_Impl (uint32 filesys_id) +int32 OS_FileSysMountVolume_Impl(uint32 filesys_id) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; - int32 status; - int fd; + OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; + int32 status; + int fd; /* * Calling open() on the physical device path * mounts the device. */ - fd = open ( local->system_mountpt, O_RDONLY, 0644 ); - if ( fd < 0 ) + fd = open(local->system_mountpt, O_RDONLY, 0644); + if (fd < 0) { status = OS_ERROR; } @@ -315,7 +307,6 @@ int32 OS_FileSysMountVolume_Impl (uint32 filesys_id) } /* end OS_FileSysMountVolume_Impl */ - /*---------------------------------------------------------------- * * Function: OS_FileSysUnmountVolume_Impl @@ -324,23 +315,23 @@ int32 OS_FileSysMountVolume_Impl (uint32 filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysUnmountVolume_Impl (uint32 filesys_id) +int32 OS_FileSysUnmountVolume_Impl(uint32 filesys_id) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; - int32 status; - int fd; + OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; + int32 status; + int fd; /* ** vxWorks uses an ioctl to unmount */ - fd = open ( local->system_mountpt, O_RDONLY, 0644 ); - if ( fd < 0 ) + fd = open(local->system_mountpt, O_RDONLY, 0644); + if (fd < 0) { status = OS_ERROR; } else { - if ( ioctl( fd, FIOUNMOUNT,0) < 0 ) + if (ioctl(fd, FIOUNMOUNT, 0) < 0) { status = OS_ERROR; } @@ -356,7 +347,6 @@ int32 OS_FileSysUnmountVolume_Impl (uint32 filesys_id) } /* end OS_FileSysUnmountVolume_Impl */ - /*---------------------------------------------------------------- * * Function: OS_FileSysStatVolume_Impl @@ -365,30 +355,28 @@ int32 OS_FileSysUnmountVolume_Impl (uint32 filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysStatVolume_Impl (uint32 filesys_id, OS_statvfs_t *result) +int32 OS_FileSysStatVolume_Impl(uint32 filesys_id, OS_statvfs_t *result) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; - struct statfs stat_buf; - int return_code; - - if (statfs(local->system_mountpt, &stat_buf) != 0) - { - return_code = OS_ERROR; - memset(result, 0, sizeof(*result)); - } - else - { - result->block_size = stat_buf.f_bsize; - result->blocks_free = stat_buf.f_bfree; - result->total_blocks = stat_buf.f_blocks; - return_code = OS_SUCCESS; - } - - return return_code; + OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; + struct statfs stat_buf; + int return_code; -} /* end OS_FileSysStatVolume_Impl */ + if (statfs(local->system_mountpt, &stat_buf) != 0) + { + return_code = OS_ERROR; + memset(result, 0, sizeof(*result)); + } + else + { + result->block_size = stat_buf.f_bsize; + result->blocks_free = stat_buf.f_bfree; + result->total_blocks = stat_buf.f_blocks; + return_code = OS_SUCCESS; + } + return return_code; +} /* end OS_FileSysStatVolume_Impl */ /*---------------------------------------------------------------- * @@ -398,14 +386,14 @@ int32 OS_FileSysStatVolume_Impl (uint32 filesys_id, OS_statvfs_t *result) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysCheckVolume_Impl (uint32 filesys_id, bool repair) +int32 OS_FileSysCheckVolume_Impl(uint32 filesys_id, bool repair) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; - STATUS chk_status; - int flags; - int fd; + OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; + STATUS chk_status; + int flags; + int fd; - fd = open (local->system_mountpt, O_RDONLY, 0); + fd = open(local->system_mountpt, O_RDONLY, 0); if (fd < 0) { return OS_ERROR; @@ -435,7 +423,3 @@ int32 OS_FileSysCheckVolume_Impl (uint32 filesys_id, bool repair) return OS_SUCCESS; } /* end OS_FileSysCheckVolume_Impl */ - - - - diff --git a/src/os/vxworks/src/os-impl-heap.c b/src/os/vxworks/src/os-impl-heap.c index 4ded24abe..fb46f0780 100644 --- a/src/os/vxworks/src/os-impl-heap.c +++ b/src/os/vxworks/src/os-impl-heap.c @@ -45,10 +45,10 @@ * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_HeapGetInfo_Impl (OS_heap_prop_t *heap_prop) +int32 OS_HeapGetInfo_Impl(OS_heap_prop_t *heap_prop) { MEM_PART_STATS stats; - STATUS status; + STATUS status; status = memPartInfoGet(memSysPartId, &stats); @@ -63,4 +63,3 @@ int32 OS_HeapGetInfo_Impl (OS_heap_prop_t *heap_prop) return (OS_SUCCESS); } /* end OS_HeapGetInfo_Impl */ - diff --git a/src/os/vxworks/src/os-impl-idmap.c b/src/os/vxworks/src/os-impl-idmap.c index 234ab3d05..41752a387 100644 --- a/src/os/vxworks/src/os-impl-idmap.c +++ b/src/os/vxworks/src/os-impl-idmap.c @@ -57,21 +57,20 @@ VX_MUTEX_SEMAPHORE(OS_module_table_mut_mem); VX_MUTEX_SEMAPHORE(OS_filesys_table_mut_mem); VX_MUTEX_SEMAPHORE(OS_console_mut_mem); -VxWorks_GlobalMutex_t VX_MUTEX_TABLE[] = -{ - [OS_OBJECT_TYPE_UNDEFINED] = { NULL }, - [OS_OBJECT_TYPE_OS_TASK] = { .mem = OS_task_table_mut_mem }, - [OS_OBJECT_TYPE_OS_QUEUE] = { .mem = OS_queue_table_mut_mem }, - [OS_OBJECT_TYPE_OS_COUNTSEM] = { .mem = OS_count_sem_table_mut_mem }, - [OS_OBJECT_TYPE_OS_BINSEM] = { .mem = OS_bin_sem_table_mut_mem }, - [OS_OBJECT_TYPE_OS_MUTEX] = { .mem = OS_mutex_table_mut_mem }, - [OS_OBJECT_TYPE_OS_STREAM] = { .mem = OS_stream_table_mut_mem }, - [OS_OBJECT_TYPE_OS_DIR] = { .mem = OS_dir_table_mut_mem }, - [OS_OBJECT_TYPE_OS_TIMEBASE] = { .mem = OS_timebase_table_mut_mem }, - [OS_OBJECT_TYPE_OS_TIMECB] = { .mem = OS_timecb_table_mut_mem }, - [OS_OBJECT_TYPE_OS_MODULE] = { .mem = OS_module_table_mut_mem }, - [OS_OBJECT_TYPE_OS_FILESYS] = { .mem = OS_filesys_table_mut_mem }, - [OS_OBJECT_TYPE_OS_CONSOLE] = { .mem = OS_console_mut_mem }, +VxWorks_GlobalMutex_t VX_MUTEX_TABLE[] = { + [OS_OBJECT_TYPE_UNDEFINED] = {NULL}, + [OS_OBJECT_TYPE_OS_TASK] = {.mem = OS_task_table_mut_mem}, + [OS_OBJECT_TYPE_OS_QUEUE] = {.mem = OS_queue_table_mut_mem}, + [OS_OBJECT_TYPE_OS_COUNTSEM] = {.mem = OS_count_sem_table_mut_mem}, + [OS_OBJECT_TYPE_OS_BINSEM] = {.mem = OS_bin_sem_table_mut_mem}, + [OS_OBJECT_TYPE_OS_MUTEX] = {.mem = OS_mutex_table_mut_mem}, + [OS_OBJECT_TYPE_OS_STREAM] = {.mem = OS_stream_table_mut_mem}, + [OS_OBJECT_TYPE_OS_DIR] = {.mem = OS_dir_table_mut_mem}, + [OS_OBJECT_TYPE_OS_TIMEBASE] = {.mem = OS_timebase_table_mut_mem}, + [OS_OBJECT_TYPE_OS_TIMECB] = {.mem = OS_timecb_table_mut_mem}, + [OS_OBJECT_TYPE_OS_MODULE] = {.mem = OS_module_table_mut_mem}, + [OS_OBJECT_TYPE_OS_FILESYS] = {.mem = OS_filesys_table_mut_mem}, + [OS_OBJECT_TYPE_OS_CONSOLE] = {.mem = OS_console_mut_mem}, }; enum @@ -104,7 +103,7 @@ int32 OS_Lock_Global_Impl(uint32 idtype) if (semTake(mut->vxid, WAIT_FOREVER) != OK) { - OS_DEBUG("semTake() - vxWorks errno %d\n",errno); + OS_DEBUG("semTake() - vxWorks errno %d\n", errno); return OS_ERROR; } @@ -136,15 +135,13 @@ int32 OS_Unlock_Global_Impl(uint32 idtype) if (semGive(mut->vxid) != OK) { - OS_DEBUG("semGive() - vxWorks errno %d\n",errno); + OS_DEBUG("semGive() - vxWorks errno %d\n", errno); return OS_ERROR; } return OS_SUCCESS; } /* end OS_Unlock_Global_Impl */ - - /**************************************************************************************** INITIALIZATION FUNCTION ****************************************************************************************/ @@ -159,17 +156,17 @@ int32 OS_Unlock_Global_Impl(uint32 idtype) *-----------------------------------------------------------------*/ int32 OS_VxWorks_TableMutex_Init(uint32 idtype) { - int32 return_code = OS_SUCCESS; - SEM_ID semid; + int32 return_code = OS_SUCCESS; + SEM_ID semid; /* Initialize the table mutex for the given idtype */ if (idtype < VX_MUTEX_TABLE_SIZE && VX_MUTEX_TABLE[idtype].mem != NULL) { - semid = semMInitialize (VX_MUTEX_TABLE[idtype].mem, SEM_Q_PRIORITY | SEM_INVERSION_SAFE); + semid = semMInitialize(VX_MUTEX_TABLE[idtype].mem, SEM_Q_PRIORITY | SEM_INVERSION_SAFE); - if ( semid == (SEM_ID)0 ) + if (semid == (SEM_ID)0) { - OS_DEBUG("Error: semMInitialize() failed - vxWorks errno %d\n",errno); + OS_DEBUG("Error: semMInitialize() failed - vxWorks errno %d\n", errno); return_code = OS_ERROR; } else @@ -178,6 +175,5 @@ int32 OS_VxWorks_TableMutex_Init(uint32 idtype) } } - return(return_code); + return (return_code); } /* end OS_VxWorks_TableMutex_Init */ - diff --git a/src/os/vxworks/src/os-impl-loader.c b/src/os/vxworks/src/os-impl-loader.c index 389f3073c..7ab65fae6 100644 --- a/src/os/vxworks/src/os-impl-loader.c +++ b/src/os/vxworks/src/os-impl-loader.c @@ -40,7 +40,6 @@ #include #include - OS_impl_module_internal_record_t OS_impl_module_table[OS_MAX_MODULES]; /**************************************************************************************** @@ -56,18 +55,14 @@ OS_impl_module_internal_record_t OS_impl_module_table[OS_MAX_MODULES]; *-----------------------------------------------------------------*/ int32 OS_VxWorks_ModuleAPI_Impl_Init(void) { - memset(&OS_impl_module_table, 0, sizeof(OS_impl_module_table)); - return(OS_SUCCESS); + memset(&OS_impl_module_table, 0, sizeof(OS_impl_module_table)); + return (OS_SUCCESS); } /* end OS_VxWorks_ModuleAPI_Impl_Init */ - - - /**************************************************************************************** Module Loader API ****************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_ModuleLoad_Impl @@ -76,54 +71,53 @@ int32 OS_VxWorks_ModuleAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleLoad_Impl ( uint32 local_id, const char *translated_path ) +int32 OS_ModuleLoad_Impl(uint32 local_id, const char *translated_path) { - int32 return_code; - int fd; - MODULE_ID vxModuleId; - - /* - ** File is ready to load - */ - - /* - ** Open the file - */ - fd = open (translated_path, O_RDONLY, 0); - if( fd < 0 ) - { - OS_DEBUG("OSAL: Error, cannot open application file: %s\n",translated_path); - return_code = OS_ERROR; - } - else - { - /* - ** Load the module - */ - vxModuleId = loadModule (fd, LOAD_ALL_SYMBOLS); - - if( vxModuleId == (MODULE_ID)0 ) - { - OS_DEBUG("OSAL: Error, cannot load module: %s\n",translated_path); - return_code = OS_ERROR; - } - else - { - OS_impl_module_table[local_id].moduleID = vxModuleId; - return_code = OS_SUCCESS; - } - - /* - ** Close the file - */ - close(fd); - } - - return(return_code); + int32 return_code; + int fd; + MODULE_ID vxModuleId; + + /* + ** File is ready to load + */ + + /* + ** Open the file + */ + fd = open(translated_path, O_RDONLY, 0); + if (fd < 0) + { + OS_DEBUG("OSAL: Error, cannot open application file: %s\n", translated_path); + return_code = OS_ERROR; + } + else + { + /* + ** Load the module + */ + vxModuleId = loadModule(fd, LOAD_ALL_SYMBOLS); + + if (vxModuleId == (MODULE_ID)0) + { + OS_DEBUG("OSAL: Error, cannot load module: %s\n", translated_path); + return_code = OS_ERROR; + } + else + { + OS_impl_module_table[local_id].moduleID = vxModuleId; + return_code = OS_SUCCESS; + } + + /* + ** Close the file + */ + close(fd); + } + + return (return_code); } /* end OS_ModuleLoad_Impl */ - /*---------------------------------------------------------------- * * Function: OS_ModuleUnload_Impl @@ -132,25 +126,24 @@ int32 OS_ModuleLoad_Impl ( uint32 local_id, const char *translated_path ) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleUnload_Impl ( uint32 local_id ) +int32 OS_ModuleUnload_Impl(uint32 local_id) { - STATUS vxStatus; + STATUS vxStatus; - /* - ** Attempt to close/unload the module - */ - vxStatus = unldByModuleId(OS_impl_module_table[local_id].moduleID, 0); - if ( vxStatus == ERROR ) - { - OS_DEBUG("OSAL: Error, Cannot Close/Unload application file: %d\n",vxStatus); - return(OS_ERROR); - } + /* + ** Attempt to close/unload the module + */ + vxStatus = unldByModuleId(OS_impl_module_table[local_id].moduleID, 0); + if (vxStatus == ERROR) + { + OS_DEBUG("OSAL: Error, Cannot Close/Unload application file: %d\n", vxStatus); + return (OS_ERROR); + } - return(OS_SUCCESS); + return (OS_SUCCESS); } /* end OS_ModuleUnload_Impl */ - /*---------------------------------------------------------------- * * Function: OS_ModuleGetInfo_Impl @@ -159,34 +152,32 @@ int32 OS_ModuleUnload_Impl ( uint32 local_id ) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleGetInfo_Impl ( uint32 local_id, OS_module_prop_t *module_prop ) +int32 OS_ModuleGetInfo_Impl(uint32 local_id, OS_module_prop_t *module_prop) { - MODULE_INFO vxModuleInfo; - STATUS vxStatus; - - - module_prop->host_module_id = (cpuaddr)OS_impl_module_table[local_id].moduleID; - - /* - ** Get the module info from vxWorks - */ - vxStatus = moduleInfoGet(OS_impl_module_table[local_id].moduleID, &vxModuleInfo); - if ( vxStatus == ERROR ) - { - OS_DEBUG("OSAL: OS_ModuleInfoGet Error from vxWorks: %d\n",vxStatus); - } - else - { - module_prop->addr.valid = true; - module_prop->addr.code_address = (cpuaddr)vxModuleInfo.segInfo.textAddr; - module_prop->addr.code_size = vxModuleInfo.segInfo.textSize; - module_prop->addr.data_address = (cpuaddr)vxModuleInfo.segInfo.dataAddr; - module_prop->addr.data_size = vxModuleInfo.segInfo.dataSize; - module_prop->addr.bss_address = (cpuaddr)vxModuleInfo.segInfo.bssAddr; - module_prop->addr.bss_size = vxModuleInfo.segInfo.bssSize; - } - - return(OS_SUCCESS); + MODULE_INFO vxModuleInfo; + STATUS vxStatus; + + module_prop->host_module_id = (cpuaddr)OS_impl_module_table[local_id].moduleID; + + /* + ** Get the module info from vxWorks + */ + vxStatus = moduleInfoGet(OS_impl_module_table[local_id].moduleID, &vxModuleInfo); + if (vxStatus == ERROR) + { + OS_DEBUG("OSAL: OS_ModuleInfoGet Error from vxWorks: %d\n", vxStatus); + } + else + { + module_prop->addr.valid = true; + module_prop->addr.code_address = (cpuaddr)vxModuleInfo.segInfo.textAddr; + module_prop->addr.code_size = vxModuleInfo.segInfo.textSize; + module_prop->addr.data_address = (cpuaddr)vxModuleInfo.segInfo.dataAddr; + module_prop->addr.data_size = vxModuleInfo.segInfo.dataSize; + module_prop->addr.bss_address = (cpuaddr)vxModuleInfo.segInfo.bssAddr; + module_prop->addr.bss_size = vxModuleInfo.segInfo.bssSize; + } + + return (OS_SUCCESS); } /* end OS_ModuleGetInfo_Impl */ - diff --git a/src/os/vxworks/src/os-impl-mutex.c b/src/os/vxworks/src/os-impl-mutex.c index da0cef750..54273f14e 100644 --- a/src/os/vxworks/src/os-impl-mutex.c +++ b/src/os/vxworks/src/os-impl-mutex.c @@ -40,14 +40,12 @@ ****************************************************************************************/ /* Console device */ -OS_impl_mutsem_internal_record_t OS_impl_mutex_table [OS_MAX_MUTEXES]; +OS_impl_mutsem_internal_record_t OS_impl_mutex_table[OS_MAX_MUTEXES]; /**************************************************************************************** MUTEX API ****************************************************************************************/ - - /*---------------------------------------------------------------- * * Function: OS_VxWorks_MutexAPI_Impl_Init @@ -61,7 +59,6 @@ int32 OS_VxWorks_MutexAPI_Impl_Init(void) return (OS_SUCCESS); } /* end OS_VxWorks_MutexAPI_Impl_Init */ - /*---------------------------------------------------------------- * * Function: OS_MutSemCreate_Impl @@ -70,7 +67,7 @@ int32 OS_VxWorks_MutexAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemCreate_Impl (uint32 sem_id, uint32 options) +int32 OS_MutSemCreate_Impl(uint32 sem_id, uint32 options) { SEM_ID tmp_sem_id; @@ -78,9 +75,9 @@ int32 OS_MutSemCreate_Impl (uint32 sem_id, uint32 options) * The memory for this sem is statically allocated. */ tmp_sem_id = semMInitialize(OS_impl_mutex_table[sem_id].mmem, SEM_Q_PRIORITY | SEM_INVERSION_SAFE); - if(tmp_sem_id == (SEM_ID)0) + if (tmp_sem_id == (SEM_ID)0) { - OS_DEBUG("semMInitalize() - vxWorks errno %d\n",errno); + OS_DEBUG("semMInitalize() - vxWorks errno %d\n", errno); return OS_SEM_FAILURE; } @@ -88,7 +85,6 @@ int32 OS_MutSemCreate_Impl (uint32 sem_id, uint32 options) return OS_SUCCESS; } /* end OS_MutSemCreate_Impl */ - /*---------------------------------------------------------------- * * Function: OS_MutSemDelete_Impl @@ -97,7 +93,7 @@ int32 OS_MutSemCreate_Impl (uint32 sem_id, uint32 options) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemDelete_Impl (uint32 sem_id) +int32 OS_MutSemDelete_Impl(uint32 sem_id) { /* * As the memory for the sem is statically allocated, delete is a no-op. @@ -107,8 +103,6 @@ int32 OS_MutSemDelete_Impl (uint32 sem_id) } /* end OS_MutSemDelete_Impl */ - - /*---------------------------------------------------------------- * * Function: OS_MutSemGive_Impl @@ -117,13 +111,12 @@ int32 OS_MutSemDelete_Impl (uint32 sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemGive_Impl (uint32 sem_id) +int32 OS_MutSemGive_Impl(uint32 sem_id) { /* Give VxWorks Semaphore */ return OS_VxWorks_GenericSemGive(OS_impl_mutex_table[sem_id].vxid); } /* end OS_MutSemGive_Impl */ - /*---------------------------------------------------------------- * * Function: OS_MutSemTake_Impl @@ -132,13 +125,12 @@ int32 OS_MutSemGive_Impl (uint32 sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemTake_Impl (uint32 sem_id) +int32 OS_MutSemTake_Impl(uint32 sem_id) { /* Take VxWorks Semaphore */ return OS_VxWorks_GenericSemTake(OS_impl_mutex_table[sem_id].vxid, WAIT_FOREVER); } /* end OS_MutSemTake_Impl */ - /*---------------------------------------------------------------- * * Function: OS_MutSemGetInfo_Impl @@ -147,10 +139,9 @@ int32 OS_MutSemTake_Impl (uint32 sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemGetInfo_Impl (uint32 sem_id, OS_mut_sem_prop_t *mut_prop) +int32 OS_MutSemGetInfo_Impl(uint32 sem_id, OS_mut_sem_prop_t *mut_prop) { /* VxWorks provides no additional info */ return OS_SUCCESS; } /* end OS_MutSemGetInfo_Impl */ - diff --git a/src/os/vxworks/src/os-impl-network.c b/src/os/vxworks/src/os-impl-network.c index eac4d1871..63c526be6 100644 --- a/src/os/vxworks/src/os-impl-network.c +++ b/src/os/vxworks/src/os-impl-network.c @@ -33,7 +33,7 @@ #include "os-impl-network.h" #include "os-shared-network.h" -#define OS_HOST_NAME_LEN 48 +#define OS_HOST_NAME_LEN 48 /*---------------------------------------------------------------- * @@ -43,26 +43,23 @@ * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_NetworkGetHostName_Impl (char *host_name, uint32 name_len) +int32 OS_NetworkGetHostName_Impl(char *host_name, uint32 name_len) { int32 return_code; - if ( gethostname(host_name, name_len) < 0 ) + if (gethostname(host_name, name_len) < 0) { return_code = OS_ERROR; } else { host_name[name_len - 1] = 0; - return_code = OS_SUCCESS; + return_code = OS_SUCCESS; } - return(return_code); + return (return_code); } /* end OS_NetworkGetHostName_Impl */ - - - /*---------------------------------------------------------------- * * Function: OS_NetworkGetID_Impl @@ -71,11 +68,11 @@ int32 OS_NetworkGetHostName_Impl (char *host_name, uint32 name_len) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_NetworkGetID_Impl (int32 *IdBuf) +int32 OS_NetworkGetID_Impl(int32 *IdBuf) { - int host_id; - int32 status; - char host_name [OS_HOST_NAME_LEN]; + int host_id; + int32 status; + char host_name[OS_HOST_NAME_LEN]; status = OS_NetworkGetHostName_Impl(host_name, sizeof(host_name)); if (status == OS_SUCCESS) @@ -95,4 +92,3 @@ int32 OS_NetworkGetID_Impl (int32 *IdBuf) return status; } /* end OS_NetworkGetID_Impl */ - diff --git a/src/os/vxworks/src/os-impl-no-module.c b/src/os/vxworks/src/os-impl-no-module.c index 6cc2eb4f5..bc20f3ccd 100644 --- a/src/os/vxworks/src/os-impl-no-module.c +++ b/src/os/vxworks/src/os-impl-no-module.c @@ -31,7 +31,6 @@ #include "os-vxworks.h" - /**************************************************************************************** INITIALIZATION FUNCTION ***************************************************************************************/ @@ -46,7 +45,5 @@ int32 OS_VxWorks_ModuleAPI_Impl_Init(void) { /* nothing to init, but needs to return SUCCESS to allow the rest of OSAL to work */ - return(OS_SUCCESS); + return (OS_SUCCESS); } /* end OS_VxWorks_ModuleAPI_Impl_Init */ - - diff --git a/src/os/vxworks/src/os-impl-queues.c b/src/os/vxworks/src/os-impl-queues.c index 41a1a5889..319d5e1dd 100644 --- a/src/os/vxworks/src/os-impl-queues.c +++ b/src/os/vxworks/src/os-impl-queues.c @@ -33,17 +33,15 @@ #include "os-shared-queue.h" #include "os-shared-timebase.h" - /**************************************************************************************** GLOBAL DATA ****************************************************************************************/ -OS_impl_queue_internal_record_t OS_impl_queue_table [OS_MAX_QUEUES]; +OS_impl_queue_internal_record_t OS_impl_queue_table[OS_MAX_QUEUES]; /**************************************************************************************** MESSAGE QUEUE API ****************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_VxWorks_QueueAPI_Impl_Init @@ -57,7 +55,6 @@ int32 OS_VxWorks_QueueAPI_Impl_Init(void) return (OS_SUCCESS); } /* end OS_VxWorks_QueueAPI_Impl_Init */ - /*---------------------------------------------------------------- * * Function: OS_QueueCreate_Impl @@ -66,19 +63,19 @@ int32 OS_VxWorks_QueueAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueueCreate_Impl (uint32 queue_id, uint32 flags) +int32 OS_QueueCreate_Impl(uint32 queue_id, uint32 flags) { MSG_Q_ID tmp_msgq_id; - int queue_depth = OS_queue_table[queue_id].max_depth; /* maximum number of messages in queue (queue depth) */ - int data_size = OS_queue_table[queue_id].max_size; /* maximum size in bytes of a message */ + int queue_depth = OS_queue_table[queue_id].max_depth; /* maximum number of messages in queue (queue depth) */ + int data_size = OS_queue_table[queue_id].max_size; /* maximum size in bytes of a message */ /* Create VxWorks Message Queue */ tmp_msgq_id = msgQCreate(queue_depth, data_size, MSG_Q_FIFO); /* check if message Q create failed */ - if(tmp_msgq_id == 0) + if (tmp_msgq_id == 0) { - OS_DEBUG("msgQCreate() - vxWorks errno %d\n",errno); + OS_DEBUG("msgQCreate() - vxWorks errno %d\n", errno); return OS_ERROR; } @@ -87,7 +84,6 @@ int32 OS_QueueCreate_Impl (uint32 queue_id, uint32 flags) } /* end OS_QueueCreate_Impl */ - /*---------------------------------------------------------------- * * Function: OS_QueueDelete_Impl @@ -96,12 +92,12 @@ int32 OS_QueueCreate_Impl (uint32 queue_id, uint32 flags) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueueDelete_Impl (uint32 queue_id) +int32 OS_QueueDelete_Impl(uint32 queue_id) { /* Try to delete the queue */ if (msgQDelete(OS_impl_queue_table[queue_id].vxid) != OK) { - OS_DEBUG("msgQDelete() - vxWorks errno %d\n",errno); + OS_DEBUG("msgQDelete() - vxWorks errno %d\n", errno); return OS_ERROR; } @@ -110,8 +106,6 @@ int32 OS_QueueDelete_Impl (uint32 queue_id) } /* end OS_QueueDelete_Impl */ - - /*---------------------------------------------------------------- * * Function: OS_QueueGet_Impl @@ -120,12 +114,11 @@ int32 OS_QueueDelete_Impl (uint32 queue_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueueGet_Impl (uint32 queue_id, void *data, uint32 size, uint32 *size_copied, - int32 timeout) +int32 OS_QueueGet_Impl(uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout) { - int32 return_code; - STATUS status; - int ticks; + int32 return_code; + STATUS status; + int ticks; /* Get Message From Message Queue */ if (timeout == OS_PEND) @@ -147,7 +140,7 @@ int32 OS_QueueGet_Impl (uint32 queue_id, void *data, uint32 size, uint32 *size_c status = msgQReceive(OS_impl_queue_table[queue_id].vxid, data, size, ticks); - if(status == ERROR) + if (status == ERROR) { *size_copied = 0; if (errno == S_objLib_OBJ_TIMEOUT) @@ -160,20 +153,19 @@ int32 OS_QueueGet_Impl (uint32 queue_id, void *data, uint32 size, uint32 *size_c } else { - OS_DEBUG("msgQReceive() - vxWorks errno %d\n",errno); + OS_DEBUG("msgQReceive() - vxWorks errno %d\n", errno); return_code = OS_ERROR; } } else { *size_copied = status; - return_code = OS_SUCCESS; + return_code = OS_SUCCESS; } return return_code; } /* end OS_QueueGet_Impl */ - /*---------------------------------------------------------------- * * Function: OS_QueuePut_Impl @@ -182,21 +174,21 @@ int32 OS_QueueGet_Impl (uint32 queue_id, void *data, uint32 size, uint32 *size_c * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueuePut_Impl (uint32 queue_id, const void *data, uint32 size, uint32 flags) +int32 OS_QueuePut_Impl(uint32 queue_id, const void *data, uint32 size, uint32 flags) { - int32 return_code; + int32 return_code; - if(msgQSend(OS_impl_queue_table[queue_id].vxid, (void*)data, size, NO_WAIT, MSG_PRI_NORMAL) == OK) + if (msgQSend(OS_impl_queue_table[queue_id].vxid, (void *)data, size, NO_WAIT, MSG_PRI_NORMAL) == OK) { return_code = OS_SUCCESS; } - else if(errno == S_objLib_OBJ_UNAVAILABLE) + else if (errno == S_objLib_OBJ_UNAVAILABLE) { return_code = OS_QUEUE_FULL; } else { - OS_DEBUG("msgQSend() - vxWorks errno %d\n",errno); + OS_DEBUG("msgQSend() - vxWorks errno %d\n", errno); return_code = OS_ERROR; } @@ -204,7 +196,6 @@ int32 OS_QueuePut_Impl (uint32 queue_id, const void *data, uint32 size, uint32 f } /* end OS_QueuePut_Impl */ - /*---------------------------------------------------------------- * * Function: OS_QueueGetInfo_Impl @@ -213,10 +204,9 @@ int32 OS_QueuePut_Impl (uint32 queue_id, const void *data, uint32 size, uint32 f * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueueGetInfo_Impl (uint32 queue_id, OS_queue_prop_t *queue_prop) +int32 OS_QueueGetInfo_Impl(uint32 queue_id, OS_queue_prop_t *queue_prop) { /* No extra info for queues in the OS implementation */ return OS_SUCCESS; } /* end OS_QueueGetInfo_Impl */ - diff --git a/src/os/vxworks/src/os-impl-shell.c b/src/os/vxworks/src/os-impl-shell.c index 88b24851f..a43fce496 100644 --- a/src/os/vxworks/src/os-impl-shell.c +++ b/src/os/vxworks/src/os-impl-shell.c @@ -44,8 +44,6 @@ #define OS_SHELL_CMD_TASK_STACK_SIZE 16384 #define OS_SHELL_CMD_TASK_PRIORITY 250 - - /*---------------------------------------------------------------- * * Function: OS_ShellOutputToFile_Impl @@ -56,14 +54,15 @@ *-----------------------------------------------------------------*/ int32 OS_ShellOutputToFile_Impl(uint32 file_id, const char *Cmd) { - int32 ReturnCode = OS_ERROR; - int32 Result; + int32 ReturnCode = OS_ERROR; + int32 Result; osal_id_t fdCmd; - uint32 cmdidx; - char * shellName; + uint32 cmdidx; + char * shellName; /* Create a file to write the command to (or write over the old one) */ - Result = OS_OpenCreate(&fdCmd, OS_SHELL_CMD_INPUT_FILE_NAME, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + Result = + OS_OpenCreate(&fdCmd, OS_SHELL_CMD_INPUT_FILE_NAME, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); if (Result < OS_SUCCESS) { @@ -74,13 +73,12 @@ int32 OS_ShellOutputToFile_Impl(uint32 file_id, const char *Cmd) { /* copy the command to the file, and then seek back to the beginning of the file */ OS_write(fdCmd, Cmd, strlen(Cmd)); - OS_lseek(fdCmd,0,OS_SEEK_SET); + OS_lseek(fdCmd, 0, OS_SEEK_SET); /* Create a shell task the will run the command in the file, push output to OS_fd */ - Result = shellGenericInit("INTERPRETER=Cmd", 0, NULL, &shellName, false, false, - OS_impl_filehandle_table[cmdidx].fd, - OS_impl_filehandle_table[file_id].fd, - OS_impl_filehandle_table[file_id].fd); + Result = + shellGenericInit("INTERPRETER=Cmd", 0, NULL, &shellName, false, false, OS_impl_filehandle_table[cmdidx].fd, + OS_impl_filehandle_table[file_id].fd, OS_impl_filehandle_table[file_id].fd); } if (Result == OK) @@ -89,10 +87,9 @@ int32 OS_ShellOutputToFile_Impl(uint32 file_id, const char *Cmd) do { taskDelay(sysClkRateGet()); - } - while (taskNameToId(shellName) != ((TASK_ID)ERROR)); + } while (taskNameToId(shellName) != ((TASK_ID)ERROR)); - ReturnCode = OS_SUCCESS; + ReturnCode = OS_SUCCESS; } /* Close the file descriptor */ @@ -101,4 +98,3 @@ int32 OS_ShellOutputToFile_Impl(uint32 file_id, const char *Cmd) return ReturnCode; } /* end OS_ShellOutputToFile_Impl */ - diff --git a/src/os/vxworks/src/os-impl-symtab.c b/src/os/vxworks/src/os-impl-symtab.c index 30f2f570f..d3ebaf85a 100644 --- a/src/os/vxworks/src/os-impl-symtab.c +++ b/src/os/vxworks/src/os-impl-symtab.c @@ -48,8 +48,8 @@ typedef struct { - char SymbolName[OS_MAX_SYM_LEN]; - cpuaddr SymbolAddress; + char SymbolName[OS_MAX_SYM_LEN]; + cpuaddr SymbolAddress; } SymbolRecord_t; /* A global for storing the state in a SymbolDump call */ @@ -70,40 +70,39 @@ extern SYMTAB_ID sysSymTbl; * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_SymbolLookup_Impl( cpuaddr *SymbolAddress, const char *SymbolName ) +int32 OS_SymbolLookup_Impl(cpuaddr *SymbolAddress, const char *SymbolName) { - STATUS vxStatus; - SYMBOL_DESC SymDesc; + STATUS vxStatus; + SYMBOL_DESC SymDesc; - /* - ** Check parameters - */ - if (( SymbolAddress == NULL ) || (SymbolName == NULL )) - { - return(OS_INVALID_POINTER); - } - - /* - ** Lookup the entry point - ** - ** VxWorks 6.9 has deprecated the "symFindByName" API and it is replaced - ** with a "symFind" API instead. - */ + /* + ** Check parameters + */ + if ((SymbolAddress == NULL) || (SymbolName == NULL)) + { + return (OS_INVALID_POINTER); + } - memset (&SymDesc, 0, sizeof (SYMBOL_DESC)); - SymDesc.mask = SYM_FIND_BY_NAME; - SymDesc.name = (char*)SymbolName; + /* + ** Lookup the entry point + ** + ** VxWorks 6.9 has deprecated the "symFindByName" API and it is replaced + ** with a "symFind" API instead. + */ - vxStatus = symFind(sysSymTbl,&SymDesc); - *SymbolAddress = (cpuaddr)SymDesc.value; + memset(&SymDesc, 0, sizeof(SYMBOL_DESC)); + SymDesc.mask = SYM_FIND_BY_NAME; + SymDesc.name = (char *)SymbolName; - if (vxStatus == ERROR) - { - return(OS_ERROR); - } + vxStatus = symFind(sysSymTbl, &SymDesc); + *SymbolAddress = (cpuaddr)SymDesc.value; + if (vxStatus == ERROR) + { + return (OS_ERROR); + } - return(OS_SUCCESS); + return (OS_SUCCESS); } /* end OS_SymbolLookup_Impl */ @@ -127,70 +126,69 @@ int32 OS_SymbolLookup_Impl( cpuaddr *SymbolAddress, const char *SymbolName ) * The address of the symbol will be stored in the pointer that is passed in. * *-----------------------------------------------------------------*/ -BOOL OS_SymTableIterator_Impl ( char *name, SYM_VALUE val, SYM_TYPE type, _Vx_usr_arg_t arg, SYM_GROUP group ) +BOOL OS_SymTableIterator_Impl(char *name, SYM_VALUE val, SYM_TYPE type, _Vx_usr_arg_t arg, SYM_GROUP group) { - SymbolRecord_t symRecord; - uint32 NextSize; - int status; - SymbolDumpState_t *state; - - /* - * Rather than passing the state pointer through the generic "int" arg, - * use a global. This is OK because dumps are serialized externally. + SymbolRecord_t symRecord; + uint32 NextSize; + int status; + SymbolDumpState_t *state; + + /* + * Rather than passing the state pointer through the generic "int" arg, + * use a global. This is OK because dumps are serialized externally. + */ + state = &OS_VxWorks_SymbolDumpState; + + if (strlen(name) >= OS_MAX_SYM_LEN) + { + OS_DEBUG("%s(): symbol name too long\n", __func__); + state->StatusCode = OS_ERROR; + return (false); + } + + /* + ** Check to see if the maximum size of the file has been reached */ - state = &OS_VxWorks_SymbolDumpState; - - if (strlen(name) >= OS_MAX_SYM_LEN) - { - OS_DEBUG("%s(): symbol name too long\n", __func__); - state->StatusCode = OS_ERROR; - return(false); - } - - /* - ** Check to see if the maximum size of the file has been reached - */ - NextSize = state->CurrSize + sizeof(symRecord); - if ( NextSize > state->Sizelimit ) - { - /* - ** We exceeded the maximum size, so tell vxWorks to stop - ** However this is not considered an error, just a stop condition. - */ - OS_DEBUG("%s(): symbol table size exceeded\n", __func__); - return(false); - } - - /* - ** Copy symbol name - */ - strncpy(symRecord.SymbolName, name, OS_MAX_SYM_LEN); - - /* - ** Save symbol address - */ - symRecord.SymbolAddress = (cpuaddr)val; - - /* - ** Write entry in file - */ - status = write(state->fd, (char *)&symRecord, sizeof(symRecord)); - /* There is a problem if not all bytes were written OR if we get an error - * value, < 0. */ - if ( status < (int)sizeof(symRecord) ) - { - state->StatusCode = OS_ERROR; - return(false); - } - - state->CurrSize = NextSize; - - /* - ** It's OK to continue - */ - return(true); -} /* end OS_SymTableIterator_Impl */ + NextSize = state->CurrSize + sizeof(symRecord); + if (NextSize > state->Sizelimit) + { + /* + ** We exceeded the maximum size, so tell vxWorks to stop + ** However this is not considered an error, just a stop condition. + */ + OS_DEBUG("%s(): symbol table size exceeded\n", __func__); + return (false); + } + + /* + ** Copy symbol name + */ + strncpy(symRecord.SymbolName, name, OS_MAX_SYM_LEN); + + /* + ** Save symbol address + */ + symRecord.SymbolAddress = (cpuaddr)val; + /* + ** Write entry in file + */ + status = write(state->fd, (char *)&symRecord, sizeof(symRecord)); + /* There is a problem if not all bytes were written OR if we get an error + * value, < 0. */ + if (status < (int)sizeof(symRecord)) + { + state->StatusCode = OS_ERROR; + return (false); + } + + state->CurrSize = NextSize; + + /* + ** It's OK to continue + */ + return (true); +} /* end OS_SymTableIterator_Impl */ /*---------------------------------------------------------------- * @@ -200,7 +198,7 @@ BOOL OS_SymTableIterator_Impl ( char *name, SYM_VALUE val, SYM_TYPE type, _Vx * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_SymbolTableDump_Impl ( const char *local_filename, uint32 SizeLimit ) +int32 OS_SymbolTableDump_Impl(const char *local_filename, uint32 SizeLimit) { SymbolDumpState_t *state; @@ -217,7 +215,7 @@ int32 OS_SymbolTableDump_Impl ( const char *local_filename, uint32 SizeLimit ) ** Open file */ state->fd = open(local_filename, O_WRONLY | O_CREAT | O_TRUNC, 0666); - if ( state->fd < 0 ) + if (state->fd < 0) { OS_DEBUG("open(%s): error: %s\n", local_filename, strerror(errno)); state->StatusCode = OS_ERROR; @@ -227,12 +225,11 @@ int32 OS_SymbolTableDump_Impl ( const char *local_filename, uint32 SizeLimit ) /* ** Iterate the symbol table */ - (void) symEach( sysSymTbl, OS_SymTableIterator_Impl, 0 ); + (void)symEach(sysSymTbl, OS_SymTableIterator_Impl, 0); close(state->fd); } - return(state->StatusCode); + return (state->StatusCode); } /* end OS_SymbolTableDump_Impl */ - diff --git a/src/os/vxworks/src/os-impl-tasks.c b/src/os/vxworks/src/os-impl-tasks.c index 9740dd981..fac9ae90e 100644 --- a/src/os/vxworks/src/os-impl-tasks.c +++ b/src/os/vxworks/src/os-impl-tasks.c @@ -49,21 +49,21 @@ * If they are not defined, use a reasonable default/substitute. */ #if defined(_STACK_ALIGN_SIZE) -#define VX_IMPL_STACK_ALIGN_SIZE _STACK_ALIGN_SIZE +#define VX_IMPL_STACK_ALIGN_SIZE _STACK_ALIGN_SIZE #else -#define VX_IMPL_STACK_ALIGN_SIZE 16 +#define VX_IMPL_STACK_ALIGN_SIZE 16 #endif #if defined(STACK_ROUND_DOWN) #define VX_IMPL_STACK_ROUND_DOWN(x) STACK_ROUND_DOWN(x) #else -#define VX_IMPL_STACK_ROUND_DOWN(x) ((x) & ~(VX_IMPL_STACK_ALIGN_SIZE-1)) +#define VX_IMPL_STACK_ROUND_DOWN(x) ((x) & ~(VX_IMPL_STACK_ALIGN_SIZE - 1)) #endif #if defined(STACK_ROUND_UP) -#define VX_IMPL_STACK_ROUND_UP(x) STACK_ROUND_UP(x) +#define VX_IMPL_STACK_ROUND_UP(x) STACK_ROUND_UP(x) #else -#define VX_IMPL_STACK_ROUND_UP(x) (((x) + (VX_IMPL_STACK_ALIGN_SIZE-1)) & ~(VX_IMPL_STACK_ALIGN_SIZE-1)) +#define VX_IMPL_STACK_ROUND_UP(x) (((x) + (VX_IMPL_STACK_ALIGN_SIZE - 1)) & ~(VX_IMPL_STACK_ALIGN_SIZE - 1)) #endif /**************************************************************************************** @@ -71,7 +71,7 @@ ****************************************************************************************/ /* Tables where the OS object information is stored */ -OS_impl_task_internal_record_t OS_impl_task_table [OS_MAX_TASKS]; +OS_impl_task_internal_record_t OS_impl_task_table[OS_MAX_TASKS]; /*--------------------------------------------------------------------------------------- Name: OS_VxWorksEntry @@ -92,13 +92,10 @@ int OS_VxWorks_TaskEntry(int arg) return 0; } /* end OS_VxWorksEntry */ - - /**************************************************************************************** TASK API ****************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_VxWorks_TaskAPI_Impl_Init @@ -112,7 +109,6 @@ int32 OS_VxWorks_TaskAPI_Impl_Init(void) return (OS_SUCCESS); } /* end OS_VxWorks_TaskAPI_Impl_Init */ - /*---------------------------------------------------------------- * * Function: OS_TaskCreate_Impl @@ -121,16 +117,16 @@ int32 OS_VxWorks_TaskAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskCreate_Impl (uint32 task_id, uint32 flags) +int32 OS_TaskCreate_Impl(uint32 task_id, uint32 flags) { - STATUS status; - int vxflags; - int vxpri; - long actualsz; - long userstackbase; - long actualstackbase; + STATUS status; + int vxflags; + int vxpri; + long actualsz; + long userstackbase; + long actualstackbase; OS_impl_task_internal_record_t *lrec; - VxWorks_ID_Buffer_t id; + VxWorks_ID_Buffer_t id; lrec = &OS_impl_task_table[task_id]; @@ -145,13 +141,12 @@ int32 OS_TaskCreate_Impl (uint32 task_id, uint32 flags) vxflags |= VX_FP_TASK; } - /* * Get priority/stack specs from main struct * priority should be a direct passthru */ - vxpri = OS_task_table[task_id].priority; - actualsz = OS_task_table[task_id].stack_size; + vxpri = OS_task_table[task_id].priority; + actualsz = OS_task_table[task_id].stack_size; userstackbase = (long)OS_task_table[task_id].stack_pointer; /* @@ -216,7 +211,6 @@ int32 OS_TaskCreate_Impl (uint32 task_id, uint32 flags) { lrec->heap_block_size = actualsz; } - } userstackbase = (long)lrec->heap_block; @@ -240,20 +234,18 @@ int32 OS_TaskCreate_Impl (uint32 task_id, uint32 flags) * the case in the event that _STACK_DIR is not defined/known */ #if !defined(_STACK_DIR) || (_STACK_DIR != _STACK_GROWS_UP) - actualstackbase += actualsz; /* move to last byte of stack block */ + actualstackbase += actualsz; /* move to last byte of stack block */ #endif - id.id = OS_global_task_table[task_id].active_id; - status = taskInit( - &lrec->tcb, /* address of new task's TCB */ - (char*)OS_global_task_table[task_id].name_entry, - vxpri, /* priority of new task */ - vxflags, /* task option word */ - (char *)actualstackbase, /* base of new task's stack */ - actualsz, /* size (bytes) of stack needed */ - (FUNCPTR)OS_VxWorks_TaskEntry, /* entry point of new task */ - id.arg, /* 1st arg is ID */ - 0,0,0,0,0,0,0,0,0); + id.id = OS_global_task_table[task_id].active_id; + status = taskInit(&lrec->tcb, /* address of new task's TCB */ + (char *)OS_global_task_table[task_id].name_entry, vxpri, /* priority of new task */ + vxflags, /* task option word */ + (char *)actualstackbase, /* base of new task's stack */ + actualsz, /* size (bytes) of stack needed */ + (FUNCPTR)OS_VxWorks_TaskEntry, /* entry point of new task */ + id.arg, /* 1st arg is ID */ + 0, 0, 0, 0, 0, 0, 0, 0, 0); if (status != OK) { @@ -268,7 +260,6 @@ int32 OS_TaskCreate_Impl (uint32 task_id, uint32 flags) } /* end OS_TaskCreate_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TaskDelete_Impl @@ -277,7 +268,7 @@ int32 OS_TaskCreate_Impl (uint32 task_id, uint32 flags) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskDelete_Impl (uint32 task_id) +int32 OS_TaskDelete_Impl(uint32 task_id) { /* ** Try to delete the task @@ -287,7 +278,7 @@ int32 OS_TaskDelete_Impl (uint32 task_id) */ if (taskDelete(OS_impl_task_table[task_id].vxid) != OK) { - OS_DEBUG("taskDelete() - vxWorks errno %d\n",errno); + OS_DEBUG("taskDelete() - vxWorks errno %d\n", errno); return OS_ERROR; } @@ -296,7 +287,6 @@ int32 OS_TaskDelete_Impl (uint32 task_id) } /* end OS_TaskDelete_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TaskExit_Impl @@ -310,7 +300,6 @@ void OS_TaskExit_Impl() taskExit(0); } /* end OS_TaskExit_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TaskDelay_Impl @@ -319,7 +308,7 @@ void OS_TaskExit_Impl() * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskDelay_Impl (uint32 milli_second) +int32 OS_TaskDelay_Impl(uint32 milli_second) { /* msecs rounded to the closest system tick count */ int sys_ticks; @@ -331,7 +320,7 @@ int32 OS_TaskDelay_Impl (uint32 milli_second) } /* if successful, the execution of task will pend here until delay finishes */ - if(taskDelay(sys_ticks) != OK) + if (taskDelay(sys_ticks) != OK) { return OS_ERROR; } @@ -339,7 +328,6 @@ int32 OS_TaskDelay_Impl (uint32 milli_second) } /* end OS_TaskDelay_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TaskSetPriority_Impl @@ -348,10 +336,10 @@ int32 OS_TaskDelay_Impl (uint32 milli_second) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskSetPriority_Impl (uint32 task_id, uint32 new_priority) +int32 OS_TaskSetPriority_Impl(uint32 task_id, uint32 new_priority) { /* Set VxWorks Task Priority */ - if(taskPrioritySet(OS_impl_task_table[task_id].vxid, new_priority) != OK) + if (taskPrioritySet(OS_impl_task_table[task_id].vxid, new_priority) != OK) { return OS_ERROR; } @@ -360,7 +348,6 @@ int32 OS_TaskSetPriority_Impl (uint32 task_id, uint32 new_priority) } /* end OS_TaskSetPriority_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TaskMatch_Impl @@ -374,16 +361,14 @@ int32 OS_TaskMatch_Impl(uint32 task_id) /* ** Get VxWorks Task Id */ - if ( taskIdSelf() != OS_impl_task_table[task_id].vxid ) + if (taskIdSelf() != OS_impl_task_table[task_id].vxid) { - return(OS_ERROR); + return (OS_ERROR); } - - return OS_SUCCESS; + return OS_SUCCESS; } /* end OS_TaskMatch_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TaskRegister_Impl @@ -392,12 +377,11 @@ int32 OS_TaskMatch_Impl(uint32 task_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskRegister_Impl (osal_id_t global_task_id) +int32 OS_TaskRegister_Impl(osal_id_t global_task_id) { return OS_SUCCESS; } /* end OS_TaskRegister_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TaskGetId_Impl @@ -406,13 +390,13 @@ int32 OS_TaskRegister_Impl (osal_id_t global_task_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -osal_id_t OS_TaskGetId_Impl (void) +osal_id_t OS_TaskGetId_Impl(void) { OS_impl_task_internal_record_t *lrec; - size_t index; - osal_id_t id; + size_t index; + osal_id_t id; - id = OS_OBJECT_ID_UNDEFINED; + id = OS_OBJECT_ID_UNDEFINED; lrec = (OS_impl_task_internal_record_t *)taskTcb(taskIdSelf()); if (lrec != NULL) @@ -428,7 +412,6 @@ osal_id_t OS_TaskGetId_Impl (void) } /* end OS_TaskGetId_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TaskGetInfo_Impl @@ -437,7 +420,7 @@ osal_id_t OS_TaskGetId_Impl (void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskGetInfo_Impl (uint32 task_id, OS_task_prop_t *task_prop) +int32 OS_TaskGetInfo_Impl(uint32 task_id, OS_task_prop_t *task_prop) { return OS_SUCCESS; @@ -474,6 +457,3 @@ bool OS_TaskIdMatchSystemData_Impl(void *ref, uint32 local_id, const OS_common_r return (*target == OS_impl_task_table[local_id].vxid); } - - - diff --git a/src/os/vxworks/src/os-impl-timebase.c b/src/os/vxworks/src/os-impl-timebase.c index 26c769c27..28955632e 100644 --- a/src/os/vxworks/src/os-impl-timebase.c +++ b/src/os/vxworks/src/os-impl-timebase.c @@ -42,7 +42,6 @@ #include #include - /**************************************************************************************** DEFINES ****************************************************************************************/ @@ -53,25 +52,23 @@ * * This should run at the highest priority to reduce latency. */ -#define OSAL_TIMEBASE_TASK_STACK_SIZE 4096 -#define OSAL_TIMEBASE_TASK_PRIORITY 0 -#define OSAL_TIMEBASE_TASK_OPTION_WORD 0 +#define OSAL_TIMEBASE_TASK_STACK_SIZE 4096 +#define OSAL_TIMEBASE_TASK_PRIORITY 0 +#define OSAL_TIMEBASE_TASK_OPTION_WORD 0 -#define OSAL_TIMEBASE_REG_WAIT_LIMIT 100 +#define OSAL_TIMEBASE_REG_WAIT_LIMIT 100 /* * Prefer to use the MONOTONIC clock if available, as it will not get distrupted by setting * the time like the REALTIME clock will. */ #ifndef OS_PREFERRED_CLOCK -#ifdef _POSIX_MONOTONIC_CLOCK -#define OS_PREFERRED_CLOCK CLOCK_MONOTONIC +#ifdef _POSIX_MONOTONIC_CLOCK +#define OS_PREFERRED_CLOCK CLOCK_MONOTONIC #else -#define OS_PREFERRED_CLOCK CLOCK_REALTIME +#define OS_PREFERRED_CLOCK CLOCK_REALTIME #endif #endif - - /**************************************************************************************** LOCAL TYPEDEFS ****************************************************************************************/ @@ -82,13 +79,12 @@ OS_impl_timebase_internal_record_t OS_impl_timebase_table[OS_MAX_TIMEBASES]; -static uint32 OS_ClockAccuracyNsec; +static uint32 OS_ClockAccuracyNsec; /**************************************************************************************** INTERNAL FUNCTIONS ****************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_TimeBaseLock_Impl @@ -115,7 +111,6 @@ void OS_TimeBaseUnlock_Impl(uint32 local_id) semGive(OS_impl_timebase_table[local_id].handler_mutex); } /* end OS_TimeBaseUnlock_Impl */ - /*---------------------------------------------------------------- * * Function: OS_Impl_UsecToTimespec @@ -125,19 +120,18 @@ void OS_TimeBaseUnlock_Impl(uint32 local_id) *-----------------------------------------------------------------*/ void OS_VxWorks_UsecToTimespec(uint32 usecs, struct timespec *time_spec) { - if ( usecs < 1000000 ) - { - time_spec->tv_nsec = (usecs * 1000); - time_spec->tv_sec = 0; - } - else - { - time_spec->tv_sec = usecs / 1000000; - time_spec->tv_nsec = (usecs % 1000000) * 1000; - } + if (usecs < 1000000) + { + time_spec->tv_nsec = (usecs * 1000); + time_spec->tv_sec = 0; + } + else + { + time_spec->tv_sec = usecs / 1000000; + time_spec->tv_nsec = (usecs % 1000000) * 1000; + } } /* end OS_Impl_UsecToTimespec */ - /*---------------------------------------------------------------- * * Function: OS_VxWorks_SigWait @@ -149,14 +143,14 @@ void OS_VxWorks_UsecToTimespec(uint32 usecs, struct timespec *time_spec) uint32 OS_VxWorks_SigWait(uint32 local_id) { OS_impl_timebase_internal_record_t *local; - OS_common_record_t *global; - osal_id_t active_id; - uint32 tick_time; - int signo; - int ret; - - local = &OS_impl_timebase_table[local_id]; - global = &OS_global_timebase_table[local_id]; + OS_common_record_t * global; + osal_id_t active_id; + uint32 tick_time; + int signo; + int ret; + + local = &OS_impl_timebase_table[local_id]; + global = &OS_global_timebase_table[local_id]; active_id = global->active_id; tick_time = 0; @@ -185,13 +179,12 @@ uint32 OS_VxWorks_SigWait(uint32 local_id) * conditions. Samples from before/after a reconfig * are generally not comparable. */ - if (ret == OK && signo == local->assigned_signal && - OS_ObjectIdEqual(global->active_id, active_id)) + if (ret == OK && signo == local->assigned_signal && OS_ObjectIdEqual(global->active_id, active_id)) { if (local->reset_flag) { /* first interval after reset, use start time */ - tick_time = local->configured_start_time; + tick_time = local->configured_start_time; local->reset_flag = false; } else @@ -204,7 +197,6 @@ uint32 OS_VxWorks_SigWait(uint32 local_id) return tick_time; } /* end OS_VxWorks_SigWait */ - /*---------------------------------------------------------------- * * Function: OS_VxWorks_RegisterTimer @@ -215,16 +207,14 @@ uint32 OS_VxWorks_SigWait(uint32 local_id) void OS_VxWorks_RegisterTimer(uint32 local_id) { OS_impl_timebase_internal_record_t *local; - struct sigevent evp; - int status; + struct sigevent evp; + int status; local = &OS_impl_timebase_table[local_id]; - memset(&evp, 0, sizeof(evp)); evp.sigev_notify = SIGEV_SIGNAL; - evp.sigev_signo = local->assigned_signal; - + evp.sigev_signo = local->assigned_signal; /* ** Create the timer @@ -263,7 +253,7 @@ void OS_VxWorks_RegisterTimer(uint32 local_id) int OS_VxWorks_TimeBaseTask(int arg) { VxWorks_ID_Buffer_t id; - uint32 local_id; + uint32 local_id; id.arg = arg; if (OS_ConvertToArrayIndex(id.id, &local_id) == OS_SUCCESS) @@ -275,9 +265,6 @@ int OS_VxWorks_TimeBaseTask(int arg) return 0; } /* end OS_VxWorks_TimeBaseTask */ - - - /**************************************************************************************** INITIALIZATION FUNCTION ****************************************************************************************/ @@ -289,7 +276,7 @@ int OS_VxWorks_TimeBaseTask(int arg) * Purpose: Local helper routine, not part of OSAL API. * *-----------------------------------------------------------------*/ -int32 OS_VxWorks_TimeBaseAPI_Impl_Init ( void ) +int32 OS_VxWorks_TimeBaseAPI_Impl_Init(void) { int clockRate; @@ -300,7 +287,7 @@ int32 OS_VxWorks_TimeBaseAPI_Impl_Init ( void ) if (clockRate <= 0) { - return OS_ERROR; + return OS_ERROR; } OS_SharedGlobalVars.TicksPerSecond = clockRate; @@ -312,9 +299,7 @@ int32 OS_VxWorks_TimeBaseAPI_Impl_Init ( void ) * This really should be an exact/whole number result; otherwise this * will round to the nearest nanosecond. */ - OS_ClockAccuracyNsec = (1000000000 + (OS_SharedGlobalVars.TicksPerSecond / 2)) / - OS_SharedGlobalVars.TicksPerSecond; - + OS_ClockAccuracyNsec = (1000000000 + (OS_SharedGlobalVars.TicksPerSecond / 2)) / OS_SharedGlobalVars.TicksPerSecond; /* * Finally compute the Microseconds per tick @@ -323,14 +308,13 @@ int32 OS_VxWorks_TimeBaseAPI_Impl_Init ( void ) */ OS_SharedGlobalVars.MicroSecPerTick = (OS_ClockAccuracyNsec + 500) / 1000; - return(OS_SUCCESS); + return (OS_SUCCESS); } /* end OS_VxWorks_TimeBaseAPI_Impl_Init */ /**************************************************************************************** Time Base API ****************************************************************************************/ - /*---------------------------------------------------------------- * * Function: OS_TimeBaseCreate_Impl @@ -345,25 +329,25 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id) * The tick_sem is a simple semaphore posted by the ISR and taken by the * timebase helper task (created later). */ - int32 return_code; + int32 return_code; OS_impl_timebase_internal_record_t *local; - OS_common_record_t *global; - int signo; - sigset_t inuse; - uint32 i; - VxWorks_ID_Buffer_t idbuf; + OS_common_record_t * global; + int signo; + sigset_t inuse; + uint32 i; + VxWorks_ID_Buffer_t idbuf; return_code = OS_SUCCESS; - local = &OS_impl_timebase_table[timer_id]; - global = &OS_global_timebase_table[timer_id]; + local = &OS_impl_timebase_table[timer_id]; + global = &OS_global_timebase_table[timer_id]; sigemptyset(&local->timer_sigset); local->assigned_signal = 0; - local->handler_task = 0; - local->handler_mutex = (SEM_ID)0; - local->host_timerid = 0; - local->timer_state = OS_TimerRegState_INIT; - local->reset_flag = false; + local->handler_task = 0; + local->handler_mutex = (SEM_ID)0; + local->host_timerid = 0; + local->timer_state = OS_TimerRegState_INIT; + local->reset_flag = false; /* * Set up the necessary OS constructs @@ -383,19 +367,17 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id) */ sigemptyset(&inuse); - for(i = 0; i < OS_MAX_TIMEBASES; ++i) + for (i = 0; i < OS_MAX_TIMEBASES; ++i) { if (OS_ObjectIdDefined(OS_global_timebase_table[i].active_id) && - OS_impl_timebase_table[i].assigned_signal > 0) + OS_impl_timebase_table[i].assigned_signal > 0) { /* mark signal as in-use */ sigaddset(&inuse, OS_impl_timebase_table[i].assigned_signal); } } - for (signo = SIGRTMIN; - signo <= SIGRTMAX; - ++signo) + for (signo = SIGRTMIN; signo <= SIGRTMAX; ++signo) { if (!sigismember(&inuse, signo)) { @@ -442,9 +424,9 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id) * occurs there is no need to free the memory later. */ local->handler_mutex = semMInitialize(local->mmem, SEM_Q_PRIORITY | SEM_INVERSION_SAFE); - if ( local->handler_mutex == (SEM_ID)0 ) + if (local->handler_mutex == (SEM_ID)0) { - OS_DEBUG("Error: Handler Mutex could not be initialized: errno=%d\n",errno); + OS_DEBUG("Error: Handler Mutex could not be initialized: errno=%d\n", errno); return_code = OS_TIMER_ERR_INTERNAL; } } @@ -461,20 +443,17 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id) */ if (return_code == OS_SUCCESS) { - idbuf.id = global->active_id; - local->handler_task = taskSpawn( - (char*)global->name_entry, - OSAL_TIMEBASE_TASK_PRIORITY, /* priority */ - OSAL_TIMEBASE_TASK_OPTION_WORD, /* task option word */ - OSAL_TIMEBASE_TASK_STACK_SIZE, /* size (bytes) of stack needed */ - (FUNCPTR)OS_VxWorks_TimeBaseTask, - idbuf.arg, /* 1st arg is ID */ - 0,0,0,0,0,0,0,0,0); + idbuf.id = global->active_id; + local->handler_task = taskSpawn((char *)global->name_entry, OSAL_TIMEBASE_TASK_PRIORITY, /* priority */ + OSAL_TIMEBASE_TASK_OPTION_WORD, /* task option word */ + OSAL_TIMEBASE_TASK_STACK_SIZE, /* size (bytes) of stack needed */ + (FUNCPTR)OS_VxWorks_TimeBaseTask, idbuf.arg, /* 1st arg is ID */ + 0, 0, 0, 0, 0, 0, 0, 0, 0); /* check if taskSpawn failed */ if (local->handler_task == ((TASK_ID)ERROR)) { - OS_DEBUG("taskSpawn() - vxWorks errno: %d\n",errno); + OS_DEBUG("taskSpawn() - vxWorks errno: %d\n", errno); return_code = OS_TIMER_ERR_INTERNAL; } else @@ -491,7 +470,7 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id) * is necessary. */ i = OSAL_TIMEBASE_REG_WAIT_LIMIT; - while(local->timer_state == OS_TimerRegState_INIT && i > 0) + while (local->timer_state == OS_TimerRegState_INIT && i > 0) { OS_TaskDelay(1); --i; @@ -510,11 +489,9 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id) } } - return return_code; } /* end OS_TimeBaseCreate_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TimeBaseSet_Impl @@ -526,9 +503,9 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id) int32 OS_TimeBaseSet_Impl(uint32 timer_id, int32 start_time, int32 interval_time) { OS_impl_timebase_internal_record_t *local; - struct itimerspec timeout; - int32 return_code; - int status; + struct itimerspec timeout; + int32 return_code; + int status; local = &OS_impl_timebase_table[timer_id]; @@ -546,10 +523,9 @@ int32 OS_TimeBaseSet_Impl(uint32 timer_id, int32 start_time, int32 interval_time /* ** Program the real timer */ - status = timer_settime(local->host_timerid, - 0, /* Flags field can be zero */ - &timeout, /* struct itimerspec */ - NULL); /* Oldvalue */ + status = timer_settime(local->host_timerid, 0, /* Flags field can be zero */ + &timeout, /* struct itimerspec */ + NULL); /* Oldvalue */ if (status == OK) { @@ -572,36 +548,28 @@ int32 OS_TimeBaseSet_Impl(uint32 timer_id, int32 start_time, int32 interval_time status = timer_gettime(local->host_timerid, &timeout); if (status == OK) { - local->configured_start_time = - (timeout.it_value.tv_sec * 1000000) + - (timeout.it_value.tv_nsec / 1000); + local->configured_start_time = (timeout.it_value.tv_sec * 1000000) + (timeout.it_value.tv_nsec / 1000); local->configured_interval_time = - (timeout.it_interval.tv_sec * 1000000) + - (timeout.it_interval.tv_nsec / 1000); + (timeout.it_interval.tv_sec * 1000000) + (timeout.it_interval.tv_nsec / 1000); if (local->configured_start_time != start_time) { OS_DEBUG("WARNING: timer %lu start_time requested=%luus, configured=%luus\n", - (unsigned long)timer_id, - (unsigned long)start_time, - (unsigned long)local->configured_start_time); + (unsigned long)timer_id, (unsigned long)start_time, + (unsigned long)local->configured_start_time); } if (local->configured_interval_time != interval_time) { OS_DEBUG("WARNING: timer %lu interval_time requested=%luus, configured=%luus\n", - (unsigned long)timer_id, - (unsigned long)interval_time, - (unsigned long)local->configured_interval_time); + (unsigned long)timer_id, (unsigned long)interval_time, + (unsigned long)local->configured_interval_time); } - } - } else { return_code = OS_TIMER_ERR_INVALID_ARGS; } - } if (!local->reset_flag && return_code == OS_SUCCESS) @@ -612,8 +580,6 @@ int32 OS_TimeBaseSet_Impl(uint32 timer_id, int32 start_time, int32 interval_time return return_code; } /* end OS_TimeBaseSet_Impl */ - - /*---------------------------------------------------------------- * * Function: OS_TimeBaseDelete_Impl @@ -625,9 +591,9 @@ int32 OS_TimeBaseSet_Impl(uint32 timer_id, int32 start_time, int32 interval_time int32 OS_TimeBaseDelete_Impl(uint32 timer_id) { OS_impl_timebase_internal_record_t *local; - int32 return_code; + int32 return_code; - local = &OS_impl_timebase_table[timer_id]; + local = &OS_impl_timebase_table[timer_id]; return_code = OS_SUCCESS; /* An assigned_signal value indicates the OS timer needs deletion too */ @@ -635,7 +601,7 @@ int32 OS_TimeBaseDelete_Impl(uint32 timer_id) { /* this also implies the sync sem needs delete too */ timer_delete(local->host_timerid); - local->host_timerid = 0; + local->host_timerid = 0; local->assigned_signal = 0; } @@ -648,7 +614,6 @@ int32 OS_TimeBaseDelete_Impl(uint32 timer_id) return return_code; } /* end OS_TimeBaseDelete_Impl */ - /*---------------------------------------------------------------- * * Function: OS_TimeBaseGetInfo_Impl @@ -657,9 +622,8 @@ int32 OS_TimeBaseDelete_Impl(uint32 timer_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TimeBaseGetInfo_Impl (uint32 timer_id, OS_timebase_prop_t *timer_prop) +int32 OS_TimeBaseGetInfo_Impl(uint32 timer_id, OS_timebase_prop_t *timer_prop) { return OS_SUCCESS; } /* end OS_TimeBaseGetInfo_Impl */ - diff --git a/src/tests/bin-sem-flush-test/bin-sem-flush-test.c b/src/tests/bin-sem-flush-test/bin-sem-flush-test.c index cd98c9733..12c6b1ac8 100644 --- a/src/tests/bin-sem-flush-test/bin-sem-flush-test.c +++ b/src/tests/bin-sem-flush-test/bin-sem-flush-test.c @@ -33,72 +33,71 @@ void BinSemFlushSetup(void); void BinSemFlushCheck(void); void BinSemFlushTeardown(void); -#define TASK_STACK_SIZE 4096 -#define TASK_1_PRIORITY 100 -#define TASK_2_PRIORITY 110 -#define TASK_3_PRIORITY 120 +#define TASK_STACK_SIZE 4096 +#define TASK_1_PRIORITY 100 +#define TASK_2_PRIORITY 110 +#define TASK_3_PRIORITY 120 -uint32 task_1_stack[TASK_STACK_SIZE]; +uint32 task_1_stack[TASK_STACK_SIZE]; osal_id_t task_1_id; -uint32 task_1_failures; -uint32 task_1_work; +uint32 task_1_failures; +uint32 task_1_work; -uint32 task_2_stack[TASK_STACK_SIZE]; +uint32 task_2_stack[TASK_STACK_SIZE]; osal_id_t task_2_id; -uint32 task_2_failures; -uint32 task_2_work; +uint32 task_2_failures; +uint32 task_2_work; -uint32 task_3_stack[TASK_STACK_SIZE]; +uint32 task_3_stack[TASK_STACK_SIZE]; osal_id_t task_3_id; -uint32 task_3_failures; -uint32 task_3_work; +uint32 task_3_failures; +uint32 task_3_work; osal_id_t bin_sem_id; void task_1(void) { - uint32 status; - OS_bin_sem_prop_t bin_sem_prop; - int counter = 0; + uint32 status; + OS_bin_sem_prop_t bin_sem_prop; + int counter = 0; OS_printf("Starting task 1\n"); OS_TaskRegister(); OS_printf("TASK 1: Waiting on the semaphore\n"); status = OS_BinSemTake(bin_sem_id); - if ( status != OS_SUCCESS ) + if (status != OS_SUCCESS) { - ++task_1_failures; - OS_printf("TASK 1: Error calling OS_BinSemTake\n"); + ++task_1_failures; + OS_printf("TASK 1: Error calling OS_BinSemTake\n"); } else { - status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop); - if ( status != OS_SUCCESS ) - { - ++task_1_failures; - OS_printf("TASK 1: Error calling OS_BinSemGetInfo\n"); - } - else - { - OS_printf("TASK 1: out of BinSemTake: %d\n",(int)bin_sem_prop.value); - } + status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); + if (status != OS_SUCCESS) + { + ++task_1_failures; + OS_printf("TASK 1: Error calling OS_BinSemGetInfo\n"); + } + else + { + OS_printf("TASK 1: out of BinSemTake: %d\n", (int)bin_sem_prop.value); + } } - while(1) + while (1) { ++task_1_work; OS_TaskDelay(100); OS_printf("TASK 1: Doing some work: %d\n", (int)counter++); - } } void task_2(void) { - uint32 status; - OS_bin_sem_prop_t bin_sem_prop; - int counter = 0; + uint32 status; + OS_bin_sem_prop_t bin_sem_prop; + int counter = 0; task_2_failures = 0; OS_printf("Starting task 2\n"); @@ -106,70 +105,68 @@ void task_2(void) OS_printf("TASK 2: Waiting on the semaphore\n"); status = OS_BinSemTake(bin_sem_id); - if ( status != OS_SUCCESS ) + if (status != OS_SUCCESS) { - ++task_2_failures; - OS_printf("TASK 2: Error calling OS_BinSemTake\n"); + ++task_2_failures; + OS_printf("TASK 2: Error calling OS_BinSemTake\n"); } else { - status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop); - if ( status != OS_SUCCESS ) - { - ++task_2_failures; - OS_printf("TASK 2: Error calling OS_BinSemGetInfo\n"); - } - else - { - OS_printf("TASK 2: out of BinSemTake: %d\n",(int)bin_sem_prop.value); - } + status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); + if (status != OS_SUCCESS) + { + ++task_2_failures; + OS_printf("TASK 2: Error calling OS_BinSemGetInfo\n"); + } + else + { + OS_printf("TASK 2: out of BinSemTake: %d\n", (int)bin_sem_prop.value); + } } - while(1) + while (1) { ++task_2_work; OS_TaskDelay(100); OS_printf("TASK 2: Doing some work: %d\n", (int)counter++); - } } void task_3(void) { - uint32 status; - OS_bin_sem_prop_t bin_sem_prop; - int counter = 0; + uint32 status; + OS_bin_sem_prop_t bin_sem_prop; + int counter = 0; OS_printf("Starting task 3\n"); OS_TaskRegister(); OS_printf("TASK 3: Waiting on the semaphore\n"); status = OS_BinSemTake(bin_sem_id); - if ( status != OS_SUCCESS ) + if (status != OS_SUCCESS) { - ++task_3_failures; - OS_printf("TASK 3: Error calling OS_BinSemTake\n"); + ++task_3_failures; + OS_printf("TASK 3: Error calling OS_BinSemTake\n"); } else { - status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop); - if ( status != OS_SUCCESS ) - { - ++task_3_failures; - OS_printf("TASK 3: Error calling OS_BinSemGetInfo\n"); - } - else - { - OS_printf("TASK 3: out of BinSemTake: %d\n",(int)bin_sem_prop.value); - } + status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); + if (status != OS_SUCCESS) + { + ++task_3_failures; + OS_printf("TASK 3: Error calling OS_BinSemGetInfo\n"); + } + else + { + OS_printf("TASK 3: out of BinSemTake: %d\n", (int)bin_sem_prop.value); + } } - while(1) + while (1) { - ++task_3_work; + ++task_3_work; OS_TaskDelay(100); OS_printf("TASK 3: Doing some work: %d\n", (int)counter++); - } } @@ -191,57 +188,53 @@ void UtTest_Setup(void) void BinSemFlushSetup(void) { - uint32 status; - OS_bin_sem_prop_t bin_sem_prop; + uint32 status; + OS_bin_sem_prop_t bin_sem_prop; + + /* Note that UT assert is not multi-thread safe, + * so each thread must use a separate error counter + * and then we will assert that these remain zero + */ + task_1_failures = 0; + task_2_failures = 0; + task_3_failures = 0; + task_1_work = 0; + task_2_work = 0; + task_3_work = 0; + + /* + ** Create the binary semaphore + */ + status = OS_BinSemCreate(&bin_sem_id, "BinSem1", 1, 0); + UtAssert_True(status == OS_SUCCESS, "BinSem1 create Id=%lx Rc=%d", OS_ObjectIdToInteger(bin_sem_id), (int)status); + + status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); + UtAssert_True(status == OS_SUCCESS, "BinSem1 value=%d Rc=%d", (int)bin_sem_prop.value, (int)status); + + /* + ** Take the semaphore so the value is 0 and the next SemTake call should block + */ + status = OS_BinSemTake(bin_sem_id); + UtAssert_True(status == OS_SUCCESS, "BinSem1 take Rc=%d", (int)status); + status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); + UtAssert_True(status == OS_SUCCESS, "BinSem1 value=%d Rc=%d", (int)bin_sem_prop.value, (int)status); + + /* + ** Create the tasks + */ + status = OS_TaskCreate(&task_1_id, "Task 1", task_1, task_1_stack, TASK_STACK_SIZE, TASK_1_PRIORITY, 0); + UtAssert_True(status == OS_SUCCESS, "Task 1 create Id=%lx Rc=%d", OS_ObjectIdToInteger(task_1_id), (int)status); + + status = OS_TaskCreate(&task_2_id, "Task 2", task_2, task_2_stack, TASK_STACK_SIZE, TASK_2_PRIORITY, 0); + UtAssert_True(status == OS_SUCCESS, "Task 2 create Id=%lx Rc=%d", OS_ObjectIdToInteger(task_2_id), (int)status); - /* Note that UT assert is not multi-thread safe, - * so each thread must use a separate error counter - * and then we will assert that these remain zero + status = OS_TaskCreate(&task_3_id, "Task 3", task_3, task_3_stack, TASK_STACK_SIZE, TASK_3_PRIORITY, 0); + UtAssert_True(status == OS_SUCCESS, "Task 3 create Id=%lx Rc=%d", OS_ObjectIdToInteger(task_3_id), (int)status); + + /* + ** Delay, then check the status */ - task_1_failures = 0; - task_2_failures = 0; - task_3_failures = 0; - task_1_work = 0; - task_2_work = 0; - task_3_work = 0; - - /* - ** Create the binary semaphore - */ - status = OS_BinSemCreate( &bin_sem_id, "BinSem1", 1, 0); - UtAssert_True(status == OS_SUCCESS, "BinSem1 create Id=%lx Rc=%d", - OS_ObjectIdToInteger(bin_sem_id), (int)status); - - status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop); - UtAssert_True(status == OS_SUCCESS, "BinSem1 value=%d Rc=%d", (int)bin_sem_prop.value, (int)status); - - /* - ** Take the semaphore so the value is 0 and the next SemTake call should block - */ - status = OS_BinSemTake(bin_sem_id); - UtAssert_True(status == OS_SUCCESS, "BinSem1 take Rc=%d", (int)status); - status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop); - UtAssert_True(status == OS_SUCCESS, "BinSem1 value=%d Rc=%d", (int)bin_sem_prop.value, (int)status); - - /* - ** Create the tasks - */ - status = OS_TaskCreate( &task_1_id, "Task 1", task_1, task_1_stack, TASK_STACK_SIZE, TASK_1_PRIORITY, 0); - UtAssert_True(status == OS_SUCCESS, "Task 1 create Id=%lx Rc=%d", - OS_ObjectIdToInteger(task_1_id), (int)status); - - status = OS_TaskCreate( &task_2_id, "Task 2", task_2, task_2_stack, TASK_STACK_SIZE, TASK_2_PRIORITY, 0); - UtAssert_True(status == OS_SUCCESS, "Task 2 create Id=%lx Rc=%d", - OS_ObjectIdToInteger(task_2_id), (int)status); - - status = OS_TaskCreate( &task_3_id, "Task 3", task_3, task_3_stack, TASK_STACK_SIZE, TASK_3_PRIORITY, 0); - UtAssert_True(status == OS_SUCCESS, "Task 3 create Id=%lx Rc=%d", - OS_ObjectIdToInteger(task_3_id), (int)status); - - /* - ** Delay, then check the status - */ - OS_TaskDelay(2000); + OS_TaskDelay(2000); } void BinSemFlushCheck(void) @@ -249,9 +242,9 @@ void BinSemFlushCheck(void) int32 status; /* At first, No task should have done any work yet (all blocked) */ - UtAssert_True(task_1_work == 0, "Task 1 work = %u",(unsigned int)task_1_work); - UtAssert_True(task_2_work == 0, "Task 2 work = %u",(unsigned int)task_2_work); - UtAssert_True(task_3_work == 0, "Task 3 work = %u",(unsigned int)task_3_work); + UtAssert_True(task_1_work == 0, "Task 1 work = %u", (unsigned int)task_1_work); + UtAssert_True(task_2_work == 0, "Task 2 work = %u", (unsigned int)task_2_work); + UtAssert_True(task_3_work == 0, "Task 3 work = %u", (unsigned int)task_3_work); status = OS_BinSemFlush(bin_sem_id); UtAssert_True(status == OS_SUCCESS, "BinSem1 flush Rc=%d", (int)status); @@ -262,14 +255,13 @@ void BinSemFlushCheck(void) */ OS_TaskDelay(4000); - UtAssert_True(task_1_work != 0, "Task 1 work = %u",(unsigned int)task_1_work); - UtAssert_True(task_2_work != 0, "Task 2 work = %u",(unsigned int)task_2_work); - UtAssert_True(task_3_work != 0, "Task 3 work = %u",(unsigned int)task_3_work); - - UtAssert_True(task_1_failures == 0, "Task 1 failures = %u",(unsigned int)task_1_failures); - UtAssert_True(task_2_failures == 0, "Task 2 failures = %u",(unsigned int)task_2_failures); - UtAssert_True(task_3_failures == 0, "Task 3 failures = %u",(unsigned int)task_3_failures); + UtAssert_True(task_1_work != 0, "Task 1 work = %u", (unsigned int)task_1_work); + UtAssert_True(task_2_work != 0, "Task 2 work = %u", (unsigned int)task_2_work); + UtAssert_True(task_3_work != 0, "Task 3 work = %u", (unsigned int)task_3_work); + UtAssert_True(task_1_failures == 0, "Task 1 failures = %u", (unsigned int)task_1_failures); + UtAssert_True(task_2_failures == 0, "Task 2 failures = %u", (unsigned int)task_2_failures); + UtAssert_True(task_3_failures == 0, "Task 3 failures = %u", (unsigned int)task_3_failures); } void BinSemFlushTeardown(void) @@ -279,15 +271,12 @@ void BinSemFlushTeardown(void) /* ** Delete the tasks */ - status = OS_TaskDelete( task_1_id ); + status = OS_TaskDelete(task_1_id); UtAssert_True(status == OS_SUCCESS, "Task 1 delete Rc=%d", (int)status); - status = OS_TaskDelete( task_2_id ); + status = OS_TaskDelete(task_2_id); UtAssert_True(status == OS_SUCCESS, "Task 2 delete Rc=%d", (int)status); - status = OS_TaskDelete( task_3_id ); + status = OS_TaskDelete(task_3_id); UtAssert_True(status == OS_SUCCESS, "Task 3 delete Rc=%d", (int)status); - - } - diff --git a/src/tests/bin-sem-test/bin-sem-test.c b/src/tests/bin-sem-test/bin-sem-test.c index 916d9ae2d..0e645c6ea 100644 --- a/src/tests/bin-sem-test/bin-sem-test.c +++ b/src/tests/bin-sem-test/bin-sem-test.c @@ -45,22 +45,22 @@ void BinSemCheck(void); #define TASK_ENTRY 0x003 #define TASK_EXIT 0x004 -uint32 task_1_stack[TASK_1_STACK_SIZE]; +uint32 task_1_stack[TASK_1_STACK_SIZE]; osal_id_t task_1_id; -uint32 task_1_failures; -uint32 task_2_stack[TASK_2_STACK_SIZE]; +uint32 task_1_failures; +uint32 task_2_stack[TASK_2_STACK_SIZE]; osal_id_t task_2_id; -uint32 timer_failures; +uint32 timer_failures; osal_id_t bin_sem_id; -uint32 timer_counter; +uint32 timer_counter; osal_id_t timer_id; -uint32 timer_start = 1000; -uint32 timer_interval = 10000; /* 1000 = 1000 hz, 10000 == 100 hz */ -uint32 timer_accuracy; +uint32 timer_start = 1000; +uint32 timer_interval = 10000; /* 1000 = 1000 hz, 10000 == 100 hz */ +uint32 timer_accuracy; -int counter = 0; +int counter = 0; /* * Note that we should not call "printf" or anything @@ -70,40 +70,39 @@ int counter = 0; */ void TimerFunction(osal_id_t timer_id) { - int32 status; - - timer_counter++; - - status = OS_BinSemGive(bin_sem_id); - if ( status != OS_SUCCESS ) - { - ++timer_failures; - } - - { - OS_bin_sem_prop_t bin_sem_prop; - status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop); - if ( status != OS_SUCCESS ) - { - ++timer_failures; - } - else if ( bin_sem_prop.value > 1 ) - { - ++timer_failures; - } - else if ( bin_sem_prop.value < -1 ) - { - ++timer_failures; - } - } + int32 status; + timer_counter++; + + status = OS_BinSemGive(bin_sem_id); + if (status != OS_SUCCESS) + { + ++timer_failures; + } + + { + OS_bin_sem_prop_t bin_sem_prop; + status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); + if (status != OS_SUCCESS) + { + ++timer_failures; + } + else if (bin_sem_prop.value > 1) + { + ++timer_failures; + } + else if (bin_sem_prop.value < -1) + { + ++timer_failures; + } + } } void task_1(void) { - uint32 status; - OS_bin_sem_prop_t bin_sem_prop; - int printf_counter = 0; + uint32 status; + OS_bin_sem_prop_t bin_sem_prop; + int printf_counter = 0; OS_printf("Starting task 1\n"); @@ -113,51 +112,50 @@ void task_1(void) OS_TaskDelay(1000); /* if failures occur, do not loop endlessly */ - while(task_1_failures < 20) + while (task_1_failures < 20) { status = OS_BinSemTake(bin_sem_id); - if ( status != OS_SUCCESS ) + if (status != OS_SUCCESS) { - OS_printf("TASK 1:Error calling OS_BinSemTake\n"); - ++task_1_failures; - OS_TaskDelay(10); + OS_printf("TASK 1:Error calling OS_BinSemTake\n"); + ++task_1_failures; + OS_TaskDelay(10); } else { - printf_counter++; - counter++; - - if ( printf_counter > 100 ) - { - OS_printf("TASK 1: counter:%d timer_counter:%d\n", (int)counter,(int)timer_counter); - printf_counter = 0; - } - status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop); - if ( status != OS_SUCCESS ) - { - OS_printf("TASK 1:Error calling OS_BinSemGetInfo\n"); - ++task_1_failures; - } - else if ( bin_sem_prop.value > 1 ) - { - OS_printf("Error: Binary sem value > 1 ( in task):%d !\n",(int)bin_sem_prop.value); + printf_counter++; + counter++; + + if (printf_counter > 100) + { + OS_printf("TASK 1: counter:%d timer_counter:%d\n", (int)counter, (int)timer_counter); + printf_counter = 0; + } + status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); + if (status != OS_SUCCESS) + { + OS_printf("TASK 1:Error calling OS_BinSemGetInfo\n"); ++task_1_failures; - } - else if ( bin_sem_prop.value < -1 ) - { - OS_printf("Error: Binary sem value < -1 ( in task):%d !\n",(int)bin_sem_prop.value); + } + else if (bin_sem_prop.value > 1) + { + OS_printf("Error: Binary sem value > 1 ( in task):%d !\n", (int)bin_sem_prop.value); ++task_1_failures; - } + } + else if (bin_sem_prop.value < -1) + { + OS_printf("Error: Binary sem value < -1 ( in task):%d !\n", (int)bin_sem_prop.value); + ++task_1_failures; + } } - } } void BinSemCheck(void) { - uint32 status; - OS_bin_sem_prop_t bin_sem_prop; + uint32 status; + OS_bin_sem_prop_t bin_sem_prop; /* Delete the task, which should be pending in OS_BinSemTake() */ status = OS_TaskDelete(task_1_id); @@ -171,7 +169,7 @@ void BinSemCheck(void) /* Confirm that the semaphore itself is still operational after task deletion */ status = OS_BinSemGive(bin_sem_id); UtAssert_True(status == OS_SUCCESS, "BinSem give Rc=%d", (int)status); - status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop); + status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); UtAssert_True(status == OS_SUCCESS, "BinSem value=%d Rc=%d", (int)bin_sem_prop.value, (int)status); status = OS_BinSemTake(bin_sem_id); UtAssert_True(status == OS_SUCCESS, "BinSem take Rc=%d", (int)status); @@ -183,7 +181,6 @@ void BinSemCheck(void) UtAssert_True(timer_failures == 0, "Timer failures = %u", (unsigned int)timer_failures); } - void UtTest_Setup(void) { if (OS_API_Init() != OS_SUCCESS) @@ -199,22 +196,21 @@ void UtTest_Setup(void) void BinSemSetup(void) { - uint32 status; - uint32 accuracy; - OS_bin_sem_prop_t bin_sem_prop; + uint32 status; + uint32 accuracy; + OS_bin_sem_prop_t bin_sem_prop; /* separate task failure counter because ut-assert is not reentrant */ task_1_failures = 0; - timer_failures = 0; + timer_failures = 0; /* ** Create the binary semaphore */ - status = OS_BinSemCreate( &bin_sem_id, "BinSem1", 1, 0); - UtAssert_True(status == OS_SUCCESS, "BinSem1 create Id=%lx Rc=%d", - OS_ObjectIdToInteger(bin_sem_id), (int)status); + status = OS_BinSemCreate(&bin_sem_id, "BinSem1", 1, 0); + UtAssert_True(status == OS_SUCCESS, "BinSem1 create Id=%lx Rc=%d", OS_ObjectIdToInteger(bin_sem_id), (int)status); - status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop); + status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); UtAssert_True(status == OS_SUCCESS, "BinSem1 value=%d Rc=%d", (int)bin_sem_prop.value, (int)status); /* @@ -222,36 +218,33 @@ void BinSemSetup(void) */ status = OS_BinSemTake(bin_sem_id); UtAssert_True(status == OS_SUCCESS, "BinSem1 take Rc=%d", (int)status); - status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop); + status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); UtAssert_True(status == OS_SUCCESS, "BinSem1 value=%d Rc=%d", (int)bin_sem_prop.value, (int)status); /* ** Create the "consumer" task. */ - status = OS_TaskCreate( &task_1_id, "Task 1", task_1, task_1_stack, TASK_1_STACK_SIZE, TASK_1_PRIORITY, 0); - UtAssert_True(status == OS_SUCCESS, "Task 1 create Id=%lx Rc=%d", - OS_ObjectIdToInteger(task_1_id), (int)status); + status = OS_TaskCreate(&task_1_id, "Task 1", task_1, task_1_stack, TASK_1_STACK_SIZE, TASK_1_PRIORITY, 0); + UtAssert_True(status == OS_SUCCESS, "Task 1 create Id=%lx Rc=%d", OS_ObjectIdToInteger(task_1_id), (int)status); /* ** Create a timer */ status = OS_TimerCreate(&timer_id, "Timer 1", &accuracy, &(TimerFunction)); - UtAssert_True(status == OS_SUCCESS, "Timer 1 create Id=%lx Rc=%d", - OS_ObjectIdToInteger(timer_id), (int)status); - UtPrintf("Timer Accuracy = %u microseconds \n",(unsigned int)accuracy); + UtAssert_True(status == OS_SUCCESS, "Timer 1 create Id=%lx Rc=%d", OS_ObjectIdToInteger(timer_id), (int)status); + UtPrintf("Timer Accuracy = %u microseconds \n", (unsigned int)accuracy); /* ** Start the timer */ - status = OS_TimerSet(timer_id, timer_start, timer_interval); + status = OS_TimerSet(timer_id, timer_start, timer_interval); UtAssert_True(status == OS_SUCCESS, "Timer 1 set Rc=%d", (int)status); /* * Give the task some time to run */ - while(timer_counter < 1000) + while (timer_counter < 1000) { - OS_TaskDelay(100); + OS_TaskDelay(100); } - } diff --git a/src/tests/bin-sem-timeout-test/bin-sem-timeout-test.c b/src/tests/bin-sem-timeout-test/bin-sem-timeout-test.c index fc7d4dc05..b368f12d3 100644 --- a/src/tests/bin-sem-timeout-test/bin-sem-timeout-test.c +++ b/src/tests/bin-sem-timeout-test/bin-sem-timeout-test.c @@ -39,24 +39,24 @@ void BinSemTimeoutCheck(void); #define TASK_2_STACK_SIZE 1024 #define TASK_2_PRIORITY 50 -uint32 task_1_stack[TASK_1_STACK_SIZE]; +uint32 task_1_stack[TASK_1_STACK_SIZE]; osal_id_t task_1_id; -uint32 task_1_timeouts; -uint32 task_1_work; -uint32 task_1_failures; -uint32 task_2_stack[TASK_2_STACK_SIZE]; +uint32 task_1_timeouts; +uint32 task_1_work; +uint32 task_1_failures; +uint32 task_2_stack[TASK_2_STACK_SIZE]; osal_id_t task_2_id; osal_id_t bin_sem_id; -uint32 timer_counter; +uint32 timer_counter; osal_id_t timer_id; -uint32 timer_start = 1000000; -uint32 timer_interval = 2000000; /* 2 second period */ -uint32 timer_accuracy; -uint32 timer_function_failures; +uint32 timer_start = 1000000; +uint32 timer_interval = 2000000; /* 2 second period */ +uint32 timer_accuracy; +uint32 timer_function_failures; -int counter = 0; +int counter = 0; /* * Note that we should not call "printf" or anything @@ -66,88 +66,88 @@ int counter = 0; */ void TimerFunction(osal_id_t timer_id) { - int32 status; - - timer_counter++; - - status = OS_BinSemGive(bin_sem_id); - if ( status != OS_SUCCESS ) - { - ++timer_function_failures; - } - - { - OS_bin_sem_prop_t bin_sem_prop; - status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop); - if ( status != OS_SUCCESS ) - { - ++timer_function_failures; - } - else if ( bin_sem_prop.value > 1 ) - { - ++timer_function_failures; - } - else if ( bin_sem_prop.value < -1 ) - { - ++timer_function_failures; - } - } + int32 status; + + timer_counter++; + + status = OS_BinSemGive(bin_sem_id); + if (status != OS_SUCCESS) + { + ++timer_function_failures; + } + + { + OS_bin_sem_prop_t bin_sem_prop; + status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); + if (status != OS_SUCCESS) + { + ++timer_function_failures; + } + else if (bin_sem_prop.value > 1) + { + ++timer_function_failures; + } + else if (bin_sem_prop.value < -1) + { + ++timer_function_failures; + } + } } void task_1(void) { - uint32 status; - OS_bin_sem_prop_t bin_sem_prop; + uint32 status; + OS_bin_sem_prop_t bin_sem_prop; OS_printf("Starting task 1\n"); OS_TaskRegister(); OS_printf("Delay for 1 second before starting\n"); - OS_TaskDelay(1000); + OS_TaskDelay(1000); - while(1) + while (1) { OS_printf("TASK 1: Waiting on the semaphore\n"); status = OS_BinSemTimedWait(bin_sem_id, 1000); - if ( status == OS_SUCCESS ) + if (status == OS_SUCCESS) { - OS_printf("TASK 1: Doing some work: %d\n", (int)counter++); - status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop); - if (status != OS_SUCCESS) - { - OS_printf("Error: OS_BinSemGetInfo\n"); - ++task_1_failures; - } - else if ( bin_sem_prop.value > 1 ) - { - OS_printf("Error: Binary sem value > 1 ( in task):%d !\n",(int)bin_sem_prop.value); + OS_printf("TASK 1: Doing some work: %d\n", (int)counter++); + status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); + if (status != OS_SUCCESS) + { + OS_printf("Error: OS_BinSemGetInfo\n"); + ++task_1_failures; + } + else if (bin_sem_prop.value > 1) + { + OS_printf("Error: Binary sem value > 1 ( in task):%d !\n", (int)bin_sem_prop.value); ++task_1_failures; - } - else if ( bin_sem_prop.value < -1 ) - { - OS_printf("Error: Binary sem value < -1 ( in task):%d !\n",(int)bin_sem_prop.value); + } + else if (bin_sem_prop.value < -1) + { + OS_printf("Error: Binary sem value < -1 ( in task):%d !\n", (int)bin_sem_prop.value); ++task_1_failures; - } + } } - else if ( status == OS_SEM_TIMEOUT ) + else if (status == OS_SEM_TIMEOUT) { - OS_printf("TASK 1:Timeout on OS_BinSemTimedWait\n"); - ++task_1_timeouts; - OS_TaskDelay(500); + OS_printf("TASK 1:Timeout on OS_BinSemTimedWait\n"); + ++task_1_timeouts; + OS_TaskDelay(500); } else { - ++task_1_failures; - OS_printf("TASK 1:Error calling OS_BinSemTimedWait\n"); + ++task_1_failures; + OS_printf("TASK 1:Error calling OS_BinSemTimedWait\n"); } } } void BinSemTimeoutCheck(void) { - int32 status; + int32 status; uint32 limit; status = OS_TimerDelete(timer_id); @@ -156,21 +156,24 @@ void BinSemTimeoutCheck(void) status = OS_TaskDelete(task_1_id); UtAssert_True(status == OS_SUCCESS, "OS_TaskDelete Rc=%d", (int)status); - UtAssert_True(counter == timer_counter, "Task counter (%d) == timer counter (%d)", (int)counter, (int)timer_counter); + UtAssert_True(counter == timer_counter, "Task counter (%d) == timer counter (%d)", (int)counter, + (int)timer_counter); UtAssert_True(task_1_failures == 0, "Task 1 failures = %u", (unsigned int)task_1_failures); UtAssert_True(timer_function_failures == 0, "Timer function failures = %u", (unsigned int)timer_function_failures); - /* - * With the timers as configured, there should be approximately 1 task_1 timeout - * per real tick. Task 1 Sequence is: - * Sem Take (success after ??? ms) --> Sem Take (timeout after 1000ms) --> 500ms delay --> - * Sem Take (success after ~500ms) --> repeat - * And Repeat... - */ + /* + * With the timers as configured, there should be approximately 1 task_1 timeout + * per real tick. Task 1 Sequence is: + * Sem Take (success after ??? ms) --> Sem Take (timeout after 1000ms) --> 500ms delay --> + * Sem Take (success after ~500ms) --> repeat + * And Repeat... + */ limit = counter / 2; - UtAssert_True(task_1_timeouts >= limit, "Task 1 timeouts=%u >= %u", (unsigned int)task_1_timeouts, (unsigned int)limit); + UtAssert_True(task_1_timeouts >= limit, "Task 1 timeouts=%u >= %u", (unsigned int)task_1_timeouts, + (unsigned int)limit); limit = counter * 2; - UtAssert_True(task_1_timeouts <= limit, "Task 1 timeouts=%u <= %u", (unsigned int)task_1_timeouts, (unsigned int)limit); + UtAssert_True(task_1_timeouts <= limit, "Task 1 timeouts=%u <= %u", (unsigned int)task_1_timeouts, + (unsigned int)limit); } void UtTest_Setup(void) @@ -188,59 +191,56 @@ void UtTest_Setup(void) void BinSemTimeoutSetup(void) { - uint32 status; - OS_bin_sem_prop_t bin_sem_prop; - uint32 accuracy; - - task_1_timeouts = 0; - task_1_work = 0; - task_1_failures = 0; - timer_function_failures = 0; - - /* - ** Create the binary semaphore - */ - status = OS_BinSemCreate( &bin_sem_id, "BinSem1", 1, 0); - UtAssert_True(status == OS_SUCCESS, "BinSem1 create Id=%lx Rc=%d", - OS_ObjectIdToInteger(bin_sem_id), (int)status); - - status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop); - UtAssert_True(status == OS_SUCCESS, "BinSem1 value=%d Rc=%d", (int)bin_sem_prop.value, (int)status); - - /* - ** Take the semaphore so the value is 0 and the next SemTake call should block - */ - status = OS_BinSemTake(bin_sem_id); - UtAssert_True(status == OS_SUCCESS, "BinSem1 take Rc=%d", (int)status); - status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop); - UtAssert_True(status == OS_SUCCESS, "BinSem1 value=%d Rc=%d", (int)bin_sem_prop.value, (int)status); - - /* - ** Create the "consumer" task. - */ - status = OS_TaskCreate( &task_1_id, "Task 1", task_1, task_1_stack, TASK_1_STACK_SIZE, TASK_1_PRIORITY, 0); - UtAssert_True(status == OS_SUCCESS, "Task 1 create Id=%lx Rc=%d", - OS_ObjectIdToInteger(task_1_id), (int)status); - - /* - ** Create a timer - */ - status = OS_TimerCreate(&timer_id, "Timer 1", &accuracy, &(TimerFunction)); - UtAssert_True(status == OS_SUCCESS, "Timer 1 create Id=%lx Rc=%d", - OS_ObjectIdToInteger(timer_id), (int)status); - UtPrintf("Timer Accuracy = %u microseconds \n",(unsigned int)accuracy); - - /* - ** Start the timer - */ - status = OS_TimerSet(timer_id, timer_start, timer_interval); - UtAssert_True(status == OS_SUCCESS, "Timer 1 set Rc=%d", (int)status); - - /* - * Give tasks time to run + uint32 status; + OS_bin_sem_prop_t bin_sem_prop; + uint32 accuracy; + + task_1_timeouts = 0; + task_1_work = 0; + task_1_failures = 0; + timer_function_failures = 0; + + /* + ** Create the binary semaphore + */ + status = OS_BinSemCreate(&bin_sem_id, "BinSem1", 1, 0); + UtAssert_True(status == OS_SUCCESS, "BinSem1 create Id=%lx Rc=%d", OS_ObjectIdToInteger(bin_sem_id), (int)status); + + status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); + UtAssert_True(status == OS_SUCCESS, "BinSem1 value=%d Rc=%d", (int)bin_sem_prop.value, (int)status); + + /* + ** Take the semaphore so the value is 0 and the next SemTake call should block + */ + status = OS_BinSemTake(bin_sem_id); + UtAssert_True(status == OS_SUCCESS, "BinSem1 take Rc=%d", (int)status); + status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); + UtAssert_True(status == OS_SUCCESS, "BinSem1 value=%d Rc=%d", (int)bin_sem_prop.value, (int)status); + + /* + ** Create the "consumer" task. + */ + status = OS_TaskCreate(&task_1_id, "Task 1", task_1, task_1_stack, TASK_1_STACK_SIZE, TASK_1_PRIORITY, 0); + UtAssert_True(status == OS_SUCCESS, "Task 1 create Id=%lx Rc=%d", OS_ObjectIdToInteger(task_1_id), (int)status); + + /* + ** Create a timer + */ + status = OS_TimerCreate(&timer_id, "Timer 1", &accuracy, &(TimerFunction)); + UtAssert_True(status == OS_SUCCESS, "Timer 1 create Id=%lx Rc=%d", OS_ObjectIdToInteger(timer_id), (int)status); + UtPrintf("Timer Accuracy = %u microseconds \n", (unsigned int)accuracy); + + /* + ** Start the timer */ - while (counter < 10) - { - OS_TaskDelay(100); - } + status = OS_TimerSet(timer_id, timer_start, timer_interval); + UtAssert_True(status == OS_SUCCESS, "Timer 1 set Rc=%d", (int)status); + + /* + * Give tasks time to run + */ + while (counter < 10) + { + OS_TaskDelay(100); + } } diff --git a/src/tests/count-sem-test/count-sem-test.c b/src/tests/count-sem-test/count-sem-test.c index ebdcccc68..6ee4c92fb 100644 --- a/src/tests/count-sem-test/count-sem-test.c +++ b/src/tests/count-sem-test/count-sem-test.c @@ -32,120 +32,118 @@ void CountSemSetup(void); void CountSemCheck(void); -#define TASK_STACK_SIZE 4096 -#define TASK_1_PRIORITY 100 -#define TASK_2_PRIORITY 110 -#define TASK_3_PRIORITY 120 +#define TASK_STACK_SIZE 4096 +#define TASK_1_PRIORITY 100 +#define TASK_2_PRIORITY 110 +#define TASK_3_PRIORITY 120 -uint32 task_1_stack[TASK_STACK_SIZE]; +uint32 task_1_stack[TASK_STACK_SIZE]; osal_id_t task_1_id; -uint32 task_1_failures; -uint32 task_1_work; +uint32 task_1_failures; +uint32 task_1_work; -uint32 task_2_stack[TASK_STACK_SIZE]; +uint32 task_2_stack[TASK_STACK_SIZE]; osal_id_t task_2_id; -uint32 task_2_failures; -uint32 task_2_work; +uint32 task_2_failures; +uint32 task_2_work; -uint32 task_3_stack[TASK_STACK_SIZE]; +uint32 task_3_stack[TASK_STACK_SIZE]; osal_id_t task_3_id; -uint32 task_3_failures; -uint32 task_3_work; +uint32 task_3_failures; +uint32 task_3_work; osal_id_t count_sem_id; void task_1(void) { - uint32 status; + uint32 status; OS_printf("Starting task 1\n"); OS_TaskRegister(); - while(1) + while (1) { - OS_TaskDelay(2000); - - OS_printf("TASK 1: Giving the counting semaphore 1\n"); - status = OS_CountSemGive(count_sem_id); - if ( status != OS_SUCCESS ) - { - ++task_1_failures; - OS_printf("TASK 1: Error calling OS_CountSemGive 1: %d\n", (int)status); - } - else - { - ++task_1_work; - OS_printf("TASK 1: Counting Sem Give 1 complete\n"); - } - - OS_TaskDelay(500); - - OS_printf("TASK 1: Giving the counting semaphore 2\n"); - status = OS_CountSemGive(count_sem_id); - if ( status != OS_SUCCESS ) - { - ++task_1_failures; - OS_printf("TASK 1: Error calling OS_CountSemGive 2: %d\n", (int)status); - } - else - { - ++task_1_work; - OS_printf("TASK 1: Counting Sem Give 2 complete\n"); - } - + OS_TaskDelay(2000); + + OS_printf("TASK 1: Giving the counting semaphore 1\n"); + status = OS_CountSemGive(count_sem_id); + if (status != OS_SUCCESS) + { + ++task_1_failures; + OS_printf("TASK 1: Error calling OS_CountSemGive 1: %d\n", (int)status); + } + else + { + ++task_1_work; + OS_printf("TASK 1: Counting Sem Give 1 complete\n"); + } + + OS_TaskDelay(500); + + OS_printf("TASK 1: Giving the counting semaphore 2\n"); + status = OS_CountSemGive(count_sem_id); + if (status != OS_SUCCESS) + { + ++task_1_failures; + OS_printf("TASK 1: Error calling OS_CountSemGive 2: %d\n", (int)status); + } + else + { + ++task_1_work; + OS_printf("TASK 1: Counting Sem Give 2 complete\n"); + } } } void task_2(void) { - uint32 status; + uint32 status; OS_printf("Starting task 2\n"); OS_TaskRegister(); - while(1) + while (1) { - OS_TaskDelay(1000); - - OS_printf("TASK 2: Waiting on the semaphore\n"); - status = OS_CountSemTake(count_sem_id); - if ( status != OS_SUCCESS ) - { - ++task_2_failures; - OS_printf("TASK 2: Error calling OS_CountSemTake: %d\n", (int)status); - } - else - { - ++task_2_work; - OS_printf("TASK 2: grabbed Counting Sem\n"); - } - + OS_TaskDelay(1000); + + OS_printf("TASK 2: Waiting on the semaphore\n"); + status = OS_CountSemTake(count_sem_id); + if (status != OS_SUCCESS) + { + ++task_2_failures; + OS_printf("TASK 2: Error calling OS_CountSemTake: %d\n", (int)status); + } + else + { + ++task_2_work; + OS_printf("TASK 2: grabbed Counting Sem\n"); + } } } void task_3(void) { - uint32 status; + uint32 status; OS_printf("Starting task 3\n"); OS_TaskRegister(); - while(1) + while (1) { - OS_TaskDelay(1000); - - OS_printf("TASK 3: Waiting on the semaphore\n"); - status = OS_CountSemTake(count_sem_id); - if ( status != OS_SUCCESS ) - { - ++task_3_failures; - OS_printf("TASK 3: Error calling OS_CountSemTake: %d\n", (int)status); - } - else - { - ++task_3_work; - OS_printf("TASK 3: grabbed Counting Sem\n"); - } + OS_TaskDelay(1000); + + OS_printf("TASK 3: Waiting on the semaphore\n"); + status = OS_CountSemTake(count_sem_id); + if (status != OS_SUCCESS) + { + ++task_3_failures; + OS_printf("TASK 3: Error calling OS_CountSemTake: %d\n", (int)status); + } + else + { + ++task_3_work; + OS_printf("TASK 3: grabbed Counting Sem\n"); + } } } @@ -164,64 +162,61 @@ void UtTest_Setup(void) void CountSemSetup(void) { - uint32 status; - int i; - - task_1_failures = 0; - task_2_failures = 0; - task_3_failures = 0; - task_1_work = 0; - task_2_work = 0; - task_3_work = 0; - - /* - ** Create the Counting semaphore - */ - status = OS_CountSemCreate( &count_sem_id, "CountSem1", 2, 0); - UtAssert_True(status == OS_SUCCESS, "CountSem1 create Id=%lx Rc=%d", - OS_ObjectIdToInteger(count_sem_id), (int)status); - - /* - ** Take the semaphore so the value is 0 and the next SemTake call should block - */ - for ( i = 0; i < 2; i++) - { - status = OS_CountSemTake(count_sem_id); - UtAssert_True(status == OS_SUCCESS, "CountSem1 take Rc=%d", (int)status); - } - - /* - ** Create the tasks - */ - status = OS_TaskCreate( &task_1_id, "Task 1", task_1, task_1_stack, TASK_STACK_SIZE, TASK_1_PRIORITY, 0); - UtAssert_True(status == OS_SUCCESS, "Task 1 create Id=%lx Rc=%d", - OS_ObjectIdToInteger(task_1_id), (int)status); - - status = OS_TaskCreate( &task_2_id, "Task 2", task_2, task_2_stack, TASK_STACK_SIZE, TASK_2_PRIORITY, 0); - UtAssert_True(status == OS_SUCCESS, "Task 2 create Id=%lx Rc=%d", - OS_ObjectIdToInteger(task_2_id), (int)status); - - status = OS_TaskCreate( &task_3_id, "Task 3", task_3, task_3_stack, TASK_STACK_SIZE, TASK_3_PRIORITY, 0); - UtAssert_True(status == OS_SUCCESS, "Task 3 create Id=%lx Rc=%d", - OS_ObjectIdToInteger(task_3_id), (int)status); - - /* - * Time-limited execution + uint32 status; + int i; + + task_1_failures = 0; + task_2_failures = 0; + task_3_failures = 0; + task_1_work = 0; + task_2_work = 0; + task_3_work = 0; + + /* + ** Create the Counting semaphore */ - while(task_1_work < 10) - { - OS_TaskDelay(100); - } + status = OS_CountSemCreate(&count_sem_id, "CountSem1", 2, 0); + UtAssert_True(status == OS_SUCCESS, "CountSem1 create Id=%lx Rc=%d", OS_ObjectIdToInteger(count_sem_id), + (int)status); - /* - * Delete the tasks + /* + ** Take the semaphore so the value is 0 and the next SemTake call should block + */ + for (i = 0; i < 2; i++) + { + status = OS_CountSemTake(count_sem_id); + UtAssert_True(status == OS_SUCCESS, "CountSem1 take Rc=%d", (int)status); + } + + /* + ** Create the tasks */ - status = OS_TaskDelete(task_1_id); - UtAssert_True(status == OS_SUCCESS, "Task 1 delete Rc=%d", (int)status); - status = OS_TaskDelete(task_2_id); - UtAssert_True(status == OS_SUCCESS, "Task 2 delete Rc=%d", (int)status); - status = OS_TaskDelete(task_3_id); - UtAssert_True(status == OS_SUCCESS, "Task 3 delete Rc=%d", (int)status); + status = OS_TaskCreate(&task_1_id, "Task 1", task_1, task_1_stack, TASK_STACK_SIZE, TASK_1_PRIORITY, 0); + UtAssert_True(status == OS_SUCCESS, "Task 1 create Id=%lx Rc=%d", OS_ObjectIdToInteger(task_1_id), (int)status); + + status = OS_TaskCreate(&task_2_id, "Task 2", task_2, task_2_stack, TASK_STACK_SIZE, TASK_2_PRIORITY, 0); + UtAssert_True(status == OS_SUCCESS, "Task 2 create Id=%lx Rc=%d", OS_ObjectIdToInteger(task_2_id), (int)status); + + status = OS_TaskCreate(&task_3_id, "Task 3", task_3, task_3_stack, TASK_STACK_SIZE, TASK_3_PRIORITY, 0); + UtAssert_True(status == OS_SUCCESS, "Task 3 create Id=%lx Rc=%d", OS_ObjectIdToInteger(task_3_id), (int)status); + + /* + * Time-limited execution + */ + while (task_1_work < 10) + { + OS_TaskDelay(100); + } + + /* + * Delete the tasks + */ + status = OS_TaskDelete(task_1_id); + UtAssert_True(status == OS_SUCCESS, "Task 1 delete Rc=%d", (int)status); + status = OS_TaskDelete(task_2_id); + UtAssert_True(status == OS_SUCCESS, "Task 2 delete Rc=%d", (int)status); + status = OS_TaskDelete(task_3_id); + UtAssert_True(status == OS_SUCCESS, "Task 3 delete Rc=%d", (int)status); } void CountSemCheck(void) @@ -234,12 +229,13 @@ void CountSemCheck(void) * The sum of task 2 and task 3 work (consumer) cannot be greater than task 1 (the producer) * Add a fudge factor of +/- 2 to help avoid false failures due to scheduling */ - UtAssert_True((task_2_work + task_3_work) <= (task_1_work + 2), "Task 2+3 work < %u", (unsigned int)(task_1_work + 2)); - UtAssert_True((task_2_work + task_3_work) >= (task_1_work - 2), "Task 2+3 work > %u", (unsigned int)(task_1_work - 2)); + UtAssert_True((task_2_work + task_3_work) <= (task_1_work + 2), "Task 2+3 work < %u", + (unsigned int)(task_1_work + 2)); + UtAssert_True((task_2_work + task_3_work) >= (task_1_work - 2), "Task 2+3 work > %u", + (unsigned int)(task_1_work - 2)); /* None of the tasks should have any failures in their own counters */ - UtAssert_True(task_1_failures == 0, "Task 1 failures = %u",(unsigned int)task_1_failures); - UtAssert_True(task_2_failures == 0, "Task 2 failures = %u",(unsigned int)task_2_failures); - UtAssert_True(task_3_failures == 0, "Task 3 failures = %u",(unsigned int)task_3_failures); + UtAssert_True(task_1_failures == 0, "Task 1 failures = %u", (unsigned int)task_1_failures); + UtAssert_True(task_2_failures == 0, "Task 2 failures = %u", (unsigned int)task_2_failures); + UtAssert_True(task_3_failures == 0, "Task 3 failures = %u", (unsigned int)task_3_failures); } - diff --git a/src/tests/file-api-test/file-api-test.c b/src/tests/file-api-test/file-api-test.c index 6c9a6ea65..8bfda6ea0 100644 --- a/src/tests/file-api-test/file-api-test.c +++ b/src/tests/file-api-test/file-api-test.c @@ -89,11 +89,11 @@ void TestMkfsMount(void) int32 status; /* Make the file system */ - status = OS_mkfs(0,"/ramdev0","RAM",512,200); - UtAssert_True(status == OS_SUCCESS, "status after mkfs = %d",(int)status); + status = OS_mkfs(0, "/ramdev0", "RAM", 512, 200); + UtAssert_True(status == OS_SUCCESS, "status after mkfs = %d", (int)status); - status = OS_mount("/ramdev0","/drive0"); - UtAssert_True(status == OS_SUCCESS, "status after mount = %d",(int)status); + status = OS_mount("/ramdev0", "/drive0"); + UtAssert_True(status == OS_SUCCESS, "status after mount = %d", (int)status); } void TestUnmountRemount(void) @@ -101,13 +101,13 @@ void TestUnmountRemount(void) int32 status; /* - ** try unmounting the drive, and then remounting it with a different name + ** try unmounting the drive, and then remounting it with a different name */ status = OS_unmount("/drive0"); - UtAssert_True(status >= OS_SUCCESS, "status after unmount = %d",(int)status); + UtAssert_True(status >= OS_SUCCESS, "status after unmount = %d", (int)status); - status = OS_mount("/ramdev0","/drive1"); - UtAssert_True(status == OS_SUCCESS, "status after reunmount = %d",(int)status); + status = OS_mount("/ramdev0", "/drive1"); + UtAssert_True(status == OS_SUCCESS, "status after reunmount = %d", (int)status); } /*--------------------------------------------------------------------------------------- @@ -122,69 +122,69 @@ void TestUnmountRemount(void) void TestCreatRemove(void) { - char filename [OS_MAX_PATH_LEN]; - char maxfilename[OS_MAX_PATH_LEN]; - char longfilename [OS_MAX_PATH_LEN + 10]; - int32 status; - osal_id_t fd; - int i; - + char filename[OS_MAX_PATH_LEN]; + char maxfilename[OS_MAX_PATH_LEN]; + char longfilename[OS_MAX_PATH_LEN + 10]; + int32 status; + osal_id_t fd; + int i; + /* Short file name */ - strncpy(filename,"/drive0/a", sizeof(filename)); + strncpy(filename, "/drive0/a", sizeof(filename)); /* Create max file name (OS_MAX_FILE_NAME including terminating null) */ - strncpy(maxfilename,"/drive0/", sizeof(maxfilename)); + strncpy(maxfilename, "/drive0/", sizeof(maxfilename)); for (i = strlen(maxfilename); i < (OS_MAX_FILE_NAME - 1); i++) { maxfilename[i] = 'm'; } /* Create longer than max file name */ - strncpy(longfilename,"/drive0/", sizeof(longfilename)); + strncpy(longfilename, "/drive0/", sizeof(longfilename)); for (i = strlen(longfilename); i < (sizeof(longfilename) - 1); i++) { longfilename[i] = 'm'; } - + /* create a file with short name */ status = OS_OpenCreate(&fd, filename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); - UtAssert_True(status == OS_SUCCESS, "fd after creat short name length file = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "fd after creat short name length file = %d", (int)status); /* close the first file */ status = OS_close(fd); - UtAssert_True(status == OS_SUCCESS, "status after close short name length file = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after close short name length file = %d", (int)status); /* create a file with max name size */ status = OS_OpenCreate(&fd, maxfilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); - UtAssert_True(status == OS_SUCCESS, "fd after creat max name length file = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "fd after creat max name length file = %d", (int)status); /* close the second file */ status = OS_close(fd); - UtAssert_True(status == OS_SUCCESS, "status after close max name length file = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after close max name length file = %d", (int)status); /* remove the file from the drive */ status = OS_remove(filename); - UtAssert_True(status == OS_SUCCESS, "status after short name length file remove = %d",(int)status); - + UtAssert_True(status == OS_SUCCESS, "status after short name length file remove = %d", (int)status); + /* remove the file from the drive */ status = OS_remove(maxfilename); - UtAssert_True(status == OS_SUCCESS, "status after remove max name length file = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after remove max name length file = %d", (int)status); /* try creating with file name too big, should fail */ status = OS_OpenCreate(&fd, longfilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); - UtAssert_True(status < OS_SUCCESS, "status after create file name too long = %d",(int)status); + UtAssert_True(status < OS_SUCCESS, "status after create file name too long = %d", (int)status); /* try removing with file name too big. Should Fail */ status = OS_remove(longfilename); - UtAssert_True(status < OS_SUCCESS, "status after remove file name too long = %d",(int)status); + UtAssert_True(status < OS_SUCCESS, "status after remove file name too long = %d", (int)status); /* try removing file that no longer exists. Should Fail */ status = OS_remove(filename); - UtAssert_True(status < OS_SUCCESS, "status after remove file doesn't exist = %d",(int)status); + UtAssert_True(status < OS_SUCCESS, "status after remove file doesn't exist = %d", (int)status); /* Similar to previous but with a bad mount point (gives different error code) */ status = OS_remove("/x"); - UtAssert_True(status == OS_FS_ERR_PATH_INVALID, "status after remove bad mount = %d",(int)status); + UtAssert_True(status == OS_FS_ERR_PATH_INVALID, "status after remove bad mount = %d", (int)status); } /*--------------------------------------------------------------------------------------- @@ -193,50 +193,50 @@ void TestCreatRemove(void) ---------------------------------------------------------------------------------------*/ void TestOpenClose(void) { - char filename [OS_MAX_PATH_LEN]; - int32 status; + char filename[OS_MAX_PATH_LEN]; + int32 status; osal_id_t fd; - strncpy(filename,"/drive0/Filename1", sizeof(filename) - 1); + strncpy(filename, "/drive0/Filename1", sizeof(filename) - 1); filename[sizeof(filename) - 1] = 0; /* create a file of reasonable length (but over 8 chars) */ status = OS_OpenCreate(&fd, filename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); - UtAssert_True(status >= OS_SUCCESS, "status after creat = %d",(int)status); - + UtAssert_True(status >= OS_SUCCESS, "status after creat = %d", (int)status); + /* ** try to close the file */ status = OS_close(fd); - UtAssert_True(status == OS_SUCCESS, "status after close = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after close = %d", (int)status); /* reopen the file */ status = OS_OpenCreate(&fd, filename, OS_FILE_FLAG_NONE, OS_READ_WRITE); - UtAssert_True(status >= OS_SUCCESS, "status after reopen = %d",(int)status); + UtAssert_True(status >= OS_SUCCESS, "status after reopen = %d", (int)status); /* ** try to close the file again */ status = OS_close(fd); - UtAssert_True(status == OS_SUCCESS, "status after close = %d",(int)status); - + UtAssert_True(status == OS_SUCCESS, "status after close = %d", (int)status); + /* ** try to close the file again. Should Fail */ status = OS_close(fd); - UtAssert_True(status != OS_SUCCESS, "status after close = %d",(int)status); - + UtAssert_True(status != OS_SUCCESS, "status after close = %d", (int)status); + /*try to close a file not on the system. Should Fail */ status = OS_close(OS_OBJECT_ID_UNDEFINED); - UtAssert_True(status != OS_SUCCESS, "status after close = %d",(int)status); + UtAssert_True(status != OS_SUCCESS, "status after close = %d", (int)status); /* open a file that was never in the system */ status = OS_OpenCreate(&fd, "/drive0/FileNotHere", OS_FILE_FLAG_NONE, OS_READ_ONLY); - UtAssert_True(status < OS_SUCCESS, "status after open = %d",(int)status); + UtAssert_True(status < OS_SUCCESS, "status after open = %d", (int)status); /* try removing the file from the drive to end the function */ status = OS_remove(filename); - UtAssert_True(status == OS_SUCCESS, "status after remove = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after remove = %d", (int)status); } /*--------------------------------------------------------------------------------------- * Name TestReadWriteLseek @@ -244,120 +244,118 @@ void TestOpenClose(void) void TestReadWriteLseek(void) { - char filename [OS_MAX_PATH_LEN]; - char buffer [30]; - char copyofbuffer[30]; - char seekbuffer[30]; - char newbuffer[30]; - int offset; - int size; - int32 status; + char filename[OS_MAX_PATH_LEN]; + char buffer[30]; + char copyofbuffer[30]; + char seekbuffer[30]; + char newbuffer[30]; + int offset; + int size; + int32 status; osal_id_t fd; - strncpy(filename,"/drive0/Filename1", sizeof(filename) - 1); + strncpy(filename, "/drive0/Filename1", sizeof(filename) - 1); filename[sizeof(filename) - 1] = 0; - strcpy(buffer,"ValueToWriteInTheFile"); - strcpy(copyofbuffer,buffer); /* hold a copy of the buffer */ + strcpy(buffer, "ValueToWriteInTheFile"); + strcpy(copyofbuffer, buffer); /* hold a copy of the buffer */ offset = 12; /* start copying offset chars in buffer into seekbuffer */ strcpy(seekbuffer, &buffer[offset]); - + /* create a file of reasonable length (but over 8 chars) */ - + /* Open In R/W mode */ status = OS_OpenCreate(&fd, filename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); - UtAssert_True(status >= OS_SUCCESS, "status after creat = %d",(int)status); - + UtAssert_True(status >= OS_SUCCESS, "status after creat = %d", (int)status); + size = strlen(buffer); - + /* test write portion of R/W mode */ - status = OS_write(fd, (void*)buffer, size); - UtAssert_True(status == size, "status after write = %d size = %d",(int)status, (int)size); - - strcpy(buffer,""); + status = OS_write(fd, (void *)buffer, size); + UtAssert_True(status == size, "status after write = %d size = %d", (int)status, (int)size); + + strcpy(buffer, ""); /* lseek back to the beginning of the file */ - status = OS_lseek(fd,0, 0); - UtAssert_True(status >= OS_SUCCESS, "status after lseek = %d",(int)status); - + status = OS_lseek(fd, 0, 0); + UtAssert_True(status >= OS_SUCCESS, "status after lseek = %d", (int)status); + /*Read what we wrote to the file */ - status = OS_read(fd,(void*)buffer, size); - UtAssert_True(status == size, "status after read = %d size = %d",(int)status,(int)size); + status = OS_read(fd, (void *)buffer, size); + UtAssert_True(status == size, "status after read = %d size = %d", (int)status, (int)size); if (status >= OS_SUCCESS) { - UtAssert_True(strcmp(buffer,copyofbuffer) == 0, - "Read: %s, Written: %s",buffer,copyofbuffer); + UtAssert_True(strcmp(buffer, copyofbuffer) == 0, "Read: %s, Written: %s", buffer, copyofbuffer); } /* close the file */ status = OS_close(fd); - UtAssert_True(status == OS_SUCCESS, "status after close = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after close = %d", (int)status); /* open a file again, but only in READ mode */ status = OS_OpenCreate(&fd, filename, OS_FILE_FLAG_NONE, OS_READ_ONLY); - UtAssert_True(status >= OS_SUCCESS, "status after reopen = %d",(int)status); + UtAssert_True(status >= OS_SUCCESS, "status after reopen = %d", (int)status); /* test write in READ ONLY mode */ - status = OS_write(fd, (void*)buffer, size); - UtAssert_True(status < OS_SUCCESS, "status after write = %d",(int)status); + status = OS_write(fd, (void *)buffer, size); + UtAssert_True(status < OS_SUCCESS, "status after write = %d", (int)status); /* try to read in READ ONLY MODE */ - - status = OS_read(fd,(void*)buffer, size); - UtAssert_True(status == size, "status after read = %d size = %d",(int)status,(int)size); + + status = OS_read(fd, (void *)buffer, size); + UtAssert_True(status == size, "status after read = %d size = %d", (int)status, (int)size); if (status >= OS_SUCCESS) { - UtAssert_True(strcmp(buffer,copyofbuffer) == 0, - "Read: %s, Written: %s",buffer,copyofbuffer); + UtAssert_True(strcmp(buffer, copyofbuffer) == 0, "Read: %s, Written: %s", buffer, copyofbuffer); } /* seek to a spot in the middle of the file to test lseek */ - status = OS_lseek(fd,offset,0); - UtAssert_True(status >= OS_SUCCESS, "status after lseek = %d",(int)status); + status = OS_lseek(fd, offset, 0); + UtAssert_True(status >= OS_SUCCESS, "status after lseek = %d", (int)status); /* now try to read out only the last chars of the file */ - - status = OS_read(fd,(void*)newbuffer, (size - offset)); - UtAssert_True(status == (size - offset), "status after read = %d size = %d",(int)status,(int)(size - offset)); + + status = OS_read(fd, (void *)newbuffer, (size - offset)); + UtAssert_True(status == (size - offset), "status after read = %d size = %d", (int)status, (int)(size - offset)); if (status >= OS_SUCCESS) { - UtAssert_True(strncmp(newbuffer,seekbuffer, size - offset) == 0, - "Read: %s, Written: %s",newbuffer,seekbuffer); + UtAssert_True(strncmp(newbuffer, seekbuffer, size - offset) == 0, "Read: %s, Written: %s", newbuffer, + seekbuffer); } /* close the file */ status = OS_close(fd); - UtAssert_True(status == OS_SUCCESS, "status after close = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after close = %d", (int)status); /* open a file again, but only in WRITE mode */ status = OS_OpenCreate(&fd, filename, OS_FILE_FLAG_NONE, OS_WRITE_ONLY); - UtAssert_True(status >= OS_SUCCESS, "status after reopen = %d",(int)status); + UtAssert_True(status >= OS_SUCCESS, "status after reopen = %d", (int)status); /* test write in WRITE ONLY mode */ - status = OS_write(fd, (void*)buffer, size); - UtAssert_True(status == size, "status after write = %d size = %d",(int)status, (int)size); + status = OS_write(fd, (void *)buffer, size); + UtAssert_True(status == size, "status after write = %d size = %d", (int)status, (int)size); /* try to read in WRITE ONLY MODE */ - status = OS_read(fd,(void*)buffer, size); - UtAssert_True(status < OS_SUCCESS, "status after read = %d",(int)status); + status = OS_read(fd, (void *)buffer, size); + UtAssert_True(status < OS_SUCCESS, "status after read = %d", (int)status); /* seek to a spot in the middle of the file to test lseek */ - status = OS_lseek(fd,offset,0); - UtAssert_True(status >= OS_SUCCESS, "status after lseek = %d",(int)status); + status = OS_lseek(fd, offset, 0); + UtAssert_True(status >= OS_SUCCESS, "status after lseek = %d", (int)status); /* now try to read out only the last chars of the file */ - status = OS_read(fd,(void*)newbuffer, (size - offset)); - UtAssert_True(status < OS_SUCCESS, "status after read = %d",(int)status); + status = OS_read(fd, (void *)newbuffer, (size - offset)); + UtAssert_True(status < OS_SUCCESS, "status after read = %d", (int)status); /* close the file */ status = OS_close(fd); - UtAssert_True(status == OS_SUCCESS, "status after close = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after close = %d", (int)status); /* try removing the file from the drive */ status = OS_remove(filename); - UtAssert_True(status == OS_SUCCESS, "status after remove = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after remove = %d", (int)status); } /*--------------------------------------------------------------------------------------- @@ -365,198 +363,194 @@ void TestReadWriteLseek(void) ---------------------------------------------------------------------------------------*/ void TestMkRmDirFreeBytes(void) { - int32 status; - char filename1[OS_MAX_PATH_LEN]; - char filename2[OS_MAX_PATH_LEN]; - char dir1 [OS_MAX_PATH_LEN]; - char dir2 [OS_MAX_PATH_LEN]; - char buffer1 [OS_MAX_PATH_LEN]; - char buffer2 [OS_MAX_PATH_LEN]; - char copybuffer1 [OS_MAX_PATH_LEN]; - char copybuffer2 [OS_MAX_PATH_LEN]; + int32 status; + char filename1[OS_MAX_PATH_LEN]; + char filename2[OS_MAX_PATH_LEN]; + char dir1[OS_MAX_PATH_LEN]; + char dir2[OS_MAX_PATH_LEN]; + char buffer1[OS_MAX_PATH_LEN]; + char buffer2[OS_MAX_PATH_LEN]; + char copybuffer1[OS_MAX_PATH_LEN]; + char copybuffer2[OS_MAX_PATH_LEN]; osal_id_t fd1; osal_id_t fd2; - int size; + int size; /* make the directory names for testing, as well as the filenames and the buffers * to put in the files */ - strcpy(dir1,"/drive0/DIRECTORY_ONE"); - strcpy(dir2,"/drive0/directory_two"); - strcpy(filename1,"/drive0/DIRECTORY_ONE/MyFile1"); - strcpy(filename2,"/drive0/directory_two/MyFile2"); - strcpy(buffer1,"111111111111"); - strcpy(copybuffer1,buffer1); - strcpy(buffer2,"222222222222"); - strcpy(copybuffer2,buffer2); - + strcpy(dir1, "/drive0/DIRECTORY_ONE"); + strcpy(dir2, "/drive0/directory_two"); + strcpy(filename1, "/drive0/DIRECTORY_ONE/MyFile1"); + strcpy(filename2, "/drive0/directory_two/MyFile2"); + strcpy(buffer1, "111111111111"); + strcpy(copybuffer1, buffer1); + strcpy(buffer2, "222222222222"); + strcpy(copybuffer2, buffer2); + /* NOTE: The blocks free call is not necessarily implemented on all filesystems. * So the response of OS_ERR_NOT_IMPLEMENTED is acceptable. */ status = OS_fsBlocksFree("/drive0"); - UtAssert_True(status == OS_ERR_NOT_IMPLEMENTED || status >= OS_SUCCESS, "Checking Free Blocks: %d",(int)status); + UtAssert_True(status == OS_ERR_NOT_IMPLEMENTED || status >= OS_SUCCESS, "Checking Free Blocks: %d", (int)status); /* make the two directories */ - status = OS_mkdir(dir1,0); - UtAssert_True(status == OS_SUCCESS, "status after mkdir 1 = %d",(int)status); - - status = OS_mkdir(dir2,0); - UtAssert_True(status == OS_SUCCESS, "status after mkdir 2 = %d",(int)status); - + status = OS_mkdir(dir1, 0); + UtAssert_True(status == OS_SUCCESS, "status after mkdir 1 = %d", (int)status); + + status = OS_mkdir(dir2, 0); + UtAssert_True(status == OS_SUCCESS, "status after mkdir 2 = %d", (int)status); + /* now create two files in the two directories (1 file per directory) */ status = OS_OpenCreate(&fd1, filename1, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); - UtAssert_True(status >= OS_SUCCESS, "status after creat 1 = %d",(int)status); - + UtAssert_True(status >= OS_SUCCESS, "status after creat 1 = %d", (int)status); + status = OS_OpenCreate(&fd2, filename2, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); - UtAssert_True(status >= OS_SUCCESS, "status after creat 2 = %d",(int)status); - + UtAssert_True(status >= OS_SUCCESS, "status after creat 2 = %d", (int)status); + /* write the propper buffers into each of the files */ - size = strlen(buffer1); + size = strlen(buffer1); status = OS_write(fd1, buffer1, size); - UtAssert_True(status == size, "status after write 1 = %d size = %d",(int)status, (int)size); - - size = strlen(buffer2); + UtAssert_True(status == size, "status after write 1 = %d size = %d", (int)status, (int)size); + + size = strlen(buffer2); status = OS_write(fd2, buffer2, size); - UtAssert_True(status == size, "status after write 2 = %d size = %d",(int)status, (int)size); + UtAssert_True(status == size, "status after write 2 = %d size = %d", (int)status, (int)size); /* lseek back to the beginning of the file */ - status = OS_lseek(fd1,0, 0); - UtAssert_True(status >= OS_SUCCESS, "status after lseek 1 = %d",(int)status); - - status = OS_lseek(fd2,0, 0); - UtAssert_True(status >= OS_SUCCESS, "status after lseek 2 = %d",(int)status); + status = OS_lseek(fd1, 0, 0); + UtAssert_True(status >= OS_SUCCESS, "status after lseek 1 = %d", (int)status); + + status = OS_lseek(fd2, 0, 0); + UtAssert_True(status >= OS_SUCCESS, "status after lseek 2 = %d", (int)status); memset(buffer1, 0, sizeof(buffer1)); memset(buffer2, 0, sizeof(buffer2)); status = OS_fsBlocksFree("/drive0"); - UtAssert_True(status == OS_ERR_NOT_IMPLEMENTED || status >= OS_SUCCESS, "Checking Free Blocks: %d",(int)status); + UtAssert_True(status == OS_ERR_NOT_IMPLEMENTED || status >= OS_SUCCESS, "Checking Free Blocks: %d", (int)status); /* read back out of the files what we wrote into them */ - size = strlen(copybuffer1); - status = OS_read(fd1,(void*)buffer1, size); - UtAssert_True(status == size, "status after read 1 = %d size = %d",(int)status, (int)size); + size = strlen(copybuffer1); + status = OS_read(fd1, (void *)buffer1, size); + UtAssert_True(status == size, "status after read 1 = %d size = %d", (int)status, (int)size); if (status >= OS_SUCCESS) { - UtAssert_True(strncmp(buffer1,copybuffer1,size) == 0, - "Read: %s, Written: %s",buffer1,copybuffer1); + UtAssert_True(strncmp(buffer1, copybuffer1, size) == 0, "Read: %s, Written: %s", buffer1, copybuffer1); } - size = strlen(copybuffer2); - status = OS_read(fd2,(void*)buffer2, size); - UtAssert_True(status == size, "status after read 2 = %d size = %d",(int)status, (int)size); + size = strlen(copybuffer2); + status = OS_read(fd2, (void *)buffer2, size); + UtAssert_True(status == size, "status after read 2 = %d size = %d", (int)status, (int)size); if (status >= OS_SUCCESS) { - UtAssert_True(strncmp(buffer2,copybuffer2,size) == 0, - "Read: %s, Written: %s",buffer1,copybuffer1); + UtAssert_True(strncmp(buffer2, copybuffer2, size) == 0, "Read: %s, Written: %s", buffer1, copybuffer1); } - + /* close the files */ status = OS_close(fd1); - UtAssert_True(status == OS_SUCCESS, "status after close 1 = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after close 1 = %d", (int)status); status = OS_close(fd2); - UtAssert_True(status == OS_SUCCESS, "status after close 2 = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after close 2 = %d", (int)status); /* try removing the file from the drive */ status = OS_remove(filename1); - UtAssert_True(status == OS_SUCCESS, "status after remove 1 = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after remove 1 = %d", (int)status); status = OS_remove(filename2); - UtAssert_True(status == OS_SUCCESS, "status after remove 2 = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after remove 2 = %d", (int)status); status = OS_rmdir(dir1); - UtAssert_True(status == OS_SUCCESS, "status after rmdir 1 = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after rmdir 1 = %d", (int)status); status = OS_rmdir(dir2); - UtAssert_True(status == OS_SUCCESS, "status after rmdir 2 = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after rmdir 2 = %d", (int)status); status = OS_fsBlocksFree("/drive0"); - UtAssert_True(status == OS_ERR_NOT_IMPLEMENTED || status >= OS_SUCCESS, "Checking Free Blocks: %d",(int)status); + UtAssert_True(status == OS_ERR_NOT_IMPLEMENTED || status >= OS_SUCCESS, "Checking Free Blocks: %d", (int)status); } /*--------------------------------------------------------------------------------------- * Name TestOpenReadCloseDir(); ---------------------------------------------------------------------------------------*/ void TestOpenReadCloseDir(void) { - int32 status; - char filename1[OS_MAX_PATH_LEN]; - char filename2[OS_MAX_PATH_LEN]; - char dir0 [OS_MAX_PATH_LEN]; - char dir1 [OS_MAX_PATH_LEN]; - char dir2 [OS_MAX_PATH_LEN]; - char buffer1 [OS_MAX_PATH_LEN]; - char buffer2 [OS_MAX_PATH_LEN]; - int size; - osal_id_t fd1; - osal_id_t fd2; - osal_id_t dirh; + int32 status; + char filename1[OS_MAX_PATH_LEN]; + char filename2[OS_MAX_PATH_LEN]; + char dir0[OS_MAX_PATH_LEN]; + char dir1[OS_MAX_PATH_LEN]; + char dir2[OS_MAX_PATH_LEN]; + char buffer1[OS_MAX_PATH_LEN]; + char buffer2[OS_MAX_PATH_LEN]; + int size; + osal_id_t fd1; + osal_id_t fd2; + osal_id_t dirh; os_dirent_t dirent; - + /* make the directory names for testing, as well as the filenames and the buffers * to put in the files */ - strcpy(dir0,"/drive0"); - strcpy(dir1,"/drive0/DIRECTORY_ONE"); - strcpy(dir2,"/drive0/directory_two"); - strcpy(filename1,"/drive0/DIRECTORY_ONE/MyFile1"); - strcpy(filename2,"/drive0/directory_two/MyFile2"); - strcpy(buffer1,"111111111111"); - strcpy(buffer2,"222222222222"); + strcpy(dir0, "/drive0"); + strcpy(dir1, "/drive0/DIRECTORY_ONE"); + strcpy(dir2, "/drive0/directory_two"); + strcpy(filename1, "/drive0/DIRECTORY_ONE/MyFile1"); + strcpy(filename2, "/drive0/directory_two/MyFile2"); + strcpy(buffer1, "111111111111"); + strcpy(buffer2, "222222222222"); /* make the two directories */ - - status = OS_mkdir(dir1,0); - UtAssert_True(status == OS_SUCCESS, "status after mkdir 1 = %d",(int)status); - - status = OS_mkdir(dir2,0); - UtAssert_True(status == OS_SUCCESS, "status after mkdir 2 = %d",(int)status); - + + status = OS_mkdir(dir1, 0); + UtAssert_True(status == OS_SUCCESS, "status after mkdir 1 = %d", (int)status); + + status = OS_mkdir(dir2, 0); + UtAssert_True(status == OS_SUCCESS, "status after mkdir 2 = %d", (int)status); + /* now create two files in the two directories (1 file per directory) */ status = OS_OpenCreate(&fd1, filename1, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); - UtAssert_True(status >= OS_SUCCESS, "status after creat 1 = %d",(int)status); - + UtAssert_True(status >= OS_SUCCESS, "status after creat 1 = %d", (int)status); + status = OS_OpenCreate(&fd2, filename2, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); - UtAssert_True(status >= OS_SUCCESS, "status after creat 2 = %d",(int)status); - + UtAssert_True(status >= OS_SUCCESS, "status after creat 2 = %d", (int)status); + /* write the proper buffers into each of the files */ - size = strlen(buffer1); + size = strlen(buffer1); status = OS_write(fd1, buffer1, size); - UtAssert_True(status == size, "status after write 1 = %d size = %d",(int)status, (int)size); - - size = strlen(buffer2); + UtAssert_True(status == size, "status after write 1 = %d size = %d", (int)status, (int)size); + + size = strlen(buffer2); status = OS_write(fd2, buffer2, size); - UtAssert_True(status == size, "status after write 2 = %d size = %d",(int)status, (int)size); + UtAssert_True(status == size, "status after write 2 = %d size = %d", (int)status, (int)size); /* close the files */ status = OS_close(fd1); - UtAssert_True(status == OS_SUCCESS, "status after close 1 = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after close 1 = %d", (int)status); status = OS_close(fd2); - UtAssert_True(status == OS_SUCCESS, "status after close 2 = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after close 2 = %d", (int)status); /* Now both of the directories are there and have files in them. Also both files have stuff written in them */ - - + /* try to open the base directory "/" */ /* New version of test 1 - uses full abstraction API */ status = OS_DirectoryOpen(&dirh, dir0); - UtAssert_True(status >= OS_SUCCESS, "OS_DirectoryOpen Id=%lx Rc=%d", - OS_ObjectIdToInteger(dirh),(int)status); - + UtAssert_True(status >= OS_SUCCESS, "OS_DirectoryOpen Id=%lx Rc=%d", OS_ObjectIdToInteger(dirh), (int)status); + /* try to read the two folders that are in the "/" */ /* Have to make it a loop to see if we can find the directories in question */ while (true) { - status = OS_DirectoryRead (dirh, &dirent); - UtAssert_True(status == OS_SUCCESS, "OS_DirectoryRead Rc=%d Name=%s",(int)status, OS_DIRENTRY_NAME(dirent)); + status = OS_DirectoryRead(dirh, &dirent); + UtAssert_True(status == OS_SUCCESS, "OS_DirectoryRead Rc=%d Name=%s", (int)status, OS_DIRENTRY_NAME(dirent)); if (status != OS_SUCCESS) { - break; + break; } - if ( strcmp(OS_DIRENTRY_NAME(dirent),"DIRECTORY_ONE") == 0 ) + if (strcmp(OS_DIRENTRY_NAME(dirent), "DIRECTORY_ONE") == 0) { break; } @@ -567,86 +561,81 @@ void TestOpenReadCloseDir(void) /* Advance to end of dir */ while (status == OS_SUCCESS) { - status = OS_DirectoryRead(dirh, &dirent); + status = OS_DirectoryRead(dirh, &dirent); } status = OS_DirectoryClose(dirh); - UtAssert_True(status >= OS_SUCCESS, "OS_DirectoryClose Rc=%d",(int)status); - + UtAssert_True(status >= OS_SUCCESS, "OS_DirectoryClose Rc=%d", (int)status); + /* New version of test 2 - uses full abstraction API */ status = OS_DirectoryOpen(&dirh, dir0); - UtAssert_True(status >= OS_SUCCESS, "OS_DirectoryOpen Id=%lx Rc=%d", - OS_ObjectIdToInteger(dirh),(int)status); + UtAssert_True(status >= OS_SUCCESS, "OS_DirectoryOpen Id=%lx Rc=%d", OS_ObjectIdToInteger(dirh), (int)status); while (true) { - status = OS_DirectoryRead (dirh, &dirent); - UtAssert_True(status == OS_SUCCESS, "OS_DirectoryRead Rc=%d Name=%s",(int)status, OS_DIRENTRY_NAME(dirent)); - if (status != OS_SUCCESS) - { - break; - } - - if ( strcmp(OS_DIRENTRY_NAME(dirent),"directory_two") == 0) - { - break; - } + status = OS_DirectoryRead(dirh, &dirent); + UtAssert_True(status == OS_SUCCESS, "OS_DirectoryRead Rc=%d Name=%s", (int)status, OS_DIRENTRY_NAME(dirent)); + if (status != OS_SUCCESS) + { + break; + } + + if (strcmp(OS_DIRENTRY_NAME(dirent), "directory_two") == 0) + { + break; + } } UtAssert_True(status == OS_SUCCESS, "directory_two found"); status = OS_DirectoryClose(dirh); - UtAssert_True(status >= OS_SUCCESS, "OS_DirectoryClose Rc=%d",(int)status); + UtAssert_True(status >= OS_SUCCESS, "OS_DirectoryClose Rc=%d", (int)status); - /* Now test the open/ read close for one of the sub directories */ - + /* New version of test 4 - uses full abstraction API */ status = OS_DirectoryOpen(&dirh, dir1); - UtAssert_True(status >= OS_SUCCESS, "OS_DirectoryOpen Id=%lx Rc=%d", - OS_ObjectIdToInteger(dirh),(int)status); - - + UtAssert_True(status >= OS_SUCCESS, "OS_DirectoryOpen Id=%lx Rc=%d", OS_ObjectIdToInteger(dirh), (int)status); + /* try to read the next file within the first directory "MyFile1" */ while (true) { - status = OS_DirectoryRead (dirh, &dirent); - UtAssert_True(status == OS_SUCCESS, "OS_DirectoryRead Rc=%d Name=%s",(int)status, OS_DIRENTRY_NAME(dirent)); - if (status != OS_SUCCESS) - { - break; - } - - if ( strcmp(OS_DIRENTRY_NAME(dirent),"MyFile1") == 0) - { - break; - } + status = OS_DirectoryRead(dirh, &dirent); + UtAssert_True(status == OS_SUCCESS, "OS_DirectoryRead Rc=%d Name=%s", (int)status, OS_DIRENTRY_NAME(dirent)); + if (status != OS_SUCCESS) + { + break; + } + + if (strcmp(OS_DIRENTRY_NAME(dirent), "MyFile1") == 0) + { + break; + } } - + UtAssert_True(status == OS_SUCCESS, "MyFile1 found"); /* Close the file */ - + status = OS_DirectoryClose(dirh); - UtAssert_True(status >= OS_SUCCESS, "OS_DirectoryClose Rc=%d",(int)status); + UtAssert_True(status >= OS_SUCCESS, "OS_DirectoryClose Rc=%d", (int)status); /* New version of test 5 - uses full abstraction API */ status = OS_DirectoryOpen(&dirh, dir2); - UtAssert_True(status >= OS_SUCCESS, "OS_DirectoryOpen Id=%lx Rc=%d", - OS_ObjectIdToInteger(dirh),(int)status); - + UtAssert_True(status >= OS_SUCCESS, "OS_DirectoryOpen Id=%lx Rc=%d", OS_ObjectIdToInteger(dirh), (int)status); + /* try to read the next file within the first directory "MyFile2" */ while (true) { - status = OS_DirectoryRead (dirh, &dirent); - UtAssert_True(status == OS_SUCCESS, "OS_DirectoryRead Rc=%d Name=%s",(int)status, OS_DIRENTRY_NAME(dirent)); + status = OS_DirectoryRead(dirh, &dirent); + UtAssert_True(status == OS_SUCCESS, "OS_DirectoryRead Rc=%d Name=%s", (int)status, OS_DIRENTRY_NAME(dirent)); if (status != OS_SUCCESS) { break; } - if ( strcmp(OS_DIRENTRY_NAME(dirent),"MyFile2") == 0) + if (strcmp(OS_DIRENTRY_NAME(dirent), "MyFile2") == 0) { break; } @@ -656,32 +645,31 @@ void TestOpenReadCloseDir(void) /*Close the file */ status = OS_DirectoryClose(dirh); - UtAssert_True(status >= OS_SUCCESS, "OS_DirectoryClose Rc=%d",(int)status); + UtAssert_True(status >= OS_SUCCESS, "OS_DirectoryClose Rc=%d", (int)status); /* Test case for bug #181 - make sure that a directory used as a mount point * is able to be opened. This should not require a trailing * slash (i.e. /test rather than /test/) */ status = OS_DirectoryOpen(&dirh, "/test"); - UtAssert_True(status >= OS_SUCCESS, "OS_DirectoryOpen /test Id=%lx Rc=%d", - OS_ObjectIdToInteger(dirh),(int)status); + UtAssert_True(status >= OS_SUCCESS, "OS_DirectoryOpen /test Id=%lx Rc=%d", OS_ObjectIdToInteger(dirh), (int)status); /*Close the file */ status = OS_DirectoryClose(dirh); - UtAssert_True(status >= OS_SUCCESS, "OS_DirectoryClose /test Rc=%d",(int)status); + UtAssert_True(status >= OS_SUCCESS, "OS_DirectoryClose /test Rc=%d", (int)status); -/* remove the files */ + /* remove the files */ status = OS_remove(filename1); - UtAssert_True(status == OS_SUCCESS, "status after remove 1 = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after remove 1 = %d", (int)status); status = OS_remove(filename2); - UtAssert_True(status == OS_SUCCESS, "status after remove 2 = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after remove 2 = %d", (int)status); -/* remove the directories */ + /* remove the directories */ status = OS_rmdir(dir1); - UtAssert_True(status == OS_SUCCESS, "status after rmdir 1 = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after rmdir 1 = %d", (int)status); status = OS_rmdir(dir2); - UtAssert_True(status == OS_SUCCESS, "status after rmdir 2 = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after rmdir 2 = %d", (int)status); } /*--------------------------------------------------------------------------------------- @@ -690,146 +678,146 @@ void TestOpenReadCloseDir(void) void TestRename(void) { int32 status; - char filename1[OS_MAX_PATH_LEN]; - char dir0 [OS_MAX_PATH_LEN]; - char dir1 [OS_MAX_PATH_LEN]; + char filename1[OS_MAX_PATH_LEN]; + char dir0[OS_MAX_PATH_LEN]; + char dir1[OS_MAX_PATH_LEN]; + + char buffer1[OS_MAX_PATH_LEN]; + char copybuffer1[OS_MAX_PATH_LEN]; - char buffer1 [OS_MAX_PATH_LEN]; - char copybuffer1 [OS_MAX_PATH_LEN]; + char newdir1[OS_MAX_PATH_LEN]; + char midname1[OS_MAX_PATH_LEN]; + char newfilename1[OS_MAX_PATH_LEN]; - char newdir1 [OS_MAX_PATH_LEN]; - char midname1 [OS_MAX_PATH_LEN]; - char newfilename1 [OS_MAX_PATH_LEN]; - osal_id_t fd1; - int size; - + int size; + /* make the directory names for testing, as well as the filenames and the buffers * to put in the files */ - strcpy(dir0,"/drive1/"); - strcpy(dir1,"/drive1/DIRECTORY_ONE"); - strcpy(filename1,"/drive1/DIRECTORY_ONE/MyFile1"); - strcpy(buffer1,"111111111111"); - strcpy(copybuffer1,buffer1); - - strcpy(newdir1,"/drive1/NEW_DIR_ONE"); - strcpy(newfilename1,"/drive1/NEW_DIR_ONE/NEW_myfile1"); - - strcpy(midname1,"/drive1/NEW_DIR_ONE/MyFile1"); - + strcpy(dir0, "/drive1/"); + strcpy(dir1, "/drive1/DIRECTORY_ONE"); + strcpy(filename1, "/drive1/DIRECTORY_ONE/MyFile1"); + strcpy(buffer1, "111111111111"); + strcpy(copybuffer1, buffer1); + + strcpy(newdir1, "/drive1/NEW_DIR_ONE"); + strcpy(newfilename1, "/drive1/NEW_DIR_ONE/NEW_myfile1"); + + strcpy(midname1, "/drive1/NEW_DIR_ONE/MyFile1"); + /* make the directory */ - - status = OS_mkdir(dir1,0); - UtAssert_True(status == OS_SUCCESS, "status after mkdir 1 = %d",(int)status); - + + status = OS_mkdir(dir1, 0); + UtAssert_True(status == OS_SUCCESS, "status after mkdir 1 = %d", (int)status); + /* now create a file in the directory */ status = OS_OpenCreate(&fd1, filename1, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); - UtAssert_True(status >= OS_SUCCESS, "status after creat 1 = %d",(int)status); - + UtAssert_True(status >= OS_SUCCESS, "status after creat 1 = %d", (int)status); + /* write the propper buffes into the file */ - - size = strlen(buffer1); + + size = strlen(buffer1); status = OS_write(fd1, buffer1, size); - UtAssert_True(status == size, "status after write 1 = %d size = %d",(int)status, (int)size); + UtAssert_True(status == size, "status after write 1 = %d size = %d", (int)status, (int)size); /* close the file */ status = OS_close(fd1); - UtAssert_True(status == OS_SUCCESS, "status after close 1 = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after close 1 = %d", (int)status); -/* now there is 1 subdirectory with 1 file in it */ + /* now there is 1 subdirectory with 1 file in it */ /* Rename the directory */ - status = OS_rename(dir1,newdir1); - UtAssert_True(status == OS_SUCCESS, "status after rename 1 = %d",(int)status); + status = OS_rename(dir1, newdir1); + UtAssert_True(status == OS_SUCCESS, "status after rename 1 = %d", (int)status); - status = OS_rename(midname1,newfilename1); - UtAssert_True(status == OS_SUCCESS, "status after rename 2 = %d",(int)status); + status = OS_rename(midname1, newfilename1); + UtAssert_True(status == OS_SUCCESS, "status after rename 2 = %d", (int)status); memset(buffer1, 0, sizeof(buffer1)); /* try to read the new file out */ status = OS_OpenCreate(&fd1, newfilename1, OS_FILE_FLAG_NONE, OS_READ_ONLY); - UtAssert_True(status >= OS_SUCCESS, "status after open 1 = %d",(int)status); - - size = strlen(copybuffer1); - status = OS_read(fd1,buffer1,size); - UtAssert_True(status == size, "status after read 1 = %d size = %d",(int)status, (int)size); + UtAssert_True(status >= OS_SUCCESS, "status after open 1 = %d", (int)status); + + size = strlen(copybuffer1); + status = OS_read(fd1, buffer1, size); + UtAssert_True(status == size, "status after read 1 = %d size = %d", (int)status, (int)size); if (status >= OS_SUCCESS) { - UtAssert_True(strncmp(buffer1,copybuffer1, size) == 0, "Read and Written Results are equal"); + UtAssert_True(strncmp(buffer1, copybuffer1, size) == 0, "Read and Written Results are equal"); } - + status = OS_close(fd1); - UtAssert_True(status == OS_SUCCESS, "status after close 1 = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after close 1 = %d", (int)status); /* try removing the file from the drive */ /* note - if this is not done, subsequent runs of this test will fail */ status = OS_remove(newfilename1); - UtAssert_True(status == OS_SUCCESS, "status after remove 1 = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after remove 1 = %d", (int)status); status = OS_rmdir(newdir1); - UtAssert_True(status == OS_SUCCESS, "status after rmdir 1 = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after rmdir 1 = %d", (int)status); } /*--------------------------------------------------------------------------------------- * Name TestStat() ---------------------------------------------------------------------------------------*/ void TestStat(void) { - int32 status; + int32 status; - char filename1[OS_MAX_PATH_LEN]; - char dir1 [OS_MAX_PATH_LEN]; - char dir1slash[OS_MAX_PATH_LEN]; - char buffer1 [OS_MAX_PATH_LEN]; - os_fstat_t StatBuff; - osal_id_t fd1; - int size; + char filename1[OS_MAX_PATH_LEN]; + char dir1[OS_MAX_PATH_LEN]; + char dir1slash[OS_MAX_PATH_LEN]; + char buffer1[OS_MAX_PATH_LEN]; + os_fstat_t StatBuff; + osal_id_t fd1; + int size; - strcpy(dir1,"/drive0/DirectoryName"); + strcpy(dir1, "/drive0/DirectoryName"); strcpy(dir1slash, dir1); strcat(dir1slash, "/"); - strcpy(filename1,"/drive0/DirectoryName/MyFile1"); - strcpy(buffer1,"111111111111"); - + strcpy(filename1, "/drive0/DirectoryName/MyFile1"); + strcpy(buffer1, "111111111111"); + /* make the directory */ - status = OS_mkdir(dir1,0); - UtAssert_True(status == OS_SUCCESS, "status after mkdir 1 = %d",(int)status); - + status = OS_mkdir(dir1, 0); + UtAssert_True(status == OS_SUCCESS, "status after mkdir 1 = %d", (int)status); + /* now create a file */ status = OS_OpenCreate(&fd1, filename1, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); - UtAssert_True(status >= OS_SUCCESS, "status after creat 1 = %d",(int)status); - + UtAssert_True(status >= OS_SUCCESS, "status after creat 1 = %d", (int)status); + /* Write some data into the file */ - - size = strlen(buffer1); + + size = strlen(buffer1); status = OS_write(fd1, buffer1, size); - UtAssert_True(status == size, "status after write 1 = %d size = %d",(int)status, (int)size); - + UtAssert_True(status == size, "status after write 1 = %d size = %d", (int)status, (int)size); + status = OS_close(fd1); - UtAssert_True(status == OS_SUCCESS, "status after close 1 = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after close 1 = %d", (int)status); - /* - ** Make the stat calls + /* + ** Make the stat calls */ - status = OS_stat(dir1slash,&StatBuff); - UtAssert_True(status == OS_SUCCESS, "status after stat 1 = %d",(int)status); + status = OS_stat(dir1slash, &StatBuff); + UtAssert_True(status == OS_SUCCESS, "status after stat 1 = %d", (int)status); - status = OS_stat(dir1,&StatBuff); - UtAssert_True(status == OS_SUCCESS, "status after stat 2 = %d",(int)status); + status = OS_stat(dir1, &StatBuff); + UtAssert_True(status == OS_SUCCESS, "status after stat 2 = %d", (int)status); - status = OS_stat(filename1,&StatBuff); - UtAssert_True(status == OS_SUCCESS, "status after stat 3 = %d",(int)status); + status = OS_stat(filename1, &StatBuff); + UtAssert_True(status == OS_SUCCESS, "status after stat 3 = %d", (int)status); /* Clean up */ status = OS_remove(filename1); - UtAssert_True(status == OS_SUCCESS, "status after remove 1 = %d",(int)status); - + UtAssert_True(status == OS_SUCCESS, "status after remove 1 = %d", (int)status); + status = OS_rmdir(dir1); - UtAssert_True(status == OS_SUCCESS, "status after rmdir 1 = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after rmdir 1 = %d", (int)status); } /*--------------------------------------------------------------------------------------- @@ -842,50 +830,49 @@ void TestStat(void) ---------------------------------------------------------------------------------------*/ void TestOpenFileAPI(void) { - char filename1 [OS_MAX_PATH_LEN]; - char filename2 [OS_MAX_PATH_LEN]; - char filename3 [OS_MAX_PATH_LEN]; - int status; + char filename1[OS_MAX_PATH_LEN]; + char filename2[OS_MAX_PATH_LEN]; + char filename3[OS_MAX_PATH_LEN]; + int status; osal_id_t fd; - - strcpy(filename1,"/drive0/Filename1"); - strcpy(filename2,"/drive0/Filename2"); - strcpy(filename3,"/drive0/Filename3"); + + strcpy(filename1, "/drive0/Filename1"); + strcpy(filename2, "/drive0/Filename2"); + strcpy(filename3, "/drive0/Filename3"); /* Create/open a file */ status = OS_OpenCreate(&fd, filename1, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); - UtAssert_True(status >= OS_SUCCESS, "status after creat 1 = %d",(int)status); + UtAssert_True(status >= OS_SUCCESS, "status after creat 1 = %d", (int)status); /* Create/open a file */ status = OS_OpenCreate(&fd, filename2, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); - UtAssert_True(status >= OS_SUCCESS, "status after creat 2 = %d",(int)status); - + UtAssert_True(status >= OS_SUCCESS, "status after creat 2 = %d", (int)status); + /* Create/open a file */ status = OS_OpenCreate(&fd, filename3, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); - UtAssert_True(status >= OS_SUCCESS, "status after creat 3 = %d",(int)status); + UtAssert_True(status >= OS_SUCCESS, "status after creat 3 = %d", (int)status); - /* + /* ** Try OS_FileOpenCheck */ status = OS_FileOpenCheck(filename1); - UtAssert_True(status >= OS_SUCCESS, "status after OS_FileOpenCheck 1 = %d",(int)status); + UtAssert_True(status >= OS_SUCCESS, "status after OS_FileOpenCheck 1 = %d", (int)status); /* ** Try OS_CloseFileByName */ status = OS_CloseFileByName(filename1); - UtAssert_True(status == OS_SUCCESS, "status after OS_CloseFileByName 1 = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after OS_CloseFileByName 1 = %d", (int)status); /* ** Try OS_CloseAllFiles */ status = OS_CloseAllFiles(); - UtAssert_True(status == OS_SUCCESS, "status after OS_CloseAllFiles = %d",(int)status); + UtAssert_True(status == OS_SUCCESS, "status after OS_CloseAllFiles = %d", (int)status); /* ** Try OS_CloseFileByName with a file that is already closed */ status = OS_CloseFileByName(filename2); - UtAssert_True(status < OS_SUCCESS, "status after OS_CloseFileByName 2 = %d",(int)status); + UtAssert_True(status < OS_SUCCESS, "status after OS_CloseFileByName 2 = %d", (int)status); } - diff --git a/src/tests/file-sys-add-fixed-map-api-test/file-sys-add-fixed-map-api-test.c b/src/tests/file-sys-add-fixed-map-api-test/file-sys-add-fixed-map-api-test.c index fc2d08c69..e3fd8567d 100644 --- a/src/tests/file-sys-add-fixed-map-api-test/file-sys-add-fixed-map-api-test.c +++ b/src/tests/file-sys-add-fixed-map-api-test/file-sys-add-fixed-map-api-test.c @@ -18,7 +18,6 @@ * limitations under the License. */ - /* * Filename: file-sys-add-fixed-map-api-test.c * @@ -35,15 +34,14 @@ #include "uttest.h" #include "utbsp.h" - /* *************************************** MAIN ************************************** */ void TestFileSysAddFixedMapApi(void) { - int32 expected; - int32 actual; + int32 expected; + int32 actual; osal_id_t fs_id; - char translated_path[OS_MAX_LOCAL_PATH_LEN]; + char translated_path[OS_MAX_LOCAL_PATH_LEN]; /* Test for nominal inputs */ @@ -53,46 +51,44 @@ void TestFileSysAddFixedMapApi(void) */ expected = OS_FS_ERR_PATH_INVALID; - actual = OS_TranslatePath("/test/myfile.txt", translated_path); + actual = OS_TranslatePath("/test/myfile.txt", translated_path); UtAssert_True(actual == expected, "OS_TranslatePath() (%ld) == OS_SUCCESS", (long)actual); expected = OS_SUCCESS; - actual = OS_FileSysAddFixedMap(&fs_id, "./test", "/test"); + actual = OS_FileSysAddFixedMap(&fs_id, "./test", "/test"); UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_SUCCESS", (long)actual); expected = OS_SUCCESS; - actual = OS_TranslatePath("/test/myfile.txt", translated_path); + actual = OS_TranslatePath("/test/myfile.txt", translated_path); UtAssert_True(actual == expected, "OS_TranslatePath() (%ld) == OS_SUCCESS", (long)actual); /* Test for invalid inputs */ expected = OS_ERR_NAME_TAKEN; - actual = OS_FileSysAddFixedMap(NULL, "./test", "/test"); + actual = OS_FileSysAddFixedMap(NULL, "./test", "/test"); UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_FileSysAddFixedMap(&fs_id, NULL, "/test"); + actual = OS_FileSysAddFixedMap(&fs_id, NULL, "/test"); UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_FileSysAddFixedMap(&fs_id, "./test", NULL); + actual = OS_FileSysAddFixedMap(&fs_id, "./test", NULL); UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_FileSysAddFixedMap(NULL, NULL, NULL); + actual = OS_FileSysAddFixedMap(NULL, NULL, NULL); UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_FileSysAddFixedMap(&fs_id, NULL, NULL); + actual = OS_FileSysAddFixedMap(&fs_id, NULL, NULL); UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_FileSysAddFixedMap(NULL, "./test", NULL); + actual = OS_FileSysAddFixedMap(NULL, "./test", NULL); UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual); - } /* end TestFileSysAddFixedMapApi */ - void UtTest_Setup(void) { if (OS_API_Init() != OS_SUCCESS) @@ -105,4 +101,3 @@ void UtTest_Setup(void) */ UtTest_Add(TestFileSysAddFixedMapApi, NULL, NULL, "TestFileSysAddFixedMapApi"); } - diff --git a/src/tests/idmap-api-test/idmap-api-test.c b/src/tests/idmap-api-test/idmap-api-test.c index c0133c0aa..c91aec89c 100644 --- a/src/tests/idmap-api-test/idmap-api-test.c +++ b/src/tests/idmap-api-test/idmap-api-test.c @@ -35,7 +35,6 @@ #include "uttest.h" #include "utbsp.h" - osal_id_t task_id; osal_id_t queue_id; osal_id_t count_sem_id; @@ -45,7 +44,7 @@ osal_id_t mutex_id2; osal_id_t mutex_id3; osal_id_t time_base_id; -#define UT_EXIT_LOOP_MAX 100 +#define UT_EXIT_LOOP_MAX 100 /* *************************************** MAIN ************************************** */ @@ -64,75 +63,75 @@ static void ObjTypeCounter(osal_id_t object_id, void *arg) { Test_OS_ObjTypeCount_t *count = arg; - switch(OS_IdentifyObject(object_id)) + switch (OS_IdentifyObject(object_id)) { - case OS_OBJECT_TYPE_OS_TASK: - ++count->TaskCount; - break; - case OS_OBJECT_TYPE_OS_QUEUE: - ++count->QueueCount; - break; - case OS_OBJECT_TYPE_OS_COUNTSEM: - ++count->CountSemCount; - break; - case OS_OBJECT_TYPE_OS_BINSEM: - ++count->BinSemCount; - break; - case OS_OBJECT_TYPE_OS_MUTEX: - ++count->MutexCount; - break; - case OS_OBJECT_TYPE_OS_TIMEBASE: - ++count->TimeBaseCount; - break; - default: - ++count->OtherCount; - break; + case OS_OBJECT_TYPE_OS_TASK: + ++count->TaskCount; + break; + case OS_OBJECT_TYPE_OS_QUEUE: + ++count->QueueCount; + break; + case OS_OBJECT_TYPE_OS_COUNTSEM: + ++count->CountSemCount; + break; + case OS_OBJECT_TYPE_OS_BINSEM: + ++count->BinSemCount; + break; + case OS_OBJECT_TYPE_OS_MUTEX: + ++count->MutexCount; + break; + case OS_OBJECT_TYPE_OS_TIMEBASE: + ++count->TimeBaseCount; + break; + default: + ++count->OtherCount; + break; } } /* -* A void test function that creates an object for testing -*/ + * A void test function that creates an object for testing + */ void Test_Void_Fn(void) { osal_id_t bin_sem_id_my_task; - OS_BinSemCreate( &bin_sem_id_my_task, "BinSemTaskMyTask", 1, 0); + OS_BinSemCreate(&bin_sem_id_my_task, "BinSemTaskMyTask", 1, 0); OS_TaskDelay(5); } /* end Test_Void_Fn */ void TestIdMapApi_Setup(void) { - uint32 loopcnt; - int32 status; + uint32 loopcnt; + int32 status; OS_task_prop_t taskprop; /* * Create all allowed objects */ - status = OS_TaskCreate( &task_id, "Task", Test_Void_Fn, NULL, 4096, 50, 0); + status = OS_TaskCreate(&task_id, "Task", Test_Void_Fn, NULL, 4096, 50, 0); UtAssert_True(status == OS_SUCCESS, "OS_TaskCreate() (%ld) == OS_SUCCESS", (long)status); - status = OS_QueueCreate( &queue_id, "Queue", 5, 5, 0); + status = OS_QueueCreate(&queue_id, "Queue", 5, 5, 0); UtAssert_True(status == OS_SUCCESS, "OS_QueueCreate() (%ld) == OS_SUCCESS", (long)status); - status = OS_CountSemCreate( &count_sem_id, "CountSem", 1, 0); + status = OS_CountSemCreate(&count_sem_id, "CountSem", 1, 0); UtAssert_True(status == OS_SUCCESS, "OS_CountSemCreate() (%ld) == OS_SUCCESS", (long)status); - status = OS_BinSemCreate( &bin_sem_id, "BinSem", 1, 0); + status = OS_BinSemCreate(&bin_sem_id, "BinSem", 1, 0); UtAssert_True(status == OS_SUCCESS, "OS_BinSemCreate() (%ld) == OS_SUCCESS", (long)status); - status = OS_MutSemCreate( &mutex_id1, "Mutex1", 0); + status = OS_MutSemCreate(&mutex_id1, "Mutex1", 0); UtAssert_True(status == OS_SUCCESS, "OS_MutSemCreate() (%ld) == OS_SUCCESS", (long)status); - status = OS_MutSemCreate( &mutex_id2, "Mutex2", 0); + status = OS_MutSemCreate(&mutex_id2, "Mutex2", 0); UtAssert_True(status == OS_SUCCESS, "OS_MutSemCreate() (%ld) == OS_SUCCESS", (long)status); - status = OS_MutSemCreate( &mutex_id3, "Mutex3", 0); + status = OS_MutSemCreate(&mutex_id3, "Mutex3", 0); UtAssert_True(status == OS_SUCCESS, "OS_MutSemCreate() (%ld) == OS_SUCCESS", (long)status); - status = OS_TimeBaseCreate( &time_base_id, "TimeBase", 0); + status = OS_TimeBaseCreate(&time_base_id, "TimeBase", 0); UtAssert_True(status == OS_SUCCESS, "OS_TimeBaseCreate() (%ld) == OS_SUCCESS", (long)status); /* Looping delay in parent task to wait for child task to exit */ loopcnt = 0; while ((OS_TaskGetInfo(task_id, &taskprop) == OS_SUCCESS) && (loopcnt < UT_EXIT_LOOP_MAX)) { - OS_TaskDelay(10); - loopcnt++; + OS_TaskDelay(10); + loopcnt++; } UtAssert_True(loopcnt < UT_EXIT_LOOP_MAX, "Task exited after %ld iterations", (long)loopcnt); } @@ -140,12 +139,12 @@ void TestIdMapApi_Setup(void) void TestIdMapApi(void) { - int32 expected; - int32 actual; - uint32 TestArrayIndex; - uint32 TestMutex1Index; - uint32 TestMutex2Index; - osal_id_t badid; + int32 expected; + int32 actual; + uint32 TestArrayIndex; + uint32 TestMutex1Index; + uint32 TestMutex2Index; + osal_id_t badid; Test_OS_ObjTypeCount_t Count; /* @@ -173,32 +172,32 @@ void TestIdMapApi(void) * Test with nominal values */ expected = OS_OBJECT_TYPE_OS_TASK; - actual = OS_IdentifyObject(task_id); - UtAssert_True(actual == expected, "OS_IdentifyObject() (%ld) == %ld", (long)actual, (long)expected); + actual = OS_IdentifyObject(task_id); + UtAssert_True(actual == expected, "OS_IdentifyObject() (%ld) == %ld", (long)actual, (long)expected); expected = OS_OBJECT_TYPE_OS_QUEUE; - actual = OS_IdentifyObject(queue_id); - UtAssert_True(actual == expected, "OS_IdentifyObject() (%ld) == %ld", (long)actual, (long)expected); + actual = OS_IdentifyObject(queue_id); + UtAssert_True(actual == expected, "OS_IdentifyObject() (%ld) == %ld", (long)actual, (long)expected); expected = OS_OBJECT_TYPE_OS_COUNTSEM; - actual = OS_IdentifyObject(count_sem_id); - UtAssert_True(actual == expected, "OS_IdentifyObject() (%ld) == %ld", (long)actual, (long)expected); + actual = OS_IdentifyObject(count_sem_id); + UtAssert_True(actual == expected, "OS_IdentifyObject() (%ld) == %ld", (long)actual, (long)expected); expected = OS_OBJECT_TYPE_OS_BINSEM; - actual = OS_IdentifyObject(bin_sem_id); - UtAssert_True(actual == expected, "OS_IdentifyObject() (%ld) == %ld", (long)actual, (long)expected); + actual = OS_IdentifyObject(bin_sem_id); + UtAssert_True(actual == expected, "OS_IdentifyObject() (%ld) == %ld", (long)actual, (long)expected); expected = OS_OBJECT_TYPE_OS_MUTEX; - actual = OS_IdentifyObject(mutex_id1); - UtAssert_True(actual == expected, "OS_IdentifyObject() (%ld) == %ld", (long)actual, (long)expected); + actual = OS_IdentifyObject(mutex_id1); + UtAssert_True(actual == expected, "OS_IdentifyObject() (%ld) == %ld", (long)actual, (long)expected); expected = OS_OBJECT_TYPE_OS_TIMEBASE; - actual = OS_IdentifyObject(time_base_id); - UtAssert_True(actual == expected, "OS_IdentifyObject() (%ld) == %ld", (long)actual, (long)expected); + actual = OS_IdentifyObject(time_base_id); + UtAssert_True(actual == expected, "OS_IdentifyObject() (%ld) == %ld", (long)actual, (long)expected); /* * Test with extreme cases using min and max values - * Note: There are no asserts, checks or expected values + * Note: There are no asserts, checks or expected values * here. The only check is that the function doesn't return * an error when called */ @@ -214,53 +213,61 @@ void TestIdMapApi(void) /* * Check different id types and verify array indices * Each Object Type index is added to an array index of its own type - * Each object type is checked once, and MUTEX is checked twice to + * Each object type is checked once, and MUTEX is checked twice to * verify multiple indices */ /* * Test with nominal values */ - actual = OS_ConvertToArrayIndex(task_id, &TestArrayIndex); - UtAssert_True(actual == expected , "OS_ConvertToArrayIndex() (%ld) == %ld ", (long)actual, (long)expected ); - UtAssert_True(TestArrayIndex >= 0 && TestArrayIndex < OS_MAX_TASKS , "0 < TestArrayIndex(%lu) <= OS_MAX_TASKS", (long)TestArrayIndex); - - actual = OS_ConvertToArrayIndex(queue_id, &TestArrayIndex); - UtAssert_True(actual == expected , "OS_ConvertToArrayIndex() (%ld) == %ld ", (long)actual, (long)expected ); - UtAssert_True(TestArrayIndex >=0 && TestArrayIndex < OS_MAX_QUEUES , "0 < TestArrayIndex(%lu) <= OS_MAX_QUEUES", (long)TestArrayIndex); - - actual = OS_ConvertToArrayIndex(count_sem_id, &TestArrayIndex); - UtAssert_True(actual == expected , "OS_ConvertToArrayIndex() (%ld) == %ld ", (long)actual, (long)expected ); - UtAssert_True(TestArrayIndex >= 0 && TestArrayIndex < OS_MAX_COUNT_SEMAPHORES , "0 < TestArrayIndex(%lu) <= OS_MAX_COUNT_SEMAPHORES", (long)TestArrayIndex); - - actual = OS_ConvertToArrayIndex(bin_sem_id, &TestArrayIndex); - UtAssert_True(actual == expected , "OS_ConvertToArrayIndex() (%ld) == %ld ", (long)actual, (long)expected ); - UtAssert_True(TestArrayIndex >= 0 && TestArrayIndex < OS_MAX_BIN_SEMAPHORES , "0 < TestArrayIndex(%lu) <= OS_MAX_BIN_SEMAPHORES", (long)TestArrayIndex); - - actual = OS_ConvertToArrayIndex(mutex_id1, &TestMutex1Index); - UtAssert_True(actual == expected , "OS_ConvertToArrayIndex() (%ld) == %ld ", (long)actual, (long)expected ); - UtAssert_True(TestMutex1Index >= 0 && TestMutex1Index < OS_MAX_MUTEXES , "0 < TestMutex1Index(%lu) <= OS_MAX_MUTEXES", (long)TestMutex1Index); - - actual = OS_ConvertToArrayIndex(mutex_id2, &TestMutex2Index); - UtAssert_True(actual == expected , "OS_ConvertToArrayIndex() (%ld) == %ld ", (long)actual, (long)expected ); - UtAssert_True(TestMutex2Index >= 0 && TestMutex2Index < OS_MAX_MUTEXES , "0 < TestMutex2Index(%lu) <= OS_MAX_MUTEXES", (long)TestMutex2Index); - UtAssert_True(TestMutex1Index != TestMutex2Index , "TestMutex1Index(%lu) != TestMutex2Index(%lu)", (long)TestMutex1Index, (long)TestMutex2Index ); - - actual = OS_ConvertToArrayIndex(time_base_id, &TestArrayIndex); - UtAssert_True(actual == expected , "OS_ConvertToArrayIndex() (%ld) == %ld ", (long)actual, (long)expected ); - UtAssert_True(TestArrayIndex >= 0 && TestArrayIndex < OS_MAX_TIMEBASES , "0 < TestArrayIndex(%lu) <= OS_MAX_TIMEBASES", (long)TestArrayIndex); + actual = OS_ConvertToArrayIndex(task_id, &TestArrayIndex); + UtAssert_True(actual == expected, "OS_ConvertToArrayIndex() (%ld) == %ld ", (long)actual, (long)expected); + UtAssert_True(TestArrayIndex >= 0 && TestArrayIndex < OS_MAX_TASKS, "0 < TestArrayIndex(%lu) <= OS_MAX_TASKS", + (long)TestArrayIndex); + + actual = OS_ConvertToArrayIndex(queue_id, &TestArrayIndex); + UtAssert_True(actual == expected, "OS_ConvertToArrayIndex() (%ld) == %ld ", (long)actual, (long)expected); + UtAssert_True(TestArrayIndex >= 0 && TestArrayIndex < OS_MAX_QUEUES, "0 < TestArrayIndex(%lu) <= OS_MAX_QUEUES", + (long)TestArrayIndex); + + actual = OS_ConvertToArrayIndex(count_sem_id, &TestArrayIndex); + UtAssert_True(actual == expected, "OS_ConvertToArrayIndex() (%ld) == %ld ", (long)actual, (long)expected); + UtAssert_True(TestArrayIndex >= 0 && TestArrayIndex < OS_MAX_COUNT_SEMAPHORES, + "0 < TestArrayIndex(%lu) <= OS_MAX_COUNT_SEMAPHORES", (long)TestArrayIndex); + + actual = OS_ConvertToArrayIndex(bin_sem_id, &TestArrayIndex); + UtAssert_True(actual == expected, "OS_ConvertToArrayIndex() (%ld) == %ld ", (long)actual, (long)expected); + UtAssert_True(TestArrayIndex >= 0 && TestArrayIndex < OS_MAX_BIN_SEMAPHORES, + "0 < TestArrayIndex(%lu) <= OS_MAX_BIN_SEMAPHORES", (long)TestArrayIndex); + + actual = OS_ConvertToArrayIndex(mutex_id1, &TestMutex1Index); + UtAssert_True(actual == expected, "OS_ConvertToArrayIndex() (%ld) == %ld ", (long)actual, (long)expected); + UtAssert_True(TestMutex1Index >= 0 && TestMutex1Index < OS_MAX_MUTEXES, + "0 < TestMutex1Index(%lu) <= OS_MAX_MUTEXES", (long)TestMutex1Index); + + actual = OS_ConvertToArrayIndex(mutex_id2, &TestMutex2Index); + UtAssert_True(actual == expected, "OS_ConvertToArrayIndex() (%ld) == %ld ", (long)actual, (long)expected); + UtAssert_True(TestMutex2Index >= 0 && TestMutex2Index < OS_MAX_MUTEXES, + "0 < TestMutex2Index(%lu) <= OS_MAX_MUTEXES", (long)TestMutex2Index); + UtAssert_True(TestMutex1Index != TestMutex2Index, "TestMutex1Index(%lu) != TestMutex2Index(%lu)", + (long)TestMutex1Index, (long)TestMutex2Index); + + actual = OS_ConvertToArrayIndex(time_base_id, &TestArrayIndex); + UtAssert_True(actual == expected, "OS_ConvertToArrayIndex() (%ld) == %ld ", (long)actual, (long)expected); + UtAssert_True(TestArrayIndex >= 0 && TestArrayIndex < OS_MAX_TIMEBASES, + "0 < TestArrayIndex(%lu) <= OS_MAX_TIMEBASES", (long)TestArrayIndex); /* * Test with extreme cases using invalid inputs and checking - * for an error return code + * for an error return code */ actual = OS_ConvertToArrayIndex(OS_OBJECT_ID_UNDEFINED, &TestArrayIndex); expected = OS_ERR_INVALID_ID; - UtAssert_True(actual == expected , "OS_ConvertToArrayIndex() (%ld) == %ld ", (long)actual, (long)expected ); + UtAssert_True(actual == expected, "OS_ConvertToArrayIndex() (%ld) == %ld ", (long)actual, (long)expected); actual = OS_ConvertToArrayIndex(badid, &TestArrayIndex); expected = OS_ERR_INVALID_ID; - UtAssert_True(actual == expected , "OS_ConvertToArrayIndex() (%ld) == %ld ", (long)actual, (long)expected ); + UtAssert_True(actual == expected, "OS_ConvertToArrayIndex() (%ld) == %ld ", (long)actual, (long)expected); /* * Test Case For: @@ -268,59 +275,71 @@ void TestIdMapApi(void) */ memset(&Count, 0, sizeof(Count)); - OS_ForEachObject (OS_OBJECT_CREATOR_ANY, &ObjTypeCounter, &Count); + OS_ForEachObject(OS_OBJECT_CREATOR_ANY, &ObjTypeCounter, &Count); /* Verify Outputs */ UtAssert_True(Count.TaskCount == 0, "OS_ForEachObject() TaskCount (%lu) == 0", (unsigned long)Count.TaskCount); UtAssert_True(Count.QueueCount == 1, "OS_ForEachObject() QueueCount (%lu) == 1", (unsigned long)Count.QueueCount); - UtAssert_True(Count.CountSemCount == 1, "OS_ForEachObject() CountSemCount (%lu) == 1", (unsigned long)Count.CountSemCount); - UtAssert_True(Count.BinSemCount == 2, "OS_ForEachObject() BinSemCount (%lu) == 2", (unsigned long)Count.BinSemCount); + UtAssert_True(Count.CountSemCount == 1, "OS_ForEachObject() CountSemCount (%lu) == 1", + (unsigned long)Count.CountSemCount); + UtAssert_True(Count.BinSemCount == 2, "OS_ForEachObject() BinSemCount (%lu) == 2", + (unsigned long)Count.BinSemCount); UtAssert_True(Count.MutexCount == 3, "OS_ForEachObject() MutexCount (%lu) == 3", (unsigned long)Count.MutexCount); - UtAssert_True(Count.TimeBaseCount == 1, "OS_ForEachObject() TimeBaseCount (%lu) == 1", (unsigned long)Count.TimeBaseCount); + UtAssert_True(Count.TimeBaseCount == 1, "OS_ForEachObject() TimeBaseCount (%lu) == 1", + (unsigned long)Count.TimeBaseCount); /* * Use current task as an input */ memset(&Count, 0, sizeof(Count)); - OS_ForEachObject (task_id, &ObjTypeCounter, &Count); + OS_ForEachObject(task_id, &ObjTypeCounter, &Count); /* Verify Output */ - UtAssert_True(Count.BinSemCount == 1, "OS_ForEachObject() BinSemCount MyTask (%lu) == 1", (unsigned long)Count.BinSemCount); + UtAssert_True(Count.BinSemCount == 1, "OS_ForEachObject() BinSemCount MyTask (%lu) == 1", + (unsigned long)Count.BinSemCount); /* * Delete all created objects, and verify that the count is now zero */ memset(&Count, 0, sizeof(Count)); OS_DeleteAllObjects(); - OS_ForEachObject (OS_OBJECT_CREATOR_ANY, &ObjTypeCounter, &Count); + OS_ForEachObject(OS_OBJECT_CREATOR_ANY, &ObjTypeCounter, &Count); /* Verify Outputs */ - UtAssert_True(Count.TaskCount == 0, "OS_ForEachObject() TaskCount After Delete (%lu) == 0", (unsigned long)Count.TaskCount); - UtAssert_True(Count.QueueCount == 0, "OS_ForEachObject() QueueCount After Delete (%lu) == 0", (unsigned long)Count.QueueCount); - UtAssert_True(Count.CountSemCount == 0, "OS_ForEachObject() CountSemCount After Delete (%lu) == 0", (unsigned long)Count.CountSemCount); - UtAssert_True(Count.BinSemCount == 0, "OS_ForEachObject() BinSemCount After Delete (%lu) == 0", (unsigned long)Count.BinSemCount); - UtAssert_True(Count.MutexCount == 0, "OS_ForEachObject() MutexCount After Delete (%lu) == 0", (unsigned long)Count.MutexCount); - UtAssert_True(Count.TimeBaseCount == 0, "OS_ForEachObject() TimeBaseCount After Delete (%lu) == 0", (unsigned long)Count.TimeBaseCount); + UtAssert_True(Count.TaskCount == 0, "OS_ForEachObject() TaskCount After Delete (%lu) == 0", + (unsigned long)Count.TaskCount); + UtAssert_True(Count.QueueCount == 0, "OS_ForEachObject() QueueCount After Delete (%lu) == 0", + (unsigned long)Count.QueueCount); + UtAssert_True(Count.CountSemCount == 0, "OS_ForEachObject() CountSemCount After Delete (%lu) == 0", + (unsigned long)Count.CountSemCount); + UtAssert_True(Count.BinSemCount == 0, "OS_ForEachObject() BinSemCount After Delete (%lu) == 0", + (unsigned long)Count.BinSemCount); + UtAssert_True(Count.MutexCount == 0, "OS_ForEachObject() MutexCount After Delete (%lu) == 0", + (unsigned long)Count.MutexCount); + UtAssert_True(Count.TimeBaseCount == 0, "OS_ForEachObject() TimeBaseCount After Delete (%lu) == 0", + (unsigned long)Count.TimeBaseCount); /* * Pass an invalid input, and verify that object counts are not increased */ - OS_ForEachObject (badid, &ObjTypeCounter, &Count); + OS_ForEachObject(badid, &ObjTypeCounter, &Count); /* Verify Outputs */ - UtAssert_True(Count.TaskCount == 0, "OS_ForEachObject() TaskCount Invalid Input (%lu) == 0", (unsigned long)Count.TaskCount); - UtAssert_True(Count.QueueCount == 0, "OS_ForEachObject() QueueCount Invalid Input (%lu) == 0", (unsigned long)Count.QueueCount); - UtAssert_True(Count.CountSemCount == 0, "OS_ForEachObject() CountSemCount Invalid Input (%lu) == 0", (unsigned long)Count.CountSemCount); - UtAssert_True(Count.BinSemCount == 0, "OS_ForEachObject() BinSemCount Invalid Input (%lu) == 0", (unsigned long)Count.BinSemCount); - UtAssert_True(Count.MutexCount == 0, "OS_ForEachObject() MutexCount Invalid Input (%lu) == 0", (unsigned long)Count.MutexCount); - UtAssert_True(Count.TimeBaseCount == 0, "OS_ForEachObject() TimeBaseCount Invalid Input (%lu) == 0", (unsigned long)Count.TimeBaseCount); - - - + UtAssert_True(Count.TaskCount == 0, "OS_ForEachObject() TaskCount Invalid Input (%lu) == 0", + (unsigned long)Count.TaskCount); + UtAssert_True(Count.QueueCount == 0, "OS_ForEachObject() QueueCount Invalid Input (%lu) == 0", + (unsigned long)Count.QueueCount); + UtAssert_True(Count.CountSemCount == 0, "OS_ForEachObject() CountSemCount Invalid Input (%lu) == 0", + (unsigned long)Count.CountSemCount); + UtAssert_True(Count.BinSemCount == 0, "OS_ForEachObject() BinSemCount Invalid Input (%lu) == 0", + (unsigned long)Count.BinSemCount); + UtAssert_True(Count.MutexCount == 0, "OS_ForEachObject() MutexCount Invalid Input (%lu) == 0", + (unsigned long)Count.MutexCount); + UtAssert_True(Count.TimeBaseCount == 0, "OS_ForEachObject() TimeBaseCount Invalid Input (%lu) == 0", + (unsigned long)Count.TimeBaseCount); } /* end TestIdMapApi */ - void UtTest_Setup(void) { if (OS_API_Init() != OS_SUCCESS) @@ -333,4 +352,3 @@ void UtTest_Setup(void) */ UtTest_Add(TestIdMapApi, TestIdMapApi_Setup, NULL, "TestIdMapApi"); } - diff --git a/src/tests/mutex-test/mutex-test.c b/src/tests/mutex-test/mutex-test.c index e13e563bb..67baef8e7 100644 --- a/src/tests/mutex-test/mutex-test.c +++ b/src/tests/mutex-test/mutex-test.c @@ -32,186 +32,185 @@ void MutexSetup(void); void MutexCheck(void); -#define TASK_STACK_SIZE 4096 -#define TASK_1_PRIORITY 100 -#define TASK_2_PRIORITY 110 -#define TASK_3_PRIORITY 120 +#define TASK_STACK_SIZE 4096 +#define TASK_1_PRIORITY 100 +#define TASK_2_PRIORITY 110 +#define TASK_3_PRIORITY 120 -uint32 task_1_stack[TASK_STACK_SIZE]; +uint32 task_1_stack[TASK_STACK_SIZE]; osal_id_t task_1_id; -uint32 task_1_failures; +uint32 task_1_failures; -uint32 task_2_stack[TASK_STACK_SIZE]; +uint32 task_2_stack[TASK_STACK_SIZE]; osal_id_t task_2_id; -uint32 task_2_failures; +uint32 task_2_failures; -uint32 task_3_stack[TASK_STACK_SIZE]; +uint32 task_3_stack[TASK_STACK_SIZE]; osal_id_t task_3_id; -uint32 task_3_failures; +uint32 task_3_failures; osal_id_t mut_sem_id; uint32 shared_obj_owner; -int counter = 0; +int counter = 0; void task_1(void) { - uint32 status; + uint32 status; OS_printf("Starting task 1\n"); OS_TaskRegister(); while (1) { - status = OS_TaskDelay(100); - status = OS_MutSemTake(mut_sem_id); - if ( status != OS_SUCCESS ) - { - ++task_1_failures; - OS_printf("TASK 1:Error calling OS_MutSemTake\n"); - } - else - { - OS_printf("TASK 1 Has the Mutex\n"); - } - - OS_printf("TASK 1 Doing some work: %d\n", (int)counter++); - if (shared_obj_owner != 0) - { - ++task_1_failures; - } - - /* Hold the resource for a while and check if any interference occurs */ - shared_obj_owner = 1; - for(status = 0; status < 100000; ++status) - { - if (shared_obj_owner != 1) - { - ++task_1_failures; - shared_obj_owner = 1; - } - } - shared_obj_owner = 0; - - status = OS_MutSemGive(mut_sem_id); - if ( status != OS_SUCCESS ) - { - ++task_1_failures; - OS_printf("TASK 1:Error calling OS_MutSemGive\n"); - } - else - { - OS_printf("TASK 1 Released the Mutex\n"); - } - } + status = OS_TaskDelay(100); + status = OS_MutSemTake(mut_sem_id); + if (status != OS_SUCCESS) + { + ++task_1_failures; + OS_printf("TASK 1:Error calling OS_MutSemTake\n"); + } + else + { + OS_printf("TASK 1 Has the Mutex\n"); + } + + OS_printf("TASK 1 Doing some work: %d\n", (int)counter++); + if (shared_obj_owner != 0) + { + ++task_1_failures; + } + + /* Hold the resource for a while and check if any interference occurs */ + shared_obj_owner = 1; + for (status = 0; status < 100000; ++status) + { + if (shared_obj_owner != 1) + { + ++task_1_failures; + shared_obj_owner = 1; + } + } + shared_obj_owner = 0; + + status = OS_MutSemGive(mut_sem_id); + if (status != OS_SUCCESS) + { + ++task_1_failures; + OS_printf("TASK 1:Error calling OS_MutSemGive\n"); + } + else + { + OS_printf("TASK 1 Released the Mutex\n"); + } + } } void task_2(void) { - uint32 status; + uint32 status; OS_printf("Starting task 2\n"); OS_TaskRegister(); while (1) { - status = OS_TaskDelay(200); - - status = OS_MutSemTake(mut_sem_id); - if ( status != OS_SUCCESS ) - { - ++task_2_failures; - OS_printf("TASK 2:Error calling OS_MutSemTake\n"); - } - else - { - OS_printf("TASK 2 Has the Mutex\n"); - } - - OS_printf("TASK 2: Doing some work: %d\n", (int)counter++); - if (shared_obj_owner != 0) - { - ++task_2_failures; - } - - - /* Hold the resource for a while and check if any interference occurs */ - shared_obj_owner = 2; - for(status = 0; status < 100000; ++status) - { - if (shared_obj_owner != 2) - { - ++task_2_failures; - shared_obj_owner = 2; - } - } - shared_obj_owner = 0; - - status = OS_MutSemGive(mut_sem_id); - if ( status != OS_SUCCESS ) - { - ++task_2_failures; - OS_printf("TASK 2:Error calling OS_MutSemGive\n"); - } - else - { - OS_printf("TASK 2 Released the Mutex\n"); - } + status = OS_TaskDelay(200); + + status = OS_MutSemTake(mut_sem_id); + if (status != OS_SUCCESS) + { + ++task_2_failures; + OS_printf("TASK 2:Error calling OS_MutSemTake\n"); + } + else + { + OS_printf("TASK 2 Has the Mutex\n"); + } + + OS_printf("TASK 2: Doing some work: %d\n", (int)counter++); + if (shared_obj_owner != 0) + { + ++task_2_failures; + } + + /* Hold the resource for a while and check if any interference occurs */ + shared_obj_owner = 2; + for (status = 0; status < 100000; ++status) + { + if (shared_obj_owner != 2) + { + ++task_2_failures; + shared_obj_owner = 2; + } + } + shared_obj_owner = 0; + + status = OS_MutSemGive(mut_sem_id); + if (status != OS_SUCCESS) + { + ++task_2_failures; + OS_printf("TASK 2:Error calling OS_MutSemGive\n"); + } + else + { + OS_printf("TASK 2 Released the Mutex\n"); + } } } void task_3(void) { - uint32 status; + uint32 status; OS_printf("Starting task 3\n"); OS_TaskRegister(); while (1) { - - status = OS_TaskDelay(300); - status = OS_MutSemTake(mut_sem_id); - if ( status != OS_SUCCESS ) - { - ++task_3_failures; - OS_printf("TASK 3:Error calling OS_MutSemTake\n"); - } - else - { - OS_printf("TASK 3 Has the Mutex\n"); - } - - OS_printf("TASK 3: Doing some work: %d\n", (int)counter++); - if (shared_obj_owner != 0) - { - ++task_3_failures; - } - - /* Hold the resource for a while and check if any interference occurs */ - shared_obj_owner = 3; - for(status = 0; status < 100000; ++status) - { - if (shared_obj_owner != 3) - { - ++task_3_failures; - shared_obj_owner = 3; - } - } - shared_obj_owner = 0; - - status = OS_MutSemGive(mut_sem_id); - if ( status != OS_SUCCESS ) - { - ++task_3_failures; - OS_printf("TASK 3:Error calling OS_MutSemGive\n"); - } - else - { - OS_printf("TASK 3 Released the Mutex\n"); - } - } + + status = OS_TaskDelay(300); + status = OS_MutSemTake(mut_sem_id); + if (status != OS_SUCCESS) + { + ++task_3_failures; + OS_printf("TASK 3:Error calling OS_MutSemTake\n"); + } + else + { + OS_printf("TASK 3 Has the Mutex\n"); + } + + OS_printf("TASK 3: Doing some work: %d\n", (int)counter++); + if (shared_obj_owner != 0) + { + ++task_3_failures; + } + + /* Hold the resource for a while and check if any interference occurs */ + shared_obj_owner = 3; + for (status = 0; status < 100000; ++status) + { + if (shared_obj_owner != 3) + { + ++task_3_failures; + shared_obj_owner = 3; + } + } + shared_obj_owner = 0; + + status = OS_MutSemGive(mut_sem_id); + if (status != OS_SUCCESS) + { + ++task_3_failures; + OS_printf("TASK 3:Error calling OS_MutSemGive\n"); + } + else + { + OS_printf("TASK 3 Released the Mutex\n"); + } + } } void UtTest_Setup(void) @@ -229,74 +228,69 @@ void UtTest_Setup(void) void MutexSetup(void) { - uint32 status; - - task_1_failures = 0; - task_2_failures = 0; - task_3_failures = 0; - shared_obj_owner = 0; - - /* - ** Create the mutex - */ - status = OS_MutSemCreate( &mut_sem_id, "MutSem1", 0); - UtAssert_True(status == OS_SUCCESS, "MutSem1 create Id=%lx Rc=%d", - OS_ObjectIdToInteger(mut_sem_id), (int)status); - - /* - ** Test the mutex to see if it supports nesting - */ - status = OS_MutSemTake(mut_sem_id); - UtAssert_True(status == OS_SUCCESS, "OS_MutSemTake 1 Rc=%d", (int)status); - - status = OS_MutSemTake(mut_sem_id); - UtAssert_True(status == OS_SUCCESS, "OS_MutSemTake 2 Rc=%d", (int)status); - - status = OS_MutSemGive(mut_sem_id); - UtAssert_True(status == OS_SUCCESS, "OS_MutSemGive 2 Rc=%d", (int)status); - - status = OS_MutSemGive(mut_sem_id); - UtAssert_True(status == OS_SUCCESS, "OS_MutSemGive 1 Rc=%d", (int)status); - - /* - ** Create the tasks - */ - status = OS_TaskCreate( &task_1_id, "Task 1", task_1, task_1_stack, TASK_STACK_SIZE, TASK_1_PRIORITY, 0); - UtAssert_True(status == OS_SUCCESS, "Task 1 create Id=%lx Rc=%d", - OS_ObjectIdToInteger(task_1_id), (int)status); - - status = OS_TaskCreate( &task_2_id, "Task 2", task_2, task_2_stack, TASK_STACK_SIZE, TASK_2_PRIORITY, 0); - UtAssert_True(status == OS_SUCCESS, "Task 2 create Id=%lx Rc=%d", - OS_ObjectIdToInteger(task_2_id), (int)status); - - status = OS_TaskCreate( &task_3_id, "Task 3", task_3, task_3_stack, TASK_STACK_SIZE, TASK_3_PRIORITY, 0); - UtAssert_True(status == OS_SUCCESS, "Task 3 create Id=%lx Rc=%d", - OS_ObjectIdToInteger(task_3_id), (int)status); - - /* - * Time limited execution + uint32 status; + + task_1_failures = 0; + task_2_failures = 0; + task_3_failures = 0; + shared_obj_owner = 0; + + /* + ** Create the mutex */ - while (counter < 100) - { - OS_TaskDelay(100); - } + status = OS_MutSemCreate(&mut_sem_id, "MutSem1", 0); + UtAssert_True(status == OS_SUCCESS, "MutSem1 create Id=%lx Rc=%d", OS_ObjectIdToInteger(mut_sem_id), (int)status); + + /* + ** Test the mutex to see if it supports nesting + */ + status = OS_MutSemTake(mut_sem_id); + UtAssert_True(status == OS_SUCCESS, "OS_MutSemTake 1 Rc=%d", (int)status); + + status = OS_MutSemTake(mut_sem_id); + UtAssert_True(status == OS_SUCCESS, "OS_MutSemTake 2 Rc=%d", (int)status); + + status = OS_MutSemGive(mut_sem_id); + UtAssert_True(status == OS_SUCCESS, "OS_MutSemGive 2 Rc=%d", (int)status); + + status = OS_MutSemGive(mut_sem_id); + UtAssert_True(status == OS_SUCCESS, "OS_MutSemGive 1 Rc=%d", (int)status); - /* - * Delete the tasks + /* + ** Create the tasks */ - status = OS_TaskDelete(task_1_id); - UtAssert_True(status == OS_SUCCESS, "Task 1 delete Rc=%d", (int)status); - status = OS_TaskDelete(task_2_id); - UtAssert_True(status == OS_SUCCESS, "Task 2 delete Rc=%d", (int)status); - status = OS_TaskDelete(task_3_id); - UtAssert_True(status == OS_SUCCESS, "Task 3 delete Rc=%d", (int)status); + status = OS_TaskCreate(&task_1_id, "Task 1", task_1, task_1_stack, TASK_STACK_SIZE, TASK_1_PRIORITY, 0); + UtAssert_True(status == OS_SUCCESS, "Task 1 create Id=%lx Rc=%d", OS_ObjectIdToInteger(task_1_id), (int)status); + + status = OS_TaskCreate(&task_2_id, "Task 2", task_2, task_2_stack, TASK_STACK_SIZE, TASK_2_PRIORITY, 0); + UtAssert_True(status == OS_SUCCESS, "Task 2 create Id=%lx Rc=%d", OS_ObjectIdToInteger(task_2_id), (int)status); + + status = OS_TaskCreate(&task_3_id, "Task 3", task_3, task_3_stack, TASK_STACK_SIZE, TASK_3_PRIORITY, 0); + UtAssert_True(status == OS_SUCCESS, "Task 3 create Id=%lx Rc=%d", OS_ObjectIdToInteger(task_3_id), (int)status); + + /* + * Time limited execution + */ + while (counter < 100) + { + OS_TaskDelay(100); + } + + /* + * Delete the tasks + */ + status = OS_TaskDelete(task_1_id); + UtAssert_True(status == OS_SUCCESS, "Task 1 delete Rc=%d", (int)status); + status = OS_TaskDelete(task_2_id); + UtAssert_True(status == OS_SUCCESS, "Task 2 delete Rc=%d", (int)status); + status = OS_TaskDelete(task_3_id); + UtAssert_True(status == OS_SUCCESS, "Task 3 delete Rc=%d", (int)status); } void MutexCheck(void) { /* None of the tasks should have any failures in their own counters */ - UtAssert_True(task_1_failures == 0, "Task 1 failures = %u",(unsigned int)task_1_failures); - UtAssert_True(task_2_failures == 0, "Task 2 failures = %u",(unsigned int)task_2_failures); - UtAssert_True(task_3_failures == 0, "Task 3 failures = %u",(unsigned int)task_3_failures); + UtAssert_True(task_1_failures == 0, "Task 1 failures = %u", (unsigned int)task_1_failures); + UtAssert_True(task_2_failures == 0, "Task 2 failures = %u", (unsigned int)task_2_failures); + UtAssert_True(task_3_failures == 0, "Task 3 failures = %u", (unsigned int)task_3_failures); } - diff --git a/src/tests/network-api-test/network-api-test.c b/src/tests/network-api-test/network-api-test.c index 5ab0c7041..5dfee1f34 100644 --- a/src/tests/network-api-test/network-api-test.c +++ b/src/tests/network-api-test/network-api-test.c @@ -18,7 +18,6 @@ * limitations under the License. */ - /* * Filename: network-api-test.c */ @@ -33,13 +32,13 @@ #include "uttest.h" #include "utbsp.h" -#define UT_EXIT_LOOP_MAX 100 +#define UT_EXIT_LOOP_MAX 100 -osal_id_t s_task_id; -osal_id_t p1_socket_id; -osal_id_t p2_socket_id; -osal_id_t s_socket_id; -osal_id_t c_socket_id; +osal_id_t s_task_id; +osal_id_t p1_socket_id; +osal_id_t p2_socket_id; +osal_id_t s_socket_id; +osal_id_t c_socket_id; OS_SockAddr_t p1_addr; OS_SockAddr_t p2_addr; OS_SockAddr_t s_addr; @@ -53,14 +52,14 @@ OS_SockAddr_t c_addr; void TestDatagramNetworkApi_Setup(void) { - int32 expected; - int32 actual; - osal_id_t socket_id; + int32 expected; + int32 actual; + osal_id_t socket_id; OS_SockAddr_t addr; OS_SockAddr_t inv_addr; /* Open a peer1 socket */ - expected = OS_SUCCESS; + expected = OS_SUCCESS; p1_socket_id = OS_OBJECT_ID_UNDEFINED; actual = OS_SocketOpen(&p1_socket_id, OS_SocketDomain_INET, OS_SocketType_DATAGRAM); @@ -83,9 +82,8 @@ void TestDatagramNetworkApi_Setup(void) actual = OS_SocketBind(p1_socket_id, &p1_addr); UtAssert_True(actual == expected, "OS_SocketBind() (%ld) == OS_SUCCESS", (long)actual); - /* Open a peer2 socket */ - expected = OS_SUCCESS; + expected = OS_SUCCESS; p2_socket_id = OS_OBJECT_ID_UNDEFINED; actual = OS_SocketOpen(&p2_socket_id, OS_SocketDomain_INET, OS_SocketType_DATAGRAM); @@ -109,7 +107,7 @@ void TestDatagramNetworkApi_Setup(void) UtAssert_True(actual == expected, "OS_SocketBind() (%ld) == OS_SUCCESS", (long)actual); /* - * Test for invalid and other nominal input parameters + * Test for invalid and other nominal input parameters * to the network functions being called above */ @@ -119,50 +117,52 @@ void TestDatagramNetworkApi_Setup(void) OS_close(socket_id); expected = OS_INVALID_POINTER; - actual = OS_SocketOpen(NULL, OS_SocketDomain_INVALID, OS_SocketType_INVALID); + actual = OS_SocketOpen(NULL, OS_SocketDomain_INVALID, OS_SocketType_INVALID); UtAssert_True(actual == expected, "OS_SocketOpen() (%ld) == OS_INVALID_POINTER", (long)actual); expected = OS_ERR_NOT_IMPLEMENTED; - actual = OS_SocketOpen(&socket_id, OS_SocketDomain_MAX, OS_SocketType_MAX); + actual = OS_SocketOpen(&socket_id, OS_SocketDomain_MAX, OS_SocketType_MAX); UtAssert_True(actual == expected, "OS_SocketOpen() (%ld) == OS_ERR_NOT_IMPLEMENTED", (long)actual); /* OS_SocketAddrInit */ actual = OS_SocketAddrInit(&addr, OS_SocketDomain_INET6); - UtAssert_True(actual == OS_SUCCESS || OS_ERR_NOT_IMPLEMENTED, "OS_SocketAddrInit() (%ld) == OS_SUCCESS", (long)actual); + UtAssert_True(actual == OS_SUCCESS || OS_ERR_NOT_IMPLEMENTED, "OS_SocketAddrInit() (%ld) == OS_SUCCESS", + (long)actual); actual = OS_SocketAddrInit(NULL, OS_SocketDomain_INET6); - UtAssert_True(actual == OS_INVALID_POINTER || OS_ERR_NOT_IMPLEMENTED, "OS_SocketAddrInit() (%ld) == OS_INVALID_POINTER", (long)actual); + UtAssert_True(actual == OS_INVALID_POINTER || OS_ERR_NOT_IMPLEMENTED, + "OS_SocketAddrInit() (%ld) == OS_INVALID_POINTER", (long)actual); expected = OS_ERR_NOT_IMPLEMENTED; - actual = OS_SocketAddrInit(&addr, OS_SocketDomain_INVALID); + actual = OS_SocketAddrInit(&addr, OS_SocketDomain_INVALID); UtAssert_True(actual == expected, "OS_SocketAddrInit() (%ld) == OS_ERR_NOT_IMPLEMENTED", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_SocketAddrInit(NULL, OS_SocketDomain_INVALID); + actual = OS_SocketAddrInit(NULL, OS_SocketDomain_INVALID); UtAssert_True(actual == expected, "OS_SocketAddrInit() (%ld) == OS_INVALID_POINTER", (long)actual); /* OS_SocketAddrSetPort */ expected = OS_ERR_BAD_ADDRESS; - actual = OS_SocketAddrSetPort(&addr, 0xFFFF); + actual = OS_SocketAddrSetPort(&addr, 0xFFFF); UtAssert_True(actual == expected, "OS_SocketAddrSetPort() (%ld) == OS_ERR_BAD_ADDRESS", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_SocketAddrSetPort(NULL, 1234); + actual = OS_SocketAddrSetPort(NULL, 1234); UtAssert_True(actual == expected, "OS_SocketAddrSetPort() (%ld) == OS_INVALID_POINTER", (long)actual); /* OS_SocketAddrFromString */ expected = OS_INVALID_POINTER; - actual = OS_SocketAddrFromString(NULL, "127.0.0.1"); + actual = OS_SocketAddrFromString(NULL, "127.0.0.1"); UtAssert_True(actual == expected, "OS_SocketAddrFromString() (%ld) == OS_SUCCESS", (long)actual); /* OS_SocketBind */ - expected = OS_ERR_INVALID_ID; + expected = OS_ERR_INVALID_ID; socket_id = OS_ObjectIdFromInteger(1); - actual = OS_SocketBind(socket_id, &addr); + actual = OS_SocketBind(socket_id, &addr); UtAssert_True(actual == expected, "OS_SocketBind() (%ld) == OS_ERR_INVALID_ID", (long)actual); expected = OS_ERR_INCORRECT_OBJ_STATE; - memset(&inv_addr,0,sizeof(inv_addr)); + memset(&inv_addr, 0, sizeof(inv_addr)); actual = OS_SocketBind(p2_socket_id, &inv_addr); UtAssert_True(actual == expected, "OS_SocketBind() (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); @@ -175,20 +175,20 @@ void TestDatagramNetworkApi_Setup(void) *****************************************************************************/ void TestDatagramNetworkApi(void) { - char AddrBuffer1[32]; - char AddrBuffer2[32]; - char AddrBuffer3[32]; - char AddrBuffer4[32]; - uint32 Buf1 = 111; - uint32 Buf2 = 000; - uint32 Buf3 = 222; - uint32 Buf4 = 000; - osal_id_t objid; - uint16 PortNum; + char AddrBuffer1[32]; + char AddrBuffer2[32]; + char AddrBuffer3[32]; + char AddrBuffer4[32]; + uint32 Buf1 = 111; + uint32 Buf2 = 000; + uint32 Buf3 = 222; + uint32 Buf4 = 000; + osal_id_t objid; + uint16 PortNum; OS_socket_prop_t prop; - OS_SockAddr_t l_addr; - int32 expected; - int32 actual; + OS_SockAddr_t l_addr; + int32 expected; + int32 actual; /* * Send data from peer1 to peer2 and verify @@ -196,17 +196,17 @@ void TestDatagramNetworkApi(void) /* Send data from peer1 to peer2 */ expected = sizeof(Buf1); - actual = OS_SocketSendTo(p1_socket_id, &Buf1, sizeof(Buf1), &p2_addr); + actual = OS_SocketSendTo(p1_socket_id, &Buf1, sizeof(Buf1), &p2_addr); UtAssert_True(actual == expected, "OS_SocketSendTo() Passed. sizeof(Buf1) (%ld) == 1", (long)actual); /* Recieve data from peer1 to peer2 */ expected = sizeof(Buf2); - actual = OS_SocketRecvFrom(p2_socket_id, &Buf2, sizeof(Buf2), &l_addr, 100); + actual = OS_SocketRecvFrom(p2_socket_id, &Buf2, sizeof(Buf2), &l_addr, 100); UtAssert_True(actual == expected, "OS_SocketRecvFrom() Passed. sizeof(Buf2) (%ld) == 1", (long)actual); UtAssert_True(Buf1 == Buf2, "Buf1 (%ld) == Buf2 (%ld)", (long)Buf1, (long)Buf2); /* Convert addresses to string and verify data is being sent from the correct address */ - expected = OS_SUCCESS; + expected = OS_SUCCESS; actual = OS_SocketAddrToString(AddrBuffer1, sizeof(AddrBuffer1), &p1_addr); UtAssert_True(actual == expected, "OS_SocketAddrToString() (%ld) == OS_SUCCESS", (long)actual); @@ -214,7 +214,8 @@ void TestDatagramNetworkApi(void) actual = OS_SocketAddrToString(AddrBuffer2, sizeof(AddrBuffer2), &l_addr); UtAssert_True(actual == expected, "OS_SocketAddrToString() (%ld) == OS_SUCCESS", (long)actual); - UtAssert_True(strcmp(AddrBuffer1, AddrBuffer2) == 0, "AddrBuffer1 (%s) == AddrBuffer2 (%s)", AddrBuffer1, AddrBuffer2); + UtAssert_True(strcmp(AddrBuffer1, AddrBuffer2) == 0, "AddrBuffer1 (%s) == AddrBuffer2 (%s)", AddrBuffer1, + AddrBuffer2); /* * Send data from peer2 to peer1 and verify @@ -222,17 +223,17 @@ void TestDatagramNetworkApi(void) /* Send data from peer2 to peer1 */ expected = sizeof(Buf3); - actual = OS_SocketSendTo(p2_socket_id, &Buf3, sizeof(Buf3), &p1_addr); + actual = OS_SocketSendTo(p2_socket_id, &Buf3, sizeof(Buf3), &p1_addr); UtAssert_True(actual == expected, "OS_SocketSendTo() Passed. sizeof(Buf1) (%ld) == 1", (long)actual); /* Recieve data from peer2 to peer1 */ expected = sizeof(Buf4); - actual = OS_SocketRecvFrom(p1_socket_id, &Buf4, sizeof(Buf4), &l_addr, 100); + actual = OS_SocketRecvFrom(p1_socket_id, &Buf4, sizeof(Buf4), &l_addr, 100); UtAssert_True(actual == expected, "OS_SocketRecvFrom() Passed. sizeof(Buf3) (%ld) == 1", (long)actual); UtAssert_True(Buf3 == Buf4, "Buf3 (%ld) == Buf4 (%ld)", (long)Buf3, (long)Buf4); /* Convert addresses to string and verify data is being sent from the correct address */ - expected = OS_SUCCESS; + expected = OS_SUCCESS; actual = OS_SocketAddrToString(AddrBuffer3, sizeof(AddrBuffer3), &p2_addr); UtAssert_True(actual == expected, "OS_SocketAddrToString() (%ld) == OS_SUCCESS", (long)actual); @@ -240,7 +241,8 @@ void TestDatagramNetworkApi(void) actual = OS_SocketAddrToString(AddrBuffer4, sizeof(AddrBuffer4), &l_addr); UtAssert_True(actual == expected, "OS_SocketAddrToString() (%ld) == OS_SUCCESS", (long)actual); - UtAssert_True(strcmp(AddrBuffer3, AddrBuffer4) == 0, "AddrBuffer3 (%s) == AddrBuffer4 (%s)", AddrBuffer3, AddrBuffer4); + UtAssert_True(strcmp(AddrBuffer3, AddrBuffer4) == 0, "AddrBuffer3 (%s) == AddrBuffer4 (%s)", AddrBuffer3, + AddrBuffer4); /* Get port from incoming address and verify */ actual = OS_SocketAddrGetPort(&PortNum, &p2_addr); @@ -250,97 +252,97 @@ void TestDatagramNetworkApi(void) /* Get socket info and verify */ actual = OS_SocketGetInfo(p1_socket_id, &prop); UtAssert_True(actual == expected, "OS_SocketGetInfo() (%ld) == OS_SUCCESS", (long)actual); - UtAssert_True(!OS_ObjectIdDefined(prop.creator), "prop.creator (%lu) == 0",OS_ObjectIdToInteger(prop.creator)); + UtAssert_True(!OS_ObjectIdDefined(prop.creator), "prop.creator (%lu) == 0", OS_ObjectIdToInteger(prop.creator)); UtAssert_True(strcmp(prop.name, "127.0.0.1:9999") == 0, "prop.name (%s) == 127.0.0.1:9999", prop.name); - actual = OS_SocketGetIdByName(&objid,"127.0.0.1:9999"); + actual = OS_SocketGetIdByName(&objid, "127.0.0.1:9999"); UtAssert_True(actual == expected, "OS_SocketGetIdByName() (%ld) == OS_SUCCESS", (long)actual); UtAssert_True(OS_ObjectIdEqual(objid, p1_socket_id), "objid (%lu) == p1_socket_id", OS_ObjectIdToInteger(objid)); /* - * Test for invalid input parameters + * Test for invalid input parameters * to the network functions being called above */ /* OS_SocketSendTo */ expected = OS_INVALID_POINTER; - actual = OS_SocketSendTo(p1_socket_id, NULL, 0, NULL); + actual = OS_SocketSendTo(p1_socket_id, NULL, 0, NULL); UtAssert_True(actual == expected, "OS_SocketSendTo(NULL) (%ld) == OS_INVALID_POINTER", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_SocketSendTo(p1_socket_id, NULL, 1, &p2_addr); + actual = OS_SocketSendTo(p1_socket_id, NULL, 1, &p2_addr); UtAssert_True(actual == expected, "OS_SocketSendTo() (%ld) == OS_INVALID_POINTER", (long)actual); expected = OS_ERR_INVALID_ID; - objid = OS_ObjectIdFromInteger(0xFFFFFFFF); - actual = OS_SocketSendTo(objid, &Buf1, 1, &p2_addr); + objid = OS_ObjectIdFromInteger(0xFFFFFFFF); + actual = OS_SocketSendTo(objid, &Buf1, 1, &p2_addr); UtAssert_True(actual == expected, "OS_SocketSendTo() (%ld) == OS_ERR_INVALID_ID", (long)actual); /* OS_SocketRecvFrom */ expected = OS_INVALID_POINTER; - actual = OS_SocketRecvFrom(p2_socket_id, NULL, 1, NULL, 100); + actual = OS_SocketRecvFrom(p2_socket_id, NULL, 1, NULL, 100); UtAssert_True(actual == expected, "OS_SocketRecvFrom() (%ld) == OS_INVALID_POINTER", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_SocketRecvFrom(p2_socket_id, NULL, 0, NULL, 0); + actual = OS_SocketRecvFrom(p2_socket_id, NULL, 0, NULL, 0); UtAssert_True(actual == expected, "OS_SocketRecvFrom(NULL) (%ld) == OS_INVALID_POINTER", (long)actual); expected = OS_ERR_INVALID_ID; - objid = OS_ObjectIdFromInteger(0xFFFFFFFF); - actual = OS_SocketRecvFrom(objid, &Buf2, 1, &l_addr, 100); + objid = OS_ObjectIdFromInteger(0xFFFFFFFF); + actual = OS_SocketRecvFrom(objid, &Buf2, 1, &l_addr, 100); UtAssert_True(actual == expected, "OS_SocketRecvFrom() (%ld) == OS_ERR_INVALID_ID", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_SocketRecvFrom(p2_socket_id, &Buf2, 0, &l_addr, 100); + actual = OS_SocketRecvFrom(p2_socket_id, &Buf2, 0, &l_addr, 100); UtAssert_True(actual == expected, "OS_SocketRecvFrom() (%ld) == OS_INVALID_POINTER", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_SocketRecvFrom(p2_socket_id, &Buf2, 0, NULL, 100); + actual = OS_SocketRecvFrom(p2_socket_id, &Buf2, 0, NULL, 100); UtAssert_True(actual == expected, "OS_SocketRecvFrom() (%ld) == OS_INVALID_POINTER", (long)actual); /* OS_SocketAddrToString */ - expected = OS_INVALID_POINTER; - actual = OS_SocketAddrToString(NULL, 0, NULL); + expected = OS_INVALID_POINTER; + actual = OS_SocketAddrToString(NULL, 0, NULL); UtAssert_True(actual == expected, "OS_SocketAddrToString() (%ld) == OS_INVALID_POINTER", (long)actual); - expected = OS_INVALID_POINTER; - actual = OS_SocketAddrToString(AddrBuffer1, sizeof(AddrBuffer1), NULL); + expected = OS_INVALID_POINTER; + actual = OS_SocketAddrToString(AddrBuffer1, sizeof(AddrBuffer1), NULL); UtAssert_True(actual == expected, "OS_SocketAddrToString() (%ld) == OS_INVALID_POINTER", (long)actual); - expected = OS_INVALID_POINTER; - actual = OS_SocketAddrToString(0, 0, &p2_addr); + expected = OS_INVALID_POINTER; + actual = OS_SocketAddrToString(0, 0, &p2_addr); UtAssert_True(actual == expected, "OS_SocketAddrToString() (%ld) == OS_INVALID_POINTER", (long)actual); /* OS_SocketAddrGetPort */ - expected = OS_INVALID_POINTER; - actual = OS_SocketAddrGetPort(NULL, NULL); + expected = OS_INVALID_POINTER; + actual = OS_SocketAddrGetPort(NULL, NULL); UtAssert_True(actual == expected, "OS_SocketAddrGetPort() (%ld) == OS_INVALID_POINTER", (long)actual); - expected = OS_INVALID_POINTER; - actual = OS_SocketAddrGetPort(0, &l_addr); + expected = OS_INVALID_POINTER; + actual = OS_SocketAddrGetPort(0, &l_addr); UtAssert_True(actual == expected, "OS_SocketAddrGetPort() (%ld) == OS_INVALID_POINTER", (long)actual); - expected = OS_INVALID_POINTER; - actual = OS_SocketAddrGetPort(&PortNum, NULL); + expected = OS_INVALID_POINTER; + actual = OS_SocketAddrGetPort(&PortNum, NULL); UtAssert_True(actual == expected, "OS_SocketAddrGetPort() (%ld) == OS_INVALID_POINTER", (long)actual); /* OS_SocketGetIdByName */ - expected = OS_INVALID_POINTER; - actual = OS_SocketGetIdByName(NULL,NULL); + expected = OS_INVALID_POINTER; + actual = OS_SocketGetIdByName(NULL, NULL); UtAssert_True(actual == expected, "OS_SocketGetIdByName() (%ld) == OS_INVALID_POINTER", (long)actual); - expected = OS_ERR_NAME_NOT_FOUND; - actual = OS_SocketGetIdByName(&objid,"NF"); + expected = OS_ERR_NAME_NOT_FOUND; + actual = OS_SocketGetIdByName(&objid, "NF"); UtAssert_True(actual == expected, "OS_SocketGetIdByName() (%ld) == OS_ERR_NAME_NOT_FOUND", (long)actual); /* OS_SocketGetInfo */ expected = OS_INVALID_POINTER; - actual = OS_SocketGetInfo(p2_socket_id, NULL); + actual = OS_SocketGetInfo(p2_socket_id, NULL); UtAssert_True(actual == expected, "OS_SocketGetInfo() (%ld) == OS_INVALID_POINTER", (long)actual); expected = OS_ERR_INVALID_ID; - objid = OS_OBJECT_ID_UNDEFINED; - actual = OS_SocketGetInfo(objid, &prop); + objid = OS_OBJECT_ID_UNDEFINED; + actual = OS_SocketGetInfo(objid, &prop); UtAssert_True(actual == expected, "OS_SocketGetInfo() (%ld) == OS_ERR_INVALID_ID", (long)actual); } /* end TestDatagramNetworkApi */ @@ -358,7 +360,6 @@ void TestDatagramNetworkApi_Teardown(void) } /* end TestDatagramNetworkApi_Teardown */ - /***************************************************************************** * * Server Function for Stream Network Functional Test @@ -366,62 +367,58 @@ void TestDatagramNetworkApi_Teardown(void) *****************************************************************************/ void Server_Fn(void) { - osal_id_t connsock_id = OS_OBJECT_ID_UNDEFINED; - uint32 iter; + osal_id_t connsock_id = OS_OBJECT_ID_UNDEFINED; + uint32 iter; OS_SockAddr_t addr; - char Buf_rcv_s[4] = {0}; - char Buf_trans[8] ={0}; - uint8 Buf_each_char_s[256] = {0}; - + char Buf_rcv_s[4] = {0}; + char Buf_trans[8] = {0}; + uint8 Buf_each_char_s[256] = {0}; /* Accept incoming connections */ OS_SocketAccept(s_socket_id, &connsock_id, &addr, OS_PEND); - /* Recieve incoming data from client*/ + /* Recieve incoming data from client*/ OS_TimedRead(connsock_id, Buf_rcv_s, sizeof(Buf_rcv_s), 10); - /* Transform the incoming data and send it back to client */ + /* Transform the incoming data and send it back to client */ strcpy(Buf_trans, "uvw"); strcat(Buf_trans, Buf_rcv_s); OS_TimedWrite(connsock_id, Buf_trans, sizeof(Buf_trans), 10); /* Send all 256 chars to client */ for (iter = 0; iter < 256; iter++) - { - Buf_each_char_s[iter] = iter; - } - + { + Buf_each_char_s[iter] = iter; + } + OS_TimedWrite(connsock_id, Buf_each_char_s, sizeof(Buf_each_char_s), 10); OS_close(s_socket_id); OS_close(connsock_id); - } /* end Server_Fn */ - /***************************************************************************** * - * Stream Network Functional Test + * Stream Network Functional Test * *****************************************************************************/ void TestStreamNetworkApi(void) { - int32 status; - int32 expected; - int32 actual; - uint32 iter; - uint32 loopcnt; - osal_id_t temp_id; - OS_SockAddr_t temp_addr; + int32 status; + int32 expected; + int32 actual; + uint32 iter; + uint32 loopcnt; + osal_id_t temp_id; + OS_SockAddr_t temp_addr; OS_task_prop_t taskprop; - char Buf_rcv_c[4] = {0}; - char Buf_send_c[4] = {0}; - char Buf_rcv_trans[8] = {0}; - char Buf_expec_trans[8] ={0}; - uint8 Buf_each_expected[256] = {0}; - uint8 Buf_each_char_rcv[256] = {0}; - + char Buf_rcv_c[4] = {0}; + char Buf_send_c[4] = {0}; + char Buf_rcv_trans[8] = {0}; + char Buf_expec_trans[8] = {0}; + uint8 Buf_each_expected[256] = {0}; + uint8 Buf_each_char_rcv[256] = {0}; /* * Set up a server @@ -429,8 +426,8 @@ void TestStreamNetworkApi(void) /* Open a server socket */ s_socket_id = OS_OBJECT_ID_UNDEFINED; - expected = OS_SUCCESS; - actual = OS_SocketOpen(&s_socket_id, OS_SocketDomain_INET, OS_SocketType_STREAM); + expected = OS_SUCCESS; + actual = OS_SocketOpen(&s_socket_id, OS_SocketDomain_INET, OS_SocketType_STREAM); UtAssert_True(actual == expected, "OS_SocketOpen() (%ld) == OS_SUCCESS", (long)actual); UtAssert_True(OS_ObjectIdDefined(s_socket_id), "s_socket_id (%lu) != 0", OS_ObjectIdToInteger(s_socket_id)); @@ -454,8 +451,8 @@ void TestStreamNetworkApi(void) * Set up a client */ - /* Open a client socket */ - expected = OS_SUCCESS; + /* Open a client socket */ + expected = OS_SUCCESS; c_socket_id = OS_OBJECT_ID_UNDEFINED; actual = OS_SocketOpen(&c_socket_id, OS_SocketDomain_INET, OS_SocketType_STREAM); @@ -480,127 +477,123 @@ void TestStreamNetworkApi(void) */ /* Create a server task/thread */ - status = OS_TaskCreate( &s_task_id, "Server", Server_Fn, 0, 16384, 50, 0); + status = OS_TaskCreate(&s_task_id, "Server", Server_Fn, 0, 16384, 50, 0); UtAssert_True(status == OS_SUCCESS, "OS_TaskCreate() (%ld) == OS_SUCCESS", (long)status); /* Connect to a server */ actual = OS_SocketConnect(c_socket_id, &s_addr, 10); UtAssert_True(actual == expected, "OS_SocketConnect() (%ld) == OS_SUCCESS", (long)actual); - /* - * Test for invalid input parameters + * Test for invalid input parameters */ /* OS_TimedRead */ expected = OS_ERR_INVALID_ID; - temp_id = OS_ObjectIdFromInteger(0xFFFFFFFF); - actual = OS_TimedRead(temp_id, Buf_rcv_c, sizeof(Buf_rcv_c), 10); - UtAssert_True(actual == expected, "OS_TimedRead() (%ld) == %ld",(long)actual, (long)expected); + temp_id = OS_ObjectIdFromInteger(0xFFFFFFFF); + actual = OS_TimedRead(temp_id, Buf_rcv_c, sizeof(Buf_rcv_c), 10); + UtAssert_True(actual == expected, "OS_TimedRead() (%ld) == %ld", (long)actual, (long)expected); expected = OS_INVALID_POINTER; - actual = OS_TimedRead(c_socket_id, NULL, sizeof(Buf_rcv_c), 10); - UtAssert_True(actual == expected, "OS_TimedRead() (%ld) == %ld",(long)actual, (long)expected); + actual = OS_TimedRead(c_socket_id, NULL, sizeof(Buf_rcv_c), 10); + UtAssert_True(actual == expected, "OS_TimedRead() (%ld) == %ld", (long)actual, (long)expected); expected = OS_ERROR_TIMEOUT; - actual = OS_TimedRead(c_socket_id, Buf_rcv_c, sizeof(Buf_rcv_c), 0); - UtAssert_True(actual == expected, "OS_TimedRead() (%ld) == %ld",(long)actual, (long)expected); + actual = OS_TimedRead(c_socket_id, Buf_rcv_c, sizeof(Buf_rcv_c), 0); + UtAssert_True(actual == expected, "OS_TimedRead() (%ld) == %ld", (long)actual, (long)expected); /* OS_TimedWrite */ expected = OS_ERR_INVALID_ID; - temp_id = OS_ObjectIdFromInteger(0xFFFFFFFF); - actual = OS_TimedWrite(temp_id, Buf_rcv_c, sizeof(Buf_rcv_c), 10); - UtAssert_True(actual == expected, "OS_TimedWrite() (%ld) == %ld",(long)actual, (long)expected); + temp_id = OS_ObjectIdFromInteger(0xFFFFFFFF); + actual = OS_TimedWrite(temp_id, Buf_rcv_c, sizeof(Buf_rcv_c), 10); + UtAssert_True(actual == expected, "OS_TimedWrite() (%ld) == %ld", (long)actual, (long)expected); expected = OS_INVALID_POINTER; - actual = OS_TimedWrite(c_socket_id, NULL, sizeof(Buf_rcv_c), 10); - UtAssert_True(actual == expected, "OS_TimedWrite() (%ld) == %ld",(long)actual, (long)expected); + actual = OS_TimedWrite(c_socket_id, NULL, sizeof(Buf_rcv_c), 10); + UtAssert_True(actual == expected, "OS_TimedWrite() (%ld) == %ld", (long)actual, (long)expected); /* OS_SocketAccept */ expected = OS_INVALID_POINTER; - actual = OS_SocketAccept(s_socket_id, NULL, NULL, 0); + actual = OS_SocketAccept(s_socket_id, NULL, NULL, 0); UtAssert_True(actual == expected, "OS_SocketAccept() (%ld) == OS_INVALID_POINTER", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_SocketAccept(s_socket_id, NULL, &temp_addr, 10); + actual = OS_SocketAccept(s_socket_id, NULL, &temp_addr, 10); UtAssert_True(actual == expected, "OS_SocketAccept() (%ld) == OS_INVALID_POINTER", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_SocketAccept(s_socket_id, &temp_id, NULL, 10); + actual = OS_SocketAccept(s_socket_id, &temp_id, NULL, 10); UtAssert_True(actual == expected, "OS_SocketAccept() (%ld) == OS_INVALID_POINTER", (long)actual); /* OS_SocketConnect */ expected = OS_INVALID_POINTER; - actual = OS_SocketConnect(c_socket_id, NULL, 10); + actual = OS_SocketConnect(c_socket_id, NULL, 10); UtAssert_True(actual == expected, "OS_SocketConnect() (%ld) == OS_INVALID_POINTER", (long)actual); expected = OS_ERR_INCORRECT_OBJ_STATE; - actual = OS_SocketConnect(c_socket_id, &s_addr, 0); + actual = OS_SocketConnect(c_socket_id, &s_addr, 0); UtAssert_True(actual == expected, "OS_SocketConnect() (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); expected = OS_ERR_INVALID_ID; - temp_id = OS_ObjectIdFromInteger(0xFFFFFFFF); - actual = OS_SocketConnect(temp_id, &s_addr, 10); + temp_id = OS_ObjectIdFromInteger(0xFFFFFFFF); + actual = OS_SocketConnect(temp_id, &s_addr, 10); UtAssert_True(actual == expected, "OS_SocketConnect() (%ld) == OS_ERR_INVALID_ID", (long)actual); /* - * Once connection is made between - * server and client, transfer data + * Once connection is made between + * server and client, transfer data */ - /* Send data to server to be transformed and sent back */ + /* Send data to server to be transformed and sent back */ strcpy(Buf_send_c, "xyz"); expected = sizeof(Buf_send_c); - actual = OS_TimedWrite(c_socket_id, Buf_send_c, sizeof(Buf_send_c), 10); - UtAssert_True(actual == expected, "OS_TimedWrite() (%ld) == %ld",(long)actual, (long)expected); + actual = OS_TimedWrite(c_socket_id, Buf_send_c, sizeof(Buf_send_c), 10); + UtAssert_True(actual == expected, "OS_TimedWrite() (%ld) == %ld", (long)actual, (long)expected); - /* Recieve back transformed data from server*/ + /* Recieve back transformed data from server*/ expected = sizeof(Buf_expec_trans); strcpy(Buf_expec_trans, "uvwxyz"); actual = OS_TimedRead(c_socket_id, Buf_rcv_trans, sizeof(Buf_rcv_trans), 10); - UtAssert_True(actual == expected, "OS_TimedRead() (%ld) == %ld",(long)actual, (long)expected); - UtAssert_True(strcmp(Buf_rcv_trans, Buf_expec_trans) == 0, "Buf_rcv_trans (%s) == Buf_expected (%s)", Buf_rcv_trans, Buf_expec_trans); + UtAssert_True(actual == expected, "OS_TimedRead() (%ld) == %ld", (long)actual, (long)expected); + UtAssert_True(strcmp(Buf_rcv_trans, Buf_expec_trans) == 0, "Buf_rcv_trans (%s) == Buf_expected (%s)", Buf_rcv_trans, + Buf_expec_trans); /* Recieve all 256 chars from server one at a time */ - expected = sizeof(Buf_each_char_rcv); - actual = OS_TimedRead(c_socket_id, Buf_each_char_rcv, sizeof(Buf_each_char_rcv), 10); - UtAssert_True(actual == expected, "OS_TimedRead() (%ld) == %ld",(long)actual, (long)expected); + expected = sizeof(Buf_each_char_rcv); + actual = OS_TimedRead(c_socket_id, Buf_each_char_rcv, sizeof(Buf_each_char_rcv), 10); + UtAssert_True(actual == expected, "OS_TimedRead() (%ld) == %ld", (long)actual, (long)expected); /* Verify all 256 chars received */ for (iter = 0; iter < 256; iter++) - { - Buf_each_expected[iter] = iter; - } - - UtAssert_True(memcmp(Buf_each_expected,Buf_each_char_rcv,sizeof(Buf_each_expected)) == 0, "buffer content match"); + { + Buf_each_expected[iter] = iter; + } + UtAssert_True(memcmp(Buf_each_expected, Buf_each_char_rcv, sizeof(Buf_each_expected)) == 0, "buffer content match"); /* Once connection socket is closed, verify that no data is recieved */ expected = 0; - actual = OS_TimedRead(c_socket_id, Buf_rcv_c, sizeof(Buf_rcv_c), 10); - UtAssert_True(actual == expected, "OS_TimedRead() (%ld) == %ld",(long)actual, (long)expected); - + actual = OS_TimedRead(c_socket_id, Buf_rcv_c, sizeof(Buf_rcv_c), 10); + UtAssert_True(actual == expected, "OS_TimedRead() (%ld) == %ld", (long)actual, (long)expected); /* - * NOTE: Tests for invalid and other nominal input parameters - * to some of the network functions being called here are already + * NOTE: Tests for invalid and other nominal input parameters + * to some of the network functions being called here are already * tested in TestDatagramNetworkApi_Setup() */ - /* Looping delay in parent task to wait for child task to exit */ loopcnt = 0; while ((OS_TaskGetInfo(s_task_id, &taskprop) == OS_SUCCESS) && (loopcnt < UT_EXIT_LOOP_MAX)) { - OS_TaskDelay(10); - loopcnt++; + OS_TaskDelay(10); + loopcnt++; } UtAssert_True(loopcnt < UT_EXIT_LOOP_MAX, "Task exited after %ld iterations", (long)loopcnt); } /* end TestStreamNetworkApi */ - /***************************************************************************** * * Stream Network Teardown @@ -613,8 +606,6 @@ void TestStreamNetworkApi_Teardown(void) } /* end TestStreamNetworkApi_Teardown */ - - void UtTest_Setup(void) { if (OS_API_Init() != OS_SUCCESS) @@ -625,7 +616,7 @@ void UtTest_Setup(void) /* * Register the test setup and check routines in UT assert */ - UtTest_Add(TestDatagramNetworkApi, TestDatagramNetworkApi_Setup, TestDatagramNetworkApi_Teardown, "TestDatagramNetworkApi"); + UtTest_Add(TestDatagramNetworkApi, TestDatagramNetworkApi_Setup, TestDatagramNetworkApi_Teardown, + "TestDatagramNetworkApi"); UtTest_Add(TestStreamNetworkApi, NULL, TestStreamNetworkApi_Teardown, "TestStreamNetworkApi"); } - diff --git a/src/tests/osal-core-test/osal-core-test.c b/src/tests/osal-core-test/osal-core-test.c index 13dc303b0..d5c04748e 100644 --- a/src/tests/osal-core-test/osal-core-test.c +++ b/src/tests/osal-core-test/osal-core-test.c @@ -30,21 +30,19 @@ #include "utbsp.h" /* Defines */ -#define UT_EXIT_LOOP_MAX 100 /* Used to limit wait for self-exiting task to exit */ +#define UT_EXIT_LOOP_MAX 100 /* Used to limit wait for self-exiting task to exit */ /* OS Constructs */ -#define OSAL_UT_MAX_CALLBACKS 5 +#define OSAL_UT_MAX_CALLBACKS 5 typedef struct { - uint32 NumInvocations; + uint32 NumInvocations; osal_id_t ObjList[OSAL_UT_MAX_CALLBACKS]; } TestCallbackState_t; - - -void TestTasks (void); -void InitializeTaskIds (void); -void InitializeQIds (void); +void TestTasks(void); +void InitializeTaskIds(void); +void InitializeQIds(void); void InitializeBinIds(void); void InitializeMutIds(void); void TestQueues(void); @@ -56,7 +54,7 @@ void TestGenericQueries(void); /* helper function for "OS_ForEachObject" test cases */ static void TestForEachCallback(osal_id_t object_id, void *arg) { - TestCallbackState_t *State = (TestCallbackState_t*)arg; + TestCallbackState_t *State = (TestCallbackState_t *)arg; if (State->NumInvocations < OSAL_UT_MAX_CALLBACKS) { State->ObjList[State->NumInvocations] = object_id; @@ -64,8 +62,6 @@ static void TestForEachCallback(osal_id_t object_id, void *arg) ++State->NumInvocations; } - - /* *************************************** MAIN ************************************** */ void UtTest_Setup(void) { @@ -73,14 +69,14 @@ void UtTest_Setup(void) { UtAssert_Abort("OS_API_Init() failed"); } - + UtTest_Add(TestTasks, NULL, NULL, "TASK"); UtTest_Add(TestQueues, NULL, NULL, "MSGQ"); UtTest_Add(TestBinaries, NULL, NULL, "BSEM"); UtTest_Add(TestMutexes, NULL, NULL, "MSEM"); UtTest_Add(TestGetInfos, NULL, NULL, "INFO"); UtTest_Add(TestGenericQueries, NULL, NULL, "QUERIES"); - + } /* end OS_Application Startup */ /* **************** A TASK THAT RUNS FOREVER **************************** */ @@ -89,7 +85,7 @@ void task_generic_no_exit(void) { OS_TaskRegister(); - while(1) + while (1) { OS_TaskDelay(100); } @@ -104,129 +100,120 @@ void task_generic_with_exit(void) return; } /* end task_0 */ - - typedef struct { - osal_id_t task_id; - uint32 task_stack[TASK_0_STACK_SIZE]; + osal_id_t task_id; + uint32 task_stack[TASK_0_STACK_SIZE]; } TestTaskData; /* ********************************************** TASKS******************************* */ void TestTasks(void) { - int32 status; - char taskname[OS_MAX_API_NAME]; - int tasknum; - osal_id_t saved_task0_id; + int32 status; + char taskname[OS_MAX_API_NAME]; + int tasknum; + osal_id_t saved_task0_id; static TestTaskData TaskData[OS_MAX_TASKS + 1]; - OS_task_prop_t taskprop; - int loopcnt; - - /* OS_TaskRegister(); */ + OS_task_prop_t taskprop; + int loopcnt; + + /* OS_TaskRegister(); */ /* Testing Creating up to OS_MAX_TASKS, plus one more */ - memset(TaskData,0xFF,sizeof(TaskData)); + memset(TaskData, 0xFF, sizeof(TaskData)); for (tasknum = 0; tasknum < (OS_MAX_TASKS + 1); ++tasknum) { - snprintf(taskname,sizeof(taskname), "Task %d", tasknum); - status = OS_TaskCreate( &TaskData[tasknum].task_id, taskname, task_generic_no_exit, TaskData[tasknum].task_stack, + snprintf(taskname, sizeof(taskname), "Task %d", tasknum); + status = OS_TaskCreate(&TaskData[tasknum].task_id, taskname, task_generic_no_exit, TaskData[tasknum].task_stack, TASK_0_STACK_SIZE, (250 - OS_MAX_TASKS) + tasknum, 0); - UtDebug("Create %s Status = %d, Id = %lx\n",taskname,(int)status, - OS_ObjectIdToInteger(TaskData[tasknum].task_id)); + UtDebug("Create %s Status = %d, Id = %lx\n", taskname, (int)status, + OS_ObjectIdToInteger(TaskData[tasknum].task_id)); - UtAssert_True((tasknum < OS_MAX_TASKS && status == OS_SUCCESS) || - (tasknum >= OS_MAX_TASKS && status != OS_SUCCESS), "OS_TaskCreate, nominal"); + UtAssert_True((tasknum < OS_MAX_TASKS && status == OS_SUCCESS) || + (tasknum >= OS_MAX_TASKS && status != OS_SUCCESS), + "OS_TaskCreate, nominal"); } - + /* Save off the task 0 ID for later */ saved_task0_id = TaskData[0].task_id; /* Testing the Deletions of all the tasks we have created */ for (tasknum = 0; tasknum < (OS_MAX_TASKS + 1); ++tasknum) { - snprintf(taskname,sizeof(taskname), "Task %d", tasknum); - status = OS_TaskDelete( TaskData[tasknum].task_id ); + snprintf(taskname, sizeof(taskname), "Task %d", tasknum); + status = OS_TaskDelete(TaskData[tasknum].task_id); - UtDebug("Delete Status = %d, Id = %lx\n",(int)status, - OS_ObjectIdToInteger(TaskData[tasknum].task_id)); + UtDebug("Delete Status = %d, Id = %lx\n", (int)status, OS_ObjectIdToInteger(TaskData[tasknum].task_id)); - UtAssert_True((tasknum < OS_MAX_TASKS && status == OS_SUCCESS) || - (tasknum >= OS_MAX_TASKS && status != OS_SUCCESS), "OS_TaskDelete, nominal"); + UtAssert_True((tasknum < OS_MAX_TASKS && status == OS_SUCCESS) || + (tasknum >= OS_MAX_TASKS && status != OS_SUCCESS), + "OS_TaskDelete, nominal"); } - + /* These next few tasks were deleted already, testing a "redelete" */ UtAssert_True(OS_TaskDelete(TaskData[1].task_id) != OS_SUCCESS, "OS_TaskDelete, redelete 1"); UtAssert_True(OS_TaskDelete(TaskData[2].task_id) != OS_SUCCESS, "OS_TaskDelete, redelete 2"); UtAssert_True(OS_TaskDelete(TaskData[3].task_id) != OS_SUCCESS, "OS_TaskDelete, redelete 3"); /* Testing tasks that exit themselves by calling OS_TaskExit() */ - memset(TaskData,0xFF,sizeof(TaskData)); + memset(TaskData, 0xFF, sizeof(TaskData)); for (tasknum = 0; tasknum < (OS_MAX_TASKS + 1); ++tasknum) { - snprintf(taskname,sizeof(taskname), "Task %d", tasknum); - status = OS_TaskCreate( &TaskData[tasknum].task_id, taskname, task_generic_with_exit, TaskData[tasknum].task_stack, - TASK_0_STACK_SIZE, (250 - OS_MAX_TASKS) + tasknum, 0); - - UtDebug("Create %s Status = %d, Id = %lx\n",taskname,(int)status, - OS_ObjectIdToInteger(TaskData[tasknum].task_id)); - - UtAssert_True(status == OS_SUCCESS, "OS_TaskCreate, self exiting task"); - - /* Looping delay in parent task to wait for child task to exit */ - loopcnt = 0; - while ((OS_TaskGetInfo(TaskData[tasknum].task_id, &taskprop) == OS_SUCCESS) && (loopcnt < UT_EXIT_LOOP_MAX)) - { - OS_TaskDelay(10); - loopcnt++; - } - UtDebug("Looped %d times waiting for child task Id %lx to exit\n", loopcnt, - OS_ObjectIdToInteger(TaskData[tasknum].task_id)); - UtAssert_True(loopcnt < UT_EXIT_LOOP_MAX, "Looped %d times without self-exiting task exiting", loopcnt); - - /* - * Attempting to delete the task that exited itself should always fail - */ - status = OS_TaskDelete( TaskData[tasknum].task_id ); - - UtDebug("Delete Status = %d, Id = %lx\n",(int)status, - OS_ObjectIdToInteger(TaskData[tasknum].task_id)); - - UtAssert_True(status != OS_SUCCESS, "OS_TaskDelete, self exiting task"); - + snprintf(taskname, sizeof(taskname), "Task %d", tasknum); + status = OS_TaskCreate(&TaskData[tasknum].task_id, taskname, task_generic_with_exit, + TaskData[tasknum].task_stack, TASK_0_STACK_SIZE, (250 - OS_MAX_TASKS) + tasknum, 0); + + UtDebug("Create %s Status = %d, Id = %lx\n", taskname, (int)status, + OS_ObjectIdToInteger(TaskData[tasknum].task_id)); + + UtAssert_True(status == OS_SUCCESS, "OS_TaskCreate, self exiting task"); + + /* Looping delay in parent task to wait for child task to exit */ + loopcnt = 0; + while ((OS_TaskGetInfo(TaskData[tasknum].task_id, &taskprop) == OS_SUCCESS) && (loopcnt < UT_EXIT_LOOP_MAX)) + { + OS_TaskDelay(10); + loopcnt++; + } + UtDebug("Looped %d times waiting for child task Id %lx to exit\n", loopcnt, + OS_ObjectIdToInteger(TaskData[tasknum].task_id)); + UtAssert_True(loopcnt < UT_EXIT_LOOP_MAX, "Looped %d times without self-exiting task exiting", loopcnt); + + /* + * Attempting to delete the task that exited itself should always fail + */ + status = OS_TaskDelete(TaskData[tasknum].task_id); + + UtDebug("Delete Status = %d, Id = %lx\n", (int)status, OS_ObjectIdToInteger(TaskData[tasknum].task_id)); + + UtAssert_True(status != OS_SUCCESS, "OS_TaskDelete, self exiting task"); } /* Creating some more tasks for testing name functions */ - InitializeTaskIds(); /* Create Task 0 again */ - status = OS_TaskCreate( &task_0_id, "Task 0", task_0, task_0_stack, - TASK_0_STACK_SIZE, TASK_0_PRIORITY, 0); - /*UtDebug("Create Status = %d, Id = %d\n",status,task_0_id); */ + status = OS_TaskCreate(&task_0_id, "Task 0", task_0, task_0_stack, TASK_0_STACK_SIZE, TASK_0_PRIORITY, 0); + /*UtDebug("Create Status = %d, Id = %d\n",status,task_0_id); */ UtAssert_True(status == OS_SUCCESS, "OS_TaskCreate, recreate 0"); - - /* Try and create another "Task 0", should fail as we already have one named "Task 0" */ - status = OS_TaskCreate( &task_1_id, "Task 0", task_0, task_0_stack, - TASK_0_STACK_SIZE, TASK_0_PRIORITY, 0); + + /* Try and create another "Task 0", should fail as we already have one named "Task 0" */ + status = OS_TaskCreate(&task_1_id, "Task 0", task_0, task_0_stack, TASK_0_STACK_SIZE, TASK_0_PRIORITY, 0); UtAssert_True(status != OS_SUCCESS, "OS_TaskCreate, dupe name 0"); - status = OS_TaskCreate( &task_2_id, "Task 2", task_2, task_2_stack, - TASK_2_STACK_SIZE, TASK_2_PRIORITY, 0); + status = OS_TaskCreate(&task_2_id, "Task 2", task_2, task_2_stack, TASK_2_STACK_SIZE, TASK_2_PRIORITY, 0); /* UtDebug("Create Status = %d, Id = %d\n",status,task_2_id); */ UtAssert_True(status == OS_SUCCESS, "OS_TaskCreate, recreate 2"); - - status = OS_TaskCreate( &task_3_id, "Task 3", task_3, task_3_stack, - TASK_3_STACK_SIZE, TASK_3_PRIORITY, 0); + + status = OS_TaskCreate(&task_3_id, "Task 3", task_3, task_3_stack, TASK_3_STACK_SIZE, TASK_3_PRIORITY, 0); /* UtDebug("Create Status = %d, Id = %d\n",status,task_3_id); */ UtAssert_True(status == OS_SUCCESS, "OS_TaskCreate, recreate 3"); - status = OS_TaskGetIdByName(&task_0_id, "Task 0"); /* UtDebug("Satus after Getting the id of \"Task 0\":%d,%d \n\n",status,task_0_id); */ /*first newly created task should have id == 0*/ UtAssert_True(status == OS_SUCCESS, "OS_TaskGetIdByName, Task 0"); - + status = OS_TaskGetIdByName(&task_1_id, "Task 1"); /*UtDebug("Satus after Getting the id of \"Task 1\":%d,%d \n\n",status,task_1_id);*/ UtAssert_True(status != OS_SUCCESS, "OS_TaskGetIdByName, Task 1"); @@ -234,7 +221,7 @@ void TestTasks(void) status = OS_TaskGetIdByName(&task_2_id, "Task 2"); /* UtDebug("Satus after Getting the id of \"Task 2\":%d,%d \n\n",status,task_2_id);*/ UtAssert_True(status == OS_SUCCESS, "OS_TaskGetIdByName, Task 2"); - + status = OS_TaskGetIdByName(&task_3_id, "Task 3"); /* UtDebug("Satus after Getting the id of \"Task 3\":%d,%d \n\n",status,task_3_id); */ UtAssert_True(status == OS_SUCCESS, "OS_TaskGetIdByName, Task 3"); @@ -249,77 +236,76 @@ void TestTasks(void) UtAssert_True(OS_TaskDelete(task_1_id) != OS_SUCCESS, "OS_TaskDelete, Task 1"); UtAssert_True(OS_TaskDelete(task_2_id) == OS_SUCCESS, "OS_TaskDelete, Task 2"); UtAssert_True(OS_TaskDelete(task_3_id) == OS_SUCCESS, "OS_TaskDelete, Task 3"); - -}/* end TestTasks */ +} /* end TestTasks */ /* ************************************************************************************ */ void TestQueues(void) { - int32 status; - char qname[OS_MAX_API_NAME]; - int qnum; - osal_id_t saved_queue0_id; + int32 status; + char qname[OS_MAX_API_NAME]; + int qnum; + osal_id_t saved_queue0_id; static osal_id_t msgq_ids[OS_MAX_QUEUES + 1]; InitializeQIds(); - memset(msgq_ids,0xFF,sizeof(msgq_ids)); - + memset(msgq_ids, 0xFF, sizeof(msgq_ids)); + for (qnum = 0; qnum < (OS_MAX_QUEUES + 1); ++qnum) { - snprintf(qname,sizeof(qname),"q %d", qnum); - status = OS_QueueCreate( &msgq_ids[qnum], qname, MSGQ_DEPTH, MSGQ_SIZE, 0); + snprintf(qname, sizeof(qname), "q %d", qnum); + status = OS_QueueCreate(&msgq_ids[qnum], qname, MSGQ_DEPTH, MSGQ_SIZE, 0); - UtAssert_True((qnum < OS_MAX_QUEUES && status == OS_SUCCESS) || - (qnum >= OS_MAX_QUEUES && status != OS_SUCCESS), "OS_QueueCreate, nominal"); + UtAssert_True((qnum < OS_MAX_QUEUES && status == OS_SUCCESS) || (qnum >= OS_MAX_QUEUES && status != OS_SUCCESS), + "OS_QueueCreate, nominal"); } - + saved_queue0_id = msgq_ids[0]; - /* Trying now to Delete all of the Queues created. */ - + /* Trying now to Delete all of the Queues created. */ + for (qnum = 0; qnum < (OS_MAX_QUEUES + 1); ++qnum) { - status = OS_QueueDelete( msgq_ids[qnum] ); + status = OS_QueueDelete(msgq_ids[qnum]); - UtAssert_True((qnum < OS_MAX_QUEUES && status == OS_SUCCESS) || - (qnum >= OS_MAX_QUEUES && status != OS_SUCCESS), "OS_QueueDelete, nominal"); + UtAssert_True((qnum < OS_MAX_QUEUES && status == OS_SUCCESS) || (qnum >= OS_MAX_QUEUES && status != OS_SUCCESS), + "OS_QueueDelete, nominal"); } -/* Create Some more Queues for trying to get the id by name */ + /* Create Some more Queues for trying to get the id by name */ InitializeQIds(); - status = OS_QueueCreate( &msgq_0, "q 0", MSGQ_DEPTH, MSGQ_SIZE, 0); - /* UtDebug("Status after Creating q 0: %d,%d\n",status,msgq_0);*/ + status = OS_QueueCreate(&msgq_0, "q 0", MSGQ_DEPTH, MSGQ_SIZE, 0); + /* UtDebug("Status after Creating q 0: %d,%d\n",status,msgq_0);*/ UtAssert_True(status == OS_SUCCESS, "OS_QueueCreate, recreate 0"); - + /* This one should fail */ - status = OS_QueueCreate( &msgq_1, "q 0", MSGQ_DEPTH, MSGQ_SIZE, 0); - /* UtDebug("Status after Creating q 0 again: %d,%d\n",status,msgq_1); */ + status = OS_QueueCreate(&msgq_1, "q 0", MSGQ_DEPTH, MSGQ_SIZE, 0); + /* UtDebug("Status after Creating q 0 again: %d,%d\n",status,msgq_1); */ UtAssert_True(status != OS_SUCCESS, "OS_QueueCreate, dupe name 0"); - - status = OS_QueueCreate( &msgq_2, "q 2", MSGQ_DEPTH, MSGQ_SIZE, 0); - /* UtDebug("Status after Creating q 2: %d,%d\n",status,msgq_2); */ + + status = OS_QueueCreate(&msgq_2, "q 2", MSGQ_DEPTH, MSGQ_SIZE, 0); + /* UtDebug("Status after Creating q 2: %d,%d\n",status,msgq_2); */ UtAssert_True(status == OS_SUCCESS, "OS_QueueCreate, recreate 2"); - - status = OS_QueueCreate( &msgq_3, "q 3", MSGQ_DEPTH, MSGQ_SIZE, 0); - /* UtDebug("Status after Creating q 3: %d,%d\n",status,msgq_3); */ + + status = OS_QueueCreate(&msgq_3, "q 3", MSGQ_DEPTH, MSGQ_SIZE, 0); + /* UtDebug("Status after Creating q 3: %d,%d\n",status,msgq_3); */ UtAssert_True(status == OS_SUCCESS, "OS_QueueCreate, recreate 3"); /* * Now that the Queues are created, its time to see if we can find * the propper ID by the name of the queue; */ - status = OS_QueueGetIdByName(&msgq_0,"q 0"); + status = OS_QueueGetIdByName(&msgq_0, "q 0"); UtAssert_True(status == OS_SUCCESS, "OS_QueueGetIdByName, q 0"); - status = OS_QueueGetIdByName(&msgq_1,"q 1"); + status = OS_QueueGetIdByName(&msgq_1, "q 1"); UtAssert_True(status != OS_SUCCESS, "OS_QueueGetIdByName, q 1"); - status = OS_QueueGetIdByName(&msgq_2,"q 2"); + status = OS_QueueGetIdByName(&msgq_2, "q 2"); UtAssert_True(status == OS_SUCCESS, "OS_QueueGetIdByName, q 2"); - status = OS_QueueGetIdByName(&msgq_3,"q 3"); + status = OS_QueueGetIdByName(&msgq_3, "q 3"); UtAssert_True(status == OS_SUCCESS, "OS_QueueGetIdByName, q 3"); /* @@ -331,52 +317,53 @@ void TestQueues(void) /* Time to Delete the Queues we just created */ status = OS_QueueDelete(msgq_0); - /* UtDebug("Status after Deleting q 0 : %d\n",status); */ + /* UtDebug("Status after Deleting q 0 : %d\n",status); */ UtAssert_True(status == OS_SUCCESS, "OS_QueueDelete, q 0"); status = OS_QueueDelete(msgq_1); - /* UtDebug("Status after Deleting q 1: %d\n",status); */ + /* UtDebug("Status after Deleting q 1: %d\n",status); */ UtAssert_True(status != OS_SUCCESS, "OS_QueueDelete, q 1"); status = OS_QueueDelete(msgq_2); - /* UtDebug("Status after Deleting q 2: %d\n",status); */ + /* UtDebug("Status after Deleting q 2: %d\n",status); */ UtAssert_True(status == OS_SUCCESS, "OS_QueueDelete, q 2"); status = OS_QueueDelete(msgq_3); - /* UtDebug("Status after Deleting q 3: %d\n",status); */ + /* UtDebug("Status after Deleting q 3: %d\n",status); */ UtAssert_True(status == OS_SUCCESS, "OS_QueueDelete, q 3"); - -}/* end TestQueues */ + +} /* end TestQueues */ /* *************************************************************************** */ void TestBinaries(void) { - int32 status; - char bname[OS_MAX_API_NAME]; - int bnum; - osal_id_t saved_bin0_id; + int32 status; + char bname[OS_MAX_API_NAME]; + int bnum; + osal_id_t saved_bin0_id; static osal_id_t binsem_ids[OS_MAX_BIN_SEMAPHORES + 1]; - - memset(binsem_ids,0xFF,sizeof(binsem_ids)); + memset(binsem_ids, 0xFF, sizeof(binsem_ids)); for (bnum = 0; bnum < (OS_MAX_BIN_SEMAPHORES + 1); ++bnum) { - snprintf(bname,sizeof(bname),"Bin %d", bnum); - status = OS_BinSemCreate( &binsem_ids[bnum], bname, 1, 0); + snprintf(bname, sizeof(bname), "Bin %d", bnum); + status = OS_BinSemCreate(&binsem_ids[bnum], bname, 1, 0); - UtAssert_True((bnum < OS_MAX_BIN_SEMAPHORES && status == OS_SUCCESS) || - (bnum >= OS_MAX_BIN_SEMAPHORES && status != OS_SUCCESS), "OS_BinSemCreate, nominal"); + UtAssert_True((bnum < OS_MAX_BIN_SEMAPHORES && status == OS_SUCCESS) || + (bnum >= OS_MAX_BIN_SEMAPHORES && status != OS_SUCCESS), + "OS_BinSemCreate, nominal"); } saved_bin0_id = binsem_ids[0]; for (bnum = 0; bnum < (OS_MAX_BIN_SEMAPHORES + 1); ++bnum) { - status = OS_BinSemDelete( binsem_ids[bnum] ); + status = OS_BinSemDelete(binsem_ids[bnum]); - UtAssert_True((bnum < OS_MAX_BIN_SEMAPHORES && status == OS_SUCCESS) || - (bnum >= OS_MAX_BIN_SEMAPHORES && status != OS_SUCCESS), "OS_BinSemDelete, nominal"); + UtAssert_True((bnum < OS_MAX_BIN_SEMAPHORES && status == OS_SUCCESS) || + (bnum >= OS_MAX_BIN_SEMAPHORES && status != OS_SUCCESS), + "OS_BinSemDelete, nominal"); } /* @@ -384,39 +371,36 @@ void TestBinaries(void) * to test GetIdByName */ InitializeBinIds(); - status = OS_BinSemCreate( &bin_0,"Bin 0",OS_SEM_FULL,0); + status = OS_BinSemCreate(&bin_0, "Bin 0", OS_SEM_FULL, 0); /* UtDebug("Status after creating: %d,%d\n",status,bin_0); */ UtAssert_True(status == OS_SUCCESS, "OS_BinSemCreate, recreate 0"); - status = OS_BinSemCreate( &bin_1,"Bin 0",OS_SEM_FULL,0); + status = OS_BinSemCreate(&bin_1, "Bin 0", OS_SEM_FULL, 0); /* UtDebug("Status after creating: %d,%d\n",status,bin_1); */ UtAssert_True(status != OS_SUCCESS, "OS_BinSemCreate, dupe name 0"); - status = OS_BinSemCreate( &bin_2,"Bin 2",OS_SEM_EMPTY,0); - /* UtDebug("Status after creating: %d,%d\n",status,bin_2); */ + status = OS_BinSemCreate(&bin_2, "Bin 2", OS_SEM_EMPTY, 0); + /* UtDebug("Status after creating: %d,%d\n",status,bin_2); */ UtAssert_True(status == OS_SUCCESS, "OS_BinSemCreate, recreate 2"); - status = OS_BinSemCreate( &bin_3,"Bin 3",OS_SEM_EMPTY,0); - /* UtDebug("Status after creating: %d,%d\n",status,bin_3); */ + status = OS_BinSemCreate(&bin_3, "Bin 3", OS_SEM_EMPTY, 0); + /* UtDebug("Status after creating: %d,%d\n",status,bin_3); */ UtAssert_True(status == OS_SUCCESS, "OS_BinSemCreate, recreate 3"); - - - - status = OS_BinSemGetIdByName(&bin_0,"Bin 0"); - /* UtDebug("Status after GETID: %d,%d\n",status,bin_0); */ + status = OS_BinSemGetIdByName(&bin_0, "Bin 0"); + /* UtDebug("Status after GETID: %d,%d\n",status,bin_0); */ UtAssert_True(status == OS_SUCCESS, "OS_BinSemGetIdByName, Bin 0"); - - status = OS_BinSemGetIdByName(&bin_1,"Bin 1"); + + status = OS_BinSemGetIdByName(&bin_1, "Bin 1"); /* UtDebug("Status after GETID: %d,%d\n",status,bin_1); */ UtAssert_True(status != OS_SUCCESS, "OS_BinSemGetIdByName, Bin 1"); - - status = OS_BinSemGetIdByName(&bin_2,"Bin 2"); + + status = OS_BinSemGetIdByName(&bin_2, "Bin 2"); /* UtDebug("Status after GETID: %d,%d\n",status,bin_2); */ UtAssert_True(status == OS_SUCCESS, "OS_BinSemGetIdByName, Bin 2"); - - status = OS_BinSemGetIdByName(&bin_3,"Bin 3"); - /* UtDebug("Status after GETID: %d,%d\n",status,bin_3); */ + + status = OS_BinSemGetIdByName(&bin_3, "Bin 3"); + /* UtDebug("Status after GETID: %d,%d\n",status,bin_3); */ UtAssert_True(status == OS_SUCCESS, "OS_BinSemGetIdByName, Bin 3"); /* @@ -426,52 +410,52 @@ void TestBinaries(void) UtAssert_True(status != OS_SUCCESS, "OS_BinSemDelete, Old ID"); status = OS_BinSemDelete(bin_0); - /* UtDebug("Status after deleteing:%d\n",status); */ + /* UtDebug("Status after deleteing:%d\n",status); */ UtAssert_True(status == OS_SUCCESS, "OS_BinSemDelete, Bin 0"); /* this one was never created */ status = OS_BinSemDelete(bin_1); - /* UtDebug("Status after deleteing:%d\n",status); */ + /* UtDebug("Status after deleteing:%d\n",status); */ UtAssert_True(status != OS_SUCCESS, "OS_BinSemDelete, Bin 1"); status = OS_BinSemDelete(bin_2); UtAssert_True(status == OS_SUCCESS, "OS_BinSemDelete, Bin 2"); - + status = OS_BinSemDelete(bin_3); UtAssert_True(status == OS_SUCCESS, "OS_BinSemDelete, Bin 3"); -}/* end TestBinaries */ - +} /* end TestBinaries */ /* ************************************************************************************ */ void TestMutexes(void) { - int32 status; - char mname[OS_MAX_API_NAME]; - int mnum; - osal_id_t saved_mut0_id; + int32 status; + char mname[OS_MAX_API_NAME]; + int mnum; + osal_id_t saved_mut0_id; static osal_id_t mutex_ids[OS_MAX_MUTEXES + 1]; - - memset(mutex_ids,0xFF,sizeof(mutex_ids)); + memset(mutex_ids, 0xFF, sizeof(mutex_ids)); for (mnum = 0; mnum < (OS_MAX_MUTEXES + 1); ++mnum) { - snprintf(mname,sizeof(mname),"Mut %d", mnum); - status = OS_MutSemCreate( &mutex_ids[mnum], mname, 0); + snprintf(mname, sizeof(mname), "Mut %d", mnum); + status = OS_MutSemCreate(&mutex_ids[mnum], mname, 0); - UtAssert_True((mnum < OS_MAX_MUTEXES && status == OS_SUCCESS) || - (mnum >= OS_MAX_MUTEXES && status != OS_SUCCESS), "OS_MutSemCreate, nominal"); + UtAssert_True((mnum < OS_MAX_MUTEXES && status == OS_SUCCESS) || + (mnum >= OS_MAX_MUTEXES && status != OS_SUCCESS), + "OS_MutSemCreate, nominal"); } - + saved_mut0_id = mutex_ids[0]; for (mnum = 0; mnum < (OS_MAX_MUTEXES + 1); ++mnum) { - status = OS_MutSemDelete( mutex_ids[mnum] ); + status = OS_MutSemDelete(mutex_ids[mnum]); - UtAssert_True((mnum < OS_MAX_MUTEXES && status == OS_SUCCESS) || - (mnum >= OS_MAX_MUTEXES && status != OS_SUCCESS), "OS_MutSemDelete, nominal"); + UtAssert_True((mnum < OS_MAX_MUTEXES && status == OS_SUCCESS) || + (mnum >= OS_MAX_MUTEXES && status != OS_SUCCESS), + "OS_MutSemDelete, nominal"); } /* @@ -479,32 +463,32 @@ void TestMutexes(void) * to test GetIdByName */ InitializeMutIds(); - status = OS_MutSemCreate( &mut_0,"Mut 0",0); + status = OS_MutSemCreate(&mut_0, "Mut 0", 0); /* UtDebug("Status after creating Mut 0: %d,%d\n",status,mut_0); */ UtAssert_True(status == OS_SUCCESS, "OS_MutSemCreate, recreate 0"); - status = OS_MutSemCreate( &mut_1,"Mut 0",0); + status = OS_MutSemCreate(&mut_1, "Mut 0", 0); /* UtDebug("Status after creating Mut 0 again: %d,%d\n",status,mut_1); */ UtAssert_True(status != OS_SUCCESS, "OS_MutSemCreate, dupe name 0"); - status = OS_MutSemCreate( &mut_2,"Mut 2",0); + status = OS_MutSemCreate(&mut_2, "Mut 2", 0); /* UtDebug("Status after creating Mut 2: %d,%d\n",status,mut_2); */ UtAssert_True(status == OS_SUCCESS, "OS_MutSemCreate, recreate 2"); - status = OS_MutSemCreate( &mut_3,"Mut 3",0); + status = OS_MutSemCreate(&mut_3, "Mut 3", 0); /* UtDebug("Status after creating Mut 3: %d,%d\n",status,mut_3); */ UtAssert_True(status == OS_SUCCESS, "OS_MutSemCreate, recreate 3"); - status = OS_MutSemGetIdByName(&mut_0,"Mut 0"); + status = OS_MutSemGetIdByName(&mut_0, "Mut 0"); UtAssert_True(status == OS_SUCCESS, "OS_MutSemGetIdByName, Mut 0"); - - status = OS_MutSemGetIdByName(&mut_1,"Mut 1"); + + status = OS_MutSemGetIdByName(&mut_1, "Mut 1"); UtAssert_True(status != OS_SUCCESS, "OS_MutSemGetIdByName, Mut 1"); - - status = OS_MutSemGetIdByName(&mut_2,"Mut 2"); + + status = OS_MutSemGetIdByName(&mut_2, "Mut 2"); UtAssert_True(status == OS_SUCCESS, "OS_MutSemGetIdByName, Mut 2"); - - status = OS_MutSemGetIdByName(&mut_3,"Mut 3"); + + status = OS_MutSemGetIdByName(&mut_3, "Mut 3"); UtAssert_True(status == OS_SUCCESS, "OS_MutSemGetIdByName, Mut 3"); /* @@ -512,7 +496,7 @@ void TestMutexes(void) */ status = OS_MutSemDelete(saved_mut0_id); UtAssert_True(status != OS_SUCCESS, "OS_MutSemDelete, Old ID"); - + status = OS_MutSemDelete(mut_0); /* UtDebug("Status after deleteing Mut 0:%d\n",status); */ UtAssert_True(status == OS_SUCCESS, "OS_MutSemDelete, Mut 0"); @@ -529,30 +513,28 @@ void TestMutexes(void) status = OS_MutSemDelete(mut_3); /* UtDebug("Status after deleteing Mut 3:%d\n",status); */ UtAssert_True(status == OS_SUCCESS, "OS_MutSemDelete, Mut 3"); - -} /* end TestMutexes */ - +} /* end TestMutexes */ /* These next several tasks simply initialize the ids to a number which * cannot occur in the system itself. This helps avoid confusion when a create - * fails, and the previous value of the id is displayed + * fails, and the previous value of the id is displayed * */ /* ************************************************************************** */ void InitializeTaskIds(void) { - task_0_id = OS_OBJECT_ID_UNDEFINED; - task_1_id = OS_OBJECT_ID_UNDEFINED; - task_2_id = OS_OBJECT_ID_UNDEFINED; - task_3_id = OS_OBJECT_ID_UNDEFINED; - task_4_id = OS_OBJECT_ID_UNDEFINED; - task_5_id = OS_OBJECT_ID_UNDEFINED; - task_6_id = OS_OBJECT_ID_UNDEFINED; - task_7_id = OS_OBJECT_ID_UNDEFINED; - task_8_id = OS_OBJECT_ID_UNDEFINED; - task_9_id = OS_OBJECT_ID_UNDEFINED; + task_0_id = OS_OBJECT_ID_UNDEFINED; + task_1_id = OS_OBJECT_ID_UNDEFINED; + task_2_id = OS_OBJECT_ID_UNDEFINED; + task_3_id = OS_OBJECT_ID_UNDEFINED; + task_4_id = OS_OBJECT_ID_UNDEFINED; + task_5_id = OS_OBJECT_ID_UNDEFINED; + task_6_id = OS_OBJECT_ID_UNDEFINED; + task_7_id = OS_OBJECT_ID_UNDEFINED; + task_8_id = OS_OBJECT_ID_UNDEFINED; + task_9_id = OS_OBJECT_ID_UNDEFINED; task_10_id = OS_OBJECT_ID_UNDEFINED; task_11_id = OS_OBJECT_ID_UNDEFINED; task_12_id = OS_OBJECT_ID_UNDEFINED; @@ -568,90 +550,86 @@ void InitializeTaskIds(void) return; } /* end InitializeTaskIds */ - /* **************************************************************************** */ void InitializeQIds(void) { - msgq_0 = OS_OBJECT_ID_UNDEFINED; - msgq_1 = OS_OBJECT_ID_UNDEFINED; - msgq_2 = OS_OBJECT_ID_UNDEFINED; - msgq_3 = OS_OBJECT_ID_UNDEFINED; - msgq_4 = OS_OBJECT_ID_UNDEFINED; - msgq_5 = OS_OBJECT_ID_UNDEFINED; - msgq_6 = OS_OBJECT_ID_UNDEFINED; - msgq_7 = OS_OBJECT_ID_UNDEFINED; - msgq_8 = OS_OBJECT_ID_UNDEFINED; - msgq_9 = OS_OBJECT_ID_UNDEFINED; + msgq_0 = OS_OBJECT_ID_UNDEFINED; + msgq_1 = OS_OBJECT_ID_UNDEFINED; + msgq_2 = OS_OBJECT_ID_UNDEFINED; + msgq_3 = OS_OBJECT_ID_UNDEFINED; + msgq_4 = OS_OBJECT_ID_UNDEFINED; + msgq_5 = OS_OBJECT_ID_UNDEFINED; + msgq_6 = OS_OBJECT_ID_UNDEFINED; + msgq_7 = OS_OBJECT_ID_UNDEFINED; + msgq_8 = OS_OBJECT_ID_UNDEFINED; + msgq_9 = OS_OBJECT_ID_UNDEFINED; msgq_10 = OS_OBJECT_ID_UNDEFINED; msgq_id = OS_OBJECT_ID_UNDEFINED; - - return; -} /* end InitializeQIds */ + return; +} /* end InitializeQIds */ /* ***************************************************************************** */ void InitializeBinIds(void) { - bin_0 = OS_OBJECT_ID_UNDEFINED; - bin_1 = OS_OBJECT_ID_UNDEFINED; - bin_2 = OS_OBJECT_ID_UNDEFINED; - bin_3 = OS_OBJECT_ID_UNDEFINED; - bin_4 = OS_OBJECT_ID_UNDEFINED; - bin_5 = OS_OBJECT_ID_UNDEFINED; - bin_6 = OS_OBJECT_ID_UNDEFINED; - bin_7 = OS_OBJECT_ID_UNDEFINED; - bin_8 = OS_OBJECT_ID_UNDEFINED; - bin_9 = OS_OBJECT_ID_UNDEFINED; + bin_0 = OS_OBJECT_ID_UNDEFINED; + bin_1 = OS_OBJECT_ID_UNDEFINED; + bin_2 = OS_OBJECT_ID_UNDEFINED; + bin_3 = OS_OBJECT_ID_UNDEFINED; + bin_4 = OS_OBJECT_ID_UNDEFINED; + bin_5 = OS_OBJECT_ID_UNDEFINED; + bin_6 = OS_OBJECT_ID_UNDEFINED; + bin_7 = OS_OBJECT_ID_UNDEFINED; + bin_8 = OS_OBJECT_ID_UNDEFINED; + bin_9 = OS_OBJECT_ID_UNDEFINED; bin_10 = OS_OBJECT_ID_UNDEFINED; return; } /* end InitializeBinIds */ - /* ***************************************************************************** */ void InitializeMutIds(void) { - mut_0 = OS_OBJECT_ID_UNDEFINED; - mut_1 = OS_OBJECT_ID_UNDEFINED; - mut_2 = OS_OBJECT_ID_UNDEFINED; - mut_3 = OS_OBJECT_ID_UNDEFINED; - mut_4 = OS_OBJECT_ID_UNDEFINED; - mut_5 = OS_OBJECT_ID_UNDEFINED; - mut_6 = OS_OBJECT_ID_UNDEFINED; - mut_7 = OS_OBJECT_ID_UNDEFINED; - mut_8 = OS_OBJECT_ID_UNDEFINED; - mut_9 = OS_OBJECT_ID_UNDEFINED; + mut_0 = OS_OBJECT_ID_UNDEFINED; + mut_1 = OS_OBJECT_ID_UNDEFINED; + mut_2 = OS_OBJECT_ID_UNDEFINED; + mut_3 = OS_OBJECT_ID_UNDEFINED; + mut_4 = OS_OBJECT_ID_UNDEFINED; + mut_5 = OS_OBJECT_ID_UNDEFINED; + mut_6 = OS_OBJECT_ID_UNDEFINED; + mut_7 = OS_OBJECT_ID_UNDEFINED; + mut_8 = OS_OBJECT_ID_UNDEFINED; + mut_9 = OS_OBJECT_ID_UNDEFINED; mut_10 = OS_OBJECT_ID_UNDEFINED; return; } /* end InitializeMutIds */ /* ***************************************************************************** */ void TestGetInfos(void) { - int status; - OS_task_prop_t task_prop; - OS_queue_prop_t queue_prop; - OS_bin_sem_prop_t bin_prop; - OS_mut_sem_prop_t mut_prop; - + int status; + OS_task_prop_t task_prop; + OS_queue_prop_t queue_prop; + OS_bin_sem_prop_t bin_prop; + OS_mut_sem_prop_t mut_prop; + /* first step is to create an object to to get the properties of */ - - status = OS_TaskCreate( &task_0_id, "Task 0", task_0, task_0_stack, - TASK_0_STACK_SIZE, TASK_0_PRIORITY, 0); + + status = OS_TaskCreate(&task_0_id, "Task 0", task_0, task_0_stack, TASK_0_STACK_SIZE, TASK_0_PRIORITY, 0); UtAssert_True(status == OS_SUCCESS, "OS_TaskCreate"); - status = OS_QueueCreate( &msgq_0, "q 0", MSGQ_DEPTH, MSGQ_SIZE, 0); - /* UtDebug("Status after Creating q 0: %d,%d\n",status,msgq_0); */ + status = OS_QueueCreate(&msgq_0, "q 0", MSGQ_DEPTH, MSGQ_SIZE, 0); + /* UtDebug("Status after Creating q 0: %d,%d\n",status,msgq_0); */ UtAssert_True(status == OS_SUCCESS, "OS_QueueCreate"); - status = OS_BinSemCreate( &bin_0,"Bin 0",1,0); - /* UtDebug("Status after creating: %d,%d\n",status,bin_0); */ + status = OS_BinSemCreate(&bin_0, "Bin 0", 1, 0); + /* UtDebug("Status after creating: %d,%d\n",status,bin_0); */ UtAssert_True(status == OS_SUCCESS, "OS_BinSemCreate"); - status = OS_MutSemCreate( &mut_0,"Mut 0",0); - /* UtDebug("Status after creating: %d,%d\n",status,mut_0); */ + status = OS_MutSemCreate(&mut_0, "Mut 0", 0); + /* UtDebug("Status after creating: %d,%d\n",status,mut_0); */ UtAssert_True(status == OS_SUCCESS, "OS_MutSemCreate"); /* Next Step is to get the properties of the objects */ - + status = OS_TaskGetInfo(task_0_id, &task_prop); UtAssert_True(status == OS_SUCCESS, "OS_TaskGetInfo"); @@ -664,21 +642,19 @@ void TestGetInfos(void) status = OS_MutSemGetInfo(mut_0, &mut_prop); UtAssert_True(status == OS_SUCCESS, "OS_MutSemGetInfo"); - status = OS_TaskDelete(task_0_id); UtAssert_True(status == OS_SUCCESS, "OS_TaskDelete"); status = OS_QueueDelete(msgq_0); UtAssert_True(status == OS_SUCCESS, "OS_QueueDelete"); - /* UtDebug("Status after Deleting q 0: %d\n",status); */ - + /* UtDebug("Status after Deleting q 0: %d\n",status); */ + status = OS_BinSemDelete(bin_0); - /* UtDebug("Status after deleteing:%d\n",status); */ + /* UtDebug("Status after deleteing:%d\n",status); */ UtAssert_True(status == OS_SUCCESS, "OS_BinSemDelete"); - status = OS_MutSemDelete(mut_0); - /* UtDebug("Status after deleteing:%d\n",status); */ + /* UtDebug("Status after deleteing:%d\n",status); */ UtAssert_True(status == OS_SUCCESS, "OS_MutSemDelete"); } @@ -688,21 +664,20 @@ void TestGetInfos(void) */ void TestGenericQueries(void) { - int status; + int status; TestCallbackState_t State; - char ResourceName[OS_MAX_API_NAME]; + char ResourceName[OS_MAX_API_NAME]; - status = OS_TaskCreate( &task_0_id, "Task 0", task_0, task_0_stack, - TASK_0_STACK_SIZE, TASK_0_PRIORITY, 0); + status = OS_TaskCreate(&task_0_id, "Task 0", task_0, task_0_stack, TASK_0_STACK_SIZE, TASK_0_PRIORITY, 0); UtAssert_True(status == OS_SUCCESS, "OS_TaskCreate (%ld) == OS_SUCCESS", (long)status); - status = OS_QueueCreate( &msgq_0, "q 0", MSGQ_DEPTH, MSGQ_SIZE, 0); + status = OS_QueueCreate(&msgq_0, "q 0", MSGQ_DEPTH, MSGQ_SIZE, 0); UtAssert_True(status == OS_SUCCESS, "OS_QueueCreate (%ld) == OS_SUCCESS", (long)status); - status = OS_BinSemCreate( &bin_0,"Bin 0",1,0); + status = OS_BinSemCreate(&bin_0, "Bin 0", 1, 0); UtAssert_True(status == OS_SUCCESS, "OS_BinSemCreate (%ld) == OS_SUCCESS", (long)status); - status = OS_MutSemCreate( &mut_0,"Mut 0",0); + status = OS_MutSemCreate(&mut_0, "Mut 0", 0); UtAssert_True(status == OS_SUCCESS, "OS_MutSemCreate (%ld) == OS_SUCCESS", (long)status); /* The "OS_ForEachObjectOfType()" should callback for only a specific object type - @@ -711,13 +686,13 @@ void TestGenericQueries(void) OS_ForEachObjectOfType(OS_OBJECT_TYPE_OS_TASK, OS_OBJECT_CREATOR_ANY, TestForEachCallback, &State); UtAssert_True(State.NumInvocations == 1, "Task NumInvocations (%lu) == 1", (unsigned long)State.NumInvocations); UtAssert_True(OS_ObjectIdEqual(State.ObjList[0], task_0_id), "Task ObjList[0] (%lx) == %lx", - OS_ObjectIdToInteger(State.ObjList[0]), OS_ObjectIdToInteger(task_0_id)); + OS_ObjectIdToInteger(State.ObjList[0]), OS_ObjectIdToInteger(task_0_id)); memset(&State, 0, sizeof(State)); OS_ForEachObjectOfType(OS_OBJECT_TYPE_OS_BINSEM, OS_OBJECT_CREATOR_ANY, TestForEachCallback, &State); UtAssert_True(State.NumInvocations == 1, "BinSem NumInvocations (%lu) == 1", (unsigned long)State.NumInvocations); UtAssert_True(OS_ObjectIdEqual(State.ObjList[0], bin_0), "BinSem ObjList[0] (%lx) == %lx", - OS_ObjectIdToInteger(State.ObjList[0]), OS_ObjectIdToInteger(bin_0)); + OS_ObjectIdToInteger(State.ObjList[0]), OS_ObjectIdToInteger(bin_0)); memset(&State, 0, sizeof(State)); OS_ForEachObjectOfType(OS_OBJECT_TYPE_OS_COUNTSEM, OS_OBJECT_CREATOR_ANY, TestForEachCallback, &State); @@ -738,22 +713,21 @@ void TestGenericQueries(void) /* Test the OS_GetResourceName() API function */ status = OS_GetResourceName(mut_0, ResourceName, 0); UtAssert_True(status == OS_INVALID_POINTER, "OS_GetResourceName (%lx,%ld) == OS_INVALID_POINTER", - OS_ObjectIdToInteger(mut_0), (long)status); + OS_ObjectIdToInteger(mut_0), (long)status); status = OS_GetResourceName(msgq_0, ResourceName, sizeof(ResourceName)); - UtAssert_True(status == OS_SUCCESS, "OS_GetResourceName (%lx,%ld) == OS_SUCCESS", - OS_ObjectIdToInteger(msgq_0), (long)status); + UtAssert_True(status == OS_SUCCESS, "OS_GetResourceName (%lx,%ld) == OS_SUCCESS", OS_ObjectIdToInteger(msgq_0), + (long)status); UtAssert_StrCmp(ResourceName, "q 0", "Output value correct"); status = OS_GetResourceName(OS_OBJECT_ID_UNDEFINED, ResourceName, sizeof(ResourceName)); UtAssert_True(status == OS_ERR_INVALID_ID, "OS_GetResourceName (%lx,%ld) == OS_ERR_INVALID_ID", - OS_ObjectIdToInteger(OS_OBJECT_ID_UNDEFINED), (long)status); + OS_ObjectIdToInteger(OS_OBJECT_ID_UNDEFINED), (long)status); status = OS_GetResourceName(bin_0, ResourceName, 1); UtAssert_True(status == OS_ERR_NAME_TOO_LONG, "OS_GetResourceName (%lx,%ld) == OS_ERR_NAME_TOO_LONG", - OS_ObjectIdToInteger(bin_0), (long)status); + OS_ObjectIdToInteger(bin_0), (long)status); /* The OS_DeleteAllObjects() should clean up every object created here. */ OS_DeleteAllObjects(); } - diff --git a/src/tests/osal-core-test/osal-core-test.h b/src/tests/osal-core-test/osal-core-test.h index fc3d3c114..0bc5ea052 100644 --- a/src/tests/osal-core-test/osal-core-test.h +++ b/src/tests/osal-core-test/osal-core-test.h @@ -24,7 +24,7 @@ * This is a simple header file used to remove a lot of the task definitions * from the example1.c file so as to make that code easier to read * - * + * * * */ @@ -216,8 +216,6 @@ uint32 task_20_stack[TASK_20_STACK_SIZE]; void task_20(void); - - /* Global Data */ /* Task Id's for testing the number of tasks that can be created */ @@ -236,36 +234,32 @@ osal_id_t msgq_10; osal_id_t msgq_id; - -osal_id_t bin_0, bin_1, bin_2, bin_3, bin_4,bin_5, bin_6; +osal_id_t bin_0, bin_1, bin_2, bin_3, bin_4, bin_5, bin_6; osal_id_t bin_7, bin_8, bin_9, bin_10; - -osal_id_t mut_0, mut_1, mut_2, mut_3, mut_4,mut_5, mut_6; -osal_id_t mut_7, mut_8 ,mut_9, mut_10; +osal_id_t mut_0, mut_1, mut_2, mut_3, mut_4, mut_5, mut_6; +osal_id_t mut_7, mut_8, mut_9, mut_10; osal_id_t mutex_id; uint32 shared_resource_x; -#define MSGQ_DEPTH 50 -#define MSGQ_SIZE 4 - -#define PASS 0 -#define FAIL 1 - +#define MSGQ_DEPTH 50 +#define MSGQ_SIZE 4 +#define PASS 0 +#define FAIL 1 /* ********************** TASK 0 **************************** */ void task_0(void) -{ +{ OS_TaskRegister(); - - while(1); - return; -} /* end task_0 */ + while (1) + ; + return; +} /* end task_0 */ /* ********************** TASK 1 **************************** */ @@ -274,19 +268,20 @@ void task_1(void) OS_TaskRegister(); - while(1); - - return; -} /* end task_1 */ + while (1) + ; + return; +} /* end task_1 */ /* ********************** TASK 2 **************************** */ void task_2(void) -{ +{ OS_TaskRegister(); - - while(1); + + while (1) + ; return; } /* end task_2 */ @@ -297,11 +292,11 @@ void task_3(void) { OS_TaskRegister(); - while(1); - - return; + while (1) + ; + + return; } /* end task_3 */ - /* ********************** TASK 4 **************************** */ @@ -309,11 +304,11 @@ void task_4(void) { OS_TaskRegister(); - while(1); - - return; -}/* end task_4 */ - + while (1) + ; + + return; +} /* end task_4 */ /* ********************** TASK 0 **************************** */ @@ -321,12 +316,12 @@ void task_5(void) { OS_TaskRegister(); - while(1); - - return; + while (1) + ; -}/* end task_5 */ - + return; + +} /* end task_5 */ /* ********************** TASK 6 **************************** */ @@ -334,12 +329,12 @@ void task_6(void) { OS_TaskRegister(); - while(1); - - return; + while (1) + ; + + return; } /* end task_6 */ - /* ********************** TASK 7 **************************** */ @@ -347,12 +342,12 @@ void task_7(void) { OS_TaskRegister(); - while(1); - - return; + while (1) + ; + + return; } /* end task_7 */ - /* ********************** TASK 8 **************************** */ @@ -360,13 +355,12 @@ void task_8(void) { OS_TaskRegister(); - while(1); - - return; + while (1) + ; -} /* end task_8 */ - + return; +} /* end task_8 */ /* ********************** TASK 9 **************************** */ @@ -374,13 +368,12 @@ void task_9(void) { OS_TaskRegister(); - while(1); - - return; + while (1) + ; -} /* end task_9 */ - + return; +} /* end task_9 */ /* ********************** TASK 10 **************************** */ @@ -388,13 +381,12 @@ void task_10(void) { OS_TaskRegister(); - while(1); - - return; + while (1) + ; + + return; } /* end task_10 */ - - /* ********************** TASK 11 **************************** */ @@ -402,13 +394,12 @@ void task_11(void) { OS_TaskRegister(); - while(1); - - return; + while (1) + ; -} /* end task_11 */ - + return; +} /* end task_11 */ /* ********************** TASK 12 **************************** */ @@ -416,12 +407,12 @@ void task_12(void) { OS_TaskRegister(); - while(1); - - return; + while (1) + ; + + return; } /* end task_12 */ - /* ********************** TASK 13 **************************** */ @@ -429,12 +420,12 @@ void task_13(void) { OS_TaskRegister(); - while(1); - - return; + while (1) + ; + + return; -}/* end task_13 */ - +} /* end task_13 */ /* ********************** TASK 14 **************************** */ @@ -442,13 +433,12 @@ void task_14(void) { OS_TaskRegister(); - while(1); - - return; + while (1) + ; -} /* end task_14 */ - + return; +} /* end task_14 */ /* ********************** TASK 15 **************************** */ @@ -456,13 +446,12 @@ void task_15(void) { OS_TaskRegister(); - while(1); - - return; + while (1) + ; -} /* end task_15 */ - + return; +} /* end task_15 */ /* ********************** TASK 16 **************************** */ @@ -470,13 +459,12 @@ void task_16(void) { OS_TaskRegister(); - while(1); - - return; + while (1) + ; -} /* end task_16 */ - + return; +} /* end task_16 */ /* ********************** TASK 17 **************************** */ @@ -484,12 +472,12 @@ void task_17(void) { OS_TaskRegister(); - while(1); - - return; + while (1) + ; + + return; } /* end task_17 */ - /* ********************** TASK 18 **************************** */ @@ -497,13 +485,12 @@ void task_18(void) { OS_TaskRegister(); - while(1); - - return; + while (1) + ; -} /* end task_18 */ - + return; +} /* end task_18 */ /* ********************** TASK 19 **************************** */ @@ -511,13 +498,12 @@ void task_19(void) { OS_TaskRegister(); - while(1); - - return; + while (1) + ; -} /* end task_19 */ - + return; +} /* end task_19 */ /* ********************** TASK 20 **************************** */ @@ -525,13 +511,9 @@ void task_20(void) { OS_TaskRegister(); - while(1); - - return; - -} /* end task_20 */ - - - + while (1) + ; + return; +} /* end task_20 */ diff --git a/src/tests/queue-timeout-test/queue-timeout-test.c b/src/tests/queue-timeout-test/queue-timeout-test.c index c5e31be72..0e05b6d5e 100644 --- a/src/tests/queue-timeout-test/queue-timeout-test.c +++ b/src/tests/queue-timeout-test/queue-timeout-test.c @@ -32,8 +32,8 @@ void QueueTimeoutSetup(void); void QueueTimeoutCheck(void); -#define MSGQ_DEPTH 50 -#define MSGQ_SIZE 4 +#define MSGQ_DEPTH 50 +#define MSGQ_SIZE 4 /* Task 1 */ #define TASK_1_STACK_SIZE 1024 @@ -41,31 +41,31 @@ void QueueTimeoutCheck(void); #define TASK_2_STACK_SIZE 1024 #define TASK_2_PRIORITY 50 -uint32 task_1_stack[TASK_1_STACK_SIZE]; +uint32 task_1_stack[TASK_1_STACK_SIZE]; osal_id_t task_1_id; -uint32 task_1_failures; -uint32 task_1_timeouts; -uint32 task_1_messages; -uint32 task_2_stack[TASK_2_STACK_SIZE]; +uint32 task_1_failures; +uint32 task_1_timeouts; +uint32 task_1_messages; +uint32 task_2_stack[TASK_2_STACK_SIZE]; osal_id_t task_2_id; osal_id_t msgq_id; -uint32 timer_counter; +uint32 timer_counter; osal_id_t timer_id; -uint32 timer_start = 10000; -uint32 timer_interval = 100000; /* 1000 = 1000 hz, 10000 == 100 hz */ -uint32 timer_accuracy; +uint32 timer_start = 10000; +uint32 timer_interval = 100000; /* 1000 = 1000 hz, 10000 == 100 hz */ +uint32 timer_accuracy; void TimerFunction(osal_id_t timer_id) { - timer_counter++; + timer_counter++; } void task_1(void) { - int32 status; - uint32 data_received; - uint32 data_size; + int32 status; + uint32 data_received; + uint32 data_size; OS_printf("Starting task 1\n"); @@ -75,25 +75,25 @@ void task_1(void) OS_TaskDelay(1000); /* if errors occur do not loop endlessly */ - while(task_1_failures < 20) + while (task_1_failures < 20) { - status = OS_QueueGet(msgq_id, (void*)&data_received, MSGQ_SIZE, &data_size, 1000); + status = OS_QueueGet(msgq_id, (void *)&data_received, MSGQ_SIZE, &data_size, 1000); - if ( status == OS_SUCCESS ) + if (status == OS_SUCCESS) { - ++task_1_messages; - OS_printf("TASK 1: Recieved a message on the queue\n"); + ++task_1_messages; + OS_printf("TASK 1: Recieved a message on the queue\n"); } - else if ( status == OS_QUEUE_TIMEOUT ) + else if (status == OS_QUEUE_TIMEOUT) { - ++task_1_timeouts; - OS_printf("TASK 1: Timeout on Queue! Timer counter = %u\n", (unsigned int)timer_counter); + ++task_1_timeouts; + OS_printf("TASK 1: Timeout on Queue! Timer counter = %u\n", (unsigned int)timer_counter); } else { - ++task_1_failures; - OS_printf("TASK 1: Queue Get error: %d!\n",(int)status); + ++task_1_failures; + OS_printf("TASK 1: Queue Get error: %d!\n", (int)status); OS_TaskDelay(10); } } @@ -101,31 +101,30 @@ void task_1(void) void QueueTimeoutCheck(void) { - int32 status; + int32 status; uint32 limit; - status = OS_TimerDelete(timer_id); + status = OS_TimerDelete(timer_id); UtAssert_True(status == OS_SUCCESS, "Timer delete Rc=%d", (int)status); status = OS_TaskDelete(task_1_id); UtAssert_True(status == OS_SUCCESS, "Task 1 delete Rc=%d", (int)status); /* None of the tasks should have any failures in their own counters */ - UtAssert_True(task_1_failures == 0, "Task 1 failures = %u",(unsigned int)task_1_failures); + UtAssert_True(task_1_failures == 0, "Task 1 failures = %u", (unsigned int)task_1_failures); /* * Since nothing currently sends messages, message count should be zero, * and timer counter =~ 10 + ( 10 x task_1_timeouts ) */ - UtAssert_True(task_1_messages == 0, "Task 1 messages = %u",(unsigned int)task_1_messages); + UtAssert_True(task_1_messages == 0, "Task 1 messages = %u", (unsigned int)task_1_messages); limit = (timer_counter / 10); - UtAssert_True(task_1_timeouts <= limit, "Task 1 timeouts %u <= %u", - (unsigned int)task_1_timeouts, (unsigned int)limit); + UtAssert_True(task_1_timeouts <= limit, "Task 1 timeouts %u <= %u", (unsigned int)task_1_timeouts, + (unsigned int)limit); limit = ((timer_counter - 20) / 12); - UtAssert_True(task_1_timeouts >= limit, "Task 1 timeouts %u >= %u", - (unsigned int)task_1_timeouts, (unsigned int)limit); - + UtAssert_True(task_1_timeouts >= limit, "Task 1 timeouts %u >= %u", (unsigned int)task_1_timeouts, + (unsigned int)limit); } void UtTest_Setup(void) @@ -143,41 +142,38 @@ void UtTest_Setup(void) void QueueTimeoutSetup(void) { - int32 status; - uint32 accuracy; - - task_1_failures = 0; - task_1_messages = 0; - task_1_timeouts = 0; - - status = OS_QueueCreate( &msgq_id, "MsgQ", MSGQ_DEPTH, MSGQ_SIZE, 0); - UtAssert_True(status == OS_SUCCESS, "MsgQ create Id=%lx Rc=%d", - OS_ObjectIdToInteger(msgq_id), (int)status); - - /* - ** Create the "consumer" task. - */ - status = OS_TaskCreate( &task_1_id, "Task 1", task_1, task_1_stack, TASK_1_STACK_SIZE, TASK_1_PRIORITY, 0); - UtAssert_True(status == OS_SUCCESS, "Task 1 create Id=%lx Rc=%d", - OS_ObjectIdToInteger(task_1_id), (int)status); - - /* - ** Create a timer - */ - status = OS_TimerCreate(&timer_id, "Timer 1", &accuracy, &(TimerFunction)); - UtAssert_True(status == OS_SUCCESS, "Timer 1 create Id=%lx Rc=%d", - OS_ObjectIdToInteger(timer_id), (int)status); - UtPrintf("Timer Accuracy = %u microseconds \n",(unsigned int)accuracy); - - /* - ** Start the timer - */ - status = OS_TimerSet(timer_id, timer_start, timer_interval); - UtAssert_True(status == OS_SUCCESS, "Timer 1 set Rc=%d", (int)status); - - /* allow some time for task to run and accrue queue timeouts */ - while (timer_counter < 100) - { - OS_TaskDelay(100); - } + int32 status; + uint32 accuracy; + + task_1_failures = 0; + task_1_messages = 0; + task_1_timeouts = 0; + + status = OS_QueueCreate(&msgq_id, "MsgQ", MSGQ_DEPTH, MSGQ_SIZE, 0); + UtAssert_True(status == OS_SUCCESS, "MsgQ create Id=%lx Rc=%d", OS_ObjectIdToInteger(msgq_id), (int)status); + + /* + ** Create the "consumer" task. + */ + status = OS_TaskCreate(&task_1_id, "Task 1", task_1, task_1_stack, TASK_1_STACK_SIZE, TASK_1_PRIORITY, 0); + UtAssert_True(status == OS_SUCCESS, "Task 1 create Id=%lx Rc=%d", OS_ObjectIdToInteger(task_1_id), (int)status); + + /* + ** Create a timer + */ + status = OS_TimerCreate(&timer_id, "Timer 1", &accuracy, &(TimerFunction)); + UtAssert_True(status == OS_SUCCESS, "Timer 1 create Id=%lx Rc=%d", OS_ObjectIdToInteger(timer_id), (int)status); + UtPrintf("Timer Accuracy = %u microseconds \n", (unsigned int)accuracy); + + /* + ** Start the timer + */ + status = OS_TimerSet(timer_id, timer_start, timer_interval); + UtAssert_True(status == OS_SUCCESS, "Timer 1 set Rc=%d", (int)status); + + /* allow some time for task to run and accrue queue timeouts */ + while (timer_counter < 100) + { + OS_TaskDelay(100); + } } diff --git a/src/tests/sem-speed-test/sem-speed-test.c b/src/tests/sem-speed-test/sem-speed-test.c index e9f5abace..6a9b59ca3 100644 --- a/src/tests/sem-speed-test/sem-speed-test.c +++ b/src/tests/sem-speed-test/sem-speed-test.c @@ -51,7 +51,7 @@ * the executive (init) task. Otherwise, the SemRun() * function may may never get CPU time to stop the test. */ -#define SEMTEST_TASK_PRIORITY 150 +#define SEMTEST_TASK_PRIORITY 150 /* * A limit for the maximum amount @@ -62,8 +62,7 @@ * work correctly. See note above * about priority requirements. */ -#define SEMTEST_WORK_LIMIT 10000000 - +#define SEMTEST_WORK_LIMIT 10000000 /* Define setup and test functions for UT assert */ void SemSetup(void); @@ -74,75 +73,75 @@ void SemRun(void); * * This resolves to a function name like e.g. OS_BinSemTake. */ -#define SEMCALL(type,op) OS_ ## type ## Sem ## op +#define SEMCALL(type, op) OS_##type##Sem##op /* * This test works with either binary or counting * semaphores. To switch between them, set this * to either "Bin" or "Count" without quotes. */ -#define SEMOP(op) SEMCALL(Count,op) +#define SEMOP(op) SEMCALL(Count, op) osal_id_t task_1_id; -uint32 task_1_work; +uint32 task_1_work; osal_id_t task_2_id; -uint32 task_2_work; +uint32 task_2_work; osal_id_t sem_id_1; osal_id_t sem_id_2; void task_1(void) { - uint32 status; + uint32 status; OS_printf("Starting task 1\n"); OS_TaskRegister(); - while(task_1_work < SEMTEST_WORK_LIMIT) + while (task_1_work < SEMTEST_WORK_LIMIT) { - status = SEMOP(Take)(sem_id_1); - if ( status != OS_SUCCESS ) - { - OS_printf("TASK 1: Error calling SemTake 1: %d\n", (int)status); - break; - } - - ++task_1_work; - - status = SEMOP(Give)(sem_id_2); - if ( status != OS_SUCCESS ) - { - OS_printf("TASK 1: Error calling SemGive 2: %d\n", (int)status); - break; - } + status = SEMOP(Take)(sem_id_1); + if (status != OS_SUCCESS) + { + OS_printf("TASK 1: Error calling SemTake 1: %d\n", (int)status); + break; + } + + ++task_1_work; + + status = SEMOP(Give)(sem_id_2); + if (status != OS_SUCCESS) + { + OS_printf("TASK 1: Error calling SemGive 2: %d\n", (int)status); + break; + } } } void task_2(void) { - uint32 status; + uint32 status; OS_printf("Starting task 2\n"); OS_TaskRegister(); - while(task_2_work < SEMTEST_WORK_LIMIT) + while (task_2_work < SEMTEST_WORK_LIMIT) { - status = SEMOP(Take)(sem_id_2); - if ( status != OS_SUCCESS ) - { - OS_printf("TASK 2: Error calling SemTake 2: %d\n", (int)status); - break; - } - - ++task_2_work; - - status = SEMOP(Give)(sem_id_1); - if ( status != OS_SUCCESS ) - { - OS_printf("TASK 2: Error calling SemGive 1: %d\n", (int)status); - break; - } + status = SEMOP(Take)(sem_id_2); + if (status != OS_SUCCESS) + { + OS_printf("TASK 2: Error calling SemTake 2: %d\n", (int)status); + break; + } + + ++task_2_work; + + status = SEMOP(Give)(sem_id_1); + if (status != OS_SUCCESS) + { + OS_printf("TASK 2: Error calling SemGive 1: %d\n", (int)status); + break; + } } } @@ -161,35 +160,31 @@ void UtTest_Setup(void) void SemSetup(void) { - uint32 status; - - task_1_work = 0; - task_2_work = 0; - - /* - ** Create the Bin semaphore - */ - status = SEMOP(Create)( &sem_id_1, "Sem1", 0, 0); - UtAssert_True(status == OS_SUCCESS, "Sem 1 create Id=%lx Rc=%d", - OS_ObjectIdToInteger(sem_id_1), (int)status); - status = SEMOP(Create)( &sem_id_2, "Sem2", 0, 0); - UtAssert_True(status == OS_SUCCESS, "Sem 2 create Id=%lx Rc=%d", - OS_ObjectIdToInteger(sem_id_2), (int)status); - - /* - ** Create the tasks - */ - status = OS_TaskCreate( &task_1_id, "Task 1", task_1, NULL, 4096, SEMTEST_TASK_PRIORITY, 0); - UtAssert_True(status == OS_SUCCESS, "Task 1 create Id=%lx Rc=%d", - OS_ObjectIdToInteger(task_1_id), (int)status); - - status = OS_TaskCreate( &task_2_id, "Task 2", task_2, NULL, 4096, SEMTEST_TASK_PRIORITY, 0); - UtAssert_True(status == OS_SUCCESS, "Task 2 create Id=%lx Rc=%d", - OS_ObjectIdToInteger(task_2_id), (int)status); - - /* A small delay just to allow the tasks - * to start and pend on the sem */ - OS_TaskDelay(10); + uint32 status; + + task_1_work = 0; + task_2_work = 0; + + /* + ** Create the Bin semaphore + */ + status = SEMOP(Create)(&sem_id_1, "Sem1", 0, 0); + UtAssert_True(status == OS_SUCCESS, "Sem 1 create Id=%lx Rc=%d", OS_ObjectIdToInteger(sem_id_1), (int)status); + status = SEMOP(Create)(&sem_id_2, "Sem2", 0, 0); + UtAssert_True(status == OS_SUCCESS, "Sem 2 create Id=%lx Rc=%d", OS_ObjectIdToInteger(sem_id_2), (int)status); + + /* + ** Create the tasks + */ + status = OS_TaskCreate(&task_1_id, "Task 1", task_1, NULL, 4096, SEMTEST_TASK_PRIORITY, 0); + UtAssert_True(status == OS_SUCCESS, "Task 1 create Id=%lx Rc=%d", OS_ObjectIdToInteger(task_1_id), (int)status); + + status = OS_TaskCreate(&task_2_id, "Task 2", task_2, NULL, 4096, SEMTEST_TASK_PRIORITY, 0); + UtAssert_True(status == OS_SUCCESS, "Task 2 create Id=%lx Rc=%d", OS_ObjectIdToInteger(task_2_id), (int)status); + + /* A small delay just to allow the tasks + * to start and pend on the sem */ + OS_TaskDelay(10); } void SemRun(void) @@ -208,20 +203,18 @@ void SemRun(void) ** NOTE: if the work limit was reached, the ** OS_TaskDelete calls may return non-success. */ - status = OS_TaskDelete( task_1_id ); + status = OS_TaskDelete(task_1_id); UtAssert_True(status == OS_SUCCESS, "Task 1 delete Rc=%d", (int)status); - status = OS_TaskDelete( task_2_id ); + status = OS_TaskDelete(task_2_id); UtAssert_True(status == OS_SUCCESS, "Task 2 delete Rc=%d", (int)status); - status = SEMOP(Delete)( sem_id_1 ); + status = SEMOP(Delete)(sem_id_1); UtAssert_True(status == OS_SUCCESS, "Sem 1 delete Rc=%d", (int)status); - status = SEMOP(Delete)( sem_id_2 ); + status = SEMOP(Delete)(sem_id_2); UtAssert_True(status == OS_SUCCESS, "Sem 2 delete Rc=%d", (int)status); - /* Task 1 and 2 should have both executed */ UtAssert_True(task_1_work != 0, "Task 1 work counter = %u", (unsigned int)task_1_work); UtAssert_True(task_2_work != 0, "Task 2 work counter = %u", (unsigned int)task_2_work); } - diff --git a/src/tests/symbol-api-test/symbol-api-test.c b/src/tests/symbol-api-test/symbol-api-test.c index f1aacee39..ee2002645 100644 --- a/src/tests/symbol-api-test/symbol-api-test.c +++ b/src/tests/symbol-api-test/symbol-api-test.c @@ -33,59 +33,60 @@ void TestSymbolApi(void) { #ifdef OS_INCLUDE_MODULE_LOADER - int32 status; + int32 status; cpuaddr SymAddress; /* Make the file system */ - status = OS_mkfs(0,"/ramdev0","RAM",512,2048); - UtAssert_True(status == OS_SUCCESS, "status after mkfs = %d",(int)status); + status = OS_mkfs(0, "/ramdev0", "RAM", 512, 2048); + UtAssert_True(status == OS_SUCCESS, "status after mkfs = %d", (int)status); - status = OS_mount("/ramdev0","/ram"); - UtAssert_True(status == OS_SUCCESS, "status after mount = %d",(int)status); - - /* - ** dump the symbol table with a 32768 byte limit - */ - UtPrintf("Dumping symbol table with a limit of 32768 bytes\n"); - status = OS_SymbolTableDump("/ram/SymbolTable32k.dat", 32768); - UtAssert_True(status == OS_SUCCESS || status == OS_ERR_NOT_IMPLEMENTED, - "status after 32k OS_SymbolTableDump = %d",(int)status); + status = OS_mount("/ramdev0", "/ram"); + UtAssert_True(status == OS_SUCCESS, "status after mount = %d", (int)status); - /* - ** dump the symbol table with a 128k byte limit - */ - UtPrintf("Dumping symbol table with a limit of 131072 bytes\n"); - status = OS_SymbolTableDump("/ram/SymbolTable128k.dat", 131072); - UtAssert_True(status == OS_SUCCESS || status == OS_ERR_NOT_IMPLEMENTED, - "status after 128k OS_SymbolTableDump = %d",(int)status); + /* + ** dump the symbol table with a 32768 byte limit + */ + UtPrintf("Dumping symbol table with a limit of 32768 bytes\n"); + status = OS_SymbolTableDump("/ram/SymbolTable32k.dat", 32768); + UtAssert_True(status == OS_SUCCESS || status == OS_ERR_NOT_IMPLEMENTED, "status after 32k OS_SymbolTableDump = %d", + (int)status); + + /* + ** dump the symbol table with a 128k byte limit + */ + UtPrintf("Dumping symbol table with a limit of 131072 bytes\n"); + status = OS_SymbolTableDump("/ram/SymbolTable128k.dat", 131072); + UtAssert_True(status == OS_SUCCESS || status == OS_ERR_NOT_IMPLEMENTED, "status after 128k OS_SymbolTableDump = %d", + (int)status); - /* - ** dump the symbol table with a 512k byte limit - */ - UtPrintf("Dumping symbol table with a limit of 524288 bytes\n"); - status = OS_SymbolTableDump("/ram/SymbolTable512k.dat", 524288); - UtAssert_True(status == OS_SUCCESS || status == OS_ERR_NOT_IMPLEMENTED, - "status after 512k OS_SymbolTableDump = %d",(int)status); + /* + ** dump the symbol table with a 512k byte limit + */ + UtPrintf("Dumping symbol table with a limit of 524288 bytes\n"); + status = OS_SymbolTableDump("/ram/SymbolTable512k.dat", 524288); + UtAssert_True(status == OS_SUCCESS || status == OS_ERR_NOT_IMPLEMENTED, "status after 512k OS_SymbolTableDump = %d", + (int)status); - /* - ** Test the symbol lookup - */ - status = OS_SymbolLookup (&SymAddress, "OS_Application_Startup" ); - UtAssert_True(status == OS_SUCCESS, "OS_SymbolLookup(OS_Application_Startup) = %d, Addr = %lx",(int)status,(unsigned long)SymAddress); + /* + ** Test the symbol lookup + */ + status = OS_SymbolLookup(&SymAddress, "OS_Application_Startup"); + UtAssert_True(status == OS_SUCCESS, "OS_SymbolLookup(OS_Application_Startup) = %d, Addr = %lx", (int)status, + (unsigned long)SymAddress); - /* - ** Test a symbol lookup that does not exist - */ - status = OS_SymbolLookup(&SymAddress, "ShouldNotExist"); - UtAssert_True(status != OS_SUCCESS, "OS_SymbolLookup(ShouldNotExist) = %d, Addr = %lx",(int)status,(unsigned long)SymAddress); + /* + ** Test a symbol lookup that does not exist + */ + status = OS_SymbolLookup(&SymAddress, "ShouldNotExist"); + UtAssert_True(status != OS_SUCCESS, "OS_SymbolLookup(ShouldNotExist) = %d, Addr = %lx", (int)status, + (unsigned long)SymAddress); #else - /* If the module loader is not present, generate an N/A test case just to indicate that the test ran */ - UtAssert_True(1, "Module loader not present"); + /* If the module loader is not present, generate an N/A test case just to indicate that the test ran */ + UtAssert_True(1, "Module loader not present"); #endif } /* end TestSymbolApi */ - void UtTest_Setup(void) { if (OS_API_Init() != OS_SUCCESS) @@ -98,4 +99,3 @@ void UtTest_Setup(void) */ UtTest_Add(TestSymbolApi, NULL, NULL, "SymbolApiTest"); } - diff --git a/src/tests/time-base-api-test/time-base-api-test.c b/src/tests/time-base-api-test/time-base-api-test.c index 3ebbfde6b..95ff39e73 100644 --- a/src/tests/time-base-api-test/time-base-api-test.c +++ b/src/tests/time-base-api-test/time-base-api-test.c @@ -41,22 +41,21 @@ static uint32 UT_TimerSync(uint32 timer_id) return 1; } - /* *************************************** MAIN ************************************** */ void TestTimeBaseApi(void) { - int32 expected; - int32 actual; - int32 TimeBaseNum; - int32 tbc_results[OS_MAX_TIMEBASES]; - uint32 freerun; - osal_id_t objid; - osal_id_t time_base_id; - osal_id_t time_base_id2; - osal_id_t tb_id[OS_MAX_TIMEBASES]; - char overMaxTimeBase[12]; - char TimeBaseIter[OS_MAX_TIMEBASES][12]; + int32 expected; + int32 actual; + int32 TimeBaseNum; + int32 tbc_results[OS_MAX_TIMEBASES]; + uint32 freerun; + osal_id_t objid; + osal_id_t time_base_id; + osal_id_t time_base_id2; + osal_id_t tb_id[OS_MAX_TIMEBASES]; + char overMaxTimeBase[12]; + char TimeBaseIter[OS_MAX_TIMEBASES][12]; OS_timebase_prop_t timebase_prop; /* @@ -67,7 +66,7 @@ void TestTimeBaseApi(void) /* Test for nominal inputs */ expected = OS_SUCCESS; - actual= OS_TimeBaseCreate(&time_base_id, "TimeBaseA", 0); + actual = OS_TimeBaseCreate(&time_base_id, "TimeBaseA", 0); UtAssert_True(actual == expected, "OS_TimeBaseCreate() (%ld) == OS_SUCCESS", (long)actual); actual = OS_TimeBaseCreate(&time_base_id2, "TimeBaseB", NULL); @@ -77,13 +76,12 @@ void TestTimeBaseApi(void) UtAssert_True(actual == expected, "OS_TimeBaseCreate() (%ld) == OS_SUCCESS", (long)actual); /* Test for nominal, max/min cases */ - objid = OS_OBJECT_ID_UNDEFINED; + objid = OS_OBJECT_ID_UNDEFINED; actual = OS_TimeBaseCreate(&objid, "TimeBaseD", 0); UtAssert_True(actual == expected, "OS_TimeBaseCreate() (%ld) == OS_SUCCESS", (long)actual); - /* Checking for OS_MAX_TIMEBASES */ - for ( int i = 0; i < OS_MAX_TIMEBASES; i++ ) + for (int i = 0; i < OS_MAX_TIMEBASES; i++) { snprintf(TimeBaseIter[i], 12, "TimeBase%d", i); tbc_results[i] = OS_TimeBaseCreate(&tb_id[i], TimeBaseIter[i], 0); @@ -92,38 +90,35 @@ void TestTimeBaseApi(void) OS_TimeBaseDelete(tb_id[i]); } - /* Test for invalid inputs */ expected = OS_INVALID_POINTER; - actual = OS_TimeBaseCreate(NULL, NULL, NULL); + actual = OS_TimeBaseCreate(NULL, NULL, NULL); UtAssert_True(actual == expected, "OS_TimeBaseCreate() (%ld) == OS_INVALID_POINTER", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_TimeBaseCreate(NULL, "TimeBase6", 0); + actual = OS_TimeBaseCreate(NULL, "TimeBase6", 0); UtAssert_True(actual == expected, "OS_TimeBaseCreate() (%ld) == OS_INVALID_POINTER", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_TimeBaseCreate(&time_base_id, NULL, 0); + actual = OS_TimeBaseCreate(&time_base_id, NULL, 0); UtAssert_True(actual == expected, "OS_TimeBaseCreate() (%ld) == OS_INVALID_POINTER", (long)actual); expected = OS_ERR_NAME_TAKEN; - actual= OS_TimeBaseCreate(&time_base_id, "TimeBaseA", 0); + actual = OS_TimeBaseCreate(&time_base_id, "TimeBaseA", 0); UtAssert_True(actual == expected, "OS_TimeBaseCreate() (%ld) == OS_ERR_NAME_TAKEN", (long)actual); /* Checking OS_MAX_TIMEBASES + 1 */ - for ( int i = 0; i < OS_MAX_TIMEBASES; i++ ) + for (int i = 0; i < OS_MAX_TIMEBASES; i++) { snprintf(TimeBaseIter[i], sizeof(TimeBaseIter[i]), "TimeBase%d", i); tbc_results[i] = OS_TimeBaseCreate(&tb_id[i], TimeBaseIter[i], 0); } - TimeBaseNum = OS_MAX_TIMEBASES+1; + TimeBaseNum = OS_MAX_TIMEBASES + 1; snprintf(overMaxTimeBase, sizeof(overMaxTimeBase), "TimeBase%d", (int)TimeBaseNum); expected = OS_ERR_NO_FREE_IDS; - actual= OS_TimeBaseCreate(&time_base_id, "overMaxTimeBase", 0); + actual = OS_TimeBaseCreate(&time_base_id, "overMaxTimeBase", 0); UtAssert_True(actual == expected, "OS_TimeBaseCreate() (%ld) == OS_ERR_NO_FREE_IDS", (long)actual); - - /* * Test Case For: * int32 OS_TimeBaseSet(uint32 timer_id, uint32 start_time, uint32 interval_time) @@ -131,36 +126,35 @@ void TestTimeBaseApi(void) /* Test for nominal inputs */ expected = OS_SUCCESS; - actual = OS_TimeBaseSet(time_base_id, 1000, 1000); + actual = OS_TimeBaseSet(time_base_id, 1000, 1000); UtAssert_True(actual == expected, "OS_TimeBaseSet() (%ld) == OS_SUCCESS", (long)actual); expected = OS_SUCCESS; - actual = OS_TimeBaseSet(time_base_id, 0, 0); + actual = OS_TimeBaseSet(time_base_id, 0, 0); UtAssert_True(actual == expected, "OS_TimeBaseSet() (%ld) == OS_SUCCESS", (long)actual); /* Test for invalid inputs */ /* overflow on input */ expected = OS_TIMER_ERR_INVALID_ARGS; - actual = OS_TimeBaseSet(time_base_id, UINT32_MAX, UINT32_MAX); + actual = OS_TimeBaseSet(time_base_id, UINT32_MAX, UINT32_MAX); UtAssert_True(actual == expected, "OS_TimeBaseSet() (%ld) == OS_TIMER_ERR_INVALID_ARGS", (long)actual); expected = OS_TIMER_ERR_INVALID_ARGS; - actual = OS_TimeBaseSet(time_base_id, -1000, -1000); + actual = OS_TimeBaseSet(time_base_id, -1000, -1000); UtAssert_True(actual == expected, "OS_TimeBaseSet() (%ld) == OS_TIMER_ERR_INVALID_ARGS", (long)actual); expected = OS_TIMER_ERR_INVALID_ARGS; - actual = OS_TimeBaseSet(time_base_id, 1000, -1000); + actual = OS_TimeBaseSet(time_base_id, 1000, -1000); UtAssert_True(actual == expected, "OS_TimeBaseSet() (%ld) == OS_TIMER_ERR_INVALID_ARGS", (long)actual); expected = OS_TIMER_ERR_INVALID_ARGS; - actual = OS_TimeBaseSet(time_base_id, -1000, 1000); + actual = OS_TimeBaseSet(time_base_id, -1000, 1000); UtAssert_True(actual == expected, "OS_TimeBaseSet() (%ld) == OS_TIMER_ERR_INVALID_ARGS", (long)actual); expected = OS_ERR_INVALID_ID; - actual = OS_TimeBaseSet(OS_OBJECT_ID_UNDEFINED, 1000, 1000); + actual = OS_TimeBaseSet(OS_OBJECT_ID_UNDEFINED, 1000, 1000); UtAssert_True(actual == expected, "OS_TimeBaseSet() (%ld) == OS_ERR_INVALID_ID", (long)actual); - /* * Test Case For: * int32 OS_TimeBaseDelete(uint32 timer_id) @@ -168,12 +162,12 @@ void TestTimeBaseApi(void) /* Test for nominal inputs */ expected = OS_SUCCESS; - actual = OS_TimeBaseDelete(time_base_id); + actual = OS_TimeBaseDelete(time_base_id); UtAssert_True(actual == expected, "OS_TimeBaseDelete() (%ld) == OS_SUCCESS", (long)actual); /* Test for invalid inputs */ expected = OS_ERR_INVALID_ID; - actual = OS_TimeBaseDelete(OS_OBJECT_ID_UNDEFINED); + actual = OS_TimeBaseDelete(OS_OBJECT_ID_UNDEFINED); UtAssert_True(actual == expected, "OS_TimeBaseDelete() (%ld) == OS_ERR_INVALID_ID", (long)actual); /* @@ -184,26 +178,24 @@ void TestTimeBaseApi(void) /* Test for nominal inputs */ /* Note: TimeBase2 was created above using TimeBaseCreate and id was set to time_base_id2 */ expected = OS_SUCCESS; - objid = OS_OBJECT_ID_UNDEFINED; - actual = OS_TimeBaseGetIdByName(&objid, "TimeBaseB"); + objid = OS_OBJECT_ID_UNDEFINED; + actual = OS_TimeBaseGetIdByName(&objid, "TimeBaseB"); UtAssert_True(actual == expected, "OS_TimeBaseGetIdByName() (%ld) == OS_SUCCESS", (long)actual); UtAssert_True(OS_ObjectIdEqual(objid, time_base_id2), "OS_TimeBaseGetIdByName() objid (%lu) Matches!", - OS_ObjectIdToInteger(objid)); - + OS_ObjectIdToInteger(objid)); /* Test for invalid inputs */ expected = OS_ERR_NAME_NOT_FOUND; - objid = OS_OBJECT_ID_UNDEFINED; - actual = OS_TimeBaseGetIdByName(&objid, "NF"); - UtAssert_True(actual == expected, "OS_TimeBaseGetIdByName() (%ld) == OS_ERR_NAME_NOT_FOUND",(long)actual); + objid = OS_OBJECT_ID_UNDEFINED; + actual = OS_TimeBaseGetIdByName(&objid, "NF"); + UtAssert_True(actual == expected, "OS_TimeBaseGetIdByName() (%ld) == OS_ERR_NAME_NOT_FOUND", (long)actual); UtAssert_True(!OS_ObjectIdDefined(objid), "OS_TimeBaseGetIdByName() objid (%lu) still OS_OBJECT_ID_UNDEFINED", - OS_ObjectIdToInteger(objid)); + OS_ObjectIdToInteger(objid)); expected = OS_INVALID_POINTER; - actual = OS_TimeBaseGetIdByName(NULL, NULL); + actual = OS_TimeBaseGetIdByName(NULL, NULL); UtAssert_True(actual == expected, "OS_TimeBaseGetIdByName() (%ld) == OS_INVALID_POINTER", (long)actual); - /* * Test Case For: * int32 OS_TimeBaseGetInfo (uint32 timebase_id, OS_timebase_prop_t *timebase_prop) @@ -221,26 +213,23 @@ void TestTimeBaseApi(void) UtAssert_True(actual == expected, "OS_TimeBaseGetInfo() (%ld) == OS_SUCCESS", (long)actual); UtAssert_True(!OS_ObjectIdDefined(timebase_prop.creator), "timebase_prop.creator (%lu) undefined", - OS_ObjectIdToInteger(timebase_prop.creator)); + OS_ObjectIdToInteger(timebase_prop.creator)); UtAssert_True(strcmp(timebase_prop.name, "TimeBaseB") == 0, "timebase_prop.name (%s) == TimeBase2", - timebase_prop.name); - UtAssert_True(timebase_prop.nominal_interval_time == 0, - "timebase_prop.nominal_interval_time (%lu) == 0", - (unsigned long)timebase_prop.nominal_interval_time); - UtAssert_True(timebase_prop.freerun_time == 0, - "timebase_prop.freerun_time (%lu) == 0", - (unsigned long)timebase_prop.freerun_time); - UtAssert_True(timebase_prop.accuracy >= 0, - "timebase_prop.accuracy (%lu) >= 0", - (unsigned long)timebase_prop.accuracy); + timebase_prop.name); + UtAssert_True(timebase_prop.nominal_interval_time == 0, "timebase_prop.nominal_interval_time (%lu) == 0", + (unsigned long)timebase_prop.nominal_interval_time); + UtAssert_True(timebase_prop.freerun_time == 0, "timebase_prop.freerun_time (%lu) == 0", + (unsigned long)timebase_prop.freerun_time); + UtAssert_True(timebase_prop.accuracy >= 0, "timebase_prop.accuracy (%lu) >= 0", + (unsigned long)timebase_prop.accuracy); /* Test for invalid inputs */ expected = OS_ERR_INVALID_ID; - actual = OS_TimeBaseGetInfo(OS_OBJECT_ID_UNDEFINED, &timebase_prop); + actual = OS_TimeBaseGetInfo(OS_OBJECT_ID_UNDEFINED, &timebase_prop); UtAssert_True(actual == expected, "OS_TimeBaseGetInfo() (%ld) == OS_ERR_INVALID_ID", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_TimeBaseGetInfo(time_base_id2, NULL); + actual = OS_TimeBaseGetInfo(time_base_id2, NULL); UtAssert_True(actual == expected, "OS_TimeBaseGetInfo() (%ld) == OS_INVALID_POINTER", (long)actual); /* @@ -253,25 +242,21 @@ void TestTimeBaseApi(void) expected = OS_SUCCESS; freerun = 0xFFFFFFFF; - actual = OS_TimeBaseGetFreeRun(time_base_id2, &freerun); + actual = OS_TimeBaseGetFreeRun(time_base_id2, &freerun); UtAssert_True(actual == expected, "OS_TimeBaseGetFreeRun() (%ld) == OS_SUCCESS", (long)actual); freerun = 0x0000000; - actual = OS_TimeBaseGetFreeRun(time_base_id2, &freerun); + actual = OS_TimeBaseGetFreeRun(time_base_id2, &freerun); UtAssert_True(actual == expected, "OS_TimeBaseGetFreeRun() (%ld) == OS_SUCCESS", (long)actual); /* Test for invalid inputs */ expected = OS_ERR_INVALID_ID; - freerun = 0xFFFFFFFF; - actual = OS_TimeBaseGetFreeRun(OS_OBJECT_ID_UNDEFINED, &freerun); + freerun = 0xFFFFFFFF; + actual = OS_TimeBaseGetFreeRun(OS_OBJECT_ID_UNDEFINED, &freerun); UtAssert_True(actual == expected, "OS_TimeBaseGetFreeRun() (%ld) == OS_SUCCESS", (long)actual); - - - } /* end TestTimeBaseApi */ - void UtTest_Setup(void) { if (OS_API_Init() != OS_SUCCESS) @@ -284,4 +269,3 @@ void UtTest_Setup(void) */ UtTest_Add(TestTimeBaseApi, NULL, NULL, "TestTimeBaseApi"); } - diff --git a/src/tests/timer-add-api-test/timer-add-api-test.c b/src/tests/timer-add-api-test/timer-add-api-test.c index 807e8640d..608eacdca 100644 --- a/src/tests/timer-add-api-test/timer-add-api-test.c +++ b/src/tests/timer-add-api-test/timer-add-api-test.c @@ -35,29 +35,25 @@ #include "uttest.h" #include "utbsp.h" -#define NUMBER_OF_TIMERS 4 +#define NUMBER_OF_TIMERS 4 #define TASK_1_STACK_SIZE 4096 #define TASK_1_PRIORITY 101 -OS_time_t StartTime; -OS_time_t EndTime; -uint32 TimerStart[NUMBER_OF_TIMERS] = {1000, 2000000, 3000000, 4000000 }; -uint32 TimerInterval[NUMBER_OF_TIMERS] = {500000, 400000, 800000, 600000 }; +OS_time_t StartTime; +OS_time_t EndTime; +uint32 TimerStart[NUMBER_OF_TIMERS] = {1000, 2000000, 3000000, 4000000}; +uint32 TimerInterval[NUMBER_OF_TIMERS] = {500000, 400000, 800000, 600000}; uint32 TimerTestTaskStack[TASK_1_STACK_SIZE]; uint32 timer_counter[NUMBER_OF_TIMERS]; - -void counter_func(osal_id_t timer_id , void *arg) +void counter_func(osal_id_t timer_id, void *arg) { - uint32 *counter = arg; - ++(*counter); + uint32 *counter = arg; + ++(*counter); } -void null_func(osal_id_t timer_id , void *arg) -{ - -} +void null_func(osal_id_t timer_id, void *arg) {} /* *************************************** MAIN ************************************** */ @@ -65,148 +61,145 @@ void TestTimerAddApi(void) { /* * Test Case For: - * int32 OS_TimerAdd(uint32 *timer_id, const char *timer_name, uint32 timebase_ref_id, OS_ArgCallback_t callback_ptr, void *callback_arg) + * int32 OS_TimerAdd(uint32 *timer_id, const char *timer_name, uint32 timebase_ref_id, OS_ArgCallback_t + * callback_ptr, void *callback_arg) */ - int32 actual; - int32 expected; - int32 tbc_ret_val; - int32 tbs_ret_val; - osal_id_t timer_id; - osal_id_t time_base_id; - int i = 0; - int32 TimerStatus[NUMBER_OF_TIMERS]; - osal_id_t TimerID[NUMBER_OF_TIMERS]; - char TimerName[NUMBER_OF_TIMERS][20] = {"TIMER1","TIMER2","TIMER3","TIMER4"}; - uint32 microsecs; - - /* Create and set the TimeBase obj and verify success */ - - tbc_ret_val = OS_TimeBaseCreate( &time_base_id, "TimeBase", 0); - expected = OS_SUCCESS; + int32 actual; + int32 expected; + int32 tbc_ret_val; + int32 tbs_ret_val; + osal_id_t timer_id; + osal_id_t time_base_id; + int i = 0; + int32 TimerStatus[NUMBER_OF_TIMERS]; + osal_id_t TimerID[NUMBER_OF_TIMERS]; + char TimerName[NUMBER_OF_TIMERS][20] = {"TIMER1", "TIMER2", "TIMER3", "TIMER4"}; + uint32 microsecs; + + /* Create and set the TimeBase obj and verify success */ + + tbc_ret_val = OS_TimeBaseCreate(&time_base_id, "TimeBase", 0); + expected = OS_SUCCESS; UtAssert_True(tbc_ret_val == expected, "OS_TimeBaseCreate() (%ld) == OS_SUCCESS", (long)tbc_ret_val); tbs_ret_val = OS_TimeBaseSet(time_base_id, 10000, 10000); /* ms */ - expected = OS_SUCCESS; + expected = OS_SUCCESS; UtAssert_True(tbs_ret_val == expected, "OS_TimeBaseSet() (%ld) == OS_SUCCESS", (long)tbs_ret_val); + for (i = 0; i < NUMBER_OF_TIMERS; i++) + { + TimerStatus[i] = OS_TimerAdd(&TimerID[i], TimerName[i], time_base_id, &counter_func, &timer_counter[i]); + UtAssert_True(TimerStatus[i] == OS_SUCCESS, "Timer %d Created RC=%d ID=%lx", i, (int)TimerStatus[i], + OS_ObjectIdToInteger(TimerID[i])); + } - for ( i = 0; i < NUMBER_OF_TIMERS; i++ ) - { - TimerStatus[i] = OS_TimerAdd(&TimerID[i], TimerName[i], time_base_id, &counter_func, &timer_counter[i]); - UtAssert_True(TimerStatus[i] == OS_SUCCESS, "Timer %d Created RC=%d ID=%lx", i, (int)TimerStatus[i], - OS_ObjectIdToInteger(TimerID[i])); - - } + /* Sample the clock now, before starting any timer */ + OS_GetLocalTime(&StartTime); + for (i = 0; i < NUMBER_OF_TIMERS; i++) + { + /* + * to ensure that all timers are started as closely as possible, + * this just stores the result and does not assert/printf now + */ + TimerStatus[i] = OS_TimerSet(TimerID[i], TimerStart[i], TimerInterval[i]); + } - /* Sample the clock now, before starting any timer */ - OS_GetLocalTime(&StartTime); - for ( i = 0; i < NUMBER_OF_TIMERS; i++ ) - { - /* - * to ensure that all timers are started as closely as possible, - * this just stores the result and does not assert/printf now - */ - TimerStatus[i] = OS_TimerSet(TimerID[i], TimerStart[i], TimerInterval[i]); - } + /* + * Now the actual OS_TimerSet() return code can be checked. + */ + for (i = 0; i < NUMBER_OF_TIMERS; i++) + { + UtAssert_True(TimerStatus[i] == OS_SUCCESS, "Timer %d programmed RC=%d", i, (int)TimerStatus[i]); + } - /* - * Now the actual OS_TimerSet() return code can be checked. - */ - for ( i = 0; i < NUMBER_OF_TIMERS; i++ ) - { - UtAssert_True(TimerStatus[i] == OS_SUCCESS, "Timer %d programmed RC=%d", i, (int)TimerStatus[i]); - } - - /* - ** Let the main thread sleep - */ - UtPrintf("Starting Delay loop.\n"); - for (i = 0 ; i < 30; i++ ) - { - /* - ** Even though this sleep call is for 1 second, - ** the sigalarm timer for the 1hz will keep waking - ** it up. Keep that in mind when setting the timer down - ** to something very small. - */ - OS_TaskDelay(1000); - } - - OS_GetLocalTime(&EndTime); - - for ( i = 0; i < NUMBER_OF_TIMERS; i++ ) - { - TimerStatus[i] = OS_TimerDelete(TimerID[i]); - } - - for ( i = 0; i < NUMBER_OF_TIMERS; i++ ) - { - UtAssert_True(TimerStatus[i] == OS_SUCCESS, "Timer %d delete RC=%d. Count total = %d", - i, (int)TimerStatus[i], (int)timer_counter[i]); - } - - /* - * Time limited test + /* + ** Let the main thread sleep */ - microsecs = 1000000 * (EndTime.seconds - StartTime.seconds); - if (EndTime.microsecs < StartTime.microsecs) - { - microsecs -= StartTime.microsecs - EndTime.microsecs; - } - else - { - microsecs += EndTime.microsecs - StartTime.microsecs; - } - - /* Make sure the ratio of the timers are OK */ - for ( i = 0; i < NUMBER_OF_TIMERS; i++ ) - { - /* - * Expect one tick after the start time (i.e. first tick) - * Plus one tick for every interval that occurred during the test - */ - expected = 1 + (microsecs - TimerStart[i]) / TimerInterval[i]; - UtAssert_True(expected > 0, "Expected ticks = %u", (unsigned int)expected); - - /* - * Since all these counts are affected by test system load, - * allow for some fudge factor before declaring failure - */ - UtAssert_True(timer_counter[i] >= (expected - 3), "Timer %d count >= %d", (int)i, (int)(expected - 3)); - UtAssert_True(timer_counter[i] <= (expected + 3), "Timer %d count <= %d", (int)i, (int)(expected + 3)); - } + UtPrintf("Starting Delay loop.\n"); + for (i = 0; i < 30; i++) + { + /* + ** Even though this sleep call is for 1 second, + ** the sigalarm timer for the 1hz will keep waking + ** it up. Keep that in mind when setting the timer down + ** to something very small. + */ + OS_TaskDelay(1000); + } + + OS_GetLocalTime(&EndTime); + + for (i = 0; i < NUMBER_OF_TIMERS; i++) + { + TimerStatus[i] = OS_TimerDelete(TimerID[i]); + } + + for (i = 0; i < NUMBER_OF_TIMERS; i++) + { + UtAssert_True(TimerStatus[i] == OS_SUCCESS, "Timer %d delete RC=%d. Count total = %d", i, (int)TimerStatus[i], + (int)timer_counter[i]); + } + + /* + * Time limited test + */ + microsecs = 1000000 * (EndTime.seconds - StartTime.seconds); + if (EndTime.microsecs < StartTime.microsecs) + { + microsecs -= StartTime.microsecs - EndTime.microsecs; + } + else + { + microsecs += EndTime.microsecs - StartTime.microsecs; + } + + /* Make sure the ratio of the timers are OK */ + for (i = 0; i < NUMBER_OF_TIMERS; i++) + { + /* + * Expect one tick after the start time (i.e. first tick) + * Plus one tick for every interval that occurred during the test + */ + expected = 1 + (microsecs - TimerStart[i]) / TimerInterval[i]; + UtAssert_True(expected > 0, "Expected ticks = %u", (unsigned int)expected); + + /* + * Since all these counts are affected by test system load, + * allow for some fudge factor before declaring failure + */ + UtAssert_True(timer_counter[i] >= (expected - 3), "Timer %d count >= %d", (int)i, (int)(expected - 3)); + UtAssert_True(timer_counter[i] <= (expected + 3), "Timer %d count <= %d", (int)i, (int)(expected + 3)); + } /* Test nominal inputs */ - expected = OS_SUCCESS; - actual = OS_TimerAdd(&timer_id, "Timer", time_base_id, null_func, NULL); + expected = OS_SUCCESS; + actual = OS_TimerAdd(&timer_id, "Timer", time_base_id, null_func, NULL); UtAssert_True(actual == expected, "OS_TimerAdd() (%ld) == OS_SUCCESS", (long)actual); /* Test invalid inputs */ expected = OS_INVALID_POINTER; - actual = OS_TimerAdd(NULL, "Timer", time_base_id, null_func, NULL); + actual = OS_TimerAdd(NULL, "Timer", time_base_id, null_func, NULL); UtAssert_True(actual == expected, "OS_TimerAdd() (%ld) == OS_INVALID_POINTER", (long)actual); expected = OS_ERR_INVALID_ID; - actual = OS_TimerAdd(&timer_id, "Timer", OS_OBJECT_ID_UNDEFINED, null_func, NULL); + actual = OS_TimerAdd(&timer_id, "Timer", OS_OBJECT_ID_UNDEFINED, null_func, NULL); UtAssert_True(actual == expected, "OS_TimerAdd() (%ld) == OS_ERR_INVALID_ID", (long)actual); expected = OS_TIMER_ERR_INVALID_ARGS; - actual = OS_TimerAdd(&timer_id, "Timer",time_base_id , NULL, NULL); + actual = OS_TimerAdd(&timer_id, "Timer", time_base_id, NULL, NULL); UtAssert_True(actual == expected, "OS_TimerAdd() (%ld) == OS_TIMER_ERR_INVALID_ARGS", (long)actual); expected = OS_ERR_NAME_TAKEN; - actual = OS_TimerAdd(&timer_id, "Timer", time_base_id, null_func, NULL); + actual = OS_TimerAdd(&timer_id, "Timer", time_base_id, null_func, NULL); UtAssert_True(actual == expected, "OS_TimerAdd() (%ld) == OS_ERR_NAME_TAKEN", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_TimerAdd(&timer_id, 0, time_base_id, null_func, NULL); + actual = OS_TimerAdd(&timer_id, 0, time_base_id, null_func, NULL); UtAssert_True(actual == expected, "OS_TimerAdd() (%ld) == OS_INVALID_POINTER", (long)actual); - } /* end TestTimerAddApi */ - void UtTest_Setup(void) { if (OS_API_Init() != OS_SUCCESS) @@ -219,4 +212,3 @@ void UtTest_Setup(void) */ UtTest_Add(TestTimerAddApi, NULL, NULL, "TestTimerAddApi"); } - diff --git a/src/tests/timer-test/timer-test.c b/src/tests/timer-test/timer-test.c index 6781894c4..83a58d923 100644 --- a/src/tests/timer-test/timer-test.c +++ b/src/tests/timer-test/timer-test.c @@ -21,7 +21,7 @@ /* ** timertest.c ** -** This program is an OSAL sample that tests the OSAL timer functions. +** This program is an OSAL sample that tests the OSAL timer functions. ** */ @@ -33,28 +33,25 @@ #include "uttest.h" #include "utbsp.h" - #define NUMBER_OF_TIMERS 4 #define TASK_1_ID 1 #define TASK_1_STACK_SIZE 4096 #define TASK_1_PRIORITY 101 - void TimerTestSetup(void); void TimerTestTask(void); void TimerTestCheck(void); -OS_time_t StartTime; -OS_time_t EndTime; -uint32 TimerStart[NUMBER_OF_TIMERS] = {1000, 2000000, 3000000, 4000000 }; -uint32 TimerInterval[NUMBER_OF_TIMERS] = {500000, 400000, 800000, 600000 }; +OS_time_t StartTime; +OS_time_t EndTime; +uint32 TimerStart[NUMBER_OF_TIMERS] = {1000, 2000000, 3000000, 4000000}; +uint32 TimerInterval[NUMBER_OF_TIMERS] = {500000, 400000, 800000, 600000}; uint32 TimerTestTaskStack[TASK_1_STACK_SIZE]; -int32 timer_counter[NUMBER_OF_TIMERS]; +int32 timer_counter[NUMBER_OF_TIMERS]; uint32 timer_idlookup[OS_MAX_TIMERS]; - /* * Test timer function. * Note: For some Host OSs, this is the equivalent of an ISR, so the calls available are limited. @@ -62,38 +59,38 @@ uint32 timer_idlookup[OS_MAX_TIMERS]; */ void test_func(osal_id_t timer_id) { - uint32 indx; - OS_ConvertToArrayIndex(timer_id, &indx); - timer_counter[timer_idlookup[indx]]++; + uint32 indx; + OS_ConvertToArrayIndex(timer_id, &indx); + timer_counter[timer_idlookup[indx]]++; } - /* ********************** MAIN **************************** */ void UtTest_Setup(void) { - if (OS_API_Init() != OS_SUCCESS) - { - UtAssert_Abort("OS_API_Init() failed"); - } + if (OS_API_Init() != OS_SUCCESS) + { + UtAssert_Abort("OS_API_Init() failed"); + } - /* - * Register the timer test setup and check routines in UT assert - */ - UtTest_Add(TimerTestCheck, TimerTestSetup, NULL, "TimerTest"); + /* + * Register the timer test setup and check routines in UT assert + */ + UtTest_Add(TimerTestCheck, TimerTestSetup, NULL, "TimerTest"); } void TimerTestSetup(void) { - int32 status; + int32 status; osal_id_t TimerTestTaskId; /* * In the new versions of OSAL, timers do NOT work in the "main" thread, * so we must create a task to handle them. */ - status = OS_TaskCreate( &TimerTestTaskId, "Task 1", TimerTestTask, TimerTestTaskStack, TASK_1_STACK_SIZE, TASK_1_PRIORITY, 0); + status = OS_TaskCreate(&TimerTestTaskId, "Task 1", TimerTestTask, TimerTestTaskStack, TASK_1_STACK_SIZE, + TASK_1_PRIORITY, 0); UtAssert_True(status == OS_SUCCESS, "Timer Test Task Created RC=%d", (int)status); /* @@ -113,112 +110,110 @@ void TimerTestSetup(void) void TimerTestTask(void) { - - int i = 0; - int32 TimerStatus[NUMBER_OF_TIMERS]; - uint32 TableId; - osal_id_t TimerID[NUMBER_OF_TIMERS]; - char TimerName[NUMBER_OF_TIMERS][20] = {"TIMER1","TIMER2","TIMER3","TIMER4"}; - uint32 ClockAccuracy; - - - for ( i = 0; i < NUMBER_OF_TIMERS && i < OS_MAX_TIMERS; i++ ) - { - TimerStatus[i] = OS_TimerCreate(&TimerID[i], TimerName[i], &ClockAccuracy, &(test_func)); - UtAssert_True(TimerStatus[i] == OS_SUCCESS, "Timer %d Created RC=%d ID=%lx", i, - (int)TimerStatus[i], OS_ObjectIdToInteger(TimerID[i])); - - UtPrintf("Timer %d Accuracy = %d microseconds \n",i ,(int)ClockAccuracy); - - OS_ConvertToArrayIndex(TimerID[i], &TableId); - timer_idlookup[TableId] = i; - } - - /* Sample the clock now, before starting any timer */ - OS_GetLocalTime(&StartTime); - for ( i = 0; i < NUMBER_OF_TIMERS && i < OS_MAX_TIMERS; i++ ) - { - /* - * to ensure that all timers are started as closely as possible, - * this just stores the result and does not assert/printf now - */ - TimerStatus[i] = OS_TimerSet(TimerID[i], TimerStart[i], TimerInterval[i]); - } - - /* - * Now the actual OS_TimerSet() return code can be checked. + + int i = 0; + int32 TimerStatus[NUMBER_OF_TIMERS]; + uint32 TableId; + osal_id_t TimerID[NUMBER_OF_TIMERS]; + char TimerName[NUMBER_OF_TIMERS][20] = {"TIMER1", "TIMER2", "TIMER3", "TIMER4"}; + uint32 ClockAccuracy; + + for (i = 0; i < NUMBER_OF_TIMERS && i < OS_MAX_TIMERS; i++) + { + TimerStatus[i] = OS_TimerCreate(&TimerID[i], TimerName[i], &ClockAccuracy, &(test_func)); + UtAssert_True(TimerStatus[i] == OS_SUCCESS, "Timer %d Created RC=%d ID=%lx", i, (int)TimerStatus[i], + OS_ObjectIdToInteger(TimerID[i])); + + UtPrintf("Timer %d Accuracy = %d microseconds \n", i, (int)ClockAccuracy); + + OS_ConvertToArrayIndex(TimerID[i], &TableId); + timer_idlookup[TableId] = i; + } + + /* Sample the clock now, before starting any timer */ + OS_GetLocalTime(&StartTime); + for (i = 0; i < NUMBER_OF_TIMERS && i < OS_MAX_TIMERS; i++) + { + /* + * to ensure that all timers are started as closely as possible, + * this just stores the result and does not assert/printf now + */ + TimerStatus[i] = OS_TimerSet(TimerID[i], TimerStart[i], TimerInterval[i]); + } + + /* + * Now the actual OS_TimerSet() return code can be checked. + */ + for (i = 0; i < NUMBER_OF_TIMERS && i < OS_MAX_TIMERS; i++) + { + UtAssert_True(TimerStatus[i] == OS_SUCCESS, "Timer %d programmed RC=%d", i, (int)TimerStatus[i]); + } + + /* + ** Let the main thread sleep */ - for ( i = 0; i < NUMBER_OF_TIMERS && i < OS_MAX_TIMERS; i++ ) - { - UtAssert_True(TimerStatus[i] == OS_SUCCESS, "Timer %d programmed RC=%d", i, (int)TimerStatus[i]); - } - - /* - ** Let the main thread sleep - */ - UtPrintf("Starting Delay loop.\n"); - for (i = 0 ; i < 30; i++ ) - { - /* - ** Even though this sleep call is for 1 second, - ** the sigalarm timer for the 1hz will keep waking - ** it up. Keep that in mind when setting the timer down - ** to something very small. - */ - OS_TaskDelay(1000); - } - OS_GetLocalTime(&EndTime); - - for ( i = 0; i < NUMBER_OF_TIMERS && i < OS_MAX_TIMERS; i++ ) - { - TimerStatus[i] = OS_TimerDelete(TimerID[i]); - } - - for ( i = 0; i < NUMBER_OF_TIMERS && i < OS_MAX_TIMERS; i++ ) - { - UtAssert_True(TimerStatus[i] == OS_SUCCESS, "Timer %d delete RC=%d. Count total = %d", - i, (int)TimerStatus[i], (int)timer_counter[i]); - } - - OS_ApplicationShutdown(true); - OS_TaskExit(); + UtPrintf("Starting Delay loop.\n"); + for (i = 0; i < 30; i++) + { + /* + ** Even though this sleep call is for 1 second, + ** the sigalarm timer for the 1hz will keep waking + ** it up. Keep that in mind when setting the timer down + ** to something very small. + */ + OS_TaskDelay(1000); + } + OS_GetLocalTime(&EndTime); + + for (i = 0; i < NUMBER_OF_TIMERS && i < OS_MAX_TIMERS; i++) + { + TimerStatus[i] = OS_TimerDelete(TimerID[i]); + } + + for (i = 0; i < NUMBER_OF_TIMERS && i < OS_MAX_TIMERS; i++) + { + UtAssert_True(TimerStatus[i] == OS_SUCCESS, "Timer %d delete RC=%d. Count total = %d", i, (int)TimerStatus[i], + (int)timer_counter[i]); + } + + OS_ApplicationShutdown(true); + OS_TaskExit(); } void TimerTestCheck(void) { - uint32 microsecs; - int32 expected; - uint32 i; + uint32 microsecs; + int32 expected; + uint32 i; - /* - * Time limited test - check and exit - */ - microsecs = 1000000 * (EndTime.seconds - StartTime.seconds); - if (EndTime.microsecs < StartTime.microsecs) - { - microsecs -= StartTime.microsecs - EndTime.microsecs; - } - else - { - microsecs += EndTime.microsecs - StartTime.microsecs; - } - - /* Make sure the ratio of the timers are OK */ - for ( i = 0; i < NUMBER_OF_TIMERS && i < OS_MAX_TIMERS; i++ ) - { - /* - * Expect one tick after the start time (i.e. first tick) - * Plus one tick for every interval that occurred during the test - */ - expected = 1 + (microsecs - TimerStart[i]) / TimerInterval[i]; - UtAssert_True(expected > 0, "Expected ticks = %u", (unsigned int)expected); - - /* - * Since all these counts are affected by test system load, - * allow for some fudge factor before declaring failure - */ - UtAssert_True(timer_counter[i] >= (expected - 3), "Timer %d count >= %d", (int)i, (int)(expected - 3)); - UtAssert_True(timer_counter[i] <= (expected + 3), "Timer %d count <= %d", (int)i, (int)(expected + 3)); - } + /* + * Time limited test - check and exit + */ + microsecs = 1000000 * (EndTime.seconds - StartTime.seconds); + if (EndTime.microsecs < StartTime.microsecs) + { + microsecs -= StartTime.microsecs - EndTime.microsecs; + } + else + { + microsecs += EndTime.microsecs - StartTime.microsecs; + } + + /* Make sure the ratio of the timers are OK */ + for (i = 0; i < NUMBER_OF_TIMERS && i < OS_MAX_TIMERS; i++) + { + /* + * Expect one tick after the start time (i.e. first tick) + * Plus one tick for every interval that occurred during the test + */ + expected = 1 + (microsecs - TimerStart[i]) / TimerInterval[i]; + UtAssert_True(expected > 0, "Expected ticks = %u", (unsigned int)expected); + + /* + * Since all these counts are affected by test system load, + * allow for some fudge factor before declaring failure + */ + UtAssert_True(timer_counter[i] >= (expected - 3), "Timer %d count >= %d", (int)i, (int)(expected - 3)); + UtAssert_True(timer_counter[i] <= (expected + 3), "Timer %d count <= %d", (int)i, (int)(expected + 3)); + } } - diff --git a/src/unit-test-coverage/portable/adaptors/inc/ut-adaptor-portable-posix-files.h b/src/unit-test-coverage/portable/adaptors/inc/ut-adaptor-portable-posix-files.h index b3700d602..f5f62aceb 100644 --- a/src/unit-test-coverage/portable/adaptors/inc/ut-adaptor-portable-posix-files.h +++ b/src/unit-test-coverage/portable/adaptors/inc/ut-adaptor-portable-posix-files.h @@ -33,5 +33,4 @@ unsigned int UT_PortablePosixFileTest_GetSelfEUID(void); unsigned int UT_PortablePosixFileTest_GetSelfEGID(void); -#endif /* INCLUDE_UT_ADAPTOR_PORTABLE_POSIX_FILES_H_ */ - +#endif /* INCLUDE_UT_ADAPTOR_PORTABLE_POSIX_FILES_H_ */ diff --git a/src/unit-test-coverage/portable/adaptors/inc/ut-adaptor-portable-posix-io.h b/src/unit-test-coverage/portable/adaptors/inc/ut-adaptor-portable-posix-io.h index 6191cc15c..98f4377b5 100644 --- a/src/unit-test-coverage/portable/adaptors/inc/ut-adaptor-portable-posix-io.h +++ b/src/unit-test-coverage/portable/adaptors/inc/ut-adaptor-portable-posix-io.h @@ -28,8 +28,6 @@ #ifndef INCLUDE_UT_ADAPTOR_PORTABLE_POSIX_IO_H_ #define INCLUDE_UT_ADAPTOR_PORTABLE_POSIX_IO_H_ - - /** * \file ut-osfileapi.h * \ingroup adaptors @@ -52,8 +50,6 @@ *****************************************************/ void UT_PortablePosixIOTest_Set_Selectable(uint32 local_id, bool is_selectable); -#endif /* _UT_OSFILEAPI_H_ */ - - -#endif /* INCLUDE_UT_ADAPTOR_PORTABLE_POSIX_IO_H_ */ +#endif /* _UT_OSFILEAPI_H_ */ +#endif /* INCLUDE_UT_ADAPTOR_PORTABLE_POSIX_IO_H_ */ diff --git a/src/unit-test-coverage/portable/adaptors/src/ut-adaptor-portable-posix-files.c b/src/unit-test-coverage/portable/adaptors/src/ut-adaptor-portable-posix-files.c index 7526db776..969dab756 100644 --- a/src/unit-test-coverage/portable/adaptors/src/ut-adaptor-portable-posix-files.c +++ b/src/unit-test-coverage/portable/adaptors/src/ut-adaptor-portable-posix-files.c @@ -25,7 +25,6 @@ * */ - /* pull in the OSAL configuration */ #include "osconfig.h" #include "ut-adaptor-portable-posix-files.h" @@ -41,4 +40,3 @@ unsigned int UT_PortablePosixFileTest_GetSelfEGID(void) { return OS_IMPL_SELF_EGID; } - diff --git a/src/unit-test-coverage/portable/adaptors/src/ut-adaptor-portable-posix-io.c b/src/unit-test-coverage/portable/adaptors/src/ut-adaptor-portable-posix-io.c index 3e3730a39..0f54a9677 100644 --- a/src/unit-test-coverage/portable/adaptors/src/ut-adaptor-portable-posix-io.c +++ b/src/unit-test-coverage/portable/adaptors/src/ut-adaptor-portable-posix-io.c @@ -31,7 +31,6 @@ #include - void UT_PortablePosixIOTest_Set_Selectable(uint32 local_id, bool is_selectable) { OS_impl_filehandle_table[local_id].selectable = is_selectable; diff --git a/src/unit-test-coverage/portable/src/coveragetest-bsd-select.c b/src/unit-test-coverage/portable/src/coveragetest-bsd-select.c index 8e3dad250..5c0c90acc 100644 --- a/src/unit-test-coverage/portable/src/coveragetest-bsd-select.c +++ b/src/unit-test-coverage/portable/src/coveragetest-bsd-select.c @@ -34,8 +34,8 @@ void Test_OS_SelectSingle_Impl(void) /* Test Case For: * int32 OS_SelectSingle_Impl(uint32 stream_id, uint32 *SelectFlags, int32 msecs) */ - uint32 SelectFlags; - uint32 StreamID; + uint32 SelectFlags; + uint32 StreamID; struct OCS_timespec nowtime; struct OCS_timespec latertime; @@ -51,27 +51,26 @@ void Test_OS_SelectSingle_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_SelectSingle_Impl, (StreamID, &SelectFlags, 0), OS_SUCCESS); UT_SetForceFail(UT_KEY(OCS_select), 0); - SelectFlags = OS_STREAM_STATE_READABLE | OS_STREAM_STATE_WRITABLE; - nowtime.tv_sec = 1; - nowtime.tv_nsec = 500000000; - latertime.tv_sec = 10; + SelectFlags = OS_STREAM_STATE_READABLE | OS_STREAM_STATE_WRITABLE; + nowtime.tv_sec = 1; + nowtime.tv_nsec = 500000000; + latertime.tv_sec = 10; latertime.tv_nsec = 0; - UT_SetDataBuffer(UT_KEY(OCS_clock_gettime),&nowtime, sizeof(nowtime), false); - UT_SetDataBuffer(UT_KEY(OCS_clock_gettime),&latertime, sizeof(latertime), false); + UT_SetDataBuffer(UT_KEY(OCS_clock_gettime), &nowtime, sizeof(nowtime), false); + UT_SetDataBuffer(UT_KEY(OCS_clock_gettime), &latertime, sizeof(latertime), false); OSAPI_TEST_FUNCTION_RC(OS_SelectSingle_Impl, (StreamID, &SelectFlags, 999), OS_ERROR_TIMEOUT); UT_SetForceFail(UT_KEY(OCS_select), -1); - SelectFlags = OS_STREAM_STATE_READABLE | OS_STREAM_STATE_WRITABLE; - nowtime.tv_sec = 1; - nowtime.tv_nsec = 0; - latertime.tv_sec = 2; + SelectFlags = OS_STREAM_STATE_READABLE | OS_STREAM_STATE_WRITABLE; + nowtime.tv_sec = 1; + nowtime.tv_nsec = 0; + latertime.tv_sec = 2; latertime.tv_nsec = 600000000; - UT_SetDataBuffer(UT_KEY(OCS_clock_gettime),&nowtime, sizeof(nowtime), false); - UT_SetDataBuffer(UT_KEY(OCS_clock_gettime),&latertime, sizeof(latertime), false); + UT_SetDataBuffer(UT_KEY(OCS_clock_gettime), &nowtime, sizeof(nowtime), false); + UT_SetDataBuffer(UT_KEY(OCS_clock_gettime), &latertime, sizeof(latertime), false); OSAPI_TEST_FUNCTION_RC(OS_SelectSingle_Impl, (StreamID, &SelectFlags, 2100), OS_ERROR); } /* end OS_SelectSingle_Impl */ - void Test_OS_SelectMultiple_Impl(void) { /* Test Case For: @@ -89,8 +88,6 @@ void Test_OS_SelectMultiple_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_SelectMultiple_Impl, (&ReadSet, &WriteSet, 1), OS_ERROR_TIMEOUT); } /* end OS_SelectMultiple_Impl */ - - /* ------------------- End of test cases --------------------------------------*/ /* Osapi_Test_Setup @@ -109,11 +106,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} - +void Osapi_Test_Teardown(void) {} /* UtTest_Setup * @@ -125,7 +118,3 @@ void UtTest_Setup(void) ADD_TEST(OS_SelectSingle_Impl); ADD_TEST(OS_SelectMultiple_Impl); } - - - - diff --git a/src/unit-test-coverage/portable/src/coveragetest-console-bsp.c b/src/unit-test-coverage/portable/src/coveragetest-console-bsp.c index 180884baa..fc38f97a0 100644 --- a/src/unit-test-coverage/portable/src/coveragetest-console-bsp.c +++ b/src/unit-test-coverage/portable/src/coveragetest-console-bsp.c @@ -31,9 +31,9 @@ #include #include -#define TEST_BUFFER_LEN 16 +#define TEST_BUFFER_LEN 16 -const char TEST_BUF_INITIALIZER[1+TEST_BUFFER_LEN] = "abcdefghijklmnop"; +const char TEST_BUF_INITIALIZER[1 + TEST_BUFFER_LEN] = "abcdefghijklmnop"; void Test_OS_ConsoleOutput_Impl(void) { @@ -50,16 +50,14 @@ void Test_OS_ConsoleOutput_Impl(void) OS_console_table[0].WritePos = 4; OS_ConsoleOutput_Impl(0); - UtAssert_True(strcmp(TestOutputBuffer, "abcd") == 0, - "TestOutputBuffer (%s) == abcd", TestOutputBuffer); + UtAssert_True(strcmp(TestOutputBuffer, "abcd") == 0, "TestOutputBuffer (%s) == abcd", TestOutputBuffer); OS_console_table[0].WritePos = 2; OS_ConsoleOutput_Impl(0); - UtAssert_True(strcmp(TestOutputBuffer, "abcdefghijklmnopab") == 0, - "TestOutputBuffer (%s) == abcdefghijklmnopab", TestOutputBuffer); + UtAssert_True(strcmp(TestOutputBuffer, "abcdefghijklmnopab") == 0, "TestOutputBuffer (%s) == abcdefghijklmnopab", + TestOutputBuffer); } - /* ------------------- End of test cases --------------------------------------*/ /* Osapi_Test_Setup @@ -79,10 +77,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* UtTest_Setup * @@ -93,5 +88,3 @@ void UtTest_Setup(void) { ADD_TEST(OS_ConsoleOutput_Impl); } - - diff --git a/src/unit-test-coverage/portable/src/coveragetest-no-loader.c b/src/unit-test-coverage/portable/src/coveragetest-no-loader.c index e21a3063c..c3df0c998 100644 --- a/src/unit-test-coverage/portable/src/coveragetest-no-loader.c +++ b/src/unit-test-coverage/portable/src/coveragetest-no-loader.c @@ -32,7 +32,7 @@ void Test_OS_ModuleLoad_Impl(void) /* Test Case For: * int32 OS_ModuleLoad_Impl ( uint32 module_id, char *translated_path ) */ - OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl, (0,"local"), OS_ERR_NOT_IMPLEMENTED); + OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl, (0, "local"), OS_ERR_NOT_IMPLEMENTED); } void Test_OS_ModuleUnload_Impl(void) @@ -51,10 +51,9 @@ void Test_OS_ModuleGetInfo_Impl(void) OS_module_prop_t module_prop; memset(&module_prop, 0, sizeof(module_prop)); - OSAPI_TEST_FUNCTION_RC(OS_ModuleGetInfo_Impl, (0,&module_prop), OS_ERR_NOT_IMPLEMENTED); + OSAPI_TEST_FUNCTION_RC(OS_ModuleGetInfo_Impl, (0, &module_prop), OS_ERR_NOT_IMPLEMENTED); } - /* ------------------- End of test cases --------------------------------------*/ /* Osapi_Test_Setup @@ -73,11 +72,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} - +void Osapi_Test_Teardown(void) {} /* UtTest_Setup * @@ -90,5 +85,3 @@ void UtTest_Setup(void) ADD_TEST(OS_ModuleUnload_Impl); ADD_TEST(OS_ModuleGetInfo_Impl); } - - diff --git a/src/unit-test-coverage/portable/src/coveragetest-no-shell.c b/src/unit-test-coverage/portable/src/coveragetest-no-shell.c index a5716dbb2..1973e407d 100644 --- a/src/unit-test-coverage/portable/src/coveragetest-no-shell.c +++ b/src/unit-test-coverage/portable/src/coveragetest-no-shell.c @@ -33,7 +33,7 @@ void Test_OS_ShellOutputToFile_Impl(void) /* Test Case For: * int32 OS_ShellOutputToFile_Impl(uint32 stream_id, const char* Cmd) */ - OSAPI_TEST_FUNCTION_RC(OS_ShellOutputToFile_Impl, (0,"ut"), OS_ERR_NOT_IMPLEMENTED); + OSAPI_TEST_FUNCTION_RC(OS_ShellOutputToFile_Impl, (0, "ut"), OS_ERR_NOT_IMPLEMENTED); } /* ------------------- End of test cases --------------------------------------*/ @@ -54,11 +54,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} - +void Osapi_Test_Teardown(void) {} /* UtTest_Setup * @@ -69,5 +65,3 @@ void UtTest_Setup(void) { ADD_TEST(OS_ShellOutputToFile_Impl); } - - diff --git a/src/unit-test-coverage/portable/src/coveragetest-posix-files.c b/src/unit-test-coverage/portable/src/coveragetest-posix-files.c index 4acccf6fa..9e8ed38e3 100644 --- a/src/unit-test-coverage/portable/src/coveragetest-posix-files.c +++ b/src/unit-test-coverage/portable/src/coveragetest-posix-files.c @@ -35,22 +35,20 @@ #include #include - void Test_OS_FileOpen_Impl(void) { /* * Test Case For: * int32 OS_FileOpen_Impl(uint32 local_id, const char *local_path, int32 flags, int32 access) */ - OSAPI_TEST_FUNCTION_RC(OS_FileOpen_Impl, (0,"local",OS_FILE_FLAG_TRUNCATE,OS_WRITE_ONLY), OS_SUCCESS); - OSAPI_TEST_FUNCTION_RC(OS_FileOpen_Impl, (0,"local",0,OS_READ_ONLY), OS_SUCCESS); - OSAPI_TEST_FUNCTION_RC(OS_FileOpen_Impl, (0,"local",OS_FILE_FLAG_CREATE,OS_READ_WRITE), OS_SUCCESS); - OSAPI_TEST_FUNCTION_RC(OS_FileOpen_Impl, (0,"local",0,-1234), OS_ERROR); - + OSAPI_TEST_FUNCTION_RC(OS_FileOpen_Impl, (0, "local", OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_FileOpen_Impl, (0, "local", 0, OS_READ_ONLY), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_FileOpen_Impl, (0, "local", OS_FILE_FLAG_CREATE, OS_READ_WRITE), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_FileOpen_Impl, (0, "local", 0, -1234), OS_ERROR); /* failure mode */ UT_SetForceFail(UT_KEY(OCS_open), -1); - OSAPI_TEST_FUNCTION_RC(OS_FileOpen_Impl, (0,"local",0,OS_READ_ONLY), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_FileOpen_Impl, (0, "local", 0, OS_READ_ONLY), OS_ERROR); } void Test_OS_FileStat_Impl(void) @@ -59,27 +57,27 @@ void Test_OS_FileStat_Impl(void) * Test Case For: * int32 OS_FileStat_Impl(const char *local_path, os_fstat_t *FileStats) */ - os_fstat_t FileStats; + os_fstat_t FileStats; struct OCS_stat RefStat; /* failure mode */ UT_SetForceFail(UT_KEY(OCS_stat), -1); - OSAPI_TEST_FUNCTION_RC(OS_FileStat_Impl, ("local",&FileStats), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_FileStat_Impl, ("local", &FileStats), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_stat)); /* nominal, no permission bits */ - memset(&FileStats,0,sizeof(FileStats)); - OSAPI_TEST_FUNCTION_RC(OS_FileStat_Impl, ("local",&FileStats), OS_SUCCESS); + memset(&FileStats, 0, sizeof(FileStats)); + OSAPI_TEST_FUNCTION_RC(OS_FileStat_Impl, ("local", &FileStats), OS_SUCCESS); UtAssert_True(FileStats.FileModeBits == 0, "File Mode Bits unset"); /* all permission bits with uid/gid match */ - RefStat.st_uid = UT_PortablePosixFileTest_GetSelfEUID(); - RefStat.st_gid = UT_PortablePosixFileTest_GetSelfEGID(); - RefStat.st_mode = ~0; - RefStat.st_size = 1234; + RefStat.st_uid = UT_PortablePosixFileTest_GetSelfEUID(); + RefStat.st_gid = UT_PortablePosixFileTest_GetSelfEGID(); + RefStat.st_mode = ~0; + RefStat.st_size = 1234; RefStat.st_mtime = 5678; UT_SetDataBuffer(UT_KEY(OCS_stat), &RefStat, sizeof(RefStat), false); - OSAPI_TEST_FUNCTION_RC(OS_FileStat_Impl, ("local",&FileStats), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_FileStat_Impl, ("local", &FileStats), OS_SUCCESS); /* Test that the result checking macros work */ UtAssert_True(OS_FILESTAT_EXEC(FileStats), "File Exec Bit set"); @@ -88,7 +86,6 @@ void Test_OS_FileStat_Impl(void) UtAssert_True(OS_FILESTAT_ISDIR(FileStats), "Directory Bit set"); UtAssert_True(OS_FILESTAT_SIZE(FileStats) == 1234, "Size match"); UtAssert_True(OS_FILESTAT_TIME(FileStats) == 5678, "Time match"); - } void Test_OS_FileChmod_Impl(void) @@ -101,24 +98,24 @@ void Test_OS_FileChmod_Impl(void) /* failure mode 1 (stat) */ UT_SetForceFail(UT_KEY(OCS_stat), -1); - OSAPI_TEST_FUNCTION_RC(OS_FileChmod_Impl, ("local",OS_READ_WRITE), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_FileChmod_Impl, ("local", OS_READ_WRITE), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_stat)); /* failure mode 2 (chmod) */ UT_SetForceFail(UT_KEY(OCS_chmod), -1); - OSAPI_TEST_FUNCTION_RC(OS_FileChmod_Impl, ("local",OS_READ_WRITE), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_FileChmod_Impl, ("local", OS_READ_WRITE), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_chmod)); /* all permission bits with uid/gid match */ - RefStat.st_uid = UT_PortablePosixFileTest_GetSelfEUID(); - RefStat.st_gid = UT_PortablePosixFileTest_GetSelfEGID(); - RefStat.st_mode = ~0; - RefStat.st_size = 1234; + RefStat.st_uid = UT_PortablePosixFileTest_GetSelfEUID(); + RefStat.st_gid = UT_PortablePosixFileTest_GetSelfEGID(); + RefStat.st_mode = ~0; + RefStat.st_size = 1234; RefStat.st_mtime = 5678; UT_SetDataBuffer(UT_KEY(OCS_stat), &RefStat, sizeof(RefStat), false); /* nominal 1 - full permissions with file owned by own uid/gid */ - OSAPI_TEST_FUNCTION_RC(OS_FileChmod_Impl, ("local",OS_READ_WRITE), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_FileChmod_Impl, ("local", OS_READ_WRITE), OS_SUCCESS); /* nominal 2 - partial permissions */ OSAPI_TEST_FUNCTION_RC(OS_FileChmod_Impl, ("local", OS_READ_ONLY), OS_SUCCESS); @@ -128,10 +125,10 @@ void Test_OS_FileChmod_Impl(void) ++RefStat.st_uid; ++RefStat.st_gid; UT_SetDataBuffer(UT_KEY(OCS_stat), &RefStat, sizeof(RefStat), false); - OSAPI_TEST_FUNCTION_RC(OS_FileChmod_Impl, ("local",OS_READ_WRITE), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_FileChmod_Impl, ("local", OS_READ_WRITE), OS_SUCCESS); } -void Test_OS_FileRemove_Impl (void) +void Test_OS_FileRemove_Impl(void) { /* * Test Case For: @@ -142,24 +139,21 @@ void Test_OS_FileRemove_Impl (void) /* failure mode */ UT_SetForceFail(UT_KEY(OCS_remove), -1); OSAPI_TEST_FUNCTION_RC(OS_FileRemove_Impl, ("local"), OS_ERROR); - } -void Test_OS_FileRename_Impl (void) +void Test_OS_FileRename_Impl(void) { /* * Test Case For: * int32 OS_FileRename_Impl(const char *old_path, const char *new_path) */ - OSAPI_TEST_FUNCTION_RC(OS_FileRename_Impl, ("old","new"), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_FileRename_Impl, ("old", "new"), OS_SUCCESS); /* failure mode */ UT_SetForceFail(UT_KEY(OCS_rename), -1); - OSAPI_TEST_FUNCTION_RC(OS_FileRename_Impl, ("old","new"), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_FileRename_Impl, ("old", "new"), OS_ERROR); } - - /* ------------------- End of test cases --------------------------------------*/ /* Osapi_Test_Setup @@ -179,13 +173,9 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} - -#define ADD_TEST(test) UtTest_Add((Test_ ## test), Osapi_Test_Setup, Osapi_Test_Teardown, #test) +#define ADD_TEST(test) UtTest_Add((Test_##test), Osapi_Test_Setup, Osapi_Test_Teardown, #test) /* UtTest_Setup * @@ -200,5 +190,3 @@ void UtTest_Setup(void) ADD_TEST(OS_FileRemove_Impl); ADD_TEST(OS_FileRename_Impl); } - - diff --git a/src/unit-test-coverage/portable/src/coveragetest-posix-gettime.c b/src/unit-test-coverage/portable/src/coveragetest-posix-gettime.c index aa74e63a3..dc63e8d18 100644 --- a/src/unit-test-coverage/portable/src/coveragetest-posix-gettime.c +++ b/src/unit-test-coverage/portable/src/coveragetest-posix-gettime.c @@ -29,7 +29,6 @@ #include - void Test_OS_GetLocalTime_Impl(void) { /* @@ -37,7 +36,7 @@ void Test_OS_GetLocalTime_Impl(void) * int32 OS_GetLocalTime_Impl(OS_time_t *time_struct) */ OS_time_t timeval; - timeval.seconds = 1; + timeval.seconds = 1; timeval.microsecs = 1; OSAPI_TEST_FUNCTION_RC(OS_GetLocalTime_Impl, (&timeval), OS_SUCCESS); @@ -52,7 +51,7 @@ void Test_OS_SetLocalTime_Impl(void) * int32 OS_SetLocalTime_Impl(const OS_time_t *time_struct) */ OS_time_t timeval; - timeval.seconds = 1; + timeval.seconds = 1; timeval.microsecs = 1; OSAPI_TEST_FUNCTION_RC(OS_SetLocalTime_Impl, (&timeval), OS_SUCCESS); @@ -60,7 +59,6 @@ void Test_OS_SetLocalTime_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_SetLocalTime_Impl, (&timeval), OS_ERROR); } - /* ------------------- End of test cases --------------------------------------*/ /* Osapi_Test_Setup @@ -79,13 +77,9 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} - +void Osapi_Test_Teardown(void) {} -#define ADD_TEST(test) UtTest_Add((Test_ ## test), Osapi_Test_Setup, Osapi_Test_Teardown, #test) +#define ADD_TEST(test) UtTest_Add((Test_##test), Osapi_Test_Setup, Osapi_Test_Teardown, #test) /* UtTest_Setup * @@ -97,5 +91,3 @@ void UtTest_Setup(void) ADD_TEST(OS_GetLocalTime_Impl); ADD_TEST(OS_SetLocalTime_Impl); } - - diff --git a/src/unit-test-coverage/portable/src/coveragetest-posix-io.c b/src/unit-test-coverage/portable/src/coveragetest-posix-io.c index 7c30d0a45..26fdf3059 100644 --- a/src/unit-test-coverage/portable/src/coveragetest-posix-io.c +++ b/src/unit-test-coverage/portable/src/coveragetest-posix-io.c @@ -37,24 +37,23 @@ #include #include - void Test_OS_GenericClose_Impl(void) { /* * Test Case For: * int32 OS_GenericClose_Impl(uint32 local_id) */ - OSAPI_TEST_FUNCTION_RC(OS_GenericClose_Impl,(0), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_GenericClose_Impl, (0), OS_SUCCESS); /* * Test path where underlying close() fails. * Should still return success. */ UT_SetForceFail(UT_KEY(OCS_close), -1); - OSAPI_TEST_FUNCTION_RC(OS_GenericClose_Impl,(0), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_GenericClose_Impl, (0), OS_SUCCESS); } -void Test_OS_GenericSeek_Impl (void) +void Test_OS_GenericSeek_Impl(void) { /* * Test Case For: @@ -63,48 +62,48 @@ void Test_OS_GenericSeek_Impl (void) /* note on success this wrapper returns the result of lseek(), not OS_SUCCESS */ UT_SetForceFail(UT_KEY(OCS_lseek), 111); - OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl,(0,0,OS_SEEK_CUR), 111); + OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl, (0, 0, OS_SEEK_CUR), 111); UT_SetForceFail(UT_KEY(OCS_lseek), 222); - OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl,(0,0,OS_SEEK_SET), 222); + OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl, (0, 0, OS_SEEK_SET), 222); UT_SetForceFail(UT_KEY(OCS_lseek), 333); - OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl,(0,0,OS_SEEK_END), 333); + OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl, (0, 0, OS_SEEK_END), 333); /* bad whence */ - OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl,(0,0,-1234), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl, (0, 0, -1234), OS_ERROR); /* generic failure of lseek() */ - UT_SetForceFail(UT_KEY(OCS_lseek),-1); - OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl,(0,0,OS_SEEK_END), OS_ERROR); + UT_SetForceFail(UT_KEY(OCS_lseek), -1); + OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl, (0, 0, OS_SEEK_END), OS_ERROR); /* The seek implementation also checks for this specific pipe errno */ OCS_errno = OCS_ESPIPE; - OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl,(0,0,OS_SEEK_END), OS_ERR_NOT_IMPLEMENTED); + OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl, (0, 0, OS_SEEK_END), OS_ERR_NOT_IMPLEMENTED); } -void Test_OS_GenericRead_Impl (void) +void Test_OS_GenericRead_Impl(void) { /* * Test Case For: * int32 OS_GenericRead_Impl (uint32 local_id, void *buffer, uint32 nbytes, int32 timeout) */ - char SrcData[] = "ABCDEFGHIJK"; - char DestData[sizeof(SrcData)] = { 0 }; + char SrcData[] = "ABCDEFGHIJK"; + char DestData[sizeof(SrcData)] = {0}; - UT_SetDataBuffer(UT_KEY(OCS_read),SrcData,sizeof(SrcData),false); + UT_SetDataBuffer(UT_KEY(OCS_read), SrcData, sizeof(SrcData), false); UT_PortablePosixIOTest_Set_Selectable(0, false); - OSAPI_TEST_FUNCTION_RC(OS_GenericRead_Impl,(0,DestData,sizeof(DestData),0), sizeof(DestData)); - UtAssert_MemCmp(SrcData, DestData, sizeof(SrcData),"read() data Valid"); + OSAPI_TEST_FUNCTION_RC(OS_GenericRead_Impl, (0, DestData, sizeof(DestData), 0), sizeof(DestData)); + UtAssert_MemCmp(SrcData, DestData, sizeof(SrcData), "read() data Valid"); /* test invocation of select() in nonblocking mode */ UT_ResetState(UT_KEY(OCS_read)); - UT_SetDataBuffer(UT_KEY(OCS_read),SrcData,sizeof(SrcData),false); + UT_SetDataBuffer(UT_KEY(OCS_read), SrcData, sizeof(SrcData), false); UT_PortablePosixIOTest_Set_Selectable(0, true); - OSAPI_TEST_FUNCTION_RC(OS_GenericRead_Impl,(0,DestData,sizeof(DestData),0), sizeof(DestData)); + OSAPI_TEST_FUNCTION_RC(OS_GenericRead_Impl, (0, DestData, sizeof(DestData), 0), sizeof(DestData)); UtAssert_True(UT_GetStubCount(UT_KEY(OS_SelectSingle_Impl)) == 1, "OS_SelectSingle() called"); /* read() failure */ UT_SetForceFail(UT_KEY(OCS_read), -1); - OSAPI_TEST_FUNCTION_RC(OS_GenericRead_Impl,(0,DestData,sizeof(DestData),0), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_GenericRead_Impl, (0, DestData, sizeof(DestData), 0), OS_ERROR); } void Test_OS_GenericWrite_Impl(void) @@ -113,28 +112,26 @@ void Test_OS_GenericWrite_Impl(void) * Test Case For: * int32 OS_GenericWrite_Impl(uint32 local_id, const void *buffer, uint32 nbytes, int32 timeout) */ - char SrcData[] = "ABCDEFGHIJKL"; - char DestData[sizeof(SrcData)] = { 0 }; + char SrcData[] = "ABCDEFGHIJKL"; + char DestData[sizeof(SrcData)] = {0}; - UT_SetDataBuffer(UT_KEY(OCS_write),DestData,sizeof(DestData),false); + UT_SetDataBuffer(UT_KEY(OCS_write), DestData, sizeof(DestData), false); UT_PortablePosixIOTest_Set_Selectable(0, false); - OSAPI_TEST_FUNCTION_RC(OS_GenericWrite_Impl,(0,SrcData,sizeof(SrcData),0), sizeof(SrcData)); + OSAPI_TEST_FUNCTION_RC(OS_GenericWrite_Impl, (0, SrcData, sizeof(SrcData), 0), sizeof(SrcData)); UtAssert_MemCmp(SrcData, DestData, sizeof(SrcData), "write() data valid"); - /* test invocation of select() in nonblocking mode */ UT_ResetState(UT_KEY(OCS_write)); - UT_SetDataBuffer(UT_KEY(OCS_write),DestData,sizeof(DestData),false); + UT_SetDataBuffer(UT_KEY(OCS_write), DestData, sizeof(DestData), false); UT_PortablePosixIOTest_Set_Selectable(0, true); - OSAPI_TEST_FUNCTION_RC(OS_GenericWrite_Impl,(0,SrcData,sizeof(SrcData),0), sizeof(SrcData)); + OSAPI_TEST_FUNCTION_RC(OS_GenericWrite_Impl, (0, SrcData, sizeof(SrcData), 0), sizeof(SrcData)); UtAssert_True(UT_GetStubCount(UT_KEY(OS_SelectSingle_Impl)) == 1, "OS_SelectSingle() called"); /* write() failure */ UT_SetForceFail(UT_KEY(OCS_write), -1); - OSAPI_TEST_FUNCTION_RC(OS_GenericWrite_Impl,(0,DestData,sizeof(DestData),0), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_GenericWrite_Impl, (0, DestData, sizeof(DestData), 0), OS_ERROR); } - /* ------------------- End of test cases --------------------------------------*/ /* Osapi_Test_Setup @@ -155,13 +152,9 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ +void Osapi_Test_Teardown(void) {} -} - - -#define ADD_TEST(test) UtTest_Add((Test_ ## test), Osapi_Test_Setup, Osapi_Test_Teardown, #test) +#define ADD_TEST(test) UtTest_Add((Test_##test), Osapi_Test_Setup, Osapi_Test_Teardown, #test) /* UtTest_Setup * @@ -175,5 +168,3 @@ void UtTest_Setup(void) ADD_TEST(OS_GenericRead_Impl); ADD_TEST(OS_GenericWrite_Impl); } - - diff --git a/src/unit-test-coverage/portable/src/os-portable-coveragetest.h b/src/unit-test-coverage/portable/src/os-portable-coveragetest.h index 21ff8b749..287d4c005 100644 --- a/src/unit-test-coverage/portable/src/os-portable-coveragetest.h +++ b/src/unit-test-coverage/portable/src/os-portable-coveragetest.h @@ -28,8 +28,6 @@ #ifndef INCLUDE_OS_PORTABLE_COVERAGETEST_H_ #define INCLUDE_OS_PORTABLE_COVERAGETEST_H_ - - /** * \file os-vxworks-coveragetest.h * \ingroup vxworks @@ -48,19 +46,16 @@ #include #include - #include "os-shared-globaldefs.h" +#define OSAPI_TEST_FUNCTION_RC(func, args, exp) \ + { \ + int32 rcexp = exp; \ + int32 rcact = func args; \ + UtAssert_True(rcact == rcexp, "%s%s (%ld) == %s (%ld)", #func, #args, (long)rcact, #exp, (long)rcexp); \ + } -#define OSAPI_TEST_FUNCTION_RC(func,args,exp) \ -{ \ - int32 rcexp = exp; \ - int32 rcact = func args; \ - UtAssert_True(rcact == rcexp, "%s%s (%ld) == %s (%ld)", \ - #func, #args, (long)rcact, #exp, (long)rcexp); \ -} - -#define ADD_TEST(test) UtTest_Add((Test_ ## test), Osapi_Test_Setup, Osapi_Test_Teardown, #test) +#define ADD_TEST(test) UtTest_Add((Test_##test), Osapi_Test_Setup, Osapi_Test_Teardown, #test) /* Osapi_Test_Setup * @@ -70,9 +65,6 @@ void Osapi_Test_Setup(void); void Osapi_Test_Teardown(void); +#endif /* _OS_PORTABLE_COVERAGETEST_H_ */ -#endif /* _OS_PORTABLE_COVERAGETEST_H_ */ - - -#endif /* INCLUDE_OS_PORTABLE_COVERAGETEST_H_ */ - +#endif /* INCLUDE_OS_PORTABLE_COVERAGETEST_H_ */ diff --git a/src/unit-test-coverage/shared/adaptors/inc/ut-adaptor-module.h b/src/unit-test-coverage/shared/adaptors/inc/ut-adaptor-module.h index 62a2296ed..354027f89 100644 --- a/src/unit-test-coverage/shared/adaptors/inc/ut-adaptor-module.h +++ b/src/unit-test-coverage/shared/adaptors/inc/ut-adaptor-module.h @@ -52,5 +52,4 @@ void Test_DummyFunc(void); int32 Osapi_Call_SymbolLookup_Static(cpuaddr *SymbolAddress, const char *SymbolName); int32 Osapi_Call_ModuleLoad_Static(const char *ModuleName); -#endif /* INCLUDE_UT_ADAPTOR_MODULE_H_ */ - +#endif /* INCLUDE_UT_ADAPTOR_MODULE_H_ */ diff --git a/src/unit-test-coverage/shared/adaptors/src/ut-adaptor-module.c b/src/unit-test-coverage/shared/adaptors/src/ut-adaptor-module.c index e6f598c80..8963abdc7 100644 --- a/src/unit-test-coverage/shared/adaptors/src/ut-adaptor-module.c +++ b/src/unit-test-coverage/shared/adaptors/src/ut-adaptor-module.c @@ -28,7 +28,6 @@ #include "ut-adaptor-module.h" #include "os-shared-module.h" - int32 Osapi_Call_SymbolLookup_Static(cpuaddr *SymbolAddress, const char *SymbolName) { return OS_SymbolLookup_Static(SymbolAddress, SymbolName); @@ -38,4 +37,3 @@ int32 Osapi_Call_ModuleLoad_Static(const char *ModuleName) { return OS_ModuleLoad_Static(ModuleName); } - diff --git a/src/unit-test-coverage/shared/src/coveragetest-binsem.c b/src/unit-test-coverage/shared/src/coveragetest-binsem.c index 251c8efde..07c605722 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-binsem.c +++ b/src/unit-test-coverage/shared/src/coveragetest-binsem.c @@ -42,12 +42,11 @@ void Test_OS_BinSemAPI_Init(void) * int32 OS_BinSemAPI_Init(void) */ int32 expected = OS_SUCCESS; - int32 actual = OS_BinSemAPI_Init(); + int32 actual = OS_BinSemAPI_Init(); UtAssert_True(actual == expected, "OS_BinSemAPI_Init() (%ld) == OS_SUCCESS", (long)actual); } - void Test_OS_BinSemCreate(void) { /* @@ -55,12 +54,12 @@ void Test_OS_BinSemCreate(void) * int32 OS_BinSemCreate (uint32 *sem_id, const char *sem_name, * uint32 sem_initial_value, uint32 options) */ - int32 expected = OS_SUCCESS; + int32 expected = OS_SUCCESS; osal_id_t objid; - int32 actual = OS_BinSemCreate(&objid, "UT", 0,0); + int32 actual = OS_BinSemCreate(&objid, "UT", 0, 0); UtAssert_True(actual == expected, "OS_BinSemCreate() (%ld) == OS_SUCCESS", (long)actual); - OSAPI_TEST_OBJID(objid,!=,OS_OBJECT_ID_UNDEFINED); + OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); OSAPI_TEST_FUNCTION_RC(OS_BinSemCreate(NULL, NULL, 0, 0), OS_INVALID_POINTER); UT_SetForceFail(UT_KEY(OCS_strlen), 10 + OS_MAX_API_NAME); @@ -74,7 +73,7 @@ void Test_OS_BinSemDelete(void) * int32 OS_BinSemDelete (uint32 sem_id) */ int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 actual = ~OS_SUCCESS; actual = OS_BinSemDelete(UT_OBJID_1); @@ -88,14 +87,13 @@ void Test_OS_BinSemGive(void) * int32 OS_BinSemGive ( uint32 sem_id ) */ int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 actual = ~OS_SUCCESS; actual = OS_BinSemGive(UT_OBJID_1); UtAssert_True(actual == expected, "OS_BinSemGive() (%ld) == OS_SUCCESS", (long)actual); } - void Test_OS_BinSemTake(void) { /* @@ -103,7 +101,7 @@ void Test_OS_BinSemTake(void) * int32 OS_BinSemTake ( uint32 sem_id ) */ int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 actual = ~OS_SUCCESS; actual = OS_BinSemTake(UT_OBJID_1); @@ -117,7 +115,7 @@ void Test_OS_BinSemFlush(void) * int32 OS_BinSemFlush (uint32 sem_id) */ int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 actual = ~OS_SUCCESS; actual = OS_BinSemFlush(UT_OBJID_1); @@ -131,34 +129,32 @@ void Test_OS_BinSemTimedWait(void) * int32 OS_BinSemTimedWait ( uint32 sem_id, uint32 msecs ) */ int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 actual = ~OS_SUCCESS; - actual = OS_BinSemTimedWait(UT_OBJID_1,1); + actual = OS_BinSemTimedWait(UT_OBJID_1, 1); UtAssert_True(actual == expected, "OS_BinSemTimedWait() (%ld) == OS_SUCCESS", (long)actual); } - void Test_OS_BinSemGetIdByName(void) { /* * Test Case For: * int32 OS_BinSemGetIdByName (uint32 *sem_id, const char *sem_name) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; osal_id_t objid; UT_SetForceFail(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); actual = OS_BinSemGetIdByName(&objid, "UT"); UtAssert_True(actual == expected, "OS_BinSemGetIdByName() (%ld) == OS_SUCCESS", (long)actual); - OSAPI_TEST_OBJID(objid,!=,OS_OBJECT_ID_UNDEFINED); + OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); UT_ClearForceFail(UT_KEY(OS_ObjectIdFindByName)); expected = OS_ERR_NAME_NOT_FOUND; - actual = OS_BinSemGetIdByName(&objid, "NF"); - UtAssert_True(actual == expected, "OS_BinSemGetIdByName() (%ld) == %ld", - (long)actual, (long)expected); + actual = OS_BinSemGetIdByName(&objid, "NF"); + UtAssert_True(actual == expected, "OS_BinSemGetIdByName() (%ld) == %ld", (long)actual, (long)expected); OSAPI_TEST_FUNCTION_RC(OS_BinSemGetIdByName(NULL, NULL), OS_INVALID_POINTER); } @@ -169,31 +165,27 @@ void Test_OS_BinSemGetInfo(void) * Test Case For: * int32 OS_BinSemGetInfo (uint32 sem_id, OS_bin_sem_prop_t *bin_prop) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; - OS_bin_sem_prop_t prop; - uint32 local_index = 1; - OS_common_record_t utrec; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; + OS_bin_sem_prop_t prop; + uint32 local_index = 1; + OS_common_record_t utrec; OS_common_record_t *rptr = &utrec; memset(&utrec, 0, sizeof(utrec)); - utrec.creator = UT_OBJID_OTHER; + utrec.creator = UT_OBJID_OTHER; utrec.name_entry = "ABC"; UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &local_index, sizeof(local_index), false); UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &rptr, sizeof(rptr), false); actual = OS_BinSemGetInfo(UT_OBJID_1, &prop); UtAssert_True(actual == expected, "OS_BinSemGetInfo() (%ld) == OS_SUCCESS", (long)actual); - OSAPI_TEST_OBJID(prop.creator,==,UT_OBJID_OTHER); - UtAssert_True(strcmp(prop.name, "ABC") == 0, "prop.name (%s) == ABC", - prop.name); - + OSAPI_TEST_OBJID(prop.creator, ==, UT_OBJID_OTHER); + UtAssert_True(strcmp(prop.name, "ABC") == 0, "prop.name (%s) == ABC", prop.name); OSAPI_TEST_FUNCTION_RC(OS_BinSemGetInfo(UT_OBJID_1, NULL), OS_INVALID_POINTER); } - - /* Osapi_Test_Setup * * Purpose: @@ -210,10 +202,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* * Register the test cases to execute with the unit test tool @@ -230,8 +219,3 @@ void UtTest_Setup(void) ADD_TEST(OS_BinSemGetIdByName); ADD_TEST(OS_BinSemGetInfo); } - - - - - diff --git a/src/unit-test-coverage/shared/src/coveragetest-clock.c b/src/unit-test-coverage/shared/src/coveragetest-clock.c index 3e6527c99..1e7b9b538 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-clock.c +++ b/src/unit-test-coverage/shared/src/coveragetest-clock.c @@ -34,15 +34,14 @@ void Test_OS_GetLocalTime(void) * int32 OS_GetLocalTime(OS_time_t *time_struct) */ OS_time_t time_struct; - int32 expected = OS_SUCCESS; - int32 actual = OS_GetLocalTime(&time_struct); + int32 expected = OS_SUCCESS; + int32 actual = OS_GetLocalTime(&time_struct); UtAssert_True(actual == expected, "OS_GetLocalTime() (%ld) == OS_SUCCESS", (long)actual); expected = OS_INVALID_POINTER; actual = OS_GetLocalTime(NULL); UtAssert_True(actual == expected, "OS_GetLocalTime() (%ld) == OS_INVALID_POINTER", (long)actual); - } void Test_OS_SetLocalTime(void) @@ -52,8 +51,8 @@ void Test_OS_SetLocalTime(void) * int32 OS_SetLocalTime(OS_time_t *time_struct) */ OS_time_t time_struct; - int32 expected = OS_SUCCESS; - int32 actual = OS_SetLocalTime(&time_struct); + int32 expected = OS_SUCCESS; + int32 actual = OS_SetLocalTime(&time_struct); UtAssert_True(actual == expected, "OS_SetLocalTime() (%ld) == OS_SUCCESS", (long)actual); @@ -78,10 +77,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* * Register the test cases to execute with the unit test tool @@ -91,7 +87,3 @@ void UtTest_Setup(void) ADD_TEST(OS_GetLocalTime); ADD_TEST(OS_SetLocalTime); } - - - - diff --git a/src/unit-test-coverage/shared/src/coveragetest-common.c b/src/unit-test-coverage/shared/src/coveragetest-common.c index a999d0b5e..c200e96be 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-common.c +++ b/src/unit-test-coverage/shared/src/coveragetest-common.c @@ -38,9 +38,8 @@ */ extern void OS_CleanUpObject(osal_id_t object_id, void *arg); - int32 Test_MicroSecPerTick = 0; -int32 Test_TicksPerSecond = 0; +int32 Test_TicksPerSecond = 0; /* ********************************************************************************** @@ -52,13 +51,13 @@ int32 Test_TicksPerSecond = 0; static int32 TimeBaseInitGlobal(void *UserObj, int32 StubRetcode, uint32 CallCount, const UT_StubContext_t *Context) { OS_SharedGlobalVars.MicroSecPerTick = Test_MicroSecPerTick; - OS_SharedGlobalVars.TicksPerSecond = Test_TicksPerSecond; + OS_SharedGlobalVars.TicksPerSecond = Test_TicksPerSecond; return StubRetcode; } static int32 ObjectDeleteCountHook(void *UserObj, int32 StubRetcode, uint32 CallCount, const UT_StubContext_t *Context) { - uint32 *counter = (uint32*)Context->ArgPtr[1]; + uint32 *counter = (uint32 *)Context->ArgPtr[1]; if (CallCount == 0) { @@ -78,8 +77,6 @@ static int32 SetShutdownFlagHook(void *UserObj, int32 StubRetcode, uint32 CallCo return StubRetcode; } - - /* ********************************************************************************** ** PUBLIC API FUNCTIONS @@ -91,18 +88,18 @@ void Test_OS_API_Init(void) UT_SetHookFunction(UT_KEY(OS_TimeBaseAPI_Init), TimeBaseInitGlobal, NULL); /* Execute Test */ - Test_MicroSecPerTick = 0; - Test_TicksPerSecond = 0; + Test_MicroSecPerTick = 0; + Test_TicksPerSecond = 0; OS_SharedGlobalVars.Initialized = false; OSAPI_TEST_FUNCTION_RC(OS_API_Init(), OS_ERROR); - Test_MicroSecPerTick = 1000; - Test_TicksPerSecond = 1000; + Test_MicroSecPerTick = 1000; + Test_TicksPerSecond = 1000; OS_SharedGlobalVars.Initialized = false; OSAPI_TEST_FUNCTION_RC(OS_API_Init(), OS_SUCCESS); - Test_MicroSecPerTick = 1000; - Test_TicksPerSecond = 1001; + Test_MicroSecPerTick = 1000; + Test_TicksPerSecond = 1001; OS_SharedGlobalVars.Initialized = false; OSAPI_TEST_FUNCTION_RC(OS_API_Init(), OS_SUCCESS); @@ -124,7 +121,6 @@ void Test_OS_API_Init(void) UT_SetForceFail(UT_KEY(OS_TaskAPI_Init), -444); OSAPI_TEST_FUNCTION_RC(OS_API_Init(), -444); UT_ResetState(UT_KEY(OS_TaskAPI_Init)); - } void Test_OS_ApplicationExit(void) @@ -143,55 +139,55 @@ void Test_OS_ApplicationExit(void) void Test_OS_CleanUpObject(void) { - uint32 objtype; - uint32 CallCount; - uint32 ActualObjs; - uint32 ExpObjs; + uint32 objtype; + uint32 CallCount; + uint32 ActualObjs; + uint32 ExpObjs; UT_EntryKey_t delhandler; ActualObjs = 0; - ExpObjs = 0; - objtype = OS_OBJECT_TYPE_UNDEFINED; + ExpObjs = 0; + objtype = OS_OBJECT_TYPE_UNDEFINED; while (objtype < OS_OBJECT_TYPE_USER) { UT_ResetState(0); UT_SetForceFail(UT_KEY(OS_IdentifyObject), objtype); - switch(objtype) + switch (objtype) { - case OS_OBJECT_TYPE_OS_TASK: - delhandler = UT_KEY(OS_TaskDelete); - break; - case OS_OBJECT_TYPE_OS_QUEUE: - delhandler = UT_KEY(OS_QueueDelete); - break; - case OS_OBJECT_TYPE_OS_BINSEM: - delhandler = UT_KEY(OS_BinSemDelete); - break; - case OS_OBJECT_TYPE_OS_COUNTSEM: - delhandler = UT_KEY(OS_CountSemDelete); - break; - case OS_OBJECT_TYPE_OS_MUTEX: - delhandler = UT_KEY(OS_MutSemDelete); - break; - case OS_OBJECT_TYPE_OS_MODULE: - delhandler = UT_KEY(OS_ModuleUnload); - break; - case OS_OBJECT_TYPE_OS_TIMEBASE: - delhandler = UT_KEY(OS_TimeBaseDelete); - break; - case OS_OBJECT_TYPE_OS_TIMECB: - delhandler = UT_KEY(OS_TimerDelete); - break; - case OS_OBJECT_TYPE_OS_STREAM: - delhandler = UT_KEY(OS_close); - break; - case OS_OBJECT_TYPE_OS_DIR: - delhandler = UT_KEY(OS_DirectoryClose); - break; - default: - delhandler = 0; - break; + case OS_OBJECT_TYPE_OS_TASK: + delhandler = UT_KEY(OS_TaskDelete); + break; + case OS_OBJECT_TYPE_OS_QUEUE: + delhandler = UT_KEY(OS_QueueDelete); + break; + case OS_OBJECT_TYPE_OS_BINSEM: + delhandler = UT_KEY(OS_BinSemDelete); + break; + case OS_OBJECT_TYPE_OS_COUNTSEM: + delhandler = UT_KEY(OS_CountSemDelete); + break; + case OS_OBJECT_TYPE_OS_MUTEX: + delhandler = UT_KEY(OS_MutSemDelete); + break; + case OS_OBJECT_TYPE_OS_MODULE: + delhandler = UT_KEY(OS_ModuleUnload); + break; + case OS_OBJECT_TYPE_OS_TIMEBASE: + delhandler = UT_KEY(OS_TimeBaseDelete); + break; + case OS_OBJECT_TYPE_OS_TIMECB: + delhandler = UT_KEY(OS_TimerDelete); + break; + case OS_OBJECT_TYPE_OS_STREAM: + delhandler = UT_KEY(OS_close); + break; + case OS_OBJECT_TYPE_OS_DIR: + delhandler = UT_KEY(OS_DirectoryClose); + break; + default: + delhandler = 0; + break; } if (delhandler != 0) @@ -203,8 +199,8 @@ void Test_OS_CleanUpObject(void) OS_CleanUpObject(OS_OBJECT_ID_UNDEFINED, &ActualObjs); CallCount = UT_GetStubCount(delhandler); - UtAssert_True(CallCount == 1, "Objtype %lu call count (%lu) == 1", - (unsigned long)objtype, (unsigned long)CallCount); + UtAssert_True(CallCount == 1, "Objtype %lu call count (%lu) == 1", (unsigned long)objtype, + (unsigned long)CallCount); } else { @@ -214,9 +210,8 @@ void Test_OS_CleanUpObject(void) ++ExpObjs; } - - UtAssert_True(ActualObjs == ExpObjs, "Total objects cleaned up (%lu) == %lu", - (unsigned long)ActualObjs, (unsigned long)ExpObjs); + UtAssert_True(ActualObjs == ExpObjs, "Total objects cleaned up (%lu) == %lu", (unsigned long)ActualObjs, + (unsigned long)ExpObjs); } void Test_OS_DeleteAllObjects(void) @@ -232,7 +227,6 @@ void Test_OS_DeleteAllObjects(void) * OS_CleanUpObject() will be covered separately. */ - /* * The "ForEachObject" API will be invoked in a loop. * For the first pass, have it output nonzero @@ -240,16 +234,13 @@ void Test_OS_DeleteAllObjects(void) */ UT_SetHookFunction(UT_KEY(OS_ForEachObject), ObjectDeleteCountHook, NULL); - /* * This gets coverage of the function but * there is nothing to assert/verify for postconditions here */ OS_DeleteAllObjects(); - } - void Test_OS_IdleLoopAndShutdown(void) { /* @@ -264,9 +255,7 @@ void Test_OS_IdleLoopAndShutdown(void) CallCount = UT_GetStubCount(UT_KEY(OS_ApplicationShutdown_Impl)); - UtAssert_True(CallCount == 1, "OS_ApplicationShutdown_Impl() call count (%lu) == 1", - (unsigned long)CallCount); - + UtAssert_True(CallCount == 1, "OS_ApplicationShutdown_Impl() call count (%lu) == 1", (unsigned long)CallCount); } /* ------------------- End of test cases --------------------------------------*/ @@ -287,10 +276,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* * Register the test cases to execute with the unit test tool @@ -303,8 +289,3 @@ void UtTest_Setup(void) ADD_TEST(OS_IdleLoopAndShutdown); ADD_TEST(OS_ApplicationExit); } - - - - - diff --git a/src/unit-test-coverage/shared/src/coveragetest-countsem.c b/src/unit-test-coverage/shared/src/coveragetest-countsem.c index aeebf5ec3..5afc26277 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-countsem.c +++ b/src/unit-test-coverage/shared/src/coveragetest-countsem.c @@ -42,12 +42,11 @@ void Test_OS_CountSemAPI_Init(void) * int32 OS_CountSemAPI_Init(void) */ int32 expected = OS_SUCCESS; - int32 actual = OS_CountSemAPI_Init(); + int32 actual = OS_CountSemAPI_Init(); UtAssert_True(actual == expected, "OS_CountSemAPI_Init() (%ld) == OS_SUCCESS", (long)actual); } - void Test_OS_CountSemCreate(void) { /* @@ -55,13 +54,13 @@ void Test_OS_CountSemCreate(void) * int32 OS_CountSemCreate (uint32 *sem_id, const char *sem_name, * uint32 sem_initial_value, uint32 options) */ - int32 expected = OS_SUCCESS; + int32 expected = OS_SUCCESS; osal_id_t objid; - int32 actual = OS_CountSemCreate(&objid, "UT", 0,0); + int32 actual = OS_CountSemCreate(&objid, "UT", 0, 0); UtAssert_True(actual == expected, "OS_CountSemCreate() (%ld) == OS_SUCCESS", (long)actual); #ifdef jphfix - OSAPI_TEST_OBJID(objid,!=,OS_OBJECT_ID_UNDEFINED); + OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); #endif OSAPI_TEST_FUNCTION_RC(OS_CountSemCreate(NULL, NULL, 0, 0), OS_INVALID_POINTER); @@ -76,7 +75,7 @@ void Test_OS_CountSemDelete(void) * int32 OS_CountSemDelete (uint32 sem_id) */ int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 actual = ~OS_SUCCESS; actual = OS_CountSemDelete(UT_OBJID_1); @@ -90,14 +89,13 @@ void Test_OS_CountSemGive(void) * int32 OS_CountSemGive ( uint32 sem_id ) */ int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 actual = ~OS_SUCCESS; actual = OS_CountSemGive(UT_OBJID_1); UtAssert_True(actual == expected, "OS_CountSemGive() (%ld) == OS_SUCCESS", (long)actual); } - void Test_OS_CountSemTake(void) { /* @@ -105,7 +103,7 @@ void Test_OS_CountSemTake(void) * int32 OS_CountSemTake ( uint32 sem_id ) */ int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 actual = ~OS_SUCCESS; actual = OS_CountSemTake(UT_OBJID_1); @@ -119,38 +117,34 @@ void Test_OS_CountSemTimedWait(void) * int32 OS_CountSemTimedWait ( uint32 sem_id, uint32 msecs ) */ int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 actual = ~OS_SUCCESS; - actual = OS_CountSemTimedWait(UT_OBJID_1,1); + actual = OS_CountSemTimedWait(UT_OBJID_1, 1); UtAssert_True(actual == expected, "OS_CountSemTimedWait() (%ld) == OS_SUCCESS", (long)actual); } - void Test_OS_CountSemGetIdByName(void) { /* * Test Case For: * int32 OS_CountSemGetIdByName (uint32 *sem_id, const char *sem_name) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; osal_id_t objid; UT_SetForceFail(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); actual = OS_CountSemGetIdByName(&objid, "UT"); UtAssert_True(actual == expected, "OS_CountSemGetIdByName() (%ld) == OS_SUCCESS", (long)actual); - OSAPI_TEST_OBJID(objid,!=,OS_OBJECT_ID_UNDEFINED); + OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); UT_ClearForceFail(UT_KEY(OS_ObjectIdFindByName)); - expected = OS_ERR_NAME_NOT_FOUND; - actual = OS_CountSemGetIdByName(&objid, "NF"); - UtAssert_True(actual == expected, "OS_CountSemGetIdByName() (%ld) == %ld", - (long)actual, (long)expected); + actual = OS_CountSemGetIdByName(&objid, "NF"); + UtAssert_True(actual == expected, "OS_CountSemGetIdByName() (%ld) == %ld", (long)actual, (long)expected); OSAPI_TEST_FUNCTION_RC(OS_CountSemGetIdByName(NULL, NULL), OS_INVALID_POINTER); - } void Test_OS_CountSemGetInfo(void) @@ -159,15 +153,15 @@ void Test_OS_CountSemGetInfo(void) * Test Case For: * int32 OS_CountSemGetInfo (uint32 sem_id, OS_count_sem_prop_t *count_prop) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; OS_count_sem_prop_t prop; - uint32 local_index = 1; - OS_common_record_t utrec; + uint32 local_index = 1; + OS_common_record_t utrec; OS_common_record_t *rptr = &utrec; memset(&utrec, 0, sizeof(utrec)); - utrec.creator = UT_OBJID_OTHER; + utrec.creator = UT_OBJID_OTHER; utrec.name_entry = "ABC"; UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &local_index, sizeof(local_index), false); UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &rptr, sizeof(rptr), false); @@ -175,17 +169,13 @@ void Test_OS_CountSemGetInfo(void) UtAssert_True(actual == expected, "OS_CountSemGetInfo() (%ld) == OS_SUCCESS", (long)actual); #ifdef jphfix - UtAssert_True(prop.creator == 111, "prop.creator (%lu) == 111", - (unsigned long)prop.creator); + UtAssert_True(prop.creator == 111, "prop.creator (%lu) == 111", (unsigned long)prop.creator); #endif - UtAssert_True(strcmp(prop.name, "ABC") == 0, "prop.name (%s) == ABC", - prop.name); + UtAssert_True(strcmp(prop.name, "ABC") == 0, "prop.name (%s) == ABC", prop.name); OSAPI_TEST_FUNCTION_RC(OS_CountSemGetInfo(UT_OBJID_1, NULL), OS_INVALID_POINTER); } - - /* Osapi_Test_Setup * * Purpose: @@ -202,10 +192,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* * Register the test cases to execute with the unit test tool @@ -221,8 +208,3 @@ void UtTest_Setup(void) ADD_TEST(OS_CountSemGetIdByName); ADD_TEST(OS_CountSemGetInfo); } - - - - - diff --git a/src/unit-test-coverage/shared/src/coveragetest-dir.c b/src/unit-test-coverage/shared/src/coveragetest-dir.c index aecf0c723..94cf59ab7 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-dir.c +++ b/src/unit-test-coverage/shared/src/coveragetest-dir.c @@ -40,12 +40,11 @@ void Test_OS_DirAPI_Init(void) * int32 OS_DirAPI_Init(void) */ int32 expected = OS_SUCCESS; - int32 actual = OS_DirAPI_Init(); + int32 actual = OS_DirAPI_Init(); UtAssert_True(actual == expected, "OS_DirAPI_Init() (%ld) == OS_SUCCESS", (long)actual); } - void Test_OS_mkdir(void) { /* @@ -53,29 +52,27 @@ void Test_OS_mkdir(void) * int32 OS_mkdir (const char *path, uint32 access) */ int32 expected = OS_SUCCESS; - int32 actual = OS_mkdir("Dir", 0); + int32 actual = OS_mkdir("Dir", 0); UtAssert_True(actual == expected, "OS_mkdir() (%ld) == OS_SUCCESS", (long)actual); } - void Test_OS_DirectoryOpen(void) { /* * Test Case For: * int32 OS_DirectoryOpen(uint32 *dir_id, const char *path) */ - int32 expected = OS_SUCCESS; + int32 expected = OS_SUCCESS; osal_id_t objid; - int32 actual = OS_DirectoryOpen(&objid, "Dir"); + int32 actual = OS_DirectoryOpen(&objid, "Dir"); UtAssert_True(actual == expected, "OS_DirectoryOpen() (%ld) == OS_SUCCESS", (long)actual); - OSAPI_TEST_OBJID(objid,!=,OS_OBJECT_ID_UNDEFINED); + OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); OSAPI_TEST_FUNCTION_RC(OS_DirectoryOpen(NULL, NULL), OS_INVALID_POINTER); } - void Test_OS_DirectoryClose(void) { /* @@ -83,19 +80,18 @@ void Test_OS_DirectoryClose(void) * int32 OS_DirectoryClose(uint32 dir_id) */ int32 expected = OS_SUCCESS; - int32 actual = OS_DirectoryClose(UT_OBJID_1); + int32 actual = OS_DirectoryClose(UT_OBJID_1); UtAssert_True(actual == expected, "OS_DirectoryClose() (%ld) == OS_SUCCESS", (long)actual); } - void Test_OS_DirectoryRead(void) { /* * Test Case For: * int32 OS_DirectoryRead(uint32 dir_id, OS_DirEntry_t *dirent) */ - int32 expected = OS_SUCCESS; + int32 expected = OS_SUCCESS; os_dirent_t dirent; int32 actual = OS_DirectoryRead(UT_OBJID_1, &dirent); @@ -105,7 +101,6 @@ void Test_OS_DirectoryRead(void) OSAPI_TEST_FUNCTION_RC(OS_DirectoryRead(UT_OBJID_1, NULL), OS_INVALID_POINTER); } - void Test_OS_DirectoryRewind(void) { /* @@ -113,12 +108,11 @@ void Test_OS_DirectoryRewind(void) * int32 OS_DirectoryRewind(uint32 dir_id) */ int32 expected = OS_SUCCESS; - int32 actual = OS_DirectoryRewind(UT_OBJID_1); + int32 actual = OS_DirectoryRewind(UT_OBJID_1); UtAssert_True(actual == expected, "OS_DirectoryRewind() (%ld) == OS_SUCCESS", (long)actual); } - void Test_OS_rmdir(void) { /* @@ -126,13 +120,11 @@ void Test_OS_rmdir(void) * int32 OS_rmdir (const char *path) */ int32 expected = OS_SUCCESS; - int32 actual = OS_rmdir("Dir"); + int32 actual = OS_rmdir("Dir"); UtAssert_True(actual == expected, "OS_rmdir() (%ld) == OS_SUCCESS", (long)actual); } - - /* Osapi_Test_Setup * * Purpose: @@ -149,11 +141,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} - +void Osapi_Test_Teardown(void) {} /* * Register the test cases to execute with the unit test tool @@ -168,8 +156,3 @@ void UtTest_Setup(void) ADD_TEST(OS_DirectoryRewind); ADD_TEST(OS_rmdir); } - - - - - diff --git a/src/unit-test-coverage/shared/src/coveragetest-errors.c b/src/unit-test-coverage/shared/src/coveragetest-errors.c index b8f2b578f..3afea3e05 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-errors.c +++ b/src/unit-test-coverage/shared/src/coveragetest-errors.c @@ -34,11 +34,11 @@ void Test_OS_GetErrorName(void) * int32 OS_GetErrorName(int32 error_num, os_err_name_t* err_name); */ os_err_name_t err_name; - int32 expected = OS_SUCCESS; - int32 actual = OS_GetErrorName(OS_ERROR, &err_name); + int32 expected = OS_SUCCESS; + int32 actual = OS_GetErrorName(OS_ERROR, &err_name); UtAssert_True(actual == expected, "OS_GetErrorName(%s) (%ld) == OS_SUCCESS", "OS_ERROR", (long)actual); - UtAssert_True(strcmp(err_name,"OS_ERROR") == 0, "string(%s) == OS_ERROR", err_name); + UtAssert_True(strcmp(err_name, "OS_ERROR") == 0, "string(%s) == OS_ERROR", err_name); expected = OS_ERROR; actual = OS_GetErrorName(-555555, &err_name); @@ -65,10 +65,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* * Register the test cases to execute with the unit test tool @@ -77,7 +74,3 @@ void UtTest_Setup(void) { ADD_TEST(OS_GetErrorName); } - - - - diff --git a/src/unit-test-coverage/shared/src/coveragetest-file.c b/src/unit-test-coverage/shared/src/coveragetest-file.c index 46071b2ff..74893e81a 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-file.c +++ b/src/unit-test-coverage/shared/src/coveragetest-file.c @@ -43,7 +43,7 @@ void Test_OS_FileAPI_Init(void) * int32 OS_FileAPI_Init(void) */ int32 expected = OS_SUCCESS; - int32 actual = OS_FileAPI_Init(); + int32 actual = OS_FileAPI_Init(); UtAssert_True(actual == expected, "OS_FileAPI_Init() (%ld) == OS_SUCCESS", (long)actual); } @@ -54,13 +54,13 @@ void Test_OS_OpenCreate(void) * Test Case For: * int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 access) */ - int32 expected; - int32 actual; + int32 expected; + int32 actual; osal_id_t filedes; /* Test in OS_creat mode */ expected = OS_SUCCESS; - actual = OS_OpenCreate(&filedes, "/cf/file", OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + actual = OS_OpenCreate(&filedes, "/cf/file", OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); UtAssert_True(actual == expected, "OS_OpenCreate() (%ld) == OS_SUCCESS (create mode)", (long)actual); /* Test in OS_open mode */ @@ -69,22 +69,20 @@ void Test_OS_OpenCreate(void) /* Test with bad descriptor buffer */ expected = OS_INVALID_POINTER; - actual = OS_OpenCreate(NULL, "/cf/file", OS_FILE_FLAG_NONE, OS_READ_WRITE); + actual = OS_OpenCreate(NULL, "/cf/file", OS_FILE_FLAG_NONE, OS_READ_WRITE); UtAssert_True(actual == expected, "OS_OpenCreate() (%ld) == OS_INVALID_POINTER (bad buffer)", (long)actual); /* Test with bad access flags */ expected = OS_ERROR; - actual = OS_OpenCreate(&filedes, "/cf/file", OS_FILE_FLAG_NONE, 9999); + actual = OS_OpenCreate(&filedes, "/cf/file", OS_FILE_FLAG_NONE, 9999); UtAssert_True(actual == expected, "OS_OpenCreate() (%ld) == OS_ERROR (bad flags)", (long)actual); - /* Test failure to convert path */ UT_SetForceFail(UT_KEY(OS_TranslatePath), OS_ERROR); expected = OS_ERROR; - actual = OS_OpenCreate(&filedes, "/cf/file", OS_FILE_FLAG_NONE, OS_READ_WRITE); + actual = OS_OpenCreate(&filedes, "/cf/file", OS_FILE_FLAG_NONE, OS_READ_WRITE); UtAssert_True(actual == OS_ERROR, "OS_OpenCreate() (%ld) == OS_ERROR (bad path)", (long)actual); UT_ClearForceFail(UT_KEY(OS_TranslatePath)); - } void Test_OS_close(void) @@ -94,101 +92,89 @@ void Test_OS_close(void) * int32 OS_close (uint32 filedes) */ int32 expected = OS_SUCCESS; - int32 actual = OS_close(UT_OBJID_1); + int32 actual = OS_close(UT_OBJID_1); UtAssert_True(actual == expected, "OS_close() (%ld) == OS_SUCCESS", (long)actual); } - void Test_OS_TimedRead(void) { /* * Test Case For: * int32 OS_TimedRead(uint32 filedes, void *buffer, uint32 nbytes, int32 timeout) */ - char Buf[4] = "zzz"; - char SrcBuf[8] = "rrrrrrr"; - int32 expected = sizeof(Buf); - int32 actual = 0; + char Buf[4] = "zzz"; + char SrcBuf[8] = "rrrrrrr"; + int32 expected = sizeof(Buf); + int32 actual = 0; UT_SetDataBuffer(UT_KEY(OS_GenericRead_Impl), SrcBuf, sizeof(SrcBuf), false); actual = OS_TimedRead(UT_OBJID_1, Buf, sizeof(Buf), 10); - UtAssert_True(actual == expected, "OS_TimedRead() (%ld) == %ld", - (long)actual, (long)expected); - UtAssert_True(memcmp(Buf,SrcBuf,actual) == 0, "buffer content match"); + UtAssert_True(actual == expected, "OS_TimedRead() (%ld) == %ld", (long)actual, (long)expected); + UtAssert_True(memcmp(Buf, SrcBuf, actual) == 0, "buffer content match"); expected = OS_INVALID_POINTER; - actual = OS_TimedRead(UT_OBJID_1, NULL, sizeof(Buf), 10); - UtAssert_True(actual == expected, "OS_TimedRead() (%ld) == %ld", - (long)actual, (long)expected); + actual = OS_TimedRead(UT_OBJID_1, NULL, sizeof(Buf), 10); + UtAssert_True(actual == expected, "OS_TimedRead() (%ld) == %ld", (long)actual, (long)expected); } - void Test_OS_TimedWrite(void) { /* * Test Case For: * int32 OS_TimedWrite(uint32 filedes, const void *buffer, uint32 nbytes, int32 timeout) */ - const char Buf[4] = "www"; - char DstBuf[8] = "zzz"; - int32 expected = sizeof(Buf); - int32 actual = 0; + const char Buf[4] = "www"; + char DstBuf[8] = "zzz"; + int32 expected = sizeof(Buf); + int32 actual = 0; UT_SetDataBuffer(UT_KEY(OS_GenericWrite_Impl), DstBuf, sizeof(DstBuf), false); actual = OS_TimedWrite(UT_OBJID_1, Buf, sizeof(Buf), 10); - UtAssert_True(actual == expected, "OS_TimedWrite() (%ld) == %ld", - (long)actual, (long)expected); - UtAssert_True(memcmp(Buf,DstBuf,actual) == 0, "buffer content match"); + UtAssert_True(actual == expected, "OS_TimedWrite() (%ld) == %ld", (long)actual, (long)expected); + UtAssert_True(memcmp(Buf, DstBuf, actual) == 0, "buffer content match"); expected = OS_INVALID_POINTER; - actual = OS_TimedWrite(UT_OBJID_1, NULL, sizeof(Buf), 10); - UtAssert_True(actual == expected, "OS_TimedWrite() (%ld) == %ld", - (long)actual, (long)expected); + actual = OS_TimedWrite(UT_OBJID_1, NULL, sizeof(Buf), 10); + UtAssert_True(actual == expected, "OS_TimedWrite() (%ld) == %ld", (long)actual, (long)expected); } - void Test_OS_read(void) { /* * Test Case For: * int32 OS_read (uint32 filedes, void *buffer, uint32 nbytes) */ - char Buf[4] = "zzz"; - char SrcBuf[8] = "RRRRRRR"; - int32 expected = sizeof(Buf); - int32 actual = 0; + char Buf[4] = "zzz"; + char SrcBuf[8] = "RRRRRRR"; + int32 expected = sizeof(Buf); + int32 actual = 0; UT_SetDataBuffer(UT_KEY(OS_GenericRead_Impl), SrcBuf, sizeof(SrcBuf), false); actual = OS_read(UT_OBJID_1, Buf, sizeof(Buf)); - UtAssert_True(actual == expected, "OS_read() (%ld) == %ld", - (long)actual, (long)expected); - UtAssert_True(memcmp(Buf,SrcBuf,actual) == 0, "buffer content match"); + UtAssert_True(actual == expected, "OS_read() (%ld) == %ld", (long)actual, (long)expected); + UtAssert_True(memcmp(Buf, SrcBuf, actual) == 0, "buffer content match"); } - void Test_OS_write(void) { /* * Test Case For: * int32 OS_write (uint32 filedes, const void *buffer, uint32 nbytes) */ - const char Buf[4] = "WWW"; - char DstBuf[8] = "zzz"; - int32 expected = sizeof(Buf); - int32 actual = 0; + const char Buf[4] = "WWW"; + char DstBuf[8] = "zzz"; + int32 expected = sizeof(Buf); + int32 actual = 0; UT_SetDataBuffer(UT_KEY(OS_GenericWrite_Impl), DstBuf, sizeof(DstBuf), false); actual = OS_write(UT_OBJID_1, Buf, sizeof(Buf)); - UtAssert_True(actual == expected, "OS_write() (%ld) == %ld", - (long)actual, (long)expected); - UtAssert_True(memcmp(Buf,DstBuf,actual) == 0, "buffer content match"); - + UtAssert_True(actual == expected, "OS_write() (%ld) == %ld", (long)actual, (long)expected); + UtAssert_True(memcmp(Buf, DstBuf, actual) == 0, "buffer content match"); } - void Test_OS_chmod(void) { /* @@ -196,30 +182,28 @@ void Test_OS_chmod(void) * int32 OS_chmod (const char *path, uint32 access) */ int32 expected = OS_SUCCESS; - int32 actual = OS_chmod("/cf/file", 0); + int32 actual = OS_chmod("/cf/file", 0); UtAssert_True(actual == expected, "OS_chmod() (%ld) == OS_SUCCESS", (long)actual); } - void Test_OS_stat(void) { /* * Test Case For: * int32 OS_stat (const char *path, OS_FileStat_t *filestats) */ - int32 expected = OS_SUCCESS; + int32 expected = OS_SUCCESS; os_fstat_t statbuf; - int32 actual = OS_stat("/cf/file", &statbuf); + int32 actual = OS_stat("/cf/file", &statbuf); UtAssert_True(actual == expected, "OS_stat() (%ld) == OS_SUCCESS", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_stat("/cf/file", NULL); + actual = OS_stat("/cf/file", NULL); UtAssert_True(actual == expected, "OS_stat() (%ld) == OS_INVALID_POINTER", (long)actual); } - void Test_OS_lseek(void) { /* @@ -227,12 +211,11 @@ void Test_OS_lseek(void) * int32 OS_lseek (uint32 filedes, int32 offset, uint32 whence) */ int32 expected = OS_SUCCESS; - int32 actual = OS_lseek(UT_OBJID_1, 0, 0); + int32 actual = OS_lseek(UT_OBJID_1, 0, 0); UtAssert_True(actual == expected, "OS_lseek() (%ld) == OS_SUCCESS", (long)actual); } - void Test_OS_remove(void) { /* @@ -240,12 +223,11 @@ void Test_OS_remove(void) * int32 OS_remove (const char *path) */ int32 expected = OS_SUCCESS; - int32 actual = OS_remove("/cf/file"); + int32 actual = OS_remove("/cf/file"); UtAssert_True(actual == expected, "OS_remove() (%ld) == OS_SUCCESS", (long)actual); } - void Test_OS_rename(void) { /* @@ -253,30 +235,27 @@ void Test_OS_rename(void) * int32 OS_rename (const char *old, const char *new) */ int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 actual = ~OS_SUCCESS; OS_global_stream_table[1].active_id = UT_OBJID_1; - strncpy(OS_stream_table[1].stream_name, "/cf/file1", - sizeof(OS_stream_table[1].stream_name)); + strncpy(OS_stream_table[1].stream_name, "/cf/file1", sizeof(OS_stream_table[1].stream_name)); actual = OS_rename("/cf/file1", "/cf/file2"); UtAssert_True(actual == expected, "OS_rename() (%ld) == OS_SUCCESS", (long)actual); UtAssert_True(strcmp(OS_stream_table[1].stream_name, "/cf/file2") == 0, - "OS_stream_table[1].stream_name (%s) == /cf/file2", - OS_stream_table[1].stream_name); + "OS_stream_table[1].stream_name (%s) == /cf/file2", OS_stream_table[1].stream_name); } - void Test_OS_cp(void) { /* * Test Case For: * int32 OS_cp (const char *src, const char *dest) */ - int32 expected = OS_INVALID_POINTER; - int32 actual = OS_cp(NULL,NULL); - char ReadBuf[] = "cpcpcpcp"; - char WriteBuf[sizeof(ReadBuf)] = ""; + int32 expected = OS_INVALID_POINTER; + int32 actual = OS_cp(NULL, NULL); + char ReadBuf[] = "cpcpcpcp"; + char WriteBuf[sizeof(ReadBuf)] = ""; UtAssert_True(actual == expected, "OS_cp() (%ld) == OS_INVALID_POINTER", (long)actual); @@ -290,24 +269,23 @@ void Test_OS_cp(void) UT_SetForceFail(UT_KEY(OS_GenericRead_Impl), -444); expected = -444; - actual = OS_cp("/cf/file1", "/cf/file2"); + actual = OS_cp("/cf/file1", "/cf/file2"); UtAssert_True(actual == expected, "OS_cp() (%ld) == -444", (long)actual); UT_ClearForceFail(UT_KEY(OS_GenericRead_Impl)); UT_SetDataBuffer(UT_KEY(OS_GenericRead_Impl), ReadBuf, sizeof(ReadBuf), false); UT_SetForceFail(UT_KEY(OS_GenericWrite_Impl), -555); expected = -555; - actual = OS_cp("/cf/file1", "/cf/file2"); + actual = OS_cp("/cf/file1", "/cf/file2"); UtAssert_True(actual == expected, "OS_cp() (%ld) == -555", (long)actual); UT_SetForceFail(UT_KEY(OS_TranslatePath), OS_INVALID_POINTER); expected = OS_INVALID_POINTER; - actual = OS_cp("/cf/file1", "/cf/file2"); + actual = OS_cp("/cf/file1", "/cf/file2"); UtAssert_True(actual == expected, "OS_cp() (%ld) == OS_INVALID_POINTER", (long)actual); UT_ClearForceFail(UT_KEY(OS_TranslatePath)); } - void Test_OS_mv(void) { /* @@ -315,7 +293,7 @@ void Test_OS_mv(void) * int32 OS_mv (const char *src, const char *dest) */ int32 expected = OS_SUCCESS; - int32 actual = OS_mv("/cf/file1", "/cf/file2"); + int32 actual = OS_mv("/cf/file1", "/cf/file2"); UtAssert_True(actual == expected, "OS_mv() (%ld) == OS_SUCCESS", (long)actual); @@ -326,35 +304,32 @@ void Test_OS_mv(void) UtAssert_True(actual == expected, "OS_mv() (%ld) == OS_SUCCESS", (long)actual); } - void Test_OS_FDGetInfo(void) { /* * Test Case For: * int32 OS_FDGetInfo (uint32 filedes, OS_file_prop_t *fd_prop) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; - OS_file_prop_t file_prop; - uint32 local_index = 1; - OS_common_record_t utrec; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; + OS_file_prop_t file_prop; + uint32 local_index = 1; + OS_common_record_t utrec; OS_common_record_t *rptr = &utrec; memset(&utrec, 0, sizeof(utrec)); - utrec.creator = UT_OBJID_OTHER; + utrec.creator = UT_OBJID_OTHER; utrec.name_entry = "ABC"; UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &local_index, sizeof(local_index), false); UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &rptr, sizeof(rptr), false); actual = OS_FDGetInfo(UT_OBJID_1, &file_prop); UtAssert_True(actual == expected, "OS_FDGetInfo() (%ld) == OS_SUCCESS", (long)actual); - UtAssert_True(strcmp(file_prop.Path, "ABC") == 0, "file_prop.Path (%s) == ABC", - file_prop.Path); + UtAssert_True(strcmp(file_prop.Path, "ABC") == 0, "file_prop.Path (%s) == ABC", file_prop.Path); expected = OS_INVALID_POINTER; - actual = OS_FDGetInfo(UT_OBJID_1, NULL); + actual = OS_FDGetInfo(UT_OBJID_1, NULL); UtAssert_True(actual == expected, "OS_FDGetInfo() (%ld) == OS_INVALID_POINTER", (long)actual); - } void Test_OS_FileOpenCheck(void) @@ -364,24 +339,22 @@ void Test_OS_FileOpenCheck(void) * int32 OS_FileOpenCheck(const char *Filename) */ int32 expected = OS_ERROR; - int32 actual = OS_FileOpenCheck("/cf/file"); + int32 actual = OS_FileOpenCheck("/cf/file"); UtAssert_True(actual == expected, "OS_FileOpenCheck() (%ld) == OS_ERROR", (long)actual); OS_global_stream_table[0].active_id = UT_OBJID_1; UT_SetForceFail(UT_KEY(OCS_strcmp), 0); expected = OS_SUCCESS; - actual = OS_FileOpenCheck("/cf/file"); + actual = OS_FileOpenCheck("/cf/file"); UtAssert_True(actual == expected, "OS_FileOpenCheck() (%ld) == OS_SUCCESS", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_FileOpenCheck(NULL); + actual = OS_FileOpenCheck(NULL); UtAssert_True(actual == expected, "OS_FDGetInfo() (%ld) == OS_INVALID_POINTER", (long)actual); - } - void Test_OS_CloseFileByName(void) { /* @@ -389,24 +362,22 @@ void Test_OS_CloseFileByName(void) * int32 OS_CloseFileByName(const char *Filename) */ int32 expected = OS_FS_ERR_PATH_INVALID; - int32 actual = OS_CloseFileByName("/cf/file"); + int32 actual = OS_CloseFileByName("/cf/file"); UtAssert_True(actual == expected, "OS_CloseFileByName() (%ld) == OS_FS_ERR_PATH_INVALID", (long)actual); /* setup for success */ - expected = OS_SUCCESS; + expected = OS_SUCCESS; OS_global_stream_table[0].active_id = UT_OBJID_1; UT_SetForceFail(UT_KEY(OCS_strcmp), 0); actual = OS_CloseFileByName("/cf/file"); UtAssert_True(actual == expected, "OS_CloseFileByName() (%ld) == OS_SUCCESS", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_CloseFileByName(NULL); + actual = OS_CloseFileByName(NULL); UtAssert_True(actual == expected, "OS_CloseFileByName() (%ld) == OS_INVALID_POINTER", (long)actual); - } - void Test_OS_CloseAllFiles(void) { /* @@ -424,10 +395,6 @@ void Test_OS_CloseAllFiles(void) UtAssert_True(actual == expected, "OS_CloseAllFiles() (%ld) == -222", (long)actual); } - - - - /* Osapi_Test_Setup * * Purpose: @@ -446,10 +413,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* * Register the test cases to execute with the unit test tool @@ -475,8 +439,3 @@ void UtTest_Setup(void) ADD_TEST(OS_CloseFileByName); ADD_TEST(OS_CloseAllFiles); } - - - - - diff --git a/src/unit-test-coverage/shared/src/coveragetest-filesys.c b/src/unit-test-coverage/shared/src/coveragetest-filesys.c index 63a8c6728..528d33886 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-filesys.c +++ b/src/unit-test-coverage/shared/src/coveragetest-filesys.c @@ -82,45 +82,44 @@ void Test_OS_mkfs(void) * uint32 blocksize, uint32 numblocks) */ int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 actual = ~OS_SUCCESS; char TestBuffer[128]; - actual = OS_mkfs(TestBuffer,"/ramdev0","vol",0,0); + actual = OS_mkfs(TestBuffer, "/ramdev0", "vol", 0, 0); UtAssert_True(actual == expected, "OS_mkfs() (%ld) == OS_SUCCESS", (long)actual); /* * Test an entry NOT found in the OS_VolumeTable */ - actual = OS_mkfs(TestBuffer,"/rd1","vol1",0,0); + actual = OS_mkfs(TestBuffer, "/rd1", "vol1", 0, 0); UtAssert_True(actual == expected, "OS_mkfs() (%ld) == OS_SUCCESS", (long)actual); - expected = OS_INVALID_POINTER; - actual = OS_mkfs(NULL,NULL,NULL,0,0); + actual = OS_mkfs(NULL, NULL, NULL, 0, 0); UtAssert_True(actual == expected, "OS_mkfs() (%ld) == OS_INVALID_POINTER", (long)actual); UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_FS_DEV_NAME_LEN); expected = OS_FS_ERR_PATH_TOO_LONG; - actual = OS_mkfs(TestBuffer,"/ramdev0","vol",0,0); + actual = OS_mkfs(TestBuffer, "/ramdev0", "vol", 0, 0); UtAssert_True(actual == expected, "OS_mkfs() (%ld) == OS_FS_ERR_PATH_TOO_LONG", (long)actual); UT_ClearForceFail(UT_KEY(OCS_strlen)); /* set up for failure due to empty strings */ expected = OS_FS_ERR_PATH_INVALID; - actual = OS_mkfs(TestBuffer,"","",0,0); + actual = OS_mkfs(TestBuffer, "", "", 0, 0); UtAssert_True(actual == expected, "OS_mkfs() (%ld) == OS_FS_ERR_PATH_INVALID", (long)actual); /* set up for failure due to formatting */ UT_SetForceFail(UT_KEY(OS_FileSysFormatVolume_Impl), OS_FS_ERR_DRIVE_NOT_CREATED); expected = OS_FS_ERR_DRIVE_NOT_CREATED; - actual = OS_mkfs(TestBuffer,"/ramdev0","vol",0,0); + actual = OS_mkfs(TestBuffer, "/ramdev0", "vol", 0, 0); UtAssert_True(actual == expected, "OS_mkfs() (%ld) == OS_FS_ERR_DRIVE_NOT_CREATED (format failure)", (long)actual); /* set up for failure due to no free slots */ UT_SetForceFail(UT_KEY(OS_ObjectIdAllocateNew), OS_ERR_NO_FREE_IDS); expected = OS_FS_ERR_DEVICE_NOT_FREE; - actual = OS_mkfs(TestBuffer,"/ramdev0","vol",0,0); + actual = OS_mkfs(TestBuffer, "/ramdev0", "vol", 0, 0); UtAssert_True(actual == expected, "OS_mkfs() (%ld) == OS_FS_ERR_DEVICE_NOT_FREE", (long)actual); } @@ -131,7 +130,7 @@ void Test_OS_rmfs(void) * int32 OS_rmfs (const char *devname) */ int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 actual = ~OS_SUCCESS; actual = OS_rmfs("/ramdev5"); UtAssert_True(actual == expected, "OS_rmfs() (%ld) == OS_SUCCESS", (long)actual); @@ -139,21 +138,20 @@ void Test_OS_rmfs(void) /* check error paths */ UT_SetForceFail(UT_KEY(OS_ObjectIdGetByName), OS_ERR_NAME_NOT_FOUND); expected = OS_ERR_NAME_NOT_FOUND; - actual = OS_rmfs("/ramdev4"); + actual = OS_rmfs("/ramdev4"); UtAssert_True(actual == expected, "OS_rmfs() (%ld) == OS_ERR_NAME_NOT_FOUND", (long)actual); UT_ClearForceFail(UT_KEY(OS_ObjectIdGetByName)); expected = OS_INVALID_POINTER; - actual = OS_rmfs(NULL); + actual = OS_rmfs(NULL); UtAssert_True(actual == expected, "OS_rmfs() (%ld) == OS_INVALID_POINTER", (long)actual); UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_FS_DEV_NAME_LEN); expected = OS_FS_ERR_PATH_TOO_LONG; - actual = OS_rmfs("/ramdev4"); + actual = OS_rmfs("/ramdev4"); UtAssert_True(actual == expected, "OS_rmfs() (%ld) == OS_FS_ERR_PATH_TOO_LONG", (long)actual); } - void Test_OS_initfs(void) { /* @@ -162,30 +160,30 @@ void Test_OS_initfs(void) * uint32 blocksize, uint32 numblocks) */ int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 actual = ~OS_SUCCESS; char TestBuffer[128]; - actual = OS_initfs(TestBuffer,"/ramdev0","vol",0,0); + actual = OS_initfs(TestBuffer, "/ramdev0", "vol", 0, 0); UtAssert_True(actual == expected, "OS_initfs() (%ld) == OS_SUCCESS", (long)actual); - actual = OS_initfs(NULL,"/hda2","vol2",0,0); + actual = OS_initfs(NULL, "/hda2", "vol2", 0, 0); UtAssert_True(actual == expected, "OS_initfs() (%ld) == OS_SUCCESS", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_initfs(NULL,NULL,NULL,0,0); + actual = OS_initfs(NULL, NULL, NULL, 0, 0); UtAssert_True(actual == expected, "OS_initfs() (%ld) == OS_INVALID_POINTER", (long)actual); UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_FS_DEV_NAME_LEN); expected = OS_FS_ERR_PATH_TOO_LONG; - actual = OS_initfs(TestBuffer,"/ramdev0","vol",0,0); + actual = OS_initfs(TestBuffer, "/ramdev0", "vol", 0, 0); UtAssert_True(actual == expected, "OS_initfs() (%ld) == OS_FS_ERR_PATH_TOO_LONG", (long)actual); UT_ClearForceFail(UT_KEY(OCS_strlen)); /* set up for failure */ UT_SetForceFail(UT_KEY(OS_ObjectIdAllocateNew), OS_ERR_NO_FREE_IDS); expected = OS_FS_ERR_DEVICE_NOT_FREE; - actual = OS_initfs(TestBuffer,"/ramdev0","vol",0,0); + actual = OS_initfs(TestBuffer, "/ramdev0", "vol", 0, 0); UtAssert_True(actual == expected, "OS_initfs() (%ld) == OS_FS_ERR_DEVICE_NOT_FREE", (long)actual); } @@ -199,34 +197,32 @@ void Test_OS_mount(void) int32 actual; expected = OS_ERR_NAME_NOT_FOUND; - actual = OS_mount("/ramdev5","/ram5"); + actual = OS_mount("/ramdev5", "/ram5"); UtAssert_True(actual == expected, "OS_mount() (%ld) == OS_ERR_NAME_NOT_FOUND", (long)actual); /* Test unknown/unset system mountpoint */ - OS_filesys_table[1].flags = OS_FILESYS_FLAG_IS_READY; + OS_filesys_table[1].flags = OS_FILESYS_FLAG_IS_READY; OS_filesys_table[1].system_mountpt[0] = 0; expected = OS_ERR_NAME_NOT_FOUND; /* should be OS_FS_ERR_PATH_INVALID, but compat return overwrites */ - actual = OS_mount("/ramdev5","/ram5"); + actual = OS_mount("/ramdev5", "/ram5"); UtAssert_True(actual == expected, "OS_mount(no mountpt) (%ld) == OS_FS_ERR_PATH_INVALID", (long)actual); /* set up so record is in the right state for mounting */ expected = OS_SUCCESS; snprintf(OS_filesys_table[1].system_mountpt, sizeof(OS_filesys_table[1].system_mountpt), "/ut"); - actual = OS_mount("/ramdev5","/ram5"); + actual = OS_mount("/ramdev5", "/ram5"); UtAssert_True(actual == expected, "OS_mount(nominal) (%ld) == OS_SUCCESS", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_mount(NULL,NULL); + actual = OS_mount(NULL, NULL); UtAssert_True(actual == expected, "OS_mount() (%ld) == OS_INVALID_POINTER", (long)actual); UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_FS_DEV_NAME_LEN); expected = OS_FS_ERR_PATH_TOO_LONG; - actual = OS_mount("/ramdev0","/ram0"); + actual = OS_mount("/ramdev0", "/ram0"); UtAssert_True(actual == expected, "OS_mount() (%ld) == OS_FS_ERR_PATH_TOO_LONG", (long)actual); - } - void Test_OS_unmount(void) { /* @@ -237,108 +233,101 @@ void Test_OS_unmount(void) int32 actual; expected = OS_ERR_NAME_NOT_FOUND; - actual = OS_unmount("/ram0"); + actual = OS_unmount("/ram0"); UtAssert_True(actual == expected, "OS_mount() (%ld) == OS_ERR_NAME_NOT_FOUND", (long)actual); /* set up so record is in the right state for mounting */ - OS_filesys_table[1].flags = OS_FILESYS_FLAG_IS_READY | - OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | - OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; + OS_filesys_table[1].flags = + OS_FILESYS_FLAG_IS_READY | OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; expected = OS_SUCCESS; - actual = OS_unmount("/ram0"); + actual = OS_unmount("/ram0"); UtAssert_True(actual == expected, "OS_unmount(nominal) (%ld) == OS_SUCCESS", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_unmount(NULL); + actual = OS_unmount(NULL); UtAssert_True(actual == expected, "OS_unmount() (%ld) == OS_INVALID_POINTER", (long)actual); UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_MAX_PATH_LEN); expected = OS_FS_ERR_PATH_TOO_LONG; - actual = OS_unmount("/ram0"); + actual = OS_unmount("/ram0"); UtAssert_True(actual == expected, "OS_unmount() (%ld) == OS_FS_ERR_PATH_TOO_LONG", (long)actual); - } - void Test_OS_fsBlocksFree(void) { /* * Test Case For: * int32 OS_fsBlocksFree (const char *name) */ - int32 expected = 1111; - int32 actual = ~OS_SUCCESS; + int32 expected = 1111; + int32 actual = ~OS_SUCCESS; OS_statvfs_t statval; - statval.block_size = 1024; - statval.blocks_free = 1111; + statval.block_size = 1024; + statval.blocks_free = 1111; statval.total_blocks = 2222; UT_SetDataBuffer(UT_KEY(OS_FileSysStatVolume_Impl), &statval, sizeof(statval), false); - OS_filesys_table[1].flags = OS_FILESYS_FLAG_IS_READY | OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; + OS_filesys_table[1].flags = + OS_FILESYS_FLAG_IS_READY | OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; actual = OS_fsBlocksFree("/cf"); UtAssert_True(actual == expected, "OS_fsBlocksFree() (%ld) == 1111", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_fsBlocksFree(NULL); + actual = OS_fsBlocksFree(NULL); UtAssert_True(actual == expected, "OS_fsBlocksFree() (%ld) == OS_INVALID_POINTER", (long)actual); UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_MAX_PATH_LEN); expected = OS_FS_ERR_PATH_TOO_LONG; - actual = OS_fsBlocksFree("/cf"); + actual = OS_fsBlocksFree("/cf"); UtAssert_True(actual == expected, "OS_fsBlocksFree() (%ld) == OS_FS_ERR_PATH_TOO_LONG", (long)actual); UT_ClearForceFail(UT_KEY(OCS_strlen)); UT_SetForceFail(UT_KEY(OS_ObjectIdGetBySearch), OS_ERR_NAME_NOT_FOUND); expected = OS_FS_ERR_PATH_INVALID; - actual = OS_fsBlocksFree("invalid"); + actual = OS_fsBlocksFree("invalid"); UtAssert_True(actual == expected, "OS_fsBlocksFree() (%ld) == OS_FS_ERR_PATH_INVALID", (long)actual); - - } - void Test_OS_fsBytesFree(void) { /* * Test Case For: * int32 OS_fsBytesFree (const char *name, uint64 *bytes_free) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; OS_statvfs_t statval; - uint64 bytes_free = 0; + uint64 bytes_free = 0; - statval.block_size = 1024; - statval.blocks_free = 1111; + statval.block_size = 1024; + statval.blocks_free = 1111; statval.total_blocks = 2222; UT_SetDataBuffer(UT_KEY(OS_FileSysStatVolume_Impl), &statval, sizeof(statval), false); - OS_filesys_table[1].flags = OS_FILESYS_FLAG_IS_READY | OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; + OS_filesys_table[1].flags = + OS_FILESYS_FLAG_IS_READY | OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; actual = OS_fsBytesFree("/cf", &bytes_free); UtAssert_True(actual == expected, "OS_fsBytesFree() (%ld) == OS_SUCCESS", (long)actual); - UtAssert_True(bytes_free == (1024*1111), "bytes_free (%lu) == (1024*1111)", - (unsigned long)bytes_free); + UtAssert_True(bytes_free == (1024 * 1111), "bytes_free (%lu) == (1024*1111)", (unsigned long)bytes_free); expected = OS_INVALID_POINTER; - actual = OS_fsBytesFree(NULL, NULL); + actual = OS_fsBytesFree(NULL, NULL); UtAssert_True(actual == expected, "OS_fsBytesFree() (%ld) == OS_INVALID_POINTER", (long)actual); UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_MAX_PATH_LEN); expected = OS_FS_ERR_PATH_TOO_LONG; - actual = OS_fsBytesFree("/cf", &bytes_free); + actual = OS_fsBytesFree("/cf", &bytes_free); UtAssert_True(actual == expected, "OS_fsBytesFree() (%ld) == OS_FS_ERR_PATH_TOO_LONG", (long)actual); UT_ClearForceFail(UT_KEY(OCS_strlen)); UT_SetForceFail(UT_KEY(OS_ObjectIdGetBySearch), OS_ERR_NAME_NOT_FOUND); expected = OS_FS_ERR_PATH_INVALID; - actual = OS_fsBytesFree("invalid",&bytes_free); + actual = OS_fsBytesFree("invalid", &bytes_free); UtAssert_True(actual == expected, "OS_fsBytesFree() (%ld) == OS_FS_ERR_PATH_INVALID", (long)actual); - } - void Test_OS_chkfs(void) { /* @@ -350,27 +339,26 @@ void Test_OS_chkfs(void) /* Setup for success by having strings match */ expected = OS_SUCCESS; - actual = OS_chkfs("/cf",true); + actual = OS_chkfs("/cf", true); UtAssert_True(actual == expected, "OS_chkfs() (%ld) == OS_SUCCESS", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_chkfs(NULL,false); + actual = OS_chkfs(NULL, false); UtAssert_True(actual == expected, "OS_fsBytesFree() (%ld) == OS_INVALID_POINTER", (long)actual); UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_MAX_PATH_LEN); expected = OS_FS_ERR_PATH_TOO_LONG; - actual = OS_chkfs("/cf",false); + actual = OS_chkfs("/cf", false); UtAssert_True(actual == expected, "OS_fsBytesFree() (%ld) == OS_FS_ERR_PATH_TOO_LONG", (long)actual); UT_ClearForceFail(UT_KEY(OCS_strlen)); /* Test Fail due to no matching VolTab entry */ UT_SetForceFail(UT_KEY(OS_ObjectIdGetBySearch), OS_ERR_NAME_NOT_FOUND); expected = OS_ERR_NAME_NOT_FOUND; - actual = OS_chkfs("none", true); + actual = OS_chkfs("none", true); UtAssert_True(actual == expected, "OS_chkfs() (%ld) == OS_ERR_NAME_NOT_FOUND", (long)actual); } - void Test_OS_FS_GetPhysDriveName(void) { /* @@ -378,68 +366,63 @@ void Test_OS_FS_GetPhysDriveName(void) * int32 OS_FS_GetPhysDriveName(char * PhysDriveName, const char * MountPoint) */ int32 expected = OS_INVALID_POINTER; - int32 actual = OS_FS_GetPhysDriveName(NULL, NULL); - char NameBuf[OS_FS_PHYS_NAME_LEN]; + int32 actual = OS_FS_GetPhysDriveName(NULL, NULL); + char NameBuf[OS_FS_PHYS_NAME_LEN]; UtAssert_True(actual == expected, "OS_FS_GetPhysDriveName() (%ld) == OS_INVALID_POINTER", (long)actual); UT_SetForceFail(UT_KEY(OCS_strlen), OS_MAX_PATH_LEN + 10); expected = OS_FS_ERR_PATH_TOO_LONG; - actual = OS_FS_GetPhysDriveName(NameBuf,"none"); + actual = OS_FS_GetPhysDriveName(NameBuf, "none"); UtAssert_True(actual == expected, "OS_FS_GetPhysDriveName() (%ld) == OS_FS_ERR_PATH_TOO_LONG", (long)actual); UT_ClearForceFail(UT_KEY(OCS_strlen)); expected = OS_ERR_INCORRECT_OBJ_STATE; - actual = OS_FS_GetPhysDriveName(NameBuf,"none"); + actual = OS_FS_GetPhysDriveName(NameBuf, "none"); UtAssert_True(actual == expected, "OS_FS_GetPhysDriveName() (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); - OS_filesys_table[1].flags = OS_FILESYS_FLAG_IS_READY | OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; + OS_filesys_table[1].flags = + OS_FILESYS_FLAG_IS_READY | OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; expected = OS_SUCCESS; - actual = OS_FS_GetPhysDriveName(NameBuf,"none"); + actual = OS_FS_GetPhysDriveName(NameBuf, "none"); UtAssert_True(actual == expected, "OS_FS_GetPhysDriveName() (%ld) == OS_SUCCESS", (long)actual); /* Test Fail due to no matching VolTab entry */ UT_SetForceFail(UT_KEY(OS_ObjectIdGetBySearch), OS_ERR_NAME_NOT_FOUND); expected = OS_ERR_NAME_NOT_FOUND; - actual = OS_FS_GetPhysDriveName(NameBuf,"none"); + actual = OS_FS_GetPhysDriveName(NameBuf, "none"); UtAssert_True(actual == expected, "OS_FS_GetPhysDriveName() (%ld) == OS_ERR_NAME_NOT_FOUND", (long)actual); } - void Test_OS_GetFsInfo(void) { /* * Test Case For: * int32 OS_GetFsInfo(OS_FsInfo_t *filesys_info) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; - os_fsinfo_t filesys_info; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; + os_fsinfo_t filesys_info; actual = OS_GetFsInfo(&filesys_info); UtAssert_True(actual == expected, "OS_FileSysInfo() (%ld) == OS_SUCCESS", (long)actual); - UtAssert_True(filesys_info.MaxFds == OS_MAX_NUM_OPEN_FILES, - "filesys_info.MaxFds (%lu) == OS_MAX_NUM_OPEN_FILES", - (unsigned long)filesys_info.MaxFds); + UtAssert_True(filesys_info.MaxFds == OS_MAX_NUM_OPEN_FILES, "filesys_info.MaxFds (%lu) == OS_MAX_NUM_OPEN_FILES", + (unsigned long)filesys_info.MaxFds); UtAssert_True(filesys_info.MaxVolumes == OS_MAX_FILE_SYSTEMS, - "filesys_info.MaxVolumes (%lu) == OS_MAX_FILE_SYSTEMS", - (unsigned long)filesys_info.MaxVolumes); + "filesys_info.MaxVolumes (%lu) == OS_MAX_FILE_SYSTEMS", (unsigned long)filesys_info.MaxVolumes); /* since there are no open files, the free fd count should match the max */ - UtAssert_True(filesys_info.FreeFds == OS_MAX_NUM_OPEN_FILES, - "filesys_info.FreeFds (%lu) == OS_MAX_NUM_OPEN_FILES", - (unsigned long)filesys_info.FreeFds); + UtAssert_True(filesys_info.FreeFds == OS_MAX_NUM_OPEN_FILES, "filesys_info.FreeFds (%lu) == OS_MAX_NUM_OPEN_FILES", + (unsigned long)filesys_info.FreeFds); UtAssert_True(filesys_info.FreeVolumes == OS_MAX_FILE_SYSTEMS, - "filesys_info.FreeVolumes (%lu) == OS_MAX_FILE_SYSTEMS", - (unsigned long)filesys_info.FreeVolumes); + "filesys_info.FreeVolumes (%lu) == OS_MAX_FILE_SYSTEMS", (unsigned long)filesys_info.FreeVolumes); expected = OS_INVALID_POINTER; - actual = OS_GetFsInfo(NULL); + actual = OS_GetFsInfo(NULL); UtAssert_True(actual == expected, "OS_GetFsInfo() (%ld) == OS_INVALID_POINTER", (long)actual); - } void Test_OS_TranslatePath(void) @@ -448,67 +431,68 @@ void Test_OS_TranslatePath(void) * Test Case For: * int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath) */ - char LocalBuffer[OS_MAX_PATH_LEN]; + char LocalBuffer[OS_MAX_PATH_LEN]; int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 actual = ~OS_SUCCESS; /* Set up the local record for success */ - OS_filesys_table[1].flags = OS_FILESYS_FLAG_IS_READY | OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; - strcpy(OS_filesys_table[1].virtual_mountpt,"/cf"); - strcpy(OS_filesys_table[1].system_mountpt,"/mnt/cf"); + OS_filesys_table[1].flags = + OS_FILESYS_FLAG_IS_READY | OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; + strcpy(OS_filesys_table[1].virtual_mountpt, "/cf"); + strcpy(OS_filesys_table[1].system_mountpt, "/mnt/cf"); - actual = OS_TranslatePath("/cf/test",LocalBuffer); + actual = OS_TranslatePath("/cf/test", LocalBuffer); UtAssert_True(actual == expected, "OS_TranslatePath(/cf/test) (%ld) == OS_SUCCESS", (long)actual); - UtAssert_True(strcmp(LocalBuffer,"/mnt/cf/test") == 0, "OS_TranslatePath(/cf/test) (%s) == /mnt/cf/test", LocalBuffer); + UtAssert_True(strcmp(LocalBuffer, "/mnt/cf/test") == 0, "OS_TranslatePath(/cf/test) (%s) == /mnt/cf/test", + LocalBuffer); /* Check various error paths */ expected = OS_INVALID_POINTER; - actual = OS_TranslatePath(NULL, NULL); + actual = OS_TranslatePath(NULL, NULL); UtAssert_True(actual == expected, "OS_TranslatePath(NULL,NULL) (%ld) == OS_INVALID_POINTER", (long)actual); UT_SetForceFail(UT_KEY(OCS_strlen), OS_MAX_PATH_LEN + 10); expected = OS_FS_ERR_PATH_TOO_LONG; - actual = OS_TranslatePath("/cf/test",LocalBuffer); + actual = OS_TranslatePath("/cf/test", LocalBuffer); UtAssert_True(actual == expected, "OS_TranslatePath() (%ld) == OS_FS_ERR_PATH_TOO_LONG", (long)actual); UT_ClearForceFail(UT_KEY(OCS_strlen)); /* Invalid no '/' */ expected = OS_FS_ERR_PATH_INVALID; - actual = OS_TranslatePath("invalid",LocalBuffer); + actual = OS_TranslatePath("invalid", LocalBuffer); UtAssert_True(actual == expected, "OS_TranslatePath() (%ld) == OS_FS_ERR_PATH_INVALID", (long)actual); UT_SetDeferredRetcode(UT_KEY(OCS_strlen), 2, OS_MAX_FILE_NAME + 1); expected = OS_FS_ERR_NAME_TOO_LONG; - actual = OS_TranslatePath("/cf/test",LocalBuffer); + actual = OS_TranslatePath("/cf/test", LocalBuffer); UtAssert_True(actual == expected, "OS_TranslatePath(/cf/test) (%ld) == OS_FS_ERR_NAME_TOO_LONG", (long)actual); /* Invalid no leading '/' */ expected = OS_FS_ERR_PATH_INVALID; - actual = OS_TranslatePath("invalid/",LocalBuffer); + actual = OS_TranslatePath("invalid/", LocalBuffer); UtAssert_True(actual == expected, "OS_TranslatePath() (%ld) == OS_FS_ERR_PATH_INVALID", (long)actual); UT_SetForceFail(UT_KEY(OS_ObjectIdGetBySearch), OS_ERR_NAME_NOT_FOUND); - actual = OS_TranslatePath("/cf/test",LocalBuffer); + actual = OS_TranslatePath("/cf/test", LocalBuffer); UtAssert_True(actual == expected, "OS_TranslatePath() (%ld) == OS_FS_ERR_PATH_INVALID", (long)actual); UT_ClearForceFail(UT_KEY(OS_ObjectIdGetBySearch)); - /* VirtPathLen < VirtPathBegin */ + /* VirtPathLen < VirtPathBegin */ UT_SetDeferredRetcode(UT_KEY(OCS_strlen), 4, OS_MAX_PATH_LEN); expected = OS_FS_ERR_PATH_INVALID; - actual = OS_TranslatePath("/cf/test",LocalBuffer); + actual = OS_TranslatePath("/cf/test", LocalBuffer); UtAssert_True(actual == expected, "OS_TranslatePath(/cf/test) (%ld) == OS_FS_ERR_PATH_INVALID", (long)actual); /* (SysMountPointLen + VirtPathLen) > OS_MAX_LOCAL_PATH_LEN */ UT_SetDeferredRetcode(UT_KEY(OCS_strlen), 3, OS_MAX_LOCAL_PATH_LEN); expected = OS_FS_ERR_PATH_TOO_LONG; - actual = OS_TranslatePath("/cf/test",LocalBuffer); + actual = OS_TranslatePath("/cf/test", LocalBuffer); UtAssert_True(actual == expected, "OS_TranslatePath(/cf/test) (%ld) == OS_FS_ERR_PATH_TOO_LONG", (long)actual); - + OS_filesys_table[1].flags = 0; - expected = OS_ERR_INCORRECT_OBJ_STATE; - actual = OS_TranslatePath("/cf/test",LocalBuffer); + expected = OS_ERR_INCORRECT_OBJ_STATE; + actual = OS_TranslatePath("/cf/test", LocalBuffer); UtAssert_True(actual == expected, "OS_TranslatePath(/cf/test) (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); - } void Test_OS_FileSys_FindVirtMountPoint(void) @@ -520,15 +504,15 @@ void Test_OS_FileSys_FindVirtMountPoint(void) * This is a static internal function and must be invoked through a UT-specific wrapper in * order to get coverage on it. */ - bool result; + bool result; OS_common_record_t refobj; - const char refstr[] = "/ut"; + const char refstr[] = "/ut"; memset(&refobj, 0, sizeof(refobj)); - OS_filesys_table[1].flags = 0; + OS_filesys_table[1].flags = 0; OS_filesys_table[1].virtual_mountpt[0] = 0; - result = OS_FileSys_FindVirtMountPoint((void*)refstr, 1, &refobj); + result = OS_FileSys_FindVirtMountPoint((void *)refstr, 1, &refobj); UtAssert_True(!result, "OS_FileSys_FindVirtMountPoint(%s) (unmounted) == false", refstr); OS_filesys_table[1].flags = OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; @@ -536,15 +520,17 @@ void Test_OS_FileSys_FindVirtMountPoint(void) /* Verify cases where one is a substring of the other - * these should also return false */ strncpy(OS_filesys_table[1].virtual_mountpt, "/ut11", sizeof(OS_filesys_table[1].virtual_mountpt)); - result = OS_FileSys_FindVirtMountPoint((void*)refstr, 1, &refobj); - UtAssert_True(!result, "OS_FileSys_FindVirtMountPoint(%s) (mountpt=%s) == false", refstr, OS_filesys_table[1].virtual_mountpt); + result = OS_FileSys_FindVirtMountPoint((void *)refstr, 1, &refobj); + UtAssert_True(!result, "OS_FileSys_FindVirtMountPoint(%s) (mountpt=%s) == false", refstr, + OS_filesys_table[1].virtual_mountpt); strncpy(OS_filesys_table[1].virtual_mountpt, "/u", sizeof(OS_filesys_table[1].virtual_mountpt)); - result = OS_FileSys_FindVirtMountPoint((void*)refstr, 1, &refobj); - UtAssert_True(!result, "OS_FileSys_FindVirtMountPoint(%s) (mountpt=%s) == false", refstr, OS_filesys_table[1].virtual_mountpt); + result = OS_FileSys_FindVirtMountPoint((void *)refstr, 1, &refobj); + UtAssert_True(!result, "OS_FileSys_FindVirtMountPoint(%s) (mountpt=%s) == false", refstr, + OS_filesys_table[1].virtual_mountpt); strncpy(OS_filesys_table[1].virtual_mountpt, "/ut", sizeof(OS_filesys_table[1].virtual_mountpt)); - result = OS_FileSys_FindVirtMountPoint((void*)refstr, 1, &refobj); + result = OS_FileSys_FindVirtMountPoint((void *)refstr, 1, &refobj); UtAssert_True(result, "OS_FileSys_FindVirtMountPoint(%s) (nominal) == true", refstr); } @@ -565,10 +551,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* * Register the test cases to execute with the unit test tool @@ -590,8 +573,3 @@ void UtTest_Setup(void) ADD_TEST(OS_TranslatePath); ADD_TEST(OS_FileSys_FindVirtMountPoint); } - - - - - diff --git a/src/unit-test-coverage/shared/src/coveragetest-heap.c b/src/unit-test-coverage/shared/src/coveragetest-heap.c index 362b8d250..31cfe970d 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-heap.c +++ b/src/unit-test-coverage/shared/src/coveragetest-heap.c @@ -27,7 +27,6 @@ #include "os-shared-coveragetest.h" #include "os-shared-heap.h" - void Test_OS_HeapGetInfo(void) { /* @@ -35,8 +34,8 @@ void Test_OS_HeapGetInfo(void) * int32 OS_HeapGetInfo(OS_heap_prop_t *heap_prop) */ OS_heap_prop_t heap_prop; - int32 expected = OS_SUCCESS; - int32 actual = OS_HeapGetInfo(&heap_prop); + int32 expected = OS_SUCCESS; + int32 actual = OS_HeapGetInfo(&heap_prop); UtAssert_True(actual == expected, "OS_HeapGetInfo() (%ld) == OS_SUCCESS", (long)actual); @@ -44,7 +43,6 @@ void Test_OS_HeapGetInfo(void) actual = OS_HeapGetInfo(NULL); UtAssert_True(actual == expected, "OS_HeapGetInfo() (%ld) == OS_INVALID_POINTER", (long)actual); - } /* Osapi_Test_Setup * @@ -62,10 +60,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* * Register the test cases to execute with the unit test tool @@ -74,7 +69,3 @@ void UtTest_Setup(void) { ADD_TEST(OS_HeapGetInfo); } - - - - diff --git a/src/unit-test-coverage/shared/src/coveragetest-idmap.c b/src/unit-test-coverage/shared/src/coveragetest-idmap.c index 13d86afed..07fc471de 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-idmap.c +++ b/src/unit-test-coverage/shared/src/coveragetest-idmap.c @@ -30,7 +30,6 @@ #include - typedef struct { uint32 TaskCount; @@ -49,24 +48,23 @@ static void ObjTypeCounter(osal_id_t object_id, void *arg) { Test_OS_ObjTypeCount_t *count = arg; - switch(OS_IdentifyObject(object_id)) + switch (OS_IdentifyObject(object_id)) { - case OS_OBJECT_TYPE_OS_TASK: - ++count->TaskCount; - break; - case OS_OBJECT_TYPE_OS_QUEUE: - ++count->QueueCount; - break; - case OS_OBJECT_TYPE_OS_MUTEX: - ++count->MutexCount; - break; - default: - ++count->OtherCount; - break; + case OS_OBJECT_TYPE_OS_TASK: + ++count->TaskCount; + break; + case OS_OBJECT_TYPE_OS_QUEUE: + ++count->QueueCount; + break; + case OS_OBJECT_TYPE_OS_MUTEX: + ++count->MutexCount; + break; + default: + ++count->OtherCount; + break; } } - void Test_OS_ObjectIdInit(void) { /* @@ -79,7 +77,6 @@ void Test_OS_ObjectIdInit(void) UtAssert_True(actual == expected, "OS_ObjectIdInit() (%ld) == %ld", (long)actual, (long)expected); } - void Test_OS_LockUnlockGlobal(void) { /* @@ -114,12 +111,12 @@ void Test_OS_ObjectIdConvertLock(void) * NOTE: These test cases just focus on code paths that are not exercised * by the other test cases in this file. */ - int32 expected; - int32 actual; - uint32 array_index; + int32 expected; + int32 actual; + uint32 array_index; OS_common_record_t *record; - osal_id_t objid; - UT_idbuf_t corrupt_objid; + osal_id_t objid; + UT_idbuf_t corrupt_objid; /* get a valid (fake) OSAL ID to start with */ OS_ObjectIdAllocateNew(OS_OBJECT_TYPE_OS_TASK, "ut", &array_index, &record); @@ -131,34 +128,33 @@ void Test_OS_ObjectIdConvertLock(void) */ corrupt_objid.id = objid; corrupt_objid.val ^= 0x10; /* flip a bit */ - actual = OS_ObjectIdConvertLock(OS_LOCK_MODE_NONE, OS_OBJECT_TYPE_OS_TASK, - corrupt_objid.id, record); + actual = OS_ObjectIdConvertLock(OS_LOCK_MODE_NONE, OS_OBJECT_TYPE_OS_TASK, corrupt_objid.id, record); expected = OS_ERR_INVALID_ID; - UtAssert_True(actual == expected, "OS_ObjectIdConvertLock() (%ld) == OS_ERR_INVALID_ID (%ld)", (long)actual, (long)expected); + UtAssert_True(actual == expected, "OS_ObjectIdConvertLock() (%ld) == OS_ERR_INVALID_ID (%ld)", (long)actual, + (long)expected); /* * Use mode OS_LOCK_MODE_NONE with matching ID * This should return success. */ - actual = OS_ObjectIdConvertLock(OS_LOCK_MODE_NONE, - OS_OBJECT_TYPE_OS_TASK, objid, record); + actual = OS_ObjectIdConvertLock(OS_LOCK_MODE_NONE, OS_OBJECT_TYPE_OS_TASK, objid, record); expected = OS_SUCCESS; - UtAssert_True(actual == expected, "OS_ObjectIdConvertLock() (%ld) == OS_ERR_INVALID_ID (%ld)", (long)actual, (long)expected); + UtAssert_True(actual == expected, "OS_ObjectIdConvertLock() (%ld) == OS_ERR_INVALID_ID (%ld)", (long)actual, + (long)expected); /* * Use mode OS_LOCK_MODE_EXCLUSIVE with matching ID and no other refs. * This should return success. */ - record->flags = 0; + record->flags = 0; record->refcount = 0; - actual = OS_ObjectIdConvertLock(OS_LOCK_MODE_EXCLUSIVE, - OS_OBJECT_TYPE_OS_TASK, objid, record); - expected = OS_SUCCESS; - - UtAssert_True(actual == expected, "OS_ObjectIdConvertLock() (%ld) == OS_SUCCESS (%ld)", (long)actual, (long)expected); + actual = OS_ObjectIdConvertLock(OS_LOCK_MODE_EXCLUSIVE, OS_OBJECT_TYPE_OS_TASK, objid, record); + expected = OS_SUCCESS; + UtAssert_True(actual == expected, "OS_ObjectIdConvertLock() (%ld) == OS_SUCCESS (%ld)", (long)actual, + (long)expected); } void Test_OS_ObjectIdGetBySearch(void) @@ -171,30 +167,28 @@ void Test_OS_ObjectIdGetBySearch(void) * NOTE: These test cases just focus on code paths that are not exercised * by the other test cases in this file. */ - int32 expected; - int32 actual; + int32 expected; + int32 actual; OS_common_record_t *record; OS_global_task_table[0].active_id = UT_OBJID_OTHER; - actual = OS_ObjectIdGetBySearch(OS_LOCK_MODE_NONE, OS_OBJECT_TYPE_OS_TASK, - TestAlwaysMatch, NULL, &record); + actual = OS_ObjectIdGetBySearch(OS_LOCK_MODE_NONE, OS_OBJECT_TYPE_OS_TASK, TestAlwaysMatch, NULL, &record); expected = OS_SUCCESS; OS_global_task_table[0].active_id = OS_OBJECT_ID_UNDEFINED; - UtAssert_True(actual == expected, "OS_ObjectIdGetBySearch() (%ld) == OS_SUCCESS (%ld)", (long)actual, (long)expected); - + UtAssert_True(actual == expected, "OS_ObjectIdGetBySearch() (%ld) == OS_SUCCESS (%ld)", (long)actual, + (long)expected); } - void Test_OS_GetMaxForObjectType(void) { /* * Test Case For: * uint32 OS_GetMaxForObjectType(uint32 idtype); */ - uint32 idtype = 0; + uint32 idtype = 0; uint32 expected = 0xFFFFFFFF; - uint32 max = 0; + uint32 max = 0; for (idtype = 0; idtype < OS_OBJECT_TYPE_USER; ++idtype) { @@ -213,11 +207,10 @@ void Test_OS_GetMaxForObjectType(void) { /* Verify Outputs */ /* only the "0" is verifiable, since everything else depends on OS config */ - UtAssert_True(max == expected, "OS_GetMaxForObjectType(%lu) (%lu) == 0", - (unsigned long)idtype, (unsigned long)max); + UtAssert_True(max == expected, "OS_GetMaxForObjectType(%lu) (%lu) == 0", (unsigned long)idtype, + (unsigned long)max); } } - } void Test_OS_GetBaseForObjectType(void) @@ -226,9 +219,9 @@ void Test_OS_GetBaseForObjectType(void) * Test Case For: * uint32 OS_GetBaseForObjectType(uint32 idtype); */ - uint32 idtype = 0; + uint32 idtype = 0; uint32 expected = 0xFFFFFFFF; - uint32 max = 0; + uint32 max = 0; for (idtype = 0; idtype < OS_OBJECT_TYPE_USER; ++idtype) { @@ -247,8 +240,8 @@ void Test_OS_GetBaseForObjectType(void) { /* Verify Outputs */ /* only the "0" is verifiable, since everything else depends on OS config */ - UtAssert_True(max == expected, "OS_GetBaseForObjectType(%lu) (%lu) == 0", - (unsigned long)idtype, (unsigned long)max); + UtAssert_True(max == expected, "OS_GetBaseForObjectType(%lu) (%lu) == 0", (unsigned long)idtype, + (unsigned long)max); } } } @@ -264,9 +257,9 @@ void Test_OS_ObjectIdToArrayIndex(void) * which is out of range. */ osal_id_t objid; - uint32 local_idx = 0xFFFFFFFF; - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + uint32 local_idx = 0xFFFFFFFF; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; /* need to get a "valid" objid for the nominal case */ OS_ObjectIdCompose_Impl(OS_OBJECT_TYPE_OS_TASK, 1, &objid); @@ -282,7 +275,7 @@ void Test_OS_ObjectIdToArrayIndex(void) UtAssert_True(actual == expected, "OS_ObjectIdToArrayIndex() (%ld) == OS_ERR_INVALID_ID", (long)actual); } -void Test_OS_ObjectIdFindByName (void) +void Test_OS_ObjectIdFindByName(void) { /* * Test Case For: @@ -291,10 +284,10 @@ void Test_OS_ObjectIdFindByName (void) * Nominal case (with no additional setup) should return OS_ERR_NAME_NOT_FOUND * Setting up a special matching entry should yield OS_SUCCESS */ - char TaskName[] = "UT_find"; + char TaskName[] = "UT_find"; osal_id_t objid; - int32 expected = OS_ERR_NAME_NOT_FOUND; - int32 actual = OS_ObjectIdFindByName(OS_OBJECT_TYPE_UNDEFINED, NULL, NULL); + int32 expected = OS_ERR_NAME_NOT_FOUND; + int32 actual = OS_ObjectIdFindByName(OS_OBJECT_TYPE_UNDEFINED, NULL, NULL); UtAssert_True(actual == expected, "OS_ObjectFindIdByName(%s) (%ld) == OS_ERR_NAME_NOT_FOUND", "NULL", (long)actual); @@ -304,10 +297,10 @@ void Test_OS_ObjectIdFindByName (void) UT_SetForceFail(UT_KEY(OCS_strlen), OS_MAX_API_NAME + 10); expected = OS_ERR_NAME_TOO_LONG; actual = OS_ObjectIdFindByName(OS_OBJECT_TYPE_OS_TASK, TaskName, &objid); - UtAssert_True(actual == expected, "OS_ObjectFindIdByName(%s) (%ld) == OS_ERR_NAME_TOO_LONG", TaskName, (long)actual); + UtAssert_True(actual == expected, "OS_ObjectFindIdByName(%s) (%ld) == OS_ERR_NAME_TOO_LONG", TaskName, + (long)actual); UT_ClearForceFail(UT_KEY(OCS_strlen)); - /* * Pass in a name that is actually not found */ @@ -315,39 +308,39 @@ void Test_OS_ObjectIdFindByName (void) expected = OS_ERR_NAME_NOT_FOUND; actual = OS_ObjectIdFindByName(OS_OBJECT_TYPE_OS_TASK, TaskName, &objid); - UtAssert_True(actual == expected, "OS_ObjectFindIdByName(%s) (%ld) == OS_ERR_NAME_NOT_FOUND", TaskName, (long)actual); - + UtAssert_True(actual == expected, "OS_ObjectFindIdByName(%s) (%ld) == OS_ERR_NAME_NOT_FOUND", TaskName, + (long)actual); /* * Set up for the ObjectIdSearch function to return success */ - OS_global_task_table[0].active_id = UT_OBJID_OTHER; + OS_global_task_table[0].active_id = UT_OBJID_OTHER; OS_global_task_table[0].name_entry = TaskName; - actual = OS_ObjectIdFindByName(OS_OBJECT_TYPE_OS_TASK, TaskName, &objid); - expected = OS_SUCCESS; - OS_global_task_table[0].active_id = OS_OBJECT_ID_UNDEFINED; + actual = OS_ObjectIdFindByName(OS_OBJECT_TYPE_OS_TASK, TaskName, &objid); + expected = OS_SUCCESS; + OS_global_task_table[0].active_id = OS_OBJECT_ID_UNDEFINED; OS_global_task_table[0].name_entry = NULL; UtAssert_True(actual == expected, "OS_ObjectFindIdByName(%s) (%ld) == OS_SUCCESS", TaskName, (long)actual); - } void Test_OS_ObjectIdGetById(void) { /* * Test Case For: - * int32 OS_ObjectIdGetById(OS_lock_mode_t check_mode, uint32 idtype, uint32 id, uint32 *array_index, OS_common_record_t **record); + * int32 OS_ObjectIdGetById(OS_lock_mode_t check_mode, uint32 idtype, uint32 id, uint32 *array_index, + * OS_common_record_t **record); * */ - int32 actual = ~OS_SUCCESS; - int32 expected = OS_SUCCESS; - osal_id_t refobjid; - uint32 local_idx = 0xFFFFFFFF; - OS_common_record_t *rptr = NULL; + int32 actual = ~OS_SUCCESS; + int32 expected = OS_SUCCESS; + osal_id_t refobjid; + uint32 local_idx = 0xFFFFFFFF; + OS_common_record_t *rptr = NULL; /* verify that the call returns ERROR when not initialized */ OS_SharedGlobalVars.Initialized = false; - actual = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, 0, OS_OBJECT_ID_UNDEFINED, &local_idx, &rptr); + actual = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, 0, OS_OBJECT_ID_UNDEFINED, &local_idx, &rptr); expected = OS_ERROR; UtAssert_True(actual == expected, "OS_ObjectIdGetById(uninitialized) (%ld) == OS_ERROR", (long)actual); @@ -357,52 +350,49 @@ void Test_OS_ObjectIdGetById(void) OS_ObjectIdCompose_Impl(OS_OBJECT_TYPE_OS_TASK, 1, &refobjid); OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_TASK, refobjid, &local_idx); OS_global_task_table[local_idx].active_id = refobjid; - expected = OS_SUCCESS; + expected = OS_SUCCESS; actual = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, OS_OBJECT_TYPE_OS_TASK, refobjid, &local_idx, &rptr); /* Verify Outputs */ UtAssert_True(actual == expected, "OS_ObjectIdGetById() (%ld) == OS_SUCCESS", (long)actual); UtAssert_True(local_idx == 1, "local_idx (%lu) == 1", (unsigned long)local_idx); - UtAssert_True(rptr != NULL, "rptr (%p) != NULL", (void*)rptr); - UtAssert_True(rptr->refcount == 1, "refcount (%u) == 1", - (unsigned int)rptr->refcount); + UtAssert_True(rptr != NULL, "rptr (%p) != NULL", (void *)rptr); + UtAssert_True(rptr->refcount == 1, "refcount (%u) == 1", (unsigned int)rptr->refcount); /* attempting to get an exclusive lock should return IN_USE error */ expected = OS_ERR_OBJECT_IN_USE; - actual = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, OS_OBJECT_TYPE_OS_TASK, refobjid, &local_idx, &rptr); + actual = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, OS_OBJECT_TYPE_OS_TASK, refobjid, &local_idx, &rptr); UtAssert_True(actual == expected, "OS_ObjectIdGetById() (%ld) == OS_ERR_OBJECT_IN_USE", (long)actual); /* attempt to get non-exclusive lock during shutdown should fail */ OS_SharedGlobalVars.ShutdownFlag = OS_SHUTDOWN_MAGIC_NUMBER; - expected = OS_ERR_INCORRECT_OBJ_STATE; + expected = OS_ERR_INCORRECT_OBJ_STATE; actual = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, OS_OBJECT_TYPE_OS_TASK, refobjid, &local_idx, &rptr); UtAssert_True(actual == expected, "OS_ObjectIdGetById() (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); OS_SharedGlobalVars.ShutdownFlag = 0; /* attempt to get lock for invalid type object should fail */ expected = OS_ERR_INVALID_ID; - actual = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, 0xFFFFFFFF, refobjid, &local_idx, &rptr); + actual = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, 0xFFFFFFFF, refobjid, &local_idx, &rptr); UtAssert_True(actual == expected, "OS_ObjectIdGetById() (%ld) == OS_ERR_INVALID_ID", (long)actual); OS_SharedGlobalVars.ShutdownFlag = 0; - /* refcount decrement should work */ expected = OS_SUCCESS; - actual = OS_ObjectIdRefcountDecr(rptr); + actual = OS_ObjectIdRefcountDecr(rptr); UtAssert_True(actual == expected, "OS_ObjectIdRefcountDecr() (%ld) == OS_SUCCESS", (long)actual); /* decrement should fail if done a second time */ expected = OS_ERR_INCORRECT_OBJ_STATE; - actual = OS_ObjectIdRefcountDecr(rptr); + actual = OS_ObjectIdRefcountDecr(rptr); UtAssert_True(actual == expected, "OS_ObjectIdRefcountDecr() (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); /* clear out state entry */ memset(&OS_global_task_table[local_idx], 0, sizeof(OS_global_task_table[local_idx])); expected = OS_ERR_INVALID_ID; - actual = OS_ObjectIdRefcountDecr(rptr); + actual = OS_ObjectIdRefcountDecr(rptr); UtAssert_True(actual == expected, "OS_ObjectIdRefcountDecr() (%ld) == OS_ERR_INVALID_ID", (long)actual); - } void Test_OS_ObjectIdFindNext(void) @@ -417,87 +407,87 @@ void Test_OS_ObjectIdFindNext(void) * before use. */ - int32 expected; - int32 actual; + int32 expected; + int32 actual; OS_common_record_t *rec1; OS_common_record_t *rec2; - osal_id_t id1; - osal_id_t id2; - UT_idbuf_t check_id; - UT_idbuf_t saved_id; - uint32 i; + osal_id_t id1; + osal_id_t id2; + UT_idbuf_t check_id; + UT_idbuf_t saved_id; + uint32 i; /* Need to first obtain a valid ID to finalize */ expected = OS_SUCCESS; - actual = OS_ObjectIdFindNext(OS_OBJECT_TYPE_OS_TASK, NULL, &rec1); + actual = OS_ObjectIdFindNext(OS_OBJECT_TYPE_OS_TASK, NULL, &rec1); UtAssert_True(actual == expected, "OS_ObjectIdFindNext() (%ld) == OS_SUCCESS", (long)actual); /* nominal case (success) */ - id1 = OS_OBJECT_ID_UNDEFINED; + id1 = OS_OBJECT_ID_UNDEFINED; actual = OS_ObjectIdFinalizeNew(OS_SUCCESS, rec1, &id1); /* Verify Outputs */ UtAssert_True(actual == expected, "OS_ObjectIdFinalizeNew() (%ld) == OS_SUCCESS", (long)actual); - OSAPI_TEST_OBJID(id1,==,rec1->active_id); + OSAPI_TEST_OBJID(id1, ==, rec1->active_id); /* Allocate another ID (should be different!) */ actual = OS_ObjectIdFindNext(OS_OBJECT_TYPE_OS_TASK, NULL, &rec2); UtAssert_True(actual == expected, "OS_ObjectIdFindNext() (%ld) == OS_SUCCESS", (long)actual); - OSAPI_TEST_OBJID(rec2->active_id,!=,rec1->active_id); + OSAPI_TEST_OBJID(rec2->active_id, !=, rec1->active_id); /* Failure to initialize the second one. * Verify the error code passes thru */ - expected = -1234; + expected = -1234; saved_id.id = rec2->active_id; - id2 = OS_OBJECT_ID_UNDEFINED; - actual = OS_ObjectIdFinalizeNew(expected, rec2, &id2); + id2 = OS_OBJECT_ID_UNDEFINED; + actual = OS_ObjectIdFinalizeNew(expected, rec2, &id2); /* Verify Outputs */ UtAssert_True(actual == expected, "OS_ObjectIdFinalizeNew() (%ld) == %ld", (long)actual, (long)expected); - OSAPI_TEST_OBJID(id2,==,OS_OBJECT_ID_UNDEFINED); - OSAPI_TEST_OBJID(rec2->active_id,==,OS_OBJECT_ID_UNDEFINED); + OSAPI_TEST_OBJID(id2, ==, OS_OBJECT_ID_UNDEFINED); + OSAPI_TEST_OBJID(rec2->active_id, ==, OS_OBJECT_ID_UNDEFINED); /* next call should re-issue the same id because init failed */ expected = OS_SUCCESS; - actual = OS_ObjectIdFindNext(OS_OBJECT_TYPE_OS_TASK, NULL, &rec2); + actual = OS_ObjectIdFindNext(OS_OBJECT_TYPE_OS_TASK, NULL, &rec2); UtAssert_True(actual == expected, "OS_ObjectIdFindNext() (%ld) == OS_SUCCESS", (long)actual); - OSAPI_TEST_OBJID(rec2->active_id,==,saved_id.id); + OSAPI_TEST_OBJID(rec2->active_id, ==, saved_id.id); /* test invalid case*/ rec2->active_id = OS_OBJECT_ID_UNDEFINED; - expected = OS_ERR_INVALID_ID; - actual = OS_ObjectIdFinalizeNew(OS_SUCCESS, rec2, &id2); + expected = OS_ERR_INVALID_ID; + actual = OS_ObjectIdFinalizeNew(OS_SUCCESS, rec2, &id2); UtAssert_True(actual == expected, "OS_ObjectIdFinalizeNew() (%ld) == %ld", (long)actual, (long)expected); - OSAPI_TEST_OBJID(id2,==,OS_OBJECT_ID_UNDEFINED); - OSAPI_TEST_OBJID(rec2->active_id,==,OS_OBJECT_ID_UNDEFINED); + OSAPI_TEST_OBJID(id2, ==, OS_OBJECT_ID_UNDEFINED); + OSAPI_TEST_OBJID(rec2->active_id, ==, OS_OBJECT_ID_UNDEFINED); /* * Finally - test the wrap-around function to verify that object IDs * will continue to allocate correctly after OS_OBJECT_INDEX_MASK */ - expected = OS_SUCCESS; + expected = OS_SUCCESS; saved_id.id = OS_OBJECT_ID_UNDEFINED; - for (i=0; i < (OS_OBJECT_INDEX_MASK+2); ++i) + for (i = 0; i < (OS_OBJECT_INDEX_MASK + 2); ++i) { actual = OS_ObjectIdFindNext(OS_OBJECT_TYPE_OS_TASK, NULL, &rec2); /* not usuing UtAssert_True here as it will create thousands of duplicates. */ if (expected != actual) { - UtAssert_Failed("OS_ObjectIdFindNext() failure (%ld)",(long)actual); + UtAssert_Failed("OS_ObjectIdFindNext() failure (%ld)", (long)actual); break; } actual = OS_ObjectIdFinalizeNew(OS_SUCCESS, rec2, NULL); if (expected != actual) { - UtAssert_Failed("OS_ObjectIdFinalizeNew() failure (%ld)",(long)actual); + UtAssert_Failed("OS_ObjectIdFinalizeNew() failure (%ld)", (long)actual); break; } /* should always be different than the previous ID */ if (OS_ObjectIdEqual(saved_id.id, rec2->active_id)) { - UtAssert_Failed("OS_ObjectIdFindNext() re-issued ID (%lx)",(unsigned long)saved_id.val); + UtAssert_Failed("OS_ObjectIdFindNext() re-issued ID (%lx)", (unsigned long)saved_id.val); break; } @@ -505,12 +495,12 @@ void Test_OS_ObjectIdFindNext(void) check_id.id = id1; if (OS_ObjectIdEqual(check_id.id, rec2->active_id)) { - UtAssert_Failed("OS_ObjectIdFindNext() duplicate ID (%lx)",(unsigned long)check_id.val); + UtAssert_Failed("OS_ObjectIdFindNext() duplicate ID (%lx)", (unsigned long)check_id.val); break; } if (rec1 == rec2) { - UtAssert_Failed("OS_ObjectIdFindNext() duplicate slot (%p)", (void*)rec1); + UtAssert_Failed("OS_ObjectIdFindNext() duplicate slot (%p)", (void *)rec1); break; } @@ -523,13 +513,12 @@ void Test_OS_ObjectIdFindNext(void) } /* clear the entry for re-use */ - saved_id.id = rec2->active_id; + saved_id.id = rec2->active_id; rec2->active_id = OS_OBJECT_ID_UNDEFINED; } /* verify that the wrap occurred */ - UtAssert_True(i < (OS_OBJECT_INDEX_MASK+2), "OS_ObjectIdFindNext() wrap around occurred"); - + UtAssert_True(i < (OS_OBJECT_INDEX_MASK + 2), "OS_ObjectIdFindNext() wrap around occurred"); } void Test_OS_ObjectIdAllocateNew(void) @@ -541,36 +530,35 @@ void Test_OS_ObjectIdAllocateNew(void) * Most of the business logic is done by OS_ObjectIdFindNext() which is tested separately * This test case mainly focuses on additional error checking */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; - uint32 indx; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; + uint32 indx; OS_common_record_t *rptr = NULL; actual = OS_ObjectIdAllocateNew(OS_OBJECT_TYPE_OS_TASK, "UT_alloc", &indx, &rptr); /* Verify Outputs */ UtAssert_True(actual == expected, "OS_ObjectIdAllocate() (%ld) == OS_SUCCESS", (long)actual); - UtAssert_True(rptr != NULL, "rptr (%p) != NULL", (void*)rptr); + UtAssert_True(rptr != NULL, "rptr (%p) != NULL", (void *)rptr); /* Passing a NULL name also should work here (used for internal objects) */ actual = OS_ObjectIdAllocateNew(OS_OBJECT_TYPE_OS_TASK, NULL, &indx, &rptr); UtAssert_True(actual == expected, "OS_ObjectIdAllocate(NULL) (%ld) == OS_SUCCESS", (long)actual); rptr->name_entry = "UT_alloc"; - expected = OS_ERR_NAME_TAKEN; - actual = OS_ObjectIdAllocateNew(OS_OBJECT_TYPE_OS_TASK, "UT_alloc", &indx, &rptr); + expected = OS_ERR_NAME_TAKEN; + actual = OS_ObjectIdAllocateNew(OS_OBJECT_TYPE_OS_TASK, "UT_alloc", &indx, &rptr); UtAssert_True(actual == expected, "OS_ObjectIdAllocate() (%ld) == OS_ERR_NAME_TAKEN", (long)actual); OS_SharedGlobalVars.ShutdownFlag = OS_SHUTDOWN_MAGIC_NUMBER; - expected = OS_ERROR; - actual = OS_ObjectIdAllocateNew(OS_OBJECT_TYPE_OS_TASK, "UT_alloc", &indx, &rptr); + expected = OS_ERROR; + actual = OS_ObjectIdAllocateNew(OS_OBJECT_TYPE_OS_TASK, "UT_alloc", &indx, &rptr); OS_SharedGlobalVars.ShutdownFlag = 0; UtAssert_True(actual == expected, "OS_ObjectIdAllocate() (%ld) == OS_ERR_NAME_TAKEN", (long)actual); expected = OS_ERR_INCORRECT_OBJ_TYPE; - actual = OS_ObjectIdAllocateNew(0xFFFFFFFF, "UT_alloc", &indx, &rptr); + actual = OS_ObjectIdAllocateNew(0xFFFFFFFF, "UT_alloc", &indx, &rptr); UtAssert_True(actual == expected, "OS_ObjectIdAllocate() (%ld) == OS_ERR_INCORRECT_OBJ_TYPE", (long)actual); - } void Test_OS_ConvertToArrayIndex(void) @@ -581,21 +569,21 @@ void Test_OS_ConvertToArrayIndex(void) * * */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; //OS_ConvertToArrayIndex(); - uint32 local_idx1 = 0xFFFFFFF0; - uint32 local_idx2 = 0xFFFFFFF1; - OS_common_record_t *rptr = NULL; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; // OS_ConvertToArrayIndex(); + uint32 local_idx1 = 0xFFFFFFF0; + uint32 local_idx2 = 0xFFFFFFF1; + OS_common_record_t *rptr = NULL; /* Need a valid ID to work with */ OS_ObjectIdFindNext(OS_OBJECT_TYPE_OS_TASK, &local_idx1, &rptr); actual = OS_ConvertToArrayIndex(rptr->active_id, &local_idx2); UtAssert_True(actual == expected, "OS_ConvertToArrayIndex() (%ld) == OS_SUCCESS", (long)actual); - UtAssert_True(local_idx1 == local_idx2, "local_idx1 (%lu) == local_idx2 (%lu)", - (unsigned long)local_idx1, (unsigned long)local_idx2); + UtAssert_True(local_idx1 == local_idx2, "local_idx1 (%lu) == local_idx2 (%lu)", (unsigned long)local_idx1, + (unsigned long)local_idx2); expected = OS_ERR_INVALID_ID; - actual = OS_ConvertToArrayIndex(OS_OBJECT_ID_UNDEFINED, &local_idx2); + actual = OS_ConvertToArrayIndex(OS_OBJECT_ID_UNDEFINED, &local_idx2); UtAssert_True(actual == expected, "OS_ConvertToArrayIndex() (%ld) == OS_ERR_INVALID_ID", (long)actual); } @@ -605,10 +593,10 @@ void Test_OS_ForEachObject(void) * Test Case For: * void OS_ForEachObject (uint32 creator_id, OS_ArgCallback_t callback_ptr, void *callback_arg); */ - uint32 objtype = OS_OBJECT_TYPE_UNDEFINED; - OS_common_record_t *rptr = NULL; - uint32 local_idx = 0xFFFFFFFF; - UT_idbuf_t self_id; + uint32 objtype = OS_OBJECT_TYPE_UNDEFINED; + OS_common_record_t * rptr = NULL; + uint32 local_idx = 0xFFFFFFFF; + UT_idbuf_t self_id; Test_OS_ObjTypeCount_t Count; self_id.id = OS_TaskGetId(); @@ -621,7 +609,7 @@ void Test_OS_ForEachObject(void) ++objtype; } - OS_ForEachObject (OS_OBJECT_ID_UNDEFINED, &ObjTypeCounter, &Count); + OS_ForEachObject(OS_OBJECT_ID_UNDEFINED, &ObjTypeCounter, &Count); /* Verify Outputs */ UtAssert_True(Count.TaskCount == 1, "OS_ForEachObject() TaskCount (%lu) == 1", (unsigned long)Count.TaskCount); @@ -630,15 +618,21 @@ void Test_OS_ForEachObject(void) UtAssert_True(Count.OtherCount == 9, "OS_ForEachObject() OtherCount (%lu) == 9", (unsigned long)Count.OtherCount); OS_ForEachObjectOfType(OS_OBJECT_TYPE_OS_QUEUE, self_id.id, ObjTypeCounter, &Count); - UtAssert_True(Count.TaskCount == 1, "OS_ForEachObjectOfType(), creator %08lx TaskCount (%lu) == 1", (unsigned long)self_id.val, (unsigned long)Count.TaskCount); - UtAssert_True(Count.QueueCount == 2, "OS_ForEachObjectOfType() QueueCount (%lu) == 2", (unsigned long)Count.QueueCount); - UtAssert_True(Count.MutexCount == 1, "OS_ForEachObjectOfType() MutexCount (%lu) == 1", (unsigned long)Count.MutexCount); + UtAssert_True(Count.TaskCount == 1, "OS_ForEachObjectOfType(), creator %08lx TaskCount (%lu) == 1", + (unsigned long)self_id.val, (unsigned long)Count.TaskCount); + UtAssert_True(Count.QueueCount == 2, "OS_ForEachObjectOfType() QueueCount (%lu) == 2", + (unsigned long)Count.QueueCount); + UtAssert_True(Count.MutexCount == 1, "OS_ForEachObjectOfType() MutexCount (%lu) == 1", + (unsigned long)Count.MutexCount); self_id.val ^= 0x01; OS_ForEachObjectOfType(OS_OBJECT_TYPE_OS_QUEUE, self_id.id, ObjTypeCounter, &Count); - UtAssert_True(Count.TaskCount == 1, "OS_ForEachObjectOfType(), non-matching creator TaskCount (%lu) == 1", (unsigned long)Count.TaskCount); - UtAssert_True(Count.QueueCount == 2, "OS_ForEachObjectOfType() QueueCount (%lu) == 2", (unsigned long)Count.QueueCount); - UtAssert_True(Count.MutexCount == 1, "OS_ForEachObjectOfType() MutexCount (%lu) == 1", (unsigned long)Count.MutexCount); + UtAssert_True(Count.TaskCount == 1, "OS_ForEachObjectOfType(), non-matching creator TaskCount (%lu) == 1", + (unsigned long)Count.TaskCount); + UtAssert_True(Count.QueueCount == 2, "OS_ForEachObjectOfType() QueueCount (%lu) == 2", + (unsigned long)Count.QueueCount); + UtAssert_True(Count.MutexCount == 1, "OS_ForEachObjectOfType() MutexCount (%lu) == 1", + (unsigned long)Count.MutexCount); } void Test_OS_GetResourceName(void) @@ -647,11 +641,11 @@ void Test_OS_GetResourceName(void) * Test Case For: * int32 OS_GetResourceName(uint32 id, char *buffer, uint32 buffer_size) */ - uint32 local_idx = 0xFFFFFFFF; - OS_common_record_t *rptr = NULL; - char NameBuffer[OS_MAX_API_NAME]; - int32 expected; - int32 actual; + uint32 local_idx = 0xFFFFFFFF; + OS_common_record_t *rptr = NULL; + char NameBuffer[OS_MAX_API_NAME]; + int32 expected; + int32 actual; /* * Set up for the OS_GetResourceName function to return success @@ -659,17 +653,17 @@ void Test_OS_GetResourceName(void) /* Need a valid ID to work with */ OS_ObjectIdFindNext(OS_OBJECT_TYPE_OS_TASK, &local_idx, &rptr); rptr->name_entry = "UTTask"; - expected = OS_SUCCESS; - actual = OS_GetResourceName(rptr->active_id, NameBuffer, sizeof(NameBuffer)); + expected = OS_SUCCESS; + actual = OS_GetResourceName(rptr->active_id, NameBuffer, sizeof(NameBuffer)); UtAssert_True(actual == expected, "OS_GetResourceName() (%ld) == OS_SUCCESS", (long)actual); UtAssert_True(strcmp(NameBuffer, "UTTask") == 0, "NameBuffer (%s) == UTTask", NameBuffer); expected = OS_ERR_NAME_TOO_LONG; - actual = OS_GetResourceName(rptr->active_id, NameBuffer, 2); + actual = OS_GetResourceName(rptr->active_id, NameBuffer, 2); UtAssert_True(actual == expected, "OS_GetResourceName() (%ld) == OS_ERR_NAME_TOO_LONG", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_GetResourceName(rptr->active_id, NULL, 0); + actual = OS_GetResourceName(rptr->active_id, NULL, 0); UtAssert_True(actual == expected, "OS_GetResourceName() (%ld) == OS_INVALID_POINTER", (long)actual); } @@ -699,10 +693,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* * Register the test cases to execute with the unit test tool @@ -724,6 +715,3 @@ void UtTest_Setup(void) ADD_TEST(OS_GetBaseForObjectType); ADD_TEST(OS_GetResourceName); } - - - diff --git a/src/unit-test-coverage/shared/src/coveragetest-module.c b/src/unit-test-coverage/shared/src/coveragetest-module.c index 64a9d415c..7cd0146b3 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-module.c +++ b/src/unit-test-coverage/shared/src/coveragetest-module.c @@ -32,9 +32,7 @@ #include /* A dummy function for the static symbol lookup test. Not called */ -void Test_DummyFunc(void) -{ -} +void Test_DummyFunc(void) {} /* * A symbol table for the static loader. @@ -42,11 +40,7 @@ void Test_DummyFunc(void) * Note - the symbol name is intentionally not the actual function name here. * This way, the test case knows that the answer actually came from the static table */ -OS_static_symbol_record_t OS_UT_STATIC_SYMBOL_TABLE[] = -{ - { "UT_staticsym", &Test_DummyFunc, "UTS" }, - { NULL } -}; +OS_static_symbol_record_t OS_UT_STATIC_SYMBOL_TABLE[] = {{"UT_staticsym", &Test_DummyFunc, "UTS"}, {NULL}}; /* ********************************************************************************** @@ -61,53 +55,48 @@ void Test_OS_ModuleAPI_Init(void) * int32 OS_ModuleAPI_Init(void) */ int32 expected = OS_SUCCESS; - int32 actual = OS_ModuleAPI_Init(); + int32 actual = OS_ModuleAPI_Init(); UtAssert_True(actual == expected, "OS_ModuleAPI_Init() (%ld) == OS_SUCCESS", (long)actual); } - - void Test_OS_ModuleLoad(void) { /* * Test Case For: * int32 OS_ModuleLoad ( uint32 *module_id, const char *module_name, const char *filename ) */ - int32 expected = OS_SUCCESS; + int32 expected = OS_SUCCESS; osal_id_t objid; - int32 actual = OS_ModuleLoad(&objid, "UT", "File"); + int32 actual = OS_ModuleLoad(&objid, "UT", "File"); UtAssert_True(actual == expected, "OS_ModuleLoad() (%ld) == OS_SUCCESS", (long)actual); actual = UT_GetStubCount(UT_KEY(OS_ModuleLoad_Impl)); UtAssert_True(actual == 1, "OS_ModuleLoad_Impl() called (%ld) == 1", (long)actual); - OSAPI_TEST_OBJID(objid,!=,OS_OBJECT_ID_UNDEFINED); - + OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); /* for a static module, it should also return a valid objid, but should NOT invoke OS_ModuleLoad_Impl */ actual = OS_ModuleLoad(&objid, "UTS", "File2"); UtAssert_True(actual == expected, "OS_ModuleLoad() (%ld) == OS_SUCCESS", (long)actual); actual = UT_GetStubCount(UT_KEY(OS_ModuleLoad_Impl)); UtAssert_True(actual == 1, "OS_ModuleLoad_Impl() called (%ld) == 1", (long)actual); - OSAPI_TEST_OBJID(objid,!=,OS_OBJECT_ID_UNDEFINED); + OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); /* error cases */ - actual = OS_ModuleLoad(NULL,NULL,NULL); + actual = OS_ModuleLoad(NULL, NULL, NULL); expected = OS_INVALID_POINTER; UtAssert_True(actual == expected, "OS_ModuleLoad() (%ld) == OS_INVALID_POINTER", (long)actual); UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_MAX_API_NAME); - actual = OS_ModuleLoad(&objid, "UTS", "File2"); + actual = OS_ModuleLoad(&objid, "UTS", "File2"); expected = OS_ERR_NAME_TOO_LONG; UtAssert_True(actual == expected, "OS_ModuleLoad() (%ld) == OS_ERR_NAME_TOO_LONG", (long)actual); UT_ResetState(UT_KEY(OCS_strlen)); - UT_SetForceFail(UT_KEY(OS_TranslatePath), OS_ERROR); - actual = OS_ModuleLoad(&objid, "UT", "FileBad"); + actual = OS_ModuleLoad(&objid, "UT", "FileBad"); expected = OS_ERROR; UtAssert_True(actual == expected, "OS_ModuleLoad() (%ld) == OS_ERROR", (long)actual); - } void Test_OS_ModuleUnload(void) @@ -117,7 +106,7 @@ void Test_OS_ModuleUnload(void) * int32 OS_ModuleUnload ( uint32 module_id ) */ int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 actual = ~OS_SUCCESS; actual = OS_ModuleUnload(UT_OBJID_1); @@ -130,36 +119,34 @@ void Test_OS_SymbolLookup(void) * Test Case For: * int32 OS_ModuleUnload ( uint32 module_id ) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; cpuaddr testaddr = 0; - cpuaddr symaddr = 0; + cpuaddr symaddr = 0; - actual = OS_SymbolLookup(&symaddr,"uttestsym0"); - UtAssert_True(actual == expected, "OS_SymbolLookup(name=%s) (%ld) == OS_SUCCESS", - "uttestsym0", (long)actual); + actual = OS_SymbolLookup(&symaddr, "uttestsym0"); + UtAssert_True(actual == expected, "OS_SymbolLookup(name=%s) (%ld) == OS_SUCCESS", "uttestsym0", (long)actual); UT_ResetState(UT_KEY(OS_SymbolLookup_Impl)); UT_SetForceFail(UT_KEY(OS_SymbolLookup_Impl), OS_ERROR); /* this lookup should always fail */ - symaddr = 0; + symaddr = 0; testaddr = 0; - actual = OS_SymbolLookup(&symaddr,"uttestsym1"); + actual = OS_SymbolLookup(&symaddr, "uttestsym1"); expected = OS_ERROR; - UtAssert_True(actual == expected, "OS_SymbolLookup(name=%s) (%ld) == OS_ERROR", - "uttestsym1", (long)actual); - UtAssert_True(symaddr == testaddr, "OS_SymbolLookup(address=%lx) == %lx", - (unsigned long)symaddr, (unsigned long)testaddr); + UtAssert_True(actual == expected, "OS_SymbolLookup(name=%s) (%ld) == OS_ERROR", "uttestsym1", (long)actual); + UtAssert_True(symaddr == testaddr, "OS_SymbolLookup(address=%lx) == %lx", (unsigned long)symaddr, + (unsigned long)testaddr); - actual = OS_SymbolLookup(NULL, NULL); + actual = OS_SymbolLookup(NULL, NULL); expected = OS_INVALID_POINTER; UtAssert_True(actual == expected, "OS_SymbolLookup(NULL) (%ld) == OS_INVALID_POINTER", (long)actual); /* * Look up a symbol that is present in the static symbol table */ - actual = OS_SymbolLookup(&symaddr, "UT_staticsym"); + actual = OS_SymbolLookup(&symaddr, "UT_staticsym"); expected = OS_SUCCESS; UtAssert_True(actual == expected, "OS_SymbolLookup(UT_staticsym) (%ld) == OS_SUCCESS", (long)actual); } @@ -169,62 +156,51 @@ void Test_OS_StaticSymbolLookup(void) /* * Test case for: * static int32 OS_ModuleLoad_Static(OS_static_symbol_record_t *StaticSymTable, const char *ModuleName) - * static int32 OS_SymbolLookup_Static(OS_static_symbol_record_t *StaticSymTable, cpuaddr *SymbolAddress, const char *SymbolName) + * static int32 OS_SymbolLookup_Static(OS_static_symbol_record_t *StaticSymTable, cpuaddr *SymbolAddress, const char + * *SymbolName) * * As these are internal helper functions we must go through a wrapper to invoke them. * The ability to get line coverage requires a non-empty lookup table, so one is supplied here. */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; cpuaddr addr; /* nominal */ actual = OS_SymbolLookup_Static(&addr, "UT_staticsym"); - UtAssert_True(actual == expected, "OS_SymbolLookup_Static(name=%s) (%ld) == OS_SUCCESS", - "Test_Func1", (long)actual); - UtAssert_True(addr == (cpuaddr)&Test_DummyFunc, "OS_SymbolLookup_Static(address=%lx) == %lx", - (unsigned long)addr, (unsigned long)&Test_DummyFunc); + UtAssert_True(actual == expected, "OS_SymbolLookup_Static(name=%s) (%ld) == OS_SUCCESS", "Test_Func1", + (long)actual); + UtAssert_True(addr == (cpuaddr)&Test_DummyFunc, "OS_SymbolLookup_Static(address=%lx) == %lx", (unsigned long)addr, + (unsigned long)&Test_DummyFunc); actual = OS_ModuleLoad_Static("UTS"); - UtAssert_True(actual == expected, "OS_ModuleLoad_Static(name=%s) (%ld) == OS_SUCCESS", - "UT", (long)actual); + UtAssert_True(actual == expected, "OS_ModuleLoad_Static(name=%s) (%ld) == OS_SUCCESS", "UT", (long)actual); expected = OS_ERROR; - actual = OS_SymbolLookup_Static(&addr, "Invalid"); - UtAssert_True(actual == expected, "OS_SymbolLookup_Static(name=%s) (%ld) == OS_ERROR", - "Invalid", (long)actual); + actual = OS_SymbolLookup_Static(&addr, "Invalid"); + UtAssert_True(actual == expected, "OS_SymbolLookup_Static(name=%s) (%ld) == OS_ERROR", "Invalid", (long)actual); expected = OS_ERR_NAME_NOT_FOUND; - actual = OS_ModuleLoad_Static("Invalid"); - UtAssert_True(actual == expected, "OS_ModuleLoad_Static(name=%s) (%ld) == OS_SUCCESS", - "Invalid", (long)actual); + actual = OS_ModuleLoad_Static("Invalid"); + UtAssert_True(actual == expected, "OS_ModuleLoad_Static(name=%s) (%ld) == OS_SUCCESS", "Invalid", (long)actual); } - void Test_OS_SymbolTableDump(void) { int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; - - actual = OS_SymbolTableDump ( "test", 555 ); - UtAssert_True(actual == expected, - "OS_SymbolTableDump() (%ld) == OS_SUCCESS", - (long)actual); + int32 actual = ~OS_SUCCESS; + actual = OS_SymbolTableDump("test", 555); + UtAssert_True(actual == expected, "OS_SymbolTableDump() (%ld) == OS_SUCCESS", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_SymbolTableDump ( NULL, 555 ); - UtAssert_True(actual == expected, - "OS_SymbolTableDump() (%ld) == OS_INVALID_POINTER", - (long)actual); + actual = OS_SymbolTableDump(NULL, 555); + UtAssert_True(actual == expected, "OS_SymbolTableDump() (%ld) == OS_INVALID_POINTER", (long)actual); UT_SetForceFail(UT_KEY(OS_TranslatePath), OS_ERROR); expected = OS_ERROR; - actual = OS_SymbolTableDump ( "test", 555 ); - UtAssert_True(actual == expected, - "OS_SymbolTableDump() (%ld) == OS_ERROR", - (long)actual); - + actual = OS_SymbolTableDump("test", 555); + UtAssert_True(actual == expected, "OS_SymbolTableDump() (%ld) == OS_ERROR", (long)actual); } void Test_OS_ModuleGetInfo(void) @@ -233,15 +209,15 @@ void Test_OS_ModuleGetInfo(void) * Test Case For: * int32 OS_ModuleInfo ( uint32 module_id, OS_module_prop_t *module_prop ) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; - OS_module_prop_t module_prop; - uint32 local_index = 1; - OS_common_record_t utrec; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; + OS_module_prop_t module_prop; + uint32 local_index = 1; + OS_common_record_t utrec; OS_common_record_t *rptr = &utrec; memset(&utrec, 0, sizeof(utrec)); - utrec.creator = UT_OBJID_OTHER; + utrec.creator = UT_OBJID_OTHER; utrec.name_entry = "ABC"; strncpy(OS_module_table[1].file_name, "DEF", sizeof(OS_module_table[1].file_name)); UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &local_index, sizeof(local_index), false); @@ -249,19 +225,14 @@ void Test_OS_ModuleGetInfo(void) actual = OS_ModuleInfo(UT_OBJID_1, &module_prop); UtAssert_True(actual == expected, "OS_ModuleGetInfo() (%ld) == OS_SUCCESS", (long)actual); - UtAssert_True(strcmp(module_prop.filename, "DEF") == 0, "module_prop.filename (%s) == DEF", - module_prop.filename); - UtAssert_True(strcmp(module_prop.name, "ABC") == 0, "module_prop.name (%s) == ABC", - module_prop.name); + UtAssert_True(strcmp(module_prop.filename, "DEF") == 0, "module_prop.filename (%s) == DEF", module_prop.filename); + UtAssert_True(strcmp(module_prop.name, "ABC") == 0, "module_prop.name (%s) == ABC", module_prop.name); - - actual = OS_ModuleInfo(UT_OBJID_1, NULL); + actual = OS_ModuleInfo(UT_OBJID_1, NULL); expected = OS_INVALID_POINTER; UtAssert_True(actual == expected, "OS_ModuleGetInfo(NULL) (%ld) == OS_INVALID_POINTER", (long)actual); } - - /* Osapi_Test_Setup * * Purpose: @@ -278,10 +249,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* * Register the test cases to execute with the unit test tool @@ -296,8 +264,3 @@ void UtTest_Setup(void) ADD_TEST(OS_SymbolTableDump); ADD_TEST(OS_StaticSymbolLookup); } - - - - - diff --git a/src/unit-test-coverage/shared/src/coveragetest-mutex.c b/src/unit-test-coverage/shared/src/coveragetest-mutex.c index c970eb1a9..ad13a1539 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-mutex.c +++ b/src/unit-test-coverage/shared/src/coveragetest-mutex.c @@ -42,24 +42,23 @@ void Test_OS_MutexAPI_Init(void) * int32 OS_MutSemAPI_Init(void) */ int32 expected = OS_SUCCESS; - int32 actual = OS_MutexAPI_Init(); + int32 actual = OS_MutexAPI_Init(); UtAssert_True(actual == expected, "OS_MutexAPI_Init() (%ld) == OS_SUCCESS", (long)actual); } - void Test_OS_MutSemCreate(void) { /* * Test Case For: * int32 OS_MutSemCreate (uint32 *sem_id, const char *sem_name, uint32 options) */ - int32 expected = OS_SUCCESS; + int32 expected = OS_SUCCESS; osal_id_t objid; - int32 actual = OS_MutSemCreate(&objid, "UT", 0); + int32 actual = OS_MutSemCreate(&objid, "UT", 0); UtAssert_True(actual == expected, "OS_MutSemCreate() (%ld) == OS_SUCCESS", (long)actual); - OSAPI_TEST_OBJID(objid,!=,OS_OBJECT_ID_UNDEFINED); + OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); OSAPI_TEST_FUNCTION_RC(OS_MutSemCreate(NULL, NULL, 0), OS_INVALID_POINTER); UT_SetForceFail(UT_KEY(OCS_strlen), 10 + OS_MAX_API_NAME); @@ -73,7 +72,7 @@ void Test_OS_MutSemDelete(void) * int32 OS_MutSemDelete (uint32 sem_id) */ int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 actual = ~OS_SUCCESS; actual = OS_MutSemDelete(UT_OBJID_1); @@ -87,14 +86,13 @@ void Test_OS_MutSemGive(void) * int32 OS_MutSemGive ( uint32 sem_id ) */ int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 actual = ~OS_SUCCESS; actual = OS_MutSemGive(UT_OBJID_1); UtAssert_True(actual == expected, "OS_MutSemGive() (%ld) == OS_SUCCESS", (long)actual); } - void Test_OS_MutSemTake(void) { /* @@ -102,7 +100,7 @@ void Test_OS_MutSemTake(void) * int32 OS_MutSemTake ( uint32 sem_id ) */ int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 actual = ~OS_SUCCESS; actual = OS_MutSemTake(UT_OBJID_1); @@ -115,23 +113,21 @@ void Test_OS_MutSemGetIdByName(void) * Test Case For: * int32 OS_MutSemGetIdByName (uint32 *sem_id, const char *sem_name) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; osal_id_t objid; UT_SetForceFail(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); actual = OS_MutSemGetIdByName(&objid, "UT"); UtAssert_True(actual == expected, "OS_MutSemGetIdByName() (%ld) == OS_SUCCESS", (long)actual); - OSAPI_TEST_OBJID(objid,!=,OS_OBJECT_ID_UNDEFINED); + OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); UT_ClearForceFail(UT_KEY(OS_ObjectIdFindByName)); expected = OS_ERR_NAME_NOT_FOUND; - actual = OS_MutSemGetIdByName(&objid, "NF"); - UtAssert_True(actual == expected, "OS_MutSemGetIdByName() (%ld) == %ld", - (long)actual, (long)expected); + actual = OS_MutSemGetIdByName(&objid, "NF"); + UtAssert_True(actual == expected, "OS_MutSemGetIdByName() (%ld) == %ld", (long)actual, (long)expected); OSAPI_TEST_FUNCTION_RC(OS_MutSemGetIdByName(NULL, NULL), OS_INVALID_POINTER); - } void Test_OS_MutSemGetInfo(void) @@ -140,31 +136,27 @@ void Test_OS_MutSemGetInfo(void) * Test Case For: * int32 OS_MutSemGetInfo (uint32 sem_id, OS_mut_sem_prop_t *mut_prop) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; - OS_mut_sem_prop_t prop; - uint32 local_index = 1; - OS_common_record_t utrec; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; + OS_mut_sem_prop_t prop; + uint32 local_index = 1; + OS_common_record_t utrec; OS_common_record_t *rptr = &utrec; memset(&utrec, 0, sizeof(utrec)); - utrec.creator = UT_OBJID_OTHER; + utrec.creator = UT_OBJID_OTHER; utrec.name_entry = "ABC"; UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &local_index, sizeof(local_index), false); UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &rptr, sizeof(rptr), false); actual = OS_MutSemGetInfo(UT_OBJID_1, &prop); UtAssert_True(actual == expected, "OS_MutSemGetInfo() (%ld) == OS_SUCCESS", (long)actual); - OSAPI_TEST_OBJID(prop.creator,==,UT_OBJID_OTHER); - UtAssert_True(strcmp(prop.name, "ABC") == 0, "prop.name (%s) == ABC", - prop.name); + OSAPI_TEST_OBJID(prop.creator, ==, UT_OBJID_OTHER); + UtAssert_True(strcmp(prop.name, "ABC") == 0, "prop.name (%s) == ABC", prop.name); OSAPI_TEST_FUNCTION_RC(OS_MutSemGetInfo(UT_OBJID_1, NULL), OS_INVALID_POINTER); - } - - /* Osapi_Test_Setup * * Purpose: @@ -181,11 +173,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} - +void Osapi_Test_Teardown(void) {} /* * Register the test cases to execute with the unit test tool @@ -200,8 +188,3 @@ void UtTest_Setup(void) ADD_TEST(OS_MutSemGetIdByName); ADD_TEST(OS_MutSemGetInfo); } - - - - - diff --git a/src/unit-test-coverage/shared/src/coveragetest-network.c b/src/unit-test-coverage/shared/src/coveragetest-network.c index f447c81e8..871992d1f 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-network.c +++ b/src/unit-test-coverage/shared/src/coveragetest-network.c @@ -27,7 +27,6 @@ #include "os-shared-coveragetest.h" #include "os-shared-network.h" - void Test_OS_NetworkAPI_Init(void) { /* @@ -35,39 +34,39 @@ void Test_OS_NetworkAPI_Init(void) * int32 OS_NetworkAPI_Init(void) */ int32 expected = OS_SUCCESS; - int32 actual = OS_NetworkAPI_Init(); + int32 actual = OS_NetworkAPI_Init(); UtAssert_True(actual == expected, "OS_NetworkAPI_Init() (%ld) == OS_SUCCESS", (long)actual); } -void Test_OS_NetworkGetHostName (void) +void Test_OS_NetworkGetHostName(void) { /* * Test Case For: * int32 OS_NetworkGetHostName(char *host_name, uint32 name_len) */ - char Buffer[32]; + char Buffer[32]; int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 actual = ~OS_SUCCESS; actual = OS_NetworkGetHostName(Buffer, sizeof(Buffer)); UtAssert_True(actual == expected, "OS_NetworkGetHostName() (%ld) == OS_SUCCESS", (long)actual); UT_SetForceFail(UT_KEY(OS_NetworkGetHostName_Impl), -4444); expected = -4444; - actual = OS_NetworkGetHostName(Buffer, sizeof(Buffer)); + actual = OS_NetworkGetHostName(Buffer, sizeof(Buffer)); UtAssert_True(actual == expected, "OS_NetworkGetHostName(impl error) (%ld) == -4444", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_NetworkGetHostName(NULL, sizeof(Buffer)); + actual = OS_NetworkGetHostName(NULL, sizeof(Buffer)); UtAssert_True(actual == expected, "OS_NetworkGetHostName(Ptr=NULL) (%ld) == OS_INVALID_POINTER", (long)actual); expected = OS_ERROR; - actual = OS_NetworkGetHostName(Buffer, 0); + actual = OS_NetworkGetHostName(Buffer, 0); UtAssert_True(actual == expected, "OS_NetworkGetHostName(Size=0) (%ld) == OS_ERROR", (long)actual); } -void Test_OS_NetworkGetID (void) +void Test_OS_NetworkGetID(void) { /* * Test Case For: @@ -77,12 +76,12 @@ void Test_OS_NetworkGetID (void) int32 actual; expected = 42; - actual = OS_NetworkGetID(); + actual = OS_NetworkGetID(); UtAssert_True(actual == expected, "OS_NetworkGetID(nominal) (%ld) == 42", (long)actual); UT_SetForceFail(UT_KEY(OS_NetworkGetID_Impl), -5555); expected = -1; - actual = OS_NetworkGetID(); + actual = OS_NetworkGetID(); UtAssert_True(actual == expected, "OS_NetworkGetID(error) (%ld) == -1", (long)actual); } @@ -102,10 +101,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* * Register the test cases to execute with the unit test tool @@ -116,8 +112,3 @@ void UtTest_Setup(void) ADD_TEST(OS_NetworkGetID); ADD_TEST(OS_NetworkGetHostName); } - - - - - diff --git a/src/unit-test-coverage/shared/src/coveragetest-printf.c b/src/unit-test-coverage/shared/src/coveragetest-printf.c index 6469d906f..8d6a888d6 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-printf.c +++ b/src/unit-test-coverage/shared/src/coveragetest-printf.c @@ -39,7 +39,7 @@ void Test_OS_ConsoleAPI_Init(void) * int32 OS_ConsoleAPI_Init(void) */ uint32 CallCount = 0; - uint32 local_id = 0; + uint32 local_id = 0; UT_SetDataBuffer(UT_KEY(OS_ObjectIdAllocateNew), &local_id, sizeof(local_id), false); @@ -50,7 +50,6 @@ void Test_OS_ConsoleAPI_Init(void) UtAssert_True(CallCount == 1, "OS_ConsoleCreate_Impl() call count (%lu) == 1", (unsigned long)CallCount); } - void Test_OS_printf(void) { /* @@ -63,29 +62,32 @@ void Test_OS_printf(void) /* catch case where OS_printf called before init */ OS_SharedGlobalVars.PrintfConsoleId = OS_OBJECT_ID_UNDEFINED; - OS_SharedGlobalVars.Initialized = false; + OS_SharedGlobalVars.Initialized = false; OS_printf("UnitTest1"); - UtAssert_True(OS_console_table[0].WritePos == 0, "WritePos (%lu) >= 0", (unsigned long)OS_console_table[0].WritePos); + UtAssert_True(OS_console_table[0].WritePos == 0, "WritePos (%lu) >= 0", + (unsigned long)OS_console_table[0].WritePos); /* because printf is disabled, the call count should _not_ increase here */ OS_SharedGlobalVars.Initialized = true; OS_printf_disable(); OS_printf("UnitTest2"); - UtAssert_True(OS_console_table[0].WritePos == 0, "WritePos (%lu) >= 0", (unsigned long)OS_console_table[0].WritePos); + UtAssert_True(OS_console_table[0].WritePos == 0, "WritePos (%lu) >= 0", + (unsigned long)OS_console_table[0].WritePos); /* normal case */ OS_printf_enable(); OS_printf("UnitTest3"); CallCount = UT_GetStubCount(UT_KEY(OS_ConsoleWakeup_Impl)); UtAssert_True(CallCount == 1, "OS_ConsoleWakeup_Impl() call count (%lu) == 1", (unsigned long)CallCount); - UtAssert_True(OS_console_table[0].WritePos >= 9, "WritePos (%lu) >= 9", (unsigned long)OS_console_table[0].WritePos); + UtAssert_True(OS_console_table[0].WritePos >= 9, "WritePos (%lu) >= 9", + (unsigned long)OS_console_table[0].WritePos); /* print a long string that does not fit in the 16-char buffer */ OS_printf_enable(); OS_printf("UnitTest4BufferLengthExceeded"); /* test writing with a non-empty console name */ - strncpy(OS_console_table[0].device_name,"ut",sizeof(OS_console_table[0].device_name)-1); + strncpy(OS_console_table[0].device_name, "ut", sizeof(OS_console_table[0].device_name) - 1); OS_printf("UnitTest5"); /* @@ -94,7 +96,7 @@ void Test_OS_printf(void) UT_SetForceFail(UT_KEY(OCS_vsnprintf), -1); OS_printf("UnitTest6"); - UT_SetForceFail(UT_KEY(OCS_vsnprintf), OS_BUFFER_SIZE+10); + UT_SetForceFail(UT_KEY(OCS_vsnprintf), OS_BUFFER_SIZE + 10); OS_printf("UnitTest7"); } @@ -118,10 +120,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* * Register the test cases to execute with the unit test tool @@ -131,7 +130,3 @@ void UtTest_Setup(void) ADD_TEST(OS_ConsoleAPI_Init); ADD_TEST(OS_printf); } - - - - diff --git a/src/unit-test-coverage/shared/src/coveragetest-queue.c b/src/unit-test-coverage/shared/src/coveragetest-queue.c index c322ff5bd..4c8bfa89a 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-queue.c +++ b/src/unit-test-coverage/shared/src/coveragetest-queue.c @@ -42,7 +42,7 @@ void Test_OS_QueueAPI_Init(void) * int32 OS_QueueAPI_Init(void) */ int32 expected = OS_SUCCESS; - int32 actual = OS_QueueAPI_Init(); + int32 actual = OS_QueueAPI_Init(); UtAssert_True(actual == expected, "OS_QueueAPI_Init() (%ld) == OS_SUCCESS", (long)actual); } @@ -51,27 +51,28 @@ void Test_OS_QueueCreate(void) { /* * Test Case For: - * int32 OS_QueueCreate (uint32 *queue_id, const char *queue_name, uint32 queue_depth, uint32 data_size, uint32 flags) + * int32 OS_QueueCreate (uint32 *queue_id, const char *queue_name, uint32 queue_depth, uint32 data_size, uint32 + * flags) */ - int32 expected = OS_SUCCESS; + int32 expected = OS_SUCCESS; osal_id_t objid; - int32 actual = OS_QueueCreate(&objid, "UT", 0, 0,0); + int32 actual = OS_QueueCreate(&objid, "UT", 0, 0, 0); UtAssert_True(actual == expected, "OS_QueueCreate() (%ld) == OS_SUCCESS", (long)actual); /* test error cases */ expected = OS_INVALID_POINTER; - actual = OS_QueueCreate(NULL, "UT", 0, 0,0); + actual = OS_QueueCreate(NULL, "UT", 0, 0, 0); UtAssert_True(actual == expected, "OS_QueueCreate() (%ld) == OS_INVALID_POINTER", (long)actual); UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_MAX_API_NAME); expected = OS_ERR_NAME_TOO_LONG; - actual = OS_QueueCreate(&objid, "UT", 0, 0,0); + actual = OS_QueueCreate(&objid, "UT", 0, 0, 0); UtAssert_True(actual == expected, "OS_QueueCreate() (%ld) == OS_ERR_NAME_TOO_LONG", (long)actual); UT_ClearForceFail(UT_KEY(OCS_strlen)); expected = OS_QUEUE_INVALID_SIZE; - actual = OS_QueueCreate(&objid, "UT", 1 + OS_QUEUE_MAX_DEPTH, 0,0); + actual = OS_QueueCreate(&objid, "UT", 1 + OS_QUEUE_MAX_DEPTH, 0, 0); UtAssert_True(actual == expected, "OS_QueueCreate() (%ld) == OS_QUEUE_INVALID_SIZE", (long)actual); } @@ -82,7 +83,7 @@ void Test_OS_QueueDelete(void) * int32 OS_QueueDelete (uint32 queue_id) */ int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 actual = ~OS_SUCCESS; actual = OS_QueueDelete(UT_OBJID_1); @@ -95,10 +96,10 @@ void Test_OS_QueueGet(void) * Test Case For: * int32 OS_QueueGet (uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; uint32 actual_size; - char Buf[4]; + char Buf[4]; actual = OS_QueueGet(UT_OBJID_1, Buf, sizeof(Buf), &actual_size, 0); @@ -106,25 +107,24 @@ void Test_OS_QueueGet(void) /* test error cases */ expected = OS_INVALID_POINTER; - actual = OS_QueueGet(UT_OBJID_1, NULL, sizeof(Buf), &actual_size, 0); + actual = OS_QueueGet(UT_OBJID_1, NULL, sizeof(Buf), &actual_size, 0); UtAssert_True(actual == expected, "OS_QueueGet() (%ld) == OS_INVALID_POINTER", (long)actual); OS_queue_table[1].max_size = sizeof(Buf) + 10; - expected = OS_QUEUE_INVALID_SIZE; - actual = OS_QueueGet(UT_OBJID_1, Buf, sizeof(Buf), &actual_size, 0); + expected = OS_QUEUE_INVALID_SIZE; + actual = OS_QueueGet(UT_OBJID_1, Buf, sizeof(Buf), &actual_size, 0); UtAssert_True(actual == expected, "OS_QueueGet() (%ld) == OS_QUEUE_INVALID_SIZE", (long)actual); } - void Test_OS_QueuePut(void) { /* * Test Case For: * int32 OS_QueuePut (uint32 queue_id, const void *data, uint32 size, uint32 flags) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; - const char Data[4] = "xyz"; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; + const char Data[4] = "xyz"; actual = OS_QueuePut(UT_OBJID_1, Data, sizeof(Data), 0); @@ -132,20 +132,18 @@ void Test_OS_QueuePut(void) /* test error cases */ expected = OS_INVALID_POINTER; - actual = OS_QueuePut(UT_OBJID_1, NULL, sizeof(Data), 0); + actual = OS_QueuePut(UT_OBJID_1, NULL, sizeof(Data), 0); UtAssert_True(actual == expected, "OS_QueuePut() (%ld) == OS_INVALID_POINTER", (long)actual); - } - void Test_OS_QueueGetIdByName(void) { /* * Test Case For: * int32 OS_QueueGetIdByName (uint32 *queue_id, const char *queue_name) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; osal_id_t objid; UT_SetForceFail(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); @@ -154,13 +152,11 @@ void Test_OS_QueueGetIdByName(void) UT_ClearForceFail(UT_KEY(OS_ObjectIdFindByName)); expected = OS_ERR_NAME_NOT_FOUND; - actual = OS_QueueGetIdByName(&objid, "NF"); - UtAssert_True(actual == expected, "OS_QueueGetIdByName() (%ld) == %ld", - (long)actual, (long)expected); - + actual = OS_QueueGetIdByName(&objid, "NF"); + UtAssert_True(actual == expected, "OS_QueueGetIdByName() (%ld) == %ld", (long)actual, (long)expected); expected = OS_INVALID_POINTER; - actual = OS_QueueGetIdByName(NULL, "NF"); + actual = OS_QueueGetIdByName(NULL, "NF"); UtAssert_True(actual == expected, "OS_QueueGetIdByName() (%ld) == OS_INVALID_POINTER", (long)actual); } @@ -170,17 +166,17 @@ void Test_OS_QueueGetInfo(void) * Test Case For: * int32 OS_QueueGetInfo (uint32 queue_id, OS_queue_prop_t *queue_prop) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; - OS_queue_prop_t queue_prop; - osal_id_t id; - uint32 local_index = 1; - OS_common_record_t utrec; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; + OS_queue_prop_t queue_prop; + osal_id_t id; + uint32 local_index = 1; + OS_common_record_t utrec; OS_common_record_t *rptr = &utrec; memset(&utrec, 0, sizeof(utrec)); - id = UT_OBJID_OTHER; - utrec.creator = UT_OBJID_OTHER; + id = UT_OBJID_OTHER; + utrec.creator = UT_OBJID_OTHER; utrec.name_entry = "ABC"; UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &local_index, sizeof(local_index), false); UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &rptr, sizeof(rptr), false); @@ -188,16 +184,13 @@ void Test_OS_QueueGetInfo(void) UtAssert_True(actual == expected, "OS_QueueGetInfo() (%ld) == OS_SUCCESS", (long)actual); UtAssert_MemCmp(&queue_prop.creator, &id, sizeof(osal_id_t), "queue_prop.creator == UT_OBJID_OTHER"); - UtAssert_True(strcmp(queue_prop.name, "ABC") == 0, "queue_prop.name (%s) == ABC", - queue_prop.name); + UtAssert_True(strcmp(queue_prop.name, "ABC") == 0, "queue_prop.name (%s) == ABC", queue_prop.name); expected = OS_INVALID_POINTER; - actual = OS_QueueGetInfo(UT_OBJID_1, NULL); + actual = OS_QueueGetInfo(UT_OBJID_1, NULL); UtAssert_True(actual == expected, "OS_QueueGetInfo() (%ld) == OS_INVALID_POINTER", (long)actual); } - - /* Osapi_Test_Setup * * Purpose: @@ -214,10 +207,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* * Register the test cases to execute with the unit test tool @@ -232,8 +222,3 @@ void UtTest_Setup(void) ADD_TEST(OS_QueueGetIdByName); ADD_TEST(OS_QueueGetInfo); } - - - - - diff --git a/src/unit-test-coverage/shared/src/coveragetest-select.c b/src/unit-test-coverage/shared/src/coveragetest-select.c index c493c9d2c..79c43f004 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-select.c +++ b/src/unit-test-coverage/shared/src/coveragetest-select.c @@ -41,9 +41,9 @@ void Test_OS_SelectSingle(void) * Test Case For: * int32 OS_SelectSingle(uint32 objid, uint32 *StateFlags, int32 msecs); */ - int32 expected = OS_SUCCESS; + int32 expected = OS_SUCCESS; uint32 StateFlags = 0; - int32 actual = OS_SelectSingle(UT_OBJID_1, &StateFlags, 0); + int32 actual = OS_SelectSingle(UT_OBJID_1, &StateFlags, 0); /* Verify Outputs */ UtAssert_True(actual == expected, "OS_SelectSingle() (%ld) == OS_SUCCESS", (long)actual); @@ -57,8 +57,8 @@ void Test_OS_SelectMultiple(void) */ OS_FdSet ReadSet; OS_FdSet WriteSet; - int32 expected = OS_SUCCESS; - int32 actual; + int32 expected = OS_SUCCESS; + int32 actual; OS_SelectFdZero(&ReadSet); OS_SelectFdZero(&WriteSet); @@ -77,9 +77,9 @@ void Test_OS_SelectFdAddClearOps(void) * int32 OS_SelectFdClear(OS_FdSet *Set, uint32 objid); * bool OS_SelectFdIsSet(OS_FdSet *Set, uint32 objid); */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; - uint32 CallCount = 0; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; + uint32 CallCount = 0; OS_FdSet UtSet; actual = OS_SelectFdZero(&UtSet); @@ -92,7 +92,7 @@ void Test_OS_SelectFdAddClearOps(void) UtAssert_True(!OS_SelectFdIsSet(&UtSet, UT_OBJID_2), "OS_SelectFdIsSet(2) == false"); expected = OS_SUCCESS; - actual = OS_SelectFdAdd(&UtSet, UT_OBJID_1); + actual = OS_SelectFdAdd(&UtSet, UT_OBJID_1); UtAssert_True(actual == expected, "OS_SelectFdAdd() (%ld) == %ld", (long)actual, (long)expected); UtAssert_True(OS_SelectFdIsSet(&UtSet, UT_OBJID_1), "OS_SelectFdIsSet(1) == true"); UtAssert_True(!OS_SelectFdIsSet(&UtSet, UT_OBJID_2), "OS_SelectFdIsSet(2) == false"); @@ -106,7 +106,6 @@ void Test_OS_SelectFdAddClearOps(void) UtAssert_True(OS_SelectFdIsSet(&UtSet, UT_OBJID_1), "OS_SelectFdIsSet(1) == true"); UtAssert_True(!OS_SelectFdIsSet(&UtSet, UT_OBJID_2), "OS_SelectFdIsSet(2) == false"); - expected = -42; UT_SetForceFail(UT_KEY(OS_ObjectIdToArrayIndex), expected); actual = OS_SelectFdAdd(&UtSet, UT_OBJID_2); @@ -137,10 +136,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* * Register the test cases to execute with the unit test tool @@ -151,8 +147,3 @@ void UtTest_Setup(void) ADD_TEST(OS_SelectSingle); ADD_TEST(OS_SelectMultiple); } - - - - - diff --git a/src/unit-test-coverage/shared/src/coveragetest-shell.c b/src/unit-test-coverage/shared/src/coveragetest-shell.c index 046d314fb..ddd96ef0c 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-shell.c +++ b/src/unit-test-coverage/shared/src/coveragetest-shell.c @@ -33,7 +33,6 @@ ********************************************************************************** */ - void Test_OS_ShellOutputToFile(void) { /* @@ -41,21 +40,16 @@ void Test_OS_ShellOutputToFile(void) * int32 OS_ShellOutputToFile(const char* Cmd, uint32 filedes) */ int32 expected = OS_SUCCESS; - int32 actual = OS_ShellOutputToFile("Cmd", 1); + int32 actual = OS_ShellOutputToFile("Cmd", 1); UtAssert_True(actual == expected, "OS_ShellOutputToFile() (%ld) == OS_SUCCESS", (long)actual); - expected = OS_INVALID_POINTER; - actual = OS_ShellOutputToFile(NULL, 1); + actual = OS_ShellOutputToFile(NULL, 1); UtAssert_True(actual == expected, "OS_ShellOutputToFile() (%ld) == OS_SUCCESS", (long)actual); } - - - - /* Osapi_Test_Setup * * Purpose: @@ -72,10 +66,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* * Register the test cases to execute with the unit test tool @@ -84,8 +75,3 @@ void UtTest_Setup(void) { ADD_TEST(OS_ShellOutputToFile); } - - - - - diff --git a/src/unit-test-coverage/shared/src/coveragetest-sockets.c b/src/unit-test-coverage/shared/src/coveragetest-sockets.c index c55ac1cd8..13c7314a6 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-sockets.c +++ b/src/unit-test-coverage/shared/src/coveragetest-sockets.c @@ -38,7 +38,7 @@ void Test_OS_SocketAPI_Init(void) * int32 OS_SocketAPI_Init(void) */ int32 expected = OS_SUCCESS; - int32 actual = OS_SocketAPI_Init(); + int32 actual = OS_SocketAPI_Init(); UtAssert_True(actual == expected, "OS_SocketAPI_Init() (%ld) == OS_SUCCESS", (long)actual); } @@ -81,17 +81,16 @@ void Test_OS_SocketOpen(void) * Test Case For: * int32 OS_SocketOpen(uint32 *sock_id, OS_SocketDomain_t Domain, OS_SocketType_t Type) */ - int32 expected = OS_SUCCESS; + int32 expected = OS_SUCCESS; osal_id_t objid; - int32 actual = OS_SocketOpen(&objid, OS_SocketDomain_INET, OS_SocketType_STREAM); + int32 actual = OS_SocketOpen(&objid, OS_SocketDomain_INET, OS_SocketType_STREAM); UtAssert_True(actual == expected, "OS_SocketOpen() (%ld) == OS_SUCCESS", (long)actual); - OSAPI_TEST_OBJID(objid,!=,OS_OBJECT_ID_UNDEFINED); + OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); expected = OS_INVALID_POINTER; - actual = OS_SocketOpen(NULL, OS_SocketDomain_INVALID, OS_SocketType_INVALID); + actual = OS_SocketOpen(NULL, OS_SocketDomain_INVALID, OS_SocketType_INVALID); UtAssert_True(actual == expected, "OS_SocketOpen(NULL) (%ld) == OS_INVALID_POINTER", (long)actual); - } /***************************************************************************** @@ -105,36 +104,37 @@ void Test_OS_SocketBind(void) * Test Case For: * int32 OS_SocketBind(uint32 sock_id, const OS_SockAddr_t *Addr) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; OS_SockAddr_t Addr; OS_stream_table[1].socket_domain = OS_SocketDomain_INET; - memset(&Addr,0,sizeof(Addr)); + memset(&Addr, 0, sizeof(Addr)); actual = OS_SocketBind(UT_OBJID_1, &Addr); UtAssert_True(actual == expected, "OS_SocketBind() (%ld) == OS_SUCCESS", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_SocketBind(UT_OBJID_1, NULL); + actual = OS_SocketBind(UT_OBJID_1, NULL); UtAssert_True(actual == expected, "OS_SocketBind(NULL) (%ld) == OS_INVALID_POINTER", (long)actual); /* * Should fail if not a socket domain */ OS_stream_table[1].socket_domain = OS_SocketDomain_INVALID; - expected = OS_ERR_INCORRECT_OBJ_TYPE; - actual = OS_SocketBind(UT_OBJID_1, &Addr); + expected = OS_ERR_INCORRECT_OBJ_TYPE; + actual = OS_SocketBind(UT_OBJID_1, &Addr); UtAssert_True(actual == expected, "OS_SocketBind() non-socket (%ld) == OS_ERR_INCORRECT_OBJ_TYPE", (long)actual); /* * Should fail if already bound */ OS_stream_table[1].socket_domain = OS_SocketDomain_INET; - OS_stream_table[1].stream_state = OS_STREAM_STATE_BOUND; - expected = OS_ERR_INCORRECT_OBJ_STATE; - actual = OS_SocketBind(UT_OBJID_1, &Addr); - UtAssert_True(actual == expected, "OS_SocketBind() already bound (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); + OS_stream_table[1].stream_state = OS_STREAM_STATE_BOUND; + expected = OS_ERR_INCORRECT_OBJ_STATE; + actual = OS_SocketBind(UT_OBJID_1, &Addr); + UtAssert_True(actual == expected, "OS_SocketBind() already bound (%ld) == OS_ERR_INCORRECT_OBJ_STATE", + (long)actual); } /***************************************************************************** @@ -148,48 +148,49 @@ void Test_OS_SocketAccept(void) * Test Case For: * int32 OS_SocketAccept(uint32 sock_id, uint32 *connsock_id, OS_SockAddr_t *Addr, int32 timeout) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; - uint32 local_id = 0; - osal_id_t connsock_id; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; + uint32 local_id = 0; + osal_id_t connsock_id; OS_SockAddr_t Addr; connsock_id = OS_OBJECT_ID_UNDEFINED; - OS_stream_table[local_id].socket_type = OS_SocketType_STREAM; + OS_stream_table[local_id].socket_type = OS_SocketType_STREAM; OS_stream_table[local_id].stream_state = OS_STREAM_STATE_BOUND; UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &local_id, sizeof(local_id), false); - memset(&Addr,0,sizeof(Addr)); + memset(&Addr, 0, sizeof(Addr)); actual = OS_SocketAccept(UT_OBJID_1, &connsock_id, &Addr, 0); UtAssert_True(actual == expected, "OS_SocketAccept() (%ld) == OS_SUCCESS", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_SocketAccept(UT_OBJID_1, NULL, NULL, 0); + actual = OS_SocketAccept(UT_OBJID_1, NULL, NULL, 0); UtAssert_True(actual == expected, "OS_SocketAccept(NULL) (%ld) == OS_INVALID_POINTER", (long)actual); /* * Should fail if not a stream socket */ OS_stream_table[1].socket_type = OS_SocketType_INVALID; - expected = OS_ERR_INCORRECT_OBJ_TYPE; - actual = OS_SocketAccept(UT_OBJID_1, &connsock_id, &Addr, 0); + expected = OS_ERR_INCORRECT_OBJ_TYPE; + actual = OS_SocketAccept(UT_OBJID_1, &connsock_id, &Addr, 0); UtAssert_True(actual == expected, "OS_SocketAccept() non-stream (%ld) == OS_ERR_INCORRECT_OBJ_TYPE", (long)actual); /* * Should fail if already connected */ - OS_stream_table[1].socket_type = OS_SocketType_STREAM; - OS_stream_table[1].stream_state = OS_STREAM_STATE_BOUND|OS_STREAM_STATE_CONNECTED; - expected = OS_ERR_INCORRECT_OBJ_STATE; - actual = OS_SocketAccept(UT_OBJID_1, &connsock_id, &Addr, 0); - UtAssert_True(actual == expected, "OS_SocketAccept() already bound (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); + OS_stream_table[1].socket_type = OS_SocketType_STREAM; + OS_stream_table[1].stream_state = OS_STREAM_STATE_BOUND | OS_STREAM_STATE_CONNECTED; + expected = OS_ERR_INCORRECT_OBJ_STATE; + actual = OS_SocketAccept(UT_OBJID_1, &connsock_id, &Addr, 0); + UtAssert_True(actual == expected, "OS_SocketAccept() already bound (%ld) == OS_ERR_INCORRECT_OBJ_STATE", + (long)actual); /* * Underlying implementation failure test */ OS_stream_table[1].stream_state = OS_STREAM_STATE_BOUND; - expected = -1234; + expected = -1234; UT_SetForceFail(UT_KEY(OS_SocketAccept_Impl), -1234); actual = OS_SocketAccept(UT_OBJID_1, &connsock_id, &Addr, 0); UtAssert_True(actual == expected, "OS_SocketAccept() underlying failure (%ld) == -1234", (long)actual); @@ -206,45 +207,45 @@ void Test_OS_SocketConnect(void) * Test Case For: * int32 OS_SocketConnect(uint32 sock_id, const OS_SockAddr_t *Addr, int32 Timeout) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; OS_SockAddr_t Addr; - uint32 idbuf; + uint32 idbuf; - memset(&Addr,0,sizeof(Addr)); + memset(&Addr, 0, sizeof(Addr)); idbuf = 1; - UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById),&idbuf, sizeof(idbuf), false); + UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &idbuf, sizeof(idbuf), false); OS_stream_table[idbuf].socket_domain = OS_SocketDomain_INET; - OS_stream_table[idbuf].socket_type = OS_SocketType_STREAM; - OS_stream_table[idbuf].stream_state = 0; + OS_stream_table[idbuf].socket_type = OS_SocketType_STREAM; + OS_stream_table[idbuf].stream_state = 0; actual = OS_SocketConnect(UT_OBJID_1, &Addr, 0); UtAssert_True(actual == expected, "OS_SocketConnect() (%ld) == OS_SUCCESS", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_SocketConnect(UT_OBJID_1, NULL, 0); + actual = OS_SocketConnect(UT_OBJID_1, NULL, 0); UtAssert_True(actual == expected, "OS_SocketConnect(NULL) (%ld) == OS_INVALID_POINTER", (long)actual); /* * Should fail if not a stream socket */ OS_stream_table[1].socket_domain = OS_SocketDomain_INVALID; - OS_stream_table[1].socket_type = OS_SocketType_INVALID; - expected = OS_ERR_INCORRECT_OBJ_TYPE; - actual = OS_SocketConnect(UT_OBJID_1, &Addr, 0); + OS_stream_table[1].socket_type = OS_SocketType_INVALID; + expected = OS_ERR_INCORRECT_OBJ_TYPE; + actual = OS_SocketConnect(UT_OBJID_1, &Addr, 0); UtAssert_True(actual == expected, "OS_SocketConnect() non-stream (%ld) == OS_ERR_INCORRECT_OBJ_TYPE", (long)actual); /* * Should fail if already connected */ OS_stream_table[1].socket_domain = OS_SocketDomain_INET; - OS_stream_table[1].socket_type = OS_SocketType_STREAM; - OS_stream_table[1].stream_state = OS_STREAM_STATE_CONNECTED; - expected = OS_ERR_INCORRECT_OBJ_STATE; - actual = OS_SocketConnect(UT_OBJID_1, &Addr, 0); - UtAssert_True(actual == expected, "OS_SocketConnect() already connected (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); - + OS_stream_table[1].socket_type = OS_SocketType_STREAM; + OS_stream_table[1].stream_state = OS_STREAM_STATE_CONNECTED; + expected = OS_ERR_INCORRECT_OBJ_STATE; + actual = OS_SocketConnect(UT_OBJID_1, &Addr, 0); + UtAssert_True(actual == expected, "OS_SocketConnect() already connected (%ld) == OS_ERR_INCORRECT_OBJ_STATE", + (long)actual); } /***************************************************************************** @@ -258,41 +259,43 @@ void Test_OS_SocketRecvFrom(void) * Test Case For: * OS_SocketRecvFrom(uint32 sock_id, void *buffer, uint32 buflen, OS_SockAddr_t *RemoteAddr, int32 timeout) */ - char Buf; - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + char Buf; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; OS_SockAddr_t Addr; - uint32 idbuf; + uint32 idbuf; - memset(&Addr,0,sizeof(Addr)); + memset(&Addr, 0, sizeof(Addr)); idbuf = 1; - UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById),&idbuf, sizeof(idbuf), false); - OS_stream_table[idbuf].socket_type = OS_SocketType_DATAGRAM; + UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &idbuf, sizeof(idbuf), false); + OS_stream_table[idbuf].socket_type = OS_SocketType_DATAGRAM; OS_stream_table[idbuf].stream_state = OS_STREAM_STATE_BOUND; - actual = OS_SocketRecvFrom(UT_OBJID_1, &Buf, 1, &Addr, 0); + actual = OS_SocketRecvFrom(UT_OBJID_1, &Buf, 1, &Addr, 0); UtAssert_True(actual == expected, "OS_SocketRecvFrom() (%ld) == OS_SUCCESS", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_SocketRecvFrom(UT_OBJID_1, NULL, 0, NULL, 0); + actual = OS_SocketRecvFrom(UT_OBJID_1, NULL, 0, NULL, 0); UtAssert_True(actual == expected, "OS_SocketRecvFrom(NULL) (%ld) == OS_INVALID_POINTER", (long)actual); /* * Should fail if not a datagram socket */ OS_stream_table[1].socket_type = OS_SocketType_INVALID; - expected = OS_ERR_INCORRECT_OBJ_TYPE; - actual = OS_SocketRecvFrom(UT_OBJID_1, &Buf, 1, &Addr, 0); - UtAssert_True(actual == expected, "OS_SocketRecvFrom() non-datagram (%ld) == OS_ERR_INCORRECT_OBJ_TYPE", (long)actual); + expected = OS_ERR_INCORRECT_OBJ_TYPE; + actual = OS_SocketRecvFrom(UT_OBJID_1, &Buf, 1, &Addr, 0); + UtAssert_True(actual == expected, "OS_SocketRecvFrom() non-datagram (%ld) == OS_ERR_INCORRECT_OBJ_TYPE", + (long)actual); /* * Should fail if not bound */ - OS_stream_table[1].socket_type = OS_SocketType_DATAGRAM; + OS_stream_table[1].socket_type = OS_SocketType_DATAGRAM; OS_stream_table[1].stream_state = 0; - expected = OS_ERR_INCORRECT_OBJ_STATE; - actual = OS_SocketRecvFrom(UT_OBJID_1, &Buf, 1, &Addr, 0); - UtAssert_True(actual == expected, "OS_SocketRecvFrom() non-bound (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); + expected = OS_ERR_INCORRECT_OBJ_STATE; + actual = OS_SocketRecvFrom(UT_OBJID_1, &Buf, 1, &Addr, 0); + UtAssert_True(actual == expected, "OS_SocketRecvFrom() non-bound (%ld) == OS_ERR_INCORRECT_OBJ_STATE", + (long)actual); } /***************************************************************************** @@ -306,65 +309,63 @@ void Test_OS_SocketSendTo(void) * Test Case For: * int32 OS_SocketSendTo(uint32 sock_id, const void *buffer, uint32 buflen, const OS_SockAddr_t *RemoteAddr) */ - char Buf = 'A'; - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + char Buf = 'A'; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; OS_SockAddr_t Addr; - uint32 idbuf; + uint32 idbuf; - memset(&Addr,0,sizeof(Addr)); + memset(&Addr, 0, sizeof(Addr)); idbuf = 1; - UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById),&idbuf, sizeof(idbuf), false); - OS_stream_table[idbuf].socket_type = OS_SocketType_DATAGRAM; + UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &idbuf, sizeof(idbuf), false); + OS_stream_table[idbuf].socket_type = OS_SocketType_DATAGRAM; OS_stream_table[idbuf].stream_state = OS_STREAM_STATE_BOUND; - actual = OS_SocketSendTo(UT_OBJID_1, &Buf, 1, &Addr); + actual = OS_SocketSendTo(UT_OBJID_1, &Buf, 1, &Addr); UtAssert_True(actual == expected, "OS_SocketSendTo() (%ld) == OS_SUCCESS", (long)actual); expected = OS_INVALID_POINTER; - actual = OS_SocketSendTo(UT_OBJID_1, NULL, 0, NULL); + actual = OS_SocketSendTo(UT_OBJID_1, NULL, 0, NULL); UtAssert_True(actual == expected, "OS_SocketSendTo(NULL) (%ld) == OS_INVALID_POINTER", (long)actual); /* * Should fail if not a datagram socket */ OS_stream_table[1].socket_type = OS_SocketType_INVALID; - expected = OS_ERR_INCORRECT_OBJ_TYPE; - actual = OS_SocketSendTo(UT_OBJID_1, &Buf, 1, &Addr); - UtAssert_True(actual == expected, "OS_SocketSendTo() non-datagram (%ld) == OS_ERR_INCORRECT_OBJ_TYPE", (long)actual); + expected = OS_ERR_INCORRECT_OBJ_TYPE; + actual = OS_SocketSendTo(UT_OBJID_1, &Buf, 1, &Addr); + UtAssert_True(actual == expected, "OS_SocketSendTo() non-datagram (%ld) == OS_ERR_INCORRECT_OBJ_TYPE", + (long)actual); } - /***************************************************************************** * * Test case for OS_SocketGetIdByName() * *****************************************************************************/ -void Test_OS_SocketGetIdByName (void) +void Test_OS_SocketGetIdByName(void) { /* * Test Case For: * int32 OS_SocketGetIdByName (uint32 *sock_id, const char *sock_name) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; osal_id_t objid; UT_SetForceFail(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); actual = OS_SocketGetIdByName(&objid, "UT"); UtAssert_True(actual == expected, "OS_SocketGetIdByName() (%ld) == OS_SUCCESS", (long)actual); - OSAPI_TEST_OBJID(objid,!=,OS_OBJECT_ID_UNDEFINED); + OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); UT_ClearForceFail(UT_KEY(OS_ObjectIdFindByName)); expected = OS_ERR_NAME_NOT_FOUND; - actual = OS_SocketGetIdByName(&objid, "NF"); - UtAssert_True(actual == expected, "OS_SocketGetIdByName() (%ld) == %ld", - (long)actual, (long)expected); + actual = OS_SocketGetIdByName(&objid, "NF"); + UtAssert_True(actual == expected, "OS_SocketGetIdByName() (%ld) == %ld", (long)actual, (long)expected); expected = OS_INVALID_POINTER; - actual = OS_SocketGetIdByName(NULL, NULL); + actual = OS_SocketGetIdByName(NULL, NULL); UtAssert_True(actual == expected, "Test_OS_SocketGetIdByName(NULL) (%ld) == OS_INVALID_POINTER", (long)actual); - } /***************************************************************************** @@ -372,38 +373,36 @@ void Test_OS_SocketGetIdByName (void) * Test case for OS_SocketGetInfo() * *****************************************************************************/ -void Test_OS_SocketGetInfo (void) +void Test_OS_SocketGetInfo(void) { /* * Test Case For: * int32 OS_SocketGetInfo (uint32 sock_id, OS_socket_prop_t *sock_prop) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; - OS_socket_prop_t prop; - uint32 local_index = 1; - OS_common_record_t utrec; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; + OS_socket_prop_t prop; + uint32 local_index = 1; + OS_common_record_t utrec; OS_common_record_t *rptr = &utrec; memset(&utrec, 0, sizeof(utrec)); - utrec.creator = UT_OBJID_OTHER; + utrec.creator = UT_OBJID_OTHER; utrec.name_entry = "ABC"; UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &local_index, sizeof(local_index), false); UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &rptr, sizeof(rptr), false); actual = OS_SocketGetInfo(UT_OBJID_1, &prop); UtAssert_True(actual == expected, "OS_SocketGetInfo() (%ld) == OS_SUCCESS", (long)actual); - OSAPI_TEST_OBJID(prop.creator,==,UT_OBJID_OTHER); - UtAssert_True(strcmp(prop.name, "ABC") == 0, "prop.name (%s) == ABC", - prop.name); + OSAPI_TEST_OBJID(prop.creator, ==, UT_OBJID_OTHER); + UtAssert_True(strcmp(prop.name, "ABC") == 0, "prop.name (%s) == ABC", prop.name); expected = OS_INVALID_POINTER; - actual = OS_SocketGetInfo(UT_OBJID_1, NULL); + actual = OS_SocketGetInfo(UT_OBJID_1, NULL); UtAssert_True(actual == expected, "OS_SocketGetInfo() (%ld) == OS_INVALID_POINTER", (long)actual); - } -void Test_OS_SocketAddr (void) +void Test_OS_SocketAddr(void) { /* * Test Case For: @@ -413,10 +412,10 @@ void Test_OS_SocketAddr (void) * int32 OS_SocketAddrGetPort(uint16 *PortNum, const OS_SockAddr_t *Addr) */ OS_SockAddr_t Addr; - char Buffer[32]; - uint16 PortNum; - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + char Buffer[32]; + uint16 PortNum; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; /* First verify nominal case for each function */ actual = OS_SocketAddrInit(&Addr, OS_SocketDomain_INVALID); @@ -434,7 +433,6 @@ void Test_OS_SocketAddr (void) actual = OS_SocketAddrGetPort(&PortNum, &Addr); UtAssert_True(actual == expected, "OS_SocketAddrGetPort() (%ld) == OS_SUCCESS", (long)actual); - /* Verify invalid pointer checking in each function */ expected = OS_INVALID_POINTER; @@ -452,7 +450,6 @@ void Test_OS_SocketAddr (void) actual = OS_SocketAddrGetPort(NULL, NULL); UtAssert_True(actual == expected, "OS_SocketAddrGetPort() (%ld) == OS_INVALID_POINTER", (long)actual); - } /* Osapi_Test_Setup @@ -473,11 +470,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} - +void Osapi_Test_Teardown(void) {} /* * Register the test cases to execute with the unit test tool @@ -496,8 +489,3 @@ void UtTest_Setup(void) ADD_TEST(OS_SocketGetInfo); ADD_TEST(OS_CreateSocketName); } - - - - - diff --git a/src/unit-test-coverage/shared/src/coveragetest-task.c b/src/unit-test-coverage/shared/src/coveragetest-task.c index e634eb04f..f1e640c6d 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-task.c +++ b/src/unit-test-coverage/shared/src/coveragetest-task.c @@ -57,33 +57,26 @@ void Test_OS_TaskEntryPoint(void) UT_TestHook_Count = 0; OS_TaskEntryPoint(UT_OBJID_1); - UtAssert_True(UT_TestHook_Count == 0, "UT_TestHook_Count (%lu) == 0", - (unsigned long)UT_TestHook_Count); + UtAssert_True(UT_TestHook_Count == 0, "UT_TestHook_Count (%lu) == 0", (unsigned long)UT_TestHook_Count); CallCount = UT_GetStubCount(UT_KEY(OS_TaskMatch_Impl)); - UtAssert_True(CallCount == 0, "OS_TaskMatch_Impl() count (%lu) == 0", - (unsigned long)CallCount); + UtAssert_True(CallCount == 0, "OS_TaskMatch_Impl() count (%lu) == 0", (unsigned long)CallCount); CallCount = UT_GetStubCount(UT_KEY(OS_TaskRegister_Impl)); - UtAssert_True(CallCount == 0, "OS_TaskRegister_Impl() count (%lu) == 0", - (unsigned long)CallCount); + UtAssert_True(CallCount == 0, "OS_TaskRegister_Impl() count (%lu) == 0", (unsigned long)CallCount); - OS_global_task_table[1].active_id = UT_OBJID_1; + OS_global_task_table[1].active_id = UT_OBJID_1; OS_task_table[1].entry_function_pointer = UT_TestHook; OS_TaskEntryPoint(UT_OBJID_1); - UtAssert_True(UT_TestHook_Count == 1, "UT_TestHook_Count (%lu) == 1", - (unsigned long)UT_TestHook_Count); + UtAssert_True(UT_TestHook_Count == 1, "UT_TestHook_Count (%lu) == 1", (unsigned long)UT_TestHook_Count); CallCount = UT_GetStubCount(UT_KEY(OS_TaskMatch_Impl)); - UtAssert_True(CallCount == 1, "OS_TaskMatch_Impl() count (%lu) == 1", - (unsigned long)CallCount); + UtAssert_True(CallCount == 1, "OS_TaskMatch_Impl() count (%lu) == 1", (unsigned long)CallCount); CallCount = UT_GetStubCount(UT_KEY(OS_TaskRegister_Impl)); - UtAssert_True(CallCount == 1, "OS_TaskRegister_Impl() count (%lu) == 1", - (unsigned long)CallCount); + UtAssert_True(CallCount == 1, "OS_TaskRegister_Impl() count (%lu) == 1", (unsigned long)CallCount); - OS_global_task_table[1].active_id = OS_OBJECT_ID_UNDEFINED; + OS_global_task_table[1].active_id = OS_OBJECT_ID_UNDEFINED; OS_task_table[1].entry_function_pointer = NULL; - } void Test_OS_TaskAPI_Init(void) @@ -93,7 +86,7 @@ void Test_OS_TaskAPI_Init(void) * int32 OS_TaskAPI_Init(void) */ int32 expected = OS_SUCCESS; - int32 actual = OS_TaskAPI_Init(); + int32 actual = OS_TaskAPI_Init(); UtAssert_True(actual == expected, "OS_TaskAPI_Init() (%ld) == OS_SUCCESS", (long)actual); } @@ -111,18 +104,19 @@ void Test_OS_TaskCreate(void) * int32 OS_TaskCreate (uint32 *task_id, const char *task_name, osal_task_entry function_pointer, * uint32 *stack_pointer, uint32 stack_size, uint32 priority, uint32 flags) */ - int32 expected = OS_SUCCESS; + int32 expected = OS_SUCCESS; osal_id_t objid; - int32 actual = OS_TaskCreate(&objid, "UT", UT_TestHook, NULL, 128, 0, 0); + int32 actual = OS_TaskCreate(&objid, "UT", UT_TestHook, NULL, 128, 0, 0); UtAssert_True(actual == expected, "OS_TaskCreate() (%ld) == OS_SUCCESS", (long)actual); - OSAPI_TEST_OBJID(objid,!=,OS_OBJECT_ID_UNDEFINED); + OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); - OSAPI_TEST_FUNCTION_RC(OS_TaskCreate(NULL, NULL, NULL, NULL, 0, 0,0), OS_INVALID_POINTER); + OSAPI_TEST_FUNCTION_RC(OS_TaskCreate(NULL, NULL, NULL, NULL, 0, 0, 0), OS_INVALID_POINTER); OSAPI_TEST_FUNCTION_RC(OS_TaskCreate(&objid, "UT", UT_TestHook, NULL, 0, 0, 0), OS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_TaskCreate(&objid, "UT", UT_TestHook, NULL, 128, 10 + OS_MAX_TASK_PRIORITY,0), OS_ERR_INVALID_PRIORITY); + OSAPI_TEST_FUNCTION_RC(OS_TaskCreate(&objid, "UT", UT_TestHook, NULL, 128, 10 + OS_MAX_TASK_PRIORITY, 0), + OS_ERR_INVALID_PRIORITY); UT_SetForceFail(UT_KEY(OCS_strlen), 10 + OS_MAX_API_NAME); - OSAPI_TEST_FUNCTION_RC(OS_TaskCreate(&objid, "UT", UT_TestHook, NULL, 128, 0,0), OS_ERR_NAME_TOO_LONG); + OSAPI_TEST_FUNCTION_RC(OS_TaskCreate(&objid, "UT", UT_TestHook, NULL, 128, 0, 0), OS_ERR_NAME_TOO_LONG); } void Test_OS_TaskDelete(void) @@ -132,20 +126,18 @@ void Test_OS_TaskDelete(void) * int32 OS_TaskDelete (uint32 task_id) */ int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 actual = ~OS_SUCCESS; - UT_TestHook_Count = 0; + UT_TestHook_Count = 0; OS_task_table[1].delete_hook_pointer = UT_TestHook; - actual = OS_TaskDelete(UT_OBJID_1); + actual = OS_TaskDelete(UT_OBJID_1); UtAssert_True(actual == expected, "OS_TaskDelete() (%ld) == OS_SUCCESS", (long)actual); - UtAssert_True(UT_TestHook_Count == 1, "UT_TestHook_Count (%lu) == 1", - (unsigned long)UT_TestHook_Count); + UtAssert_True(UT_TestHook_Count == 1, "UT_TestHook_Count (%lu) == 1", (unsigned long)UT_TestHook_Count); UT_SetForceFail(UT_KEY(OS_TaskDelete_Impl), OS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_TaskDelete(UT_OBJID_1), OS_ERROR); - UtAssert_True(UT_TestHook_Count == 1, "UT_TestHook_Count (%lu) == 1", - (unsigned long)UT_TestHook_Count); + UtAssert_True(UT_TestHook_Count == 1, "UT_TestHook_Count (%lu) == 1", (unsigned long)UT_TestHook_Count); OS_task_table[1].delete_hook_pointer = NULL; } @@ -156,8 +148,8 @@ void Test_OS_TaskExit(void) * Test Case For: * void OS_TaskExit() */ - uint32 local_index = 0; - OS_common_record_t utrec; + uint32 local_index = 0; + OS_common_record_t utrec; OS_common_record_t *rptr = &utrec; memset(&utrec, 0, sizeof(utrec)); @@ -177,7 +169,7 @@ void Test_OS_TaskDelay(void) * int32 OS_TaskDelay(uint32 millisecond) */ int32 expected = OS_SUCCESS; - int32 actual = OS_TaskDelay(1); + int32 actual = OS_TaskDelay(1); UtAssert_True(actual == expected, "OS_TaskDelay() (%ld) == OS_SUCCESS", (long)actual); } @@ -188,7 +180,7 @@ void Test_OS_TaskSetPriority(void) * int32 OS_TaskSetPriority (uint32 task_id, uint32 new_priority) */ int32 expected = OS_SUCCESS; - int32 actual = OS_TaskSetPriority(UT_OBJID_1, 1); + int32 actual = OS_TaskSetPriority(UT_OBJID_1, 1); UtAssert_True(actual == expected, "OS_TaskSetPriority() (%ld) == OS_SUCCESS", (long)actual); @@ -201,7 +193,7 @@ void Test_OS_TaskRegister(void) * int32 OS_TaskRegister (void) */ int32 expected = OS_SUCCESS; - int32 actual = OS_TaskRegister(); + int32 actual = OS_TaskRegister(); UtAssert_True(actual == expected, "OS_TaskRegister() (%ld) == OS_SUCCESS", (long)actual); } @@ -212,16 +204,16 @@ void Test_OS_TaskGetId(void) * uint32 OS_TaskGetId (void) */ UT_idbuf_t idbuf; - osal_id_t objid; + osal_id_t objid; idbuf.val = 5555; UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), idbuf.val); objid = OS_TaskGetId(); - OSAPI_TEST_OBJID(objid,==,idbuf.id); + OSAPI_TEST_OBJID(objid, ==, idbuf.id); UT_SetForceFail(UT_KEY(OS_ObjectIdGetById), OS_ERROR); objid = OS_TaskGetId(); - OSAPI_TEST_OBJID(objid,==,OS_OBJECT_ID_UNDEFINED); + OSAPI_TEST_OBJID(objid, ==, OS_OBJECT_ID_UNDEFINED); } void Test_OS_TaskGetIdByName(void) @@ -230,20 +222,19 @@ void Test_OS_TaskGetIdByName(void) * Test Case For: * int32 OS_TaskGetIdByName (uint32 *task_id, const char *task_name) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; - osal_id_t objid = OS_OBJECT_ID_UNDEFINED; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; + osal_id_t objid = OS_OBJECT_ID_UNDEFINED; UT_SetForceFail(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); actual = OS_TaskGetIdByName(&objid, "UT"); UtAssert_True(actual == expected, "OS_TaskGetIdByName() (%ld) == OS_SUCCESS", (long)actual); - OSAPI_TEST_OBJID(objid,!=,OS_OBJECT_ID_UNDEFINED); + OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); UT_ClearForceFail(UT_KEY(OS_ObjectIdFindByName)); expected = OS_ERR_NAME_NOT_FOUND; - actual = OS_TaskGetIdByName(&objid, "NF"); - UtAssert_True(actual == expected, "OS_TaskGetIdByName() (%ld) == %ld", - (long)actual, (long)expected); + actual = OS_TaskGetIdByName(&objid, "NF"); + UtAssert_True(actual == expected, "OS_TaskGetIdByName() (%ld) == %ld", (long)actual, (long)expected); OSAPI_TEST_FUNCTION_RC(OS_TaskGetIdByName(NULL, NULL), OS_INVALID_POINTER); } @@ -254,33 +245,31 @@ void Test_OS_TaskGetInfo(void) * Test Case For: * int32 OS_TaskGetInfo (uint32 task_id, OS_task_prop_t *task_prop) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; - OS_task_prop_t task_prop; - uint32 local_index = 1; - OS_common_record_t utrec; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; + OS_task_prop_t task_prop; + uint32 local_index = 1; + OS_common_record_t utrec; OS_common_record_t *rptr = &utrec; memset(&utrec, 0, sizeof(utrec)); - utrec.creator = UT_OBJID_OTHER; - utrec.name_entry = "ABC"; + utrec.creator = UT_OBJID_OTHER; + utrec.name_entry = "ABC"; OS_task_table[1].stack_size = 222; - OS_task_table[1].priority = 333; + OS_task_table[1].priority = 333; UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &local_index, sizeof(local_index), false); UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &rptr, sizeof(rptr), false); actual = OS_TaskGetInfo(UT_OBJID_1, &task_prop); UtAssert_True(actual == expected, "OS_TaskGetInfo() (%ld) == OS_SUCCESS", (long)actual); OSAPI_TEST_OBJID(task_prop.creator, ==, UT_OBJID_OTHER); - UtAssert_True(strcmp(task_prop.name, "ABC") == 0, "task_prop.name (%s) == ABC", - task_prop.name); + UtAssert_True(strcmp(task_prop.name, "ABC") == 0, "task_prop.name (%s) == ABC", task_prop.name); UtAssert_True(task_prop.stack_size == 222, "task_prop.stack_size (%lu) == 222", - (unsigned long)task_prop.stack_size); - UtAssert_True(task_prop.priority == 333, "task_prop.priority (%lu) == 333", - (unsigned long)task_prop.priority); + (unsigned long)task_prop.stack_size); + UtAssert_True(task_prop.priority == 333, "task_prop.priority (%lu) == 333", (unsigned long)task_prop.priority); OS_task_table[1].stack_size = 0; - OS_task_table[1].priority = 0; + OS_task_table[1].priority = 0; OSAPI_TEST_FUNCTION_RC(OS_TaskGetInfo(OS_OBJECT_ID_UNDEFINED, NULL), OS_INVALID_POINTER); } @@ -292,14 +281,14 @@ void Test_OS_TaskInstallDeleteHandler(void) * int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer) */ int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 actual = ~OS_SUCCESS; UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), 1); actual = OS_TaskInstallDeleteHandler(UT_TestHook); UtAssert_True(actual == expected, "OS_TaskInstallDeleteHandler() (%ld) == OS_SUCCESS", (long)actual); - UtAssert_True(OS_task_table[1].delete_hook_pointer == UT_TestHook, "OS_task_table[1].delete_hook_pointer (%lx) == %lx", - (unsigned long)OS_task_table[1].delete_hook_pointer, - (unsigned long)UT_TestHook); + UtAssert_True(OS_task_table[1].delete_hook_pointer == UT_TestHook, + "OS_task_table[1].delete_hook_pointer (%lx) == %lx", + (unsigned long)OS_task_table[1].delete_hook_pointer, (unsigned long)UT_TestHook); OS_task_table[1].delete_hook_pointer = NULL; } @@ -311,8 +300,8 @@ void Test_OS_TaskFindIdBySystemData(void) * int32 OS_TaskFindIdBySystemData(uint32 *task_id, const void *sysdata, size_t sysdata_size) */ - int32 expected; - int32 actual; + int32 expected; + int32 actual; osal_id_t task_id; /* @@ -322,18 +311,18 @@ void Test_OS_TaskFindIdBySystemData(void) struct { unsigned long v; - void *p; + void * p; } test_sysdata; memset(&test_sysdata, 'x', sizeof(test_sysdata)); expected = OS_SUCCESS; - actual = OS_TaskFindIdBySystemData(&task_id, &test_sysdata, sizeof(test_sysdata)); + actual = OS_TaskFindIdBySystemData(&task_id, &test_sysdata, sizeof(test_sysdata)); UtAssert_True(actual == expected, "OS_TaskFindIdBySystemData() (%ld) == OS_SUCCESS", (long)actual); /* Test parameter validation branches */ expected = OS_INVALID_POINTER; - actual = OS_TaskFindIdBySystemData(NULL, &test_sysdata, sizeof(test_sysdata)); + actual = OS_TaskFindIdBySystemData(NULL, &test_sysdata, sizeof(test_sysdata)); UtAssert_True(actual == expected, "OS_TaskFindIdBySystemData() (%ld) == OS_INVALID_POINTER", (long)actual); UT_SetForceFail(UT_KEY(OS_TaskValidateSystemData_Impl), expected); @@ -349,7 +338,6 @@ void Test_OS_TaskFindIdBySystemData(void) UT_ClearForceFail(UT_KEY(OS_ObjectIdGetBySearch)); } - /* Osapi_Test_Setup * * Purpose: @@ -366,11 +354,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} - +void Osapi_Test_Teardown(void) {} /* * Register the test cases to execute with the unit test tool @@ -391,8 +375,3 @@ void UtTest_Setup(void) ADD_TEST(OS_TaskInstallDeleteHandler); ADD_TEST(OS_TaskFindIdBySystemData); } - - - - - diff --git a/src/unit-test-coverage/shared/src/coveragetest-time.c b/src/unit-test-coverage/shared/src/coveragetest-time.c index 11d1a2888..d62a28fb1 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-time.c +++ b/src/unit-test-coverage/shared/src/coveragetest-time.c @@ -31,7 +31,7 @@ #include -static uint32 UT_TimerCount = 0; +static uint32 UT_TimerCount = 0; static uint32 UT_TimerArgCount = 0; void UT_TimerCallback(osal_id_t timer_id) @@ -56,7 +56,7 @@ void Test_OS_TimerCbAPI_Init(void) * int32 OS_TimerCbAPI_Init(void) */ int32 expected = OS_SUCCESS; - int32 actual = OS_TimerCbAPI_Init(); + int32 actual = OS_TimerCbAPI_Init(); UtAssert_True(actual == expected, "OS_TimerCbAPI_Init() (%ld) == OS_SUCCESS", (long)actual); } @@ -65,11 +65,12 @@ void Test_OS_TimerAdd(void) { /* * Test Case For: - * int32 OS_TimerAdd(uint32 *timer_id, const char *timer_name, uint32 timebase_ref_id, OS_ArgCallback_t callback_ptr, void *callback_arg) + * int32 OS_TimerAdd(uint32 *timer_id, const char *timer_name, uint32 timebase_ref_id, OS_ArgCallback_t + * callback_ptr, void *callback_arg) */ - int32 expected = OS_SUCCESS; - osal_id_t objid = OS_OBJECT_ID_UNDEFINED; - char arg = 'a'; + int32 expected = OS_SUCCESS; + osal_id_t objid = OS_OBJECT_ID_UNDEFINED; + char arg = 'a'; int32 actual = OS_TimerAdd(&objid, "UT", UT_OBJID_1, UT_TimerArgCallback, &arg); @@ -77,35 +78,34 @@ void Test_OS_TimerAdd(void) /* test error cases */ expected = OS_INVALID_POINTER; - actual = OS_TimerAdd(NULL, "UT", UT_OBJID_1, UT_TimerArgCallback, &arg); + actual = OS_TimerAdd(NULL, "UT", UT_OBJID_1, UT_TimerArgCallback, &arg); UtAssert_True(actual == expected, "OS_TimerAdd() (%ld) == OS_INVALID_POINTER", (long)actual); UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_MAX_API_NAME); expected = OS_ERR_NAME_TOO_LONG; - actual = OS_TimerAdd(&objid, "UT", UT_OBJID_1, UT_TimerArgCallback, &arg); + actual = OS_TimerAdd(&objid, "UT", UT_OBJID_1, UT_TimerArgCallback, &arg); UtAssert_True(actual == expected, "OS_TimerAdd() (%ld) == OS_ERR_NAME_TOO_LONG", (long)actual); UT_ClearForceFail(UT_KEY(OCS_strlen)); expected = OS_TIMER_ERR_INVALID_ARGS; - actual = OS_TimerAdd(&objid, "UT", UT_OBJID_1, NULL, &arg); + actual = OS_TimerAdd(&objid, "UT", UT_OBJID_1, NULL, &arg); UtAssert_True(actual == expected, "OS_TimerAdd() (%ld) == OS_TIMER_ERR_INVALID_ARGS", (long)actual); UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); expected = OS_ERR_INCORRECT_OBJ_STATE; - actual = OS_TimerAdd(&objid, "UT", UT_OBJID_1, UT_TimerArgCallback, &arg); + actual = OS_TimerAdd(&objid, "UT", UT_OBJID_1, UT_TimerArgCallback, &arg); UtAssert_True(actual == expected, "OS_TimerAdd() (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); UT_ClearForceFail(UT_KEY(OS_TaskGetId_Impl)); UT_SetForceFail(UT_KEY(OS_ObjectIdGetById), OS_ERROR); expected = OS_ERROR; - actual = OS_TimerAdd(&objid, "UT", UT_OBJID_1, UT_TimerArgCallback, &arg); + actual = OS_TimerAdd(&objid, "UT", UT_OBJID_1, UT_TimerArgCallback, &arg); UtAssert_True(actual == expected, "OS_TimerAdd() (%ld) == OS_ERROR", (long)actual); UT_ClearForceFail(UT_KEY(OS_ObjectIdGetById)); - UT_SetForceFail(UT_KEY(OS_ObjectIdAllocateNew), OS_ERROR); expected = OS_ERROR; - actual = OS_TimerAdd(&objid, "UT", UT_OBJID_1, UT_TimerArgCallback, &arg); + actual = OS_TimerAdd(&objid, "UT", UT_OBJID_1, UT_TimerArgCallback, &arg); UtAssert_True(actual == expected, "OS_TimerAdd() (%ld) == OS_ERROR", (long)actual); UT_ClearForceFail(UT_KEY(OS_ObjectIdAllocateNew)); } @@ -114,56 +114,48 @@ void Test_OS_TimerCreate(void) { /* * Test Case For: - * int32 OS_TimerCreate(uint32 *timer_id, const char *timer_name, uint32 *accuracy, OS_TimerCallback_t callback_ptr) + * int32 OS_TimerCreate(uint32 *timer_id, const char *timer_name, uint32 *accuracy, OS_TimerCallback_t callback_ptr) */ - int32 expected = OS_SUCCESS; - osal_id_t objid = OS_OBJECT_ID_UNDEFINED; - uint32 local_id = 0xFFFFFFFF; - uint32 accuracy = 0xFFFFFFFF; - int32 actual = OS_TimerCreate(&objid, "UT", &accuracy, UT_TimerCallback); + int32 expected = OS_SUCCESS; + osal_id_t objid = OS_OBJECT_ID_UNDEFINED; + uint32 local_id = 0xFFFFFFFF; + uint32 accuracy = 0xFFFFFFFF; + int32 actual = OS_TimerCreate(&objid, "UT", &accuracy, UT_TimerCallback); UtAssert_True(actual == expected, "OS_TimerCreate() (%ld) == OS_SUCCESS", (long)actual); OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_TIMECB, objid, &local_id); - UtAssert_True(OS_timecb_table[local_id].callback_ptr != NULL, - "OS_timecb_table[%lu].callback_ptr (%lx) != NULL", - (unsigned long)local_id, - (unsigned long)OS_timecb_table[local_id].callback_ptr); + UtAssert_True(OS_timecb_table[local_id].callback_ptr != NULL, "OS_timecb_table[%lu].callback_ptr (%lx) != NULL", + (unsigned long)local_id, (unsigned long)OS_timecb_table[local_id].callback_ptr); UT_TimerCount = 0; OS_timecb_table[local_id].callback_ptr(objid, OS_timecb_table[local_id].callback_arg); - UtAssert_True(UT_TimerCount == 1, - "UT_TimerCount (%lu) == 1", - (unsigned long)UT_TimerCount); + UtAssert_True(UT_TimerCount == 1, "UT_TimerCount (%lu) == 1", (unsigned long)UT_TimerCount); /* additional cases to exercise error paths */ expected = OS_INVALID_POINTER; - actual = OS_TimerCreate(&objid, NULL, NULL, NULL); + actual = OS_TimerCreate(&objid, NULL, NULL, NULL); UtAssert_True(actual == expected, "OS_TimerSet() (%ld) == OS_INVALID_POINTER", (long)actual); expected = OS_TIMER_ERR_INVALID_ARGS; - actual = OS_TimerCreate(&objid, "UT", &accuracy, NULL); + actual = OS_TimerCreate(&objid, "UT", &accuracy, NULL); UtAssert_True(actual == expected, "OS_TimerSet() (%ld) == OS_TIMER_ERR_INVALID_ARGS", (long)actual); - UT_SetForceFail(UT_KEY(OS_TimeBaseCreate), OS_ERROR); expected = OS_ERROR; - actual = OS_TimerCreate(&objid, "UT", &accuracy, UT_TimerCallback); + actual = OS_TimerCreate(&objid, "UT", &accuracy, UT_TimerCallback); UtAssert_True(actual == expected, "OS_TimerCreate() (%ld) == OS_ERROR", (long)actual); UT_ClearForceFail(UT_KEY(OS_TimeBaseCreate)); UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_MAX_API_NAME); expected = OS_ERR_NAME_TOO_LONG; - actual = OS_TimerCreate(&objid, "UT", &accuracy, UT_TimerCallback); + actual = OS_TimerCreate(&objid, "UT", &accuracy, UT_TimerCallback); UtAssert_True(actual == expected, "OS_TimerCreate() (%ld) == OS_ERR_NAME_TOO_LONG", (long)actual); UT_ClearForceFail(UT_KEY(OCS_strlen)); - - } - void Test_OS_TimerSet(void) { /* @@ -171,32 +163,31 @@ void Test_OS_TimerSet(void) * int32 OS_TimerSet(uint32 timer_id, uint32 start_time, uint32 interval_time) */ int32 expected = OS_ERROR; - int32 actual = OS_TimerSet(UT_OBJID_1, 0, 0); + int32 actual = OS_TimerSet(UT_OBJID_1, 0, 0); UtAssert_True(actual == expected, "OS_TimerSet() (%ld) == OS_ERROR", (long)actual); expected = OS_SUCCESS; - actual = OS_TimerSet(UT_OBJID_1, 0, 1); + actual = OS_TimerSet(UT_OBJID_1, 0, 1); UtAssert_True(actual == expected, "OS_TimerSet() (%ld) == OS_SUCCESS", (long)actual); - OS_timecb_table[2].timebase_ref = 0; - OS_timecb_table[2].flags = TIMECB_FLAG_DEDICATED_TIMEBASE; + OS_timecb_table[2].timebase_ref = 0; + OS_timecb_table[2].flags = TIMECB_FLAG_DEDICATED_TIMEBASE; OS_global_timebase_table[0].active_id = UT_OBJID_2; - actual = OS_TimerSet(UT_OBJID_2, 0, 1); + actual = OS_TimerSet(UT_OBJID_2, 0, 1); UtAssert_True(actual == expected, "OS_TimerSet() (%ld) == OS_SUCCESS", (long)actual); memset(OS_timecb_table, 0, sizeof(OS_timecb_table)); expected = OS_TIMER_ERR_INVALID_ARGS; - actual = OS_TimerSet(UT_OBJID_2, UINT32_MAX, UINT32_MAX); + actual = OS_TimerSet(UT_OBJID_2, UINT32_MAX, UINT32_MAX); UtAssert_True(actual == expected, "OS_TimerSet() (%ld) == OS_TIMER_ERR_INVALID_ARGS", (long)actual); UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); expected = OS_ERR_INCORRECT_OBJ_STATE; - actual = OS_TimerSet(UT_OBJID_2, 0, 1); + actual = OS_TimerSet(UT_OBJID_2, 0, 1); UtAssert_True(actual == expected, "OS_TimerSet() (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); UT_ClearForceFail(UT_KEY(OS_TaskGetId_Impl)); } - void Test_OS_TimerDelete(void) { /* @@ -204,28 +195,28 @@ void Test_OS_TimerDelete(void) * int32 OS_TimerDelete(uint32 timer_id) */ int32 expected = OS_SUCCESS; - int32 actual = OS_TimerDelete(UT_OBJID_1); + int32 actual = OS_TimerDelete(UT_OBJID_1); UtAssert_True(actual == expected, "OS_TimerDelete() (%ld) == OS_SUCCESS", (long)actual); OS_timecb_table[1].timebase_ref = 0; OS_timecb_table[2].timebase_ref = 0; - OS_timecb_table[2].next_ref = 1; - OS_timecb_table[1].next_ref = 1; - OS_timebase_table[0].first_cb = UT_OBJID_2; - actual = OS_TimerDelete(UT_OBJID_2); + OS_timecb_table[2].next_ref = 1; + OS_timecb_table[1].next_ref = 1; + OS_timebase_table[0].first_cb = UT_OBJID_2; + actual = OS_TimerDelete(UT_OBJID_2); UtAssert_True(actual == expected, "OS_TimerDelete() (%ld) == OS_SUCCESS", (long)actual); OS_timebase_table[0].first_cb = UT_OBJID_1; - actual = OS_TimerDelete(UT_OBJID_1); + actual = OS_TimerDelete(UT_OBJID_1); UtAssert_True(actual == expected, "OS_TimerDelete() (%ld) == OS_SUCCESS", (long)actual); /* verify deletion of the dedicated timebase objects * these are implicitly created as part of timer creation for API compatibility */ - OS_TimeBaseCreate(&OS_global_timebase_table[0].active_id,"ut",NULL); - OS_timecb_table[1].flags = TIMECB_FLAG_DEDICATED_TIMEBASE; + OS_TimeBaseCreate(&OS_global_timebase_table[0].active_id, "ut", NULL); + OS_timecb_table[1].flags = TIMECB_FLAG_DEDICATED_TIMEBASE; OS_timecb_table[1].timebase_ref = 0; - actual = OS_TimerDelete(UT_OBJID_1); + actual = OS_TimerDelete(UT_OBJID_1); UtAssert_True(actual == expected, "OS_TimerDelete() (%ld) == OS_SUCCESS", (long)actual); UtAssert_True(UT_GetStubCount(UT_KEY(OS_TimeBaseDelete)) == 1, "OS_TimerDelete() invoked OS_TimeBaseDelete()"); @@ -234,21 +225,19 @@ void Test_OS_TimerDelete(void) UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); expected = OS_ERR_INCORRECT_OBJ_STATE; - actual = OS_TimerDelete(UT_OBJID_2); + actual = OS_TimerDelete(UT_OBJID_2); UtAssert_True(actual == expected, "OS_TimerDelete() (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); UT_ClearForceFail(UT_KEY(OS_TaskGetId_Impl)); - } - void Test_OS_TimerGetIdByName(void) { /* * Test Case For: * int32 OS_TimerGetIdByName (uint32 *timer_id, const char *timer_name) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; osal_id_t objid; UT_SetForceFail(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); @@ -257,71 +246,60 @@ void Test_OS_TimerGetIdByName(void) UT_ClearForceFail(UT_KEY(OS_ObjectIdFindByName)); expected = OS_ERR_NAME_NOT_FOUND; - actual = OS_TimerGetIdByName(&objid, "NF"); - UtAssert_True(actual == expected, "OS_TimerGetIdByName() (%ld) == %ld", - (long)actual, (long)expected); + actual = OS_TimerGetIdByName(&objid, "NF"); + UtAssert_True(actual == expected, "OS_TimerGetIdByName() (%ld) == %ld", (long)actual, (long)expected); expected = OS_INVALID_POINTER; - actual = OS_TimerGetIdByName(NULL, "NF"); - UtAssert_True(actual == expected, "OS_TimerGetIdByName() (%ld) == %ld", - (long)actual, (long)expected); + actual = OS_TimerGetIdByName(NULL, "NF"); + UtAssert_True(actual == expected, "OS_TimerGetIdByName() (%ld) == %ld", (long)actual, (long)expected); UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); expected = OS_ERR_INCORRECT_OBJ_STATE; - actual = OS_TimerGetIdByName(&objid, "NF"); - UtAssert_True(actual == expected, "OS_TimerGetIdByName() (%ld) == %ld", - (long)actual, (long)expected); + actual = OS_TimerGetIdByName(&objid, "NF"); + UtAssert_True(actual == expected, "OS_TimerGetIdByName() (%ld) == %ld", (long)actual, (long)expected); UT_ClearForceFail(UT_KEY(OS_TaskGetId_Impl)); - } - void Test_OS_TimerGetInfo(void) { /* * Test Case For: * int32 OS_TimerGetInfo (uint32 timer_id, OS_timer_prop_t *timer_prop) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; - OS_timer_prop_t timer_prop; - uint32 local_index = 1; - OS_common_record_t utrec; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; + OS_timer_prop_t timer_prop; + uint32 local_index = 1; + OS_common_record_t utrec; OS_common_record_t *rptr = &utrec; memset(&utrec, 0, sizeof(utrec)); - utrec.creator = UT_OBJID_OTHER; - utrec.name_entry = "ABC"; - OS_timecb_table[1].interval_time = 2222; - OS_timecb_table[1].timebase_ref = 0; + utrec.creator = UT_OBJID_OTHER; + utrec.name_entry = "ABC"; + OS_timecb_table[1].interval_time = 2222; + OS_timecb_table[1].timebase_ref = 0; OS_timebase_table[0].accuracy_usec = 3333; UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &local_index, sizeof(local_index), false); UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &rptr, sizeof(rptr), false); actual = OS_TimerGetInfo(UT_OBJID_1, &timer_prop); UtAssert_True(actual == expected, "OS_TimerGetInfo() (%ld) == OS_SUCCESS", (long)actual); - UtAssert_True(strcmp(timer_prop.name, "ABC") == 0, "timer_prop.name (%s) == ABC", - timer_prop.name); - UtAssert_True(timer_prop.interval_time == 2222, - "timer_prop.interval_time (%lu) == 2222", - (unsigned long)timer_prop.interval_time); - UtAssert_True(timer_prop.accuracy == 3333, - "timer_prop.accuracy (%lu) == 3333", - (unsigned long)timer_prop.accuracy); + UtAssert_True(strcmp(timer_prop.name, "ABC") == 0, "timer_prop.name (%s) == ABC", timer_prop.name); + UtAssert_True(timer_prop.interval_time == 2222, "timer_prop.interval_time (%lu) == 2222", + (unsigned long)timer_prop.interval_time); + UtAssert_True(timer_prop.accuracy == 3333, "timer_prop.accuracy (%lu) == 3333", (unsigned long)timer_prop.accuracy); expected = OS_INVALID_POINTER; - actual = OS_TimerGetInfo(UT_OBJID_1, NULL); + actual = OS_TimerGetInfo(UT_OBJID_1, NULL); UtAssert_True(actual == expected, "OS_TimerGetInfo() (%ld) == OS_INVALID_POINTER", (long)actual); UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); expected = OS_ERR_INCORRECT_OBJ_STATE; - actual = OS_TimerGetInfo(UT_OBJID_1, &timer_prop); + actual = OS_TimerGetInfo(UT_OBJID_1, &timer_prop); UtAssert_True(actual == expected, "OS_TimerGetInfo() (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); UT_ClearForceFail(UT_KEY(OS_TaskGetId_Impl)); - } - /* Osapi_Test_Setup * * Purpose: @@ -338,10 +316,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* * Register the test cases to execute with the unit test tool @@ -356,8 +331,3 @@ void UtTest_Setup(void) ADD_TEST(OS_TimerGetIdByName); ADD_TEST(OS_TimerGetInfo); } - - - - - diff --git a/src/unit-test-coverage/shared/src/coveragetest-timebase.c b/src/unit-test-coverage/shared/src/coveragetest-timebase.c index 995087a75..9484cb9c0 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-timebase.c +++ b/src/unit-test-coverage/shared/src/coveragetest-timebase.c @@ -34,9 +34,9 @@ #include #include -static uint32 TimerSyncCount = 0; +static uint32 TimerSyncCount = 0; static uint32 TimerSyncRetVal = 0; -static uint32 TimeCB = 0; +static uint32 TimeCB = 0; static uint32 UT_TimerSync(uint32 timer_id) { @@ -73,7 +73,7 @@ void Test_OS_TimeBaseAPI_Init(void) * int32 OS_TimeBaseAPI_Init(void) */ int32 expected = OS_SUCCESS; - int32 actual = OS_TimeBaseAPI_Init(); + int32 actual = OS_TimeBaseAPI_Init(); UtAssert_True(actual == expected, "OS_TimeBaseAPI_Init() (%ld) == OS_SUCCESS", (long)actual); } @@ -84,9 +84,9 @@ void Test_OS_TimeBaseCreate(void) * Test Case For: * int32 OS_TimeBaseCreate(uint32 *timer_id, const char *timebase_name, OS_TimerSync_t external_sync) */ - int32 expected = OS_SUCCESS; + int32 expected = OS_SUCCESS; osal_id_t objid; - int32 actual; + int32 actual; actual = OS_TimeBaseCreate(&objid, "UT1", UT_TimerSync); UtAssert_True(actual == expected, "OS_TimeBaseCreate() (%ld) == OS_SUCCESS", (long)actual); @@ -96,18 +96,18 @@ void Test_OS_TimeBaseCreate(void) /* test error paths */ expected = OS_INVALID_POINTER; - actual = OS_TimeBaseCreate(NULL, NULL, NULL); + actual = OS_TimeBaseCreate(NULL, NULL, NULL); UtAssert_True(actual == expected, "OS_TimeBaseCreate() (%ld) == OS_INVALID_POINTER", (long)actual); UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_MAX_API_NAME); expected = OS_ERR_NAME_TOO_LONG; - actual = OS_TimeBaseCreate(&objid, "UT", UT_TimerSync); + actual = OS_TimeBaseCreate(&objid, "UT", UT_TimerSync); UtAssert_True(actual == expected, "OS_TimeBaseCreate() (%ld) == OS_ERR_NAME_TOO_LONG", (long)actual); UT_ClearForceFail(UT_KEY(OCS_strlen)); UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); expected = OS_ERR_INCORRECT_OBJ_STATE; - actual = OS_TimeBaseCreate(&objid, "UT", UT_TimerSync); + actual = OS_TimeBaseCreate(&objid, "UT", UT_TimerSync); UtAssert_True(actual == expected, "OS_TimeBaseCreate() (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); } @@ -118,21 +118,20 @@ void Test_OS_TimeBaseSet(void) * int32 OS_TimeBaseSet(uint32 timer_id, uint32 start_time, uint32 interval_time) */ int32 expected = OS_SUCCESS; - int32 actual = OS_TimeBaseSet(UT_OBJID_1, 1000, 1000); + int32 actual = OS_TimeBaseSet(UT_OBJID_1, 1000, 1000); UtAssert_True(actual == expected, "OS_TimeBaseSet() (%ld) == OS_SUCCESS", (long)actual); /* test error paths: overflow on input */ expected = OS_TIMER_ERR_INVALID_ARGS; - actual = OS_TimeBaseSet(UT_OBJID_1, UINT32_MAX, UINT32_MAX); + actual = OS_TimeBaseSet(UT_OBJID_1, UINT32_MAX, UINT32_MAX); UtAssert_True(actual == expected, "OS_TimeBaseSet() (%ld) == OS_TIMER_ERR_INVALID_ARGS", (long)actual); /* test error paths */ UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); expected = OS_ERR_INCORRECT_OBJ_STATE; - actual = OS_TimeBaseSet(UT_OBJID_1, 1000, 1000); + actual = OS_TimeBaseSet(UT_OBJID_1, 1000, 1000); UtAssert_True(actual == expected, "OS_TimeBaseSet() (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); - } void Test_OS_TimeBaseDelete(void) @@ -142,14 +141,14 @@ void Test_OS_TimeBaseDelete(void) * int32 OS_TimeBaseDelete(uint32 timer_id) */ int32 expected = OS_SUCCESS; - int32 actual = OS_TimeBaseDelete(UT_OBJID_1); + int32 actual = OS_TimeBaseDelete(UT_OBJID_1); UtAssert_True(actual == expected, "OS_TimeBaseDelete() (%ld) == OS_SUCCESS", (long)actual); /* test error paths */ UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); expected = OS_ERR_INCORRECT_OBJ_STATE; - actual = OS_TimeBaseDelete(UT_OBJID_1); + actual = OS_TimeBaseDelete(UT_OBJID_1); UtAssert_True(actual == expected, "OS_TimeBaseDelete() (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); } @@ -159,30 +158,28 @@ void Test_OS_TimeBaseGetIdByName(void) * Test Case For: * int32 OS_TimeBaseGetIdByName (uint32 *timer_id, const char *timebase_name) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; osal_id_t objid; UT_SetForceFail(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); actual = OS_TimeBaseGetIdByName(&objid, "UT"); UtAssert_True(actual == expected, "OS_TimeBaseGetIdByName() (%ld) == OS_SUCCESS", (long)actual); - OSAPI_TEST_OBJID(objid,!=,OS_OBJECT_ID_UNDEFINED); + OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); UT_ClearForceFail(UT_KEY(OS_ObjectIdFindByName)); expected = OS_ERR_NAME_NOT_FOUND; - actual = OS_TimeBaseGetIdByName(&objid, "NF"); - UtAssert_True(actual == expected, "OS_TimeBaseGetIdByName() (%ld) == %ld", - (long)actual, (long)expected); - + actual = OS_TimeBaseGetIdByName(&objid, "NF"); + UtAssert_True(actual == expected, "OS_TimeBaseGetIdByName() (%ld) == %ld", (long)actual, (long)expected); /* test error paths */ expected = OS_INVALID_POINTER; - actual = OS_TimeBaseGetIdByName(NULL, NULL); + actual = OS_TimeBaseGetIdByName(NULL, NULL); UtAssert_True(actual == expected, "OS_TimeBaseGetIdByName() (%ld) == OS_INVALID_POINTER", (long)actual); UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); expected = OS_ERR_INCORRECT_OBJ_STATE; - actual = OS_TimeBaseGetIdByName(&objid, "NF"); + actual = OS_TimeBaseGetIdByName(&objid, "NF"); UtAssert_True(actual == expected, "OS_TimeBaseGetIdByName() (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); } @@ -192,48 +189,43 @@ void Test_OS_TimeBaseGetInfo(void) * Test Case For: * int32 OS_TimeBaseGetInfo (uint32 timebase_id, OS_timebase_prop_t *timebase_prop) */ - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; - OS_timebase_prop_t timebase_prop; - uint32 local_index = 1; - OS_common_record_t utrec; + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; + OS_timebase_prop_t timebase_prop; + uint32 local_index = 1; + OS_common_record_t utrec; OS_common_record_t *rptr = &utrec; memset(&utrec, 0, sizeof(utrec)); - utrec.creator = UT_OBJID_OTHER; - utrec.name_entry = "ABC"; + utrec.creator = UT_OBJID_OTHER; + utrec.name_entry = "ABC"; OS_timebase_table[1].nominal_interval_time = 2222; - OS_timebase_table[1].freerun_time = 3333; - OS_timebase_table[1].accuracy_usec = 4444; + OS_timebase_table[1].freerun_time = 3333; + OS_timebase_table[1].accuracy_usec = 4444; UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &local_index, sizeof(local_index), false); UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &rptr, sizeof(rptr), false); actual = OS_TimeBaseGetInfo(UT_OBJID_1, &timebase_prop); UtAssert_True(actual == expected, "OS_TimeBaseGetInfo() (%ld) == OS_SUCCESS", (long)actual); - OSAPI_TEST_OBJID(timebase_prop.creator,==,UT_OBJID_OTHER); - UtAssert_True(strcmp(timebase_prop.name, "ABC") == 0, "timebase_prop.name (%s) == ABC", - timebase_prop.name); - UtAssert_True(timebase_prop.nominal_interval_time == 2222, - "timebase_prop.nominal_interval_time (%lu) == 2222", - (unsigned long)timebase_prop.nominal_interval_time); - UtAssert_True(timebase_prop.freerun_time == 3333, - "timebase_prop.freerun_time (%lu) == 3333", - (unsigned long)timebase_prop.freerun_time); - UtAssert_True(timebase_prop.accuracy == 4444, - "timebase_prop.accuracy (%lu) == 4444", - (unsigned long)timebase_prop.accuracy); + OSAPI_TEST_OBJID(timebase_prop.creator, ==, UT_OBJID_OTHER); + UtAssert_True(strcmp(timebase_prop.name, "ABC") == 0, "timebase_prop.name (%s) == ABC", timebase_prop.name); + UtAssert_True(timebase_prop.nominal_interval_time == 2222, "timebase_prop.nominal_interval_time (%lu) == 2222", + (unsigned long)timebase_prop.nominal_interval_time); + UtAssert_True(timebase_prop.freerun_time == 3333, "timebase_prop.freerun_time (%lu) == 3333", + (unsigned long)timebase_prop.freerun_time); + UtAssert_True(timebase_prop.accuracy == 4444, "timebase_prop.accuracy (%lu) == 4444", + (unsigned long)timebase_prop.accuracy); /* test error paths */ expected = OS_INVALID_POINTER; - actual = OS_TimeBaseGetInfo(UT_OBJID_1, NULL); + actual = OS_TimeBaseGetInfo(UT_OBJID_1, NULL); UtAssert_True(actual == expected, "OS_TimeBaseGetInfo() (%ld) == OS_INVALID_POINTER", (long)actual); UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), 1 | (OS_OBJECT_TYPE_OS_TIMEBASE << OS_OBJECT_TYPE_SHIFT)); expected = OS_ERR_INCORRECT_OBJ_STATE; - actual = OS_TimeBaseGetInfo(UT_OBJID_1, &timebase_prop); + actual = OS_TimeBaseGetInfo(UT_OBJID_1, &timebase_prop); UtAssert_True(actual == expected, "OS_TimeBaseGetInfo() (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); - } void Test_OS_TimeBaseGetFreeRun(void) @@ -242,9 +234,9 @@ void Test_OS_TimeBaseGetFreeRun(void) * Test Case For: * int32 OS_TimeBaseGetFreeRun (uint32 timebase_id, uint32 *freerun_val) */ - int32 expected = OS_SUCCESS; - uint32 freerun = 0xFFFFFFFF; - int32 actual = OS_TimeBaseGetFreeRun(UT_OBJID_1, &freerun); + int32 expected = OS_SUCCESS; + uint32 freerun = 0xFFFFFFFF; + int32 actual = OS_TimeBaseGetFreeRun(UT_OBJID_1, &freerun); UtAssert_True(actual == expected, "OS_TimeBaseGetFreeRun() (%ld) == OS_SUCCESS", (long)actual); } @@ -255,41 +247,40 @@ void Test_OS_TimeBase_CallbackThread(void) * Test Case For: * void OS_TimeBase_CallbackThread(uint32 timebase_id) */ - OS_common_record_t fake_record; + OS_common_record_t fake_record; OS_common_record_t *recptr = &fake_record; - osal_id_t idbuf; + osal_id_t idbuf; memset(&fake_record, 0, sizeof(fake_record)); fake_record.active_id = UT_OBJID_2; OS_timebase_table[2].external_sync = UT_TimerSync; - OS_timecb_table[0].wait_time = 2000; - OS_timecb_table[0].callback_ptr = UT_TimeCB; - TimerSyncCount = 0; - TimerSyncRetVal = 0; - TimeCB = 0; - idbuf = UT_OBJID_2; - UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById),&idbuf, sizeof(idbuf), false); - UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById),&recptr, sizeof(recptr), false); + OS_timecb_table[0].wait_time = 2000; + OS_timecb_table[0].callback_ptr = UT_TimeCB; + TimerSyncCount = 0; + TimerSyncRetVal = 0; + TimeCB = 0; + idbuf = UT_OBJID_2; + UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &idbuf, sizeof(idbuf), false); + UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &recptr, sizeof(recptr), false); UT_SetHookFunction(UT_KEY(OS_TimeBaseLock_Impl), ClearObjectsHook, recptr); OS_TimeBase_CallbackThread(UT_OBJID_2); UtAssert_True(TimerSyncCount == 11, "TimerSyncCount (%lu) == 11", (unsigned long)TimerSyncCount); UT_ResetState(UT_KEY(OS_TimeBaseLock_Impl)); - TimerSyncCount = 0; - TimerSyncRetVal = 1000; + TimerSyncCount = 0; + TimerSyncRetVal = 1000; fake_record.active_id = UT_OBJID_2; - idbuf = UT_OBJID_2; - UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById),&idbuf, sizeof(idbuf), false); - UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById),&recptr, sizeof(recptr), false); + idbuf = UT_OBJID_2; + UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &idbuf, sizeof(idbuf), false); + UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &recptr, sizeof(recptr), false); UT_SetHookFunction(UT_KEY(OS_TimeBaseLock_Impl), ClearObjectsHook, recptr); OS_TimeBase_CallbackThread(UT_OBJID_2); /* Check that the TimeCB function was called */ UtAssert_True(TimeCB > 0, "TimeCB (%lu) > 0", (unsigned long)TimeCB); - UT_SetForceFail(UT_KEY(OS_ObjectIdGetById), OS_ERROR); OS_TimeBase_CallbackThread(UT_OBJID_2); } @@ -304,13 +295,13 @@ void Test_OS_Milli2Ticks(void) int ticks; int expected; - msec = 5678; + msec = 5678; OS_SharedGlobalVars.TicksPerSecond = 500; UtAssert_INT32_EQ(OS_Milli2Ticks(msec, &ticks), OS_SUCCESS); UtAssert_INT32_EQ(ticks, 2839); /* Bigger than uint32 but valid case */ - msec = UINT_MAX - 1; + msec = UINT_MAX - 1; expected = (((uint64)msec * OS_SharedGlobalVars.TicksPerSecond) + 999) / 1000; UtAssert_INT32_EQ(OS_Milli2Ticks(msec, &ticks), OS_SUCCESS); UtAssert_INT32_EQ(ticks, expected); @@ -326,8 +317,6 @@ void Test_OS_Milli2Ticks(void) UtAssert_INT32_EQ(ticks, 0); } - - /* Osapi_Test_Setup * * Purpose: @@ -344,11 +333,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} - +void Osapi_Test_Teardown(void) {} /* * Register the test cases to execute with the unit test tool @@ -365,8 +350,3 @@ void UtTest_Setup(void) ADD_TEST(OS_TimeBase_CallbackThread); ADD_TEST(OS_Milli2Ticks); } - - - - - diff --git a/src/unit-test-coverage/shared/src/os-shared-coveragetest.h b/src/unit-test-coverage/shared/src/os-shared-coveragetest.h index f847cdd46..86c23d952 100644 --- a/src/unit-test-coverage/shared/src/os-shared-coveragetest.h +++ b/src/unit-test-coverage/shared/src/os-shared-coveragetest.h @@ -38,13 +38,12 @@ /* * Macro to call a function and check its int32 return code */ -#define OSAPI_TEST_FUNCTION_RC(func,exp) \ -{ \ - int32 rcexp = exp; \ - int32 rcact = func; \ - UtAssert_True(rcact == rcexp, "%s (%ld) == %s (%ld)", \ - #func, (long)rcact, #exp, (long)rcexp); \ -} +#define OSAPI_TEST_FUNCTION_RC(func, exp) \ + { \ + int32 rcexp = exp; \ + int32 rcact = func; \ + UtAssert_True(rcact == rcexp, "%s (%ld) == %s (%ld)", #func, (long)rcact, #exp, (long)rcexp); \ + } /* * A union type allowing the osal_id_t to be manipulated as a uint32. @@ -57,25 +56,23 @@ typedef union uint32 val; } UT_idbuf_t; -#define OSAPI_TEST_OBJID(act,op,exp) \ -{ \ - UT_idbuf_t idexp = { .id = exp }; \ - UT_idbuf_t idact = { .id = act }; \ - UtAssert_True(memcmp(&idexp,&idact,sizeof(osal_id_t)) op 0, \ - "%s (%lu) %s %s (%lu)", \ - #act, (unsigned long)idact.val, #op, \ - #exp, (unsigned long)idexp.val); \ -} +#define OSAPI_TEST_OBJID(act, op, exp) \ + { \ + UT_idbuf_t idexp = {.id = exp}; \ + UT_idbuf_t idact = {.id = act}; \ + UtAssert_True(memcmp(&idexp, &idact, sizeof(osal_id_t)) op 0, "%s (%lu) %s %s (%lu)", #act, \ + (unsigned long)idact.val, #op, #exp, (unsigned long)idexp.val); \ + } /* * Macro to add a test case to the list of tests to execute */ -#define ADD_TEST(test) UtTest_Add((Test_ ## test),Osapi_Test_Setup,Osapi_Test_Teardown, #test) +#define ADD_TEST(test) UtTest_Add((Test_##test), Osapi_Test_Setup, Osapi_Test_Teardown, #test) -#define UT_OBJID_1 ((osal_id_t){1}) -#define UT_OBJID_2 ((osal_id_t){2}) -#define UT_OBJID_OTHER ((osal_id_t){0x12345}) -#define UT_OBJID_MAX ((osal_id_t){0xFFFFFFFF}) +#define UT_OBJID_1 ((osal_id_t) {1}) +#define UT_OBJID_2 ((osal_id_t) {2}) +#define UT_OBJID_OTHER ((osal_id_t) {0x12345}) +#define UT_OBJID_MAX ((osal_id_t) {0xFFFFFFFF}) /* * Setup function prior to every test @@ -87,5 +84,4 @@ void Osapi_Test_Setup(void); */ void Osapi_Test_Teardown(void); -#endif /* INCLUDE_OS_SHARED_COVERAGETEST_H_ */ - +#endif /* INCLUDE_OS_SHARED_COVERAGETEST_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_arpa_inet.h b/src/unit-test-coverage/ut-stubs/inc/OCS_arpa_inet.h index 9107a1bf1..09ea6539e 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_arpa_inet.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_arpa_inet.h @@ -36,9 +36,7 @@ /* prototypes normally declared in arpa/inet.h */ /* ----------------------------------------- */ -extern const char *OCS_inet_ntop (int af, const void * cp, char * buf, size_t len); -extern int OCS_inet_pton (int af, const char * cp, void * buf); - +extern const char *OCS_inet_ntop(int af, const void *cp, char *buf, size_t len); +extern int OCS_inet_pton(int af, const char *cp, void *buf); #endif /* _OSAL_STUB_ARPA_INET_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_assert.h b/src/unit-test-coverage/ut-stubs/inc/OCS_assert.h index a19995350..da4f69005 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_assert.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_assert.h @@ -32,13 +32,10 @@ /* types normally defined in assert.h */ /* ----------------------------------------- */ - /* ----------------------------------------- */ /* prototypes normally declared in assert.h */ /* ----------------------------------------- */ void OCS_assert(bool expression); - #endif /* _OSAL_STUB_ASSERT_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_basetypes.h b/src/unit-test-coverage/ut-stubs/inc/OCS_basetypes.h index 164455faa..368286bfd 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_basetypes.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_basetypes.h @@ -31,11 +31,9 @@ * potential re-mapping (#define) statements are done. */ -#include /* for correct size_t and ptrdiff_t types */ -#include /* for correct fixed-width integer types */ -#include /* for correct INT_MAX, etc. */ -#include /* for correct boolean semantics */ - +#include /* for correct size_t and ptrdiff_t types */ +#include /* for correct fixed-width integer types */ +#include /* for correct INT_MAX, etc. */ +#include /* for correct boolean semantics */ #endif /* _OSAL_STUB_BASETYPES_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_blkIo.h b/src/unit-test-coverage/ut-stubs/inc/OCS_blkIo.h index 9ecf40605..9883751e7 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_blkIo.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_blkIo.h @@ -26,9 +26,10 @@ #include /* The module and blk_dev types are used in several headers */ -typedef struct OCS_BLK_DEV { int bd; } OCS_BLK_DEV; -typedef OCS_BLK_DEV* OCS_BLK_DEV_ID; - +typedef struct OCS_BLK_DEV +{ + int bd; +} OCS_BLK_DEV; +typedef OCS_BLK_DEV *OCS_BLK_DEV_ID; #endif /* _OSAL_STUB_BLKIO_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_bsp-impl.h b/src/unit-test-coverage/ut-stubs/inc/OCS_bsp-impl.h index b9b7f3283..5cefc0938 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_bsp-impl.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_bsp-impl.h @@ -45,7 +45,6 @@ #ifndef INCLUDE_OCS_BSP_IMPL_H_ #define INCLUDE_OCS_BSP_IMPL_H_ - #include #define OCS_OS_BSP_CONSOLEMODE_NORMAL 0x2101 @@ -91,6 +90,4 @@ extern void OCS_OS_BSP_ConsoleOutput_Impl(const char *Str, uint32_t DataLen); ------------------------------------------------------------------*/ extern void OCS_OS_BSP_ConsoleSetMode_Impl(uint32_t ModeBits); - -#endif /* INCLUDE_OCS_BSP_IMPL_H_ */ - +#endif /* INCLUDE_OCS_BSP_IMPL_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_cbioLib.h b/src/unit-test-coverage/ut-stubs/inc/OCS_cbioLib.h index 126b02ae4..0a7700f19 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_cbioLib.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_cbioLib.h @@ -37,7 +37,4 @@ /* prototypes normally declared in cbioLib.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_CBIOLIB_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_complex.h b/src/unit-test-coverage/ut-stubs/inc/OCS_complex.h index 9f873a50f..ec467a2df 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_complex.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_complex.h @@ -36,7 +36,4 @@ /* prototypes normally declared in complex.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_COMPLEX_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_ctype.h b/src/unit-test-coverage/ut-stubs/inc/OCS_ctype.h index 689ed97ca..b74c2d2e2 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_ctype.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_ctype.h @@ -38,6 +38,4 @@ extern int OCS_isgraph(int c); - #endif /* _OSAL_STUB_CTYPE_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_dirent.h b/src/unit-test-coverage/ut-stubs/inc/OCS_dirent.h index d8c719b27..3e0768ec6 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_dirent.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_dirent.h @@ -32,24 +32,20 @@ /* types normally defined in dirent.h */ /* ----------------------------------------- */ -typedef struct OCS_DIR OCS_DIR; +typedef struct OCS_DIR OCS_DIR; struct OCS_dirent { char d_name[4]; }; - - /* ----------------------------------------- */ /* prototypes normally declared in dirent.h */ /* ----------------------------------------- */ -extern int OCS_closedir (OCS_DIR * dirp); -extern OCS_DIR *OCS_opendir (const char * name); -extern struct OCS_dirent *OCS_readdir (OCS_DIR * dirp); -extern void OCS_rewinddir (OCS_DIR * dirp); - +extern int OCS_closedir(OCS_DIR *dirp); +extern OCS_DIR * OCS_opendir(const char *name); +extern struct OCS_dirent *OCS_readdir(OCS_DIR *dirp); +extern void OCS_rewinddir(OCS_DIR *dirp); #endif /* _OSAL_STUB_DIRENT_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_dlfcn.h b/src/unit-test-coverage/ut-stubs/inc/OCS_dlfcn.h index e07e1c73d..3e1016218 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_dlfcn.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_dlfcn.h @@ -36,11 +36,9 @@ /* prototypes normally declared in dlfcn.h */ /* ----------------------------------------- */ -extern int OCS_dlclose (void * handle); -extern char *OCS_dlerror (void); -extern void *OCS_dlopen (const char * file, int flags); -extern void *OCS_dlsym (void * handle, const char * name); - +extern int OCS_dlclose(void *handle); +extern char *OCS_dlerror(void); +extern void *OCS_dlopen(const char *file, int flags); +extern void *OCS_dlsym(void *handle, const char *name); #endif /* _OSAL_STUB_DLFCN_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_dosFsLib.h b/src/unit-test-coverage/ut-stubs/inc/OCS_dosFsLib.h index cd6891e00..00951db11 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_dosFsLib.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_dosFsLib.h @@ -32,7 +32,7 @@ #define OCS_DOS_CHK_REPAIR 0x00000002 #define OCS_DOS_CHK_VERB_0 0x0000ff00 /* verbosity level/flags */ #define OCS_DOS_CHK_VERB_SILENT OCS_DOS_CHK_VERB_0 -#define OCS_DOS_OPT_BLANK 0x0002 /* create a clean boot block */ +#define OCS_DOS_OPT_BLANK 0x0002 /* create a clean boot block */ /* ----------------------------------------- */ /* types normally defined in dosFsLib.h */ @@ -43,7 +43,4 @@ /* ----------------------------------------- */ extern OCS_STATUS OCS_dosFsVolFormat(char *path, int opt, OCS_FUNCPTR pPromptFunc); - - #endif /* _OSAL_STUB_DOSFSLIB_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_drv_hdisk_ataDrv.h b/src/unit-test-coverage/ut-stubs/inc/OCS_drv_hdisk_ataDrv.h index d1fa2ab2a..c9970c19a 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_drv_hdisk_ataDrv.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_drv_hdisk_ataDrv.h @@ -39,7 +39,4 @@ /* ----------------------------------------- */ extern OCS_BLK_DEV *OCS_ataDevCreate(int ctrl, int drive, unsigned int nBlocks, unsigned int blkOffset); - - #endif /* _OSAL_STUB_DRV_HDISK_ATADRV_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_errno.h b/src/unit-test-coverage/ut-stubs/inc/OCS_errno.h index fd152ae1f..98bfc8847 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_errno.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_errno.h @@ -28,13 +28,12 @@ /* constants normally defined in errno.h */ /* ----------------------------------------- */ /* POSIX-specific errnos */ -#define OCS_EINTR 0x1801 -#define OCS_EAGAIN 0x1802 -#define OCS_EINVAL 0x1803 -#define OCS_EMSGSIZE 0x1804 -#define OCS_ETIMEDOUT 0x1805 -#define OCS_ESPIPE 0x1806 - +#define OCS_EINTR 0x1801 +#define OCS_EAGAIN 0x1802 +#define OCS_EINVAL 0x1803 +#define OCS_EMSGSIZE 0x1804 +#define OCS_ETIMEDOUT 0x1805 +#define OCS_ESPIPE 0x1806 /* ----------------------------------------- */ /* types normally defined in errno.h */ @@ -47,4 +46,3 @@ extern int OCS_errno; #endif /* _OSAL_STUB_ERRNO_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_errnoLib.h b/src/unit-test-coverage/ut-stubs/inc/OCS_errnoLib.h index fd16bf0b9..27bdde88f 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_errnoLib.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_errnoLib.h @@ -37,8 +37,6 @@ /* prototypes normally declared in errnoLib.h */ /* ----------------------------------------- */ -extern int OCS_errnoGet (void); - +extern int OCS_errnoGet(void); #endif /* _OSAL_STUB_ERRNOLIB_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_fcntl.h b/src/unit-test-coverage/ut-stubs/inc/OCS_fcntl.h index 3e19b3c9b..1aec16909 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_fcntl.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_fcntl.h @@ -28,7 +28,6 @@ /* constants normally defined in fcntl.h */ /* ----------------------------------------- */ - /* * note these constants are used as bitmasks and so * they must be single bit flags to work properly. @@ -39,49 +38,43 @@ * * These are exposed to apps through fcntl.h and sys/stat.h */ -#define OCS_S_IXOTH 0x1000 -#define OCS_S_IXGRP 0x2000 -#define OCS_S_IXUSR 0x4000 - -#define OCS_S_IROTH 0x0100 -#define OCS_S_IRGRP 0x0200 -#define OCS_S_IRUSR 0x0400 - -#define OCS_S_IWOTH 0x0010 -#define OCS_S_IWGRP 0x0020 -#define OCS_S_IWUSR 0x0040 - -#define OCS_S_IFDIR 0x0001 -#define OCS_S_ISDIR(x) (((x) & OCS_S_IFDIR) == OCS_S_IFDIR) - - -#define OCS_O_RDONLY 0x1501 -#define OCS_O_WRONLY 0x1502 -#define OCS_O_RDWR 0x1503 -#define OCS_O_CREAT 0x1504 -#define OCS_O_TRUNC 0x1508 -#define OCS_O_NONBLOCK 0x1510 - - -#define OCS_F_GETFL 0x1D01 -#define OCS_F_SETFL 0x1D02 -#define OCS_F_GETFD 0x1D03 -#define OCS_F_SETFD 0x1D04 -#define OCS_F_DUPFD 0x1D05 +#define OCS_S_IXOTH 0x1000 +#define OCS_S_IXGRP 0x2000 +#define OCS_S_IXUSR 0x4000 + +#define OCS_S_IROTH 0x0100 +#define OCS_S_IRGRP 0x0200 +#define OCS_S_IRUSR 0x0400 + +#define OCS_S_IWOTH 0x0010 +#define OCS_S_IWGRP 0x0020 +#define OCS_S_IWUSR 0x0040 + +#define OCS_S_IFDIR 0x0001 +#define OCS_S_ISDIR(x) (((x)&OCS_S_IFDIR) == OCS_S_IFDIR) + +#define OCS_O_RDONLY 0x1501 +#define OCS_O_WRONLY 0x1502 +#define OCS_O_RDWR 0x1503 +#define OCS_O_CREAT 0x1504 +#define OCS_O_TRUNC 0x1508 +#define OCS_O_NONBLOCK 0x1510 + +#define OCS_F_GETFL 0x1D01 +#define OCS_F_SETFL 0x1D02 +#define OCS_F_GETFD 0x1D03 +#define OCS_F_SETFD 0x1D04 +#define OCS_F_DUPFD 0x1D05 /* ----------------------------------------- */ /* types normally defined in fcntl.h */ /* ----------------------------------------- */ - /* ----------------------------------------- */ /* prototypes normally declared in fcntl.h */ /* ----------------------------------------- */ -extern int OCS_fcntl (int fd, int cmd, ...); -extern int OCS_open (const char * file, int oflag, ...); - - +extern int OCS_fcntl(int fd, int cmd, ...); +extern int OCS_open(const char *file, int oflag, ...); #endif /* _OSAL_STUB_FCNTL_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_fenv.h b/src/unit-test-coverage/ut-stubs/inc/OCS_fenv.h index 86fae04ac..fd6d80ceb 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_fenv.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_fenv.h @@ -36,7 +36,4 @@ /* prototypes normally declared in fenv.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_FENV_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_float.h b/src/unit-test-coverage/ut-stubs/inc/OCS_float.h index afde4f8bf..afe94b3e1 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_float.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_float.h @@ -36,7 +36,4 @@ /* prototypes normally declared in float.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_FLOAT_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_hostLib.h b/src/unit-test-coverage/ut-stubs/inc/OCS_hostLib.h index 329070ffb..6198581e8 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_hostLib.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_hostLib.h @@ -42,8 +42,6 @@ /* ----------------------------------------- */ /* prototypes normally declared in hostLib.h */ /* ----------------------------------------- */ -extern int OCS_hostGetByName (char *name); - - -#endif /* INCLUDE_OCS_HOSTLIB_H_ */ +extern int OCS_hostGetByName(char *name); +#endif /* INCLUDE_OCS_HOSTLIB_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_intLib.h b/src/unit-test-coverage/ut-stubs/inc/OCS_intLib.h index 0f1a39c62..1a0b2c0bb 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_intLib.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_intLib.h @@ -37,13 +37,11 @@ /* prototypes normally declared in intLib.h */ /* ----------------------------------------- */ - -extern OCS_STATUS OCS_intConnect(OCS_VOIDFUNCPTR *vector, OCS_VOIDFUNCPTR routine, int parameter); -extern int OCS_intDisable(int level); -extern int OCS_intEnable(int level); -extern int OCS_intLock(void); -extern int OCS_intUnlock(int lockKey); -extern OCS_VOIDFUNCPTR * OCS_INUM_TO_IVEC(unsigned int ui); +extern OCS_STATUS OCS_intConnect(OCS_VOIDFUNCPTR *vector, OCS_VOIDFUNCPTR routine, int parameter); +extern int OCS_intDisable(int level); +extern int OCS_intEnable(int level); +extern int OCS_intLock(void); +extern int OCS_intUnlock(int lockKey); +extern OCS_VOIDFUNCPTR *OCS_INUM_TO_IVEC(unsigned int ui); #endif /* _OSAL_STUB_INTLIB_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_inttypes.h b/src/unit-test-coverage/ut-stubs/inc/OCS_inttypes.h index 107555512..205ca36d0 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_inttypes.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_inttypes.h @@ -36,7 +36,4 @@ /* prototypes normally declared in inttypes.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_INTTYPES_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_ioLib.h b/src/unit-test-coverage/ut-stubs/inc/OCS_ioLib.h index f46923e74..88138eaff 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_ioLib.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_ioLib.h @@ -29,9 +29,8 @@ /* constants normally defined in ioLib.h */ /* ----------------------------------------- */ -#define OCS_FIOCHKDSK 0x1E01 -#define OCS_FIOUNMOUNT 0x1E02 - +#define OCS_FIOCHKDSK 0x1E01 +#define OCS_FIOUNMOUNT 0x1E02 /* ----------------------------------------- */ /* types normally defined in ioLib.h */ @@ -41,9 +40,6 @@ /* prototypes normally declared in ioLib.h */ /* ----------------------------------------- */ -extern int OCS_ioctl (int fd, unsigned long request, ...); - - +extern int OCS_ioctl(int fd, unsigned long request, ...); #endif /* _OSAL_STUB_IOLIB_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_loadLib.h b/src/unit-test-coverage/ut-stubs/inc/OCS_loadLib.h index 987b2ce3b..06e83f4b8 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_loadLib.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_loadLib.h @@ -40,6 +40,4 @@ extern OCS_MODULE_ID OCS_loadModule(int fd, unsigned int symFlag); - #endif /* _OSAL_STUB_LOADLIB_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_locale.h b/src/unit-test-coverage/ut-stubs/inc/OCS_locale.h index ede0acd60..5fe7584bc 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_locale.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_locale.h @@ -36,7 +36,4 @@ /* prototypes normally declared in locale.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_LOCALE_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_logLib.h b/src/unit-test-coverage/ut-stubs/inc/OCS_logLib.h index 39983dba3..122326fce 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_logLib.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_logLib.h @@ -37,7 +37,4 @@ /* prototypes normally declared in logLib.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_LOGLIB_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_math.h b/src/unit-test-coverage/ut-stubs/inc/OCS_math.h index 545cbcff1..2de714646 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_math.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_math.h @@ -36,7 +36,4 @@ /* prototypes normally declared in math.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_MATH_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_memPartLib.h b/src/unit-test-coverage/ut-stubs/inc/OCS_memPartLib.h index 9a074e02b..c7c6a2b5c 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_memPartLib.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_memPartLib.h @@ -32,32 +32,26 @@ /* ----------------------------------------- */ /* types normally defined in memPartLib.h */ /* ----------------------------------------- */ -typedef struct OCS_PART * OCS_PART_ID; +typedef struct OCS_PART *OCS_PART_ID; typedef struct { - unsigned long numBytesFree; /* Number of Free Bytes in Partition */ - unsigned long numBlocksFree; /* Number of Free Blocks in Partition */ - unsigned long maxBlockSizeFree;/* Maximum block size that is free. */ - unsigned long numBytesAlloc; /* Number of Allocated Bytes in Partition */ - unsigned long numBlocksAlloc; /* Number of Allocated Blocks in Partition */ -} OCS_MEM_PART_STATS; - - + unsigned long numBytesFree; /* Number of Free Bytes in Partition */ + unsigned long numBlocksFree; /* Number of Free Blocks in Partition */ + unsigned long maxBlockSizeFree; /* Maximum block size that is free. */ + unsigned long numBytesAlloc; /* Number of Allocated Bytes in Partition */ + unsigned long numBlocksAlloc; /* Number of Allocated Blocks in Partition */ +} OCS_MEM_PART_STATS; /* ----------------------------------------- */ /* prototypes normally declared in memPartLib.h */ /* ----------------------------------------- */ -extern OCS_STATUS OCS_memPartShow(OCS_PART_ID partId, /* partition ID */ - int type /* 0 = statistics, 1 = statistics & list */); - -extern OCS_STATUS OCS_memPartInfoGet(OCS_PART_ID partId, /* partition ID */ - OCS_MEM_PART_STATS * ppartStats /* partition stats structure */); - +extern OCS_STATUS OCS_memPartShow(OCS_PART_ID partId, /* partition ID */ + int type /* 0 = statistics, 1 = statistics & list */); +extern OCS_STATUS OCS_memPartInfoGet(OCS_PART_ID partId, /* partition ID */ + OCS_MEM_PART_STATS *ppartStats /* partition stats structure */); extern OCS_PART_ID OCS_memSysPartId; - #endif /* _OSAL_STUB_MEMPARTLIB_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_moduleLib.h b/src/unit-test-coverage/ut-stubs/inc/OCS_moduleLib.h index 637201d1f..98637b23a 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_moduleLib.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_moduleLib.h @@ -32,8 +32,11 @@ /* ----------------------------------------- */ /* types normally defined in moduleLib.h */ /* ----------------------------------------- */ -typedef struct OCS_MODULE { int m; } OCS_MODULE; -typedef OCS_MODULE* OCS_MODULE_ID; +typedef struct OCS_MODULE +{ + int m; +} OCS_MODULE; +typedef OCS_MODULE *OCS_MODULE_ID; typedef struct OCS_MODULE_INFO { @@ -53,9 +56,6 @@ typedef struct OCS_MODULE_INFO /* prototypes normally declared in moduleLib.h */ /* ----------------------------------------- */ -extern OCS_STATUS OCS_moduleInfoGet(OCS_MODULE_ID moduleId, OCS_MODULE_INFO * pModuleInfo); - - +extern OCS_STATUS OCS_moduleInfoGet(OCS_MODULE_ID moduleId, OCS_MODULE_INFO *pModuleInfo); #endif /* _OSAL_STUB_MODULELIB_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_mqueue.h b/src/unit-test-coverage/ut-stubs/inc/OCS_mqueue.h index eaf8e5c29..b3c051bcb 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_mqueue.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_mqueue.h @@ -46,13 +46,13 @@ struct OCS_mq_attr /* prototypes normally declared in mqueue.h */ /* ----------------------------------------- */ -extern int OCS_mq_close (OCS_mqd_t mqdes); -extern OCS_mqd_t OCS_mq_open (const char * name, int oflag, ...); -extern OCS_ssize_t OCS_mq_receive (OCS_mqd_t mqdes, char * msg_ptr, size_t msg_len, unsigned int * msg_prio); -extern OCS_ssize_t OCS_mq_timedreceive (OCS_mqd_t mqdes, char * msg_ptr, size_t msg_len, unsigned int * msg_prio, const struct OCS_timespec * abs_timeout); -extern int OCS_mq_timedsend (OCS_mqd_t mqdes, const char * msg_ptr, size_t msg_len, unsigned int msg_prio, const struct OCS_timespec * abs_timeout); -extern int OCS_mq_unlink (const char * name); - +extern int OCS_mq_close(OCS_mqd_t mqdes); +extern OCS_mqd_t OCS_mq_open(const char *name, int oflag, ...); +extern OCS_ssize_t OCS_mq_receive(OCS_mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned int *msg_prio); +extern OCS_ssize_t OCS_mq_timedreceive(OCS_mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned int *msg_prio, + const struct OCS_timespec *abs_timeout); +extern int OCS_mq_timedsend(OCS_mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio, + const struct OCS_timespec *abs_timeout); +extern int OCS_mq_unlink(const char *name); #endif /* _OSAL_STUB_MQUEUE_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_msgQLib.h b/src/unit-test-coverage/ut-stubs/inc/OCS_msgQLib.h index 5e182aae7..f313b71e4 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_msgQLib.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_msgQLib.h @@ -29,28 +29,29 @@ /* ----------------------------------------- */ /* constants normally defined in msgQLib.h */ /* ----------------------------------------- */ -#define OCS_MSG_Q_FIFO 0x0 -#define OCS_MSG_Q_PRIORITY 0x1 -#define OCS_WIND_MSG_Q_OPTION_MASK (OCS_MSG_Q_FIFO|OCS_MSG_Q_PRIORITY) +#define OCS_MSG_Q_FIFO 0x0 +#define OCS_MSG_Q_PRIORITY 0x1 +#define OCS_WIND_MSG_Q_OPTION_MASK (OCS_MSG_Q_FIFO | OCS_MSG_Q_PRIORITY) #define OCS_MSG_PRI_NORMAL 0 #define OCS_MSG_PRI_URGENT 1 - /* ----------------------------------------- */ /* types normally defined in msgQLib.h */ /* ----------------------------------------- */ -typedef struct { int x; } OCS_MSG_Q; -typedef OCS_MSG_Q* OCS_MSG_Q_ID; +typedef struct +{ + int x; +} OCS_MSG_Q; +typedef OCS_MSG_Q *OCS_MSG_Q_ID; /* ----------------------------------------- */ /* prototypes normally declared in msgQLib.h */ /* ----------------------------------------- */ extern OCS_MSG_Q_ID OCS_msgQCreate(int maxMsgs, int maxMsgLength, int options); -extern OCS_STATUS OCS_msgQDelete(OCS_MSG_Q_ID msgQId); -extern int OCS_msgQReceive(OCS_MSG_Q_ID msgQId, char * buffer, OCS_UINT maxNBytes, int timeout); -extern OCS_STATUS OCS_msgQSend(OCS_MSG_Q_ID msgQId, char *buffer, OCS_UINT nBytes, int timeout, int priority); +extern OCS_STATUS OCS_msgQDelete(OCS_MSG_Q_ID msgQId); +extern int OCS_msgQReceive(OCS_MSG_Q_ID msgQId, char *buffer, OCS_UINT maxNBytes, int timeout); +extern OCS_STATUS OCS_msgQSend(OCS_MSG_Q_ID msgQId, char *buffer, OCS_UINT nBytes, int timeout, int priority); #endif /* _OSAL_STUB_MSGQLIB_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_net_if.h b/src/unit-test-coverage/ut-stubs/inc/OCS_net_if.h index 009e1f808..3bcb94134 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_net_if.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_net_if.h @@ -36,7 +36,4 @@ /* prototypes normally declared in net/if.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_NET_IF_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_netdb.h b/src/unit-test-coverage/ut-stubs/inc/OCS_netdb.h index 8b2924e68..5803f098e 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_netdb.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_netdb.h @@ -36,7 +36,4 @@ /* prototypes normally declared in netdb.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_NETDB_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_netinet_in.h b/src/unit-test-coverage/ut-stubs/inc/OCS_netinet_in.h index 40eb3ca7e..1ea9295fe 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_netinet_in.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_netinet_in.h @@ -36,12 +36,9 @@ /* prototypes normally declared in netinet/in.h */ /* ----------------------------------------- */ -extern uint16_t OCS_htons (uint16_t hostshort); -extern uint16_t OCS_ntohs (uint16_t netshort); -extern uint32_t OCS_htonl (uint32_t hostlong); -extern uint32_t OCS_ntohl (uint32_t netlong); - - +extern uint16_t OCS_htons(uint16_t hostshort); +extern uint16_t OCS_ntohs(uint16_t netshort); +extern uint32_t OCS_htonl(uint32_t hostlong); +extern uint32_t OCS_ntohl(uint32_t netlong); #endif /* _OSAL_STUB_NETINET_IN_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_netinet_tcp.h b/src/unit-test-coverage/ut-stubs/inc/OCS_netinet_tcp.h index 3d9fddc29..0a755caf0 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_netinet_tcp.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_netinet_tcp.h @@ -36,7 +36,4 @@ /* prototypes normally declared in netinet/tcp.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_NETINET_TCP_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_objLib.h b/src/unit-test-coverage/ut-stubs/inc/OCS_objLib.h index f97e11e42..ac057bd71 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_objLib.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_objLib.h @@ -29,14 +29,12 @@ /* constants normally defined in objLib.h */ /* ----------------------------------------- */ /* VxWorks-specific errnos */ -#define OCS_M_objLib 0x1810 -#define OCS_S_objLib_OBJ_ID_ERROR (OCS_M_objLib | 1) -#define OCS_S_objLib_OBJ_UNAVAILABLE (OCS_M_objLib | 2) -#define OCS_S_objLib_OBJ_DELETED (OCS_M_objLib | 3) -#define OCS_S_objLib_OBJ_TIMEOUT (OCS_M_objLib | 4) -#define OCS_S_objLib_OBJ_NO_METHOD (OCS_M_objLib | 5) - - +#define OCS_M_objLib 0x1810 +#define OCS_S_objLib_OBJ_ID_ERROR (OCS_M_objLib | 1) +#define OCS_S_objLib_OBJ_UNAVAILABLE (OCS_M_objLib | 2) +#define OCS_S_objLib_OBJ_DELETED (OCS_M_objLib | 3) +#define OCS_S_objLib_OBJ_TIMEOUT (OCS_M_objLib | 4) +#define OCS_S_objLib_OBJ_NO_METHOD (OCS_M_objLib | 5) /* ----------------------------------------- */ /* types normally defined in objLib.h */ @@ -46,7 +44,4 @@ /* prototypes normally declared in objLib.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_OBJLIB_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_poll.h b/src/unit-test-coverage/ut-stubs/inc/OCS_poll.h index 6dd0c2ee5..92d0ae860 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_poll.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_poll.h @@ -36,7 +36,4 @@ /* prototypes normally declared in poll.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_POLL_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_pthread.h b/src/unit-test-coverage/ut-stubs/inc/OCS_pthread.h index 311aba577..03003f848 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_pthread.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_pthread.h @@ -30,9 +30,9 @@ /* constants normally defined in pthread.h */ /* ----------------------------------------- */ -#define OCS_PTHREAD_PRIO_INHERIT 0x1000 -#define OCS_PTHREAD_MUTEX_RECURSIVE 0x1001 -#define OCS_PTHREAD_EXPLICIT_SCHED 0x1002 +#define OCS_PTHREAD_PRIO_INHERIT 0x1000 +#define OCS_PTHREAD_MUTEX_RECURSIVE 0x1001 +#define OCS_PTHREAD_EXPLICIT_SCHED 0x1002 /* ----------------------------------------- */ /* types normally defined in pthread.h */ @@ -73,54 +73,53 @@ struct OCS_pthread_condattr int pthr_cattr; }; -typedef struct OCS_pthread OCS_pthread_t; -typedef struct OCS_pthread_attr OCS_pthread_attr_t; -typedef struct OCS_pthread_mutex OCS_pthread_mutex_t; -typedef struct OCS_pthread_mutexattr OCS_pthread_mutexattr_t; -typedef struct OCS_pthread_cond OCS_pthread_cond_t; -typedef struct OCS_pthread_condattr OCS_pthread_condattr_t; -typedef struct OCS_pthread_key OCS_pthread_key_t; +typedef struct OCS_pthread OCS_pthread_t; +typedef struct OCS_pthread_attr OCS_pthread_attr_t; +typedef struct OCS_pthread_mutex OCS_pthread_mutex_t; +typedef struct OCS_pthread_mutexattr OCS_pthread_mutexattr_t; +typedef struct OCS_pthread_cond OCS_pthread_cond_t; +typedef struct OCS_pthread_condattr OCS_pthread_condattr_t; +typedef struct OCS_pthread_key OCS_pthread_key_t; /* ----------------------------------------- */ /* prototypes normally declared in pthread.h */ /* ----------------------------------------- */ -extern int OCS_pthread_attr_destroy (OCS_pthread_attr_t * attr); -extern int OCS_pthread_attr_getschedparam (const OCS_pthread_attr_t * attr, struct OCS_sched_param * param); -extern int OCS_pthread_attr_init (OCS_pthread_attr_t * attr); -extern int OCS_pthread_attr_setinheritsched (OCS_pthread_attr_t * attr, int inherit); -extern int OCS_pthread_attr_setschedparam (OCS_pthread_attr_t * attr, const struct OCS_sched_param * param); -extern int OCS_pthread_attr_setschedpolicy (OCS_pthread_attr_t * attr, int policy); -extern int OCS_pthread_attr_setstacksize (OCS_pthread_attr_t * attr, size_t stacksize); -extern int OCS_pthread_cancel (OCS_pthread_t th); -extern int OCS_pthread_cond_broadcast (OCS_pthread_cond_t * cond); -extern int OCS_pthread_cond_destroy (OCS_pthread_cond_t * cond); -extern int OCS_pthread_cond_init (OCS_pthread_cond_t * cond, const OCS_pthread_condattr_t * cond_attr); -extern int OCS_pthread_cond_signal (OCS_pthread_cond_t * cond); -extern int OCS_pthread_cond_timedwait (OCS_pthread_cond_t * cond, OCS_pthread_mutex_t * mutex, const struct OCS_timespec * abstime); -extern int OCS_pthread_cond_wait (OCS_pthread_cond_t * cond, OCS_pthread_mutex_t * mutex); -extern int OCS_pthread_create (OCS_pthread_t * newthread, const OCS_pthread_attr_t * attr, void *(* start_routine) (void *), void * arg); -extern int OCS_pthread_detach (OCS_pthread_t th); -extern int OCS_pthread_equal (OCS_pthread_t thread1, OCS_pthread_t thread2); -extern void OCS_pthread_exit (void * retval); -extern int OCS_pthread_getschedparam (OCS_pthread_t target_thread, int * policy, struct OCS_sched_param * param); -extern void *OCS_pthread_getspecific (OCS_pthread_key_t key); -extern int OCS_pthread_key_create (OCS_pthread_key_t * key, void (* destr_function) (void *)); -extern int OCS_pthread_mutexattr_destroy (OCS_pthread_mutexattr_t * attr); -extern int OCS_pthread_mutexattr_init (OCS_pthread_mutexattr_t * attr); -extern int OCS_pthread_mutexattr_setprotocol (OCS_pthread_mutexattr_t * attr, int protocol); -extern int OCS_pthread_mutexattr_settype (OCS_pthread_mutexattr_t * attr, int kind); -extern int OCS_pthread_mutex_destroy (OCS_pthread_mutex_t * mutex); -extern int OCS_pthread_mutex_init (OCS_pthread_mutex_t * mutex, const OCS_pthread_mutexattr_t * mutexattr); -extern int OCS_pthread_mutex_lock (OCS_pthread_mutex_t * mutex); -extern int OCS_pthread_mutex_unlock (OCS_pthread_mutex_t * mutex); -extern OCS_pthread_t OCS_pthread_self (void); -extern int OCS_pthread_setschedparam (OCS_pthread_t target_thread, int policy, const struct OCS_sched_param * param); -extern int OCS_pthread_setschedprio (OCS_pthread_t target_thread, int prio); -extern int OCS_pthread_setspecific (OCS_pthread_key_t key, const void * pointer); -extern int OCS_pthread_sigmask (int how, const OCS_sigset_t *set, OCS_sigset_t * oldset); - - +extern int OCS_pthread_attr_destroy(OCS_pthread_attr_t *attr); +extern int OCS_pthread_attr_getschedparam(const OCS_pthread_attr_t *attr, struct OCS_sched_param *param); +extern int OCS_pthread_attr_init(OCS_pthread_attr_t *attr); +extern int OCS_pthread_attr_setinheritsched(OCS_pthread_attr_t *attr, int inherit); +extern int OCS_pthread_attr_setschedparam(OCS_pthread_attr_t *attr, const struct OCS_sched_param *param); +extern int OCS_pthread_attr_setschedpolicy(OCS_pthread_attr_t *attr, int policy); +extern int OCS_pthread_attr_setstacksize(OCS_pthread_attr_t *attr, size_t stacksize); +extern int OCS_pthread_cancel(OCS_pthread_t th); +extern int OCS_pthread_cond_broadcast(OCS_pthread_cond_t *cond); +extern int OCS_pthread_cond_destroy(OCS_pthread_cond_t *cond); +extern int OCS_pthread_cond_init(OCS_pthread_cond_t *cond, const OCS_pthread_condattr_t *cond_attr); +extern int OCS_pthread_cond_signal(OCS_pthread_cond_t *cond); +extern int OCS_pthread_cond_timedwait(OCS_pthread_cond_t *cond, OCS_pthread_mutex_t *mutex, + const struct OCS_timespec *abstime); +extern int OCS_pthread_cond_wait(OCS_pthread_cond_t *cond, OCS_pthread_mutex_t *mutex); +extern int OCS_pthread_create(OCS_pthread_t *newthread, const OCS_pthread_attr_t *attr, void *(*start_routine)(void *), + void *arg); +extern int OCS_pthread_detach(OCS_pthread_t th); +extern int OCS_pthread_equal(OCS_pthread_t thread1, OCS_pthread_t thread2); +extern void OCS_pthread_exit(void *retval); +extern int OCS_pthread_getschedparam(OCS_pthread_t target_thread, int *policy, struct OCS_sched_param *param); +extern void * OCS_pthread_getspecific(OCS_pthread_key_t key); +extern int OCS_pthread_key_create(OCS_pthread_key_t *key, void (*destr_function)(void *)); +extern int OCS_pthread_mutexattr_destroy(OCS_pthread_mutexattr_t *attr); +extern int OCS_pthread_mutexattr_init(OCS_pthread_mutexattr_t *attr); +extern int OCS_pthread_mutexattr_setprotocol(OCS_pthread_mutexattr_t *attr, int protocol); +extern int OCS_pthread_mutexattr_settype(OCS_pthread_mutexattr_t *attr, int kind); +extern int OCS_pthread_mutex_destroy(OCS_pthread_mutex_t *mutex); +extern int OCS_pthread_mutex_init(OCS_pthread_mutex_t *mutex, const OCS_pthread_mutexattr_t *mutexattr); +extern int OCS_pthread_mutex_lock(OCS_pthread_mutex_t *mutex); +extern int OCS_pthread_mutex_unlock(OCS_pthread_mutex_t *mutex); +extern OCS_pthread_t OCS_pthread_self(void); +extern int OCS_pthread_setschedparam(OCS_pthread_t target_thread, int policy, const struct OCS_sched_param *param); +extern int OCS_pthread_setschedprio(OCS_pthread_t target_thread, int prio); +extern int OCS_pthread_setspecific(OCS_pthread_key_t key, const void *pointer); +extern int OCS_pthread_sigmask(int how, const OCS_sigset_t *set, OCS_sigset_t *oldset); #endif /* _OSAL_STUB_PTHREAD_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_ramDiskCbio.h b/src/unit-test-coverage/ut-stubs/inc/OCS_ramDiskCbio.h index 661df5501..9aad6bb0e 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_ramDiskCbio.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_ramDiskCbio.h @@ -37,7 +37,4 @@ /* prototypes normally declared in ramDiskCbio.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_RAMDISKCBIO_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_ramDrv.h b/src/unit-test-coverage/ut-stubs/inc/OCS_ramDrv.h index 0235343ab..3195323a1 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_ramDrv.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_ramDrv.h @@ -37,11 +37,6 @@ /* ----------------------------------------- */ /* prototypes normally declared in ramDrv.h */ /* ----------------------------------------- */ -extern OCS_BLK_DEV *OCS_ramDevCreate (char *ramAddr, int bytesPerSec, int secPerTrack, - int nSectors, int secOffset); - - - +extern OCS_BLK_DEV *OCS_ramDevCreate(char *ramAddr, int bytesPerSec, int secPerTrack, int nSectors, int secOffset); #endif /* _OSAL_STUB_RAMDRV_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_sched.h b/src/unit-test-coverage/ut-stubs/inc/OCS_sched.h index 89a4b050b..8a7cdf4d9 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_sched.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_sched.h @@ -27,8 +27,8 @@ /* ----------------------------------------- */ /* constants normally defined in sched.h */ /* ----------------------------------------- */ -#define OCS_SCHED_FIFO 0x1200 -#define OCS_SCHED_RR 0x1201 +#define OCS_SCHED_FIFO 0x1200 +#define OCS_SCHED_RR 0x1201 /* ----------------------------------------- */ /* types normally defined in sched.h */ @@ -38,7 +38,6 @@ struct OCS_sched_param int sched_priority; }; - /* ----------------------------------------- */ /* prototypes normally declared in sched.h */ /* ----------------------------------------- */ @@ -46,6 +45,4 @@ struct OCS_sched_param extern int OCS_sched_get_priority_max(int policy); extern int OCS_sched_get_priority_min(int policy); - #endif /* _OSAL_STUB_SCHED_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_semLib.h b/src/unit-test-coverage/ut-stubs/inc/OCS_semLib.h index 6947dfba0..5fe016edb 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_semLib.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_semLib.h @@ -28,21 +28,21 @@ /* ----------------------------------------- */ /* constants normally defined in semLib.h */ /* ----------------------------------------- */ -#define OCS_VX_BINARY_SEMAPHORE(x) OCS_SEM x[1] -#define OCS_VX_COUNTING_SEMAPHORE(x) OCS_SEM x[1] -#define OCS_VX_MUTEX_SEMAPHORE(x) OCS_SEM x[1] +#define OCS_VX_BINARY_SEMAPHORE(x) OCS_SEM x[1] +#define OCS_VX_COUNTING_SEMAPHORE(x) OCS_SEM x[1] +#define OCS_VX_MUTEX_SEMAPHORE(x) OCS_SEM x[1] /* ----------------------------------------- */ /* types normally defined in semLib.h */ /* ----------------------------------------- */ -typedef char OCS_SEM; -typedef OCS_SEM* OCS_SEM_ID; +typedef char OCS_SEM; +typedef OCS_SEM *OCS_SEM_ID; /*for binary semaphores */ typedef enum { OCS_SEM_EMPTY = 0, - OCS_SEM_FULL = 1 + OCS_SEM_FULL = 1 } OCS_SEM_B_STATE; enum @@ -54,7 +54,6 @@ enum OCS_SEM_EVENTSEND_ERR_NOTIFY = 0x10 }; - /* ----------------------------------------- */ /* prototypes normally declared in semLib.h */ /* ----------------------------------------- */ @@ -71,7 +70,4 @@ extern OCS_STATUS OCS_semFlush(OCS_SEM_ID semId); extern OCS_STATUS OCS_semTake(OCS_SEM_ID semId, int timeout); extern OCS_STATUS OCS_semGive(OCS_SEM_ID semId); - - #endif /* _OSAL_STUB_SEMLIB_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_semaphore.h b/src/unit-test-coverage/ut-stubs/inc/OCS_semaphore.h index 7f170acd3..034ad6f0f 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_semaphore.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_semaphore.h @@ -33,19 +33,20 @@ /* types normally defined in semaphore.h */ /* ----------------------------------------- */ -typedef struct { int s; } OCS_sem_t; +typedef struct +{ + int s; +} OCS_sem_t; /* ----------------------------------------- */ /* prototypes normally declared in semaphore.h */ /* ----------------------------------------- */ -extern int OCS_sem_destroy (OCS_sem_t * sem); -extern int OCS_sem_getvalue (OCS_sem_t * sem, int * sval); -extern int OCS_sem_init (OCS_sem_t * sem, int pshared, unsigned int value); -extern int OCS_sem_post (OCS_sem_t * sem); -extern int OCS_sem_timedwait (OCS_sem_t * sem, const struct OCS_timespec * abstime); -extern int OCS_sem_wait (OCS_sem_t * sem); - +extern int OCS_sem_destroy(OCS_sem_t *sem); +extern int OCS_sem_getvalue(OCS_sem_t *sem, int *sval); +extern int OCS_sem_init(OCS_sem_t *sem, int pshared, unsigned int value); +extern int OCS_sem_post(OCS_sem_t *sem); +extern int OCS_sem_timedwait(OCS_sem_t *sem, const struct OCS_timespec *abstime); +extern int OCS_sem_wait(OCS_sem_t *sem); #endif /* _OSAL_STUB_SEMAPHORE_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_setjmp.h b/src/unit-test-coverage/ut-stubs/inc/OCS_setjmp.h index ae650bf77..89ed14b05 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_setjmp.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_setjmp.h @@ -36,7 +36,4 @@ /* prototypes normally declared in setjmp.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_SETJMP_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_shellLib.h b/src/unit-test-coverage/ut-stubs/inc/OCS_shellLib.h index bbb02a705..8f2dc631c 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_shellLib.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_shellLib.h @@ -37,17 +37,7 @@ /* prototypes normally declared in shellLib.h */ /* ----------------------------------------- */ -extern OCS_STATUS OCS_shellGenericInit( - const char * config, - int stackSize, - const char * shellName, - char **pShellName, - OCS_BOOL interactive, - OCS_BOOL loginAccess, - int fdin, - int fdout, - int fderr -); +extern OCS_STATUS OCS_shellGenericInit(const char *config, int stackSize, const char *shellName, char **pShellName, + OCS_BOOL interactive, OCS_BOOL loginAccess, int fdin, int fdout, int fderr); #endif /* _OSAL_STUB_SHELLLIB_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_signal.h b/src/unit-test-coverage/ut-stubs/inc/OCS_signal.h index 778f4de61..c0d3006bb 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_signal.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_signal.h @@ -29,19 +29,18 @@ /* constants normally defined in signal.h */ /* ----------------------------------------- */ -#define OCS_SIG_SETMASK 0x1100 -#define OCS_SIGHUP 0x1101 -#define OCS_SIGINT 0x1102 -#define OCS_SIGABRT 0x1103 -#define OCS_SIGSEGV 0x1104 -#define OCS_SIGBUS 0x1105 -#define OCS_SIGFPE 0x1106 -#define OCS_SIGILL 0x1107 -#define OCS_SIGRTMIN 0x1110 -#define OCS_SIGRTMAX 0x1120 - -#define OCS_SIGEV_SIGNAL 0x1180 +#define OCS_SIG_SETMASK 0x1100 +#define OCS_SIGHUP 0x1101 +#define OCS_SIGINT 0x1102 +#define OCS_SIGABRT 0x1103 +#define OCS_SIGSEGV 0x1104 +#define OCS_SIGBUS 0x1105 +#define OCS_SIGFPE 0x1106 +#define OCS_SIGILL 0x1107 +#define OCS_SIGRTMIN 0x1110 +#define OCS_SIGRTMAX 0x1120 +#define OCS_SIGEV_SIGNAL 0x1180 /* ----------------------------------------- */ /* types normally defined in signal.h */ @@ -57,24 +56,22 @@ struct OCS_sigevent int sigev_notify; }; -typedef void (*OCS_sighandler_t)(int); -typedef int OCS_sig_atomic_t; - +typedef void (*OCS_sighandler_t)(int); +typedef int OCS_sig_atomic_t; /* ----------------------------------------- */ /* prototypes normally declared in signal.h */ /* ----------------------------------------- */ -extern int OCS_kill (OCS_pid_t pid, int sig); -extern int OCS_sigaddset (OCS_sigset_t * set, int signo); -extern int OCS_sigdelset (OCS_sigset_t * set, int signo); -extern int OCS_sigemptyset (OCS_sigset_t * set); -extern int OCS_sigfillset (OCS_sigset_t * set); -extern int OCS_sigismember (const OCS_sigset_t * set, int signo); +extern int OCS_kill(OCS_pid_t pid, int sig); +extern int OCS_sigaddset(OCS_sigset_t *set, int signo); +extern int OCS_sigdelset(OCS_sigset_t *set, int signo); +extern int OCS_sigemptyset(OCS_sigset_t *set); +extern int OCS_sigfillset(OCS_sigset_t *set); +extern int OCS_sigismember(const OCS_sigset_t *set, int signo); extern OCS_sighandler_t OCS_signal(int signum, OCS_sighandler_t handler); -extern int OCS_sigprocmask (int how, const OCS_sigset_t * set, OCS_sigset_t * oset); -extern int OCS_sigsuspend (const OCS_sigset_t * set); -extern int OCS_sigwait (const OCS_sigset_t * set, int * sig); +extern int OCS_sigprocmask(int how, const OCS_sigset_t *set, OCS_sigset_t *oset); +extern int OCS_sigsuspend(const OCS_sigset_t *set); +extern int OCS_sigwait(const OCS_sigset_t *set, int *sig); #endif /* _OSAL_STUB_SIGNAL_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_stat.h b/src/unit-test-coverage/ut-stubs/inc/OCS_stat.h index 6cfa0d0be..3a9f79d55 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_stat.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_stat.h @@ -39,11 +39,11 @@ struct OCS_stat { - OCS_mode_t st_mode; - OCS_off_t st_size; - OCS_time_t st_mtime; - OCS_uid_t st_uid; - OCS_gid_t st_gid; + OCS_mode_t st_mode; + OCS_off_t st_size; + OCS_time_t st_mtime; + OCS_uid_t st_uid; + OCS_gid_t st_gid; }; /* ----------------------------------------- */ @@ -60,19 +60,15 @@ struct OCS_statvfs /* prototypes normally declared in sys/stat.h */ /* ----------------------------------------- */ -extern int OCS_fchmod (int fd, OCS_mode_t mode); -extern int OCS_chmod (const char *path, OCS_mode_t mode); -extern int OCS_mkdir (const char * path, ...); -extern int OCS_stat (const char * file, struct OCS_stat * buf); - +extern int OCS_fchmod(int fd, OCS_mode_t mode); +extern int OCS_chmod(const char *path, OCS_mode_t mode); +extern int OCS_mkdir(const char *path, ...); +extern int OCS_stat(const char *file, struct OCS_stat *buf); /* ----------------------------------------- */ /* prototypes normally declared in sys/statvfs.h */ /* ----------------------------------------- */ -extern int OCS_statvfs (const char * file, struct OCS_statvfs * buf); - - +extern int OCS_statvfs(const char *file, struct OCS_statvfs *buf); #endif /* _OSAL_STUB_STAT_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_stdarg.h b/src/unit-test-coverage/ut-stubs/inc/OCS_stdarg.h index cf93c1245..474e68c3e 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_stdarg.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_stdarg.h @@ -31,18 +31,16 @@ /* ----------------------------------------- */ /* types normally defined in stdarg.h */ /* ----------------------------------------- */ -typedef struct { void *p; } OCS_va_list; - - +typedef struct +{ + void *p; +} OCS_va_list; /* ----------------------------------------- */ /* prototypes normally declared in stdarg.h */ /* ----------------------------------------- */ -#define OCS_va_start(ap, last) ap.p = &last +#define OCS_va_start(ap, last) ap.p = &last #define OCS_va_end(ap) - - #endif /* _OSAL_STUB_STDARG_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_stdio.h b/src/unit-test-coverage/ut-stubs/inc/OCS_stdio.h index 1008a65a2..b6a03a08c 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_stdio.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_stdio.h @@ -34,26 +34,23 @@ /* ----------------------------------------- */ typedef struct OCS_FILE OCS_FILE; - /* ----------------------------------------- */ /* prototypes normally declared in stdio.h */ /* ----------------------------------------- */ -extern int OCS_fclose (OCS_FILE * stream); -extern char *OCS_fgets (char * s, int n, OCS_FILE * stream); -extern OCS_FILE *OCS_fopen (const char * filename, const char * modes); -extern int OCS_fputs (const char * s, OCS_FILE * stream); -extern int OCS_remove (const char * filename); -extern int OCS_rename (const char * old, const char * nw); -extern int OCS_snprintf (char * s, size_t maxlen, const char * format, ...); -extern int OCS_vsnprintf (char * s, size_t maxlen, const char * format, OCS_va_list arg); -extern int OCS_printf (const char * format, ...); -extern int OCS_putchar (int c); - -extern OCS_FILE* OCS_stdin; -extern OCS_FILE* OCS_stdout; -extern OCS_FILE* OCS_stderr; - +extern int OCS_fclose(OCS_FILE *stream); +extern char * OCS_fgets(char *s, int n, OCS_FILE *stream); +extern OCS_FILE *OCS_fopen(const char *filename, const char *modes); +extern int OCS_fputs(const char *s, OCS_FILE *stream); +extern int OCS_remove(const char *filename); +extern int OCS_rename(const char *old, const char *nw); +extern int OCS_snprintf(char *s, size_t maxlen, const char *format, ...); +extern int OCS_vsnprintf(char *s, size_t maxlen, const char *format, OCS_va_list arg); +extern int OCS_printf(const char *format, ...); +extern int OCS_putchar(int c); + +extern OCS_FILE *OCS_stdin; +extern OCS_FILE *OCS_stdout; +extern OCS_FILE *OCS_stderr; #endif /* _OSAL_STUB_STDIO_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_stdlib.h b/src/unit-test-coverage/ut-stubs/inc/OCS_stdlib.h index 849a3a21a..7332b9d32 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_stdlib.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_stdlib.h @@ -28,9 +28,8 @@ /* constants normally defined in stdlib.h */ /* ----------------------------------------- */ -#define OCS_EXIT_SUCCESS 0x0100 -#define OCS_EXIT_FAILURE 0x0101 - +#define OCS_EXIT_SUCCESS 0x0100 +#define OCS_EXIT_FAILURE 0x0101 /* ----------------------------------------- */ /* types normally defined in stdlib.h */ @@ -40,12 +39,10 @@ /* prototypes normally declared in stdlib.h */ /* ----------------------------------------- */ -extern void OCS_exit (int status); -extern unsigned long int OCS_strtoul (const char * nptr, char ** endptr, int base); -extern int OCS_system (const char * command); -extern void *OCS_malloc(size_t sz); -extern void OCS_free(void *ptr); - +extern void OCS_exit(int status); +extern unsigned long int OCS_strtoul(const char *nptr, char **endptr, int base); +extern int OCS_system(const char *command); +extern void * OCS_malloc(size_t sz); +extern void OCS_free(void *ptr); #endif /* _OSAL_STUB_STDLIB_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_string.h b/src/unit-test-coverage/ut-stubs/inc/OCS_string.h index 9cf50b70f..a4a931284 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_string.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_string.h @@ -36,18 +36,17 @@ /* prototypes normally declared in string.h */ /* ----------------------------------------- */ -extern void *OCS_memcpy (void * dest, const void * src, size_t n); -extern void *OCS_memset (void * s, int c, size_t n); -extern int OCS_strcmp (const char * s1, const char * s2); -extern char *OCS_strcpy (char * dest, const char * src); -extern size_t OCS_strlen (const char * s); -extern int OCS_strncmp (const char * s1, const char * s2, size_t n); -extern char *OCS_strncpy (char * dest, const char * src, size_t n); -extern char *OCS_strchr(const char *s, int c); -extern char *OCS_strrchr (const char * s, int c); -extern char *OCS_strcat(char *dest, const char *src); -extern char *OCS_strncat(char *dest, const char *src, size_t n); -extern char *OCS_strerror(int errnum); +extern void * OCS_memcpy(void *dest, const void *src, size_t n); +extern void * OCS_memset(void *s, int c, size_t n); +extern int OCS_strcmp(const char *s1, const char *s2); +extern char * OCS_strcpy(char *dest, const char *src); +extern size_t OCS_strlen(const char *s); +extern int OCS_strncmp(const char *s1, const char *s2, size_t n); +extern char * OCS_strncpy(char *dest, const char *src, size_t n); +extern char * OCS_strchr(const char *s, int c); +extern char * OCS_strrchr(const char *s, int c); +extern char * OCS_strcat(char *dest, const char *src); +extern char * OCS_strncat(char *dest, const char *src, size_t n); +extern char * OCS_strerror(int errnum); #endif /* _OSAL_STUB_STRING_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_strings.h b/src/unit-test-coverage/ut-stubs/inc/OCS_strings.h index 080f9d8cb..480522ec2 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_strings.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_strings.h @@ -36,7 +36,4 @@ /* prototypes normally declared in strings.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_STRINGS_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_symLib.h b/src/unit-test-coverage/ut-stubs/inc/OCS_symLib.h index f3b4edd2c..61a437942 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_symLib.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_symLib.h @@ -35,31 +35,30 @@ /* ----------------------------------------- */ /* constants normally defined in symLib.h */ /* ----------------------------------------- */ -#define OCS_LOAD_ALL_SYMBOLS 0x1A00 -#define OCS_SYM_FIND_BY_NAME 0x1A01 +#define OCS_LOAD_ALL_SYMBOLS 0x1A00 +#define OCS_SYM_FIND_BY_NAME 0x1A01 /* ----------------------------------------- */ /* types normally defined in symLib.h */ /* ----------------------------------------- */ -typedef int OCS_SYM_TYPE; +typedef int OCS_SYM_TYPE; typedef uintptr_t OCS_SYM_VALUE; -typedef int OCS_SYM_GROUP; +typedef int OCS_SYM_GROUP; -typedef struct OCS_SYMBOL OCS_SYMBOL; -typedef struct OCS_SYMTAB OCS_SYMTAB; +typedef struct OCS_SYMBOL OCS_SYMBOL; +typedef struct OCS_SYMTAB OCS_SYMTAB; - -typedef OCS_SYMTAB * OCS_SYMTAB_ID; -typedef OCS_SYMBOL * OCS_SYMBOL_ID; +typedef OCS_SYMTAB *OCS_SYMTAB_ID; +typedef OCS_SYMBOL *OCS_SYMBOL_ID; typedef struct OCS_SYMBOL_DESC { - unsigned int mask; - char * name; - OCS_SYM_VALUE value; + unsigned int mask; + char * name; + OCS_SYM_VALUE value; } OCS_SYMBOL_DESC; -typedef OCS_BOOL (*OCS_symEach_Routine_t) (char *, OCS_SYM_VALUE, OCS_SYM_TYPE, OCS_Vx_usr_arg_t, OCS_SYM_GROUP); +typedef OCS_BOOL (*OCS_symEach_Routine_t)(char *, OCS_SYM_VALUE, OCS_SYM_TYPE, OCS_Vx_usr_arg_t, OCS_SYM_GROUP); /* ----------------------------------------- */ /* prototypes normally declared in symLib.h */ @@ -67,11 +66,8 @@ typedef OCS_BOOL (*OCS_symEach_Routine_t) (char *, OCS_SYM_VALUE, OCS_SYM_TYPE, extern OCS_SYMTAB_ID OCS_sysSymTbl; +extern OCS_STATUS OCS_symFindByName(OCS_SYMTAB_ID symTblId, char *name, char **pValue, OCS_SYM_TYPE *pType); +extern OCS_SYMBOL *OCS_symEach(OCS_SYMTAB_ID symTblId, OCS_symEach_Routine_t routine, int routineArg); +extern OCS_STATUS OCS_symFind(OCS_SYMTAB_ID symTblId, OCS_SYMBOL_DESC *pSymbol); -extern OCS_STATUS OCS_symFindByName(OCS_SYMTAB_ID symTblId, char * name, char ** pValue, OCS_SYM_TYPE * pType); -extern OCS_SYMBOL * OCS_symEach(OCS_SYMTAB_ID symTblId, OCS_symEach_Routine_t routine, int routineArg); -extern OCS_STATUS OCS_symFind (OCS_SYMTAB_ID symTblId, OCS_SYMBOL_DESC * pSymbol); - - -#endif /* INCLUDE_OCS_SYMLIB_H_ */ - +#endif /* INCLUDE_OCS_SYMLIB_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_sysLib.h b/src/unit-test-coverage/ut-stubs/inc/OCS_sysLib.h index 7243c1211..36b43f7e8 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_sysLib.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_sysLib.h @@ -38,7 +38,4 @@ /* ----------------------------------------- */ extern int OCS_sysClkRateGet(void); - - #endif /* _OSAL_STUB_SYSLIB_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_sys_ioctl.h b/src/unit-test-coverage/ut-stubs/inc/OCS_sys_ioctl.h index f8cf1e635..230ecb053 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_sys_ioctl.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_sys_ioctl.h @@ -36,8 +36,6 @@ /* prototypes normally declared in sys/ioctl.h */ /* ----------------------------------------- */ -extern int OCS_ioctl (int fd, unsigned long request, ...); - +extern int OCS_ioctl(int fd, unsigned long request, ...); #endif /* _OSAL_STUB_SYS_IOCTL_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_sys_ipc.h b/src/unit-test-coverage/ut-stubs/inc/OCS_sys_ipc.h index 6b6f91178..9384f38a0 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_sys_ipc.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_sys_ipc.h @@ -36,7 +36,4 @@ /* prototypes normally declared in sys/ipc.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_SYS_IPC_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_sys_mman.h b/src/unit-test-coverage/ut-stubs/inc/OCS_sys_mman.h index ee9c19b23..944ac9d43 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_sys_mman.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_sys_mman.h @@ -27,13 +27,13 @@ /* ----------------------------------------- */ /* constants normally defined in sys/mman.h */ /* ----------------------------------------- */ -#define OCS_MAP_SHARED 0x2001 -#define OCS_MAP_PRIVATE 0x2002 -#define OCS_PROT_EXEC 0x2004 -#define OCS_PROT_READ 0x2008 -#define OCS_PROT_WRITE 0x2010 -#define OCS_PROT_NONE 0x2020 -#define OCS_MAP_FIXED 0x2080 +#define OCS_MAP_SHARED 0x2001 +#define OCS_MAP_PRIVATE 0x2002 +#define OCS_PROT_EXEC 0x2004 +#define OCS_PROT_READ 0x2008 +#define OCS_PROT_WRITE 0x2010 +#define OCS_PROT_NONE 0x2020 +#define OCS_MAP_FIXED 0x2080 /* ----------------------------------------- */ /* types normally defined in sys/mman.h */ @@ -42,10 +42,7 @@ /* ----------------------------------------- */ /* prototypes normally declared in sys/mman.h */ /* ----------------------------------------- */ -void *OCS_mmap(void *addr, size_t length, int prot, int flags, - int fd, OCS_off_t offset); -int OCS_munmap(void *addr, size_t length); - +void *OCS_mmap(void *addr, size_t length, int prot, int flags, int fd, OCS_off_t offset); +int OCS_munmap(void *addr, size_t length); #endif /* _OSAL_STUB_SYS_MMAN_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_sys_select.h b/src/unit-test-coverage/ut-stubs/inc/OCS_sys_select.h index fdfce2690..10c1c1e7b 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_sys_select.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_sys_select.h @@ -38,18 +38,21 @@ /* ----------------------------------------- */ /* types normally defined in sys/select.h */ /* ----------------------------------------- */ -typedef struct { unsigned int fds; } OCS_fd_set; +typedef struct +{ + unsigned int fds; +} OCS_fd_set; /* ----------------------------------------- */ /* prototypes normally declared in sys/select.h */ /* ----------------------------------------- */ -extern int OCS_select (int nfds, OCS_fd_set * readfds, OCS_fd_set * writefds, OCS_fd_set * exceptfds, struct OCS_timeval * timeout); +extern int OCS_select(int nfds, OCS_fd_set *readfds, OCS_fd_set *writefds, OCS_fd_set *exceptfds, + struct OCS_timeval *timeout); extern void OCS_FD_SET(int fd, OCS_fd_set *set); -extern int OCS_FD_ISSET(int fd, OCS_fd_set *set); +extern int OCS_FD_ISSET(int fd, OCS_fd_set *set); extern void OCS_FD_CLR(int fd, OCS_fd_set *set); extern void OCS_FD_ZERO(OCS_fd_set *set); -#endif /* INCLUDE_OCS_SYS_SELECT_H_ */ - +#endif /* INCLUDE_OCS_SYS_SELECT_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_sys_socket.h b/src/unit-test-coverage/ut-stubs/inc/OCS_sys_socket.h index cdea98e34..c5c13391d 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_sys_socket.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_sys_socket.h @@ -32,7 +32,7 @@ /* ----------------------------------------- */ /* types normally defined in sys/socket.h */ /* ----------------------------------------- */ -typedef size_t OCS_socklen_t; +typedef size_t OCS_socklen_t; struct OCS_sockaddr { @@ -43,16 +43,16 @@ struct OCS_sockaddr /* prototypes normally declared in sys/socket.h */ /* ----------------------------------------- */ -extern int OCS_accept (int fd, struct OCS_sockaddr * addr, OCS_socklen_t * addr_len); -extern int OCS_bind (int fd, const struct OCS_sockaddr * addr, OCS_socklen_t len); -extern int OCS_connect (int fd, const struct OCS_sockaddr * addr, OCS_socklen_t len); -extern int OCS_getsockopt (int fd, int level, int optname, void * optval, OCS_socklen_t * optlen); -extern int OCS_listen (int fd, int n); -extern OCS_ssize_t OCS_recvfrom (int fd, void * buf, size_t n, int flags, struct OCS_sockaddr * addr, OCS_socklen_t * addr_len); -extern OCS_ssize_t OCS_sendto (int fd, const void * buf, size_t n, int flags, const struct OCS_sockaddr * addr, OCS_socklen_t addr_len); -extern int OCS_setsockopt (int fd, int level, int optname, const void * optval, OCS_socklen_t optlen); -extern int OCS_socket (int domain, int type, int protocol); - +extern int OCS_accept(int fd, struct OCS_sockaddr *addr, OCS_socklen_t *addr_len); +extern int OCS_bind(int fd, const struct OCS_sockaddr *addr, OCS_socklen_t len); +extern int OCS_connect(int fd, const struct OCS_sockaddr *addr, OCS_socklen_t len); +extern int OCS_getsockopt(int fd, int level, int optname, void *optval, OCS_socklen_t *optlen); +extern int OCS_listen(int fd, int n); +extern OCS_ssize_t OCS_recvfrom(int fd, void *buf, size_t n, int flags, struct OCS_sockaddr *addr, + OCS_socklen_t *addr_len); +extern OCS_ssize_t OCS_sendto(int fd, const void *buf, size_t n, int flags, const struct OCS_sockaddr *addr, + OCS_socklen_t addr_len); +extern int OCS_setsockopt(int fd, int level, int optname, const void *optval, OCS_socklen_t optlen); +extern int OCS_socket(int domain, int type, int protocol); #endif /* _OSAL_STUB_SYS_SOCKET_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_sys_time.h b/src/unit-test-coverage/ut-stubs/inc/OCS_sys_time.h index c1190dcf9..d510083df 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_sys_time.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_sys_time.h @@ -37,7 +37,4 @@ /* prototypes normally declared in sys/time.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_SYS_TIME_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_sys_times.h b/src/unit-test-coverage/ut-stubs/inc/OCS_sys_times.h index df9a3db5e..eb177637f 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_sys_times.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_sys_times.h @@ -37,7 +37,4 @@ /* prototypes normally declared in sys/times.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_SYS_TIMES_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_sys_types.h b/src/unit-test-coverage/ut-stubs/inc/OCS_sys_types.h index b9b42d90f..c9f8a5a3b 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_sys_types.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_sys_types.h @@ -31,19 +31,16 @@ /* ----------------------------------------- */ /* types normally defined in sys/types.h */ /* ----------------------------------------- */ -typedef ptrdiff_t OCS_ssize_t; -typedef long OCS_off_t; -typedef unsigned int OCS_mode_t; -typedef long OCS_time_t; -typedef int OCS_pid_t; -typedef int OCS_gid_t; -typedef int OCS_uid_t; +typedef ptrdiff_t OCS_ssize_t; +typedef long OCS_off_t; +typedef unsigned int OCS_mode_t; +typedef long OCS_time_t; +typedef int OCS_pid_t; +typedef int OCS_gid_t; +typedef int OCS_uid_t; /* ----------------------------------------- */ /* prototypes normally declared in sys/types.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_SYS_TYPES_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_sys_un.h b/src/unit-test-coverage/ut-stubs/inc/OCS_sys_un.h index 6fd8af769..1a1cdafb0 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_sys_un.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_sys_un.h @@ -36,7 +36,4 @@ /* prototypes normally declared in sys/un.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_SYS_UN_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_sys_wait.h b/src/unit-test-coverage/ut-stubs/inc/OCS_sys_wait.h index 40b3cfbbf..ceef2726d 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_sys_wait.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_sys_wait.h @@ -36,7 +36,4 @@ /* prototypes normally declared in sys/wait.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_SYS_WAIT_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_taskLib.h b/src/unit-test-coverage/ut-stubs/inc/OCS_taskLib.h index d569c6925..6760a41f0 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_taskLib.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_taskLib.h @@ -28,8 +28,7 @@ /* ----------------------------------------- */ /* constants normally defined in taskLib.h */ /* ----------------------------------------- */ -#define OCS_VX_FP_TASK 0x1b01 /* execute with floating-point coprocessor support. */ - +#define OCS_VX_FP_TASK 0x1b01 /* execute with floating-point coprocessor support. */ /* ----------------------------------------- */ /* types normally defined in taskLib.h */ @@ -39,14 +38,13 @@ typedef struct OCS_WIND_TCB int data; } OCS_WIND_TCB; -typedef struct OCS_WIND_TCB* OCS_TASK_ID; +typedef struct OCS_WIND_TCB *OCS_TASK_ID; typedef struct OCS_TASK_DESC { OCS_TASK_ID tid; } OCS_TASK_DESC; - /* ----------------------------------------- */ /* prototypes normally declared in taskInfo.h */ /* ----------------------------------------- */ @@ -54,62 +52,31 @@ typedef struct OCS_TASK_DESC extern const char *OCS_taskName(OCS_TASK_ID task_id); extern OCS_TASK_ID OCS_taskNameToId(const char *name); extern OCS_TASK_ID OCS_taskIdDefault(OCS_TASK_ID task_id); -extern OCS_BOOL OCS_taskIsReady(OCS_TASK_ID task_id); -extern OCS_BOOL OCS_taskIsSuspended (OCS_TASK_ID task_id); -extern OCS_STATUS OCS_taskGetInfo(OCS_TASK_ID task_id, OCS_TASK_DESC *desc); - - +extern OCS_BOOL OCS_taskIsReady(OCS_TASK_ID task_id); +extern OCS_BOOL OCS_taskIsSuspended(OCS_TASK_ID task_id); +extern OCS_STATUS OCS_taskGetInfo(OCS_TASK_ID task_id, OCS_TASK_DESC *desc); /* ----------------------------------------- */ /* prototypes normally declared in taskLib.h */ /* ----------------------------------------- */ -extern OCS_STATUS OCS_taskActivate(OCS_TASK_ID tid); -extern void OCS_taskExit(int code); +extern OCS_STATUS OCS_taskActivate(OCS_TASK_ID tid); +extern void OCS_taskExit(int code); extern OCS_TASK_ID OCS_taskIdSelf(void); -extern OCS_STATUS OCS_taskDelay(int ticks); -extern OCS_STATUS OCS_taskDelete(OCS_TASK_ID tid); -extern OCS_STATUS OCS_taskDeleteForce(OCS_TASK_ID tid); -extern OCS_STATUS OCS_taskSuspend(OCS_TASK_ID tid); -extern OCS_STATUS OCS_taskResume(OCS_TASK_ID tid); -extern OCS_STATUS OCS_taskPrioritySet(OCS_TASK_ID tid, int newPriority); -extern OCS_TASK_ID OCS_taskSpawn(char * name, - int priority, - int options, - int stackSize, - OCS_FUNCPTR entryPt, - int arg1, - int arg2, - int arg3, - int arg4, - int arg5, - int arg6, - int arg7, - int arg8, - int arg9, - int arg10); - -OCS_STATUS OCS_taskInit(OCS_WIND_TCB *pTcb, - char *name, - int priority, - int options, - char * pStackBase, - int stackSize, - OCS_FUNCPTR entryPt, - int arg1, - int arg2, - int arg3, - int arg4, - int arg5, - int arg6, - int arg7, - int arg8, - int arg9, - int arg10 -); +extern OCS_STATUS OCS_taskDelay(int ticks); +extern OCS_STATUS OCS_taskDelete(OCS_TASK_ID tid); +extern OCS_STATUS OCS_taskDeleteForce(OCS_TASK_ID tid); +extern OCS_STATUS OCS_taskSuspend(OCS_TASK_ID tid); +extern OCS_STATUS OCS_taskResume(OCS_TASK_ID tid); +extern OCS_STATUS OCS_taskPrioritySet(OCS_TASK_ID tid, int newPriority); +extern OCS_TASK_ID OCS_taskSpawn(char *name, int priority, int options, int stackSize, OCS_FUNCPTR entryPt, int arg1, + int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, + int arg10); + +OCS_STATUS OCS_taskInit(OCS_WIND_TCB *pTcb, char *name, int priority, int options, char *pStackBase, int stackSize, + OCS_FUNCPTR entryPt, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, + int arg8, int arg9, int arg10); OCS_WIND_TCB *OCS_taskTcb(OCS_TASK_ID tid); - #endif /* _OSAL_STUB_TASKLIB_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_taskVarLib.h b/src/unit-test-coverage/ut-stubs/inc/OCS_taskVarLib.h index 95b80810e..611e61d78 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_taskVarLib.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_taskVarLib.h @@ -39,7 +39,4 @@ extern OCS_STATUS OCS_taskVarAdd(int tid, int *pVar); - - #endif /* _OSAL_STUB_TASKVARLIB_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_termios.h b/src/unit-test-coverage/ut-stubs/inc/OCS_termios.h index b7474b1ec..69f91ddcd 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_termios.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_termios.h @@ -36,7 +36,4 @@ /* prototypes normally declared in termios.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_TERMIOS_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_tgmath.h b/src/unit-test-coverage/ut-stubs/inc/OCS_tgmath.h index d0ad520d3..d095228a5 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_tgmath.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_tgmath.h @@ -36,7 +36,4 @@ /* prototypes normally declared in tgmath.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_TGMATH_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_time.h b/src/unit-test-coverage/ut-stubs/inc/OCS_time.h index bafa00921..88decb45c 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_time.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_time.h @@ -29,31 +29,30 @@ /* constants normally defined in time.h */ /* ----------------------------------------- */ -#define OCS_CLOCK_REALTIME 0x1301 -#define OCS_CLOCK_MONOTONIC 0x1302 -#define OCS_TIMER_ABSTIME 0x1701 +#define OCS_CLOCK_REALTIME 0x1301 +#define OCS_CLOCK_MONOTONIC 0x1302 +#define OCS_TIMER_ABSTIME 0x1701 /* ----------------------------------------- */ /* types normally defined in time.h */ /* ----------------------------------------- */ -typedef int OCS_clockid_t; -typedef int OCS_timer_t; -typedef long OCS_suseconds_t; +typedef int OCS_clockid_t; +typedef int OCS_timer_t; +typedef long OCS_suseconds_t; struct OCS_timespec { OCS_time_t tv_sec; - long tv_nsec; + long tv_nsec; }; struct OCS_timeval { - OCS_time_t tv_sec; + OCS_time_t tv_sec; OCS_suseconds_t tv_usec; }; - struct OCS_itimerspec { struct OCS_timespec it_interval; @@ -67,17 +66,17 @@ typedef void (*OCS_TIMER_CONNECT_FUNC)(OCS_timer_t, int arg); /* prototypes normally declared in time.h */ /* ----------------------------------------- */ -extern int OCS_clock_getres (OCS_clockid_t clock_id, struct OCS_timespec * res); -extern int OCS_clock_gettime (OCS_clockid_t clock_id, struct OCS_timespec * tp); -extern int OCS_clock_nanosleep (OCS_clockid_t clock_id, int flags, const struct OCS_timespec * req, struct OCS_timespec * rem); -extern int OCS_clock_settime (OCS_clockid_t clock_id, const struct OCS_timespec * tp); -extern int OCS_timer_create (OCS_clockid_t clock_id, struct OCS_sigevent * evp, OCS_timer_t * timerid); -extern int OCS_timer_delete (OCS_timer_t timerid) ; -extern int OCS_timer_gettime (OCS_timer_t timerid, struct OCS_itimerspec * value); -extern int OCS_timer_settime (OCS_timer_t timerid, int flags, const struct OCS_itimerspec * value, struct OCS_itimerspec * ovalue); +extern int OCS_clock_getres(OCS_clockid_t clock_id, struct OCS_timespec *res); +extern int OCS_clock_gettime(OCS_clockid_t clock_id, struct OCS_timespec *tp); +extern int OCS_clock_nanosleep(OCS_clockid_t clock_id, int flags, const struct OCS_timespec *req, + struct OCS_timespec *rem); +extern int OCS_clock_settime(OCS_clockid_t clock_id, const struct OCS_timespec *tp); +extern int OCS_timer_create(OCS_clockid_t clock_id, struct OCS_sigevent *evp, OCS_timer_t *timerid); +extern int OCS_timer_delete(OCS_timer_t timerid); +extern int OCS_timer_gettime(OCS_timer_t timerid, struct OCS_itimerspec *value); +extern int OCS_timer_settime(OCS_timer_t timerid, int flags, const struct OCS_itimerspec *value, + struct OCS_itimerspec *ovalue); extern int OCS_timer_connect(OCS_timer_t timerid, OCS_TIMER_CONNECT_FUNC func, int arg); - #endif /* _OSAL_STUB_TIME_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_timers.h b/src/unit-test-coverage/ut-stubs/inc/OCS_timers.h index bb92ef2f6..6f1707626 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_timers.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_timers.h @@ -36,7 +36,4 @@ /* prototypes normally declared in timers.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_TIMERS_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_ulimit.h b/src/unit-test-coverage/ut-stubs/inc/OCS_ulimit.h index b3d576448..d2789d3ec 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_ulimit.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_ulimit.h @@ -37,6 +37,4 @@ /* ----------------------------------------- */ long OCS_ulimit(int cmd, long newlimit); - #endif /* _OSAL_STUB_ULIMIT_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_unistd.h b/src/unit-test-coverage/ut-stubs/inc/OCS_unistd.h index 361e50c00..43eb9b74c 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_unistd.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_unistd.h @@ -29,13 +29,12 @@ /* constants normally defined in unistd.h */ /* ----------------------------------------- */ -#define OCS_SEEK_SET 0x1C01 -#define OCS_SEEK_CUR 0x1C02 -#define OCS_SEEK_END 0x1C03 -#define OCS_STDIN_FILENO 0x1C04 -#define OCS_STDOUT_FILENO 0x1C05 -#define OCS_STDERR_FILENO 0x1C06 - +#define OCS_SEEK_SET 0x1C01 +#define OCS_SEEK_CUR 0x1C02 +#define OCS_SEEK_END 0x1C03 +#define OCS_STDIN_FILENO 0x1C04 +#define OCS_STDOUT_FILENO 0x1C05 +#define OCS_STDERR_FILENO 0x1C06 /* ----------------------------------------- */ /* types normally defined in unistd.h */ @@ -45,18 +44,16 @@ /* prototypes normally declared in unistd.h */ /* ----------------------------------------- */ -extern int OCS_close (int fd); -extern OCS_gid_t OCS_getegid (void); -extern OCS_uid_t OCS_geteuid (void); -extern long int OCS_gethostid (void); -extern int OCS_gethostname (char * name, size_t len); -extern OCS_pid_t OCS_getpid (void); -extern OCS_off_t OCS_lseek (int fd, OCS_off_t offset, int whence); -extern OCS_ssize_t OCS_read (int fd, void * buf, size_t nbytes); -extern int OCS_rmdir (const char * path); -extern long int OCS_sysconf (int name); -extern OCS_ssize_t OCS_write (int fd, const void * buf, size_t n); - +extern int OCS_close(int fd); +extern OCS_gid_t OCS_getegid(void); +extern OCS_uid_t OCS_geteuid(void); +extern long int OCS_gethostid(void); +extern int OCS_gethostname(char *name, size_t len); +extern OCS_pid_t OCS_getpid(void); +extern OCS_off_t OCS_lseek(int fd, OCS_off_t offset, int whence); +extern OCS_ssize_t OCS_read(int fd, void *buf, size_t nbytes); +extern int OCS_rmdir(const char *path); +extern long int OCS_sysconf(int name); +extern OCS_ssize_t OCS_write(int fd, const void *buf, size_t n); #endif /* _OSAL_STUB_UNISTD_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_unldLib.h b/src/unit-test-coverage/ut-stubs/inc/OCS_unldLib.h index cf692f3e8..ed4847847 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_unldLib.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_unldLib.h @@ -39,7 +39,4 @@ /* ----------------------------------------- */ extern OCS_STATUS OCS_unldByModuleId(OCS_MODULE_ID moduleId, int options); - - #endif /* _OSAL_STUB_UNLDLIB_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_usrLib.h b/src/unit-test-coverage/ut-stubs/inc/OCS_usrLib.h index 493f34e3f..0929b6049 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_usrLib.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_usrLib.h @@ -37,7 +37,4 @@ /* prototypes normally declared in usrLib.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_USRLIB_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_version.h b/src/unit-test-coverage/ut-stubs/inc/OCS_version.h index ccf1914d5..1839ce637 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_version.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_version.h @@ -36,7 +36,4 @@ /* prototypes normally declared in version.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_VERSION_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_vxWorks.h b/src/unit-test-coverage/ut-stubs/inc/OCS_vxWorks.h index 0bf48466d..cbb7f6c64 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_vxWorks.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_vxWorks.h @@ -22,7 +22,7 @@ * \file OCS_vxWorks.h * \ingroup ut-stubs * \author joseph.p.hickey@nasa.gov - * OSAL coverage stub replacement for vxWorks.h + * OSAL coverage stub replacement for vxWorks.h */ #ifndef INCLUDE_OCS_VXWORKS_H_ @@ -36,7 +36,7 @@ enum { OCS_ERROR = -1, - OCS_OK = 0 + OCS_OK = 0 }; enum @@ -45,22 +45,20 @@ enum OCS_NO_WAIT = 0 }; - - /* ----------------------------------------- */ /* types normally defined in vxWorks.h */ /* ----------------------------------------- */ -typedef int OCS_STATUS; -typedef bool OCS_BOOL; -typedef unsigned int OCS_UINT; -typedef int8_t OCS_INT8; -typedef uint8_t OCS_UINT8; -typedef int16_t OCS_INT16; -typedef uint16_t OCS_UINT16; -typedef int32_t OCS_INT32; -typedef uint32_t OCS_UINT32; +typedef int OCS_STATUS; +typedef bool OCS_BOOL; +typedef unsigned int OCS_UINT; +typedef int8_t OCS_INT8; +typedef uint8_t OCS_UINT8; +typedef int16_t OCS_INT16; +typedef uint16_t OCS_UINT16; +typedef int32_t OCS_INT32; +typedef uint32_t OCS_UINT32; -typedef long OCS_Vx_usr_arg_t; +typedef long OCS_Vx_usr_arg_t; /* Function pointers are used in many VxWorks modules. */ /* @@ -71,14 +69,11 @@ typedef long OCS_Vx_usr_arg_t; * is defined as a int argument. This means that application code * may need to cast it at the time of use (which is generally done anyway). */ -typedef int (*OCS_FUNCPTR)(int); -typedef void (*OCS_VOIDFUNCPTR)(void); - +typedef int (*OCS_FUNCPTR)(int); +typedef void (*OCS_VOIDFUNCPTR)(void); /* ----------------------------------------- */ /* prototypes normally declared in vxWorks.h */ /* ----------------------------------------- */ - -#endif /* INCLUDE_OCS_VXWORKS_H_ */ - +#endif /* INCLUDE_OCS_VXWORKS_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_wchar.h b/src/unit-test-coverage/ut-stubs/inc/OCS_wchar.h index 5717ff2cb..f2e667c26 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_wchar.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_wchar.h @@ -36,7 +36,4 @@ /* prototypes normally declared in wchar.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_WCHAR_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_wctype.h b/src/unit-test-coverage/ut-stubs/inc/OCS_wctype.h index 9b2fc5c5d..5fa115d55 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_wctype.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_wctype.h @@ -36,7 +36,4 @@ /* prototypes normally declared in wctype.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_WCTYPE_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_xbdBlkDev.h b/src/unit-test-coverage/ut-stubs/inc/OCS_xbdBlkDev.h index 56195b679..314ca080e 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_xbdBlkDev.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_xbdBlkDev.h @@ -29,7 +29,7 @@ /* ----------------------------------------- */ /* constants normally defined in xbdBlkDev.h */ /* ----------------------------------------- */ -#define OCS_NULLDEV ((OCS_device_t)0) +#define OCS_NULLDEV ((OCS_device_t)0) /* ----------------------------------------- */ /* types normally defined in xbdBlkDev.h */ @@ -39,10 +39,7 @@ typedef int OCS_device_t; /* ----------------------------------------- */ /* prototypes normally declared in xbdBlkDev.h */ /* ----------------------------------------- */ -extern OCS_device_t OCS_xbdBlkDevCreateSync (OCS_BLK_DEV *bd, const char *name); -extern OCS_STATUS OCS_xbdBlkDevDelete (OCS_device_t dev, OCS_BLK_DEV **ppbd); - - +extern OCS_device_t OCS_xbdBlkDevCreateSync(OCS_BLK_DEV *bd, const char *name); +extern OCS_STATUS OCS_xbdBlkDevDelete(OCS_device_t dev, OCS_BLK_DEV **ppbd); #endif /* _OSAL_STUB_XBDBLKDEV_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/inc/OCS_xbdRamDisk.h b/src/unit-test-coverage/ut-stubs/inc/OCS_xbdRamDisk.h index ba262e702..92bf6ba87 100644 --- a/src/unit-test-coverage/ut-stubs/inc/OCS_xbdRamDisk.h +++ b/src/unit-test-coverage/ut-stubs/inc/OCS_xbdRamDisk.h @@ -37,7 +37,4 @@ /* prototypes normally declared in xbdRamDisk.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_STUB_XBDRAMDISK_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/override_inc/arpa/inet.h b/src/unit-test-coverage/ut-stubs/override_inc/arpa/inet.h index ae267fd54..5c5a9f90d 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/arpa/inet.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/arpa/inet.h @@ -27,8 +27,7 @@ /* ----------------------------------------- */ /* mappings for declarations in arpa/inet.h */ /* ----------------------------------------- */ -#define inet_ntop OCS_inet_ntop -#define inet_pton OCS_inet_pton - +#define inet_ntop OCS_inet_ntop +#define inet_pton OCS_inet_pton #endif /* _OSAL_OVERRIDE_ARPA_INET_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/assert.h b/src/unit-test-coverage/ut-stubs/override_inc/assert.h index 6172d7f7e..6e889619e 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/assert.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/assert.h @@ -28,6 +28,6 @@ /* mappings for declarations in assert.h */ /* ----------------------------------------- */ -#define assert OCS_assert +#define assert OCS_assert #endif /* _OSAL_OVERRIDE_ASSERT_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/blkIo.h b/src/unit-test-coverage/ut-stubs/override_inc/blkIo.h index 272a7477e..645c242a6 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/blkIo.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/blkIo.h @@ -28,9 +28,8 @@ /* ---------------------------------------*/ /* mappings for declarations in blkIo.h */ /* ---------------------------------------*/ -#define NULLDEV OCS_NULLDEV -#define BLK_DEV OCS_BLK_DEV -#define BLK_DEV_ID OCS_BLK_DEV_ID - +#define NULLDEV OCS_NULLDEV +#define BLK_DEV OCS_BLK_DEV +#define BLK_DEV_ID OCS_BLK_DEV_ID #endif /* _OSAL_OVERRIDE_BLKIO_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/bsp-impl.h b/src/unit-test-coverage/ut-stubs/override_inc/bsp-impl.h index 5fddfa221..eadea5868 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/bsp-impl.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/bsp-impl.h @@ -43,5 +43,4 @@ END bsp-impl.h *********************/ -#endif /* INCLUDE_BSP_IMPL_H_ */ - +#endif /* INCLUDE_BSP_IMPL_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/cbioLib.h b/src/unit-test-coverage/ut-stubs/override_inc/cbioLib.h index a4b295f76..0310e8f77 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/cbioLib.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/cbioLib.h @@ -28,5 +28,4 @@ /* mappings for declarations in cbioLib.h */ /* ----------------------------------------- */ - #endif /* _OSAL_OVERRIDE_CBIOLIB_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/complex.h b/src/unit-test-coverage/ut-stubs/override_inc/complex.h index 1f59c47cc..941797e33 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/complex.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/complex.h @@ -28,5 +28,4 @@ /* mappings for declarations in complex.h */ /* ----------------------------------------- */ - #endif /* _OSAL_OVERRIDE_COMPLEX_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/ctype.h b/src/unit-test-coverage/ut-stubs/override_inc/ctype.h index c0f44da89..1a7903a0e 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/ctype.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/ctype.h @@ -28,6 +28,6 @@ /* mappings for declarations in ctype.h */ /* ----------------------------------------- */ -#define isgraph OCS_isgraph +#define isgraph OCS_isgraph #endif /* _OSAL_OVERRIDE_CTYPE_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/dirent.h b/src/unit-test-coverage/ut-stubs/override_inc/dirent.h index 6a742a07d..bbf7648a4 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/dirent.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/dirent.h @@ -28,11 +28,11 @@ /* mappings for declarations in dirent.h */ /* ----------------------------------------- */ -#define DIR OCS_DIR -#define dirent OCS_dirent -#define closedir OCS_closedir -#define opendir OCS_opendir -#define readdir OCS_readdir -#define rewinddir OCS_rewinddir +#define DIR OCS_DIR +#define dirent OCS_dirent +#define closedir OCS_closedir +#define opendir OCS_opendir +#define readdir OCS_readdir +#define rewinddir OCS_rewinddir #endif /* _OSAL_OVERRIDE_DIRENT_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/dlfcn.h b/src/unit-test-coverage/ut-stubs/override_inc/dlfcn.h index 943e9112b..02f9d57a0 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/dlfcn.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/dlfcn.h @@ -28,10 +28,9 @@ /* mappings for declarations in dlfcn.h */ /* ----------------------------------------- */ -#define dlclose OCS_dlclose -#define dlerror OCS_dlerror -#define dlopen OCS_dlopen -#define dlsym OCS_dlsym - +#define dlclose OCS_dlclose +#define dlerror OCS_dlerror +#define dlopen OCS_dlopen +#define dlsym OCS_dlsym #endif /* _OSAL_OVERRIDE_DLFCN_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/dosFsLib.h b/src/unit-test-coverage/ut-stubs/override_inc/dosFsLib.h index a651fb2f4..bc3935e57 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/dosFsLib.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/dosFsLib.h @@ -28,14 +28,12 @@ /* ----------------------------------------- */ /* mappings for declarations in dosFsLib.h */ /* ----------------------------------------- */ -#define DOS_CHK_ONLY OCS_DOS_CHK_ONLY -#define DOS_CHK_REPAIR OCS_DOS_CHK_REPAIR -#define DOS_CHK_VERB_0 OCS_DOS_CHK_VERB_0 -#define DOS_CHK_VERB_SILENT OCS_DOS_CHK_VERB_SILENT -#define DOS_OPT_BLANK OCS_DOS_OPT_BLANK - -#define dosFsVolFormat OCS_dosFsVolFormat - +#define DOS_CHK_ONLY OCS_DOS_CHK_ONLY +#define DOS_CHK_REPAIR OCS_DOS_CHK_REPAIR +#define DOS_CHK_VERB_0 OCS_DOS_CHK_VERB_0 +#define DOS_CHK_VERB_SILENT OCS_DOS_CHK_VERB_SILENT +#define DOS_OPT_BLANK OCS_DOS_OPT_BLANK +#define dosFsVolFormat OCS_dosFsVolFormat #endif /* _OSAL_OVERRIDE_DOSFSLIB_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/drv/hdisk/ataDrv.h b/src/unit-test-coverage/ut-stubs/override_inc/drv/hdisk/ataDrv.h index 90bd9821d..7aca05fd5 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/drv/hdisk/ataDrv.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/drv/hdisk/ataDrv.h @@ -29,8 +29,6 @@ /* ----------------------------------------- */ /* mappings for declarations in drv/hdisk/ataDrv.h */ /* ----------------------------------------- */ -#define ataDevCreate OCS_ataDevCreate - - +#define ataDevCreate OCS_ataDevCreate #endif /* _OSAL_OVERRIDE_DRV_HDISK_ATADRV_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/errno.h b/src/unit-test-coverage/ut-stubs/override_inc/errno.h index 189dc2d6b..ada97f87e 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/errno.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/errno.h @@ -34,6 +34,6 @@ #define ETIMEDOUT OCS_ETIMEDOUT #define ESPIPE OCS_ESPIPE -#define errno OCS_errno +#define errno OCS_errno #endif /* _OSAL_OVERRIDE_ERRNO_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/errnoLib.h b/src/unit-test-coverage/ut-stubs/override_inc/errnoLib.h index e1a6275eb..c28e22fbb 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/errnoLib.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/errnoLib.h @@ -25,11 +25,9 @@ #include #include - /* ----------------------------------------- */ /* mappings for declarations in errnoLib.h */ /* ----------------------------------------- */ -#define errnoGet OCS_errnoGet - +#define errnoGet OCS_errnoGet #endif /* _OSAL_OVERRIDE_ERRNOLIB_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/fcntl.h b/src/unit-test-coverage/ut-stubs/override_inc/fcntl.h index 791293d2d..e78b8b3a4 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/fcntl.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/fcntl.h @@ -27,31 +27,30 @@ /* ----------------------------------------- */ /* mappings for declarations in fcntl.h */ /* ----------------------------------------- */ -#define S_IXOTH OCS_S_IXOTH -#define S_IXGRP OCS_S_IXGRP -#define S_IXUSR OCS_S_IXUSR -#define S_IROTH OCS_S_IROTH -#define S_IRGRP OCS_S_IRGRP -#define S_IRUSR OCS_S_IRUSR -#define S_IWOTH OCS_S_IWOTH -#define S_IWGRP OCS_S_IWGRP -#define S_IWUSR OCS_S_IWUSR -#define S_IFDIR OCS_S_IFDIR -#define S_ISDIR(x) OCS_S_ISDIR(x) -#define O_RDONLY OCS_O_RDONLY -#define O_WRONLY OCS_O_WRONLY -#define O_RDWR OCS_O_RDWR -#define O_CREAT OCS_O_CREAT -#define O_TRUNC OCS_O_TRUNC -#define O_NONBLOCK OCS_O_NONBLOCK -#define F_GETFL OCS_F_GETFL -#define F_SETFL OCS_F_SETFL -#define F_GETFD OCS_F_GETFD -#define F_SETFD OCS_F_SETFD -#define F_DUPFD OCS_F_DUPFD - -#define fcntl OCS_fcntl -#define open OCS_open +#define S_IXOTH OCS_S_IXOTH +#define S_IXGRP OCS_S_IXGRP +#define S_IXUSR OCS_S_IXUSR +#define S_IROTH OCS_S_IROTH +#define S_IRGRP OCS_S_IRGRP +#define S_IRUSR OCS_S_IRUSR +#define S_IWOTH OCS_S_IWOTH +#define S_IWGRP OCS_S_IWGRP +#define S_IWUSR OCS_S_IWUSR +#define S_IFDIR OCS_S_IFDIR +#define S_ISDIR(x) OCS_S_ISDIR(x) +#define O_RDONLY OCS_O_RDONLY +#define O_WRONLY OCS_O_WRONLY +#define O_RDWR OCS_O_RDWR +#define O_CREAT OCS_O_CREAT +#define O_TRUNC OCS_O_TRUNC +#define O_NONBLOCK OCS_O_NONBLOCK +#define F_GETFL OCS_F_GETFL +#define F_SETFL OCS_F_SETFL +#define F_GETFD OCS_F_GETFD +#define F_SETFD OCS_F_SETFD +#define F_DUPFD OCS_F_DUPFD +#define fcntl OCS_fcntl +#define open OCS_open #endif /* _OSAL_OVERRIDE_FCNTL_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/fenv.h b/src/unit-test-coverage/ut-stubs/override_inc/fenv.h index 276a78fd4..f260c305b 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/fenv.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/fenv.h @@ -28,6 +28,4 @@ /* mappings for declarations in fenv.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_OVERRIDE_FENV_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/float.h b/src/unit-test-coverage/ut-stubs/override_inc/float.h index 426b77b76..22c3d745a 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/float.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/float.h @@ -28,5 +28,4 @@ /* mappings for declarations in float.h */ /* ----------------------------------------- */ - #endif /* _OSAL_OVERRIDE_FLOAT_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/hostLib.h b/src/unit-test-coverage/ut-stubs/override_inc/hostLib.h index 75f0b2d5c..5ac654f15 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/hostLib.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/hostLib.h @@ -32,11 +32,9 @@ #include #include - /* ----------------------------------------- */ /* mappings for declarations in hostLib.h */ /* ----------------------------------------- */ -#define hostGetByName OCS_hostGetByName - -#endif /* INCLUDE_HOSTLIB_H_ */ +#define hostGetByName OCS_hostGetByName +#endif /* INCLUDE_HOSTLIB_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/intLib.h b/src/unit-test-coverage/ut-stubs/override_inc/intLib.h index ffc2b5f7f..98b666ec6 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/intLib.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/intLib.h @@ -25,17 +25,15 @@ #include #include - /* ----------------------------------------- */ /* mappings for declarations in intLib.h */ /* ----------------------------------------- */ - -#define intConnect OCS_intConnect -#define intDisable OCS_intDisable -#define intEnable OCS_intEnable -#define intLock OCS_intLock -#define intUnlock OCS_intUnlock -#define INUM_TO_IVEC OCS_INUM_TO_IVEC +#define intConnect OCS_intConnect +#define intDisable OCS_intDisable +#define intEnable OCS_intEnable +#define intLock OCS_intLock +#define intUnlock OCS_intUnlock +#define INUM_TO_IVEC OCS_INUM_TO_IVEC #endif /* _OSAL_OVERRIDE_INTLIB_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/inttypes.h b/src/unit-test-coverage/ut-stubs/override_inc/inttypes.h index 714940c1c..95d44dd03 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/inttypes.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/inttypes.h @@ -28,5 +28,4 @@ /* mappings for declarations in inttypes.h */ /* ----------------------------------------- */ - #endif /* _OSAL_OVERRIDE_INTTYPES_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/ioLib.h b/src/unit-test-coverage/ut-stubs/override_inc/ioLib.h index 5fe25ee8b..aa8d04501 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/ioLib.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/ioLib.h @@ -25,14 +25,12 @@ #include #include - /* ----------------------------------------- */ /* mappings for declarations in ioLib.h */ /* ----------------------------------------- */ -#define FIOCHKDSK OCS_FIOCHKDSK -#define FIOUNMOUNT OCS_FIOUNMOUNT -#define ioctl OCS_ioctl - +#define FIOCHKDSK OCS_FIOCHKDSK +#define FIOUNMOUNT OCS_FIOUNMOUNT +#define ioctl OCS_ioctl #endif /* _OSAL_OVERRIDE_IOLIB_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/iv.h b/src/unit-test-coverage/ut-stubs/override_inc/iv.h index e60ac3005..af02ea147 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/iv.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/iv.h @@ -28,5 +28,4 @@ /* mappings for declarations in iv.h */ /* ----------------------------------------- */ - #endif /* _OSAL_OVERRIDE_IV_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/loadLib.h b/src/unit-test-coverage/ut-stubs/override_inc/loadLib.h index 804c697b5..cd8324ec6 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/loadLib.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/loadLib.h @@ -30,7 +30,6 @@ /* mappings for declarations in loadLib.h */ /* ----------------------------------------- */ -#define loadModule OCS_loadModule - +#define loadModule OCS_loadModule #endif /* _OSAL_OVERRIDE_LOADLIB_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/locale.h b/src/unit-test-coverage/ut-stubs/override_inc/locale.h index e49ed9d2a..124963b3f 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/locale.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/locale.h @@ -28,5 +28,4 @@ /* mappings for declarations in locale.h */ /* ----------------------------------------- */ - #endif /* _OSAL_OVERRIDE_LOCALE_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/logLib.h b/src/unit-test-coverage/ut-stubs/override_inc/logLib.h index 3500744ed..005a1eb4f 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/logLib.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/logLib.h @@ -29,6 +29,4 @@ /* mappings for declarations in logLib.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_OVERRIDE_LOGLIB_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/math.h b/src/unit-test-coverage/ut-stubs/override_inc/math.h index 4b12995b5..07d08024e 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/math.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/math.h @@ -28,5 +28,4 @@ /* mappings for declarations in math.h */ /* ----------------------------------------- */ - #endif /* _OSAL_OVERRIDE_MATH_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/memPartLib.h b/src/unit-test-coverage/ut-stubs/override_inc/memPartLib.h index c89b5c981..6c40c603e 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/memPartLib.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/memPartLib.h @@ -28,12 +28,11 @@ /* ----------------------------------------- */ /* mappings for declarations in memPartLib.h */ /* ----------------------------------------- */ -#define PART_ID OCS_PART_ID -#define MEM_PART_STATS OCS_MEM_PART_STATS +#define PART_ID OCS_PART_ID +#define MEM_PART_STATS OCS_MEM_PART_STATS #define memPartShow OCS_memPartShow #define memPartInfoGet OCS_memPartInfoGet #define memSysPartId OCS_memSysPartId - #endif /* _OSAL_OVERRIDE_MEMPARTLIB_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/moduleLib.h b/src/unit-test-coverage/ut-stubs/override_inc/moduleLib.h index 65333b93c..c92fd2e0c 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/moduleLib.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/moduleLib.h @@ -29,12 +29,9 @@ /* mappings for declarations in moduleLib.h */ /* ----------------------------------------- */ -#define MODULE_ID OCS_MODULE_ID -#define MODULE_INFO OCS_MODULE_INFO - -#define moduleInfoGet OCS_moduleInfoGet - +#define MODULE_ID OCS_MODULE_ID +#define MODULE_INFO OCS_MODULE_INFO +#define moduleInfoGet OCS_moduleInfoGet #endif /* _OSAL_OVERRIDE_MODULELIB_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/override_inc/mqueue.h b/src/unit-test-coverage/ut-stubs/override_inc/mqueue.h index 33f1875f0..44b6464b3 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/mqueue.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/mqueue.h @@ -29,15 +29,14 @@ /* mappings for declarations in mqueue.h */ /* ----------------------------------------- */ -#define mqd_t OCS_mqd_t -#define mq_attr OCS_mq_attr - -#define mq_close OCS_mq_close -#define mq_open OCS_mq_open -#define mq_receive OCS_mq_receive -#define mq_timedreceive OCS_mq_timedreceive -#define mq_timedsend OCS_mq_timedsend -#define mq_unlink OCS_mq_unlink +#define mqd_t OCS_mqd_t +#define mq_attr OCS_mq_attr +#define mq_close OCS_mq_close +#define mq_open OCS_mq_open +#define mq_receive OCS_mq_receive +#define mq_timedreceive OCS_mq_timedreceive +#define mq_timedsend OCS_mq_timedsend +#define mq_unlink OCS_mq_unlink #endif /* _OSAL_OVERRIDE_MQUEUE_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/msgQLib.h b/src/unit-test-coverage/ut-stubs/override_inc/msgQLib.h index f3e36e651..88a269e17 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/msgQLib.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/msgQLib.h @@ -29,18 +29,17 @@ /* ----------------------------------------- */ /* mappings for declarations in msgQLib.h */ /* ----------------------------------------- */ -#define MSG_Q_FIFO OCS_MSG_Q_FIFO -#define MSG_Q_PRIORITY OCS_MSG_Q_PRIORITY -#define WIND_MSG_Q_OPTION_MASK OCS_WIND_MSG_Q_OPTION_MASK -#define MSG_PRI_NORMAL OCS_MSG_PRI_NORMAL -#define MSG_PRI_URGENT OCS_MSG_PRI_URGENT +#define MSG_Q_FIFO OCS_MSG_Q_FIFO +#define MSG_Q_PRIORITY OCS_MSG_Q_PRIORITY +#define WIND_MSG_Q_OPTION_MASK OCS_WIND_MSG_Q_OPTION_MASK +#define MSG_PRI_NORMAL OCS_MSG_PRI_NORMAL +#define MSG_PRI_URGENT OCS_MSG_PRI_URGENT -#define MSG_Q_ID OCS_MSG_Q_ID +#define MSG_Q_ID OCS_MSG_Q_ID -#define msgQCreate OCS_msgQCreate -#define msgQDelete OCS_msgQDelete -#define msgQReceive OCS_msgQReceive -#define msgQSend OCS_msgQSend +#define msgQCreate OCS_msgQCreate +#define msgQDelete OCS_msgQDelete +#define msgQReceive OCS_msgQReceive +#define msgQSend OCS_msgQSend #endif /* _OSAL_OVERRIDE_MSGQLIB_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/override_inc/net/if.h b/src/unit-test-coverage/ut-stubs/override_inc/net/if.h index d8c0da590..e92f24a1c 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/net/if.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/net/if.h @@ -28,5 +28,4 @@ /* mappings for declarations in net/if.h */ /* ----------------------------------------- */ - #endif /* _OSAL_OVERRIDE_NET_IF_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/netdb.h b/src/unit-test-coverage/ut-stubs/override_inc/netdb.h index e308c14fa..cbc87575a 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/netdb.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/netdb.h @@ -28,6 +28,4 @@ /* mappings for declarations in netdb.h */ /* ----------------------------------------- */ - #endif /* _OSAL_OVERRIDE_NETDB_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/override_inc/netinet/in.h b/src/unit-test-coverage/ut-stubs/override_inc/netinet/in.h index 9b27c57ec..ddedb8e16 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/netinet/in.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/netinet/in.h @@ -28,10 +28,9 @@ /* mappings for declarations in netinet/in.h */ /* ----------------------------------------- */ -#define htons OCS_htons -#define ntohs OCS_ntohs -#define htonl OCS_htonl -#define ntohl OCS_ntohl - +#define htons OCS_htons +#define ntohs OCS_ntohs +#define htonl OCS_htonl +#define ntohl OCS_ntohl #endif /* _OSAL_OVERRIDE_NETINET_IN_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/netinet/tcp.h b/src/unit-test-coverage/ut-stubs/override_inc/netinet/tcp.h index 3fcb055ca..0aecd0f69 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/netinet/tcp.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/netinet/tcp.h @@ -28,5 +28,4 @@ /* mappings for declarations in netinet/tcp.h */ /* ----------------------------------------- */ - #endif /* _OSAL_OVERRIDE_NETINET_TCP_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/objLib.h b/src/unit-test-coverage/ut-stubs/override_inc/objLib.h index 288d56d14..e90e69c8d 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/objLib.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/objLib.h @@ -29,12 +29,11 @@ /* mappings for declarations in objLib.h */ /* ----------------------------------------- */ -#define M_objLib OCS_M_objLib -#define S_objLib_OBJ_ID_ERROR OCS_S_objLib_OBJ_ID_ERROR -#define S_objLib_OBJ_UNAVAILABLE OCS_S_objLib_OBJ_UNAVAILABLE -#define S_objLib_OBJ_DELETED OCS_S_objLib_OBJ_DELETED -#define S_objLib_OBJ_TIMEOUT OCS_S_objLib_OBJ_TIMEOUT -#define S_objLib_OBJ_NO_METHOD OCS_S_objLib_OBJ_NO_METHOD - +#define M_objLib OCS_M_objLib +#define S_objLib_OBJ_ID_ERROR OCS_S_objLib_OBJ_ID_ERROR +#define S_objLib_OBJ_UNAVAILABLE OCS_S_objLib_OBJ_UNAVAILABLE +#define S_objLib_OBJ_DELETED OCS_S_objLib_OBJ_DELETED +#define S_objLib_OBJ_TIMEOUT OCS_S_objLib_OBJ_TIMEOUT +#define S_objLib_OBJ_NO_METHOD OCS_S_objLib_OBJ_NO_METHOD #endif /* _OSAL_OVERRIDE_OBJLIB_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/poll.h b/src/unit-test-coverage/ut-stubs/override_inc/poll.h index af7229545..cbd8efe16 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/poll.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/poll.h @@ -28,5 +28,4 @@ /* mappings for declarations in poll.h */ /* ----------------------------------------- */ - #endif /* _OSAL_OVERRIDE_POLL_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/pthread.h b/src/unit-test-coverage/ut-stubs/override_inc/pthread.h index 35e7a449c..127afa071 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/pthread.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/pthread.h @@ -29,54 +29,51 @@ /* mappings for declarations in pthread.h */ /* ----------------------------------------- */ -#define PTHREAD_PRIO_INHERIT OCS_PTHREAD_PRIO_INHERIT -#define PTHREAD_MUTEX_RECURSIVE OCS_PTHREAD_MUTEX_RECURSIVE -#define PTHREAD_EXPLICIT_SCHED OCS_PTHREAD_EXPLICIT_SCHED - -#define pthread_t OCS_pthread_t -#define pthread_attr_t OCS_pthread_attr_t -#define pthread_mutex_t OCS_pthread_mutex_t -#define pthread_mutexattr_t OCS_pthread_mutexattr_t -#define pthread_cond_t OCS_pthread_cond_t -#define pthread_condattr_t OCS_pthread_condattr_t -#define pthread_key_t OCS_pthread_key_t - -#define pthread_attr_destroy OCS_pthread_attr_destroy -#define pthread_attr_getschedparam OCS_pthread_attr_getschedparam -#define pthread_attr_init OCS_pthread_attr_init -#define pthread_attr_setinheritsched OCS_pthread_attr_setinheritsched -#define pthread_attr_setschedparam OCS_pthread_attr_setschedparam -#define pthread_attr_setschedpolicy OCS_pthread_attr_setschedpolicy -#define pthread_attr_setstacksize OCS_pthread_attr_setstacksize -#define pthread_cancel OCS_pthread_cancel -#define pthread_cond_broadcast OCS_pthread_cond_broadcast -#define pthread_cond_destroy OCS_pthread_cond_destroy -#define pthread_cond_init OCS_pthread_cond_init -#define pthread_cond_signal OCS_pthread_cond_signal -#define pthread_cond_timedwait OCS_pthread_cond_timedwait -#define pthread_cond_wait OCS_pthread_cond_wait -#define pthread_create OCS_pthread_create -#define pthread_detach OCS_pthread_detach -#define pthread_equal OCS_pthread_equal -#define pthread_exit OCS_pthread_exit -#define pthread_getschedparam OCS_pthread_getschedparam -#define pthread_getspecific OCS_pthread_getspecific -#define pthread_key_create OCS_pthread_key_create -#define pthread_mutexattr_destroy OCS_pthread_mutexattr_destroy -#define pthread_mutexattr_init OCS_pthread_mutexattr_init -#define pthread_mutexattr_setprotocol OCS_pthread_mutexattr_setprotocol -#define pthread_mutexattr_settype OCS_pthread_mutexattr_settype -#define pthread_mutex_destroy OCS_pthread_mutex_destroy -#define pthread_mutex_init OCS_pthread_mutex_init -#define pthread_mutex_lock OCS_pthread_mutex_lock -#define pthread_mutex_unlock OCS_pthread_mutex_unlock -#define pthread_self OCS_pthread_self -#define pthread_setschedparam OCS_pthread_setschedparam -#define pthread_setschedprio OCS_pthread_setschedprio -#define pthread_setspecific OCS_pthread_setspecific -#define pthread_sigmask OCS_pthread_sigmask +#define PTHREAD_PRIO_INHERIT OCS_PTHREAD_PRIO_INHERIT +#define PTHREAD_MUTEX_RECURSIVE OCS_PTHREAD_MUTEX_RECURSIVE +#define PTHREAD_EXPLICIT_SCHED OCS_PTHREAD_EXPLICIT_SCHED +#define pthread_t OCS_pthread_t +#define pthread_attr_t OCS_pthread_attr_t +#define pthread_mutex_t OCS_pthread_mutex_t +#define pthread_mutexattr_t OCS_pthread_mutexattr_t +#define pthread_cond_t OCS_pthread_cond_t +#define pthread_condattr_t OCS_pthread_condattr_t +#define pthread_key_t OCS_pthread_key_t +#define pthread_attr_destroy OCS_pthread_attr_destroy +#define pthread_attr_getschedparam OCS_pthread_attr_getschedparam +#define pthread_attr_init OCS_pthread_attr_init +#define pthread_attr_setinheritsched OCS_pthread_attr_setinheritsched +#define pthread_attr_setschedparam OCS_pthread_attr_setschedparam +#define pthread_attr_setschedpolicy OCS_pthread_attr_setschedpolicy +#define pthread_attr_setstacksize OCS_pthread_attr_setstacksize +#define pthread_cancel OCS_pthread_cancel +#define pthread_cond_broadcast OCS_pthread_cond_broadcast +#define pthread_cond_destroy OCS_pthread_cond_destroy +#define pthread_cond_init OCS_pthread_cond_init +#define pthread_cond_signal OCS_pthread_cond_signal +#define pthread_cond_timedwait OCS_pthread_cond_timedwait +#define pthread_cond_wait OCS_pthread_cond_wait +#define pthread_create OCS_pthread_create +#define pthread_detach OCS_pthread_detach +#define pthread_equal OCS_pthread_equal +#define pthread_exit OCS_pthread_exit +#define pthread_getschedparam OCS_pthread_getschedparam +#define pthread_getspecific OCS_pthread_getspecific +#define pthread_key_create OCS_pthread_key_create +#define pthread_mutexattr_destroy OCS_pthread_mutexattr_destroy +#define pthread_mutexattr_init OCS_pthread_mutexattr_init +#define pthread_mutexattr_setprotocol OCS_pthread_mutexattr_setprotocol +#define pthread_mutexattr_settype OCS_pthread_mutexattr_settype +#define pthread_mutex_destroy OCS_pthread_mutex_destroy +#define pthread_mutex_init OCS_pthread_mutex_init +#define pthread_mutex_lock OCS_pthread_mutex_lock +#define pthread_mutex_unlock OCS_pthread_mutex_unlock +#define pthread_self OCS_pthread_self +#define pthread_setschedparam OCS_pthread_setschedparam +#define pthread_setschedprio OCS_pthread_setschedprio +#define pthread_setspecific OCS_pthread_setspecific +#define pthread_sigmask OCS_pthread_sigmask #endif /* _OSAL_OVERRIDE_PTHREAD_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/override_inc/ramDiskCbio.h b/src/unit-test-coverage/ut-stubs/override_inc/ramDiskCbio.h index 22dda2a2b..bb55400b7 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/ramDiskCbio.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/ramDiskCbio.h @@ -29,5 +29,4 @@ /* mappings for declarations in ramDiskCbio.h */ /* ----------------------------------------- */ - #endif /* _OSAL_OVERRIDE_RAMDISKCBIO_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/ramDrv.h b/src/unit-test-coverage/ut-stubs/override_inc/ramDrv.h index 0afbc2b3c..7e37959c7 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/ramDrv.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/ramDrv.h @@ -30,7 +30,6 @@ /* mappings for declarations in ramDrv.h */ /* ----------------------------------------- */ -#define ramDevCreate OCS_ramDevCreate - +#define ramDevCreate OCS_ramDevCreate #endif /* _OSAL_OVERRIDE_RAMDRV_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/sched.h b/src/unit-test-coverage/ut-stubs/override_inc/sched.h index 7d74885c8..1d2811ea9 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/sched.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/sched.h @@ -28,14 +28,12 @@ /* mappings for declarations in sched.h */ /* ----------------------------------------- */ -#define SCHED_FIFO OCS_SCHED_FIFO -#define SCHED_RR OCS_SCHED_RR +#define SCHED_FIFO OCS_SCHED_FIFO +#define SCHED_RR OCS_SCHED_RR -#define sched_param OCS_sched_param - -#define sched_get_priority_max OCS_sched_get_priority_max -#define sched_get_priority_min OCS_sched_get_priority_min +#define sched_param OCS_sched_param +#define sched_get_priority_max OCS_sched_get_priority_max +#define sched_get_priority_min OCS_sched_get_priority_min #endif /* _OSAL_OVERRIDE_SCHED_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/override_inc/selectLib.h b/src/unit-test-coverage/ut-stubs/override_inc/selectLib.h index 864659627..153bbf321 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/selectLib.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/selectLib.h @@ -35,6 +35,4 @@ /* mappings for declarations in selectLib.h */ /* ----------------------------------------- */ - -#endif /* INCLUDE_SELECTLIB_H_ */ - +#endif /* INCLUDE_SELECTLIB_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/semLib.h b/src/unit-test-coverage/ut-stubs/override_inc/semLib.h index 6e416b84c..f7704907b 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/semLib.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/semLib.h @@ -29,31 +29,29 @@ /* mappings for declarations in semLib.h */ /* ----------------------------------------- */ -#define VX_BINARY_SEMAPHORE(x) OCS_VX_BINARY_SEMAPHORE(x) -#define VX_COUNTING_SEMAPHORE(x) OCS_VX_COUNTING_SEMAPHORE(x) -#define VX_MUTEX_SEMAPHORE(x) OCS_VX_MUTEX_SEMAPHORE(x) - -#define SEM_ID OCS_SEM_ID -#define SEM_B_STATE OCS_SEM_B_STATE -#define SEM_EMPTY OCS_SEM_EMPTY -#define SEM_FULL OCS_SEM_FULL -#define SEM_Q_FIFO OCS_SEM_Q_FIFO -#define SEM_Q_PRIORITY OCS_SEM_Q_PRIORITY -#define SEM_DELETE_SAFE OCS_SEM_DELETE_SAFE -#define SEM_INVERSION_SAFE OCS_SEM_INVERSION_SAFE -#define SEM_EVENTSEND_ERR_NOTIFY OCS_SEM_EVENTSEND_ERR_NOTIFY - -#define semBInitialize OCS_semBInitialize -#define semBCreate OCS_semBCreate -#define semMInitialize OCS_semMInitialize -#define semMCreate OCS_semMCreate -#define semCInitialize OCS_semCInitialize -#define semCCreate OCS_semCCreate -#define semDelete OCS_semDelete -#define semFlush OCS_semFlush -#define semTake OCS_semTake -#define semGive OCS_semGive - - +#define VX_BINARY_SEMAPHORE(x) OCS_VX_BINARY_SEMAPHORE(x) +#define VX_COUNTING_SEMAPHORE(x) OCS_VX_COUNTING_SEMAPHORE(x) +#define VX_MUTEX_SEMAPHORE(x) OCS_VX_MUTEX_SEMAPHORE(x) + +#define SEM_ID OCS_SEM_ID +#define SEM_B_STATE OCS_SEM_B_STATE +#define SEM_EMPTY OCS_SEM_EMPTY +#define SEM_FULL OCS_SEM_FULL +#define SEM_Q_FIFO OCS_SEM_Q_FIFO +#define SEM_Q_PRIORITY OCS_SEM_Q_PRIORITY +#define SEM_DELETE_SAFE OCS_SEM_DELETE_SAFE +#define SEM_INVERSION_SAFE OCS_SEM_INVERSION_SAFE +#define SEM_EVENTSEND_ERR_NOTIFY OCS_SEM_EVENTSEND_ERR_NOTIFY + +#define semBInitialize OCS_semBInitialize +#define semBCreate OCS_semBCreate +#define semMInitialize OCS_semMInitialize +#define semMCreate OCS_semMCreate +#define semCInitialize OCS_semCInitialize +#define semCCreate OCS_semCCreate +#define semDelete OCS_semDelete +#define semFlush OCS_semFlush +#define semTake OCS_semTake +#define semGive OCS_semGive #endif /* _OSAL_OVERRIDE_SEMLIB_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/semaphore.h b/src/unit-test-coverage/ut-stubs/override_inc/semaphore.h index 00573a096..cf04b8636 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/semaphore.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/semaphore.h @@ -28,13 +28,12 @@ /* ----------------------------------------- */ /* mappings for declarations in semaphore.h */ /* ----------------------------------------- */ -#define sem_t OCS_sem_t -#define sem_destroy OCS_sem_destroy -#define sem_getvalue OCS_sem_getvalue -#define sem_init OCS_sem_init -#define sem_post OCS_sem_post -#define sem_timedwait OCS_sem_timedwait -#define sem_wait OCS_sem_wait - +#define sem_t OCS_sem_t +#define sem_destroy OCS_sem_destroy +#define sem_getvalue OCS_sem_getvalue +#define sem_init OCS_sem_init +#define sem_post OCS_sem_post +#define sem_timedwait OCS_sem_timedwait +#define sem_wait OCS_sem_wait #endif /* _OSAL_OVERRIDE_SEMAPHORE_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/setjmp.h b/src/unit-test-coverage/ut-stubs/override_inc/setjmp.h index d86a1adb2..bf56ccd51 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/setjmp.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/setjmp.h @@ -28,6 +28,4 @@ /* mappings for declarations in setjmp.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_OVERRIDE_SETJMP_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/shellLib.h b/src/unit-test-coverage/ut-stubs/override_inc/shellLib.h index 85bde9f83..d072d0fb3 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/shellLib.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/shellLib.h @@ -28,6 +28,6 @@ /* ----------------------------------------- */ /* mappings for declarations in shellLib.h */ /* ----------------------------------------- */ -#define shellGenericInit OCS_shellGenericInit +#define shellGenericInit OCS_shellGenericInit #endif /* _OSAL_OVERRIDE_SHELLLIB_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/signal.h b/src/unit-test-coverage/ut-stubs/override_inc/signal.h index c4eb76d9c..82ac74ae9 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/signal.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/signal.h @@ -28,33 +28,32 @@ /* mappings for declarations in signal.h */ /* ----------------------------------------- */ -#define SIG_SETMASK OCS_SIG_SETMASK -#define SIGHUP OCS_SIGHUP -#define SIGINT OCS_SIGINT -#define SIGABRT OCS_SIGABRT -#define SIGSEGV OCS_SIGSEGV -#define SIGBUS OCS_SIGBUS -#define SIGFPE OCS_SIGFPE -#define SIGILL OCS_SIGILL -#define SIGRTMIN OCS_SIGRTMIN -#define SIGRTMAX OCS_SIGRTMAX -#define SIGEV_SIGNAL OCS_SIGEV_SIGNAL - -#define sighandler_t OCS_sighandler_t -#define sigset_t OCS_sigset_t -#define sig_atomic_t OCS_sig_atomic_t -#define sigevent OCS_sigevent - - -#define kill OCS_kill -#define sigaddset OCS_sigaddset -#define sigdelset OCS_sigdelset -#define sigemptyset OCS_sigemptyset -#define sigfillset OCS_sigfillset -#define sigismember OCS_sigismember -#define signal OCS_signal -#define sigprocmask OCS_sigprocmask -#define sigsuspend OCS_sigsuspend -#define sigwait OCS_sigwait +#define SIG_SETMASK OCS_SIG_SETMASK +#define SIGHUP OCS_SIGHUP +#define SIGINT OCS_SIGINT +#define SIGABRT OCS_SIGABRT +#define SIGSEGV OCS_SIGSEGV +#define SIGBUS OCS_SIGBUS +#define SIGFPE OCS_SIGFPE +#define SIGILL OCS_SIGILL +#define SIGRTMIN OCS_SIGRTMIN +#define SIGRTMAX OCS_SIGRTMAX +#define SIGEV_SIGNAL OCS_SIGEV_SIGNAL + +#define sighandler_t OCS_sighandler_t +#define sigset_t OCS_sigset_t +#define sig_atomic_t OCS_sig_atomic_t +#define sigevent OCS_sigevent + +#define kill OCS_kill +#define sigaddset OCS_sigaddset +#define sigdelset OCS_sigdelset +#define sigemptyset OCS_sigemptyset +#define sigfillset OCS_sigfillset +#define sigismember OCS_sigismember +#define signal OCS_signal +#define sigprocmask OCS_sigprocmask +#define sigsuspend OCS_sigsuspend +#define sigwait OCS_sigwait #endif /* _OSAL_OVERRIDE_SIGNAL_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/stat.h b/src/unit-test-coverage/ut-stubs/override_inc/stat.h index 3f6a50577..b391c2c95 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/stat.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/stat.h @@ -28,18 +28,15 @@ /* mappings for declarations in sys/stat.h */ /* ----------------------------------------- */ -#define stat OCS_stat -#define fchmod OCS_fchmod -#define chmod OCS_chmod -#define mkdir OCS_mkdir - +#define stat OCS_stat +#define fchmod OCS_fchmod +#define chmod OCS_chmod +#define mkdir OCS_mkdir /* ----------------------------------------- */ /* mappings for declarations in sys/statvfs.h */ /* ----------------------------------------- */ -#define statvfs OCS_statvfs -#define statfs OCS_statvfs - - +#define statvfs OCS_statvfs +#define statfs OCS_statvfs #endif /* _OSAL_OVERRIDE_STAT_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/stdarg.h b/src/unit-test-coverage/ut-stubs/override_inc/stdarg.h index c3c34bfaa..50f84b773 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/stdarg.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/stdarg.h @@ -28,9 +28,8 @@ /* mappings for declarations in stdarg.h */ /* ----------------------------------------- */ -#define va_list OCS_va_list -#define va_start(ap, last) OCS_va_start(ap, last) -#define va_end(ap) OCS_va_end(ap) - +#define va_list OCS_va_list +#define va_start(ap, last) OCS_va_start(ap, last) +#define va_end(ap) OCS_va_end(ap) #endif /* _OSAL_OVERRIDE_STDARG_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/stdio.h b/src/unit-test-coverage/ut-stubs/override_inc/stdio.h index e2f56592c..ef1afa2c1 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/stdio.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/stdio.h @@ -28,22 +28,20 @@ /* mappings for declarations in stdio.h */ /* ----------------------------------------- */ -#define FILE OCS_FILE -#define fclose OCS_fclose -#define fgets OCS_fgets -#define fopen OCS_fopen -#define fputs OCS_fputs -#define remove OCS_remove -#define rename OCS_rename -#define snprintf OCS_snprintf -#define vsnprintf OCS_vsnprintf -#define printf(...) OCS_printf(__VA_ARGS__) -#define putchar OCS_putchar - -#define stdin OCS_stdin -#define stdout OCS_stdout -#define stderr OCS_stderr - +#define FILE OCS_FILE +#define fclose OCS_fclose +#define fgets OCS_fgets +#define fopen OCS_fopen +#define fputs OCS_fputs +#define remove OCS_remove +#define rename OCS_rename +#define snprintf OCS_snprintf +#define vsnprintf OCS_vsnprintf +#define printf(...) OCS_printf(__VA_ARGS__) +#define putchar OCS_putchar + +#define stdin OCS_stdin +#define stdout OCS_stdout +#define stderr OCS_stderr #endif /* _OSAL_OVERRIDE_STDIO_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/override_inc/stdlib.h b/src/unit-test-coverage/ut-stubs/override_inc/stdlib.h index d42035969..2d16d6cf2 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/stdlib.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/stdlib.h @@ -28,13 +28,12 @@ /* mappings for declarations in stdlib.h */ /* ----------------------------------------- */ -#define EXIT_SUCCESS OCS_EXIT_SUCCESS -#define EXIT_FAILURE OCS_EXIT_FAILURE -#define exit OCS_exit -#define strtoul OCS_strtoul -#define system OCS_system -#define malloc OCS_malloc -#define free OCS_free - +#define EXIT_SUCCESS OCS_EXIT_SUCCESS +#define EXIT_FAILURE OCS_EXIT_FAILURE +#define exit OCS_exit +#define strtoul OCS_strtoul +#define system OCS_system +#define malloc OCS_malloc +#define free OCS_free #endif /* _OSAL_OVERRIDE_STDLIB_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/string.h b/src/unit-test-coverage/ut-stubs/override_inc/string.h index 5a6cac69a..86b4d6046 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/string.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/string.h @@ -27,17 +27,17 @@ /* ----------------------------------------- */ /* mappings for declarations in string.h */ /* ----------------------------------------- */ -#define memcpy OCS_memcpy -#define memset OCS_memset -#define strcmp OCS_strcmp -#define strcpy OCS_strcpy -#define strlen OCS_strlen -#define strncmp OCS_strncmp -#define strncpy OCS_strncpy -#define strchr OCS_strchr -#define strrchr OCS_strrchr -#define strcat OCS_strcat -#define strncat OCS_strncat -#define strerror OCS_strerror +#define memcpy OCS_memcpy +#define memset OCS_memset +#define strcmp OCS_strcmp +#define strcpy OCS_strcpy +#define strlen OCS_strlen +#define strncmp OCS_strncmp +#define strncpy OCS_strncpy +#define strchr OCS_strchr +#define strrchr OCS_strrchr +#define strcat OCS_strcat +#define strncat OCS_strncat +#define strerror OCS_strerror #endif /* _OSAL_OVERRIDE_STRING_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/strings.h b/src/unit-test-coverage/ut-stubs/override_inc/strings.h index f95903aea..8e799498b 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/strings.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/strings.h @@ -28,5 +28,4 @@ /* mappings for declarations in strings.h */ /* ----------------------------------------- */ - #endif /* _OSAL_OVERRIDE_STRINGS_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/symLib.h b/src/unit-test-coverage/ut-stubs/override_inc/symLib.h index 886a3f3f6..8513fa755 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/symLib.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/symLib.h @@ -34,23 +34,21 @@ /* ----------------------------------------- */ /* mappings for declarations in symLib.h */ /* ----------------------------------------- */ -#define LOAD_ALL_SYMBOLS OCS_LOAD_ALL_SYMBOLS -#define SYM_FIND_BY_NAME OCS_SYM_FIND_BY_NAME - -#define SYM_TYPE OCS_SYM_TYPE -#define SYMTAB OCS_SYMTAB -#define SYMBOL OCS_SYMBOL -#define SYMTAB_ID OCS_SYMTAB_ID -#define SYMBOL_ID OCS_SYMBOL_ID -#define SYMBOL_DESC OCS_SYMBOL_DESC -#define SYM_GROUP OCS_SYM_GROUP -#define SYM_VALUE OCS_SYM_VALUE - -#define sysSymTbl OCS_sysSymTbl -#define symFindByName OCS_symFindByName -#define symEach OCS_symEach -#define symFind OCS_symFind - - -#endif /* INCLUDE_SYMLIB_H_ */ - +#define LOAD_ALL_SYMBOLS OCS_LOAD_ALL_SYMBOLS +#define SYM_FIND_BY_NAME OCS_SYM_FIND_BY_NAME + +#define SYM_TYPE OCS_SYM_TYPE +#define SYMTAB OCS_SYMTAB +#define SYMBOL OCS_SYMBOL +#define SYMTAB_ID OCS_SYMTAB_ID +#define SYMBOL_ID OCS_SYMBOL_ID +#define SYMBOL_DESC OCS_SYMBOL_DESC +#define SYM_GROUP OCS_SYM_GROUP +#define SYM_VALUE OCS_SYM_VALUE + +#define sysSymTbl OCS_sysSymTbl +#define symFindByName OCS_symFindByName +#define symEach OCS_symEach +#define symFind OCS_symFind + +#endif /* INCLUDE_SYMLIB_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/sys/ioctl.h b/src/unit-test-coverage/ut-stubs/override_inc/sys/ioctl.h index 0e40f6fc9..d0748e8a5 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/sys/ioctl.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/sys/ioctl.h @@ -30,5 +30,4 @@ #define ioctl OCS_ioctl - #endif /* _OSAL_OVERRIDE_SYS_IOCTL_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/sys/ipc.h b/src/unit-test-coverage/ut-stubs/override_inc/sys/ipc.h index d1f2dab9a..db1c81f5b 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/sys/ipc.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/sys/ipc.h @@ -28,5 +28,4 @@ /* mappings for declarations in sys/ipc.h */ /* ----------------------------------------- */ - #endif /* _OSAL_OVERRIDE_SYS_IPC_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/sys/mman.h b/src/unit-test-coverage/ut-stubs/override_inc/sys/mman.h index 8e853cc8e..675abaf7f 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/sys/mman.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/sys/mman.h @@ -28,15 +28,14 @@ /* mappings for declarations in sys/mman.h */ /* ----------------------------------------- */ -#define MAP_SHARED OCS_MAP_SHARED -#define MAP_PRIVATE OCS_MAP_PRIVATE -#define PROT_EXEC OCS_PROT_EXEC -#define PROT_READ OCS_PROT_READ -#define PROT_WRITE OCS_PROT_WRITE -#define PROT_NONE OCS_PROT_NONE -#define MAP_FIXED OCS_MAP_FIXED -#define mmap OCS_mmap -#define munmap OCS_munmap - +#define MAP_SHARED OCS_MAP_SHARED +#define MAP_PRIVATE OCS_MAP_PRIVATE +#define PROT_EXEC OCS_PROT_EXEC +#define PROT_READ OCS_PROT_READ +#define PROT_WRITE OCS_PROT_WRITE +#define PROT_NONE OCS_PROT_NONE +#define MAP_FIXED OCS_MAP_FIXED +#define mmap OCS_mmap +#define munmap OCS_munmap #endif /* _OSAL_OVERRIDE_SYS_MMAN_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/sys/select.h b/src/unit-test-coverage/ut-stubs/override_inc/sys/select.h index 3d2dbcebd..649137bdf 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/sys/select.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/sys/select.h @@ -42,13 +42,12 @@ /* mappings for declarations in sys/select.h */ /* ----------------------------------------- */ -#define fd_set OCS_fd_set -#define select OCS_select +#define fd_set OCS_fd_set +#define select OCS_select -#define FD_SET OCS_FD_SET -#define FD_ISSET OCS_FD_ISSET -#define FD_CLR OCS_FD_CLR -#define FD_ZERO OCS_FD_ZERO - -#endif /* INCLUDE_SELECT_H_ */ +#define FD_SET OCS_FD_SET +#define FD_ISSET OCS_FD_ISSET +#define FD_CLR OCS_FD_CLR +#define FD_ZERO OCS_FD_ZERO +#endif /* INCLUDE_SELECT_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/sys/signal.h b/src/unit-test-coverage/ut-stubs/override_inc/sys/signal.h index 981c6a1cc..e3d401b9f 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/sys/signal.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/sys/signal.h @@ -25,5 +25,4 @@ /* alias to signal.h */ #include - #endif /* _OSAL_OVERRIDE_SYS_SIGNAL_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/sys/socket.h b/src/unit-test-coverage/ut-stubs/override_inc/sys/socket.h index 20e2d6fb8..bb1ef7309 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/sys/socket.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/sys/socket.h @@ -27,18 +27,16 @@ /* ----------------------------------------- */ /* mappings for declarations in sys/socket.h */ /* ----------------------------------------- */ -#define socklen_t OCS_socklen_t -#define sockaddr OCS_sockaddr -#define accept OCS_accept -#define bind OCS_bind -#define connect OCS_connect -#define getsockopt OCS_getsockopt -#define listen OCS_listen -#define recvfrom OCS_recvfrom -#define sendto OCS_sendto -#define setsockopt OCS_setsockopt -#define socket OCS_socket - +#define socklen_t OCS_socklen_t +#define sockaddr OCS_sockaddr +#define accept OCS_accept +#define bind OCS_bind +#define connect OCS_connect +#define getsockopt OCS_getsockopt +#define listen OCS_listen +#define recvfrom OCS_recvfrom +#define sendto OCS_sendto +#define setsockopt OCS_setsockopt +#define socket OCS_socket #endif /* _OSAL_OVERRIDE_SYS_SOCKET_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/override_inc/sys/stat.h b/src/unit-test-coverage/ut-stubs/override_inc/sys/stat.h index 7e5424789..a63bfc525 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/sys/stat.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/sys/stat.h @@ -25,5 +25,4 @@ /* alias to stat.h */ #include - #endif /* _OSAL_OVERRIDE_SYS_STAT_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/sys/statvfs.h b/src/unit-test-coverage/ut-stubs/override_inc/sys/statvfs.h index 2faf5d447..feb6fa97d 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/sys/statvfs.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/sys/statvfs.h @@ -25,5 +25,4 @@ /* alias to stat.h */ #include - #endif /* _OSAL_OVERRIDE_SYS_STATVFS_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/sys/time.h b/src/unit-test-coverage/ut-stubs/override_inc/sys/time.h index ecbb323b5..d327024cb 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/sys/time.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/sys/time.h @@ -29,5 +29,4 @@ /* mappings for declarations in sys/time.h */ /* ----------------------------------------- */ - #endif /* _OSAL_OVERRIDE_SYS_TIME_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/sys/times.h b/src/unit-test-coverage/ut-stubs/override_inc/sys/times.h index 6851444ef..e4c6626c7 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/sys/times.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/sys/times.h @@ -29,5 +29,4 @@ /* mappings for declarations in sys/times.h */ /* ----------------------------------------- */ - #endif /* _OSAL_OVERRIDE_SYS_TIMES_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/sys/types.h b/src/unit-test-coverage/ut-stubs/override_inc/sys/types.h index 69df77f16..50ef43ffa 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/sys/types.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/sys/types.h @@ -27,11 +27,11 @@ /* ----------------------------------------- */ /* mappings for declarations in sys/types.h */ /* ----------------------------------------- */ -#define ssize_t OCS_ssize_t -#define off_t OCS_off_t -#define mode_t OCS_mode_t -#define pid_t OCS_pid_t -#define gid_t OCS_gid_t -#define uid_t OCS_uid_t +#define ssize_t OCS_ssize_t +#define off_t OCS_off_t +#define mode_t OCS_mode_t +#define pid_t OCS_pid_t +#define gid_t OCS_gid_t +#define uid_t OCS_uid_t #endif /* _OSAL_OVERRIDE_SYS_TYPES_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/sys/un.h b/src/unit-test-coverage/ut-stubs/override_inc/sys/un.h index 0f1893fde..7f093ac5c 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/sys/un.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/sys/un.h @@ -28,7 +28,4 @@ /* mappings for declarations in sys/un.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_OVERRIDE_SYS_UN_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/override_inc/sys/wait.h b/src/unit-test-coverage/ut-stubs/override_inc/sys/wait.h index 295991fb0..358781c80 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/sys/wait.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/sys/wait.h @@ -28,6 +28,4 @@ /* mappings for declarations in sys/wait.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_OVERRIDE_SYS_WAIT_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/sysLib.h b/src/unit-test-coverage/ut-stubs/override_inc/sysLib.h index 24ebcabbd..06363364e 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/sysLib.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/sysLib.h @@ -28,7 +28,6 @@ /* ----------------------------------------- */ /* mappings for declarations in sysLib.h */ /* ----------------------------------------- */ -#define sysClkRateGet OCS_sysClkRateGet - +#define sysClkRateGet OCS_sysClkRateGet #endif /* _OSAL_OVERRIDE_SYSLIB_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/taskLib.h b/src/unit-test-coverage/ut-stubs/override_inc/taskLib.h index 01e1a1d9d..625923443 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/taskLib.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/taskLib.h @@ -28,30 +28,29 @@ /* ----------------------------------------- */ /* mappings for declarations in taskLib.h */ /* ----------------------------------------- */ -#define VX_FP_TASK OCS_VX_FP_TASK -#define TASK_ID OCS_TASK_ID -#define WIND_TCB OCS_WIND_TCB -#define TASK_DESC OCS_TASK_DESC +#define VX_FP_TASK OCS_VX_FP_TASK +#define TASK_ID OCS_TASK_ID +#define WIND_TCB OCS_WIND_TCB +#define TASK_DESC OCS_TASK_DESC -#define taskName OCS_taskName -#define taskNameToId OCS_taskNameToId -#define taskIdDefault OCS_taskIdDefault -#define taskIsReady OCS_taskIsReady -#define taskIsSuspended OCS_taskIsSuspended -#define taskGetInfo OCS_taskGetInfo - -#define taskActivate OCS_taskActivate -#define taskExit OCS_taskExit -#define taskIdSelf OCS_taskIdSelf -#define taskDelay OCS_taskDelay -#define taskDelete OCS_taskDelete -#define taskDeleteForce OCS_taskDeleteForce -#define taskSuspend OCS_taskSuspend -#define taskResume OCS_taskResume -#define taskPrioritySet OCS_taskPrioritySet -#define taskSpawn OCS_taskSpawn -#define taskInit OCS_taskInit -#define taskTcb OCS_taskTcb +#define taskName OCS_taskName +#define taskNameToId OCS_taskNameToId +#define taskIdDefault OCS_taskIdDefault +#define taskIsReady OCS_taskIsReady +#define taskIsSuspended OCS_taskIsSuspended +#define taskGetInfo OCS_taskGetInfo +#define taskActivate OCS_taskActivate +#define taskExit OCS_taskExit +#define taskIdSelf OCS_taskIdSelf +#define taskDelay OCS_taskDelay +#define taskDelete OCS_taskDelete +#define taskDeleteForce OCS_taskDeleteForce +#define taskSuspend OCS_taskSuspend +#define taskResume OCS_taskResume +#define taskPrioritySet OCS_taskPrioritySet +#define taskSpawn OCS_taskSpawn +#define taskInit OCS_taskInit +#define taskTcb OCS_taskTcb #endif /* _OSAL_OVERRIDE_TASKLIB_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/taskVarLib.h b/src/unit-test-coverage/ut-stubs/override_inc/taskVarLib.h index c3016df42..470bafd88 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/taskVarLib.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/taskVarLib.h @@ -29,8 +29,6 @@ /* mappings for declarations in taskVarLib.h */ /* ----------------------------------------- */ -#define taskVarAdd OCS_taskVarAdd - - +#define taskVarAdd OCS_taskVarAdd #endif /* _OSAL_OVERRIDE_TASKVARLIB_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/termios.h b/src/unit-test-coverage/ut-stubs/override_inc/termios.h index d82946532..fbab2171d 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/termios.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/termios.h @@ -28,5 +28,4 @@ /* mappings for declarations in termios.h */ /* ----------------------------------------- */ - #endif /* _OSAL_OVERRIDE_TERMIOS_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/tgmath.h b/src/unit-test-coverage/ut-stubs/override_inc/tgmath.h index 4c315ad29..0643ca2bd 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/tgmath.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/tgmath.h @@ -28,6 +28,4 @@ /* mappings for declarations in tgmath.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_OVERRIDE_TGMATH_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/time.h b/src/unit-test-coverage/ut-stubs/override_inc/time.h index 15a9b6d03..67e0cf09e 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/time.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/time.h @@ -28,29 +28,27 @@ /* mappings for declarations in time.h */ /* ----------------------------------------- */ -#define CLOCK_REALTIME OCS_CLOCK_REALTIME -#define CLOCK_MONOTONIC OCS_CLOCK_MONOTONIC -#define TIMER_ABSTIME OCS_TIMER_ABSTIME - -#define clockid_t OCS_clockid_t -#define timer_t OCS_timer_t -#define time_t OCS_time_t -#define suseconds_t OCS_suseconds_t -#define timespec OCS_timespec -#define timeval OCS_timeval -#define itimerspec OCS_itimerspec -#define TIMER_CONNECT_FUNC OCS_TIMER_CONNECT_FUNC - -#define clock_getres OCS_clock_getres -#define clock_gettime OCS_clock_gettime -#define clock_nanosleep OCS_clock_nanosleep -#define clock_settime OCS_clock_settime -#define timer_create OCS_timer_create -#define timer_delete OCS_timer_delete -#define timer_gettime OCS_timer_gettime -#define timer_settime OCS_timer_settime -#define timer_connect OCS_timer_connect - +#define CLOCK_REALTIME OCS_CLOCK_REALTIME +#define CLOCK_MONOTONIC OCS_CLOCK_MONOTONIC +#define TIMER_ABSTIME OCS_TIMER_ABSTIME + +#define clockid_t OCS_clockid_t +#define timer_t OCS_timer_t +#define time_t OCS_time_t +#define suseconds_t OCS_suseconds_t +#define timespec OCS_timespec +#define timeval OCS_timeval +#define itimerspec OCS_itimerspec +#define TIMER_CONNECT_FUNC OCS_TIMER_CONNECT_FUNC + +#define clock_getres OCS_clock_getres +#define clock_gettime OCS_clock_gettime +#define clock_nanosleep OCS_clock_nanosleep +#define clock_settime OCS_clock_settime +#define timer_create OCS_timer_create +#define timer_delete OCS_timer_delete +#define timer_gettime OCS_timer_gettime +#define timer_settime OCS_timer_settime +#define timer_connect OCS_timer_connect #endif /* _OSAL_OVERRIDE_TIME_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/override_inc/timers.h b/src/unit-test-coverage/ut-stubs/override_inc/timers.h index 168c81fec..eae5889c6 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/timers.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/timers.h @@ -29,5 +29,4 @@ * Note: this is just an alias for time.h */ - #endif /* _OSAL_OVERRIDE_TIMERS_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/ulimit.h b/src/unit-test-coverage/ut-stubs/override_inc/ulimit.h index 28bd6ad8f..7a26b4009 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/ulimit.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/ulimit.h @@ -24,11 +24,9 @@ #include - /* ----------------------------------------- */ /* mappings for declarations in ulimit.h */ /* ----------------------------------------- */ -#define ulimit OCS_ulimit - +#define ulimit OCS_ulimit #endif /* _OSAL_OVERRIDE_ULIMIT_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/unistd.h b/src/unit-test-coverage/ut-stubs/override_inc/unistd.h index 3722e16e7..2f77e11a6 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/unistd.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/unistd.h @@ -28,25 +28,23 @@ /* mappings for declarations in unistd.h */ /* ----------------------------------------- */ -#define SEEK_SET OCS_SEEK_SET -#define SEEK_CUR OCS_SEEK_CUR -#define SEEK_END OCS_SEEK_END -#define STDIN_FILENO OCS_STDIN_FILENO -#define STDOUT_FILENO OCS_STDOUT_FILENO -#define STDERR_FILENO OCS_STDERR_FILENO - -#define close OCS_close -#define getegid OCS_getegid -#define geteuid OCS_geteuid -#define gethostid OCS_gethostid -#define gethostname OCS_gethostname -#define getpid OCS_getpid -#define lseek OCS_lseek -#define read OCS_read -#define rmdir OCS_rmdir -#define sysconf OCS_sysconf -#define write OCS_write - +#define SEEK_SET OCS_SEEK_SET +#define SEEK_CUR OCS_SEEK_CUR +#define SEEK_END OCS_SEEK_END +#define STDIN_FILENO OCS_STDIN_FILENO +#define STDOUT_FILENO OCS_STDOUT_FILENO +#define STDERR_FILENO OCS_STDERR_FILENO + +#define close OCS_close +#define getegid OCS_getegid +#define geteuid OCS_geteuid +#define gethostid OCS_gethostid +#define gethostname OCS_gethostname +#define getpid OCS_getpid +#define lseek OCS_lseek +#define read OCS_read +#define rmdir OCS_rmdir +#define sysconf OCS_sysconf +#define write OCS_write #endif /* _OSAL_OVERRIDE_UNISTD_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/override_inc/unldLib.h b/src/unit-test-coverage/ut-stubs/override_inc/unldLib.h index 4ea98eac7..ed7fb77f7 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/unldLib.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/unldLib.h @@ -29,7 +29,6 @@ /* ----------------------------------------- */ /* mappings for declarations in unldLib.h */ /* ----------------------------------------- */ -#define unldByModuleId OCS_unldByModuleId - +#define unldByModuleId OCS_unldByModuleId #endif /* _OSAL_OVERRIDE_UNLDLIB_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/usrLib.h b/src/unit-test-coverage/ut-stubs/override_inc/usrLib.h index 17eb05464..7d1eda6b1 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/usrLib.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/usrLib.h @@ -29,6 +29,4 @@ /* mappings for declarations in usrLib.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_OVERRIDE_USRLIB_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/vxWorks.h b/src/unit-test-coverage/ut-stubs/override_inc/vxWorks.h index d5821aad1..1c9572df7 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/vxWorks.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/vxWorks.h @@ -33,27 +33,24 @@ /* ----------------------------------------- */ /* mappings for declarations in vxWorks.h */ /* ----------------------------------------- */ -#define ERROR OCS_ERROR -#define OK OCS_OK -#define WAIT_FOREVER OCS_WAIT_FOREVER -#define NO_WAIT OCS_NO_WAIT - - -#define STATUS OCS_STATUS -#define BOOL OCS_BOOL -#define FUNCPTR OCS_FUNCPTR -#define VOIDFUNCPTR OCS_VOIDFUNCPTR - -#define UINT OCS_UINT -#define INT8 OCS_INT8 -#define UINT8 OCS_UINT8 -#define INT16 OCS_INT16 -#define UINT16 OCS_UINT16 -#define INT32 OCS_INT32 -#define UINT32 OCS_UINT32 - -#define _Vx_usr_arg_t OCS_Vx_usr_arg_t - - -#endif /* INCLUDE_VXWORKS_H_ */ - +#define ERROR OCS_ERROR +#define OK OCS_OK +#define WAIT_FOREVER OCS_WAIT_FOREVER +#define NO_WAIT OCS_NO_WAIT + +#define STATUS OCS_STATUS +#define BOOL OCS_BOOL +#define FUNCPTR OCS_FUNCPTR +#define VOIDFUNCPTR OCS_VOIDFUNCPTR + +#define UINT OCS_UINT +#define INT8 OCS_INT8 +#define UINT8 OCS_UINT8 +#define INT16 OCS_INT16 +#define UINT16 OCS_UINT16 +#define INT32 OCS_INT32 +#define UINT32 OCS_UINT32 + +#define _Vx_usr_arg_t OCS_Vx_usr_arg_t + +#endif /* INCLUDE_VXWORKS_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/wchar.h b/src/unit-test-coverage/ut-stubs/override_inc/wchar.h index e84c90ffe..00f72b272 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/wchar.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/wchar.h @@ -28,6 +28,4 @@ /* mappings for declarations in wchar.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_OVERRIDE_WCHAR_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/wctype.h b/src/unit-test-coverage/ut-stubs/override_inc/wctype.h index 50f273351..cc2d3fbc3 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/wctype.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/wctype.h @@ -28,6 +28,4 @@ /* mappings for declarations in wctype.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_OVERRIDE_WCTYPE_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/override_inc/xbdBlkDev.h b/src/unit-test-coverage/ut-stubs/override_inc/xbdBlkDev.h index 2629877ca..03bf58d16 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/xbdBlkDev.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/xbdBlkDev.h @@ -30,12 +30,9 @@ /* mappings for declarations in xbdBlkDev.h */ /* ----------------------------------------- */ -#define NULLDEV OCS_NULLDEV -#define device_t OCS_device_t -#define xbdBlkDevCreateSync OCS_xbdBlkDevCreateSync -#define xbdBlkDevDelete OCS_xbdBlkDevDelete - - +#define NULLDEV OCS_NULLDEV +#define device_t OCS_device_t +#define xbdBlkDevCreateSync OCS_xbdBlkDevCreateSync +#define xbdBlkDevDelete OCS_xbdBlkDevDelete #endif /* _OSAL_OVERRIDE_XBDBLKDEV_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/override_inc/xbdRamDisk.h b/src/unit-test-coverage/ut-stubs/override_inc/xbdRamDisk.h index 7a373139d..4b01cf054 100644 --- a/src/unit-test-coverage/ut-stubs/override_inc/xbdRamDisk.h +++ b/src/unit-test-coverage/ut-stubs/override_inc/xbdRamDisk.h @@ -29,6 +29,4 @@ /* mappings for declarations in xbdRamDisk.h */ /* ----------------------------------------- */ - - #endif /* _OSAL_OVERRIDE_XBDRAMDISK_H_ */ diff --git a/src/unit-test-coverage/ut-stubs/src/bsd-select-stubs.c b/src/unit-test-coverage/ut-stubs/src/bsd-select-stubs.c index 649ebff66..1495272ab 100644 --- a/src/unit-test-coverage/ut-stubs/src/bsd-select-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/bsd-select-stubs.c @@ -32,7 +32,7 @@ #include -int OCS_select (int nfds, OCS_fd_set * readfds, OCS_fd_set * writefds, OCS_fd_set * exceptfds, struct OCS_timeval * timeout) +int OCS_select(int nfds, OCS_fd_set *readfds, OCS_fd_set *writefds, OCS_fd_set *exceptfds, struct OCS_timeval *timeout) { return UT_DEFAULT_IMPL_RC(OCS_select, 1); } @@ -56,4 +56,3 @@ void OCS_FD_ZERO(OCS_fd_set *set) { UT_DEFAULT_IMPL(OCS_FD_ZERO); } - diff --git a/src/unit-test-coverage/ut-stubs/src/bsp-console-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/bsp-console-impl-stubs.c index 89b704a6c..23aeb900c 100644 --- a/src/unit-test-coverage/ut-stubs/src/bsp-console-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/bsp-console-impl-stubs.c @@ -78,4 +78,3 @@ void OCS_OS_BSP_ConsoleSetMode_Impl(uint32_t ModeBits) UT_Stub_CopyFromLocal(UT_KEY(OCS_OS_BSP_ConsoleSetMode_Impl), &ModeBits, sizeof(ModeBits)); } } - diff --git a/src/unit-test-coverage/ut-stubs/src/libc-ctype-stubs.c b/src/unit-test-coverage/ut-stubs/src/libc-ctype-stubs.c index 167d852f1..1ad576121 100644 --- a/src/unit-test-coverage/ut-stubs/src/libc-ctype-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/libc-ctype-stubs.c @@ -28,4 +28,3 @@ int OCS_isgraph(int c) { return UT_DEFAULT_IMPL_RC(OCS_isgraph, isgraph(c)); } - diff --git a/src/unit-test-coverage/ut-stubs/src/libc-stdio-stubs.c b/src/unit-test-coverage/ut-stubs/src/libc-stdio-stubs.c index d521f363e..aa67f8aa2 100644 --- a/src/unit-test-coverage/ut-stubs/src/libc-stdio-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/libc-stdio-stubs.c @@ -31,9 +31,9 @@ struct OCS_FILE int f; }; -#define OCS_STDIO_MAX_SIZE 0x01000000 +#define OCS_STDIO_MAX_SIZE 0x01000000 -int OCS_fclose (OCS_FILE * stream) +int OCS_fclose(OCS_FILE *stream) { int32 Status; @@ -42,9 +42,9 @@ int OCS_fclose (OCS_FILE * stream) return Status; } -char *OCS_fgets (char * s, int n, OCS_FILE * stream) +char *OCS_fgets(char *s, int n, OCS_FILE *stream) { - int32 Status; + int32 Status; uint32 CopySize; Status = UT_DEFAULT_IMPL_RC(OCS_fgets, OCS_STDIO_MAX_SIZE); @@ -89,11 +89,11 @@ char *OCS_fgets (char * s, int n, OCS_FILE * stream) return s; } -OCS_FILE *OCS_fopen (const char * filename, const char * modes) +OCS_FILE *OCS_fopen(const char *filename, const char *modes) { - int32 Status; - OCS_FILE *retval; - static OCS_FILE FOPEN_FP = { 0 }; + int32 Status; + OCS_FILE * retval; + static OCS_FILE FOPEN_FP = {0}; Status = UT_DEFAULT_IMPL(OCS_fopen); @@ -109,7 +109,7 @@ OCS_FILE *OCS_fopen (const char * filename, const char * modes) return retval; } -int OCS_fputs (const char * s, OCS_FILE * stream) +int OCS_fputs(const char *s, OCS_FILE *stream) { int32 Status; @@ -118,7 +118,7 @@ int OCS_fputs (const char * s, OCS_FILE * stream) return Status; } -int OCS_putchar (int c) +int OCS_putchar(int c) { int32 Status; @@ -127,8 +127,7 @@ int OCS_putchar (int c) return Status; } - -int OCS_remove (const char * filename) +int OCS_remove(const char *filename) { int32 Status; @@ -137,7 +136,7 @@ int OCS_remove (const char * filename) return Status; } -int OCS_rename (const char * old, const char * nw) +int OCS_rename(const char *old, const char *nw) { int32 Status; @@ -146,10 +145,10 @@ int OCS_rename (const char * old, const char * nw) return Status; } -int OCS_snprintf (char * s, size_t maxlen, const char * format, ...) +int OCS_snprintf(char *s, size_t maxlen, const char *format, ...) { - int32 Status; - int actual = 0; + int32 Status; + int actual = 0; va_list ap; Status = UT_DEFAULT_IMPL(OCS_snprintf); @@ -158,7 +157,7 @@ int OCS_snprintf (char * s, size_t maxlen, const char * format, ...) if (Status >= 0) { va_start(ap, format); - actual = vsnprintf(s,maxlen,format,ap); + actual = vsnprintf(s, maxlen, format, ap); va_end(ap); } @@ -170,10 +169,10 @@ int OCS_snprintf (char * s, size_t maxlen, const char * format, ...) return actual; } -int OCS_vsnprintf (char * s, size_t maxlen, const char * format, OCS_va_list arg) +int OCS_vsnprintf(char *s, size_t maxlen, const char *format, OCS_va_list arg) { int32 Status; - int actual = 0; + int actual = 0; Status = UT_DEFAULT_IMPL(OCS_vsnprintf); @@ -181,7 +180,7 @@ int OCS_vsnprintf (char * s, size_t maxlen, const char * format, OCS_va_list arg * cannot do the real vsnprintf because we lost the args. */ if (Status >= 0) { - actual = snprintf(s,maxlen,"%s",format); + actual = snprintf(s, maxlen, "%s", format); } if (Status != 0) @@ -192,16 +191,13 @@ int OCS_vsnprintf (char * s, size_t maxlen, const char * format, OCS_va_list arg return actual; } -int OCS_printf (const char * format, ...) +int OCS_printf(const char *format, ...) { return UT_DEFAULT_IMPL(OCS_printf); } +static OCS_FILE LOCAL_FP[3] = {{10}, {11}, {12}}; -static OCS_FILE LOCAL_FP[3] = { { 10 }, { 11 }, { 12 } }; - -OCS_FILE* OCS_stdin = &LOCAL_FP[0]; -OCS_FILE* OCS_stdout = &LOCAL_FP[1]; -OCS_FILE* OCS_stderr = &LOCAL_FP[2]; - - +OCS_FILE *OCS_stdin = &LOCAL_FP[0]; +OCS_FILE *OCS_stdout = &LOCAL_FP[1]; +OCS_FILE *OCS_stderr = &LOCAL_FP[2]; diff --git a/src/unit-test-coverage/ut-stubs/src/libc-stdlib-stubs.c b/src/unit-test-coverage/ut-stubs/src/libc-stdlib-stubs.c index 7f28f47a1..88eabb995 100644 --- a/src/unit-test-coverage/ut-stubs/src/libc-stdlib-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/libc-stdlib-stubs.c @@ -35,19 +35,17 @@ * it only allocates sequential blocks and does not recover * the space after free. */ -#define MPOOL_START_SIGNATURE 0x8a458c6b -#define MPOOL_BLOCK_SIGNATURE 0x3ef65721 -#define MPOOL_ALIGN 16 +#define MPOOL_START_SIGNATURE 0x8a458c6b +#define MPOOL_BLOCK_SIGNATURE 0x3ef65721 +#define MPOOL_ALIGN 16 struct MPOOL_REC { cpuaddr BlockAddr; - uint32 Magic; - uint32 Size; + uint32 Magic; + uint32 Size; }; - - void OCS_exit(int c) { UT_DEFAULT_IMPL(OCS_exit); @@ -61,9 +59,9 @@ void OCS_exit(int c) */ } -unsigned long int OCS_strtoul (const char * nptr, char ** endptr, int base) +unsigned long int OCS_strtoul(const char *nptr, char **endptr, int base) { - int32 Status; + int32 Status; unsigned long Result = 0; Status = UT_DEFAULT_IMPL_RC(OCS_strtoul, -1); @@ -79,46 +77,45 @@ unsigned long int OCS_strtoul (const char * nptr, char ** endptr, int base) } return Result; - } -int OCS_system (const char * command) +int OCS_system(const char *command) { return UT_DEFAULT_IMPL(OCS_system); } void *OCS_malloc(size_t sz) { - int32 Status; - void *PoolPtr; - cpuaddr PoolStart; - cpuaddr PoolEnd; - cpuaddr NextBlock; - size_t NextSize; - uint32 PoolSize; - uint32 CallCnt; + int32 Status; + void * PoolPtr; + cpuaddr PoolStart; + cpuaddr PoolEnd; + cpuaddr NextBlock; + size_t NextSize; + uint32 PoolSize; + uint32 CallCnt; struct MPOOL_REC *Rec; - Rec = NULL; + Rec = NULL; CallCnt = UT_GetStubCount(UT_KEY(OCS_malloc)); UT_GetDataBuffer(UT_KEY(OCS_malloc), &PoolPtr, &PoolSize, NULL); if (PoolPtr != NULL) { PoolStart = (cpuaddr)PoolPtr; - PoolEnd = PoolStart + PoolSize; + PoolEnd = PoolStart + PoolSize; PoolStart = (PoolStart + MPOOL_ALIGN - 1) & ~((cpuaddr)MPOOL_ALIGN - 1); - PoolSize = PoolEnd - PoolStart; + PoolSize = PoolEnd - PoolStart; if (PoolSize > (MPOOL_ALIGN * 2)) { - Rec = (struct MPOOL_REC*)PoolStart; + Rec = (struct MPOOL_REC *)PoolStart; NextBlock = PoolStart + MPOOL_ALIGN; PoolSize -= MPOOL_ALIGN; if (CallCnt == 0) { - Rec->Magic = MPOOL_START_SIGNATURE; - Rec->Size = 0; + Rec->Magic = MPOOL_START_SIGNATURE; + Rec->Size = 0; Rec->BlockAddr = NextBlock; } else if (Rec->Magic != MPOOL_START_SIGNATURE) @@ -148,25 +145,25 @@ void *OCS_malloc(size_t sz) return NULL; } - NextSize = (NextSize + MPOOL_ALIGN - 1) & ~((size_t)MPOOL_ALIGN); + NextSize = (NextSize + MPOOL_ALIGN - 1) & ~((size_t)MPOOL_ALIGN); NextBlock = Rec->BlockAddr + MPOOL_ALIGN; Rec->BlockAddr += NextSize; Rec->Size += NextSize; - Rec = (struct MPOOL_REC*)(NextBlock - sizeof(struct MPOOL_REC)); + Rec = (struct MPOOL_REC *)(NextBlock - sizeof(struct MPOOL_REC)); Rec->BlockAddr = NextBlock; - Rec->Magic = MPOOL_BLOCK_SIGNATURE; - Rec->Size = sz; + Rec->Magic = MPOOL_BLOCK_SIGNATURE; + Rec->Size = sz; - return ((void*)NextBlock); + return ((void *)NextBlock); } void OCS_free(void *ptr) { - int32 Status; - cpuaddr BlockAddr; - void *PoolPtr; - uint32 PoolSize; + int32 Status; + cpuaddr BlockAddr; + void * PoolPtr; + uint32 PoolSize; struct MPOOL_REC *Rec; /* @@ -185,7 +182,7 @@ void OCS_free(void *ptr) } else { - Rec = (struct MPOOL_REC*)(BlockAddr - sizeof(struct MPOOL_REC)); + Rec = (struct MPOOL_REC *)(BlockAddr - sizeof(struct MPOOL_REC)); if (Rec->Magic == MPOOL_BLOCK_SIGNATURE) { Rec->Magic = ~MPOOL_BLOCK_SIGNATURE; @@ -200,8 +197,4 @@ void OCS_free(void *ptr) } } } - - } - - diff --git a/src/unit-test-coverage/ut-stubs/src/libc-string-stubs.c b/src/unit-test-coverage/ut-stubs/src/libc-string-stubs.c index 09cd25293..d8cac53a7 100644 --- a/src/unit-test-coverage/ut-stubs/src/libc-string-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/libc-string-stubs.c @@ -26,7 +26,7 @@ #include -void* OCS_memset(void * s, int c, size_t n) +void *OCS_memset(void *s, int c, size_t n) { int32 Status; void *Result; @@ -45,7 +45,7 @@ void* OCS_memset(void * s, int c, size_t n) return Result; } -void *OCS_memcpy (void * dest, const void * src, size_t n) +void *OCS_memcpy(void *dest, const void *src, size_t n) { int32 Status; void *Result; @@ -73,14 +73,14 @@ char *OCS_strchr(const char *s, int c) if (Status == 0) { /* "nominal" response */ - return strchr(s,c); + return strchr(s, c); } if (Status < 0) { - return (char*)0; + return (char *)0; } - return (char*)&s[Status-1]; + return (char *)&s[Status - 1]; } char *OCS_strrchr(const char *s, int c) @@ -92,14 +92,14 @@ char *OCS_strrchr(const char *s, int c) if (Status == 0) { /* "nominal" response */ - return strrchr(s,c); + return strrchr(s, c); } if (Status < 0) { - return (char*)0; + return (char *)0; } - return (char*)&s[Status-1]; + return (char *)&s[Status - 1]; } size_t OCS_strlen(const char *s) @@ -120,10 +120,10 @@ char *OCS_strcat(char *dest, const char *src) if (Status == 0) { /* "nominal" response */ - return strcat(dest,src); + return strcat(dest, src); } - return (char*)0; + return (char *)0; } char *OCS_strncat(char *dest, const char *src, size_t size) @@ -135,17 +135,17 @@ char *OCS_strncat(char *dest, const char *src, size_t size) if (Status == 0) { /* "nominal" response */ - return strncat(dest,src,size); + return strncat(dest, src, size); } - return (char*)0; + return (char *)0; } int OCS_strncmp(const char *s1, const char *s2, size_t size) { int32 Status; - Status = UT_DEFAULT_IMPL_RC(OCS_strncmp, strncmp(s1,s2,size)); + Status = UT_DEFAULT_IMPL_RC(OCS_strncmp, strncmp(s1, s2, size)); return Status; } @@ -154,7 +154,7 @@ int OCS_strcmp(const char *s1, const char *s2) { int32 Status; - Status = UT_DEFAULT_IMPL_RC(OCS_strcmp, strcmp(s1,s2)); + Status = UT_DEFAULT_IMPL_RC(OCS_strcmp, strcmp(s1, s2)); return Status; } @@ -168,10 +168,10 @@ char *OCS_strcpy(char *dst, const char *src) if (Status == 0) { /* "nominal" response */ - return strcpy(dst,src); + return strcpy(dst, src); } - return (char*)0; + return (char *)0; } char *OCS_strncpy(char *dst, const char *src, size_t size) @@ -183,16 +183,16 @@ char *OCS_strncpy(char *dst, const char *src, size_t size) if (Status == 0) { /* "nominal" response */ - return strncpy(dst,src,size); + return strncpy(dst, src, size); } - return (char*)0; + return (char *)0; } char *OCS_strerror(int errnum) { static char str[16]; - int32 Status; + int32 Status; Status = UT_DEFAULT_IMPL(OCS_strerror); @@ -202,10 +202,6 @@ char *OCS_strerror(int errnum) } /* "nominal" response */ - snprintf(str,sizeof(str),"UT_ERR_%d", errnum); + snprintf(str, sizeof(str), "UT_ERR_%d", errnum); return str; } - - - - diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-binsem-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-binsem-impl-stubs.c index 59aed9cc8..c54b742e1 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-binsem-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-binsem-impl-stubs.c @@ -34,16 +34,14 @@ #include "os-shared-binsem.h" - /* ** Semaphore API */ -UT_DEFAULT_STUB(OS_BinSemCreate_Impl,(uint32 sem_id, uint32 sem_initial_value, uint32 options)) -UT_DEFAULT_STUB(OS_BinSemFlush_Impl,(uint32 sem_id)) -UT_DEFAULT_STUB(OS_BinSemGive_Impl,(uint32 sem_id)) -UT_DEFAULT_STUB(OS_BinSemTake_Impl,(uint32 sem_id)) -UT_DEFAULT_STUB(OS_BinSemTimedWait_Impl,(uint32 sem_id, uint32 msecs)) -UT_DEFAULT_STUB(OS_BinSemDelete_Impl,(uint32 sem_id)) -UT_DEFAULT_STUB(OS_BinSemGetInfo_Impl,(uint32 sem_id, OS_bin_sem_prop_t *bin_prop)) - +UT_DEFAULT_STUB(OS_BinSemCreate_Impl, (uint32 sem_id, uint32 sem_initial_value, uint32 options)) +UT_DEFAULT_STUB(OS_BinSemFlush_Impl, (uint32 sem_id)) +UT_DEFAULT_STUB(OS_BinSemGive_Impl, (uint32 sem_id)) +UT_DEFAULT_STUB(OS_BinSemTake_Impl, (uint32 sem_id)) +UT_DEFAULT_STUB(OS_BinSemTimedWait_Impl, (uint32 sem_id, uint32 msecs)) +UT_DEFAULT_STUB(OS_BinSemDelete_Impl, (uint32 sem_id)) +UT_DEFAULT_STUB(OS_BinSemGetInfo_Impl, (uint32 sem_id, OS_bin_sem_prop_t *bin_prop)) diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-common-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-common-impl-stubs.c index 0b0fa990b..07393f74f 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-common-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-common-impl-stubs.c @@ -36,13 +36,12 @@ UT_DEFAULT_STUB(OS_API_Impl_Init, (uint32 idtype)) -void OS_IdleLoop_Impl (void) +void OS_IdleLoop_Impl(void) { UT_DEFAULT_IMPL(OS_IdleLoop_Impl); } -void OS_ApplicationShutdown_Impl (void) +void OS_ApplicationShutdown_Impl(void) { UT_DEFAULT_IMPL(OS_ApplicationShutdown_Impl); } - diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-console-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-console-impl-stubs.c index 7a35b0800..6a0d202fb 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-console-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-console-impl-stubs.c @@ -37,7 +37,7 @@ /* ** Console output API (printf) */ -void OS_ConsoleWakeup_Impl(uint32 local_id) +void OS_ConsoleWakeup_Impl(uint32 local_id) { UT_DEFAULT_IMPL(OS_ConsoleWakeup_Impl); } @@ -45,4 +45,3 @@ int32 OS_ConsoleCreate_Impl(uint32 local_id) { return UT_DEFAULT_IMPL(OS_ConsoleCreate_Impl); } - diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-countsem-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-countsem-impl-stubs.c index e62d4fdd3..caa024050 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-countsem-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-countsem-impl-stubs.c @@ -38,10 +38,9 @@ ** Semaphore API */ -UT_DEFAULT_STUB(OS_CountSemCreate_Impl,(uint32 sem_id, uint32 sem_initial_value, uint32 options)) -UT_DEFAULT_STUB(OS_CountSemGive_Impl,(uint32 sem_id)) -UT_DEFAULT_STUB(OS_CountSemTake_Impl,(uint32 sem_id)) -UT_DEFAULT_STUB(OS_CountSemTimedWait_Impl,(uint32 sem_id, uint32 msecs)) -UT_DEFAULT_STUB(OS_CountSemDelete_Impl,(uint32 sem_id)) -UT_DEFAULT_STUB(OS_CountSemGetInfo_Impl,(uint32 sem_id, OS_count_sem_prop_t *count_prop)) - +UT_DEFAULT_STUB(OS_CountSemCreate_Impl, (uint32 sem_id, uint32 sem_initial_value, uint32 options)) +UT_DEFAULT_STUB(OS_CountSemGive_Impl, (uint32 sem_id)) +UT_DEFAULT_STUB(OS_CountSemTake_Impl, (uint32 sem_id)) +UT_DEFAULT_STUB(OS_CountSemTimedWait_Impl, (uint32 sem_id, uint32 msecs)) +UT_DEFAULT_STUB(OS_CountSemDelete_Impl, (uint32 sem_id)) +UT_DEFAULT_STUB(OS_CountSemGetInfo_Impl, (uint32 sem_id, OS_count_sem_prop_t *count_prop)) diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-error-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-error-impl-stubs.c index 2a8cf0e2e..3e75fc378 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-error-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-error-impl-stubs.c @@ -34,9 +34,4 @@ #include "os-shared-errors.h" -const OS_ErrorTable_Entry_t OS_IMPL_ERROR_NAME_TABLE[] = -{ - { -4444, "UT_ERROR" }, - { 0, NULL } -}; - +const OS_ErrorTable_Entry_t OS_IMPL_ERROR_NAME_TABLE[] = {{-4444, "UT_ERROR"}, {0, NULL}}; diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-file-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-file-impl-stubs.c index 9691456ed..26fec0ba1 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-file-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-file-impl-stubs.c @@ -35,28 +35,26 @@ #include "os-shared-file.h" #include "os-shared-dir.h" - /* * File API abstraction layer */ -UT_DEFAULT_STUB(OS_FileOpen_Impl,(uint32 file_id, const char *local_path, int32 flags, int32 access)) -UT_DEFAULT_STUB(OS_FileStat_Impl,(const char *local_path, os_fstat_t *filestat)) -UT_DEFAULT_STUB(OS_FileRemove_Impl,(const char *local_path)) -UT_DEFAULT_STUB(OS_FileRename_Impl,(const char *old_path, const char *new_path)) +UT_DEFAULT_STUB(OS_FileOpen_Impl, (uint32 file_id, const char *local_path, int32 flags, int32 access)) +UT_DEFAULT_STUB(OS_FileStat_Impl, (const char *local_path, os_fstat_t *filestat)) +UT_DEFAULT_STUB(OS_FileRemove_Impl, (const char *local_path)) +UT_DEFAULT_STUB(OS_FileRename_Impl, (const char *old_path, const char *new_path)) UT_DEFAULT_STUB(OS_FileChmod_Impl, (const char *local_path, uint32 access)) -UT_DEFAULT_STUB(OS_ShellOutputToFile_Impl,(uint32 file_id, const char* Cmd)) +UT_DEFAULT_STUB(OS_ShellOutputToFile_Impl, (uint32 file_id, const char *Cmd)) /* * Directory API abstraction layer */ -UT_DEFAULT_STUB(OS_DirCreate_Impl,(const char *local_path, uint32 access)) -UT_DEFAULT_STUB(OS_DirOpen_Impl,(uint32 dir_id, const char *local_path)) -UT_DEFAULT_STUB(OS_DirClose_Impl,(uint32 dir_id)) -UT_DEFAULT_STUB(OS_DirRead_Impl,(uint32 dir_id, os_dirent_t *dirent)) -UT_DEFAULT_STUB(OS_DirRewind_Impl,(uint32 dir_id)) -UT_DEFAULT_STUB(OS_DirRemove_Impl,(const char *local_path)) - +UT_DEFAULT_STUB(OS_DirCreate_Impl, (const char *local_path, uint32 access)) +UT_DEFAULT_STUB(OS_DirOpen_Impl, (uint32 dir_id, const char *local_path)) +UT_DEFAULT_STUB(OS_DirClose_Impl, (uint32 dir_id)) +UT_DEFAULT_STUB(OS_DirRead_Impl, (uint32 dir_id, os_dirent_t *dirent)) +UT_DEFAULT_STUB(OS_DirRewind_Impl, (uint32 dir_id)) +UT_DEFAULT_STUB(OS_DirRemove_Impl, (const char *local_path)) /* * Stream abstraction layer (applies to sockets and files) @@ -79,13 +77,11 @@ int32 OS_GenericWrite_Impl(uint32 stream_id, const void *buffer, uint32 nbytes, if (Status == OS_SUCCESS) { - Status = UT_Stub_CopyFromLocal(UT_KEY(OS_GenericWrite_Impl), (const uint8*)buffer, nbytes); + Status = UT_Stub_CopyFromLocal(UT_KEY(OS_GenericWrite_Impl), (const uint8 *)buffer, nbytes); } return Status; } -UT_DEFAULT_STUB(OS_GenericSeek_Impl,(uint32 file_id, int32 offset, uint32 whence)) -UT_DEFAULT_STUB(OS_GenericClose_Impl,(uint32 file_id)) - - +UT_DEFAULT_STUB(OS_GenericSeek_Impl, (uint32 file_id, int32 offset, uint32 whence)) +UT_DEFAULT_STUB(OS_GenericClose_Impl, (uint32 file_id)) diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-filesys-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-filesys-impl-stubs.c index a2aa6861c..8c0ac6f24 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-filesys-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-filesys-impl-stubs.c @@ -36,23 +36,22 @@ /* * File system abstraction layer */ -UT_DEFAULT_STUB(OS_FileSysStartVolume_Impl,(uint32 filesys_id)) +UT_DEFAULT_STUB(OS_FileSysStartVolume_Impl, (uint32 filesys_id)) UT_DEFAULT_STUB(OS_FileSysStopVolume_Impl, (uint32 filesys_id)) UT_DEFAULT_STUB(OS_FileSysFormatVolume_Impl, (uint32 filesys_id)) UT_DEFAULT_STUB(OS_FileSysCheckVolume_Impl, (uint32 filesys_id, bool repair)) UT_DEFAULT_STUB(OS_FileSysMountVolume_Impl, (uint32 filesys_id)) UT_DEFAULT_STUB(OS_FileSysUnmountVolume_Impl, (uint32 filesys_id)) -int32 OS_FileSysStatVolume_Impl (uint32 filesys_id, OS_statvfs_t *result) +int32 OS_FileSysStatVolume_Impl(uint32 filesys_id, OS_statvfs_t *result) { int32 Status = UT_DEFAULT_IMPL(OS_FileSysStatVolume_Impl); if (Status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_FileSysStatVolume_Impl), result, sizeof(*result)) < sizeof(*result)) + UT_Stub_CopyToLocal(UT_KEY(OS_FileSysStatVolume_Impl), result, sizeof(*result)) < sizeof(*result)) { memset(result, 0, sizeof(*result)); } return Status; } - diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-heap-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-heap-impl-stubs.c index 86e14baa5..00b07fb04 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-heap-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-heap-impl-stubs.c @@ -37,4 +37,4 @@ /* * Heap API low-level handler */ -UT_DEFAULT_STUB(OS_HeapGetInfo_Impl,(OS_heap_prop_t *heap_prop)) +UT_DEFAULT_STUB(OS_HeapGetInfo_Impl, (OS_heap_prop_t * heap_prop)) diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-idmap-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-idmap-impl-stubs.c index d95303b28..f3546e9f9 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-idmap-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-idmap-impl-stubs.c @@ -38,7 +38,5 @@ * Table locking and unlocking for global objects can be done at the shared code * layer but the actual implementation is OS-specific */ -UT_DEFAULT_STUB(OS_Lock_Global_Impl,(uint32 idtype)) -UT_DEFAULT_STUB(OS_Unlock_Global_Impl,(uint32 idtype)) - - +UT_DEFAULT_STUB(OS_Lock_Global_Impl, (uint32 idtype)) +UT_DEFAULT_STUB(OS_Unlock_Global_Impl, (uint32 idtype)) diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-loader-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-loader-impl-stubs.c index c9fd295b8..8c5d7aa77 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-loader-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-loader-impl-stubs.c @@ -33,13 +33,11 @@ #include "utstubs.h" #include "os-shared-module.h" - /* * Module Loader API */ -UT_DEFAULT_STUB(OS_ModuleLoad_Impl,( uint32 module_id, const char *translated_path )) -UT_DEFAULT_STUB(OS_ModuleUnload_Impl,( uint32 module_id )) -UT_DEFAULT_STUB(OS_ModuleGetInfo_Impl,( uint32 module_id, OS_module_prop_t *module_prop )) -UT_DEFAULT_STUB(OS_SymbolLookup_Impl,( cpuaddr *SymbolAddress, const char *SymbolName )) -UT_DEFAULT_STUB(OS_SymbolTableDump_Impl,( const char *filename, uint32 size_limit )) - +UT_DEFAULT_STUB(OS_ModuleLoad_Impl, (uint32 module_id, const char *translated_path)) +UT_DEFAULT_STUB(OS_ModuleUnload_Impl, (uint32 module_id)) +UT_DEFAULT_STUB(OS_ModuleGetInfo_Impl, (uint32 module_id, OS_module_prop_t *module_prop)) +UT_DEFAULT_STUB(OS_SymbolLookup_Impl, (cpuaddr * SymbolAddress, const char *SymbolName)) +UT_DEFAULT_STUB(OS_SymbolTableDump_Impl, (const char *filename, uint32 size_limit)) diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-mutex-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-mutex-impl-stubs.c index 9afeed103..7bc4230bc 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-mutex-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-mutex-impl-stubs.c @@ -34,14 +34,12 @@ #include "os-shared-mutex.h" - /* ** Mutex API */ -UT_DEFAULT_STUB(OS_MutSemCreate_Impl,(uint32 sem_id, uint32 options)) -UT_DEFAULT_STUB(OS_MutSemGive_Impl,(uint32 sem_id)) -UT_DEFAULT_STUB(OS_MutSemTake_Impl,(uint32 sem_id)) -UT_DEFAULT_STUB(OS_MutSemDelete_Impl,(uint32 sem_id)) -UT_DEFAULT_STUB(OS_MutSemGetInfo_Impl,(uint32 sem_id, OS_mut_sem_prop_t *mut_prop)) - +UT_DEFAULT_STUB(OS_MutSemCreate_Impl, (uint32 sem_id, uint32 options)) +UT_DEFAULT_STUB(OS_MutSemGive_Impl, (uint32 sem_id)) +UT_DEFAULT_STUB(OS_MutSemTake_Impl, (uint32 sem_id)) +UT_DEFAULT_STUB(OS_MutSemDelete_Impl, (uint32 sem_id)) +UT_DEFAULT_STUB(OS_MutSemGetInfo_Impl, (uint32 sem_id, OS_mut_sem_prop_t *mut_prop)) diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-network-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-network-impl-stubs.c index 71e806e21..e576d35ca 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-network-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-network-impl-stubs.c @@ -37,23 +37,25 @@ /* * Sockets API abstraction layer */ -UT_DEFAULT_STUB(OS_SocketOpen_Impl,(uint32 sock_id)) -UT_DEFAULT_STUB(OS_SocketClose_Impl,(uint32 sock_id)) -UT_DEFAULT_STUB(OS_SocketBind_Impl,(uint32 sock_id, const OS_SockAddr_t *Addr)) -UT_DEFAULT_STUB(OS_SocketAccept_Impl,(uint32 sock_id, uint32 connsock_id, OS_SockAddr_t *Addr, int32 timeout)) -UT_DEFAULT_STUB(OS_SocketConnect_Impl,(uint32 sock_id, const OS_SockAddr_t *Addr, int32 timeout)) -UT_DEFAULT_STUB(OS_SocketRecvFrom_Impl,(uint32 sock_id, void *buffer, uint32 buflen, OS_SockAddr_t *RemoteAddr, int32 timeout)) -UT_DEFAULT_STUB(OS_SocketSendTo_Impl,(uint32 sock_id, const void *buffer, uint32 buflen, const OS_SockAddr_t *RemoteAddr)) -UT_DEFAULT_STUB(OS_SocketGetInfo_Impl,(uint32 sock_id, OS_socket_prop_t *sock_prop)) +UT_DEFAULT_STUB(OS_SocketOpen_Impl, (uint32 sock_id)) +UT_DEFAULT_STUB(OS_SocketClose_Impl, (uint32 sock_id)) +UT_DEFAULT_STUB(OS_SocketBind_Impl, (uint32 sock_id, const OS_SockAddr_t *Addr)) +UT_DEFAULT_STUB(OS_SocketAccept_Impl, (uint32 sock_id, uint32 connsock_id, OS_SockAddr_t *Addr, int32 timeout)) +UT_DEFAULT_STUB(OS_SocketConnect_Impl, (uint32 sock_id, const OS_SockAddr_t *Addr, int32 timeout)) +UT_DEFAULT_STUB(OS_SocketRecvFrom_Impl, + (uint32 sock_id, void *buffer, uint32 buflen, OS_SockAddr_t *RemoteAddr, int32 timeout)) +UT_DEFAULT_STUB(OS_SocketSendTo_Impl, + (uint32 sock_id, const void *buffer, uint32 buflen, const OS_SockAddr_t *RemoteAddr)) +UT_DEFAULT_STUB(OS_SocketGetInfo_Impl, (uint32 sock_id, OS_socket_prop_t *sock_prop)) -UT_DEFAULT_STUB(OS_SocketAddrInit_Impl,(OS_SockAddr_t *Addr, OS_SocketDomain_t Domain)) -UT_DEFAULT_STUB(OS_SocketAddrToString_Impl,(char *buffer, uint32 buflen, const OS_SockAddr_t *Addr)) -UT_DEFAULT_STUB(OS_SocketAddrGetPort_Impl,(uint16 *PortNum, const OS_SockAddr_t *Addr)) -UT_DEFAULT_STUB(OS_SocketAddrFromString_Impl,(OS_SockAddr_t *Addr, const char *string)) -UT_DEFAULT_STUB(OS_SocketAddrSetPort_Impl,(OS_SockAddr_t *Addr, uint16 PortNum)) -UT_DEFAULT_STUB(OS_NetworkGetHostName_Impl,(char *host_name, uint32 name_len)) +UT_DEFAULT_STUB(OS_SocketAddrInit_Impl, (OS_SockAddr_t * Addr, OS_SocketDomain_t Domain)) +UT_DEFAULT_STUB(OS_SocketAddrToString_Impl, (char *buffer, uint32 buflen, const OS_SockAddr_t *Addr)) +UT_DEFAULT_STUB(OS_SocketAddrGetPort_Impl, (uint16 * PortNum, const OS_SockAddr_t *Addr)) +UT_DEFAULT_STUB(OS_SocketAddrFromString_Impl, (OS_SockAddr_t * Addr, const char *string)) +UT_DEFAULT_STUB(OS_SocketAddrSetPort_Impl, (OS_SockAddr_t * Addr, uint16 PortNum)) +UT_DEFAULT_STUB(OS_NetworkGetHostName_Impl, (char *host_name, uint32 name_len)) -int32 OS_NetworkGetID_Impl (int32 *IdBuf) +int32 OS_NetworkGetID_Impl(int32 *IdBuf) { int32 Status = UT_DEFAULT_IMPL(OS_NetworkGetID_Impl); if (Status == 0) @@ -62,4 +64,3 @@ int32 OS_NetworkGetID_Impl (int32 *IdBuf) } return Status; } - diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-queue-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-queue-impl-stubs.c index 405edec5b..306733f5b 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-queue-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-queue-impl-stubs.c @@ -38,9 +38,8 @@ ** Message Queue API */ -UT_DEFAULT_STUB(OS_QueueCreate_Impl,(uint32 queue_id, uint32 flags)) -UT_DEFAULT_STUB(OS_QueueDelete_Impl,(uint32 queue_id)) -UT_DEFAULT_STUB(OS_QueueGet_Impl,(uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout)) -UT_DEFAULT_STUB(OS_QueuePut_Impl,(uint32 queue_id, const void *data, uint32 size, uint32 flags)) -UT_DEFAULT_STUB(OS_QueueGetInfo_Impl,(uint32 queue_id, OS_queue_prop_t *queue_prop)) - +UT_DEFAULT_STUB(OS_QueueCreate_Impl, (uint32 queue_id, uint32 flags)) +UT_DEFAULT_STUB(OS_QueueDelete_Impl, (uint32 queue_id)) +UT_DEFAULT_STUB(OS_QueueGet_Impl, (uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout)) +UT_DEFAULT_STUB(OS_QueuePut_Impl, (uint32 queue_id, const void *data, uint32 size, uint32 flags)) +UT_DEFAULT_STUB(OS_QueueGetInfo_Impl, (uint32 queue_id, OS_queue_prop_t *queue_prop)) diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-select-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-select-impl-stubs.c index 89f4259df..f30e43840 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-select-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-select-impl-stubs.c @@ -33,5 +33,5 @@ #include "utstubs.h" #include "os-shared-select.h" -UT_DEFAULT_STUB(OS_SelectSingle_Impl,(uint32 stream_id, uint32 *SelectFlags, int32 msecs)) -UT_DEFAULT_STUB(OS_SelectMultiple_Impl,(OS_FdSet *ReadSet, OS_FdSet *WriteSet, int32 msecs)) +UT_DEFAULT_STUB(OS_SelectSingle_Impl, (uint32 stream_id, uint32 *SelectFlags, int32 msecs)) +UT_DEFAULT_STUB(OS_SelectMultiple_Impl, (OS_FdSet * ReadSet, OS_FdSet *WriteSet, int32 msecs)) diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-shared-binsem-table-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-shared-binsem-table-stubs.c index 2043d8794..3118b32de 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-shared-binsem-table-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-shared-binsem-table-stubs.c @@ -30,4 +30,4 @@ #include "os-shared-binsem.h" -OS_bin_sem_internal_record_t OS_bin_sem_table[OS_MAX_BIN_SEMAPHORES]; +OS_bin_sem_internal_record_t OS_bin_sem_table[OS_MAX_BIN_SEMAPHORES]; diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-shared-common-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-shared-common-stubs.c index 3b20f8afc..bba938912 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-shared-common-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-shared-common-stubs.c @@ -31,4 +31,3 @@ #include "os-shared-common.h" OS_SharedGlobalVars_t OS_SharedGlobalVars; - diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-shared-console-table-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-shared-console-table-stubs.c index 3dd738da2..fb979daf8 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-shared-console-table-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-shared-console-table-stubs.c @@ -30,4 +30,4 @@ #include "os-shared-printf.h" -OS_console_internal_record_t OS_console_table[OS_MAX_CONSOLES]; +OS_console_internal_record_t OS_console_table[OS_MAX_CONSOLES]; diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-shared-countsem-table-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-shared-countsem-table-stubs.c index f34822d70..3c5668f60 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-shared-countsem-table-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-shared-countsem-table-stubs.c @@ -30,4 +30,4 @@ #include "os-shared-countsem.h" -OS_count_sem_internal_record_t OS_count_sem_table[OS_MAX_COUNT_SEMAPHORES]; +OS_count_sem_internal_record_t OS_count_sem_table[OS_MAX_COUNT_SEMAPHORES]; diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-shared-debug-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-shared-debug-stubs.c index 1d6c6f5d0..d2973e5de 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-shared-debug-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-shared-debug-stubs.c @@ -32,6 +32,4 @@ * This is only relevant when building OSAL with OSAL_CONFIG_DEBUG_PRINTF enabled * *****************************************************************************/ -void OS_DebugPrintf(uint32 Level, const char *Func, uint32 Line, const char *Format, ...) -{ -} +void OS_DebugPrintf(uint32 Level, const char *Func, uint32 Line, const char *Format, ...) {} diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-shared-dir-table-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-shared-dir-table-stubs.c index bc76b6a02..4593344e2 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-shared-dir-table-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-shared-dir-table-stubs.c @@ -30,4 +30,4 @@ #include "os-shared-dir.h" -OS_dir_internal_record_t OS_dir_table[OS_MAX_NUM_OPEN_DIRS]; +OS_dir_internal_record_t OS_dir_table[OS_MAX_NUM_OPEN_DIRS]; diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-shared-filesys-table-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-shared-filesys-table-stubs.c index 35b2aa94b..3974890b2 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-shared-filesys-table-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-shared-filesys-table-stubs.c @@ -30,4 +30,4 @@ #include "os-shared-filesys.h" -OS_filesys_internal_record_t OS_filesys_table[OS_MAX_FILE_SYSTEMS]; +OS_filesys_internal_record_t OS_filesys_table[OS_MAX_FILE_SYSTEMS]; diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-shared-idmap-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-shared-idmap-stubs.c index e80ec58d2..354e78a2c 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-shared-idmap-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-shared-idmap-stubs.c @@ -43,15 +43,15 @@ OS_common_record_t OS_stub_timecb_table[OS_MAX_TIMERS]; OS_common_record_t OS_stub_stream_table[OS_MAX_NUM_OPEN_FILES]; OS_common_record_t OS_stub_dir_table[OS_MAX_NUM_OPEN_DIRS]; -OS_common_record_t * const OS_global_task_table = OS_stub_task_table; -OS_common_record_t * const OS_global_queue_table = OS_stub_queue_table; -OS_common_record_t * const OS_global_bin_sem_table = OS_stub_bin_sem_table; -OS_common_record_t * const OS_global_count_sem_table = OS_stub_count_sem_table; -OS_common_record_t * const OS_global_mutex_table = OS_stub_mutex_table; -OS_common_record_t * const OS_global_stream_table = OS_stub_stream_table; -OS_common_record_t * const OS_global_dir_table = OS_stub_dir_table; -OS_common_record_t * const OS_global_timebase_table = OS_stub_timebase_table; -OS_common_record_t * const OS_global_timecb_table = OS_stub_timecb_table; -OS_common_record_t * const OS_global_module_table = OS_stub_module_table; -OS_common_record_t * const OS_global_filesys_table = OS_stub_filesys_table; -OS_common_record_t * const OS_global_console_table = OS_stub_console_table; +OS_common_record_t *const OS_global_task_table = OS_stub_task_table; +OS_common_record_t *const OS_global_queue_table = OS_stub_queue_table; +OS_common_record_t *const OS_global_bin_sem_table = OS_stub_bin_sem_table; +OS_common_record_t *const OS_global_count_sem_table = OS_stub_count_sem_table; +OS_common_record_t *const OS_global_mutex_table = OS_stub_mutex_table; +OS_common_record_t *const OS_global_stream_table = OS_stub_stream_table; +OS_common_record_t *const OS_global_dir_table = OS_stub_dir_table; +OS_common_record_t *const OS_global_timebase_table = OS_stub_timebase_table; +OS_common_record_t *const OS_global_timecb_table = OS_stub_timecb_table; +OS_common_record_t *const OS_global_module_table = OS_stub_module_table; +OS_common_record_t *const OS_global_filesys_table = OS_stub_filesys_table; +OS_common_record_t *const OS_global_console_table = OS_stub_console_table; diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-shared-module-table-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-shared-module-table-stubs.c index 4792442fb..981bd0b4c 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-shared-module-table-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-shared-module-table-stubs.c @@ -31,4 +31,4 @@ #include "os-shared-module.h" -OS_module_internal_record_t OS_module_table[OS_MAX_MODULES]; +OS_module_internal_record_t OS_module_table[OS_MAX_MODULES]; diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-shared-mutex-table-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-shared-mutex-table-stubs.c index 0dbd96a21..ba57a1248 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-shared-mutex-table-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-shared-mutex-table-stubs.c @@ -31,4 +31,4 @@ #include "os-shared-mutex.h" -OS_mutex_internal_record_t OS_mutex_table[OS_MAX_MUTEXES]; +OS_mutex_internal_record_t OS_mutex_table[OS_MAX_MUTEXES]; diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-shared-queue-table-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-shared-queue-table-stubs.c index 2034a605d..872daee22 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-shared-queue-table-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-shared-queue-table-stubs.c @@ -31,4 +31,4 @@ #include "os-shared-queue.h" -OS_queue_internal_record_t OS_queue_table[OS_MAX_QUEUES]; +OS_queue_internal_record_t OS_queue_table[OS_MAX_QUEUES]; diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-shared-stream-table-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-shared-stream-table-stubs.c index 7a1d5cf32..3dfd30a41 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-shared-stream-table-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-shared-stream-table-stubs.c @@ -31,4 +31,4 @@ #include "os-shared-file.h" -OS_stream_internal_record_t OS_stream_table[OS_MAX_NUM_OPEN_FILES]; +OS_stream_internal_record_t OS_stream_table[OS_MAX_NUM_OPEN_FILES]; diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-shared-task-table-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-shared-task-table-stubs.c index c29ed2f8d..c2aabc9cb 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-shared-task-table-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-shared-task-table-stubs.c @@ -31,4 +31,4 @@ #include "os-shared-task.h" -OS_task_internal_record_t OS_task_table[OS_MAX_TASKS]; +OS_task_internal_record_t OS_task_table[OS_MAX_TASKS]; diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-shared-timebase-table-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-shared-timebase-table-stubs.c index 9f628a29e..005bebfcc 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-shared-timebase-table-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-shared-timebase-table-stubs.c @@ -31,4 +31,4 @@ #include "os-shared-timebase.h" -OS_timebase_internal_record_t OS_timebase_table[OS_MAX_TIMEBASES]; +OS_timebase_internal_record_t OS_timebase_table[OS_MAX_TIMEBASES]; diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-shared-timecb-table-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-shared-timecb-table-stubs.c index c106b9d00..34d1b2229 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-shared-timecb-table-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-shared-timecb-table-stubs.c @@ -31,4 +31,4 @@ #include "os-shared-time.h" -OS_timecb_internal_record_t OS_timecb_table[OS_MAX_TIMERS]; +OS_timecb_internal_record_t OS_timecb_table[OS_MAX_TIMERS]; diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-task-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-task-impl-stubs.c index cb163c702..76acb04f9 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-task-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-task-impl-stubs.c @@ -34,23 +34,22 @@ #include "os-shared-task.h" - /* ** Task API */ -UT_DEFAULT_STUB(OS_TaskMatch_Impl,(uint32 task_id)) -UT_DEFAULT_STUB(OS_TaskCreate_Impl,(uint32 task_id, uint32 flags)) -UT_DEFAULT_STUB(OS_TaskDelete_Impl,(uint32 task_id)) -void OS_TaskExit_Impl (void) +UT_DEFAULT_STUB(OS_TaskMatch_Impl, (uint32 task_id)) +UT_DEFAULT_STUB(OS_TaskCreate_Impl, (uint32 task_id, uint32 flags)) +UT_DEFAULT_STUB(OS_TaskDelete_Impl, (uint32 task_id)) +void OS_TaskExit_Impl(void) { UT_DEFAULT_IMPL(OS_TaskExit_Impl); } -UT_DEFAULT_STUB(OS_TaskDelay_Impl,(uint32 millisecond)) -UT_DEFAULT_STUB(OS_TaskSetPriority_Impl,(uint32 task_id, uint32 new_priority)) -osal_id_t OS_TaskGetId_Impl (void) +UT_DEFAULT_STUB(OS_TaskDelay_Impl, (uint32 millisecond)) +UT_DEFAULT_STUB(OS_TaskSetPriority_Impl, (uint32 task_id, uint32 new_priority)) +osal_id_t OS_TaskGetId_Impl(void) { - int32 status; + int32 status; osal_id_t id; status = UT_DEFAULT_IMPL(OS_TaskGetId_Impl); @@ -61,13 +60,12 @@ osal_id_t OS_TaskGetId_Impl (void) return id; } -UT_DEFAULT_STUB(OS_TaskGetInfo_Impl,(uint32 task_id, OS_task_prop_t *task_prop)) -UT_DEFAULT_STUB(OS_TaskRegister_Impl,(osal_id_t global_task_id)) +UT_DEFAULT_STUB(OS_TaskGetInfo_Impl, (uint32 task_id, OS_task_prop_t *task_prop)) +UT_DEFAULT_STUB(OS_TaskRegister_Impl, (osal_id_t global_task_id)) bool OS_TaskIdMatchSystemData_Impl(void *ref, uint32 local_id, const OS_common_record_t *obj) { return UT_DEFAULT_IMPL(OS_TaskIdMatchSystemData_Impl); } -UT_DEFAULT_STUB(OS_TaskValidateSystemData_Impl,(const void *sysdata, uint32 sysdata_size)) - +UT_DEFAULT_STUB(OS_TaskValidateSystemData_Impl, (const void *sysdata, uint32 sysdata_size)) diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-timer-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-timer-impl-stubs.c index 74bb49f0c..5d7e89fe6 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-timer-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-timer-impl-stubs.c @@ -37,26 +37,24 @@ /* ** OS Time/Tick related API */ -UT_DEFAULT_STUB(OS_TimeBaseCreate_Impl,(uint32 timer_id)) -UT_DEFAULT_STUB(OS_TimeBaseSet_Impl,(uint32 timer_id, int32 start_time, int32 interval_time)) -UT_DEFAULT_STUB(OS_TimeBaseDelete_Impl,(uint32 timer_id)) -void OS_TimeBaseLock_Impl (uint32 timebase_id) +UT_DEFAULT_STUB(OS_TimeBaseCreate_Impl, (uint32 timer_id)) +UT_DEFAULT_STUB(OS_TimeBaseSet_Impl, (uint32 timer_id, int32 start_time, int32 interval_time)) +UT_DEFAULT_STUB(OS_TimeBaseDelete_Impl, (uint32 timer_id)) +void OS_TimeBaseLock_Impl(uint32 timebase_id) { UT_DEFAULT_IMPL(OS_TimeBaseLock_Impl); } -void OS_TimeBaseUnlock_Impl (uint32 timebase_id) +void OS_TimeBaseUnlock_Impl(uint32 timebase_id) { UT_DEFAULT_IMPL(OS_TimeBaseUnlock_Impl); } -UT_DEFAULT_STUB(OS_TimeBaseGetInfo_Impl,(uint32 timer_id, OS_timebase_prop_t *timer_prop)) +UT_DEFAULT_STUB(OS_TimeBaseGetInfo_Impl, (uint32 timer_id, OS_timebase_prop_t *timer_prop)) -UT_DEFAULT_STUB(OS_TimeBaseRegister_Impl,(uint32 timebase_id)) +UT_DEFAULT_STUB(OS_TimeBaseRegister_Impl, (uint32 timebase_id)) /* * Clock API low-level handlers */ -UT_DEFAULT_STUB(OS_GetLocalTime_Impl,(OS_time_t *time_struct)) -UT_DEFAULT_STUB(OS_SetLocalTime_Impl,(const OS_time_t *time_struct)) - - +UT_DEFAULT_STUB(OS_GetLocalTime_Impl, (OS_time_t * time_struct)) +UT_DEFAULT_STUB(OS_SetLocalTime_Impl, (const OS_time_t *time_struct)) diff --git a/src/unit-test-coverage/ut-stubs/src/portable-console-bsp-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/portable-console-bsp-impl-stubs.c index 718ecfa67..58778d7f0 100644 --- a/src/unit-test-coverage/ut-stubs/src/portable-console-bsp-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/portable-console-bsp-impl-stubs.c @@ -37,8 +37,7 @@ /* ** Console output API (printf) */ -void OS_ConsoleOutput_Impl(uint32 local_id) +void OS_ConsoleOutput_Impl(uint32 local_id) { UT_DEFAULT_IMPL(OS_ConsoleOutput_Impl); } - diff --git a/src/unit-test-coverage/ut-stubs/src/posix-dirent-stubs.c b/src/unit-test-coverage/ut-stubs/src/posix-dirent-stubs.c index 38c1ca673..98b96b4d8 100644 --- a/src/unit-test-coverage/ut-stubs/src/posix-dirent-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/posix-dirent-stubs.c @@ -31,9 +31,9 @@ struct OCS_DIR }; static struct OCS_DIR OCS_LOCAL_DIR; -struct OCS_dirent OCS_LOCAL_DIRENT; +struct OCS_dirent OCS_LOCAL_DIRENT; -int OCS_closedir (OCS_DIR * dirp) +int OCS_closedir(OCS_DIR *dirp) { int32 Status; @@ -42,7 +42,7 @@ int OCS_closedir (OCS_DIR * dirp) return Status; } -OCS_DIR *OCS_opendir (const char * name) +OCS_DIR *OCS_opendir(const char *name) { int32 Status; @@ -50,22 +50,21 @@ OCS_DIR *OCS_opendir (const char * name) if (Status != 0) { - return (OCS_DIR*)0; + return (OCS_DIR *)0; } return &OCS_LOCAL_DIR; } -struct OCS_dirent *OCS_readdir (OCS_DIR * dirp) +struct OCS_dirent *OCS_readdir(OCS_DIR *dirp) { - int32 Status; + int32 Status; struct OCS_dirent *retval = (struct OCS_dirent *)0; Status = UT_DEFAULT_IMPL(OCS_readdir); - if (Status == 0 && - UT_Stub_CopyToLocal(UT_KEY(OCS_readdir), &retval, sizeof(retval)) < sizeof(retval) && - UT_GetStubCount(UT_KEY(OCS_readdir)) < 2) + if (Status == 0 && UT_Stub_CopyToLocal(UT_KEY(OCS_readdir), &retval, sizeof(retval)) < sizeof(retval) && + UT_GetStubCount(UT_KEY(OCS_readdir)) < 2) { memset(&OCS_LOCAL_DIRENT, 0, sizeof(OCS_LOCAL_DIRENT)); retval = &OCS_LOCAL_DIRENT; @@ -74,9 +73,7 @@ struct OCS_dirent *OCS_readdir (OCS_DIR * dirp) return retval; } -void OCS_rewinddir (OCS_DIR * dirp) +void OCS_rewinddir(OCS_DIR *dirp) { UT_DEFAULT_IMPL(OCS_rewinddir); } - - diff --git a/src/unit-test-coverage/ut-stubs/src/posix-dlfcn-stubs.c b/src/unit-test-coverage/ut-stubs/src/posix-dlfcn-stubs.c index 562012c97..0ce005221 100644 --- a/src/unit-test-coverage/ut-stubs/src/posix-dlfcn-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/posix-dlfcn-stubs.c @@ -34,11 +34,9 @@ /* prototypes normally declared in dlfcn.h */ /* ----------------------------------------- */ -extern int OCS_dlclose (void * handle); -extern char *OCS_dlerror (void); -extern void *OCS_dlopen (const char * file, int mode); -extern void *OCS_dlsym (void * handle, const char * name); - +extern int OCS_dlclose(void *handle); +extern char *OCS_dlerror(void); +extern void *OCS_dlopen(const char *file, int mode); +extern void *OCS_dlsym(void *handle, const char *name); #endif /* _OSAL_STUB_DLFCN_H_ */ - diff --git a/src/unit-test-coverage/ut-stubs/src/posix-errno-stubs.c b/src/unit-test-coverage/ut-stubs/src/posix-errno-stubs.c index bc475e274..7d4bc494c 100644 --- a/src/unit-test-coverage/ut-stubs/src/posix-errno-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/posix-errno-stubs.c @@ -26,5 +26,3 @@ #include int OCS_errno = 0; - - diff --git a/src/unit-test-coverage/ut-stubs/src/posix-fcntl-stubs.c b/src/unit-test-coverage/ut-stubs/src/posix-fcntl-stubs.c index 916c6150a..52bfa82c6 100644 --- a/src/unit-test-coverage/ut-stubs/src/posix-fcntl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/posix-fcntl-stubs.c @@ -25,7 +25,7 @@ #include -int OCS_fcntl (int fd, int cmd, ...) +int OCS_fcntl(int fd, int cmd, ...) { int32 Status; @@ -34,7 +34,7 @@ int OCS_fcntl (int fd, int cmd, ...) return Status; } -int OCS_open (const char * file, int oflag, ...) +int OCS_open(const char *file, int oflag, ...) { int32 Status; @@ -42,5 +42,3 @@ int OCS_open (const char * file, int oflag, ...) return Status; } - - diff --git a/src/unit-test-coverage/ut-stubs/src/posix-ioctl-stubs.c b/src/unit-test-coverage/ut-stubs/src/posix-ioctl-stubs.c index de2fc9605..dc4b4d299 100644 --- a/src/unit-test-coverage/ut-stubs/src/posix-ioctl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/posix-ioctl-stubs.c @@ -25,7 +25,7 @@ #include -int OCS_ioctl (int fd, unsigned long req, ...) +int OCS_ioctl(int fd, unsigned long req, ...) { int32 Status; @@ -33,4 +33,3 @@ int OCS_ioctl (int fd, unsigned long req, ...) return Status; } - diff --git a/src/unit-test-coverage/ut-stubs/src/posix-mqueue-stubs.c b/src/unit-test-coverage/ut-stubs/src/posix-mqueue-stubs.c index 8fda21a2f..63695333c 100644 --- a/src/unit-test-coverage/ut-stubs/src/posix-mqueue-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/posix-mqueue-stubs.c @@ -25,7 +25,7 @@ #include -int OCS_mq_close (OCS_mqd_t mqdes) +int OCS_mq_close(OCS_mqd_t mqdes) { int32 Status; @@ -34,7 +34,7 @@ int OCS_mq_close (OCS_mqd_t mqdes) return Status; } -OCS_mqd_t OCS_mq_open (const char * name, int oflag, ...) +OCS_mqd_t OCS_mq_open(const char *name, int oflag, ...) { int32 Status; @@ -43,7 +43,7 @@ OCS_mqd_t OCS_mq_open (const char * name, int oflag, ...) return Status; } -OCS_ssize_t OCS_mq_receive (OCS_mqd_t mqdes, char * msg_ptr, size_t msg_len, unsigned int * msg_prio) +OCS_ssize_t OCS_mq_receive(OCS_mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned int *msg_prio) { int32 Status; @@ -52,7 +52,8 @@ OCS_ssize_t OCS_mq_receive (OCS_mqd_t mqdes, char * msg_ptr, size_t msg_len, uns return Status; } -OCS_ssize_t OCS_mq_timedreceive (OCS_mqd_t mqdes, char * msg_ptr, size_t msg_len, unsigned int * msg_prio, const struct OCS_timespec * abs_timeout) +OCS_ssize_t OCS_mq_timedreceive(OCS_mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned int *msg_prio, + const struct OCS_timespec *abs_timeout) { int32 Status; @@ -61,7 +62,8 @@ OCS_ssize_t OCS_mq_timedreceive (OCS_mqd_t mqdes, char * msg_ptr, size_t msg_len return Status; } -int OCS_mq_timedsend (OCS_mqd_t mqdes, const char * msg_ptr, size_t msg_len, unsigned int msg_prio, const struct OCS_timespec * abs_timeout) +int OCS_mq_timedsend(OCS_mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio, + const struct OCS_timespec *abs_timeout) { int32 Status; @@ -70,7 +72,7 @@ int OCS_mq_timedsend (OCS_mqd_t mqdes, const char * msg_ptr, size_t msg_len, uns return Status; } -int OCS_mq_unlink (const char * name) +int OCS_mq_unlink(const char *name) { int32 Status; @@ -78,4 +80,3 @@ int OCS_mq_unlink (const char * name) return Status; } - diff --git a/src/unit-test-coverage/ut-stubs/src/posix-pthread-stubs.c b/src/unit-test-coverage/ut-stubs/src/posix-pthread-stubs.c index 97b426a85..f27231b82 100644 --- a/src/unit-test-coverage/ut-stubs/src/posix-pthread-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/posix-pthread-stubs.c @@ -25,7 +25,7 @@ #include -int OCS_pthread_attr_destroy (OCS_pthread_attr_t * attr) +int OCS_pthread_attr_destroy(OCS_pthread_attr_t *attr) { int32 Status; @@ -34,7 +34,7 @@ int OCS_pthread_attr_destroy (OCS_pthread_attr_t * attr) return Status; } -int OCS_pthread_attr_getschedparam (const OCS_pthread_attr_t * attr, struct OCS_sched_param * param) +int OCS_pthread_attr_getschedparam(const OCS_pthread_attr_t *attr, struct OCS_sched_param *param) { int32 Status; @@ -43,7 +43,7 @@ int OCS_pthread_attr_getschedparam (const OCS_pthread_attr_t * attr, struct OCS_ return Status; } -int OCS_pthread_attr_init (OCS_pthread_attr_t * attr) +int OCS_pthread_attr_init(OCS_pthread_attr_t *attr) { int32 Status; @@ -52,7 +52,7 @@ int OCS_pthread_attr_init (OCS_pthread_attr_t * attr) return Status; } -int OCS_pthread_attr_setinheritsched (OCS_pthread_attr_t * attr, int inherit) +int OCS_pthread_attr_setinheritsched(OCS_pthread_attr_t *attr, int inherit) { int32 Status; @@ -61,7 +61,7 @@ int OCS_pthread_attr_setinheritsched (OCS_pthread_attr_t * attr, int inherit) return Status; } -int OCS_pthread_attr_setschedparam (OCS_pthread_attr_t * attr, const struct OCS_sched_param * param) +int OCS_pthread_attr_setschedparam(OCS_pthread_attr_t *attr, const struct OCS_sched_param *param) { int32 Status; @@ -70,7 +70,7 @@ int OCS_pthread_attr_setschedparam (OCS_pthread_attr_t * attr, const struct OCS_ return Status; } -int OCS_pthread_attr_setschedpolicy (OCS_pthread_attr_t * attr, int policy) +int OCS_pthread_attr_setschedpolicy(OCS_pthread_attr_t *attr, int policy) { int32 Status; @@ -79,7 +79,7 @@ int OCS_pthread_attr_setschedpolicy (OCS_pthread_attr_t * attr, int policy) return Status; } -int OCS_pthread_attr_setstacksize (OCS_pthread_attr_t * attr, size_t stacksize) +int OCS_pthread_attr_setstacksize(OCS_pthread_attr_t *attr, size_t stacksize) { int32 Status; @@ -88,7 +88,7 @@ int OCS_pthread_attr_setstacksize (OCS_pthread_attr_t * attr, size_t stacksize) return Status; } -int OCS_pthread_cancel (OCS_pthread_t th) +int OCS_pthread_cancel(OCS_pthread_t th) { int32 Status; @@ -97,7 +97,7 @@ int OCS_pthread_cancel (OCS_pthread_t th) return Status; } -int OCS_pthread_cond_broadcast (OCS_pthread_cond_t * cond) +int OCS_pthread_cond_broadcast(OCS_pthread_cond_t *cond) { int32 Status; @@ -106,7 +106,7 @@ int OCS_pthread_cond_broadcast (OCS_pthread_cond_t * cond) return Status; } -int OCS_pthread_cond_destroy (OCS_pthread_cond_t * cond) +int OCS_pthread_cond_destroy(OCS_pthread_cond_t *cond) { int32 Status; @@ -115,7 +115,7 @@ int OCS_pthread_cond_destroy (OCS_pthread_cond_t * cond) return Status; } -int OCS_pthread_cond_init (OCS_pthread_cond_t * cond, const OCS_pthread_condattr_t * cond_attr) +int OCS_pthread_cond_init(OCS_pthread_cond_t *cond, const OCS_pthread_condattr_t *cond_attr) { int32 Status; @@ -123,7 +123,7 @@ int OCS_pthread_cond_init (OCS_pthread_cond_t * cond, const OCS_pthread_condattr return Status; } -int OCS_pthread_cond_signal (OCS_pthread_cond_t * cond) +int OCS_pthread_cond_signal(OCS_pthread_cond_t *cond) { int32 Status; @@ -132,7 +132,7 @@ int OCS_pthread_cond_signal (OCS_pthread_cond_t * cond) return Status; } -int OCS_pthread_cond_timedwait (OCS_pthread_cond_t * cond, OCS_pthread_mutex_t * mutex, const struct OCS_timespec * abstime) +int OCS_pthread_cond_timedwait(OCS_pthread_cond_t *cond, OCS_pthread_mutex_t *mutex, const struct OCS_timespec *abstime) { int32 Status; @@ -141,7 +141,7 @@ int OCS_pthread_cond_timedwait (OCS_pthread_cond_t * cond, OCS_pthread_mutex_t * return Status; } -int OCS_pthread_cond_wait (OCS_pthread_cond_t * cond, OCS_pthread_mutex_t * mutex) +int OCS_pthread_cond_wait(OCS_pthread_cond_t *cond, OCS_pthread_mutex_t *mutex) { int32 Status; @@ -150,7 +150,8 @@ int OCS_pthread_cond_wait (OCS_pthread_cond_t * cond, OCS_pthread_mutex_t * mute return Status; } -int OCS_pthread_create (OCS_pthread_t * newthread, const OCS_pthread_attr_t * attr, void *(* start_routine) (void *), void * arg) +int OCS_pthread_create(OCS_pthread_t *newthread, const OCS_pthread_attr_t *attr, void *(*start_routine)(void *), + void *arg) { int32 Status; @@ -159,7 +160,7 @@ int OCS_pthread_create (OCS_pthread_t * newthread, const OCS_pthread_attr_t * at return Status; } -int OCS_pthread_detach (OCS_pthread_t th) +int OCS_pthread_detach(OCS_pthread_t th) { int32 Status; @@ -168,7 +169,7 @@ int OCS_pthread_detach (OCS_pthread_t th) return Status; } -int OCS_pthread_equal (OCS_pthread_t thread1, OCS_pthread_t thread2) +int OCS_pthread_equal(OCS_pthread_t thread1, OCS_pthread_t thread2) { int32 Status; @@ -182,12 +183,12 @@ int OCS_pthread_equal (OCS_pthread_t thread1, OCS_pthread_t thread2) return Status; } -void OCS_pthread_exit (void * retval) +void OCS_pthread_exit(void *retval) { UT_DEFAULT_IMPL(OCS_pthread_exit); } -int OCS_pthread_getschedparam (OCS_pthread_t target_thread, int * policy, struct OCS_sched_param * param) +int OCS_pthread_getschedparam(OCS_pthread_t target_thread, int *policy, struct OCS_sched_param *param) { int32 Status; @@ -196,24 +197,22 @@ int OCS_pthread_getschedparam (OCS_pthread_t target_thread, int * policy, struct return Status; } -void *OCS_pthread_getspecific (OCS_pthread_key_t key) +void *OCS_pthread_getspecific(OCS_pthread_key_t key) { int32 Status; void *retval; Status = UT_DEFAULT_IMPL(OCS_pthread_getspecific); - if (Status != 0 || - UT_Stub_CopyToLocal(UT_KEY(OCS_pthread_getspecific), &retval, sizeof(retval)) < sizeof(retval)) + if (Status != 0 || UT_Stub_CopyToLocal(UT_KEY(OCS_pthread_getspecific), &retval, sizeof(retval)) < sizeof(retval)) { retval = NULL; } - return retval; } -int OCS_pthread_key_create (OCS_pthread_key_t * key, void (* destr_function) (void *)) +int OCS_pthread_key_create(OCS_pthread_key_t *key, void (*destr_function)(void *)) { int32 Status; @@ -222,7 +221,7 @@ int OCS_pthread_key_create (OCS_pthread_key_t * key, void (* destr_function) (vo return Status; } -int OCS_pthread_mutexattr_destroy (OCS_pthread_mutexattr_t * attr) +int OCS_pthread_mutexattr_destroy(OCS_pthread_mutexattr_t *attr) { int32 Status; @@ -231,7 +230,7 @@ int OCS_pthread_mutexattr_destroy (OCS_pthread_mutexattr_t * attr) return Status; } -int OCS_pthread_mutexattr_init (OCS_pthread_mutexattr_t * attr) +int OCS_pthread_mutexattr_init(OCS_pthread_mutexattr_t *attr) { int32 Status; @@ -240,7 +239,7 @@ int OCS_pthread_mutexattr_init (OCS_pthread_mutexattr_t * attr) return Status; } -int OCS_pthread_mutexattr_setprotocol (OCS_pthread_mutexattr_t * attr, int protocol) +int OCS_pthread_mutexattr_setprotocol(OCS_pthread_mutexattr_t *attr, int protocol) { int32 Status; @@ -249,7 +248,7 @@ int OCS_pthread_mutexattr_setprotocol (OCS_pthread_mutexattr_t * attr, int proto return Status; } -int OCS_pthread_mutexattr_settype (OCS_pthread_mutexattr_t * attr, int kind) +int OCS_pthread_mutexattr_settype(OCS_pthread_mutexattr_t *attr, int kind) { int32 Status; @@ -258,7 +257,7 @@ int OCS_pthread_mutexattr_settype (OCS_pthread_mutexattr_t * attr, int kind) return Status; } -int OCS_pthread_mutex_destroy (OCS_pthread_mutex_t * mutex) +int OCS_pthread_mutex_destroy(OCS_pthread_mutex_t *mutex) { int32 Status; @@ -267,7 +266,7 @@ int OCS_pthread_mutex_destroy (OCS_pthread_mutex_t * mutex) return Status; } -int OCS_pthread_mutex_init (OCS_pthread_mutex_t * mutex, const OCS_pthread_mutexattr_t * mutexattr) +int OCS_pthread_mutex_init(OCS_pthread_mutex_t *mutex, const OCS_pthread_mutexattr_t *mutexattr) { int32 Status; @@ -276,7 +275,7 @@ int OCS_pthread_mutex_init (OCS_pthread_mutex_t * mutex, const OCS_pthread_mutex return Status; } -int OCS_pthread_mutex_lock (OCS_pthread_mutex_t * mutex) +int OCS_pthread_mutex_lock(OCS_pthread_mutex_t *mutex) { int32 Status; @@ -285,7 +284,7 @@ int OCS_pthread_mutex_lock (OCS_pthread_mutex_t * mutex) return Status; } -int OCS_pthread_mutex_unlock (OCS_pthread_mutex_t * mutex) +int OCS_pthread_mutex_unlock(OCS_pthread_mutex_t *mutex) { int32 Status; @@ -294,7 +293,7 @@ int OCS_pthread_mutex_unlock (OCS_pthread_mutex_t * mutex) return Status; } -OCS_pthread_t OCS_pthread_self (void) +OCS_pthread_t OCS_pthread_self(void) { OCS_pthread_t result; @@ -303,7 +302,7 @@ OCS_pthread_t OCS_pthread_self (void) return result; } -int OCS_pthread_setschedparam (OCS_pthread_t target_thread, int policy, const struct OCS_sched_param * param) +int OCS_pthread_setschedparam(OCS_pthread_t target_thread, int policy, const struct OCS_sched_param *param) { int32 Status; @@ -312,7 +311,7 @@ int OCS_pthread_setschedparam (OCS_pthread_t target_thread, int policy, const st return Status; } -int OCS_pthread_setschedprio (OCS_pthread_t target_thread, int prio) +int OCS_pthread_setschedprio(OCS_pthread_t target_thread, int prio) { int32 Status; @@ -321,7 +320,7 @@ int OCS_pthread_setschedprio (OCS_pthread_t target_thread, int prio) return Status; } -int OCS_pthread_setspecific (OCS_pthread_key_t key, const void * pointer) +int OCS_pthread_setspecific(OCS_pthread_key_t key, const void *pointer) { int32 Status; @@ -330,7 +329,7 @@ int OCS_pthread_setspecific (OCS_pthread_key_t key, const void * pointer) return Status; } -int OCS_pthread_sigmask (int how, const OCS_sigset_t *set, OCS_sigset_t * oldset) +int OCS_pthread_sigmask(int how, const OCS_sigset_t *set, OCS_sigset_t *oldset) { int32 Status; @@ -338,4 +337,3 @@ int OCS_pthread_sigmask (int how, const OCS_sigset_t *set, OCS_sigset_t * oldset return Status; } - diff --git a/src/unit-test-coverage/ut-stubs/src/posix-sched-stubs.c b/src/unit-test-coverage/ut-stubs/src/posix-sched-stubs.c index efb51b431..c73fd4f36 100644 --- a/src/unit-test-coverage/ut-stubs/src/posix-sched-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/posix-sched-stubs.c @@ -25,25 +25,20 @@ #include - int OCS_sched_get_priority_max(int policy) { int32 Status; - Status = UT_DEFAULT_IMPL_RC(OCS_sched_get_priority_max,9); + Status = UT_DEFAULT_IMPL_RC(OCS_sched_get_priority_max, 9); return Status; } - int OCS_sched_get_priority_min(int policy) { int32 Status; - Status = UT_DEFAULT_IMPL_RC(OCS_sched_get_priority_min,1); + Status = UT_DEFAULT_IMPL_RC(OCS_sched_get_priority_min, 1); return Status; } - - - diff --git a/src/unit-test-coverage/ut-stubs/src/posix-semaphore-stubs.c b/src/unit-test-coverage/ut-stubs/src/posix-semaphore-stubs.c index 70d1254ec..050664b58 100644 --- a/src/unit-test-coverage/ut-stubs/src/posix-semaphore-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/posix-semaphore-stubs.c @@ -25,7 +25,7 @@ #include -int OCS_sem_destroy (OCS_sem_t * sem) +int OCS_sem_destroy(OCS_sem_t *sem) { int32 Status; @@ -34,7 +34,7 @@ int OCS_sem_destroy (OCS_sem_t * sem) return Status; } -int OCS_sem_getvalue (OCS_sem_t * sem, int * sval) +int OCS_sem_getvalue(OCS_sem_t *sem, int *sval) { int32 Status; @@ -43,7 +43,7 @@ int OCS_sem_getvalue (OCS_sem_t * sem, int * sval) return Status; } -int OCS_sem_init (OCS_sem_t * sem, int pshared, unsigned int value) +int OCS_sem_init(OCS_sem_t *sem, int pshared, unsigned int value) { int32 Status; @@ -52,7 +52,7 @@ int OCS_sem_init (OCS_sem_t * sem, int pshared, unsigned int value) return Status; } -int OCS_sem_post (OCS_sem_t * sem) +int OCS_sem_post(OCS_sem_t *sem) { int32 Status; @@ -61,7 +61,7 @@ int OCS_sem_post (OCS_sem_t * sem) return Status; } -int OCS_sem_timedwait (OCS_sem_t * sem, const struct OCS_timespec * abstime) +int OCS_sem_timedwait(OCS_sem_t *sem, const struct OCS_timespec *abstime) { int32 Status; @@ -70,7 +70,7 @@ int OCS_sem_timedwait (OCS_sem_t * sem, const struct OCS_timespec * abstime) return Status; } -int OCS_sem_wait (OCS_sem_t * sem) +int OCS_sem_wait(OCS_sem_t *sem) { int32 Status; @@ -78,5 +78,3 @@ int OCS_sem_wait (OCS_sem_t * sem) return Status; } - - diff --git a/src/unit-test-coverage/ut-stubs/src/posix-signal-stubs.c b/src/unit-test-coverage/ut-stubs/src/posix-signal-stubs.c index 074bf44c2..3ab5f74c3 100644 --- a/src/unit-test-coverage/ut-stubs/src/posix-signal-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/posix-signal-stubs.c @@ -25,7 +25,7 @@ #include -int OCS_kill (OCS_pid_t pid, int sig) +int OCS_kill(OCS_pid_t pid, int sig) { int32 Status; @@ -34,8 +34,7 @@ int OCS_kill (OCS_pid_t pid, int sig) return Status; } - -int OCS_sigaddset (OCS_sigset_t * set, int signo) +int OCS_sigaddset(OCS_sigset_t *set, int signo) { int32 Status; @@ -44,8 +43,7 @@ int OCS_sigaddset (OCS_sigset_t * set, int signo) return Status; } - -int OCS_sigdelset (OCS_sigset_t * set, int signo) +int OCS_sigdelset(OCS_sigset_t *set, int signo) { int32 Status; @@ -54,8 +52,7 @@ int OCS_sigdelset (OCS_sigset_t * set, int signo) return Status; } - -int OCS_sigemptyset (OCS_sigset_t * set) +int OCS_sigemptyset(OCS_sigset_t *set) { int32 Status; @@ -64,8 +61,7 @@ int OCS_sigemptyset (OCS_sigset_t * set) return Status; } - -int OCS_sigfillset (OCS_sigset_t * set) +int OCS_sigfillset(OCS_sigset_t *set) { int32 Status; @@ -74,8 +70,7 @@ int OCS_sigfillset (OCS_sigset_t * set) return Status; } - -int OCS_sigismember (const OCS_sigset_t * set, int signo) +int OCS_sigismember(const OCS_sigset_t *set, int signo) { int32 Status; @@ -84,15 +79,13 @@ int OCS_sigismember (const OCS_sigset_t * set, int signo) return Status; } - OCS_sighandler_t OCS_signal(int signum, OCS_sighandler_t handler) { UT_DEFAULT_IMPL(OCS_signal); return (OCS_sighandler_t)0; } - -int OCS_sigprocmask (int how, const OCS_sigset_t * set, OCS_sigset_t * oset) +int OCS_sigprocmask(int how, const OCS_sigset_t *set, OCS_sigset_t *oset) { int32 Status; @@ -101,8 +94,7 @@ int OCS_sigprocmask (int how, const OCS_sigset_t * set, OCS_sigset_t * oset) return Status; } - -int OCS_sigsuspend (const OCS_sigset_t * set) +int OCS_sigsuspend(const OCS_sigset_t *set) { int32 Status; @@ -111,8 +103,7 @@ int OCS_sigsuspend (const OCS_sigset_t * set) return Status; } - -int OCS_sigwait (const OCS_sigset_t * set, int * sig) +int OCS_sigwait(const OCS_sigset_t *set, int *sig) { int32 Status; @@ -122,12 +113,10 @@ int OCS_sigwait (const OCS_sigset_t * set, int * sig) * The "sig" value is an output, which the UT test * case may need to control. */ - if (UT_Stub_CopyToLocal(UT_KEY(OCS_sigwait),sig,sizeof(*sig)) < sizeof(*sig)) + if (UT_Stub_CopyToLocal(UT_KEY(OCS_sigwait), sig, sizeof(*sig)) < sizeof(*sig)) { *sig = 1; } return Status; } - - diff --git a/src/unit-test-coverage/ut-stubs/src/posix-stat-stubs.c b/src/unit-test-coverage/ut-stubs/src/posix-stat-stubs.c index 7b38cd19f..af937bd9f 100644 --- a/src/unit-test-coverage/ut-stubs/src/posix-stat-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/posix-stat-stubs.c @@ -25,8 +25,7 @@ #include - -int OCS_fchmod (int fd, OCS_mode_t mode) +int OCS_fchmod(int fd, OCS_mode_t mode) { int32 Status; @@ -35,7 +34,7 @@ int OCS_fchmod (int fd, OCS_mode_t mode) return Status; } -int OCS_chmod (const char *path, OCS_mode_t mode) +int OCS_chmod(const char *path, OCS_mode_t mode) { int32 Status; @@ -44,7 +43,7 @@ int OCS_chmod (const char *path, OCS_mode_t mode) return Status; } -int OCS_mkdir (const char * path, ...) +int OCS_mkdir(const char *path, ...) { int32 Status; @@ -53,14 +52,13 @@ int OCS_mkdir (const char * path, ...) return Status; } -int OCS_stat (const char * file, struct OCS_stat * buf) +int OCS_stat(const char *file, struct OCS_stat *buf) { int32 Status; Status = UT_DEFAULT_IMPL(OCS_stat); - if (Status == 0 && - UT_Stub_CopyToLocal(UT_KEY(OCS_stat), buf, sizeof(*buf)) < sizeof(*buf)) + if (Status == 0 && UT_Stub_CopyToLocal(UT_KEY(OCS_stat), buf, sizeof(*buf)) < sizeof(*buf)) { memset(buf, 0, sizeof(*buf)); } @@ -68,18 +66,16 @@ int OCS_stat (const char * file, struct OCS_stat * buf) return Status; } -int OCS_statvfs (const char * file, struct OCS_statvfs * buf) +int OCS_statvfs(const char *file, struct OCS_statvfs *buf) { int32 Status; Status = UT_DEFAULT_IMPL(OCS_statvfs); - if (Status == 0 && - UT_Stub_CopyToLocal(UT_KEY(OCS_statvfs), buf, sizeof(*buf)) < sizeof(*buf)) + if (Status == 0 && UT_Stub_CopyToLocal(UT_KEY(OCS_statvfs), buf, sizeof(*buf)) < sizeof(*buf)) { memset(buf, 0, sizeof(*buf)); } return Status; } - diff --git a/src/unit-test-coverage/ut-stubs/src/posix-time-stubs.c b/src/unit-test-coverage/ut-stubs/src/posix-time-stubs.c index af6fb1270..7b447ca72 100644 --- a/src/unit-test-coverage/ut-stubs/src/posix-time-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/posix-time-stubs.c @@ -25,7 +25,7 @@ #include -int OCS_clock_getres (OCS_clockid_t clock_id, struct OCS_timespec * res) +int OCS_clock_getres(OCS_clockid_t clock_id, struct OCS_timespec *res) { int32 Status; @@ -34,23 +34,21 @@ int OCS_clock_getres (OCS_clockid_t clock_id, struct OCS_timespec * res) return Status; } -int OCS_clock_gettime (OCS_clockid_t clock_id, struct OCS_timespec * tp) +int OCS_clock_gettime(OCS_clockid_t clock_id, struct OCS_timespec *tp) { int32 Status; Status = UT_DEFAULT_IMPL(OCS_clock_gettime); - if (Status == 0 && - UT_Stub_CopyToLocal(UT_KEY(OCS_clock_gettime), tp, sizeof(*tp)) < sizeof(*tp)) + if (Status == 0 && UT_Stub_CopyToLocal(UT_KEY(OCS_clock_gettime), tp, sizeof(*tp)) < sizeof(*tp)) { memset(tp, 0, sizeof(*tp)); } - return Status; } -int OCS_clock_nanosleep (OCS_clockid_t clock_id, int flags, const struct OCS_timespec * req, struct OCS_timespec * rem) +int OCS_clock_nanosleep(OCS_clockid_t clock_id, int flags, const struct OCS_timespec *req, struct OCS_timespec *rem) { int32 Status; @@ -59,7 +57,7 @@ int OCS_clock_nanosleep (OCS_clockid_t clock_id, int flags, const struct OCS_tim return Status; } -int OCS_clock_settime (OCS_clockid_t clock_id, const struct OCS_timespec * tp) +int OCS_clock_settime(OCS_clockid_t clock_id, const struct OCS_timespec *tp) { int32 Status; @@ -68,7 +66,7 @@ int OCS_clock_settime (OCS_clockid_t clock_id, const struct OCS_timespec * tp) return Status; } -int OCS_timer_create (OCS_clockid_t clock_id, struct OCS_sigevent * evp, OCS_timer_t * timerid) +int OCS_timer_create(OCS_clockid_t clock_id, struct OCS_sigevent *evp, OCS_timer_t *timerid) { int32 Status; @@ -77,7 +75,7 @@ int OCS_timer_create (OCS_clockid_t clock_id, struct OCS_sigevent * evp, OCS_tim return Status; } -int OCS_timer_delete (OCS_timer_t timerid) +int OCS_timer_delete(OCS_timer_t timerid) { int32 Status; @@ -86,7 +84,7 @@ int OCS_timer_delete (OCS_timer_t timerid) return Status; } -int OCS_timer_settime (OCS_timer_t timerid, int flags, const struct OCS_itimerspec * value, struct OCS_itimerspec * ovalue) +int OCS_timer_settime(OCS_timer_t timerid, int flags, const struct OCS_itimerspec *value, struct OCS_itimerspec *ovalue) { int32 Status; @@ -99,7 +97,7 @@ int OCS_timer_settime (OCS_timer_t timerid, int flags, const struct OCS_itimersp return Status; } -int OCS_timer_gettime (OCS_timer_t timerid, struct OCS_itimerspec * value) +int OCS_timer_gettime(OCS_timer_t timerid, struct OCS_itimerspec *value) { int32 Status; @@ -112,4 +110,3 @@ int OCS_timer_gettime (OCS_timer_t timerid, struct OCS_itimerspec * value) return Status; } - diff --git a/src/unit-test-coverage/ut-stubs/src/posix-unistd-stubs.c b/src/unit-test-coverage/ut-stubs/src/posix-unistd-stubs.c index 959bb0629..20cff601a 100644 --- a/src/unit-test-coverage/ut-stubs/src/posix-unistd-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/posix-unistd-stubs.c @@ -25,11 +25,9 @@ #include +#define OCS_MAX_RDWR_SIZE 0x01000000 /* 16MB */ -#define OCS_MAX_RDWR_SIZE 0x01000000 /* 16MB */ - - -int OCS_close (int fd) +int OCS_close(int fd) { int32 Status; @@ -38,8 +36,7 @@ int OCS_close (int fd) return Status; } - -OCS_gid_t OCS_getegid (void) +OCS_gid_t OCS_getegid(void) { int32 Status; @@ -48,8 +45,7 @@ OCS_gid_t OCS_getegid (void) return Status; } - -OCS_uid_t OCS_geteuid (void) +OCS_uid_t OCS_geteuid(void) { int32 Status; @@ -58,8 +54,7 @@ OCS_uid_t OCS_geteuid (void) return Status; } - -long int OCS_gethostid (void) +long int OCS_gethostid(void) { int32 Status; @@ -68,8 +63,7 @@ long int OCS_gethostid (void) return Status; } - -int OCS_gethostname (char * name, size_t len) +int OCS_gethostname(char *name, size_t len) { int32 Status; @@ -77,15 +71,14 @@ int OCS_gethostname (char * name, size_t len) if (Status == 0 && len > 0) { - strncpy(name, "ut", len-1); - name[len-1] = 0; + strncpy(name, "ut", len - 1); + name[len - 1] = 0; } return Status; } - -OCS_pid_t OCS_getpid (void) +OCS_pid_t OCS_getpid(void) { int32 Status; @@ -94,8 +87,7 @@ OCS_pid_t OCS_getpid (void) return Status; } - -OCS_off_t OCS_lseek (int fd, OCS_off_t offset, int whence) +OCS_off_t OCS_lseek(int fd, OCS_off_t offset, int whence) { int32 Status; @@ -104,10 +96,9 @@ OCS_off_t OCS_lseek (int fd, OCS_off_t offset, int whence) return Status; } - -OCS_ssize_t OCS_read (int fd, void * buf, size_t n) +OCS_ssize_t OCS_read(int fd, void *buf, size_t n) { - int32 Status; + int32 Status; uint32 CopySize; Status = UT_DEFAULT_IMPL_RC(OCS_read, OCS_MAX_RDWR_SIZE); @@ -147,8 +138,7 @@ OCS_ssize_t OCS_read (int fd, void * buf, size_t n) return Status; } - -int OCS_rmdir (const char * path) +int OCS_rmdir(const char *path) { int32 Status; @@ -157,8 +147,7 @@ int OCS_rmdir (const char * path) return Status; } - -long int OCS_sysconf (int name) +long int OCS_sysconf(int name) { int32 Status; @@ -167,10 +156,9 @@ long int OCS_sysconf (int name) return Status; } - -OCS_ssize_t OCS_write (int fd, const void * buf, size_t n) +OCS_ssize_t OCS_write(int fd, const void *buf, size_t n) { - int32 Status; + int32 Status; uint32 CopySize; Status = UT_DEFAULT_IMPL_RC(OCS_write, OCS_MAX_RDWR_SIZE); @@ -200,5 +188,3 @@ OCS_ssize_t OCS_write (int fd, const void * buf, size_t n) return Status; } - - diff --git a/src/unit-test-coverage/ut-stubs/src/vxworks-ataDrv-stubs.c b/src/unit-test-coverage/ut-stubs/src/vxworks-ataDrv-stubs.c index 5a44de35d..53a59e670 100644 --- a/src/unit-test-coverage/ut-stubs/src/vxworks-ataDrv-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/vxworks-ataDrv-stubs.c @@ -25,11 +25,11 @@ #include -static OCS_BLK_DEV LOCAL_ATADEV = { 0 }; +static OCS_BLK_DEV LOCAL_ATADEV = {0}; OCS_BLK_DEV *OCS_ataDevCreate(int ctrl, int drive, unsigned int nBlocks, unsigned int blkOffset) { - int32 Status; + int32 Status; OCS_BLK_DEV *retval = NULL; Status = UT_DEFAULT_IMPL(OCS_ataDevCreate); @@ -40,6 +40,3 @@ OCS_BLK_DEV *OCS_ataDevCreate(int ctrl, int drive, unsigned int nBlocks, unsigne return retval; } - - - diff --git a/src/unit-test-coverage/ut-stubs/src/vxworks-dosFsLib-stubs.c b/src/unit-test-coverage/ut-stubs/src/vxworks-dosFsLib-stubs.c index 231383c31..902d0071f 100644 --- a/src/unit-test-coverage/ut-stubs/src/vxworks-dosFsLib-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/vxworks-dosFsLib-stubs.c @@ -25,7 +25,6 @@ #include - /* ----------------------------------------- */ /* prototypes normally declared in dosFsLib.h */ /* ----------------------------------------- */ @@ -33,4 +32,3 @@ OCS_STATUS OCS_dosFsVolFormat(char *path, int opt, OCS_FUNCPTR pPromptFunc) { return (UT_DEFAULT_IMPL(OCS_dosFsVolFormat)); } - diff --git a/src/unit-test-coverage/ut-stubs/src/vxworks-errnoLib-stubs.c b/src/unit-test-coverage/ut-stubs/src/vxworks-errnoLib-stubs.c index e6db0d510..c9671ae7f 100644 --- a/src/unit-test-coverage/ut-stubs/src/vxworks-errnoLib-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/vxworks-errnoLib-stubs.c @@ -25,8 +25,7 @@ #include - -int OCS_errnoGet (void) +int OCS_errnoGet(void) { return UT_DEFAULT_IMPL(OCS_errnoGet); } diff --git a/src/unit-test-coverage/ut-stubs/src/vxworks-hostLib-stubs.c b/src/unit-test-coverage/ut-stubs/src/vxworks-hostLib-stubs.c index 45c0b0375..2c803e214 100644 --- a/src/unit-test-coverage/ut-stubs/src/vxworks-hostLib-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/vxworks-hostLib-stubs.c @@ -32,7 +32,7 @@ #include -int OCS_hostGetByName (char *name) +int OCS_hostGetByName(char *name) { return (UT_DEFAULT_IMPL(OCS_hostGetByName)); } diff --git a/src/unit-test-coverage/ut-stubs/src/vxworks-intLib-stubs.c b/src/unit-test-coverage/ut-stubs/src/vxworks-intLib-stubs.c index da499e5a6..d72d25a91 100644 --- a/src/unit-test-coverage/ut-stubs/src/vxworks-intLib-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/vxworks-intLib-stubs.c @@ -25,7 +25,6 @@ #include - OCS_STATUS OCS_intConnect(OCS_VOIDFUNCPTR *vector, OCS_VOIDFUNCPTR routine, int parameter) { return (UT_DEFAULT_IMPL(OCS_intConnect)); @@ -47,20 +46,18 @@ int OCS_intUnlock(int lockKey) return (UT_DEFAULT_IMPL(OCS_intUnlock)); } -static void OCS_intLib_dummyfunc(void) -{ -} +static void OCS_intLib_dummyfunc(void) {} -OCS_VOIDFUNCPTR * OCS_INUM_TO_IVEC(unsigned int ui) +OCS_VOIDFUNCPTR *OCS_INUM_TO_IVEC(unsigned int ui) { - int32 Status = UT_DEFAULT_IMPL(OCS_INUM_TO_IVEC); + int32 Status = UT_DEFAULT_IMPL(OCS_INUM_TO_IVEC); OCS_VOIDFUNCPTR *VecTbl; - OCS_VOIDFUNCPTR DummyVec; - uint32 VecTblSize; + OCS_VOIDFUNCPTR DummyVec; + uint32 VecTblSize; if (Status == 0) { - UT_GetDataBuffer(UT_KEY(OCS_INUM_TO_IVEC), (void**)&VecTbl, &VecTblSize, NULL); + UT_GetDataBuffer(UT_KEY(OCS_INUM_TO_IVEC), (void **)&VecTbl, &VecTblSize, NULL); if (VecTbl != NULL && ui < (VecTblSize / sizeof(OCS_VOIDFUNCPTR))) { VecTbl += ui; @@ -68,7 +65,7 @@ OCS_VOIDFUNCPTR * OCS_INUM_TO_IVEC(unsigned int ui) else { DummyVec = &OCS_intLib_dummyfunc; - VecTbl = &DummyVec; + VecTbl = &DummyVec; } } else @@ -78,6 +75,3 @@ OCS_VOIDFUNCPTR * OCS_INUM_TO_IVEC(unsigned int ui) return VecTbl; } - - - diff --git a/src/unit-test-coverage/ut-stubs/src/vxworks-loadLib-stubs.c b/src/unit-test-coverage/ut-stubs/src/vxworks-loadLib-stubs.c index 64d90e8de..ed2a56f08 100644 --- a/src/unit-test-coverage/ut-stubs/src/vxworks-loadLib-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/vxworks-loadLib-stubs.c @@ -26,11 +26,11 @@ #include #include -static OCS_MODULE LOCAL_MODULE = { 0 }; +static OCS_MODULE LOCAL_MODULE = {0}; OCS_MODULE_ID OCS_loadModule(int fd, unsigned int symFlag) { - int32 Status; + int32 Status; OCS_MODULE_ID retval; Status = UT_DEFAULT_IMPL(OCS_loadModule); @@ -50,4 +50,3 @@ OCS_STATUS OCS_unldByModuleId(OCS_MODULE_ID moduleId, int options) { return (UT_DEFAULT_IMPL(OCS_unldByModuleId)); } - diff --git a/src/unit-test-coverage/ut-stubs/src/vxworks-memPartLib-stubs.c b/src/unit-test-coverage/ut-stubs/src/vxworks-memPartLib-stubs.c index 9353acd6c..555385522 100644 --- a/src/unit-test-coverage/ut-stubs/src/vxworks-memPartLib-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/vxworks-memPartLib-stubs.c @@ -30,12 +30,9 @@ OCS_STATUS OCS_memPartShow(OCS_PART_ID partId, int type) return (UT_DEFAULT_IMPL(OCS_memPartShow)); } -OCS_STATUS OCS_memPartInfoGet(OCS_PART_ID partId, OCS_MEM_PART_STATS * ppartStats) +OCS_STATUS OCS_memPartInfoGet(OCS_PART_ID partId, OCS_MEM_PART_STATS *ppartStats) { return (UT_DEFAULT_IMPL(OCS_memPartInfoGet)); } - - OCS_PART_ID OCS_memSysPartId; - diff --git a/src/unit-test-coverage/ut-stubs/src/vxworks-moduleLib-stubs.c b/src/unit-test-coverage/ut-stubs/src/vxworks-moduleLib-stubs.c index ac38fee11..06a42946d 100644 --- a/src/unit-test-coverage/ut-stubs/src/vxworks-moduleLib-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/vxworks-moduleLib-stubs.c @@ -25,14 +25,14 @@ #include -OCS_STATUS OCS_moduleInfoGet(OCS_MODULE_ID moduleId, OCS_MODULE_INFO * pModuleInfo) +OCS_STATUS OCS_moduleInfoGet(OCS_MODULE_ID moduleId, OCS_MODULE_INFO *pModuleInfo) { int32 Status; Status = UT_DEFAULT_IMPL(OCS_moduleInfoGet); if (Status == 0 && - UT_Stub_CopyToLocal(UT_KEY(OCS_moduleInfoGet), pModuleInfo, sizeof(*pModuleInfo)) < sizeof(*pModuleInfo)) + UT_Stub_CopyToLocal(UT_KEY(OCS_moduleInfoGet), pModuleInfo, sizeof(*pModuleInfo)) < sizeof(*pModuleInfo)) { memset(pModuleInfo, 0, sizeof(*pModuleInfo)); } diff --git a/src/unit-test-coverage/ut-stubs/src/vxworks-msgQLib-stubs.c b/src/unit-test-coverage/ut-stubs/src/vxworks-msgQLib-stubs.c index 96e7c300f..e240d90f1 100644 --- a/src/unit-test-coverage/ut-stubs/src/vxworks-msgQLib-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/vxworks-msgQLib-stubs.c @@ -25,11 +25,11 @@ #include -static OCS_MSG_Q LOCAL_UT_MSGQ = { 0 }; +static OCS_MSG_Q LOCAL_UT_MSGQ = {0}; OCS_MSG_Q_ID OCS_msgQCreate(int maxMsgs, int maxMsgLength, int options) { - int32 Status; + int32 Status; OCS_MSG_Q_ID retval; Status = UT_DEFAULT_IMPL(OCS_msgQCreate); @@ -48,7 +48,7 @@ OCS_STATUS OCS_msgQDelete(OCS_MSG_Q_ID msgQId) { return (UT_DEFAULT_IMPL(OCS_msgQDelete)); } -int OCS_msgQReceive(OCS_MSG_Q_ID msgQId, char * buffer, OCS_UINT maxNBytes, int timeout) +int OCS_msgQReceive(OCS_MSG_Q_ID msgQId, char *buffer, OCS_UINT maxNBytes, int timeout) { return (UT_DEFAULT_IMPL(OCS_msgQReceive)); } @@ -56,5 +56,3 @@ OCS_STATUS OCS_msgQSend(OCS_MSG_Q_ID msgQId, char *buffer, OCS_UINT nBytes, int { return (UT_DEFAULT_IMPL(OCS_msgQSend)); } - - diff --git a/src/unit-test-coverage/ut-stubs/src/vxworks-ramDrv-stubs.c b/src/unit-test-coverage/ut-stubs/src/vxworks-ramDrv-stubs.c index 56320e13c..85fc78bfb 100644 --- a/src/unit-test-coverage/ut-stubs/src/vxworks-ramDrv-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/vxworks-ramDrv-stubs.c @@ -25,12 +25,11 @@ #include -static OCS_BLK_DEV LOCAL_RAMDEV = { 0 }; +static OCS_BLK_DEV LOCAL_RAMDEV = {0}; -OCS_BLK_DEV *OCS_ramDevCreate (char *ramAddr, int bytesPerSec, int secPerTrack, - int nSectors, int secOffset) +OCS_BLK_DEV *OCS_ramDevCreate(char *ramAddr, int bytesPerSec, int secPerTrack, int nSectors, int secOffset) { - int32 Status; + int32 Status; OCS_BLK_DEV *retval = NULL; Status = UT_DEFAULT_IMPL(OCS_ramDevCreate); @@ -41,6 +40,3 @@ OCS_BLK_DEV *OCS_ramDevCreate (char *ramAddr, int bytesPerSec, int secPerTrack, return retval; } - - - diff --git a/src/unit-test-coverage/ut-stubs/src/vxworks-semLib-stubs.c b/src/unit-test-coverage/ut-stubs/src/vxworks-semLib-stubs.c index b06761844..16735ddde 100644 --- a/src/unit-test-coverage/ut-stubs/src/vxworks-semLib-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/vxworks-semLib-stubs.c @@ -25,12 +25,12 @@ #include -static OCS_SEM LOCAL_UT_SEM = { 0 }; +static OCS_SEM LOCAL_UT_SEM = {0}; OCS_SEM_ID OCS_semBInitialize(OCS_SEM *pSemMem, int options, OCS_SEM_B_STATE initialState) { OCS_SEM_ID retval = NULL; - int32 Status; + int32 Status; Status = UT_DEFAULT_IMPL(OCS_semBInitialize); if (Status == 0) @@ -43,7 +43,7 @@ OCS_SEM_ID OCS_semBInitialize(OCS_SEM *pSemMem, int options, OCS_SEM_B_STATE ini OCS_SEM_ID OCS_semBCreate(int options, OCS_SEM_B_STATE initialState) { OCS_SEM_ID retval = NULL; - int32 Status; + int32 Status; Status = UT_DEFAULT_IMPL(OCS_semBCreate); if (Status == 0) @@ -56,7 +56,7 @@ OCS_SEM_ID OCS_semBCreate(int options, OCS_SEM_B_STATE initialState) OCS_SEM_ID OCS_semMInitialize(OCS_SEM *pSemMem, int options) { OCS_SEM_ID retval = NULL; - int32 Status; + int32 Status; Status = UT_DEFAULT_IMPL(OCS_semMInitialize); if (Status == 0) @@ -69,7 +69,7 @@ OCS_SEM_ID OCS_semMInitialize(OCS_SEM *pSemMem, int options) OCS_SEM_ID OCS_semMCreate(int options) { OCS_SEM_ID retval = NULL; - int32 Status; + int32 Status; Status = UT_DEFAULT_IMPL(OCS_semMCreate); if (Status == 0) @@ -82,7 +82,7 @@ OCS_SEM_ID OCS_semMCreate(int options) OCS_SEM_ID OCS_semCInitialize(OCS_SEM *pSemMem, int options, int initialCount) { OCS_SEM_ID retval = NULL; - int32 Status; + int32 Status; Status = UT_DEFAULT_IMPL(OCS_semCInitialize); if (Status == 0) @@ -95,7 +95,7 @@ OCS_SEM_ID OCS_semCInitialize(OCS_SEM *pSemMem, int options, int initialCount) OCS_SEM_ID OCS_semCCreate(int flags, int count) { OCS_SEM_ID retval = NULL; - int32 Status; + int32 Status; Status = UT_DEFAULT_IMPL(OCS_semCCreate); if (Status == 0) @@ -122,5 +122,3 @@ OCS_STATUS OCS_semGive(OCS_SEM_ID semId) { return (UT_DEFAULT_IMPL(OCS_semGive)); } - - diff --git a/src/unit-test-coverage/ut-stubs/src/vxworks-shellLib-stubs.c b/src/unit-test-coverage/ut-stubs/src/vxworks-shellLib-stubs.c index 344ebffe7..1c40db0fe 100644 --- a/src/unit-test-coverage/ut-stubs/src/vxworks-shellLib-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/vxworks-shellLib-stubs.c @@ -25,17 +25,8 @@ #include -OCS_STATUS OCS_shellGenericInit( - const char * config, - int stackSize, - const char * shellName, - char **pShellName, - OCS_BOOL interactive, - OCS_BOOL loginAccess, - int fdin, - int fdout, - int fderr) +OCS_STATUS OCS_shellGenericInit(const char *config, int stackSize, const char *shellName, char **pShellName, + OCS_BOOL interactive, OCS_BOOL loginAccess, int fdin, int fdout, int fderr) { return (UT_DEFAULT_IMPL(OCS_shellGenericInit)); } - diff --git a/src/unit-test-coverage/ut-stubs/src/vxworks-symLib-stubs.c b/src/unit-test-coverage/ut-stubs/src/vxworks-symLib-stubs.c index 9ae7d7662..e7383bc43 100644 --- a/src/unit-test-coverage/ut-stubs/src/vxworks-symLib-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/vxworks-symLib-stubs.c @@ -42,19 +42,19 @@ struct OCS_SYMTAB int symtab; }; -static OCS_SYMBOL LOCAL_SYMBOL = { 1 }; -static OCS_SYMTAB LOCAL_SYMTAB = { 2 }; +static OCS_SYMBOL LOCAL_SYMBOL = {1}; +static OCS_SYMTAB LOCAL_SYMTAB = {2}; OCS_SYMTAB_ID OCS_sysSymTbl = &LOCAL_SYMTAB; -OCS_STATUS OCS_symFindByName(OCS_SYMTAB_ID symTblId, char * name, char ** pValue, OCS_SYM_TYPE * pType) +OCS_STATUS OCS_symFindByName(OCS_SYMTAB_ID symTblId, char *name, char **pValue, OCS_SYM_TYPE *pType) { return (UT_DEFAULT_IMPL(OCS_symFindByName)); } -OCS_SYMBOL * OCS_symEach(OCS_SYMTAB_ID symTblId, OCS_symEach_Routine_t routine, int routineArg) +OCS_SYMBOL *OCS_symEach(OCS_SYMTAB_ID symTblId, OCS_symEach_Routine_t routine, int routineArg) { - int32 Status; + int32 Status; OCS_SYMBOL *retval; Status = UT_DEFAULT_IMPL(OCS_symEach); @@ -70,16 +70,15 @@ OCS_SYMBOL * OCS_symEach(OCS_SYMTAB_ID symTblId, OCS_symEach_Routine_t routine, return retval; } -OCS_STATUS OCS_symFind (OCS_SYMTAB_ID symTblId, OCS_SYMBOL_DESC * pSymbol) +OCS_STATUS OCS_symFind(OCS_SYMTAB_ID symTblId, OCS_SYMBOL_DESC *pSymbol) { int32 Status; Status = UT_DEFAULT_IMPL(OCS_symFind); if (Status == 0 && UT_Stub_CopyToLocal(UT_KEY(OCS_symFind), pSymbol, sizeof(*pSymbol)) < sizeof(*pSymbol)) { - memset(pSymbol,0, sizeof(*pSymbol)); + memset(pSymbol, 0, sizeof(*pSymbol)); } return Status; } - diff --git a/src/unit-test-coverage/ut-stubs/src/vxworks-sysLib-stubs.c b/src/unit-test-coverage/ut-stubs/src/vxworks-sysLib-stubs.c index af56cafe8..f822ac79d 100644 --- a/src/unit-test-coverage/ut-stubs/src/vxworks-sysLib-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/vxworks-sysLib-stubs.c @@ -27,8 +27,5 @@ int OCS_sysClkRateGet(void) { - return (UT_DEFAULT_IMPL_RC(OCS_sysClkRateGet,10000)); + return (UT_DEFAULT_IMPL_RC(OCS_sysClkRateGet, 10000)); } - - - diff --git a/src/unit-test-coverage/ut-stubs/src/vxworks-taskLib-stubs.c b/src/unit-test-coverage/ut-stubs/src/vxworks-taskLib-stubs.c index 156a3a379..8c3886614 100644 --- a/src/unit-test-coverage/ut-stubs/src/vxworks-taskLib-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/vxworks-taskLib-stubs.c @@ -26,7 +26,7 @@ #include #include -static OCS_WIND_TCB OCS_LOCAL_TASK = { 0 }; +static OCS_WIND_TCB OCS_LOCAL_TASK = {0}; void OCS_taskExit(int code) { @@ -81,43 +81,15 @@ OCS_STATUS OCS_taskPrioritySet(OCS_TASK_ID tid, int newPriority) return (UT_DEFAULT_IMPL(OCS_taskPrioritySet)); } -OCS_STATUS OCS_taskInit(OCS_WIND_TCB *pTcb, - char *name, - int priority, - int options, - char * pStackBase, - int stackSize, - OCS_FUNCPTR entryPt, - int arg1, - int arg2, - int arg3, - int arg4, - int arg5, - int arg6, - int arg7, - int arg8, - int arg9, - int arg10 -) +OCS_STATUS OCS_taskInit(OCS_WIND_TCB *pTcb, char *name, int priority, int options, char *pStackBase, int stackSize, + OCS_FUNCPTR entryPt, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, + int arg8, int arg9, int arg10) { return (UT_DEFAULT_IMPL(OCS_taskInit)); } -OCS_TASK_ID OCS_taskSpawn(char * name, - int priority, - int options, - int stackSize, - OCS_FUNCPTR entryPt, - int arg1, - int arg2, - int arg3, - int arg4, - int arg5, - int arg6, - int arg7, - int arg8, - int arg9, - int arg10) +OCS_TASK_ID OCS_taskSpawn(char *name, int priority, int options, int stackSize, OCS_FUNCPTR entryPt, int arg1, int arg2, + int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10) { int32 Status; @@ -142,7 +114,7 @@ OCS_STATUS OCS_taskActivate(OCS_TASK_ID tid) OCS_WIND_TCB *OCS_taskTcb(OCS_TASK_ID tid) { - int32 Status; + int32 Status; OCS_WIND_TCB *LocalTcb; Status = UT_DEFAULT_IMPL(OCS_taskTcb); @@ -164,4 +136,3 @@ OCS_WIND_TCB *OCS_taskTcb(OCS_TASK_ID tid) return LocalTcb; } - diff --git a/src/unit-test-coverage/ut-stubs/src/vxworks-taskVarLib-stubs.c b/src/unit-test-coverage/ut-stubs/src/vxworks-taskVarLib-stubs.c index eed4c8302..b704b7ec5 100644 --- a/src/unit-test-coverage/ut-stubs/src/vxworks-taskVarLib-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/vxworks-taskVarLib-stubs.c @@ -25,11 +25,7 @@ #include - OCS_STATUS OCS_taskVarAdd(int tid, int *pVar) { return (UT_DEFAULT_IMPL(OCS_taskVarAdd)); } - - - diff --git a/src/unit-test-coverage/ut-stubs/src/vxworks-xbdBlkDev-stubs.c b/src/unit-test-coverage/ut-stubs/src/vxworks-xbdBlkDev-stubs.c index de2bca607..72766b02d 100644 --- a/src/unit-test-coverage/ut-stubs/src/vxworks-xbdBlkDev-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/vxworks-xbdBlkDev-stubs.c @@ -25,14 +25,14 @@ #include -OCS_device_t OCS_xbdBlkDevCreateSync (OCS_BLK_DEV *bd, const char *name) +OCS_device_t OCS_xbdBlkDevCreateSync(OCS_BLK_DEV *bd, const char *name) { - int32 status = UT_DEFAULT_IMPL(OCS_xbdBlkDevCreateSync); + int32 status = UT_DEFAULT_IMPL(OCS_xbdBlkDevCreateSync); OCS_device_t res; if (status != 0) { - res = OCS_NULLDEV; /* NULLDEV (0) means error */ + res = OCS_NULLDEV; /* NULLDEV (0) means error */ } else { @@ -42,8 +42,7 @@ OCS_device_t OCS_xbdBlkDevCreateSync (OCS_BLK_DEV *bd, const char *name) return res; } -OCS_STATUS OCS_xbdBlkDevDelete (OCS_device_t dev, OCS_BLK_DEV **ppbd) +OCS_STATUS OCS_xbdBlkDevDelete(OCS_device_t dev, OCS_BLK_DEV **ppbd) { return (UT_DEFAULT_IMPL(OCS_xbdBlkDevDelete)); } - diff --git a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-binsem.h b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-binsem.h index f4ef473e5..01033e846 100644 --- a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-binsem.h +++ b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-binsem.h @@ -33,8 +33,7 @@ #include #include - -extern void* const UT_Ref_OS_impl_bin_sem_table; +extern void *const UT_Ref_OS_impl_bin_sem_table; extern size_t const UT_Ref_OS_impl_bin_sem_table_SIZE; /* @@ -49,5 +48,4 @@ extern const UT_EntryKey_t UT_StubKey_GenericSemGive; extern int32 UT_Call_OS_VxWorks_BinSemAPI_Impl_Init(void); -#endif /* INCLUDE_UT_ADAPTOR_BINSEM_H_ */ - +#endif /* INCLUDE_UT_ADAPTOR_BINSEM_H_ */ diff --git a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-common.h b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-common.h index f78a8712d..30d9dfd18 100644 --- a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-common.h +++ b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-common.h @@ -55,5 +55,4 @@ extern int32 OS_VxWorks_GenericSemGive(OCS_SEM_ID vxid); */ extern const UT_EntryKey_t UT_StubKey_OS_VxWorks_TableMutex_Init; -#endif /* INCLUDE_UT_ADAPTOR_COMMON_H_ */ - +#endif /* INCLUDE_UT_ADAPTOR_COMMON_H_ */ diff --git a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-console.h b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-console.h index cabd51281..72dec2e7a 100644 --- a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-console.h +++ b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-console.h @@ -31,10 +31,9 @@ #include #include "ut-adaptor-common.h" -extern void* const UT_Ref_OS_impl_console_table; +extern void *const UT_Ref_OS_impl_console_table; extern size_t const UT_Ref_OS_impl_console_table_SIZE; - /** * Invokes the console helper task entry point */ @@ -45,6 +44,4 @@ extern void UT_ConsoleTest_TaskEntry(int arg); */ extern void UT_ConsoleTest_SetConsoleAsync(uint32 local_id, bool is_async); - -#endif /* INCLUDE_UT_ADAPTOR_CONSOLE_H_ */ - +#endif /* INCLUDE_UT_ADAPTOR_CONSOLE_H_ */ diff --git a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-countsem.h b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-countsem.h index 96a0baae4..eed755c48 100644 --- a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-countsem.h +++ b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-countsem.h @@ -32,10 +32,9 @@ #include #include -extern void* const UT_Ref_OS_impl_count_sem_table; +extern void *const UT_Ref_OS_impl_count_sem_table; extern size_t const UT_Ref_OS_impl_count_sem_table_SIZE; - /***************************************************** * * UT FUNCTION PROTOTYPES @@ -47,5 +46,4 @@ extern size_t const UT_Ref_OS_impl_count_sem_table_SIZE; int32 UT_Call_OS_VxWorks_CountSemAPI_Impl_Init(void); -#endif /* INCLUDE_UT_ADAPTOR_COUNTSEM_H_ */ - +#endif /* INCLUDE_UT_ADAPTOR_COUNTSEM_H_ */ diff --git a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-dirs.h b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-dirs.h index b2f0b5740..b93409c41 100644 --- a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-dirs.h +++ b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-dirs.h @@ -39,11 +39,9 @@ * *****************************************************/ - /* * Prototype for table init function (needs to be called from UT) */ extern int32 UT_Call_OS_VxWorks_DirAPI_Impl_Init(void); -#endif /* INCLUDE_UT_ADAPTOR_DIRS_H_ */ - +#endif /* INCLUDE_UT_ADAPTOR_DIRS_H_ */ diff --git a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-files.h b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-files.h index ffd63457f..23ddfad9d 100644 --- a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-files.h +++ b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-files.h @@ -39,7 +39,6 @@ * *****************************************************/ - /* * Prototype for table init function (needs to be called from UT) */ @@ -56,5 +55,4 @@ unsigned int UT_FileTest_GetSelfEGID(void); void UT_FileTest_Set_Selectable(uint32 local_id, bool is_selectable); -#endif /* INCLUDE_UT_ADAPTOR_FILES_H_ */ - +#endif /* INCLUDE_UT_ADAPTOR_FILES_H_ */ diff --git a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-filesys.h b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-filesys.h index 3c628e6b1..8049ee0d9 100644 --- a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-filesys.h +++ b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-filesys.h @@ -31,12 +31,9 @@ #include #include -extern void* const UT_Ref_OS_impl_filesys_table; +extern void *const UT_Ref_OS_impl_filesys_table; extern size_t const UT_Ref_OS_impl_filesys_table_SIZE; - void UT_FileSysTest_SetupFileSysEntry(uint32 id, OCS_BLK_DEV *blkdev, OCS_device_t xbddev, uint32 MaxParts); - -#endif /* INCLUDE_UT_ADAPTOR_FILESYS_H_ */ - +#endif /* INCLUDE_UT_ADAPTOR_FILESYS_H_ */ diff --git a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-filetable-stub.h b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-filetable-stub.h index 3402b73f3..873c17237 100644 --- a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-filetable-stub.h +++ b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-filetable-stub.h @@ -31,10 +31,7 @@ #include #include - -extern void* const UT_FileTableTest_OS_impl_filehandle_table; +extern void *const UT_FileTableTest_OS_impl_filehandle_table; extern size_t const UT_FileTableTest_OS_impl_filehandle_table_SIZE; - -#endif /* INCLUDE_UT_ADAPTOR_FILETABLE_STUB_H_ */ - +#endif /* INCLUDE_UT_ADAPTOR_FILETABLE_STUB_H_ */ diff --git a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-idmap.h b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-idmap.h index d46973b96..cd8b50127 100644 --- a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-idmap.h +++ b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-idmap.h @@ -40,8 +40,6 @@ * *****************************************************/ int32 UT_Call_OS_VxWorks_TableMutex_Init(uint32 idtype); -void UT_IdMapTest_SetImplTableMutex(uint32 idtype, OCS_SEM_ID vxid); - - -#endif /* INCLUDE_UT_ADAPTOR_IDMAP_H_ */ +void UT_IdMapTest_SetImplTableMutex(uint32 idtype, OCS_SEM_ID vxid); +#endif /* INCLUDE_UT_ADAPTOR_IDMAP_H_ */ diff --git a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-loader.h b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-loader.h index 05a46ae1e..e3447fe52 100644 --- a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-loader.h +++ b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-loader.h @@ -33,11 +33,9 @@ #include #include - -extern void* const UT_Ref_OS_impl_module_table; +extern void *const UT_Ref_OS_impl_module_table; extern size_t const UT_Ref_OS_impl_module_table_SIZE; extern int32 UT_Call_OS_VxWorks_ModuleAPI_Impl_Init(void); -#endif /* INCLUDE_UT_ADAPTOR_LOADER_H_ */ - +#endif /* INCLUDE_UT_ADAPTOR_LOADER_H_ */ diff --git a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-mutex.h b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-mutex.h index 78671808e..f30c94c27 100644 --- a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-mutex.h +++ b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-mutex.h @@ -28,16 +28,13 @@ #ifndef INCLUDE_UT_ADAPTOR_MUTEX_H_ #define INCLUDE_UT_ADAPTOR_MUTEX_H_ - #include #include #include -extern void* const UT_Ref_OS_impl_mutex_table; +extern void *const UT_Ref_OS_impl_mutex_table; extern size_t const UT_Ref_OS_impl_mutex_table_SIZE; - - /***************************************************** * * UT FUNCTION PROTOTYPES @@ -49,5 +46,4 @@ extern size_t const UT_Ref_OS_impl_mutex_table_SIZE; int32 UT_Call_OS_VxWorks_MutexAPI_Impl_Init(void); -#endif /* INCLUDE_UT_ADAPTOR_MUTEX_H_ */ - +#endif /* INCLUDE_UT_ADAPTOR_MUTEX_H_ */ diff --git a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-queues.h b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-queues.h index 17a244107..e630e85ba 100644 --- a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-queues.h +++ b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-queues.h @@ -31,10 +31,9 @@ #include #include -extern void* const UT_Ref_OS_impl_queue_table; +extern void *const UT_Ref_OS_impl_queue_table; extern size_t const UT_Ref_OS_impl_queue_table_SIZE; - /***************************************************** * * UT FUNCTION PROTOTYPES @@ -46,6 +45,4 @@ extern size_t const UT_Ref_OS_impl_queue_table_SIZE; int32 UT_Call_OS_VxWorks_QueueAPI_Impl_Init(void); - -#endif /* INCLUDE_UT_ADAPTOR_QUEUES_H_ */ - +#endif /* INCLUDE_UT_ADAPTOR_QUEUES_H_ */ diff --git a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-symtab.h b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-symtab.h index 301ace339..b29ec05c4 100644 --- a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-symtab.h +++ b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-symtab.h @@ -30,7 +30,6 @@ #include -int32 UT_SymTabTest_CallIteratorFunc(const char *name, void* val, uint32 TestSize, uint32 SizeLimit); - -#endif /* INCLUDE_UT_ADAPTOR_SYMTAB_H_ */ +int32 UT_SymTabTest_CallIteratorFunc(const char *name, void *val, uint32 TestSize, uint32 SizeLimit); +#endif /* INCLUDE_UT_ADAPTOR_SYMTAB_H_ */ diff --git a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-tasks.h b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-tasks.h index 875d64352..d2b3a44bc 100644 --- a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-tasks.h +++ b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-tasks.h @@ -31,10 +31,9 @@ #include #include -extern void* const UT_Ref_OS_impl_task_table; +extern void *const UT_Ref_OS_impl_task_table; extern size_t const UT_Ref_OS_impl_task_table_SIZE; - /***************************************************** * * UT FUNCTION PROTOTYPES @@ -44,11 +43,9 @@ extern size_t const UT_Ref_OS_impl_task_table_SIZE; * *****************************************************/ -int32 UT_Call_OS_VxWorks_TaskAPI_Impl_Init(void); -void UT_TaskTest_SetImplTaskId(uint32 local_id, OCS_TASK_ID TaskId); -int UT_TaskTest_CallEntryPoint(int arg); -OCS_WIND_TCB* UT_TaskTest_GetTaskTcb(uint32 local_id); - - -#endif /* INCLUDE_UT_ADAPTOR_TASKS_H_ */ +int32 UT_Call_OS_VxWorks_TaskAPI_Impl_Init(void); +void UT_TaskTest_SetImplTaskId(uint32 local_id, OCS_TASK_ID TaskId); +int UT_TaskTest_CallEntryPoint(int arg); +OCS_WIND_TCB *UT_TaskTest_GetTaskTcb(uint32 local_id); +#endif /* INCLUDE_UT_ADAPTOR_TASKS_H_ */ diff --git a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-timebase.h b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-timebase.h index 47f1d6ba7..19cac7f67 100644 --- a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-timebase.h +++ b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-timebase.h @@ -32,10 +32,9 @@ #include #include -extern void* const UT_Ref_OS_impl_timebase_table; +extern void *const UT_Ref_OS_impl_timebase_table; extern size_t const UT_Ref_OS_impl_timebase_table_SIZE; - int32 UT_Call_OS_VxWorks_TimeBaseAPI_Impl_Init(void); void UT_TimeBaseTest_Setup(uint32 local_id, int signo, bool reset_flag); @@ -63,5 +62,4 @@ bool UT_TimeBaseTest_CheckTimeBaseErrorState(uint32 local_id); /* Invoke the internal UsecToTimespec API */ void UT_TimeBaseTest_UsecToTimespec(uint32 usecs, struct OCS_timespec *time_spec); -#endif /* INCLUDE_UT_ADAPTOR_TIMEBASE_H_ */ - +#endif /* INCLUDE_UT_ADAPTOR_TIMEBASE_H_ */ diff --git a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-binsem.c b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-binsem.c index ac3da4256..1511fcd91 100644 --- a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-binsem.c +++ b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-binsem.c @@ -32,8 +32,7 @@ #include #include - -void* const UT_Ref_OS_impl_bin_sem_table = OS_impl_bin_sem_table; +void *const UT_Ref_OS_impl_bin_sem_table = OS_impl_bin_sem_table; size_t const UT_Ref_OS_impl_bin_sem_table_SIZE = sizeof(OS_impl_bin_sem_table); const UT_EntryKey_t UT_StubKey_GenericSemTake = UT_KEY(OS_VxWorks_GenericSemTake); @@ -43,5 +42,3 @@ int32 UT_Call_OS_VxWorks_BinSemAPI_Impl_Init(void) { return OS_VxWorks_BinSemAPI_Impl_Init(); } - - diff --git a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-common.c b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-common.c index 945c72526..9c68e5cdb 100644 --- a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-common.c +++ b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-common.c @@ -34,4 +34,3 @@ #include "ut-adaptor-common.h" const UT_EntryKey_t UT_StubKey_OS_VxWorks_TableMutex_Init = UT_KEY(OS_VxWorks_TableMutex_Init); - diff --git a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-console.c b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-console.c index 9630fd6e8..b0f280feb 100644 --- a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-console.c +++ b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-console.c @@ -32,7 +32,7 @@ #include #include -void* const UT_Ref_OS_impl_console_table = OS_impl_console_table; +void *const UT_Ref_OS_impl_console_table = OS_impl_console_table; size_t const UT_Ref_OS_impl_console_table_SIZE = sizeof(OS_impl_console_table); void UT_ConsoleTest_TaskEntry(int arg) diff --git a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-countsem.c b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-countsem.c index 051f2fcc3..6f33930fd 100644 --- a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-countsem.c +++ b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-countsem.c @@ -31,13 +31,10 @@ #include #include -void* const UT_Ref_OS_impl_count_sem_table = OS_impl_count_sem_table; +void *const UT_Ref_OS_impl_count_sem_table = OS_impl_count_sem_table; size_t const UT_Ref_OS_impl_count_sem_table_SIZE = sizeof(OS_impl_count_sem_table); - int32 UT_Call_OS_VxWorks_CountSemAPI_Impl_Init(void) { return OS_VxWorks_CountSemAPI_Impl_Init(); } - - diff --git a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-dirs.c b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-dirs.c index 7d14db5be..0422e6270 100644 --- a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-dirs.c +++ b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-dirs.c @@ -32,9 +32,7 @@ #include #include - int32 UT_Call_OS_VxWorks_DirAPI_Impl_Init(void) { return OS_VxWorks_DirAPI_Impl_Init(); } - diff --git a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-files.c b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-files.c index f14f05a0d..2cdd8d7c2 100644 --- a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-files.c +++ b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-files.c @@ -32,8 +32,6 @@ #include #include - - int32 UT_Call_OS_VxWorks_StreamAPI_Impl_Init(void) { return OS_VxWorks_StreamAPI_Impl_Init(); diff --git a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-filesys.c b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-filesys.c index 7e9b2a97d..9094de350 100644 --- a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-filesys.c +++ b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-filesys.c @@ -31,15 +31,12 @@ #include #include - - -void* const UT_Ref_OS_impl_filesys_table = OS_impl_filesys_table; +void *const UT_Ref_OS_impl_filesys_table = OS_impl_filesys_table; size_t const UT_Ref_OS_impl_filesys_table_SIZE = sizeof(OS_impl_filesys_table); void UT_FileSysTest_SetupFileSysEntry(uint32 id, OCS_BLK_DEV *blkdev, OCS_device_t xbddev, uint32 MaxParts) { - OS_impl_filesys_table[id].blkDev = blkdev; - OS_impl_filesys_table[id].xbd = xbddev; + OS_impl_filesys_table[id].blkDev = blkdev; + OS_impl_filesys_table[id].xbd = xbddev; OS_impl_filesys_table[id].xbdMaxPartitions = MaxParts; } - diff --git a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-filetable-stub.c b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-filetable-stub.c index 0069a9241..9af7e1383 100644 --- a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-filetable-stub.c +++ b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-filetable-stub.c @@ -31,11 +31,7 @@ #include #include - - - OS_VxWorks_filehandle_entry_t OS_impl_filehandle_table[OS_MAX_NUM_OPEN_FILES]; - -void* const UT_FileTableTest_OS_impl_filehandle_table = OS_impl_filehandle_table; +void *const UT_FileTableTest_OS_impl_filehandle_table = OS_impl_filehandle_table; size_t const UT_FileTableTest_OS_impl_filehandle_table_SIZE = sizeof(OS_impl_filehandle_table); diff --git a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-idmap.c b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-idmap.c index e61a283fc..f4053559b 100644 --- a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-idmap.c +++ b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-idmap.c @@ -41,4 +41,3 @@ void UT_IdMapTest_SetImplTableMutex(uint32 idtype, OCS_SEM_ID vxid) { VX_MUTEX_TABLE[idtype].vxid = vxid; } - diff --git a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-loader.c b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-loader.c index 9d303b8ac..753563507 100644 --- a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-loader.c +++ b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-loader.c @@ -32,13 +32,10 @@ #include #include - -void* const UT_Ref_OS_impl_module_table = OS_impl_module_table; +void *const UT_Ref_OS_impl_module_table = OS_impl_module_table; size_t const UT_Ref_OS_impl_module_table_SIZE = sizeof(OS_impl_module_table); int32 UT_Call_OS_VxWorks_ModuleAPI_Impl_Init(void) { return OS_VxWorks_ModuleAPI_Impl_Init(); } - - diff --git a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-mutex.c b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-mutex.c index 653fceff4..9c7b0c3af 100644 --- a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-mutex.c +++ b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-mutex.c @@ -32,13 +32,10 @@ #include #include -void* const UT_Ref_OS_impl_mutex_table = OS_impl_mutex_table; +void *const UT_Ref_OS_impl_mutex_table = OS_impl_mutex_table; size_t const UT_Ref_OS_impl_mutex_table_SIZE = sizeof(OS_impl_mutex_table); - int32 UT_Call_OS_VxWorks_MutexAPI_Impl_Init(void) { return OS_VxWorks_MutexAPI_Impl_Init(); } - - diff --git a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-queues.c b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-queues.c index cc0fe4a1d..c7cca7e2d 100644 --- a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-queues.c +++ b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-queues.c @@ -32,13 +32,10 @@ #include #include -void* const UT_Ref_OS_impl_queue_table = OS_impl_queue_table; +void *const UT_Ref_OS_impl_queue_table = OS_impl_queue_table; size_t const UT_Ref_OS_impl_queue_table_SIZE = sizeof(OS_impl_queue_table); - int32 UT_Call_OS_VxWorks_QueueAPI_Impl_Init(void) { return OS_VxWorks_QueueAPI_Impl_Init(); } - - diff --git a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-symtab.c b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-symtab.c index aafe036f4..61e5a37a7 100644 --- a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-symtab.c +++ b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-symtab.c @@ -36,15 +36,14 @@ * A UT-specific wrapper function to invoke the Symbol Table Iterator. * This is normally static so it needs this wrapper to call it. */ -int32 UT_SymTabTest_CallIteratorFunc(const char *name, void* val, uint32 TestSize, uint32 SizeLimit) +int32 UT_SymTabTest_CallIteratorFunc(const char *name, void *val, uint32 TestSize, uint32 SizeLimit) { OS_VxWorks_SymbolDumpState.Sizelimit = SizeLimit; - OS_VxWorks_SymbolDumpState.CurrSize = TestSize; + OS_VxWorks_SymbolDumpState.CurrSize = TestSize; /* * note the internal function is takes a name declared as "char*" to be * consistent with the VxWorks API, however the implementation does not * modify this argument. */ - return OS_SymTableIterator_Impl((char*)name,(OCS_SYM_VALUE)val,0,0,0); + return OS_SymTableIterator_Impl((char *)name, (OCS_SYM_VALUE)val, 0, 0, 0); } - diff --git a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-tasks.c b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-tasks.c index fcf6200c7..10f06f39e 100644 --- a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-tasks.c +++ b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-tasks.c @@ -32,10 +32,9 @@ #include #include -void* const UT_Ref_OS_impl_task_table = OS_impl_task_table; +void *const UT_Ref_OS_impl_task_table = OS_impl_task_table; size_t const UT_Ref_OS_impl_task_table_SIZE = sizeof(OS_impl_task_table); - int32 UT_Call_OS_VxWorks_TaskAPI_Impl_Init(void) { return OS_VxWorks_TaskAPI_Impl_Init(); @@ -56,8 +55,7 @@ int UT_TaskTest_CallEntryPoint(int arg) return OS_VxWorks_TaskEntry(arg); } -OCS_WIND_TCB* UT_TaskTest_GetTaskTcb(uint32 local_id) +OCS_WIND_TCB *UT_TaskTest_GetTaskTcb(uint32 local_id) { return &OS_impl_task_table[local_id].tcb; } - diff --git a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-timebase.c b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-timebase.c index 0aeabf9f4..0806059b8 100644 --- a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-timebase.c +++ b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-timebase.c @@ -32,8 +32,7 @@ #include #include - -void* const UT_Ref_OS_impl_timebase_table = OS_impl_timebase_table; +void *const UT_Ref_OS_impl_timebase_table = OS_impl_timebase_table; size_t const UT_Ref_OS_impl_timebase_table_SIZE = sizeof(OS_impl_timebase_table); int32 UT_Call_OS_VxWorks_TimeBaseAPI_Impl_Init(void) @@ -41,7 +40,6 @@ int32 UT_Call_OS_VxWorks_TimeBaseAPI_Impl_Init(void) return OS_VxWorks_TimeBaseAPI_Impl_Init(); } - int32 UT_TimeBaseTest_CallSigWaitFunc(uint32 local_id) { return OS_VxWorks_SigWait(local_id); @@ -95,11 +93,10 @@ void UT_TimeBaseTest_UsecToTimespec(uint32 usecs, struct OCS_timespec *time_spec void UT_TimeBaseTest_Setup(uint32 local_id, int signo, bool reset_flag) { static OCS_WIND_TCB FAKE_TASK; - static OCS_SEM FAKE_SEM; + static OCS_SEM FAKE_SEM; OS_impl_timebase_table[local_id].assigned_signal = signo; - OS_impl_timebase_table[local_id].handler_task = &FAKE_TASK; - OS_impl_timebase_table[local_id].handler_mutex = &FAKE_SEM; - OS_impl_timebase_table[local_id].reset_flag = reset_flag; + OS_impl_timebase_table[local_id].handler_task = &FAKE_TASK; + OS_impl_timebase_table[local_id].handler_mutex = &FAKE_SEM; + OS_impl_timebase_table[local_id].reset_flag = reset_flag; } - diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-binsem.c b/src/unit-test-coverage/vxworks/src/coveragetest-binsem.c index 2b6c06c07..931f7f37d 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-binsem.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-binsem.c @@ -25,7 +25,6 @@ * */ - #include "os-vxworks-coveragetest.h" #include "ut-adaptor-binsem.h" @@ -51,10 +50,10 @@ void Test_OS_BinSemCreate_Impl(void) * Test Case For: * int32 OS_BinSemCreate_Impl (uint32 sem_id, uint32 initial_value, uint32 options) */ - OSAPI_TEST_FUNCTION_RC(OS_BinSemCreate_Impl(0,0,0), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_BinSemCreate_Impl(0, 0, 0), OS_SUCCESS); UT_SetForceFail(UT_KEY(OCS_semBInitialize), OCS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_BinSemCreate_Impl(0,0,0), OS_SEM_FAILURE); + OSAPI_TEST_FUNCTION_RC(OS_BinSemCreate_Impl(0, 0, 0), OS_SEM_FAILURE); } void Test_OS_BinSemDelete_Impl(void) @@ -105,13 +104,13 @@ void Test_OS_BinSemTimedWait_Impl(void) * Test Case For: * int32 OS_BinSemTimedWait_Impl ( uint32 sem_id, uint32 msecs ) */ - OSAPI_TEST_FUNCTION_RC(OS_BinSemTimedWait_Impl(0,100), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_BinSemTimedWait_Impl(0, 100), OS_SUCCESS); UT_SetForceFail(UT_StubKey_GenericSemTake, OS_SEM_FAILURE); - OSAPI_TEST_FUNCTION_RC(OS_BinSemTimedWait_Impl(0,100), OS_SEM_FAILURE); + OSAPI_TEST_FUNCTION_RC(OS_BinSemTimedWait_Impl(0, 100), OS_SEM_FAILURE); UT_SetForceFail(UT_KEY(OS_Milli2Ticks), OS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_BinSemTimedWait_Impl(0,100), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_BinSemTimedWait_Impl(0, 100), OS_ERROR); } void Test_OS_BinSemGetInfo_Impl(void) @@ -122,7 +121,7 @@ void Test_OS_BinSemGetInfo_Impl(void) */ OS_bin_sem_prop_t sem_prop; memset(&sem_prop, 0xEE, sizeof(sem_prop)); - OSAPI_TEST_FUNCTION_RC(OS_BinSemGetInfo_Impl(0,&sem_prop), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_BinSemGetInfo_Impl(0, &sem_prop), OS_SUCCESS); } /* ------------------- End of test cases --------------------------------------*/ @@ -148,10 +147,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* UtTest_Setup * @@ -169,5 +165,3 @@ void UtTest_Setup(void) ADD_TEST(OS_BinSemTimedWait_Impl); ADD_TEST(OS_BinSemGetInfo_Impl); } - - diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-common.c b/src/unit-test-coverage/vxworks/src/coveragetest-common.c index c0362c93b..874ac2ae7 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-common.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-common.c @@ -35,7 +35,6 @@ OCS_SEM TestGlobalSem; - void Test_OS_API_Impl_Init(void) { /* @@ -90,7 +89,6 @@ void Test_OS_VxWorks_GenericSemGive(void) OSAPI_TEST_FUNCTION_RC(OS_VxWorks_GenericSemGive(SemID), OS_SEM_FAILURE); } /* end OS_VxWorks_GenericSemGive */ - void Test_OS_VxWorks_GenericSemTake(void) { /* @@ -108,7 +106,6 @@ void Test_OS_VxWorks_GenericSemTake(void) } /* end OS_VxWorks_GenericSemTake */ - /* ------------------- End of test cases --------------------------------------*/ /* Osapi_Test_Setup @@ -128,10 +125,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* UtTest_Setup * @@ -146,5 +140,3 @@ void UtTest_Setup(void) ADD_TEST(OS_VxWorks_GenericSemGive); ADD_TEST(OS_VxWorks_GenericSemTake); } - - diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-console.c b/src/unit-test-coverage/vxworks/src/coveragetest-console.c index f8c1f3f77..c39910841 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-console.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-console.c @@ -97,13 +97,9 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} - -#define ADD_TEST(test) UtTest_Add((Test_ ## test), Osapi_Test_Setup, Osapi_Test_Teardown, #test) +#define ADD_TEST(test) UtTest_Add((Test_##test), Osapi_Test_Setup, Osapi_Test_Teardown, #test) /* UtTest_Setup * @@ -115,5 +111,3 @@ void UtTest_Setup(void) ADD_TEST(OS_ConsoleCreate_Impl); ADD_TEST(OS_ConsoleWakeup_Impl); } - - diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-countsem.c b/src/unit-test-coverage/vxworks/src/coveragetest-countsem.c index dbff06dba..f29a015c4 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-countsem.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-countsem.c @@ -46,10 +46,10 @@ void Test_OS_CountSemCreate_Impl(void) * Test Case For: * int32 OS_CountSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 options) */ - OSAPI_TEST_FUNCTION_RC(OS_CountSemCreate_Impl(0,0,0), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_CountSemCreate_Impl(0, 0, 0), OS_SUCCESS); UT_SetForceFail(UT_KEY(OCS_semCInitialize), OCS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_CountSemCreate_Impl(0,0,0), OS_SEM_FAILURE); + OSAPI_TEST_FUNCTION_RC(OS_CountSemCreate_Impl(0, 0, 0), OS_SEM_FAILURE); } void Test_OS_CountSemDelete_Impl(void) @@ -88,7 +88,7 @@ void Test_OS_CountSemTimedWait_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_CountSemTimedWait_Impl(0, 100), OS_SUCCESS); UT_SetForceFail(UT_KEY(OS_Milli2Ticks), OS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_CountSemTimedWait_Impl(0,100), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_CountSemTimedWait_Impl(0, 100), OS_ERROR); } void Test_OS_CountSemGetInfo_Impl(void) @@ -102,7 +102,6 @@ void Test_OS_CountSemGetInfo_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_CountSemGetInfo_Impl(0, &count_prop), OS_SUCCESS); } - /* ------------------- End of test cases --------------------------------------*/ /* Osapi_Test_Setup @@ -126,10 +125,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* UtTest_Setup * @@ -146,5 +142,3 @@ void UtTest_Setup(void) ADD_TEST(OS_CountSemTimedWait_Impl); ADD_TEST(OS_CountSemGetInfo_Impl); } - - diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-dirs.c b/src/unit-test-coverage/vxworks/src/coveragetest-dirs.c index cebd3e8fa..f896cb598 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-dirs.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-dirs.c @@ -89,7 +89,6 @@ void Test_OS_DirRead_Impl(void) UT_SetForceFail(UT_KEY(OCS_readdir), -1); OSAPI_TEST_FUNCTION_RC(OS_DirRead_Impl(0, &dirent_buff), OS_ERROR); - } void Test_OS_DirRewind_Impl(void) @@ -113,7 +112,6 @@ void Test_OS_DirRemove_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_DirRemove_Impl("dir"), OS_ERROR); } - /* ------------------- End of test cases --------------------------------------*/ /* Osapi_Test_Setup @@ -132,10 +130,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* UtTest_Setup * @@ -152,5 +147,3 @@ void UtTest_Setup(void) ADD_TEST(OS_DirRewind_Impl); ADD_TEST(OS_DirRemove_Impl); } - - diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-files.c b/src/unit-test-coverage/vxworks/src/coveragetest-files.c index 3a576b9c3..fafb9cd0f 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-files.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-files.c @@ -44,7 +44,6 @@ void Test_OS_VxWorks_StreamAPI_Impl_Init(void) OSAPI_TEST_FUNCTION_RC(UT_Call_OS_VxWorks_StreamAPI_Impl_Init(), OS_SUCCESS); } - /* ------------------- End of test cases --------------------------------------*/ /* Osapi_Test_Setup @@ -63,10 +62,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* UtTest_Setup * @@ -77,5 +73,3 @@ void UtTest_Setup(void) { ADD_TEST(OS_VxWorks_StreamAPI_Impl_Init); } - - diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-filesys.c b/src/unit-test-coverage/vxworks/src/coveragetest-filesys.c index 60668eb7b..6cdf934ec 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-filesys.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-filesys.c @@ -39,9 +39,6 @@ #include #include - - - void Test_OS_FileSysStartVolume_Impl(void) { /* @@ -117,7 +114,6 @@ void Test_OS_FileSysFormatVolume_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_FileSysFormatVolume_Impl(0), OS_FS_ERR_DRIVE_NOT_CREATED); } - void Test_OS_FileSysMountVolume_Impl(void) { /* Test Case For: @@ -131,7 +127,6 @@ void Test_OS_FileSysMountVolume_Impl(void) UT_ClearForceFail(UT_KEY(OCS_open)); } - void Test_OS_FileSysUnmountVolume_Impl(void) { /* Test Case For: @@ -156,10 +151,10 @@ void Test_OS_FileSysStatVolume_Impl(void) * int32 OS_FileSysStatVolume_Impl (uint32 filesys_id, OS_statvfs_t *result) */ OS_statvfs_t stat; - OSAPI_TEST_FUNCTION_RC(OS_FileSysStatVolume_Impl(0,&stat), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_FileSysStatVolume_Impl(0, &stat), OS_SUCCESS); UT_SetForceFail(UT_KEY(OCS_statvfs), -1); - OSAPI_TEST_FUNCTION_RC(OS_FileSysStatVolume_Impl(0,&stat), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_FileSysStatVolume_Impl(0, &stat), OS_ERROR); } void Test_OS_FileSysCheckVolume_Impl(void) @@ -168,15 +163,14 @@ void Test_OS_FileSysCheckVolume_Impl(void) * Test Case For: * int32 OS_FileSysCheckVolume_Impl (uint32 filesys_id, bool repair) */ - OSAPI_TEST_FUNCTION_RC(OS_FileSysCheckVolume_Impl(0,true), OS_SUCCESS); - + OSAPI_TEST_FUNCTION_RC(OS_FileSysCheckVolume_Impl(0, true), OS_SUCCESS); UT_SetForceFail(UT_KEY(OCS_open), -1); - OSAPI_TEST_FUNCTION_RC(OS_FileSysCheckVolume_Impl(0,false), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_FileSysCheckVolume_Impl(0, false), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_open)); UT_SetForceFail(UT_KEY(OCS_ioctl), -1); - OSAPI_TEST_FUNCTION_RC(OS_FileSysCheckVolume_Impl(0,false), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_FileSysCheckVolume_Impl(0, false), OS_ERROR); } /* ------------------- End of test cases --------------------------------------*/ @@ -202,10 +196,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* UtTest_Setup * @@ -222,4 +213,3 @@ void UtTest_Setup(void) ADD_TEST(OS_FileSysMountVolume_Impl); ADD_TEST(OS_FileSysUnmountVolume_Impl); } - diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-heap.c b/src/unit-test-coverage/vxworks/src/coveragetest-heap.c index 24f028f2e..10d68a79a 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-heap.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-heap.c @@ -29,7 +29,6 @@ #include - void Test_OS_HeapGetInfo_Impl(void) { /* @@ -45,7 +44,6 @@ void Test_OS_HeapGetInfo_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_HeapGetInfo_Impl(&heap_prop), OS_ERROR); } - /* ------------------- End of test cases --------------------------------------*/ /* Osapi_Test_Setup @@ -64,10 +62,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* UtTest_Setup * @@ -78,5 +73,3 @@ void UtTest_Setup(void) { ADD_TEST(OS_HeapGetInfo_Impl); } - - diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-idmap.c b/src/unit-test-coverage/vxworks/src/coveragetest-idmap.c index 7304d6326..124f7d322 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-idmap.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-idmap.c @@ -35,7 +35,6 @@ OCS_SEM TestGlobalSem; - void Test_OS_Lock_Global_Impl(void) { /* @@ -86,7 +85,6 @@ void Test_OS_API_Impl_Init(void) OSAPI_TEST_FUNCTION_RC(UT_Call_OS_VxWorks_TableMutex_Init(OS_OBJECT_TYPE_OS_TASK), OS_SUCCESS); } - /* ------------------- End of test cases --------------------------------------*/ /* Osapi_Test_Setup @@ -105,10 +103,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* UtTest_Setup * @@ -121,5 +116,3 @@ void UtTest_Setup(void) ADD_TEST(OS_Unlock_Global_Impl); ADD_TEST(OS_API_Impl_Init); } - - diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-loader.c b/src/unit-test-coverage/vxworks/src/coveragetest-loader.c index 37670738c..4fede680c 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-loader.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-loader.c @@ -50,12 +50,12 @@ void Test_OS_ModuleLoad_Impl(void) /* Test Case For: * int32 OS_ModuleLoad_Impl ( uint32 module_id, char *translated_path ) */ - OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl(0,"local"), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl(0, "local"), OS_SUCCESS); UT_SetForceFail(UT_KEY(OCS_open), -1); - OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl(0,"local"), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl(0, "local"), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_open)); UT_SetForceFail(UT_KEY(OCS_loadModule), OCS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl(0,"local"), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl(0, "local"), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_loadModule)); } @@ -78,7 +78,7 @@ void Test_OS_ModuleGetInfo_Impl(void) OS_module_prop_t module_prop; memset(&module_prop, 0, sizeof(module_prop)); - OSAPI_TEST_FUNCTION_RC(OS_ModuleGetInfo_Impl(0,&module_prop), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_ModuleGetInfo_Impl(0, &module_prop), OS_SUCCESS); UtAssert_True(module_prop.addr.valid, "addresses in output valid"); /* @@ -87,12 +87,11 @@ void Test_OS_ModuleGetInfo_Impl(void) */ memset(&module_prop, 0, sizeof(module_prop)); UT_SetForceFail(UT_KEY(OCS_moduleInfoGet), OCS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_ModuleGetInfo_Impl(0,&module_prop), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_ModuleGetInfo_Impl(0, &module_prop), OS_SUCCESS); UT_ClearForceFail(UT_KEY(OCS_moduleInfoGet)); UtAssert_True(!module_prop.addr.valid, "addresses in output not valid"); } - /* ------------------- End of test cases --------------------------------------*/ /* Osapi_Test_Setup @@ -116,11 +115,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} - +void Osapi_Test_Teardown(void) {} /* UtTest_Setup * @@ -134,5 +129,3 @@ void UtTest_Setup(void) ADD_TEST(OS_ModuleUnload_Impl); ADD_TEST(OS_ModuleGetInfo_Impl); } - - diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-mutex.c b/src/unit-test-coverage/vxworks/src/coveragetest-mutex.c index f134c2912..bceac85b3 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-mutex.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-mutex.c @@ -43,10 +43,10 @@ void Test_OS_MutSemCreate_Impl(void) * Test Case For: * int32 OS_MutSemCreate_Impl (uint32 sem_id, uint32 options) */ - OSAPI_TEST_FUNCTION_RC(OS_MutSemCreate_Impl(0,0), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_MutSemCreate_Impl(0, 0), OS_SUCCESS); UT_SetForceFail(UT_KEY(OCS_semMInitialize), OCS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_MutSemCreate_Impl(0,0), OS_SEM_FAILURE); + OSAPI_TEST_FUNCTION_RC(OS_MutSemCreate_Impl(0, 0), OS_SEM_FAILURE); } void Test_OS_MutSemDelete_Impl(void) @@ -84,10 +84,9 @@ void Test_OS_MutSemGetInfo_Impl(void) */ OS_mut_sem_prop_t mut_prop; memset(&mut_prop, 0xEE, sizeof(mut_prop)); - OSAPI_TEST_FUNCTION_RC(OS_MutSemGetInfo_Impl(0,&mut_prop), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_MutSemGetInfo_Impl(0, &mut_prop), OS_SUCCESS); } - /* ------------------- End of test cases --------------------------------------*/ /* Osapi_Test_Setup @@ -106,10 +105,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* UtTest_Setup * @@ -125,5 +121,3 @@ void UtTest_Setup(void) ADD_TEST(OS_MutSemTake_Impl); ADD_TEST(OS_MutSemGetInfo_Impl); } - - diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-network.c b/src/unit-test-coverage/vxworks/src/coveragetest-network.c index 061aa7413..e196dc5cc 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-network.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-network.c @@ -54,7 +54,6 @@ void Test_OS_NetworkGetHostName_Impl(void) } /* end OS_NetworkGetHostName_Impl */ - void Test_OS_NetworkGetID_Impl(void) { @@ -71,7 +70,6 @@ void Test_OS_NetworkGetID_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_NetworkGetID_Impl(&IdBuf), OS_ERROR); } /* end OS_NetworkGetID_Impl */ - /* ------------------- End of test cases --------------------------------------*/ /* Osapi_Test_Setup @@ -90,10 +88,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* UtTest_Setup * @@ -105,4 +100,3 @@ void UtTest_Setup(void) ADD_TEST(OS_NetworkGetID_Impl); ADD_TEST(OS_NetworkGetHostName_Impl); } - diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-no-module.c b/src/unit-test-coverage/vxworks/src/coveragetest-no-module.c index 754de4be3..7983ad49e 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-no-module.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-no-module.c @@ -48,12 +48,12 @@ void Test_OS_ModuleLoad_Impl(void) /* Test Case For: * int32 OS_ModuleLoad_Impl ( uint32 module_id, char *translated_path ) */ - OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl(0,"local"), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl(0, "local"), OS_SUCCESS); UT_SetForceFail(UT_KEY(OCS_open), -1); - OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl(0,"local"), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl(0, "local"), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_open)); UT_SetForceFail(UT_KEY(OCS_loadModule), OCS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl(0,"local"), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl(0, "local"), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_loadModule)); } @@ -76,7 +76,7 @@ void Test_OS_ModuleGetInfo_Impl(void) OS_module_prop_t module_prop; memset(&module_prop, 0, sizeof(module_prop)); - OSAPI_TEST_FUNCTION_RC(OS_ModuleGetInfo_Impl(0,&module_prop), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_ModuleGetInfo_Impl(0, &module_prop), OS_SUCCESS); UtAssert_True(module_prop.addr.valid, "addresses in output valid"); /* @@ -85,12 +85,11 @@ void Test_OS_ModuleGetInfo_Impl(void) */ memset(&module_prop, 0, sizeof(module_prop)); UT_SetForceFail(UT_KEY(OCS_moduleInfoGet), OCS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_ModuleGetInfo_Impl(0,&module_prop), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_ModuleGetInfo_Impl(0, &module_prop), OS_SUCCESS); UT_ClearForceFail(UT_KEY(OCS_moduleInfoGet)); UtAssert_True(!module_prop.addr.valid, "addresses in output not valid"); } - /* ------------------- End of test cases --------------------------------------*/ /* Osapi_Test_Setup @@ -102,7 +101,6 @@ void Osapi_Test_Setup(void) { UT_ResetState(0); - memset(&OS_SharedGlobalVars, 0, sizeof(OS_SharedGlobalVars)); memset(OS_module_table, 0, sizeof(OS_module_table)); memset(OS_global_module_table, 0, sizeof(OS_common_record_t) * OS_MAX_MODULES); @@ -116,11 +114,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} - +void Osapi_Test_Teardown(void) {} /* UtTest_Setup * @@ -134,5 +128,3 @@ void UtTest_Setup(void) ADD_TEST(OS_ModuleUnload_Impl); ADD_TEST(OS_ModuleGetInfo_Impl); } - - diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-queues.c b/src/unit-test-coverage/vxworks/src/coveragetest-queues.c index b2e19de3f..7c059a148 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-queues.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-queues.c @@ -47,10 +47,10 @@ void Test_OS_QueueCreate_Impl(void) * Test Case For: * int32 OS_QueueCreate_Impl (uint32 queue_id, uint32 flags) */ - OSAPI_TEST_FUNCTION_RC(OS_QueueCreate_Impl(0,0), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_QueueCreate_Impl(0, 0), OS_SUCCESS); UT_SetForceFail(UT_KEY(OCS_msgQCreate), OCS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_QueueCreate_Impl(0,0), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_QueueCreate_Impl(0, 0), OS_ERROR); } void Test_OS_QueueDelete_Impl(void) @@ -71,7 +71,7 @@ void Test_OS_QueueGet_Impl(void) * Test Case For: * int32 OS_QueueGet_Impl (uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout) */ - char Data[16]; + char Data[16]; uint32 ActSz; OSAPI_TEST_FUNCTION_RC(OS_QueueGet_Impl(0, &Data, sizeof(Data), &ActSz, OS_PEND), OS_SUCCESS); @@ -114,10 +114,9 @@ void Test_OS_QueueGetInfo_Impl(void) */ OS_queue_prop_t queue_prop; memset(&queue_prop, 0xEE, sizeof(queue_prop)); - OSAPI_TEST_FUNCTION_RC(OS_QueueGetInfo_Impl(0,&queue_prop), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_QueueGetInfo_Impl(0, &queue_prop), OS_SUCCESS); } - /* ------------------- End of test cases --------------------------------------*/ /* Osapi_Test_Setup @@ -141,10 +140,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* UtTest_Setup * @@ -160,5 +156,3 @@ void UtTest_Setup(void) ADD_TEST(OS_QueuePut_Impl); ADD_TEST(OS_QueueGetInfo_Impl); } - - diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-shell.c b/src/unit-test-coverage/vxworks/src/coveragetest-shell.c index 2824a8981..af2897453 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-shell.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-shell.c @@ -55,13 +55,12 @@ void Test_OS_ShellOutputToFile_Impl(void) /* failure to open the output file */ UT_SetForceFail(UT_KEY(OS_OpenCreate), OS_ERROR); expected = OS_ERROR; - actual = OS_ShellOutputToFile_Impl(0, "TestCmd"); + actual = OS_ShellOutputToFile_Impl(0, "TestCmd"); UtAssert_True(actual == expected, "OS_ShellOutputToFile_Impl() (%ld) == OS_ERROR", (long)actual); } /* ------------------- End of test cases --------------------------------------*/ - /* Osapi_Test_Setup * * Purpose: @@ -79,10 +78,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* UtTest_Setup * @@ -93,4 +89,3 @@ void UtTest_Setup(void) { ADD_TEST(OS_ShellOutputToFile_Impl); } - diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-symtab.c b/src/unit-test-coverage/vxworks/src/coveragetest-symtab.c index 55bbb1005..890fd480d 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-symtab.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-symtab.c @@ -52,13 +52,13 @@ void Test_OS_SymTableIterator_Impl(void) */ uint32 Data = 0; - OSAPI_TEST_FUNCTION_RC(UT_SymTabTest_CallIteratorFunc("ut",&Data,100,1000), true); - OSAPI_TEST_FUNCTION_RC(UT_SymTabTest_CallIteratorFunc("ut",&Data,100,101), false); + OSAPI_TEST_FUNCTION_RC(UT_SymTabTest_CallIteratorFunc("ut", &Data, 100, 1000), true); + OSAPI_TEST_FUNCTION_RC(UT_SymTabTest_CallIteratorFunc("ut", &Data, 100, 101), false); UT_SetForceFail(UT_KEY(OCS_strlen), OS_MAX_SYM_LEN + 10); - OSAPI_TEST_FUNCTION_RC(UT_SymTabTest_CallIteratorFunc("ut",&Data,100,1000), false); + OSAPI_TEST_FUNCTION_RC(UT_SymTabTest_CallIteratorFunc("ut", &Data, 100, 1000), false); UT_ClearForceFail(UT_KEY(OCS_strlen)); UT_SetForceFail(UT_KEY(OCS_write), -1); - OSAPI_TEST_FUNCTION_RC(UT_SymTabTest_CallIteratorFunc("ut",&Data,100,1000), false); + OSAPI_TEST_FUNCTION_RC(UT_SymTabTest_CallIteratorFunc("ut", &Data, 100, 1000), false); UT_ClearForceFail(UT_KEY(OCS_write)); } @@ -67,13 +67,12 @@ void Test_OS_SymbolTableDump_Impl(void) /* Test Case For: * int32 OS_SymbolTableDump_Impl ( const char *filename, uint32 SizeLimit ) */ - OSAPI_TEST_FUNCTION_RC(OS_SymbolTableDump_Impl("file",10000), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_SymbolTableDump_Impl("file", 10000), OS_SUCCESS); UT_SetForceFail(UT_KEY(OCS_open), -1); - OSAPI_TEST_FUNCTION_RC(OS_SymbolTableDump_Impl("file",10000), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_SymbolTableDump_Impl("file", 10000), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_open)); } - /* ------------------- End of test cases --------------------------------------*/ /* Osapi_Test_Setup @@ -92,11 +91,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} - +void Osapi_Test_Teardown(void) {} /* UtTest_Setup * @@ -109,5 +104,3 @@ void UtTest_Setup(void) ADD_TEST(OS_SymbolLookup_Impl); ADD_TEST(OS_SymbolTableDump_Impl); } - - diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-tasks.c b/src/unit-test-coverage/vxworks/src/coveragetest-tasks.c index e990db4e5..0fd7b96ab 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-tasks.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-tasks.c @@ -37,7 +37,7 @@ * A chunk of memory usable as a heap for malloc() emulation */ unsigned long TestHeap[4096]; -int TestGlobalSem; +int TestGlobalSem; void Test_OS_VxWorks_TaskAPI_Impl_Init(void) { @@ -54,7 +54,7 @@ void Test_OS_VxWorksEntry(void) * Test Case For: * static int OS_VxWorksEntry(int arg) */ - OSAPI_TEST_FUNCTION_RC(UT_TaskTest_CallEntryPoint(0),OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(UT_TaskTest_CallEntryPoint(0), OS_SUCCESS); UtAssert_True(UT_GetStubCount(UT_KEY(OS_TaskEntryPoint)) == 1, "OS_TaskEntryPoint() called"); } @@ -71,10 +71,10 @@ void Test_OS_TaskCreate_Impl(void) * The first call checks the failure path and ensures that a malloc failure gets handled */ OS_task_table[0].stack_size = 250; UT_SetForceFail(UT_KEY(OCS_malloc), OS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_TaskCreate_Impl(0,0), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_TaskCreate_Impl(0, 0), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_malloc)); - OSAPI_TEST_FUNCTION_RC(OS_TaskCreate_Impl(0,OS_FP_ENABLED), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_TaskCreate_Impl(0, OS_FP_ENABLED), OS_SUCCESS); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_malloc)) == 2, "malloc() called"); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_free)) == 0, "free() not called"); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_taskInit)) == 1, "taskInit() called"); @@ -82,7 +82,7 @@ void Test_OS_TaskCreate_Impl(void) /* create again with smaller stack - this should re-use existing buffer */ OS_task_table[0].stack_size = 100; - OSAPI_TEST_FUNCTION_RC(OS_TaskCreate_Impl(0,OS_FP_ENABLED), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_TaskCreate_Impl(0, OS_FP_ENABLED), OS_SUCCESS); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_malloc)) == 2, "malloc() not called"); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_free)) == 0, "free() not called"); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_taskInit)) == 2, "taskInit() called"); @@ -90,17 +90,15 @@ void Test_OS_TaskCreate_Impl(void) /* create again with larger stack - this should free existing and malloc() new buffer */ OS_task_table[0].stack_size = 400; - OSAPI_TEST_FUNCTION_RC(OS_TaskCreate_Impl(0,OS_FP_ENABLED), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_TaskCreate_Impl(0, OS_FP_ENABLED), OS_SUCCESS); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_malloc)) == 3, "malloc() called"); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_free)) == 1, "free() called"); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_taskInit)) == 3, "taskInit() called"); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_taskActivate)) == 3, "taskActivate() called"); - /* other failure modes */ UT_SetForceFail(UT_KEY(OCS_taskInit), -1); - OSAPI_TEST_FUNCTION_RC(OS_TaskCreate_Impl(0,0), OS_ERROR); - + OSAPI_TEST_FUNCTION_RC(OS_TaskCreate_Impl(0, 0), OS_ERROR); } void Test_OS_TaskMatch_Impl(void) @@ -181,12 +179,12 @@ void Test_OS_TaskGetId_Impl(void) * uint32 OS_TaskGetId_Impl (void) */ OCS_WIND_TCB *TaskTcb; - osal_id_t id1; - osal_id_t id2; + osal_id_t id1; + osal_id_t id2; memset(&id1, 0x11, sizeof(osal_id_t)); OS_global_task_table[1].active_id = id1; - TaskTcb = UT_TaskTest_GetTaskTcb(1); + TaskTcb = UT_TaskTest_GetTaskTcb(1); UT_SetDataBuffer(UT_KEY(OCS_taskTcb), &TaskTcb, sizeof(TaskTcb), false); id2 = OS_TaskGetId_Impl(); UtAssert_MemCmp(&id1, &id2, sizeof(osal_id_t), "OS_TaskGetId_Impl()"); @@ -200,7 +198,7 @@ void Test_OS_TaskGetInfo_Impl(void) */ OS_task_prop_t task_prop; memset(&task_prop, 0xEE, sizeof(task_prop)); - OSAPI_TEST_FUNCTION_RC(OS_TaskGetInfo_Impl(0,&task_prop), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_TaskGetInfo_Impl(0, &task_prop), OS_SUCCESS); } void Test_OS_TaskValidateSystemData_Impl(void) @@ -215,7 +213,7 @@ void Test_OS_TaskValidateSystemData_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_TaskValidateSystemData_Impl(&test_sys_id, sizeof(test_sys_id)), OS_SUCCESS); OSAPI_TEST_FUNCTION_RC(OS_TaskValidateSystemData_Impl(NULL, sizeof(test_sys_id)), OS_INVALID_POINTER); - OSAPI_TEST_FUNCTION_RC(OS_TaskValidateSystemData_Impl(&test_sys_id, sizeof(test_sys_id)-1), OS_INVALID_POINTER); + OSAPI_TEST_FUNCTION_RC(OS_TaskValidateSystemData_Impl(&test_sys_id, sizeof(test_sys_id) - 1), OS_INVALID_POINTER); } void Test_OS_TaskIdMatchSystemData_Impl(void) @@ -235,7 +233,6 @@ void Test_OS_TaskIdMatchSystemData_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_TaskIdMatchSystemData_Impl(&test_sys_id, 0, NULL), false); } - /* ------------------- End of test cases --------------------------------------*/ /* Osapi_Test_Setup @@ -258,10 +255,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} +void Osapi_Test_Teardown(void) {} /* UtTest_Setup * @@ -284,5 +278,3 @@ void UtTest_Setup(void) ADD_TEST(OS_TaskValidateSystemData_Impl); ADD_TEST(OS_TaskIdMatchSystemData_Impl); } - - diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-timebase.c b/src/unit-test-coverage/vxworks/src/coveragetest-timebase.c index c84c092f5..92ad9198a 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-timebase.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-timebase.c @@ -35,7 +35,6 @@ #include #include - void Test_OS_VxWorks_TimeBaseAPI_Impl_Init(void) { /* Test Case For: @@ -46,7 +45,6 @@ void Test_OS_VxWorks_TimeBaseAPI_Impl_Init(void) OSAPI_TEST_FUNCTION_RC(UT_Call_OS_VxWorks_TimeBaseAPI_Impl_Init(), OS_ERROR); } - void Test_OS_TimeBaseLock_Impl(void) { /* Test Case For: @@ -63,7 +61,8 @@ void Test_OS_TimeBaseUnlock_Impl(void) OS_TimeBaseUnlock_Impl(0); } -static int32 UT_TimeBaseTest_TimeBaseRegHook(void *UserObj, int32 StubRetcode, uint32 CallCount, const UT_StubContext_t *Context) +static int32 UT_TimeBaseTest_TimeBaseRegHook(void *UserObj, int32 StubRetcode, uint32 CallCount, + const UT_StubContext_t *Context) { UT_TimeBaseTest_SetTimeBaseRegState(0, true); return 0; @@ -89,7 +88,6 @@ void Test_OS_Impl_UsecToTimespec(void) UtAssert_True(ts.tv_sec == 0, "ts.tv_sec (%ld) == 0", (long)ts.tv_sec); UtAssert_True(ts.tv_nsec == 1000, "ts.tv_nsec (%ld) == 1000", (long)ts.tv_sec); - memset(&ts, 255, sizeof(ts)); UT_TimeBaseTest_UsecToTimespec(1000000000, &ts); UtAssert_True(ts.tv_sec == 1000, "ts.tv_sec (%ld) == 1000", (long)ts.tv_sec); @@ -111,7 +109,7 @@ void Test_OS_TimeBaseCreate_Impl(void) */ memset(&id, 0x01, sizeof(id)); OS_global_timebase_table[1].active_id = id; - UT_TimeBaseTest_Setup(1,OCS_SIGRTMIN, false); + UT_TimeBaseTest_Setup(1, OCS_SIGRTMIN, false); UT_SetForceFail(UT_KEY(OCS_sigismember), true); OSAPI_TEST_FUNCTION_RC(OS_TimeBaseCreate_Impl(0), OS_TIMER_ERR_UNAVAILABLE); UT_ResetState(UT_KEY(OCS_sigismember)); @@ -165,30 +163,30 @@ void Test_OS_VxWorks_SigWait(void) * static uint32 OS_VxWorks_SigWait(uint32 local_id) * (invocation of static function through a wrapper) */ - int signo = OCS_SIGRTMIN; + int signo = OCS_SIGRTMIN; struct OCS_itimerspec config_value; - osal_id_t id; + osal_id_t id; memset(&id, 0x02, sizeof(id)); - OS_global_timebase_table[0].active_id = id; - OS_timebase_table[0].nominal_start_time = 8888; + OS_global_timebase_table[0].active_id = id; + OS_timebase_table[0].nominal_start_time = 8888; OS_timebase_table[0].nominal_interval_time = 5555; memset(&config_value, 0, sizeof(config_value)); - UT_SetDataBuffer(UT_KEY(OCS_timer_settime),&config_value,sizeof(config_value),false); - UT_SetDataBuffer(UT_KEY(OCS_timer_gettime),&config_value,sizeof(config_value),false); + UT_SetDataBuffer(UT_KEY(OCS_timer_settime), &config_value, sizeof(config_value), false); + UT_SetDataBuffer(UT_KEY(OCS_timer_gettime), &config_value, sizeof(config_value), false); UT_TimeBaseTest_Setup(0, signo, true); OS_TimeBaseSet_Impl(0, 1111111, 2222222); - UT_SetDataBuffer(UT_KEY(OCS_sigwait),&signo,sizeof(signo),false); + UT_SetDataBuffer(UT_KEY(OCS_sigwait), &signo, sizeof(signo), false); OSAPI_TEST_FUNCTION_RC(UT_TimeBaseTest_CallSigWaitFunc(0), 1111111); - UT_SetDataBuffer(UT_KEY(OCS_sigwait),&signo,sizeof(signo),false); + UT_SetDataBuffer(UT_KEY(OCS_sigwait), &signo, sizeof(signo), false); OSAPI_TEST_FUNCTION_RC(UT_TimeBaseTest_CallSigWaitFunc(0), 2222222); - UT_SetDataBuffer(UT_KEY(OCS_sigwait),&signo,sizeof(signo),false); + UT_SetDataBuffer(UT_KEY(OCS_sigwait), &signo, sizeof(signo), false); OSAPI_TEST_FUNCTION_RC(UT_TimeBaseTest_CallSigWaitFunc(0), 2222222); UT_TimeBaseTest_Setup(0, 0, false); - OS_global_timebase_table[0].active_id = OS_OBJECT_ID_UNDEFINED; + OS_global_timebase_table[0].active_id = OS_OBJECT_ID_UNDEFINED; OS_timebase_table[0].nominal_interval_time = 0; } @@ -197,13 +195,13 @@ void Test_OS_TimeBaseSet_Impl(void) /* Test Case For: * int32 OS_TimeBaseSet_Impl(uint32 timer_id, int32 start_time, int32 interval_time) */ - OSAPI_TEST_FUNCTION_RC(OS_TimeBaseSet_Impl(0,1,1), OS_ERR_NOT_IMPLEMENTED); + OSAPI_TEST_FUNCTION_RC(OS_TimeBaseSet_Impl(0, 1, 1), OS_ERR_NOT_IMPLEMENTED); UT_TimeBaseTest_Setup(0, OCS_SIGRTMIN, false); - OSAPI_TEST_FUNCTION_RC(OS_TimeBaseSet_Impl(0,1,1), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_TimeBaseSet_Impl(0, 1, 1), OS_SUCCESS); UT_SetForceFail(UT_KEY(OCS_timer_settime), -1); - OSAPI_TEST_FUNCTION_RC(OS_TimeBaseSet_Impl(0,1,1), OS_TIMER_ERR_INVALID_ARGS); + OSAPI_TEST_FUNCTION_RC(OS_TimeBaseSet_Impl(0, 1, 1), OS_TIMER_ERR_INVALID_ARGS); } void Test_OS_TimeBaseDelete_Impl(void) @@ -221,7 +219,7 @@ void Test_OS_TimeBaseGetInfo_Impl(void) * int32 OS_TimeBaseGetInfo_Impl (uint32 timer_id, OS_timebase_prop_t *timer_prop) */ OS_timebase_prop_t timer_prop; - OSAPI_TEST_FUNCTION_RC(OS_TimeBaseGetInfo_Impl(0,&timer_prop), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_TimeBaseGetInfo_Impl(0, &timer_prop), OS_SUCCESS); } /* ------------------- End of test cases --------------------------------------*/ @@ -247,11 +245,7 @@ void Osapi_Test_Setup(void) * Purpose: * Called by the unit test tool to tear down the app after each test */ -void Osapi_Test_Teardown(void) -{ - -} - +void Osapi_Test_Teardown(void) {} /* UtTest_Setup * @@ -270,4 +264,3 @@ void UtTest_Setup(void) ADD_TEST(OS_TimeBaseGetInfo_Impl); ADD_TEST(OS_Impl_UsecToTimespec); } - diff --git a/src/unit-test-coverage/vxworks/src/os-vxworks-coveragetest.h b/src/unit-test-coverage/vxworks/src/os-vxworks-coveragetest.h index de4158a3f..d51d0fb41 100644 --- a/src/unit-test-coverage/vxworks/src/os-vxworks-coveragetest.h +++ b/src/unit-test-coverage/vxworks/src/os-vxworks-coveragetest.h @@ -34,16 +34,14 @@ #include "os-shared-idmap.h" +#define OSAPI_TEST_FUNCTION_RC(func, exp) \ + { \ + int32 rcexp = exp; \ + int32 rcact = func; \ + UtAssert_True(rcact == rcexp, "%s (%ld) == %s (%ld)", #func, (long)rcact, #exp, (long)rcexp); \ + } -#define OSAPI_TEST_FUNCTION_RC(func,exp) \ -{ \ - int32 rcexp = exp; \ - int32 rcact = func; \ - UtAssert_True(rcact == rcexp, "%s (%ld) == %s (%ld)", \ - #func, (long)rcact, #exp, (long)rcexp); \ -} - -#define ADD_TEST(test) UtTest_Add((Test_ ## test), Osapi_Test_Setup, Osapi_Test_Teardown, #test) +#define ADD_TEST(test) UtTest_Add((Test_##test), Osapi_Test_Setup, Osapi_Test_Teardown, #test) /* Osapi_Test_Setup * @@ -53,6 +51,4 @@ void Osapi_Test_Setup(void); void Osapi_Test_Teardown(void); - -#endif /* INCLUDE_OS_VXWORKS_COVERAGETEST_H_ */ - +#endif /* INCLUDE_OS_VXWORKS_COVERAGETEST_H_ */ diff --git a/src/unit-test-coverage/vxworks/ut-stubs/src/vxworks-os-impl-idmap-stubs.c b/src/unit-test-coverage/vxworks/ut-stubs/src/vxworks-os-impl-idmap-stubs.c index a7d5338d3..5c1acef5f 100644 --- a/src/unit-test-coverage/vxworks/ut-stubs/src/vxworks-os-impl-idmap-stubs.c +++ b/src/unit-test-coverage/vxworks/ut-stubs/src/vxworks-os-impl-idmap-stubs.c @@ -29,4 +29,3 @@ #include "utstubs.h" UT_DEFAULT_STUB(OS_VxWorks_TableMutex_Init, (uint32 idtype)) - diff --git a/src/unit-tests/inc/ut_os_support.h b/src/unit-tests/inc/ut_os_support.h index 74419a51a..86e841b83 100644 --- a/src/unit-tests/inc/ut_os_support.h +++ b/src/unit-tests/inc/ut_os_support.h @@ -39,7 +39,6 @@ #include "uttest.h" #include "osapi.h" - /*--------------------------------------------------------------------------------* ** Macros **--------------------------------------------------------------------------------*/ @@ -50,27 +49,30 @@ * These are sized somewhat larger than the osconfig.h specification, * so that test cases may create names that exceed the allowed length */ -#define UT_OS_NAME_BUFF_SIZE (OS_MAX_API_NAME + 10) -#define UT_OS_FILE_BUFF_SIZE (OS_MAX_FILE_NAME + 10) -#define UT_OS_PATH_BUFF_SIZE (OS_MAX_PATH_LEN + 10) -#define UT_OS_PHYS_NAME_BUFF_SIZE (OS_FS_PHYS_NAME_LEN + 10) -#define UT_OS_LOCAL_PATH_BUFF_SIZE (OS_MAX_LOCAL_PATH_LEN + 10) +#define UT_OS_NAME_BUFF_SIZE (OS_MAX_API_NAME + 10) +#define UT_OS_FILE_BUFF_SIZE (OS_MAX_FILE_NAME + 10) +#define UT_OS_PATH_BUFF_SIZE (OS_MAX_PATH_LEN + 10) +#define UT_OS_PHYS_NAME_BUFF_SIZE (OS_FS_PHYS_NAME_LEN + 10) +#define UT_OS_LOCAL_PATH_BUFF_SIZE (OS_MAX_LOCAL_PATH_LEN + 10) /* * Generic buffer for I/O operations */ -#define UT_OS_IO_BUFF_SIZE 128 +#define UT_OS_IO_BUFF_SIZE 128 -static inline bool UtOsalRetVal(int32 Fn, int32 Exp, UtAssert_CaseType_t casetype, const char *File, uint32 Line, const char *FnTxt, const char *ExpTxt, const char *Msg) +static inline bool UtOsalRetVal(int32 Fn, int32 Exp, UtAssert_CaseType_t casetype, const char *File, uint32 Line, + const char *FnTxt, const char *ExpTxt, const char *Msg) { return UtAssertEx(Fn == Exp, casetype, File, Line, "%s (%d) == %s (%d): %s", FnTxt, (int)Fn, ExpTxt, (int)Exp, Msg); } /* Only report errors */ -static inline bool UtOsalCheck(int32 Fn, int32 Exp, UtAssert_CaseType_t casetype, const char *File, uint32 Line, const char *FnTxt, const char *ExpTxt) +static inline bool UtOsalCheck(int32 Fn, int32 Exp, UtAssert_CaseType_t casetype, const char *File, uint32 Line, + const char *FnTxt, const char *ExpTxt) { - return Fn == Exp ? true : - UtAssertEx(Fn == Exp, casetype, File, Line, "%s (%d) == %s (%d)", FnTxt, (int)Fn, ExpTxt, (int)Exp); + return Fn == Exp + ? true + : UtAssertEx(Fn == Exp, casetype, File, Line, "%s (%d) == %s (%d)", FnTxt, (int)Fn, ExpTxt, (int)Exp); } static inline bool UtOsalImplemented(int32 Fn, const char *File, uint32 Line) @@ -84,28 +86,30 @@ static inline bool UtOsalImplemented(int32 Fn, const char *File, uint32 Line) return true; } - -#define UT_NOMINAL(Fn) UtOsalRetVal(Fn, OS_SUCCESS, UTASSERT_CASETYPE_FAILURE, __FILE__, __LINE__, #Fn, "OS_SUCCESS", "Nominal") +#define UT_NOMINAL(Fn) \ + UtOsalRetVal(Fn, OS_SUCCESS, UTASSERT_CASETYPE_FAILURE, __FILE__, __LINE__, #Fn, "OS_SUCCESS", "Nominal") #define UT_RETVAL(Fn, Exp, Msg) UtOsalRetVal(Fn, Exp, UTASSERT_CASETYPE_FAILURE, __FILE__, __LINE__, #Fn, #Exp, Msg) -#define UT_SETUP(Fn) UtOsalCheck(Fn, OS_SUCCESS, UTASSERT_CASETYPE_TSF, __FILE__, __LINE__, #Fn, "OS_SUCCESS") -#define UT_TEARDOWN(Fn) UtOsalCheck(Fn, OS_SUCCESS, UTASSERT_CASETYPE_TTF, __FILE__, __LINE__, #Fn, "OS_SUCCESS") -#define UT_IMPL(Fn) UtOsalImplemented(Fn, __FILE__, __LINE__) +#define UT_SETUP(Fn) UtOsalCheck(Fn, OS_SUCCESS, UTASSERT_CASETYPE_TSF, __FILE__, __LINE__, #Fn, "OS_SUCCESS") +#define UT_TEARDOWN(Fn) UtOsalCheck(Fn, OS_SUCCESS, UTASSERT_CASETYPE_TTF, __FILE__, __LINE__, #Fn, "OS_SUCCESS") +#define UT_IMPL(Fn) UtOsalImplemented(Fn, __FILE__, __LINE__) /*--------------------------------------------------------------------------------*/ -#define UT_OS_TEST_RESULT(descStr, caseType) \ - UtAssertEx(false, caseType, __FILE__, __LINE__, "%s", descStr) +#define UT_OS_TEST_RESULT(descStr, caseType) UtAssertEx(false, caseType, __FILE__, __LINE__, "%s", descStr) /*--------------------------------------------------------------------------------*/ -#define UT_os_sprintf(buf,...) \ - do { int x = snprintf(buf,sizeof(buf),__VA_ARGS__); if (x > 0 && x < sizeof(buf)) buf[x] = 0; } while (0) +#define UT_os_sprintf(buf, ...) \ + do \ + { \ + int x = snprintf(buf, sizeof(buf), __VA_ARGS__); \ + if (x > 0 && x < sizeof(buf)) \ + buf[x] = 0; \ + } while (0) /*--------------------------------------------------------------------------------*/ -#define UT_OS_LOG(...) \ - UtAssert_Message(UTASSERT_CASETYPE_INFO,__FILE__,__LINE__,__VA_ARGS__); - +#define UT_OS_LOG(...) UtAssert_Message(UTASSERT_CASETYPE_INFO, __FILE__, __LINE__, __VA_ARGS__); /* * An osal_id_t value which is not OS_OBJECT_ID_UNDEFINED and also @@ -113,7 +117,7 @@ static inline bool UtOsalImplemented(int32 Fn, const char *File, uint32 Line) * * This is used to test for proper rejection of bad ID values. */ -#define UT_OBJID_INCORRECT ((osal_id_t){0xDEADBEEF}) +#define UT_OBJID_INCORRECT ((osal_id_t) {0xDEADBEEF}) /*--------------------------------------------------------------------------------* ** Data types @@ -131,10 +135,9 @@ static inline bool UtOsalImplemented(int32 Fn, const char *File, uint32 Line) ** Function prototypes **--------------------------------------------------------------------------------*/ - /*--------------------------------------------------------------------------------*/ -#endif /* _UT_OS_SUPPORT_H_ */ +#endif /* _UT_OS_SUPPORT_H_ */ /*================================================================================* ** End of File: ut_os_support.h diff --git a/src/unit-tests/oscore-test/ut_oscore_binsem_test.c b/src/unit-tests/oscore-test/ut_oscore_binsem_test.c index fca480e1f..14dafa6c6 100644 --- a/src/unit-tests/oscore-test/ut_oscore_binsem_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_binsem_test.c @@ -67,13 +67,14 @@ **--------------------------------------------------------------------------------*/ void UT_os_bin_sem_create_test() { - int i; - char sem_name[UT_OS_NAME_BUFF_SIZE]; - char long_sem_name[UT_OS_NAME_BUFF_SIZE]; - osal_id_t sem_ids[OS_MAX_BIN_SEMAPHORES+1]; + int i; + char sem_name[UT_OS_NAME_BUFF_SIZE]; + char long_sem_name[UT_OS_NAME_BUFF_SIZE]; + osal_id_t sem_ids[OS_MAX_BIN_SEMAPHORES + 1]; /*-----------------------------------------------------*/ - if (!UT_IMPL(OS_BinSemCreate(&sem_ids[0], "Good", 1, 0))) return; + if (!UT_IMPL(OS_BinSemCreate(&sem_ids[0], "Good", 1, 0))) + return; UT_TEARDOWN(OS_BinSemDelete(sem_ids[0])); /*-----------------------------------------------------*/ @@ -84,37 +85,38 @@ void UT_os_bin_sem_create_test() /*-----------------------------------------------------*/ memset(long_sem_name, 'X', sizeof(long_sem_name)); - long_sem_name[sizeof(long_sem_name)-1] = '\0'; + long_sem_name[sizeof(long_sem_name) - 1] = '\0'; UT_RETVAL(OS_BinSemCreate(&sem_ids[0], long_sem_name, 1, 0), OS_ERR_NAME_TOO_LONG, "name too long"); /*-----------------------------------------------------*/ /* Setup */ - for ( i = 0; i< OS_MAX_BIN_SEMAPHORES; i++ ) + for (i = 0; i < OS_MAX_BIN_SEMAPHORES; i++) { - memset(sem_name, '\0', sizeof(sem_name)); - UT_os_sprintf(sem_name, "BINSEM%d", i); + memset(sem_name, '\0', sizeof(sem_name)); + UT_os_sprintf(sem_name, "BINSEM%d", i); - if(!UT_SETUP(OS_BinSemCreate(&sem_ids[i], sem_name, 1, 0))) - { - break; - } + if (!UT_SETUP(OS_BinSemCreate(&sem_ids[i], sem_name, 1, 0))) + { + break; + } } - if ( i == OS_MAX_BIN_SEMAPHORES ) /* setup was successful */ + if (i == OS_MAX_BIN_SEMAPHORES) /* setup was successful */ { - UT_RETVAL(OS_BinSemCreate(&sem_ids[OS_MAX_BIN_SEMAPHORES], "OneTooMany", 1, 0), OS_ERR_NO_FREE_IDS, "no free ids"); + UT_RETVAL(OS_BinSemCreate(&sem_ids[OS_MAX_BIN_SEMAPHORES], "OneTooMany", 1, 0), OS_ERR_NO_FREE_IDS, + "no free ids"); } /* Reset test environment */ OS_DeleteAllObjects(); /*-----------------------------------------------------*/ - if(UT_SETUP(OS_BinSemCreate(&sem_ids[0], "DUPLICATE", 1, 0))) + if (UT_SETUP(OS_BinSemCreate(&sem_ids[0], "DUPLICATE", 1, 0))) { - UT_RETVAL(OS_BinSemCreate(&sem_ids[0], "DUPLICATE", 1, 0), OS_ERR_NAME_TAKEN, "duplicate name"); + UT_RETVAL(OS_BinSemCreate(&sem_ids[0], "DUPLICATE", 1, 0), OS_ERR_NAME_TAKEN, "duplicate name"); - /* Reset test environment */ - UT_TEARDOWN(OS_BinSemDelete(sem_ids[0])); + /* Reset test environment */ + UT_TEARDOWN(OS_BinSemDelete(sem_ids[0])); } /*-----------------------------------------------------*/ @@ -134,18 +136,19 @@ void UT_os_bin_sem_create_test() **--------------------------------------------------------------------------------*/ void UT_os_bin_sem_delete_test() { - osal_id_t bin_sem_id; + osal_id_t bin_sem_id; /*-----------------------------------------------------*/ - if (!UT_IMPL(OS_BinSemDelete(OS_OBJECT_ID_UNDEFINED))) return; + if (!UT_IMPL(OS_BinSemDelete(OS_OBJECT_ID_UNDEFINED))) + return; /*-----------------------------------------------------*/ UT_RETVAL(OS_BinSemDelete(UT_OBJID_INCORRECT), OS_ERR_INVALID_ID, "invalid id arg"); /*-----------------------------------------------------*/ - if(UT_SETUP(OS_BinSemCreate(&bin_sem_id, "DeleteTest", 1, 0))) + if (UT_SETUP(OS_BinSemCreate(&bin_sem_id, "DeleteTest", 1, 0))) { - UT_NOMINAL(OS_BinSemDelete(bin_sem_id)); + UT_NOMINAL(OS_BinSemDelete(bin_sem_id)); } } @@ -160,19 +163,20 @@ void UT_os_bin_sem_delete_test() **--------------------------------------------------------------------------------*/ void UT_os_bin_sem_flush_test() { - osal_id_t bin_sem_id; + osal_id_t bin_sem_id; /*-----------------------------------------------------*/ - if (!UT_IMPL(OS_BinSemFlush(OS_OBJECT_ID_UNDEFINED))) return; + if (!UT_IMPL(OS_BinSemFlush(OS_OBJECT_ID_UNDEFINED))) + return; /*-----------------------------------------------------*/ UT_RETVAL(OS_BinSemFlush(UT_OBJID_INCORRECT), OS_ERR_INVALID_ID, "invalid id arg"); /*----------------------------------------------------*/ - if(UT_SETUP(OS_BinSemCreate(&bin_sem_id, "FlushTest", 1, 0))) + if (UT_SETUP(OS_BinSemCreate(&bin_sem_id, "FlushTest", 1, 0))) { - UT_NOMINAL(OS_BinSemFlush(bin_sem_id)); - UT_TEARDOWN(OS_BinSemDelete(bin_sem_id)); + UT_NOMINAL(OS_BinSemFlush(bin_sem_id)); + UT_TEARDOWN(OS_BinSemDelete(bin_sem_id)); } } @@ -187,10 +191,11 @@ void UT_os_bin_sem_flush_test() **--------------------------------------------------------------------------------*/ void UT_os_bin_sem_give_test() { - osal_id_t bin_sem_id; + osal_id_t bin_sem_id; /*-----------------------------------------------------*/ - if (!UT_IMPL(OS_BinSemGive(OS_OBJECT_ID_UNDEFINED))) return; + if (!UT_IMPL(OS_BinSemGive(OS_OBJECT_ID_UNDEFINED))) + return; /*-----------------------------------------------------*/ UT_RETVAL(OS_BinSemGive(UT_OBJID_INCORRECT), OS_ERR_INVALID_ID, "invalid id arg"); @@ -198,8 +203,8 @@ void UT_os_bin_sem_give_test() /*-----------------------------------------------------*/ if (UT_SETUP(OS_BinSemCreate(&bin_sem_id, "GiveTest", 1, 0))) { - UT_NOMINAL(OS_BinSemGive(bin_sem_id)); - UT_TEARDOWN(OS_BinSemDelete(bin_sem_id)); + UT_NOMINAL(OS_BinSemGive(bin_sem_id)); + UT_TEARDOWN(OS_BinSemDelete(bin_sem_id)); } } @@ -215,10 +220,11 @@ void UT_os_bin_sem_give_test() **--------------------------------------------------------------------------------*/ void UT_os_bin_sem_take_test() { - osal_id_t bin_sem_id; + osal_id_t bin_sem_id; /*-----------------------------------------------------*/ - if (!UT_IMPL(OS_BinSemTake(OS_OBJECT_ID_UNDEFINED))) return; + if (!UT_IMPL(OS_BinSemTake(OS_OBJECT_ID_UNDEFINED))) + return; /*-----------------------------------------------------*/ UT_RETVAL(OS_BinSemTake(UT_OBJID_INCORRECT), OS_ERR_INVALID_ID, "invalid id arg"); @@ -226,8 +232,8 @@ void UT_os_bin_sem_take_test() /*-----------------------------------------------------*/ if (UT_SETUP(OS_BinSemCreate(&bin_sem_id, "TakeTest", 1, 0))) { - UT_NOMINAL(OS_BinSemTake(bin_sem_id)); - UT_TEARDOWN(OS_BinSemDelete(bin_sem_id)); + UT_NOMINAL(OS_BinSemTake(bin_sem_id)); + UT_TEARDOWN(OS_BinSemDelete(bin_sem_id)); } } @@ -242,24 +248,24 @@ void UT_os_bin_sem_take_test() **--------------------------------------------------------------------------------*/ void UT_os_bin_sem_timed_wait_test() { - osal_id_t bin_sem_id; + osal_id_t bin_sem_id; /*-----------------------------------------------------*/ - if (!UT_IMPL(OS_BinSemTimedWait(OS_OBJECT_ID_UNDEFINED, 1000))) return; + if (!UT_IMPL(OS_BinSemTimedWait(OS_OBJECT_ID_UNDEFINED, 1000))) + return; /*-----------------------------------------------------*/ UT_RETVAL(OS_BinSemTimedWait(UT_OBJID_INCORRECT, 1000), OS_ERR_INVALID_ID, "invalid id arg"); /*-----------------------------------------------------*/ - if(UT_SETUP(OS_BinSemCreate(&bin_sem_id, "TimedWait", 1, 0)) - && UT_SETUP(OS_BinSemTake(bin_sem_id))) + if (UT_SETUP(OS_BinSemCreate(&bin_sem_id, "TimedWait", 1, 0)) && UT_SETUP(OS_BinSemTake(bin_sem_id))) { - UT_RETVAL(OS_BinSemTimedWait(bin_sem_id, 1000), OS_SEM_TIMEOUT, "semtake timed out"); - UT_TEARDOWN(OS_BinSemDelete(bin_sem_id)); + UT_RETVAL(OS_BinSemTimedWait(bin_sem_id, 1000), OS_SEM_TIMEOUT, "semtake timed out"); + UT_TEARDOWN(OS_BinSemDelete(bin_sem_id)); } /*-----------------------------------------------------*/ - if(UT_SETUP(OS_BinSemCreate(&bin_sem_id, "TimedWait", 1, 0))) + if (UT_SETUP(OS_BinSemCreate(&bin_sem_id, "TimedWait", 1, 0))) { UT_NOMINAL(OS_BinSemTimedWait(bin_sem_id, 1000)); UT_TEARDOWN(OS_BinSemDelete(bin_sem_id)); @@ -278,11 +284,12 @@ void UT_os_bin_sem_timed_wait_test() **--------------------------------------------------------------------------------*/ void UT_os_bin_sem_get_id_by_name_test() { - osal_id_t bin_sem_id; - char long_sem_name[UT_OS_NAME_BUFF_SIZE]; + osal_id_t bin_sem_id; + char long_sem_name[UT_OS_NAME_BUFF_SIZE]; /*-----------------------------------------------------*/ - if (!UT_IMPL(OS_BinSemGetIdByName(NULL, "InvalidName"))) return; + if (!UT_IMPL(OS_BinSemGetIdByName(NULL, "InvalidName"))) + return; /*-----------------------------------------------------*/ UT_RETVAL(OS_BinSemGetIdByName(NULL, "InvalidName"), OS_INVALID_POINTER, "invalid ptr arg 1"); @@ -292,17 +299,17 @@ void UT_os_bin_sem_get_id_by_name_test() /*-----------------------------------------------------*/ memset(long_sem_name, 'Y', sizeof(long_sem_name)); - long_sem_name[sizeof(long_sem_name)-1] = '\0'; + long_sem_name[sizeof(long_sem_name) - 1] = '\0'; UT_RETVAL(OS_BinSemGetIdByName(&bin_sem_id, long_sem_name), OS_ERR_NAME_TOO_LONG, "name too long"); /*-----------------------------------------------------*/ UT_RETVAL(OS_BinSemGetIdByName(&bin_sem_id, "NameNotFound"), OS_ERR_NAME_NOT_FOUND, "name not found"); /*-----------------------------------------------------*/ - if(UT_SETUP(OS_BinSemCreate(&bin_sem_id, "GetIDByName", 1, 0))) + if (UT_SETUP(OS_BinSemCreate(&bin_sem_id, "GetIDByName", 1, 0))) { - UT_NOMINAL(OS_BinSemGetIdByName(&bin_sem_id, "GetIDByName")); - UT_TEARDOWN(OS_BinSemDelete(bin_sem_id)); + UT_NOMINAL(OS_BinSemGetIdByName(&bin_sem_id, "GetIDByName")); + UT_TEARDOWN(OS_BinSemDelete(bin_sem_id)); } } @@ -317,24 +324,25 @@ void UT_os_bin_sem_get_id_by_name_test() **--------------------------------------------------------------------------------*/ void UT_os_bin_sem_get_info_test() { - osal_id_t bin_sem_id; - OS_bin_sem_prop_t bin_sem_prop; + osal_id_t bin_sem_id; + OS_bin_sem_prop_t bin_sem_prop; /*-----------------------------------------------------*/ - if (!UT_IMPL(OS_BinSemGetInfo(OS_OBJECT_ID_UNDEFINED, &bin_sem_prop))) return; + if (!UT_IMPL(OS_BinSemGetInfo(OS_OBJECT_ID_UNDEFINED, &bin_sem_prop))) + return; /*-----------------------------------------------------*/ UT_RETVAL(OS_BinSemGetInfo(UT_OBJID_INCORRECT, &bin_sem_prop), OS_ERR_INVALID_ID, "invalid id"); /*-----------------------------------------------------*/ - if(UT_SETUP(OS_BinSemCreate(&bin_sem_id, "GetInfo", 1, 0))) + if (UT_SETUP(OS_BinSemCreate(&bin_sem_id, "GetInfo", 1, 0))) { - UT_RETVAL(OS_BinSemGetInfo(bin_sem_id, NULL),OS_INVALID_POINTER, "invalid ptr"); + UT_RETVAL(OS_BinSemGetInfo(bin_sem_id, NULL), OS_INVALID_POINTER, "invalid ptr"); UT_TEARDOWN(OS_BinSemDelete(bin_sem_id)); } /*-----------------------------------------------------*/ - if(UT_SETUP(OS_BinSemCreate(&bin_sem_id, "GetInfo", 1, 0))) + if (UT_SETUP(OS_BinSemCreate(&bin_sem_id, "GetInfo", 1, 0))) { UT_NOMINAL(OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop)); UT_TEARDOWN(OS_BinSemDelete(bin_sem_id)); diff --git a/src/unit-tests/oscore-test/ut_oscore_binsem_test.h b/src/unit-tests/oscore-test/ut_oscore_binsem_test.h index 72e05cee7..591c207ca 100644 --- a/src/unit-tests/oscore-test/ut_oscore_binsem_test.h +++ b/src/unit-tests/oscore-test/ut_oscore_binsem_test.h @@ -64,7 +64,7 @@ void UT_os_bin_sem_get_info_test(void); /*--------------------------------------------------------------------------------*/ -#endif /* _UT_OSCORE_BINSEM_TEST_H_ */ +#endif /* _UT_OSCORE_BINSEM_TEST_H_ */ /*================================================================================* ** End of File: ut_oscore_binsem_test.h diff --git a/src/unit-tests/oscore-test/ut_oscore_countsem_test.c b/src/unit-tests/oscore-test/ut_oscore_countsem_test.c index 706c7b8d1..e35112dc3 100644 --- a/src/unit-tests/oscore-test/ut_oscore_countsem_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_countsem_test.c @@ -67,21 +67,21 @@ **--------------------------------------------------------------------------------*/ void UT_os_count_sem_create_test() { - int i; - int32 res = 0; - const char* testDesc; - osal_id_t count_sem_ids[OS_MAX_COUNT_SEMAPHORES+1]; - char sem_name[UT_OS_NAME_BUFF_SIZE]; - char long_sem_name[UT_OS_NAME_BUFF_SIZE]; - uint32 test_setup_invalid = 0; + int i; + int32 res = 0; + const char *testDesc; + osal_id_t count_sem_ids[OS_MAX_COUNT_SEMAPHORES + 1]; + char sem_name[UT_OS_NAME_BUFF_SIZE]; + char long_sem_name[UT_OS_NAME_BUFF_SIZE]; + uint32 test_setup_invalid = 0; /*-----------------------------------------------------*/ testDesc = "API not implemented"; - res = OS_CountSemCreate(&count_sem_ids[0], "Good", 1, 0 ); + res = OS_CountSemCreate(&count_sem_ids[0], "Good", 1, 0); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_count_sem_create_test_exit_tag; } @@ -93,29 +93,29 @@ void UT_os_count_sem_create_test() res = OS_CountSemCreate(NULL, "CountSem1", 1, 0); if (res == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Null-pointer-arg-2"; res = OS_CountSemCreate(&count_sem_ids[0], NULL, 1, 0); if (res == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Name-too-long"; memset(long_sem_name, 'X', sizeof(long_sem_name)); - long_sem_name[sizeof(long_sem_name)-1] = '\0'; - res = OS_CountSemCreate(&count_sem_ids[0], long_sem_name, 1, 0); + long_sem_name[sizeof(long_sem_name) - 1] = '\0'; + res = OS_CountSemCreate(&count_sem_ids[0], long_sem_name, 1, 0); if (res == OS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 Initial-count-too-high"; @@ -128,38 +128,38 @@ void UT_os_count_sem_create_test() #ifdef SEM_VALUE_MAX res = OS_CountSemCreate(&count_sem_ids[0], "CountSem1", ((uint32)SEM_VALUE_MAX) + 1, 0); if (res == OS_INVALID_SEM_VALUE) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); #else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); #endif /*-----------------------------------------------------*/ testDesc = "#5 No-free-IDs"; /* Setup */ - for ( i = 0; i< OS_MAX_COUNT_SEMAPHORES; i++ ) + for (i = 0; i < OS_MAX_COUNT_SEMAPHORES; i++) { memset(sem_name, '\0', sizeof(sem_name)); UT_os_sprintf(sem_name, "COUNTSEM%d", i); res = OS_CountSemCreate(&count_sem_ids[i], sem_name, 1, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#5 No-free-IDs - Count Sem Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); test_setup_invalid = 1; break; } } - if ( test_setup_invalid == 0 ) + if (test_setup_invalid == 0) { res = OS_CountSemCreate(&count_sem_ids[OS_MAX_COUNT_SEMAPHORES], "OneTooMany", 1, 0); if (res == OS_ERR_NO_FREE_IDS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } /* Reset test environment */ @@ -170,18 +170,18 @@ void UT_os_count_sem_create_test() /* Setup */ res = OS_CountSemCreate(&count_sem_ids[0], "DUPLICATE", 1, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#6 Duplicate-name - Count Sem Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); } else { res = OS_CountSemCreate(&count_sem_ids[1], "DUPLICATE", 1, 0); if (res == OS_ERR_NAME_TAKEN) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_CountSemDelete(count_sem_ids[0]); @@ -191,23 +191,22 @@ void UT_os_count_sem_create_test() /*-----------------------------------------------------*/ testDesc = "#7 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#8 Nominal"; res = OS_CountSemCreate(&count_sem_ids[0], "Good", 1, 0); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_SUCCESS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ res = OS_CountSemDelete(count_sem_ids[0]); UT_os_count_sem_create_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -220,9 +219,9 @@ void UT_os_count_sem_create_test() **--------------------------------------------------------------------------------*/ void UT_os_count_sem_delete_test() { - int32 res = 0; - const char* testDesc; - osal_id_t count_sem_id; + int32 res = 0; + const char *testDesc; + osal_id_t count_sem_id; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -230,7 +229,7 @@ void UT_os_count_sem_delete_test() res = OS_CountSemDelete(OS_OBJECT_ID_UNDEFINED); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_count_sem_delete_test_exit_tag; } @@ -238,38 +237,37 @@ void UT_os_count_sem_delete_test() testDesc = "#1 Invalid-ID-arg"; res = OS_CountSemDelete(UT_OBJID_INCORRECT); - if ( res == OS_ERR_INVALID_ID ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_ERR_INVALID_ID) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#3 Nominal"; /* Setup */ res = OS_CountSemCreate(&count_sem_id, "DeleteTest", 1, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#3 Nominal - Count Sem Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_CountSemDelete(count_sem_id); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_SUCCESS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } UT_os_count_sem_delete_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -283,9 +281,9 @@ void UT_os_count_sem_delete_test() **--------------------------------------------------------------------------------*/ void UT_os_count_sem_give_test() { - int32 res = 0; - const char* testDesc; - osal_id_t count_sem_id; + int32 res = 0; + const char *testDesc; + osal_id_t count_sem_id; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -293,7 +291,7 @@ void UT_os_count_sem_give_test() res = OS_CountSemGive(OS_OBJECT_ID_UNDEFINED); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_count_sem_give_test_exit_tag; } @@ -301,40 +299,39 @@ void UT_os_count_sem_give_test() testDesc = "#1 Invalid-ID-arg"; res = OS_CountSemGive(UT_OBJID_INCORRECT); - if ( res == OS_ERR_INVALID_ID ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_ERR_INVALID_ID) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#3 Nominal"; /* Setup */ res = OS_CountSemCreate(&count_sem_id, "GiveTest", 1, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#3 Nominal - Count Sem Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_CountSemGive(count_sem_id); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_SUCCESS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); res = OS_CountSemDelete(count_sem_id); } UT_os_count_sem_give_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -348,9 +345,9 @@ void UT_os_count_sem_give_test() **--------------------------------------------------------------------------------*/ void UT_os_count_sem_take_test() { - int32 res = 0; - const char* testDesc; - osal_id_t count_sem_id; + int32 res = 0; + const char *testDesc; + osal_id_t count_sem_id; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -358,7 +355,7 @@ void UT_os_count_sem_take_test() res = OS_CountSemTake(OS_OBJECT_ID_UNDEFINED); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_count_sem_take_test_exit_tag; } @@ -366,39 +363,38 @@ void UT_os_count_sem_take_test() testDesc = "#1 Invalid-ID-arg"; res = OS_CountSemTake(UT_OBJID_INCORRECT); - if ( res == OS_ERR_INVALID_ID ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_ERR_INVALID_ID) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#3 Nominal"; /* Setup */ res = OS_CountSemCreate(&count_sem_id, "TakeTest", 1, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#3 Nominal - Count Sem Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_CountSemTake(count_sem_id); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_SUCCESS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); res = OS_CountSemDelete(count_sem_id); } UT_os_count_sem_take_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -412,17 +408,17 @@ void UT_os_count_sem_take_test() **--------------------------------------------------------------------------------*/ void UT_os_count_sem_timed_wait_test() { - int32 res = 0; - const char* testDesc; - osal_id_t count_sem_id; + int32 res = 0; + const char *testDesc; + osal_id_t count_sem_id; /*-----------------------------------------------------*/ testDesc = "API not implemented"; - res = OS_CountSemTimedWait(OS_OBJECT_ID_UNDEFINED,1000); + res = OS_CountSemTimedWait(OS_OBJECT_ID_UNDEFINED, 1000); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_count_sem_timed_wait_test_exit_tag; } @@ -430,41 +426,41 @@ void UT_os_count_sem_timed_wait_test() testDesc = "#1 Invalid-ID-arg"; res = OS_CountSemTimedWait(UT_OBJID_INCORRECT, 1000); - if ( res == OS_ERR_INVALID_ID ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_ERR_INVALID_ID) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#3 Sem-take-timed-out"; /* Setup */ res = OS_CountSemCreate(&count_sem_id, "TimedWait", 1, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#3 Sem-take-timed-out - Count Sem Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_CountSemTake(count_sem_id); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#3 Sem-take-timed-out - Count Sem Take failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_CountSemTimedWait(count_sem_id, 1000); - if ( res == OS_SEM_TIMEOUT ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_SEM_TIMEOUT) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } res = OS_CountSemDelete(count_sem_id); } @@ -474,25 +470,24 @@ void UT_os_count_sem_timed_wait_test() /* Setup */ res = OS_CountSemCreate(&count_sem_id, "TimedWait", 1, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#4 Nominal - Count Sem Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_CountSemTimedWait(count_sem_id, 1000); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_SUCCESS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); res = OS_CountSemDelete(count_sem_id); } UT_os_count_sem_timed_wait_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -507,10 +502,10 @@ void UT_os_count_sem_timed_wait_test() **--------------------------------------------------------------------------------*/ void UT_os_count_sem_get_id_by_name_test() { - int32 res = 0; - const char* testDesc; - osal_id_t count_sem_id; - char long_sem_name[UT_OS_NAME_BUFF_SIZE]; + int32 res = 0; + const char *testDesc; + osal_id_t count_sem_id; + char long_sem_name[UT_OS_NAME_BUFF_SIZE]; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -518,7 +513,7 @@ void UT_os_count_sem_get_id_by_name_test() res = OS_CountSemGetIdByName(0, "InvalidName"); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_count_sem_get_id_by_name_test_exit_tag; } @@ -526,64 +521,63 @@ void UT_os_count_sem_get_id_by_name_test() testDesc = "#1 Invalid-pointer-arg-1"; res = OS_CountSemGetIdByName(NULL, "InvalidName"); - if ( res == OS_INVALID_POINTER ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_INVALID_POINTER) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-pointer-arg-2"; res = OS_CountSemGetIdByName(&count_sem_id, NULL); - if ( res == OS_INVALID_POINTER ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_INVALID_POINTER) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Name-too-long"; memset(long_sem_name, 'Y', sizeof(long_sem_name)); - long_sem_name[sizeof(long_sem_name)-1] = '\0'; - res = OS_CountSemGetIdByName(&count_sem_id, long_sem_name); - if ( res == OS_ERR_NAME_TOO_LONG ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + long_sem_name[sizeof(long_sem_name) - 1] = '\0'; + res = OS_CountSemGetIdByName(&count_sem_id, long_sem_name); + if (res == OS_ERR_NAME_TOO_LONG) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 Name-not-found"; res = OS_CountSemGetIdByName(&count_sem_id, "NameNotFound"); - if ( res == OS_ERR_NAME_NOT_FOUND ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_ERR_NAME_NOT_FOUND) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#5 Nominal"; /* Setup */ res = OS_CountSemCreate(&count_sem_id, "GetIDByName", 1, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#5 Nominal - Count Sem Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_CountSemGetIdByName(&count_sem_id, "GetIDByName"); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_SUCCESS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); res = OS_CountSemDelete(count_sem_id); } UT_os_count_sem_get_id_by_name_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -596,18 +590,18 @@ void UT_os_count_sem_get_id_by_name_test() **--------------------------------------------------------------------------------*/ void UT_os_count_sem_get_info_test() { - int32 res = 0; - const char* testDesc; - osal_id_t count_sem_id; - OS_count_sem_prop_t count_sem_prop; + int32 res = 0; + const char * testDesc; + osal_id_t count_sem_id; + OS_count_sem_prop_t count_sem_prop; /*-----------------------------------------------------*/ testDesc = "API not implemented"; - res = OS_CountSemGetInfo(OS_OBJECT_ID_UNDEFINED,&count_sem_prop); + res = OS_CountSemGetInfo(OS_OBJECT_ID_UNDEFINED, &count_sem_prop); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_count_sem_get_info_test_exit_tag; } @@ -615,28 +609,28 @@ void UT_os_count_sem_get_info_test() testDesc = "#1 Invalid-ID-arg"; res = OS_CountSemGetInfo(UT_OBJID_INCORRECT, &count_sem_prop); - if ( res == OS_ERR_INVALID_ID ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_ERR_INVALID_ID) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-pointer-arg"; /* Setup */ res = OS_CountSemCreate(&count_sem_id, "GetInfo", 1, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#2 Invalid-pointer-arg - Count Sem Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_CountSemGetInfo(count_sem_id, NULL); - if ( res == OS_INVALID_POINTER ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_INVALID_POINTER) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); res = OS_CountSemDelete(count_sem_id); } @@ -646,25 +640,24 @@ void UT_os_count_sem_get_info_test() /* Setup */ res = OS_CountSemCreate(&count_sem_id, "GetInfo", 1, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#3 Nominal - Count Sem Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_CountSemGetInfo(count_sem_id, &count_sem_prop); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_SUCCESS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); res = OS_CountSemDelete(count_sem_id); } UT_os_count_sem_get_info_test_exit_tag: return; - } /*================================================================================* diff --git a/src/unit-tests/oscore-test/ut_oscore_countsem_test.h b/src/unit-tests/oscore-test/ut_oscore_countsem_test.h index 562e4ed1f..3e011f7b2 100644 --- a/src/unit-tests/oscore-test/ut_oscore_countsem_test.h +++ b/src/unit-tests/oscore-test/ut_oscore_countsem_test.h @@ -63,7 +63,7 @@ void UT_os_count_sem_get_info_test(void); /*--------------------------------------------------------------------------------*/ -#endif /* _UT_OSCORE_COUNTSEM_TEST_H_ */ +#endif /* _UT_OSCORE_COUNTSEM_TEST_H_ */ /*================================================================================* ** End of File: ut_oscore_countsem_test.h diff --git a/src/unit-tests/oscore-test/ut_oscore_misc_test.c b/src/unit-tests/oscore-test/ut_oscore_misc_test.c index 233d0085c..07b066140 100644 --- a/src/unit-tests/oscore-test/ut_oscore_misc_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_misc_test.c @@ -88,12 +88,12 @@ *--------------------------------------------------------------------------------*/ void UT_os_apiinit_test() { - int32 res = 0; - const char* testDesc; - osal_id_t qId; - uint32 qDepth = 10, qSize = 4, qFlags = 0; - osal_id_t semIds[3]; - uint32 semInitValue = 1, semOptions = 0; + int32 res = 0; + const char *testDesc; + osal_id_t qId; + uint32 qDepth = 10, qSize = 4, qFlags = 0; + osal_id_t semIds[3]; + uint32 semInitValue = 1, semOptions = 0; /*-----------------------------------------------------*/ testDesc = "#1 Init-not-call-first"; @@ -102,9 +102,9 @@ void UT_os_apiinit_test() (OS_BinSemCreate(&semIds[0], "BinSem 1", semInitValue, semOptions) != OS_SUCCESS) && (OS_CountSemCreate(&semIds[1], "CountSem 1", semInitValue, semOptions) != OS_SUCCESS) && (OS_MutSemCreate(&semIds[2], "MutexSem 1", semOptions) != OS_SUCCESS)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_QueueDelete(qId); @@ -119,20 +119,19 @@ void UT_os_apiinit_test() if (res == OS_ERR_NOT_IMPLEMENTED) { testDesc = "API not implemented"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_apiinit_test_exit_tag; } - else if ((res == OS_SUCCESS) && - (OS_QueueCreate(&qId, "Queue A", qDepth, qSize, qFlags) == OS_SUCCESS) && + else if ((res == OS_SUCCESS) && (OS_QueueCreate(&qId, "Queue A", qDepth, qSize, qFlags) == OS_SUCCESS) && (OS_BinSemCreate(&semIds[0], "BinSem 1", semInitValue, semOptions) == OS_SUCCESS) && (OS_CountSemCreate(&semIds[1], "CountSem 1", semInitValue, semOptions) == OS_SUCCESS) && (OS_MutSemCreate(&semIds[2], "MutexSem 1", semOptions) == OS_SUCCESS)) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); } else { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } /* Reset test environment */ @@ -143,7 +142,6 @@ void UT_os_apiinit_test() UT_os_apiinit_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -164,8 +162,7 @@ void UT_os_printf_test() UT_OS_LOG("OS_printf() - #1 Nominal [This is the expected stdout output after API call]\n"); OS_printf("OS_printf() - #1 Nominal [ This is the expected stdout output after API call]\n"); - UT_OS_TEST_RESULT( "#1 Nominal - Manual inspection required", UTASSERT_CASETYPE_MIR); - + UT_OS_TEST_RESULT("#1 Nominal - Manual inspection required", UTASSERT_CASETYPE_MIR); } /*--------------------------------------------------------------------------------* @@ -188,8 +185,7 @@ void UT_os_printfenable_test() UT_OS_LOG("OS_printf_enable() - #1 Nominal [This is the expected stdout output after API call]\n"); OS_printf("OS_printf_enable() - #1 Nominal [This is the expected stdout output after API call]\n"); - UT_OS_TEST_RESULT( "#1 Nominal - Manual inspection required", UTASSERT_CASETYPE_MIR); - + UT_OS_TEST_RESULT("#1 Nominal - Manual inspection required", UTASSERT_CASETYPE_MIR); } /*--------------------------------------------------------------------------------* @@ -214,13 +210,12 @@ void UT_os_printfdisable_test() UT_OS_LOG("OS_printf_disable() - #1 Nominal [This is NOT the expected stdout output after API call]\n"); OS_printf("OS_printf_disable() - #1 Nominal [This is NOT the expected stdout output after API call]\n"); - UT_OS_TEST_RESULT( "#1 Nominal - Manual inspection required", UTASSERT_CASETYPE_MIR); + UT_OS_TEST_RESULT("#1 Nominal - Manual inspection required", UTASSERT_CASETYPE_MIR); /* Reset test environment */ OS_printf_enable(); UT_OS_LOG("OS_printf_disable() - #1 Nominal [This is the expected stdout output after test reset]\n"); OS_printf("OS_printf_disable() - #1 Nominal [This is the expected stdout output after test reset]\n"); - } /*--------------------------------------------------------------------------------* @@ -256,9 +251,9 @@ void UT_os_printfdisable_test() **--------------------------------------------------------------------------------*/ void UT_os_getlocaltime_test() { - OS_time_t time_struct; - const char* testDesc; - int32 res = 0, i = 0; + OS_time_t time_struct; + const char *testDesc; + int32 res = 0, i = 0; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -266,22 +261,22 @@ void UT_os_getlocaltime_test() res = OS_GetLocalTime(NULL); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_getlocaltime_test_exit_tag; } /*-----------------------------------------------------*/ testDesc = "#1 Null-pointer-arg"; - res = OS_GetLocalTime(NULL); + res = OS_GetLocalTime(NULL); if (res == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#3 Nominal"; @@ -289,28 +284,27 @@ void UT_os_getlocaltime_test() res = OS_GetLocalTime(&time_struct); if (res == OS_SUCCESS) { - UT_OS_LOG("\n"); - for (i=0; i < 5; i++) + UT_OS_LOG("\n"); + for (i = 0; i < 5; i++) { UT_OS_LOG("OS_GetLocalTime() - #3 Nominal "); - UT_OS_LOG("[Expecting output after API call to increase over time: %ld.%ld]\n", - (long)time_struct.seconds, (long)time_struct.microsecs); + UT_OS_LOG("[Expecting output after API call to increase over time: %ld.%ld]\n", (long)time_struct.seconds, + (long)time_struct.microsecs); OS_TaskDelay(20); OS_GetLocalTime(&time_struct); } testDesc = "#3 Nominal - Manual inspection required"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_MIR); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_MIR); } else { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } UT_os_getlocaltime_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -346,9 +340,9 @@ void UT_os_getlocaltime_test() **--------------------------------------------------------------------------------*/ void UT_os_setlocaltime_test() { - OS_time_t time_struct; - const char* testDesc; - int32 res = 0, i = 0; + OS_time_t time_struct; + const char *testDesc; + int32 res = 0, i = 0; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -356,7 +350,7 @@ void UT_os_setlocaltime_test() res = OS_SetLocalTime(NULL); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_setlocaltime_test_exit_tag; } @@ -365,14 +359,14 @@ void UT_os_setlocaltime_test() res = OS_GetLocalTime(NULL); if (res == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#3 Nominal"; @@ -380,11 +374,11 @@ void UT_os_setlocaltime_test() res = OS_GetLocalTime(&time_struct); if (res == OS_SUCCESS) { - for (i=0; i < 5; i++) + for (i = 0; i < 5; i++) { UT_OS_LOG("OS_SetLocalTime() - #3 Nominal "); - UT_OS_LOG("[Expecting output before API call to increase over time: %ld.%ld]\n", - (long)time_struct.seconds, (long)time_struct.microsecs); + UT_OS_LOG("[Expecting output before API call to increase over time: %ld.%ld]\n", (long)time_struct.seconds, + (long)time_struct.microsecs); OS_TaskDelay(20); OS_GetLocalTime(&time_struct); @@ -392,23 +386,23 @@ void UT_os_setlocaltime_test() } memset(&time_struct, 0x00, sizeof(time_struct)); - time_struct.seconds = 20000; + time_struct.seconds = 20000; time_struct.microsecs = 123; res = OS_SetLocalTime(&time_struct); if (res == OS_SUCCESS) { - UT_OS_LOG("OS_SetLocalTime() - #3 Nominal [New time set at %ld.%ld]\n", - (long)time_struct.seconds, (long)time_struct.microsecs); + UT_OS_LOG("OS_SetLocalTime() - #3 Nominal [New time set at %ld.%ld]\n", (long)time_struct.seconds, + (long)time_struct.microsecs); res = OS_GetLocalTime(&time_struct); if (res == OS_SUCCESS) { - for (i=0; i < 5; i++) + for (i = 0; i < 5; i++) { UT_OS_LOG("OS_SetLocalTime() - #3 Nominal "); - UT_OS_LOG("[Expecting output after API call to increase over time: %ld.%ld]\n", - (long)time_struct.seconds, (long)time_struct.microsecs); + UT_OS_LOG("[Expecting output after API call to increase over time: %ld.%ld]\n", + (long)time_struct.seconds, (long)time_struct.microsecs); OS_TaskDelay(20); OS_GetLocalTime(&time_struct); @@ -416,17 +410,16 @@ void UT_os_setlocaltime_test() } testDesc = "#3 Nominal - Manual inspection required"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_MIR); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_MIR); } else { /* Most likely it is a permission issue - no way to fix - but OK to ignore this failure */ - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); } UT_os_setlocaltime_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -455,9 +448,9 @@ void UT_os_setlocaltime_test() **--------------------------------------------------------------------------------*/ void UT_os_geterrorname_test(void) { - int32 res = 0; + int32 res = 0; os_err_name_t errNames[4]; - const char* testDesc; + const char * testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -465,7 +458,7 @@ void UT_os_geterrorname_test(void) res = OS_GetErrorName(OS_SUCCESS, &errNames[0]); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_geterrorname_test_exit_tag; } @@ -474,17 +467,17 @@ void UT_os_geterrorname_test(void) res = OS_GetErrorName(OS_ERROR, NULL); if (res == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Undefined Error"; if (OS_GetErrorName(12345, &errNames[0]) == OS_ERROR) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Nominal"; @@ -495,13 +488,12 @@ void UT_os_geterrorname_test(void) (strcmp(errNames[1], "OS_ERR_NAME_TAKEN") == 0) && (OS_GetErrorName(OS_ERR_NO_FREE_IDS, &errNames[2]) == OS_SUCCESS) && (strcmp(errNames[2], "OS_ERR_NO_FREE_IDS") == 0)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); UT_os_geterrorname_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -536,9 +528,9 @@ void UT_os_geterrorname_test(void) **--------------------------------------------------------------------------------*/ void UT_os_heapgetinfo_test(void) { - int32 res = 0; + int32 res = 0; OS_heap_prop_t heapProp; - const char* testDesc; + const char * testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -546,7 +538,7 @@ void UT_os_heapgetinfo_test(void) res = OS_HeapGetInfo(&heapProp); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_heapgetinfo_test_exit_tag; } @@ -555,27 +547,26 @@ void UT_os_heapgetinfo_test(void) res = OS_HeapGetInfo(NULL); if (res == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#3 Nominal"; res = OS_HeapGetInfo(&heapProp); if (res == OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); UT_os_heapgetinfo_test_exit_tag: return; - } /*================================================================================* diff --git a/src/unit-tests/oscore-test/ut_oscore_misc_test.h b/src/unit-tests/oscore-test/ut_oscore_misc_test.h index cb174697e..1510f5c42 100644 --- a/src/unit-tests/oscore-test/ut_oscore_misc_test.h +++ b/src/unit-tests/oscore-test/ut_oscore_misc_test.h @@ -68,7 +68,7 @@ void UT_os_heapgetinfo_test(void); /*--------------------------------------------------------------------------------*/ -#endif /* _UT_OSCORE_MISC_TEST_H_ */ +#endif /* _UT_OSCORE_MISC_TEST_H_ */ /*================================================================================* ** End of File: ut_oscore_misc_test.h diff --git a/src/unit-tests/oscore-test/ut_oscore_mutex_test.c b/src/unit-tests/oscore-test/ut_oscore_mutex_test.c index 23ebeeb9d..4781db0f9 100644 --- a/src/unit-tests/oscore-test/ut_oscore_mutex_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_mutex_test.c @@ -67,22 +67,22 @@ **--------------------------------------------------------------------------------*/ void UT_os_mut_sem_create_test() { - int i; - int32 res = 0; - const char* testDesc; - osal_id_t mut_sem_id; - osal_id_t mut_sem_id2; - char sem_name[UT_OS_NAME_BUFF_SIZE]; - char long_sem_name[UT_OS_NAME_BUFF_SIZE]; - uint32 test_setup_invalid = 0; + int i; + int32 res = 0; + const char *testDesc; + osal_id_t mut_sem_id; + osal_id_t mut_sem_id2; + char sem_name[UT_OS_NAME_BUFF_SIZE]; + char long_sem_name[UT_OS_NAME_BUFF_SIZE]; + uint32 test_setup_invalid = 0; /*-----------------------------------------------------*/ testDesc = "API not implemented"; - res = OS_MutSemCreate(&mut_sem_id, "Good", 0 ); + res = OS_MutSemCreate(&mut_sem_id, "Good", 0); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_mut_sem_create_test_exit_tag; } @@ -94,55 +94,55 @@ void UT_os_mut_sem_create_test() res = OS_MutSemCreate(NULL, "MutSem1", 0); if (res == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Null-pointer-arg-2"; res = OS_MutSemCreate(&mut_sem_id, NULL, 0); if (res == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Name-too-long"; memset(long_sem_name, 'X', sizeof(long_sem_name)); - long_sem_name[sizeof(long_sem_name)-1] = '\0'; - res = OS_MutSemCreate(&mut_sem_id, long_sem_name, 0); + long_sem_name[sizeof(long_sem_name) - 1] = '\0'; + res = OS_MutSemCreate(&mut_sem_id, long_sem_name, 0); if (res == OS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 No-free-IDs"; /* Setup */ - for ( i = 0; i< OS_MAX_MUTEXES; i++ ) + for (i = 0; i < OS_MAX_MUTEXES; i++) { memset(sem_name, '\0', sizeof(sem_name)); - UT_os_sprintf(sem_name, "MUTSEM%d",i); + UT_os_sprintf(sem_name, "MUTSEM%d", i); res = OS_MutSemCreate(&mut_sem_id, sem_name, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#4 No-free-IDs - Mutex Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); test_setup_invalid = 1; break; } } - if ( test_setup_invalid == 0 ) + if (test_setup_invalid == 0) { res = OS_MutSemCreate(&mut_sem_id, "OneTooMany", 0); if (res == OS_ERR_NO_FREE_IDS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } /* Reset test environment */ @@ -152,19 +152,19 @@ void UT_os_mut_sem_create_test() testDesc = "#5 Duplicate-name"; /* Setup */ - res = OS_MutSemCreate(&mut_sem_id2, "DUPLICATE", 0); - if ( res != OS_SUCCESS ) + res = OS_MutSemCreate(&mut_sem_id2, "DUPLICATE", 0); + if (res != OS_SUCCESS) { testDesc = "#5 Duplicate-name - Mutex Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_MutSemCreate(&mut_sem_id, "DUPLICATE", 0); if (res == OS_ERR_NAME_TAKEN) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ res = OS_MutSemDelete(mut_sem_id2); @@ -173,23 +173,22 @@ void UT_os_mut_sem_create_test() /*-----------------------------------------------------*/ testDesc = "#6 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#7 Nominal"; res = OS_MutSemCreate(&mut_sem_id, "Good", 0); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_SUCCESS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ res = OS_MutSemDelete(mut_sem_id); UT_os_mut_sem_create_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -203,9 +202,9 @@ void UT_os_mut_sem_create_test() **--------------------------------------------------------------------------------*/ void UT_os_mut_sem_delete_test() { - int32 res = 0; - const char* testDesc; - osal_id_t mut_sem_id; + int32 res = 0; + const char *testDesc; + osal_id_t mut_sem_id; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -213,7 +212,7 @@ void UT_os_mut_sem_delete_test() res = OS_MutSemDelete(OS_OBJECT_ID_UNDEFINED); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_mut_sem_delete_test_exit_tag; } @@ -221,38 +220,37 @@ void UT_os_mut_sem_delete_test() testDesc = "#1 Invalid-ID-arg"; res = OS_MutSemDelete(UT_OBJID_INCORRECT); - if ( res == OS_ERR_INVALID_ID ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_ERR_INVALID_ID) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#3 Nominal"; /* Setup */ res = OS_MutSemCreate(&mut_sem_id, "DeleteTest", 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#3 Nominal - Mutex Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_MutSemDelete(mut_sem_id); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_SUCCESS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } UT_os_mut_sem_delete_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -266,9 +264,9 @@ void UT_os_mut_sem_delete_test() **--------------------------------------------------------------------------------*/ void UT_os_mut_sem_give_test() { - int32 res = 0; - const char* testDesc; - osal_id_t mut_sem_id; + int32 res = 0; + const char *testDesc; + osal_id_t mut_sem_id; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -276,7 +274,7 @@ void UT_os_mut_sem_give_test() res = OS_MutSemGive(OS_OBJECT_ID_UNDEFINED); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_mut_sem_give_test_exit_tag; } @@ -284,41 +282,41 @@ void UT_os_mut_sem_give_test() testDesc = "#1 Invalid-ID-arg"; res = OS_MutSemGive(UT_OBJID_INCORRECT); - if ( res == OS_ERR_INVALID_ID ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_ERR_INVALID_ID) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#3 Nominal"; /* Setup */ res = OS_MutSemCreate(&mut_sem_id, "GiveTest", 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#3 Nominal - Mutex Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_MutSemTake(mut_sem_id); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#3 Nominal - Mutex Take failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_MutSemGive(mut_sem_id); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_SUCCESS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); res = OS_MutSemDelete(mut_sem_id); } @@ -326,7 +324,6 @@ void UT_os_mut_sem_give_test() UT_os_mut_sem_give_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -340,9 +337,9 @@ void UT_os_mut_sem_give_test() **--------------------------------------------------------------------------------*/ void UT_os_mut_sem_take_test() { - int32 res = 0; - const char* testDesc; - osal_id_t mut_sem_id; + int32 res = 0; + const char *testDesc; + osal_id_t mut_sem_id; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -350,7 +347,7 @@ void UT_os_mut_sem_take_test() res = OS_MutSemTake(OS_OBJECT_ID_UNDEFINED); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_mut_sem_take_test_exit_tag; } @@ -358,33 +355,33 @@ void UT_os_mut_sem_take_test() testDesc = "#1 Invalid-ID-arg"; res = OS_MutSemTake(UT_OBJID_INCORRECT); - if ( res == OS_ERR_INVALID_ID ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_ERR_INVALID_ID) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#3 Nominal"; /* Setup */ res = OS_MutSemCreate(&mut_sem_id, "TakeTest", 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#3 Nominal - Mutex Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_MutSemTake(mut_sem_id); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_SUCCESS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); OS_MutSemGive(mut_sem_id); OS_MutSemDelete(mut_sem_id); @@ -392,7 +389,6 @@ void UT_os_mut_sem_take_test() UT_os_mut_sem_take_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -406,18 +402,18 @@ void UT_os_mut_sem_take_test() **--------------------------------------------------------------------------------*/ void UT_os_mut_sem_get_id_by_name_test() { - int32 res = 0; - const char* testDesc; - osal_id_t mut_sem_id; + int32 res = 0; + const char *testDesc; + osal_id_t mut_sem_id; char long_sem_name[UT_OS_NAME_BUFF_SIZE]; /*-----------------------------------------------------*/ testDesc = "API not implemented"; - res = OS_MutSemGetIdByName(0,"InvalidName"); + res = OS_MutSemGetIdByName(0, "InvalidName"); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_mut_sem_get_id_by_name_test_exit_tag; } @@ -425,63 +421,62 @@ void UT_os_mut_sem_get_id_by_name_test() testDesc = "#1 Invalid-pointer-arg-1"; res = OS_MutSemGetIdByName(NULL, "InvalidName"); - if ( res == OS_INVALID_POINTER ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_INVALID_POINTER) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-pointer-arg-2"; res = OS_MutSemGetIdByName(&mut_sem_id, NULL); - if ( res == OS_INVALID_POINTER ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_INVALID_POINTER) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Name-too-long"; memset(long_sem_name, 'Y', sizeof(long_sem_name)); - long_sem_name[sizeof(long_sem_name)-1] = '\0'; - res = OS_MutSemGetIdByName(&mut_sem_id, long_sem_name); - if ( res == OS_ERR_NAME_TOO_LONG ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + long_sem_name[sizeof(long_sem_name) - 1] = '\0'; + res = OS_MutSemGetIdByName(&mut_sem_id, long_sem_name); + if (res == OS_ERR_NAME_TOO_LONG) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 Name-not-found"; res = OS_MutSemGetIdByName(&mut_sem_id, "NameNotFound"); - if ( res == OS_ERR_NAME_NOT_FOUND ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_ERR_NAME_NOT_FOUND) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#5 Nominal"; /* Setup */ res = OS_MutSemCreate(&mut_sem_id, "GetIDByName", 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#5 Nominal - Mutex Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_MutSemGetIdByName(&mut_sem_id, "GetIDByName"); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_SUCCESS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); res = OS_MutSemDelete(mut_sem_id); } UT_os_mut_sem_get_id_by_name_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -494,10 +489,10 @@ void UT_os_mut_sem_get_id_by_name_test() **--------------------------------------------------------------------------------*/ void UT_os_mut_sem_get_info_test() { - int32 res = 0; - const char* testDesc; - osal_id_t mut_sem_id; - OS_mut_sem_prop_t mut_sem_prop; + int32 res = 0; + const char * testDesc; + osal_id_t mut_sem_id; + OS_mut_sem_prop_t mut_sem_prop; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -505,7 +500,7 @@ void UT_os_mut_sem_get_info_test() res = OS_MutSemGetInfo(OS_OBJECT_ID_UNDEFINED, &mut_sem_prop); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_mut_sem_get_info_test_exit_tag; } @@ -513,10 +508,10 @@ void UT_os_mut_sem_get_info_test() testDesc = "#1 Invalid-ID-arg"; res = OS_MutSemGetInfo(UT_OBJID_INCORRECT, &mut_sem_prop); - if ( res == OS_ERR_INVALID_ID ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_ERR_INVALID_ID) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-pointer-arg"; @@ -525,17 +520,17 @@ void UT_os_mut_sem_get_info_test() if (res != OS_SUCCESS) { testDesc = "#2 Invalid-pointer-arg - Mutex Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_MutSemGetInfo(mut_sem_id, NULL); - if ( res == OS_INVALID_POINTER ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_INVALID_POINTER) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); - OS_MutSemDelete(mut_sem_id); + OS_MutSemDelete(mut_sem_id); } /*-----------------------------------------------------*/ @@ -543,25 +538,24 @@ void UT_os_mut_sem_get_info_test() /* Setup */ res = OS_MutSemCreate(&mut_sem_id, "GetInfo", 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#3 Nominal - Mutex Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_MutSemGetInfo(mut_sem_id, &mut_sem_prop); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_SUCCESS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); res = OS_MutSemDelete(mut_sem_id); } UT_os_mut_sem_get_info_test_exit_tag: return; - } /*================================================================================* diff --git a/src/unit-tests/oscore-test/ut_oscore_mutex_test.h b/src/unit-tests/oscore-test/ut_oscore_mutex_test.h index abc905afe..6c0b30b1a 100644 --- a/src/unit-tests/oscore-test/ut_oscore_mutex_test.h +++ b/src/unit-tests/oscore-test/ut_oscore_mutex_test.h @@ -62,7 +62,7 @@ void UT_os_mut_sem_get_info_test(void); /*--------------------------------------------------------------------------------*/ -#endif /* _UT_OSCORE_MUTEX_TEST_H_ */ +#endif /* _UT_OSCORE_MUTEX_TEST_H_ */ /*================================================================================* ** End of File: ut_oscore_mutex_test.h diff --git a/src/unit-tests/oscore-test/ut_oscore_queue_test.c b/src/unit-tests/oscore-test/ut_oscore_queue_test.c index 2d29d1a52..d47dc6629 100644 --- a/src/unit-tests/oscore-test/ut_oscore_queue_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_queue_test.c @@ -71,14 +71,14 @@ **--------------------------------------------------------------------------------*/ void UT_os_queue_create_test() { - int i = 0; - int32 res = 0; - const char* testDesc; - osal_id_t queue_id; - osal_id_t queue_id2; - char queue_name[UT_OS_NAME_BUFF_SIZE]; - char long_queue_name[UT_OS_NAME_BUFF_SIZE]; - uint32 test_setup_invalid = 0; + int i = 0; + int32 res = 0; + const char *testDesc; + osal_id_t queue_id; + osal_id_t queue_id2; + char queue_name[UT_OS_NAME_BUFF_SIZE]; + char long_queue_name[UT_OS_NAME_BUFF_SIZE]; + uint32 test_setup_invalid = 0; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -86,7 +86,7 @@ void UT_os_queue_create_test() res = OS_QueueCreate(&queue_id, "Good", 10, 4, 0); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_queue_create_test_exit_tag; } /* Clean up */ @@ -97,55 +97,55 @@ void UT_os_queue_create_test() res = OS_QueueCreate(NULL, "Queue1", 10, 4, 0); if (res == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Null-pointer-arg-2"; res = OS_QueueCreate(&queue_id, NULL, 10, 4, 0); if (res == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Name-too-long"; memset(long_queue_name, 'X', sizeof(long_queue_name)); - long_queue_name[sizeof(long_queue_name)-1] = '\0'; - res = OS_QueueCreate(&queue_id, long_queue_name, 10, 4, 0); + long_queue_name[sizeof(long_queue_name) - 1] = '\0'; + res = OS_QueueCreate(&queue_id, long_queue_name, 10, 4, 0); if (res == OS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 No-free-IDs"; /* Setup */ - for ( i = 0; i< OS_MAX_QUEUES; i++ ) + for (i = 0; i < OS_MAX_QUEUES; i++) { memset(queue_name, '\0', sizeof(queue_name)); - UT_os_sprintf(queue_name, "QUEUE%d",i); + UT_os_sprintf(queue_name, "QUEUE%d", i); res = OS_QueueCreate(&queue_id, queue_name, 2, 4, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#4 No-free-IDs - Queue Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); test_setup_invalid = 1; break; } } - if ( test_setup_invalid == 0 ) + if (test_setup_invalid == 0) { res = OS_QueueCreate(&queue_id, "OneTooMany", 10, 4, 0); if (res == OS_ERR_NO_FREE_IDS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } /* Reset test environment */ @@ -156,17 +156,17 @@ void UT_os_queue_create_test() /* Setup */ res = OS_QueueCreate(&queue_id2, "DUPLICATE", 10, 4, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { - UT_OS_TEST_RESULT( "Queue Create failed", UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT("Queue Create failed", UTASSERT_CASETYPE_TSF); } else { res = OS_QueueCreate(&queue_id, "DUPLICATE", 10, 4, 0); if (res == OS_ERR_NAME_TAKEN) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ res = OS_QueueDelete(queue_id2); @@ -175,23 +175,22 @@ void UT_os_queue_create_test() /*-----------------------------------------------------*/ testDesc = "#6 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#7 Nominal"; res = OS_QueueCreate(&queue_id, "Good", 10, 4, 0); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_SUCCESS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ res = OS_QueueDelete(queue_id); UT_os_queue_create_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -204,9 +203,9 @@ void UT_os_queue_create_test() **--------------------------------------------------------------------------------*/ void UT_os_queue_delete_test() { - int32 res = 0; - const char* testDesc; - osal_id_t queue_id; + int32 res = 0; + const char *testDesc; + osal_id_t queue_id; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -214,7 +213,7 @@ void UT_os_queue_delete_test() res = OS_QueueDelete(OS_OBJECT_ID_UNDEFINED); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_queue_delete_test_exit_tag; } @@ -222,38 +221,37 @@ void UT_os_queue_delete_test() testDesc = "#1 Invalid-ID-arg"; res = OS_QueueDelete(UT_OBJID_INCORRECT); - if ( res == OS_ERR_INVALID_ID ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_ERR_INVALID_ID) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#3 Nominal"; /* Setup */ res = OS_QueueCreate(&queue_id, "DeleteTest", 10, 4, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#3 Nominal - Queue Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_QueueDelete(queue_id); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_SUCCESS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } UT_os_queue_delete_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -269,13 +267,13 @@ void UT_os_queue_delete_test() **--------------------------------------------------------------------------------*/ void UT_os_queue_get_test() { - int32 res = 0; - const char* testDesc; - osal_id_t queue_id; - uint32 queue_data_out; - uint32 queue_data_in; - uint32 size_copied; - uint32 data_size; + int32 res = 0; + const char *testDesc; + osal_id_t queue_id; + uint32 queue_data_out; + uint32 queue_data_in; + uint32 size_copied; + uint32 data_size; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -283,7 +281,7 @@ void UT_os_queue_get_test() res = OS_QueueGet(OS_OBJECT_ID_UNDEFINED, (void *)&queue_data_in, 4, &size_copied, OS_CHECK); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_queue_get_test_exit_tag; } @@ -291,28 +289,28 @@ void UT_os_queue_get_test() testDesc = "#1 Invalid-ID-arg"; res = OS_QueueGet(UT_OBJID_INCORRECT, (void *)&queue_data_in, 4, &size_copied, OS_CHECK); - if ( res == OS_ERR_INVALID_ID ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_ERR_INVALID_ID) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-pointer-arg-1"; /* Setup */ res = OS_QueueCreate(&queue_id, "QueueGet", 10, 4, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#2 Invalid-pointer-arg-1 - Queue Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_QueueGet(queue_id, NULL, 4, &size_copied, OS_CHECK); - if ( res == OS_INVALID_POINTER ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_INVALID_POINTER) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); res = OS_QueueDelete(queue_id); } @@ -322,20 +320,20 @@ void UT_os_queue_get_test() /* Setup */ res = OS_QueueCreate(&queue_id, "QueueGet", 10, 4, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#3 Invalid-pointer-arg-2 - Queue Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_QueueGet(queue_id, (void *)&queue_data_in, 4, NULL, OS_CHECK); - if ( res == OS_INVALID_POINTER ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_INVALID_POINTER) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); - res = OS_QueueDelete(queue_id); + res = OS_QueueDelete(queue_id); } /*-----------------------------------------------------*/ @@ -343,18 +341,18 @@ void UT_os_queue_get_test() /* Setup */ res = OS_QueueCreate(&queue_id, "QueueEmpty", 10, 4, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#4 Queue-empty - Queue Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_QueueGet(queue_id, (void *)&queue_data_in, 4, &data_size, OS_CHECK); - if ( res == OS_QUEUE_EMPTY ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_QUEUE_EMPTY) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); res = OS_QueueDelete(queue_id); } @@ -364,18 +362,18 @@ void UT_os_queue_get_test() /* Setup */ res = OS_QueueCreate(&queue_id, "QueueTimeout", 10, 4, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#5 Queue-timed-out - Queue Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_QueueGet(queue_id, (void *)&queue_data_in, 4, &data_size, 2); - if ( res == OS_QUEUE_TIMEOUT ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_QUEUE_TIMEOUT) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); res = OS_QueueDelete(queue_id); } @@ -385,27 +383,27 @@ void UT_os_queue_get_test() /* Setup */ res = OS_QueueCreate(&queue_id, "QueuePut", 10, 4, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#6 Invalid-queue-size - Queue Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { queue_data_out = 0x11223344; - res = OS_QueuePut(queue_id, (void *)&queue_data_out, 2, 0); - if ( res != OS_SUCCESS ) + res = OS_QueuePut(queue_id, (void *)&queue_data_out, 2, 0); + if (res != OS_SUCCESS) { testDesc = "#6 Invalid-queue-size - Queue Put failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_QueueGet(queue_id, (void *)&queue_data_in, 3, &data_size, OS_CHECK); - if ( res == OS_QUEUE_INVALID_SIZE ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_QUEUE_INVALID_SIZE) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } res = OS_QueueDelete(queue_id); } @@ -413,34 +411,34 @@ void UT_os_queue_get_test() /*-----------------------------------------------------*/ testDesc = "#7 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#8 Nominal Pend"; /* Setup */ res = OS_QueueCreate(&queue_id, "QueueGet", 10, 4, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#8 Nominal Pend - Queue Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { queue_data_out = 0x11223344; - res = OS_QueuePut(queue_id, (void *)&queue_data_out, 4, 0); - if ( res != OS_SUCCESS ) + res = OS_QueuePut(queue_id, (void *)&queue_data_out, 4, 0); + if (res != OS_SUCCESS) { testDesc = "#8 Nominal Pend - Queue Put failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_QueueGet(queue_id, (void *)&queue_data_in, 4, &data_size, OS_PEND); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_SUCCESS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } res = OS_QueueDelete(queue_id); } @@ -450,27 +448,27 @@ void UT_os_queue_get_test() /* Setup */ res = OS_QueueCreate(&queue_id, "QueueGet", 10, 4, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#9 Nominal timeout - Queue Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { queue_data_out = 0x11223344; - res = OS_QueuePut(queue_id, (void *)&queue_data_out, 4, 0); - if ( res != OS_SUCCESS ) + res = OS_QueuePut(queue_id, (void *)&queue_data_out, 4, 0); + if (res != OS_SUCCESS) { testDesc = "#9 Nominal timeout - Queue Put failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_QueueGet(queue_id, (void *)&queue_data_in, 4, &data_size, 20); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_SUCCESS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } res = OS_QueueDelete(queue_id); } @@ -480,34 +478,33 @@ void UT_os_queue_get_test() /* Setup */ res = OS_QueueCreate(&queue_id, "QueueGet", 10, 4, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#10 Nominal check - Queue Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { queue_data_out = 0x11223344; - res = OS_QueuePut(queue_id, (void *)&queue_data_out, 4, 0); - if ( res != OS_SUCCESS ) + res = OS_QueuePut(queue_id, (void *)&queue_data_out, 4, 0); + if (res != OS_SUCCESS) { testDesc = "#10 Nominal check - Queue Put failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_QueueGet(queue_id, (void *)&queue_data_in, 4, &data_size, OS_CHECK); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_SUCCESS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } res = OS_QueueDelete(queue_id); } UT_os_queue_get_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -522,11 +519,11 @@ void UT_os_queue_get_test() **--------------------------------------------------------------------------------*/ void UT_os_queue_put_test() { - int32 res = 0; - const char* testDesc; - osal_id_t queue_id; - uint32 queue_data_out = 0; - int i; + int32 res = 0; + const char *testDesc; + osal_id_t queue_id; + uint32 queue_data_out = 0; + int i; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -534,7 +531,7 @@ void UT_os_queue_put_test() res = OS_QueuePut(OS_OBJECT_ID_UNDEFINED, (void *)&queue_data_out, 4, 0); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_queue_put_test_exit_tag; } @@ -542,60 +539,60 @@ void UT_os_queue_put_test() testDesc = "#1 Invalid-ID-arg"; res = OS_QueuePut(UT_OBJID_INCORRECT, (void *)&queue_data_out, 4, 0); - if ( res == OS_ERR_INVALID_ID ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_ERR_INVALID_ID) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-pointer-arg"; /* Setup */ res = OS_QueueCreate(&queue_id, "QueuePut", 10, 4, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#2 Invalid-pointer-arg - Queue Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_QueuePut(queue_id, NULL, 4, 0); - if ( res == OS_INVALID_POINTER ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_INVALID_POINTER) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); res = OS_QueueDelete(queue_id); } /*-----------------------------------------------------*/ testDesc = "#3 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#4 Queue-full"; /* Setup */ res = OS_QueueCreate(&queue_id, "QueuePut", 10, 4, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#4 Queue-full - Queue Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { queue_data_out = 0x11223344; - for ( i = 0; i < 100; i++ ) + for (i = 0; i < 100; i++) { res = OS_QueuePut(queue_id, (void *)&queue_data_out, 4, 0); - if ( res == OS_QUEUE_FULL ) + if (res == OS_QUEUE_FULL) break; } - if ( res == OS_QUEUE_FULL ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_QUEUE_FULL) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); res = OS_QueueDelete(queue_id); } @@ -605,25 +602,24 @@ void UT_os_queue_put_test() /* Setup */ res = OS_QueueCreate(&queue_id, "QueueGet", 10, 4, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#5 Nominal - Queue Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { queue_data_out = 0x11223344; - res = OS_QueuePut(queue_id, (void *)&queue_data_out, 4, 0); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + res = OS_QueuePut(queue_id, (void *)&queue_data_out, 4, 0); + if (res == OS_SUCCESS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); res = OS_QueueDelete(queue_id); } UT_os_queue_put_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -637,10 +633,10 @@ void UT_os_queue_put_test() **--------------------------------------------------------------------------------*/ void UT_os_queue_get_id_by_name_test() { - int32 res = 0; - const char* testDesc; - osal_id_t queue_id; - char long_queue_name[UT_OS_NAME_BUFF_SIZE]; + int32 res = 0; + const char *testDesc; + osal_id_t queue_id; + char long_queue_name[UT_OS_NAME_BUFF_SIZE]; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -648,7 +644,7 @@ void UT_os_queue_get_id_by_name_test() res = OS_QueueGetIdByName(0, "InvalidName"); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_queue_get_id_by_name_test_exit_tag; } @@ -656,64 +652,63 @@ void UT_os_queue_get_id_by_name_test() testDesc = "#1 Invalid-pointer-arg-1"; res = OS_QueueGetIdByName(NULL, "InvalidName"); - if ( res == OS_INVALID_POINTER ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_INVALID_POINTER) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-pointer-arg-2"; res = OS_QueueGetIdByName(&queue_id, NULL); - if ( res == OS_INVALID_POINTER ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_INVALID_POINTER) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Name-too-long"; memset(long_queue_name, 'Y', sizeof(long_queue_name)); - long_queue_name[sizeof(long_queue_name)-1] = '\0'; - res = OS_QueueGetIdByName(&queue_id, long_queue_name); - if ( res == OS_ERR_NAME_TOO_LONG ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + long_queue_name[sizeof(long_queue_name) - 1] = '\0'; + res = OS_QueueGetIdByName(&queue_id, long_queue_name); + if (res == OS_ERR_NAME_TOO_LONG) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 Name-not-found"; res = OS_QueueGetIdByName(&queue_id, "NameNotFound"); - if ( res == OS_ERR_NAME_NOT_FOUND ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_ERR_NAME_NOT_FOUND) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#5 Nominal"; /* Setup */ res = OS_QueueCreate(&queue_id, "GetIDByName", 10, 4, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#5 Nominal - Queue Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_QueueGetIdByName(&queue_id, "GetIDByName"); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_SUCCESS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); res = OS_QueueDelete(queue_id); } UT_os_queue_get_id_by_name_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -726,18 +721,18 @@ void UT_os_queue_get_id_by_name_test() **--------------------------------------------------------------------------------*/ void UT_os_queue_get_info_test() { - int32 res = 0; - const char* testDesc; - osal_id_t queue_id; - OS_queue_prop_t queue_prop; + int32 res = 0; + const char * testDesc; + osal_id_t queue_id; + OS_queue_prop_t queue_prop; /*-----------------------------------------------------*/ testDesc = "API not implemented"; - res = OS_QueueGetInfo(OS_OBJECT_ID_UNDEFINED,&queue_prop); + res = OS_QueueGetInfo(OS_OBJECT_ID_UNDEFINED, &queue_prop); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_queue_get_info_test_exit_tag; } @@ -745,28 +740,28 @@ void UT_os_queue_get_info_test() testDesc = "#1 Invalid-ID-arg"; res = OS_QueueGetInfo(UT_OBJID_INCORRECT, &queue_prop); - if ( res == OS_ERR_INVALID_ID ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_ERR_INVALID_ID) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-pointer-arg"; /* Setup */ res = OS_QueueCreate(&queue_id, "GetInfo", 10, 4, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#2 Invalid-pointer-arg - Queue Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_QueueGetInfo(queue_id, NULL); - if ( res == OS_INVALID_POINTER ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_INVALID_POINTER) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); res = OS_QueueDelete(queue_id); } @@ -776,25 +771,24 @@ void UT_os_queue_get_info_test() /* Setup */ res = OS_QueueCreate(&queue_id, "GetInfo", 10, 4, 0); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#3 Nominal - Queue Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_QueueGetInfo(queue_id, &queue_prop); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_SUCCESS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); res = OS_QueueDelete(queue_id); } UT_os_queue_get_info_test_exit_tag: return; - } /*================================================================================* diff --git a/src/unit-tests/oscore-test/ut_oscore_queue_test.h b/src/unit-tests/oscore-test/ut_oscore_queue_test.h index 21b2aa73f..ab8305cbf 100644 --- a/src/unit-tests/oscore-test/ut_oscore_queue_test.h +++ b/src/unit-tests/oscore-test/ut_oscore_queue_test.h @@ -62,7 +62,7 @@ void UT_os_queue_get_info_test(void); /*--------------------------------------------------------------------------------*/ -#endif /* _UT_OSCORE_QUEUE_TEST_H_ */ +#endif /* _UT_OSCORE_QUEUE_TEST_H_ */ /*================================================================================* ** End of File: ut_oscore_queue_test.h diff --git a/src/unit-tests/oscore-test/ut_oscore_select_test.c b/src/unit-tests/oscore-test/ut_oscore_select_test.c index 9bff0ec39..567fc9fbc 100644 --- a/src/unit-tests/oscore-test/ut_oscore_select_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_select_test.c @@ -60,7 +60,7 @@ ** Local function definitions **--------------------------------------------------------------------------------*/ -char *fsAddrPtr = NULL; +char * fsAddrPtr = NULL; static osal_id_t setup_file(void) { osal_id_t id; @@ -87,12 +87,11 @@ static void teardown_file(osal_id_t fd) **--------------------------------------------------------------------------------*/ void UT_os_select_fd_test(void) { - OS_FdSet FdSet; + OS_FdSet FdSet; osal_id_t fd = setup_file(); - if(OS_SelectFdZero(&FdSet) == OS_ERR_NOT_IMPLEMENTED - || OS_SelectFdAdd(&FdSet, fd) == OS_ERR_NOT_IMPLEMENTED - || OS_SelectFdClear(&FdSet, fd) == OS_ERR_NOT_IMPLEMENTED) + if (OS_SelectFdZero(&FdSet) == OS_ERR_NOT_IMPLEMENTED || OS_SelectFdAdd(&FdSet, fd) == OS_ERR_NOT_IMPLEMENTED || + OS_SelectFdClear(&FdSet, fd) == OS_ERR_NOT_IMPLEMENTED) { UtAssertEx(false, UTASSERT_CASETYPE_NA, __FILE__, __LINE__, "OS_SelectFd...() not implemented"); goto UT_os_select_fd_test_exit_tag; @@ -125,27 +124,29 @@ void UT_os_select_fd_test(void) **--------------------------------------------------------------------------------*/ void UT_os_select_single_test(void) { - uint32 StateFlags; + uint32 StateFlags; osal_id_t fd = setup_file(); - int32 rc; + int32 rc; UT_RETVAL(OS_SelectSingle(fd, NULL, 0), OS_INVALID_POINTER, "NULL flags pointer"); StateFlags = OS_STREAM_STATE_WRITABLE; - rc = OS_SelectSingle(fd, &StateFlags, 0); - if(rc == OS_ERR_NOT_IMPLEMENTED || rc == OS_ERR_OPERATION_NOT_SUPPORTED) + rc = OS_SelectSingle(fd, &StateFlags, 0); + if (rc == OS_ERR_NOT_IMPLEMENTED || rc == OS_ERR_OPERATION_NOT_SUPPORTED) { UtAssertEx(false, UTASSERT_CASETYPE_NA, __FILE__, __LINE__, "OS_SelectSingle() not supported"); goto UT_os_select_single_test_exit_tag; } UT_RETVAL(rc, OS_SUCCESS, "OS_SelectSingle(fd, OS_STREAM_STATE_WRITABLE, 0)"); - UtAssert_True((StateFlags & OS_STREAM_STATE_WRITABLE) != 0, "StateFlags (0x%x) & OS_STREAM_STATE_WRITABLE", (unsigned int)StateFlags); + UtAssert_True((StateFlags & OS_STREAM_STATE_WRITABLE) != 0, "StateFlags (0x%x) & OS_STREAM_STATE_WRITABLE", + (unsigned int)StateFlags); StateFlags = OS_STREAM_STATE_READABLE; - rc = OS_SelectSingle(fd, &StateFlags, 1); + rc = OS_SelectSingle(fd, &StateFlags, 1); UT_RETVAL(rc, OS_SUCCESS, "OS_SelectSingle(fd, OS_STREAM_STATE_READABLE, 0)"); - UtAssert_True((StateFlags & OS_STREAM_STATE_READABLE) != 0, "StateFlags (0x%x) & OS_STREAM_STATE_READABLE", (unsigned int)StateFlags); + UtAssert_True((StateFlags & OS_STREAM_STATE_READABLE) != 0, "StateFlags (0x%x) & OS_STREAM_STATE_READABLE", + (unsigned int)StateFlags); UT_os_select_single_test_exit_tag: teardown_file(fd); @@ -160,20 +161,19 @@ void UT_os_select_single_test(void) **--------------------------------------------------------------------------------*/ void UT_os_select_multi_test(void) { - OS_FdSet ReadSet, WriteSet; + OS_FdSet ReadSet, WriteSet; osal_id_t fd = setup_file(); - int32 rc; + int32 rc; OS_SelectFdZero(&WriteSet); OS_SelectFdAdd(&WriteSet, fd); rc = OS_SelectMultiple(NULL, &WriteSet, 1); - if(rc == OS_ERR_NOT_IMPLEMENTED || rc == OS_ERR_OPERATION_NOT_SUPPORTED) + if (rc == OS_ERR_NOT_IMPLEMENTED || rc == OS_ERR_OPERATION_NOT_SUPPORTED) { UtAssertEx(false, UTASSERT_CASETYPE_NA, __FILE__, __LINE__, "OS_SelectMultiple() not supported"); goto UT_select_multi_test_exit_tag; } - UT_RETVAL(rc, OS_SUCCESS, "OS_SelectMultiple(NULL, &WriteSet, 1)"); UtAssert_True(OS_SelectFdIsSet(&WriteSet, fd), "OS_SelectFdIsSet(&WriteSet, fd)"); diff --git a/src/unit-tests/oscore-test/ut_oscore_select_test.h b/src/unit-tests/oscore-test/ut_oscore_select_test.h index 620308cd5..1187f3ea7 100644 --- a/src/unit-tests/oscore-test/ut_oscore_select_test.h +++ b/src/unit-tests/oscore-test/ut_oscore_select_test.h @@ -59,7 +59,7 @@ void UT_os_select_multi_test(void); /*--------------------------------------------------------------------------------*/ -#endif /* _UT_OSCORE_SELECT_TEST_H_ */ +#endif /* _UT_OSCORE_SELECT_TEST_H_ */ /*================================================================================* ** End of File: ut_oscore_select_test.h diff --git a/src/unit-tests/oscore-test/ut_oscore_task_test.c b/src/unit-tests/oscore-test/ut_oscore_task_test.c index ff98f0224..7f0cd5ae3 100644 --- a/src/unit-tests/oscore-test/ut_oscore_task_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_task_test.c @@ -34,11 +34,11 @@ ** Macros **--------------------------------------------------------------------------------*/ -#define UT_TASK_STACK_SIZE 0x2000 -#define UT_TASK_PRIORITY 111 +#define UT_TASK_STACK_SIZE 0x2000 +#define UT_TASK_PRIORITY 111 /* This is not global in the OSAL */ -#define MAX_PRIORITY 255 +#define MAX_PRIORITY 255 /*--------------------------------------------------------------------------------* ** Data types @@ -48,17 +48,17 @@ ** External global variables **--------------------------------------------------------------------------------*/ -extern char* g_task_names[UT_OS_TASK_LIST_LEN]; +extern char *g_task_names[UT_OS_TASK_LIST_LEN]; extern char g_long_task_name[UT_OS_NAME_BUFF_SIZE]; /*--------------------------------------------------------------------------------* ** Global variables **--------------------------------------------------------------------------------*/ -uint32 g_task_result = 0; +uint32 g_task_result = 0; osal_id_t g_task_sync_sem; osal_id_t g_task_ids[UT_OS_TASK_LIST_LEN]; -uint32 g_task_stacks[UT_OS_TASK_LIST_LEN][UT_TASK_STACK_SIZE]; +uint32 g_task_stacks[UT_OS_TASK_LIST_LEN][UT_TASK_STACK_SIZE]; /*--------------------------------------------------------------------------------* ** External function prototypes @@ -76,16 +76,15 @@ uint32 g_task_stacks[UT_OS_TASK_LIST_LEN][UT_TASK_STACK_SIZE]; void generic_test_task(void) { - osal_id_t task_id; + osal_id_t task_id; OS_task_prop_t task_prop; OS_TaskRegister(); task_id = OS_TaskGetId(); OS_TaskGetInfo(task_id, &task_prop); - - UT_OS_LOG("Starting GenericTask: %s, id: %lx\n", - task_prop.name, OS_ObjectIdToInteger(task_id)); + + UT_OS_LOG("Starting GenericTask: %s, id: %lx\n", task_prop.name, OS_ObjectIdToInteger(task_id)); while (1) { @@ -107,18 +106,18 @@ void generic_test_task(void) **--------------------------------------------------------------------------------*/ void UT_os_task_create_test() { - int32 i=0, res=0; - const char* testDesc; - char task_name[UT_OS_NAME_BUFF_SIZE]; + int32 i = 0, res = 0; + const char *testDesc; + char task_name[UT_OS_NAME_BUFF_SIZE]; /*-----------------------------------------------------*/ testDesc = "API not implemented"; - res = OS_TaskCreate(&g_task_ids[0], g_task_names[0], generic_test_task, g_task_stacks[0], - UT_TASK_STACK_SIZE, UT_TASK_PRIORITY, 0); + res = OS_TaskCreate(&g_task_ids[0], g_task_names[0], generic_test_task, g_task_stacks[0], UT_TASK_STACK_SIZE, + UT_TASK_PRIORITY, 0); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_task_create_test_exit_tag; } @@ -131,63 +130,63 @@ void UT_os_task_create_test() /*-----------------------------------------------------*/ testDesc = "#1 Null-pointer-arg-1"; - res = OS_TaskCreate(NULL, g_task_names[1], generic_test_task, g_task_stacks[1], - UT_TASK_STACK_SIZE, UT_TASK_PRIORITY, 0); + res = OS_TaskCreate(NULL, g_task_names[1], generic_test_task, g_task_stacks[1], UT_TASK_STACK_SIZE, + UT_TASK_PRIORITY, 0); if (res == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Null-pointer-arg-2"; - res = OS_TaskCreate(&g_task_ids[2], NULL, generic_test_task, g_task_stacks[2], - UT_TASK_STACK_SIZE, UT_TASK_PRIORITY, 0); + res = OS_TaskCreate(&g_task_ids[2], NULL, generic_test_task, g_task_stacks[2], UT_TASK_STACK_SIZE, UT_TASK_PRIORITY, + 0); if (res == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Null-pointer-arg-3"; - res = OS_TaskCreate(&g_task_ids[3], g_task_names[3], NULL, g_task_stacks[3], - UT_TASK_STACK_SIZE, UT_TASK_PRIORITY, 0); + res = + OS_TaskCreate(&g_task_ids[3], g_task_names[3], NULL, g_task_stacks[3], UT_TASK_STACK_SIZE, UT_TASK_PRIORITY, 0); if (res == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 Name-too-long"; - res = OS_TaskCreate(&g_task_ids[4], g_long_task_name, generic_test_task, g_task_stacks[4], - UT_TASK_STACK_SIZE, UT_TASK_PRIORITY, 0); + res = OS_TaskCreate(&g_task_ids[4], g_long_task_name, generic_test_task, g_task_stacks[4], UT_TASK_STACK_SIZE, + UT_TASK_PRIORITY, 0); if (res == OS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#5 Invalid-priority"; - res = OS_TaskCreate(&g_task_ids[5], g_task_names[5], generic_test_task, g_task_stacks[5], - UT_TASK_STACK_SIZE, MAX_PRIORITY+1, 0); + res = OS_TaskCreate(&g_task_ids[5], g_task_names[5], generic_test_task, g_task_stacks[5], UT_TASK_STACK_SIZE, + MAX_PRIORITY + 1, 0); if (res == OS_ERR_INVALID_PRIORITY) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#6 No-free-IDs"; /* Setup */ - for (i=0; i <= OS_MAX_TASKS; i++) + for (i = 0; i <= OS_MAX_TASKS; i++) { memset(task_name, '\0', sizeof(task_name)); UT_os_sprintf(task_name, "CREATE_TASK%d", (int)i); - res = OS_TaskCreate(&g_task_ids[i], task_name, generic_test_task, g_task_stacks[i], - UT_TASK_STACK_SIZE, UT_TASK_PRIORITY, 0); + res = OS_TaskCreate(&g_task_ids[i], task_name, generic_test_task, g_task_stacks[i], UT_TASK_STACK_SIZE, + UT_TASK_PRIORITY, 0); if (res != OS_SUCCESS) { break; @@ -195,38 +194,38 @@ void UT_os_task_create_test() } if ((res == OS_ERR_NO_FREE_IDS) && (i == OS_MAX_TASKS)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Delay to let child tasks run */ - OS_TaskDelay(500); + OS_TaskDelay(500); /* Reset test environment */ - for (i=0; i < OS_MAX_TASKS; i++) + for (i = 0; i < OS_MAX_TASKS; i++) { - res = OS_TaskDelete(g_task_ids[i]); /* Ignore errors, does not matter here */ + res = OS_TaskDelete(g_task_ids[i]); /* Ignore errors, does not matter here */ } /*-----------------------------------------------------*/ testDesc = "#7 Duplicate-name"; /* Setup */ - res = OS_TaskCreate(&g_task_ids[7], g_task_names[7], generic_test_task, g_task_stacks[7], - UT_TASK_STACK_SIZE, UT_TASK_PRIORITY, 0); + res = OS_TaskCreate(&g_task_ids[7], g_task_names[7], generic_test_task, g_task_stacks[7], UT_TASK_STACK_SIZE, + UT_TASK_PRIORITY, 0); if (res != OS_SUCCESS) { testDesc = "#7 Duplicate-name - Task-Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { - res = OS_TaskCreate(&g_task_ids[8], g_task_names[7], generic_test_task, g_task_stacks[8], - UT_TASK_STACK_SIZE, UT_TASK_PRIORITY, 0); + res = OS_TaskCreate(&g_task_ids[8], g_task_names[7], generic_test_task, g_task_stacks[8], UT_TASK_STACK_SIZE, + UT_TASK_PRIORITY, 0); if (res == OS_ERR_NAME_TAKEN) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Delay to let child task run */ OS_TaskDelay(200); @@ -238,17 +237,17 @@ void UT_os_task_create_test() /*-----------------------------------------------------*/ testDesc = "#8 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#9 Nominal"; - res = OS_TaskCreate(&g_task_ids[9], g_task_names[9], generic_test_task, g_task_stacks[9], - UT_TASK_STACK_SIZE, UT_TASK_PRIORITY, 0); + res = OS_TaskCreate(&g_task_ids[9], g_task_names[9], generic_test_task, g_task_stacks[9], UT_TASK_STACK_SIZE, + UT_TASK_PRIORITY, 0); if (res == OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Delay to let child task run */ OS_TaskDelay(200); @@ -258,7 +257,6 @@ void UT_os_task_create_test() UT_os_task_create_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -271,8 +269,8 @@ void UT_os_task_create_test() **--------------------------------------------------------------------------------*/ void UT_os_task_delete_test() { - int32 res=0; - const char* testDesc; + int32 res = 0; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -280,7 +278,7 @@ void UT_os_task_delete_test() res = OS_TaskDelete(UT_OBJID_INCORRECT); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_task_delete_test_exit_tag; } @@ -288,26 +286,26 @@ void UT_os_task_delete_test() testDesc = "#1 Invalid-ID-arg"; res = OS_TaskDelete(UT_OBJID_INCORRECT); - if ( res == OS_ERR_INVALID_ID ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_ERR_INVALID_ID) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#3 Nominal"; /* Setup */ - res = OS_TaskCreate(&g_task_ids[3], g_task_names[3], generic_test_task, g_task_stacks[3], - UT_TASK_STACK_SIZE, UT_TASK_PRIORITY, 0); + res = OS_TaskCreate(&g_task_ids[3], g_task_names[3], generic_test_task, g_task_stacks[3], UT_TASK_STACK_SIZE, + UT_TASK_PRIORITY, 0); if (res != OS_SUCCESS) { testDesc = "#3 Nominal - Task-Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { @@ -316,14 +314,13 @@ void UT_os_task_delete_test() res = OS_TaskDelete(g_task_ids[3]); if (res == OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } UT_os_task_delete_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -342,7 +339,7 @@ void delete_handler_callback(void) void delete_handler_test_task(void) { - osal_id_t task_id; + osal_id_t task_id; OS_task_prop_t task_prop; OS_TaskRegister(); @@ -350,12 +347,11 @@ void delete_handler_test_task(void) task_id = OS_TaskGetId(); OS_TaskGetInfo(task_id, &task_prop); - UT_OS_LOG("Starting DeleteTest Task: %s, id: %lx\n", - task_prop.name, OS_ObjectIdToInteger(task_id)); + UT_OS_LOG("Starting DeleteTest Task: %s, id: %lx\n", task_prop.name, OS_ObjectIdToInteger(task_id)); g_task_result = OS_TaskInstallDeleteHandler(&delete_handler_callback); - /* + /* ** Release the semaphore so the main function can record the results of the test ** and clean up */ @@ -371,8 +367,8 @@ void delete_handler_test_task(void) void UT_os_task_install_delete_handler_test(void) { - int32 res=0; - const char* testDesc; + int32 res = 0; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -380,7 +376,7 @@ void UT_os_task_install_delete_handler_test(void) res = OS_TaskInstallDeleteHandler(&delete_handler_callback); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_task_install_delete_handler_test_exit_tag; } @@ -392,10 +388,10 @@ void UT_os_task_install_delete_handler_test(void) ** which should not be an official OSAL task */ res = OS_TaskInstallDeleteHandler(&delete_handler_callback); - if ( res == OS_ERR_INVALID_ID ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_ERR_INVALID_ID) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Nominal"; @@ -405,7 +401,7 @@ void UT_os_task_install_delete_handler_test(void) if (res != OS_SUCCESS) { testDesc = "#2 Nominal - Bin-Sem-Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { @@ -416,7 +412,7 @@ void UT_os_task_install_delete_handler_test(void) if (res != OS_SUCCESS) { testDesc = "#2 Nominal - Task-Create-failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { @@ -428,17 +424,16 @@ void UT_os_task_install_delete_handler_test(void) res = OS_TaskDelete(g_task_ids[2]); if (g_task_result == OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } - res = OS_BinSemDelete(g_task_sync_sem); + res = OS_BinSemDelete(g_task_sync_sem); } UT_os_task_install_delete_handler_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -449,7 +444,7 @@ void UT_os_task_install_delete_handler_test(void) **--------------------------------------------------------------------------------*/ void exit_test_task(void) { - osal_id_t task_id; + osal_id_t task_id; OS_task_prop_t task_prop; OS_TaskRegister(); @@ -457,8 +452,7 @@ void exit_test_task(void) task_id = OS_TaskGetId(); OS_TaskGetInfo(task_id, &task_prop); - UT_OS_LOG("Starting ExitTest Task: %s, id: %lx\n", - task_prop.name, OS_ObjectIdToInteger(task_id)); + UT_OS_LOG("Starting ExitTest Task: %s, id: %lx\n", task_prop.name, OS_ObjectIdToInteger(task_id)); /* ** The parent task will check to see if this task is valid. @@ -477,9 +471,9 @@ void exit_test_task(void) void UT_os_task_exit_test(void) { - int32 res=0; + int32 res = 0; OS_task_prop_t task_prop; - const char* testDesc; + const char * testDesc; /*-----------------------------------------------------*/ testDesc = "#1 Nominal"; @@ -489,18 +483,18 @@ void UT_os_task_exit_test(void) if (res != OS_SUCCESS) { testDesc = "#1 Nominal - Bin-Sem-Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { OS_BinSemTake(g_task_sync_sem); - res = OS_TaskCreate(&g_task_ids[1], g_task_names[1], exit_test_task, g_task_stacks[1], - UT_TASK_STACK_SIZE, UT_TASK_PRIORITY, 0); + res = OS_TaskCreate(&g_task_ids[1], g_task_names[1], exit_test_task, g_task_stacks[1], UT_TASK_STACK_SIZE, + UT_TASK_PRIORITY, 0); if (res != OS_SUCCESS) { testDesc = "#1 Nominal - Task-Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { @@ -515,18 +509,17 @@ void UT_os_task_exit_test(void) */ res = OS_TaskGetInfo(g_task_ids[1], &task_prop); if (res == OS_ERR_INVALID_ID) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); - OS_TaskDelete(g_task_ids[1]); /* Won't hurt if its already deleted */ + OS_TaskDelete(g_task_ids[1]); /* Won't hurt if its already deleted */ } OS_BinSemDelete(g_task_sync_sem); } return; - } /*--------------------------------------------------------------------------------* @@ -538,8 +531,8 @@ void UT_os_task_exit_test(void) **--------------------------------------------------------------------------------*/ void UT_os_task_delay_test() { - int32 res=0; - const char* testDesc; + int32 res = 0; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -547,27 +540,26 @@ void UT_os_task_delay_test() res = OS_TaskDelay(100); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_task_delay_test_exit_tag; } /*-----------------------------------------------------*/ testDesc = "#1 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#2 Nominal"; res = OS_TaskDelay(100); if (res == OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); UT_os_task_delay_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -581,18 +573,18 @@ void UT_os_task_delay_test() **--------------------------------------------------------------------------------*/ void UT_os_task_set_priority_test() { - int32 res=0; - const char* testDesc; + int32 res = 0; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; - res = OS_TaskCreate(&g_task_ids[0], g_task_names[0], generic_test_task, g_task_stacks[0], - UT_TASK_STACK_SIZE, UT_TASK_PRIORITY, 0); + res = OS_TaskCreate(&g_task_ids[0], g_task_names[0], generic_test_task, g_task_stacks[0], UT_TASK_STACK_SIZE, + UT_TASK_PRIORITY, 0); if (res != OS_SUCCESS) { testDesc = "#0 API not implemented - Task-Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_task_set_priority_test_exit_tag; } else @@ -600,7 +592,7 @@ void UT_os_task_set_priority_test() res = OS_TaskSetPriority(g_task_ids[0], UT_TASK_PRIORITY); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_task_set_priority_test_exit_tag; } @@ -616,28 +608,28 @@ void UT_os_task_set_priority_test() res = OS_TaskSetPriority(UT_OBJID_INCORRECT, 100); if (res == OS_ERR_INVALID_ID) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-priority"; - res = OS_TaskCreate(&g_task_ids[2], g_task_names[2], generic_test_task, g_task_stacks[2], - UT_TASK_STACK_SIZE, UT_TASK_PRIORITY, 0); + res = OS_TaskCreate(&g_task_ids[2], g_task_names[2], generic_test_task, g_task_stacks[2], UT_TASK_STACK_SIZE, + UT_TASK_PRIORITY, 0); if (res != OS_SUCCESS) { testDesc = "#2 Invalid-priority - Task-Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { - res = OS_TaskSetPriority(g_task_ids[2], MAX_PRIORITY+1); + res = OS_TaskSetPriority(g_task_ids[2], MAX_PRIORITY + 1); if (res == OS_ERR_INVALID_PRIORITY) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); + /* Delay to let child task run */ OS_TaskDelay(500); @@ -648,26 +640,26 @@ void UT_os_task_set_priority_test() /*-----------------------------------------------------*/ testDesc = "#3 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#4 Nominal"; - res = OS_TaskCreate(&g_task_ids[4], g_task_names[4], generic_test_task, g_task_stacks[4], - UT_TASK_STACK_SIZE, UT_TASK_PRIORITY, 0); + res = OS_TaskCreate(&g_task_ids[4], g_task_names[4], generic_test_task, g_task_stacks[4], UT_TASK_STACK_SIZE, + UT_TASK_PRIORITY, 0); if (res != OS_SUCCESS) { testDesc = "#4 Nominal - Task-Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { - res = OS_TaskSetPriority(g_task_ids[4], UT_TASK_PRIORITY-10); + res = OS_TaskSetPriority(g_task_ids[4], UT_TASK_PRIORITY - 10); if (res == OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); + /* Delay to let child task run */ OS_TaskDelay(500); @@ -678,7 +670,6 @@ void UT_os_task_set_priority_test() UT_os_task_set_priority_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -691,7 +682,7 @@ void UT_os_task_set_priority_test() **--------------------------------------------------------------------------------*/ void register_test_task(void) { - osal_id_t task_id; + osal_id_t task_id; OS_task_prop_t task_prop; g_task_result = OS_TaskRegister(); @@ -699,9 +690,10 @@ void register_test_task(void) task_id = OS_TaskGetId(); OS_TaskGetInfo(task_id, &task_prop); - UT_OS_LOG("Starting RegisterTest Task: %s\n", task_prop.name);; + UT_OS_LOG("Starting RegisterTest Task: %s\n", task_prop.name); + ; - /* + /* ** Release the semaphore so the main function can record the results of the test ** and clean up */ @@ -717,8 +709,8 @@ void register_test_task(void) void UT_os_task_register_test(void) { - int32 res=0; - const char* testDesc; + int32 res = 0; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -726,7 +718,7 @@ void UT_os_task_register_test(void) res = OS_TaskRegister(); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_task_register_test_exit_tag; } @@ -735,14 +727,14 @@ void UT_os_task_register_test(void) res = OS_TaskRegister(); if (res == OS_ERR_INVALID_ID) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#3 Nominal"; @@ -752,18 +744,18 @@ void UT_os_task_register_test(void) if (res != OS_SUCCESS) { testDesc = "#3 Nominal - Bin-Sem-Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { OS_BinSemTake(g_task_sync_sem); - res = OS_TaskCreate(&g_task_ids[3], g_task_names[3], register_test_task, g_task_stacks[3], - UT_TASK_STACK_SIZE, UT_TASK_PRIORITY, 0); - if ( res != OS_SUCCESS ) + res = OS_TaskCreate(&g_task_ids[3], g_task_names[3], register_test_task, g_task_stacks[3], UT_TASK_STACK_SIZE, + UT_TASK_PRIORITY, 0); + if (res != OS_SUCCESS) { testDesc = "#3 Nominal - Task-Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { @@ -776,22 +768,21 @@ void UT_os_task_register_test(void) res = OS_BinSemDelete(g_task_sync_sem); if (g_task_result == OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); + else + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } } UT_os_task_register_test_exit_tag: return; - } /*--------------------------------------------------------------------------------*/ void getid_test_task(void) { - osal_id_t task_id; + osal_id_t task_id; OS_task_prop_t task_prop; OS_TaskRegister(); @@ -799,8 +790,7 @@ void getid_test_task(void) task_id = OS_TaskGetId(); OS_TaskGetInfo(task_id, &task_prop); - UT_OS_LOG("OS_TaskGetId() - #1 Nominal [This is the returned task Id=%lx]\n", - OS_ObjectIdToInteger(task_id)); + UT_OS_LOG("OS_TaskGetId() - #1 Nominal [This is the returned task Id=%lx]\n", OS_ObjectIdToInteger(task_id)); while (1) { @@ -816,8 +806,8 @@ void getid_test_task(void) **--------------------------------------------------------------------------------*/ void UT_os_task_get_id_test() { - int32 res=0; - const char* testDesc; + int32 res = 0; + const char *testDesc; /* * Note this function does not return a normal status code, @@ -828,25 +818,24 @@ void UT_os_task_get_id_test() testDesc = "#1 Nominal"; /* Setup */ - res = OS_TaskCreate(&g_task_ids[1], g_task_names[1], getid_test_task, g_task_stacks[1], - UT_TASK_STACK_SIZE, UT_TASK_PRIORITY, 0); + res = OS_TaskCreate(&g_task_ids[1], g_task_names[1], getid_test_task, g_task_stacks[1], UT_TASK_STACK_SIZE, + UT_TASK_PRIORITY, 0); if (res != OS_SUCCESS) { - testDesc = "#1 Nominal - Task-Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + testDesc = "#1 Nominal - Task-Create failed"; + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { - OS_TaskDelay(500); + OS_TaskDelay(500); - UT_OS_LOG("OS_TaskGetId() - #1 Nominal [This is the expected task Id=%lx]\n", - OS_ObjectIdToInteger(g_task_ids[1])); + UT_OS_LOG("OS_TaskGetId() - #1 Nominal [This is the expected task Id=%lx]\n", + OS_ObjectIdToInteger(g_task_ids[1])); - res = OS_TaskDelete(g_task_ids[1]); /* Won't hurt if its already deleted */ + res = OS_TaskDelete(g_task_ids[1]); /* Won't hurt if its already deleted */ - UT_OS_TEST_RESULT( "#1 Nominal - Manual inspection required", UTASSERT_CASETYPE_MIR); + UT_OS_TEST_RESULT("#1 Nominal - Manual inspection required", UTASSERT_CASETYPE_MIR); } - } /*--------------------------------------------------------------------------------* @@ -860,8 +849,8 @@ void UT_os_task_get_id_test() **--------------------------------------------------------------------------------*/ void UT_os_task_get_id_by_name_test() { - int32 res=0; - const char* testDesc; + int32 res = 0; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -869,7 +858,7 @@ void UT_os_task_get_id_by_name_test() res = OS_TaskGetIdByName(0, "InvalidName"); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_task_get_id_by_name_test_exit_tag; } @@ -878,55 +867,55 @@ void UT_os_task_get_id_by_name_test() res = OS_TaskGetIdByName(NULL, "InvalidName"); if (res == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-pointer-arg-2"; res = OS_TaskGetIdByName(&g_task_ids[2], NULL); if (res == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Name-too-long"; res = OS_TaskGetIdByName(&g_task_ids[3], g_long_task_name); if (res == OS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 Name-not-found"; res = OS_TaskGetIdByName(&g_task_ids[4], "NameNotFound"); - if ( res == OS_ERR_NAME_NOT_FOUND ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_ERR_NAME_NOT_FOUND) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#5 Nominal"; /* Setup */ - res = OS_TaskCreate(&g_task_ids[5], g_task_names[5], generic_test_task, g_task_stacks[5], - UT_TASK_STACK_SIZE, UT_TASK_PRIORITY, 0); + res = OS_TaskCreate(&g_task_ids[5], g_task_names[5], generic_test_task, g_task_stacks[5], UT_TASK_STACK_SIZE, + UT_TASK_PRIORITY, 0); if (res != OS_SUCCESS) { testDesc = "#5 Nominal - Task-Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_TaskGetIdByName(&g_task_ids[6], g_task_names[5]); if ((res == OS_SUCCESS) && OS_ObjectIdEqual(g_task_ids[5], g_task_ids[6])) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); OS_TaskDelay(500); /* Delay to let task run */ res = OS_TaskDelete(g_task_ids[5]); @@ -934,7 +923,6 @@ void UT_os_task_get_id_by_name_test() UT_os_task_get_id_by_name_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -947,9 +935,9 @@ void UT_os_task_get_id_by_name_test() **--------------------------------------------------------------------------------*/ void UT_os_task_get_info_test() { - int32 res=0; + int32 res = 0; OS_task_prop_t task_prop; - const char* testDesc; + const char * testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -957,7 +945,7 @@ void UT_os_task_get_info_test() res = OS_TaskGetInfo(UT_OBJID_INCORRECT, &task_prop); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_task_get_info_test_exit_tag; } @@ -966,28 +954,28 @@ void UT_os_task_get_info_test() res = OS_TaskGetInfo(UT_OBJID_INCORRECT, &task_prop); if (res == OS_ERR_INVALID_ID) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-pointer-arg"; /* Setup */ - res = OS_TaskCreate(&g_task_ids[2], g_task_names[2], generic_test_task, g_task_stacks[2], - UT_TASK_STACK_SIZE, UT_TASK_PRIORITY, 0); + res = OS_TaskCreate(&g_task_ids[2], g_task_names[2], generic_test_task, g_task_stacks[2], UT_TASK_STACK_SIZE, + UT_TASK_PRIORITY, 0); if (res != OS_SUCCESS) { testDesc = "#2 Invalid-pointer-arg - Task-Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_TaskGetInfo(g_task_ids[2], NULL); if (res == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Delay to let child task run */ OS_TaskDelay(500); @@ -1000,20 +988,20 @@ void UT_os_task_get_info_test() testDesc = "#3 Nominal"; /* Setup */ - res = OS_TaskCreate(&g_task_ids[3], g_task_names[3], generic_test_task, g_task_stacks[3], - UT_TASK_STACK_SIZE, UT_TASK_PRIORITY, 0); + res = OS_TaskCreate(&g_task_ids[3], g_task_names[3], generic_test_task, g_task_stacks[3], UT_TASK_STACK_SIZE, + UT_TASK_PRIORITY, 0); if (res != OS_SUCCESS) { testDesc = "#3 Nominal - Task-Create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_TaskGetInfo(g_task_ids[3], &task_prop); if (res == OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Delay to let child task run */ OS_TaskDelay(500); @@ -1024,7 +1012,6 @@ void UT_os_task_get_info_test() UT_os_task_get_info_test_exit_tag: return; - } /*================================================================================* diff --git a/src/unit-tests/oscore-test/ut_oscore_task_test.h b/src/unit-tests/oscore-test/ut_oscore_task_test.h index a5fc28e52..2a1a55df3 100644 --- a/src/unit-tests/oscore-test/ut_oscore_task_test.h +++ b/src/unit-tests/oscore-test/ut_oscore_task_test.h @@ -37,7 +37,7 @@ ** Macros **--------------------------------------------------------------------------------*/ -#define UT_OS_TASK_LIST_LEN (OS_MAX_TASKS + 10) +#define UT_OS_TASK_LIST_LEN (OS_MAX_TASKS + 10) /*--------------------------------------------------------------------------------* ** Data types @@ -69,7 +69,7 @@ void UT_os_task_get_id_test(void); /*--------------------------------------------------------------------------------*/ -#endif /* _UT_OSCORE_TASK_TEST_H_ */ +#endif /* _UT_OSCORE_TASK_TEST_H_ */ /*================================================================================* ** End of File: ut_oscore_task_test.h diff --git a/src/unit-tests/oscore-test/ut_oscore_test.c b/src/unit-tests/oscore-test/ut_oscore_test.c index 37f7612f7..1567f238d 100644 --- a/src/unit-tests/oscore-test/ut_oscore_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_test.c @@ -46,8 +46,8 @@ ** Global variables **--------------------------------------------------------------------------------*/ -const char* g_task_names[UT_OS_TASK_LIST_LEN]; -char g_long_task_name[UT_OS_NAME_BUFF_SIZE]; +const char *g_task_names[UT_OS_TASK_LIST_LEN]; +char g_long_task_name[UT_OS_NAME_BUFF_SIZE]; /*--------------------------------------------------------------------------------* ** External function prototypes @@ -76,7 +76,7 @@ void UT_os_init_task_get_info_test(void); void UT_os_init_task_misc() { memset(g_long_task_name, 'X', sizeof(g_long_task_name)); - g_long_task_name[sizeof(g_long_task_name)-1] = '\0'; + g_long_task_name[sizeof(g_long_task_name) - 1] = '\0'; } /*--------------------------------------------------------------------------------*/ @@ -229,61 +229,18 @@ void UtTest_Setup(void) UtTest_Add(UT_os_select_single_test, NULL, NULL, "OS_SelectSingle"); UtTest_Add(UT_os_select_multi_test, NULL, NULL, "OS_SelectMultiple"); - UtTest_Add( - NULL, - UT_os_init_task_misc, - NULL, - "UT_os_init_task_misc"); - UtTest_Add( - UT_os_task_create_test, - UT_os_init_task_create_test, - NULL, - "OS_TaskCreate"); - UtTest_Add( - UT_os_task_delete_test, - UT_os_init_task_delete_test, - NULL, - "OS_TaskDelete"); - UtTest_Add( - UT_os_task_install_delete_handler_test, - UT_os_setup_install_delete_handler_test, - NULL, - "OS_TaskInstallDeleteHandler"); - UtTest_Add( - UT_os_task_exit_test, - UT_os_init_task_exit_test, - NULL, - "OS_TaskExit"); - UtTest_Add( - UT_os_task_delay_test, - UT_os_init_task_delay_test, - NULL, - "OS_TaskDelay"); - UtTest_Add( - UT_os_task_set_priority_test, - UT_os_init_task_set_priority_test, - NULL, - "OS_TaskSetPriority"); - UtTest_Add( - UT_os_task_register_test, - UT_os_init_task_register_test, - NULL, - "OS_TaskRegister"); - UtTest_Add( - UT_os_task_get_id_test, - UT_os_init_task_get_id_test, - NULL, - "OS_TaskGetId"); - UtTest_Add( - UT_os_task_get_id_by_name_test, - UT_os_init_task_get_id_by_name_test, - NULL, - "OS_TaskGetIdByName"); - UtTest_Add( - UT_os_task_get_info_test, - UT_os_init_task_get_info_test, - NULL, - "OS_TaskGetInfo"); + UtTest_Add(NULL, UT_os_init_task_misc, NULL, "UT_os_init_task_misc"); + UtTest_Add(UT_os_task_create_test, UT_os_init_task_create_test, NULL, "OS_TaskCreate"); + UtTest_Add(UT_os_task_delete_test, UT_os_init_task_delete_test, NULL, "OS_TaskDelete"); + UtTest_Add(UT_os_task_install_delete_handler_test, UT_os_setup_install_delete_handler_test, NULL, + "OS_TaskInstallDeleteHandler"); + UtTest_Add(UT_os_task_exit_test, UT_os_init_task_exit_test, NULL, "OS_TaskExit"); + UtTest_Add(UT_os_task_delay_test, UT_os_init_task_delay_test, NULL, "OS_TaskDelay"); + UtTest_Add(UT_os_task_set_priority_test, UT_os_init_task_set_priority_test, NULL, "OS_TaskSetPriority"); + UtTest_Add(UT_os_task_register_test, UT_os_init_task_register_test, NULL, "OS_TaskRegister"); + UtTest_Add(UT_os_task_get_id_test, UT_os_init_task_get_id_test, NULL, "OS_TaskGetId"); + UtTest_Add(UT_os_task_get_id_by_name_test, UT_os_init_task_get_id_by_name_test, NULL, "OS_TaskGetIdByName"); + UtTest_Add(UT_os_task_get_info_test, UT_os_init_task_get_info_test, NULL, "OS_TaskGetInfo"); UtTest_Add(UT_os_geterrorname_test, NULL, NULL, "OS_GetErrorName"); diff --git a/src/unit-tests/oscore-test/ut_oscore_test.h b/src/unit-tests/oscore-test/ut_oscore_test.h index 558c10d0d..1be4ae0f9 100644 --- a/src/unit-tests/oscore-test/ut_oscore_test.h +++ b/src/unit-tests/oscore-test/ut_oscore_test.h @@ -62,7 +62,7 @@ /*--------------------------------------------------------------------------------*/ -#endif /* _UT_OSCORE_TEST_H_ */ +#endif /* _UT_OSCORE_TEST_H_ */ /*================================================================================* ** End of File: ut_oscore_test_posix.h diff --git a/src/unit-tests/osfile-test/ut_osfile_dirio_test.c b/src/unit-tests/osfile-test/ut_osfile_dirio_test.c index 6be06b81d..974b808bc 100644 --- a/src/unit-tests/osfile-test/ut_osfile_dirio_test.c +++ b/src/unit-tests/osfile-test/ut_osfile_dirio_test.c @@ -34,7 +34,7 @@ ** Macros **--------------------------------------------------------------------------------*/ -#define UT_OS_FILE_MAX_DIRS 5 +#define UT_OS_FILE_MAX_DIRS 5 /*--------------------------------------------------------------------------------* ** Data types @@ -44,23 +44,23 @@ ** External global variables **--------------------------------------------------------------------------------*/ -extern char* g_fsAddrPtr; +extern char *g_fsAddrPtr; -extern char g_longPathName[UT_OS_PATH_BUFF_SIZE]; +extern char g_longPathName[UT_OS_PATH_BUFF_SIZE]; -extern char* g_mntName; +extern char *g_mntName; /*--------------------------------------------------------------------------------* ** Global variables **--------------------------------------------------------------------------------*/ -char g_dirName[UT_OS_PATH_BUFF_SIZE]; -char g_fileName[UT_OS_FILE_BUFF_SIZE]; +char g_dirName[UT_OS_PATH_BUFF_SIZE]; +char g_fileName[UT_OS_FILE_BUFF_SIZE]; -char g_subdirNames[UT_OS_FILE_MAX_DIRS][UT_OS_PATH_BUFF_SIZE]; -const char* g_tgtSubdirs[UT_OS_FILE_MAX_DIRS] = {"subdir1", "subdir2"}; +char g_subdirNames[UT_OS_FILE_MAX_DIRS][UT_OS_PATH_BUFF_SIZE]; +const char *g_tgtSubdirs[UT_OS_FILE_MAX_DIRS] = {"subdir1", "subdir2"}; -char g_dirItems[UT_OS_FILE_MAX_DIRS][UT_OS_FILE_BUFF_SIZE]; +char g_dirItems[UT_OS_FILE_MAX_DIRS][UT_OS_FILE_BUFF_SIZE]; /*--------------------------------------------------------------------------------* ** Local function prototypes @@ -120,16 +120,16 @@ void UT_os_read_n_sort_dirs(osal_id_t); **--------------------------------------------------------------------------------*/ void UT_os_makedir_test() { - int32 status; - osal_id_t fileDesc; - const char* testDesc; + int32 status; + osal_id_t fileDesc; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; if (OS_mkdir(NULL, 755) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_makedir_test_exit_tag; } @@ -137,30 +137,30 @@ void UT_os_makedir_test() testDesc = "#1 Null-pointer-arg"; if (OS_mkdir(NULL, 755) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Path-too-long-arg"; if (OS_mkdir(g_longPathName, 755) == OS_FS_ERR_PATH_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Invalid-path-arg"; if (OS_mkdir("tmpDir", 755) == OS_FS_ERR_PATH_INVALID) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#5 Nominal"; @@ -170,17 +170,17 @@ void UT_os_makedir_test() if (OS_mkdir(g_dirName, 755) != OS_SUCCESS) { testDesc = "#5 Nominal - File-system-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_makedir_test_exit_tag; } memset(g_fileName, '\0', sizeof(g_fileName)); UT_os_sprintf(g_fileName, "%s/mkdir_File.txt", g_dirName); - status = OS_OpenCreate(&fileDesc, g_fileName, OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + status = OS_OpenCreate(&fileDesc, g_fileName, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); if (status >= 0) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_close(fileDesc); @@ -189,7 +189,6 @@ void UT_os_makedir_test() UT_os_makedir_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -239,15 +238,15 @@ void UT_os_makedir_test() **--------------------------------------------------------------------------------*/ void UT_os_opendir_test() { - osal_id_t dirh; - const char* testDesc; + osal_id_t dirh; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; if (OS_DirectoryOpen(&dirh, NULL) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_opendir_test_exit_tag; } @@ -255,30 +254,30 @@ void UT_os_opendir_test() testDesc = "#1 Null-pointer-arg"; if (OS_DirectoryOpen(&dirh, NULL) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Path-too-long-arg"; if (OS_DirectoryOpen(&dirh, g_longPathName) == OS_FS_ERR_PATH_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Invalid-path-arg"; if (OS_DirectoryOpen(&dirh, "/drive0/tmpDir") != OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#5 Nominal"; @@ -288,14 +287,14 @@ void UT_os_opendir_test() if (OS_mkdir(g_dirName, 755) != OS_SUCCESS) { testDesc = "#5 Nominal - Dir-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_opendir_test_exit_tag; } if (OS_DirectoryOpen(&dirh, g_dirName) == OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_DirectoryClose(dirh); @@ -303,7 +302,6 @@ void UT_os_opendir_test() UT_os_opendir_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -341,23 +339,23 @@ void UT_os_opendir_test() **--------------------------------------------------------------------------------*/ void UT_os_closedir_test() { - osal_id_t dirh; - os_dirent_t* dirEntry=NULL; - const char* testDesc; + osal_id_t dirh; + os_dirent_t *dirEntry = NULL; + const char * testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; if (OS_DirectoryClose(OS_OBJECT_ID_UNDEFINED) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_closedir_test_exit_tag; } /*-----------------------------------------------------*/ testDesc = "#1 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#2 Nominal"; @@ -367,34 +365,33 @@ void UT_os_closedir_test() if (OS_mkdir(g_dirName, 755) != OS_SUCCESS) { testDesc = "#2 Nominal - Dir-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_closedir_test_exit_tag; } if (OS_DirectoryOpen(&dirh, g_dirName) != OS_SUCCESS) { testDesc = "#2 Nominal - Dir-open failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); goto UT_os_closedir_test_exit_tag; } if (OS_DirectoryClose(dirh) != OS_SUCCESS) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); goto UT_os_closedir_test_exit_tag; } if (OS_DirectoryRead(dirh, dirEntry) != OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_rmdir(g_dirName); UT_os_closedir_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -442,8 +439,8 @@ void UT_os_closedir_test() **--------------------------------------------------------------------------------*/ void UT_os_readdir_test() { - osal_id_t dirh; - const char* testDesc; + osal_id_t dirh; + const char *testDesc; strcpy(g_subdirNames[0], " "); strcpy(g_subdirNames[1], " "); @@ -453,7 +450,7 @@ void UT_os_readdir_test() if (OS_DirectoryRead(OS_OBJECT_ID_UNDEFINED, NULL) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_readdir_test_exit_tag; } @@ -461,14 +458,14 @@ void UT_os_readdir_test() testDesc = "#1 Null-pointer-arg"; if (OS_DirectoryRead(OS_OBJECT_ID_UNDEFINED, NULL) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#3 Nominal"; @@ -478,7 +475,7 @@ void UT_os_readdir_test() if (OS_mkdir(g_dirName, 755) != OS_SUCCESS) { testDesc = "#3 Nominal - Dir-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_readdir_test_exit_tag; } @@ -487,7 +484,7 @@ void UT_os_readdir_test() if (OS_mkdir(g_subdirNames[0], 755) != OS_SUCCESS) { testDesc = "#3 Nominal - Dir-create(subdir1) failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_readdir_test_exit_tag; } @@ -497,7 +494,7 @@ void UT_os_readdir_test() if (OS_mkdir(g_subdirNames[1], 755) != OS_SUCCESS) { testDesc = "#3 Nominal - Dir-create(subdir2) failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_readdir_test_exit_tag; } @@ -505,18 +502,17 @@ void UT_os_readdir_test() if (OS_DirectoryOpen(&dirh, g_dirName) != OS_SUCCESS) { testDesc = "#3 Nominal - Dir-open failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_readdir_test_exit_tag; } UT_os_read_n_sort_dirs(dirh); - if ((strcmp(g_dirItems[2], g_tgtSubdirs[0]) == 0) && - (strcmp(g_dirItems[3], g_tgtSubdirs[1]) == 0)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if ((strcmp(g_dirItems[2], g_tgtSubdirs[0]) == 0) && (strcmp(g_dirItems[3], g_tgtSubdirs[1]) == 0)) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); UT_os_readdir_test_exit_tag: /* Reset test environment */ @@ -526,7 +522,6 @@ void UT_os_readdir_test() OS_rmdir(g_dirName); return; - } /*--------------------------------------------------------------------------------* @@ -571,8 +566,8 @@ void UT_os_readdir_test() **--------------------------------------------------------------------------------*/ void UT_os_rewinddir_test() { - osal_id_t dirh; - const char* testDesc; + osal_id_t dirh; + const char *testDesc; strcpy(g_subdirNames[0], " "); strcpy(g_subdirNames[1], " "); @@ -582,14 +577,14 @@ void UT_os_rewinddir_test() if (OS_DirectoryRewind(OS_OBJECT_ID_UNDEFINED) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_rewinddir_test_exit_tag; } /*-----------------------------------------------------*/ testDesc = "#1 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#2 Nominal"; @@ -599,7 +594,7 @@ void UT_os_rewinddir_test() if (OS_mkdir(g_dirName, 755) != OS_SUCCESS) { testDesc = "#2 Nominal - Dir-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_rewinddir_test_exit_tag; } @@ -609,7 +604,7 @@ void UT_os_rewinddir_test() if (OS_mkdir(g_subdirNames[0], 755) != OS_SUCCESS) { testDesc = "#2 Nominal - Dir-create(subdir1) failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_rewinddir_test_exit_tag; } @@ -619,7 +614,7 @@ void UT_os_rewinddir_test() if (OS_mkdir(g_subdirNames[1], 755) != OS_SUCCESS) { testDesc = "#2 Nominal - Dir-create(subdir2) failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_rewinddir_test_exit_tag; } @@ -627,18 +622,17 @@ void UT_os_rewinddir_test() if (OS_DirectoryOpen(&dirh, g_dirName) != OS_SUCCESS) { testDesc = "#2 Nominal - Dir-open failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_rewinddir_test_exit_tag; } UT_os_read_n_sort_dirs(dirh); - if ((strcmp(g_dirItems[2], g_tgtSubdirs[0]) != 0) || - (strcmp(g_dirItems[3], g_tgtSubdirs[1]) != 0)) + if ((strcmp(g_dirItems[2], g_tgtSubdirs[0]) != 0) || (strcmp(g_dirItems[3], g_tgtSubdirs[1]) != 0)) { testDesc = "#2 Nominal - Dir-read failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_rewinddir_test_exit_tag; } @@ -647,11 +641,10 @@ void UT_os_rewinddir_test() UT_os_read_n_sort_dirs(dirh); - if ((strcmp(g_dirItems[2], g_tgtSubdirs[0]) != 0) || - (strcmp(g_dirItems[3], g_tgtSubdirs[1]) != 0)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + if ((strcmp(g_dirItems[2], g_tgtSubdirs[0]) != 0) || (strcmp(g_dirItems[3], g_tgtSubdirs[1]) != 0)) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); UT_os_rewinddir_test_exit_tag: /* Reset test environment */ @@ -661,7 +654,6 @@ void UT_os_rewinddir_test() OS_rmdir(g_dirName); return; - } /*--------------------------------------------------------------------------------* @@ -719,16 +711,16 @@ void UT_os_rewinddir_test() **--------------------------------------------------------------------------------*/ void UT_os_removedir_test() { - int32 status; - osal_id_t fileDesc; - const char* testDesc; + int32 status; + osal_id_t fileDesc; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; if (OS_rmdir(NULL) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_removedir_test_exit_tag; } @@ -736,30 +728,30 @@ void UT_os_removedir_test() testDesc = "#1 Null-pointer-arg"; if (OS_rmdir(NULL) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Path-too-long-arg"; if (OS_rmdir(g_longPathName) == OS_FS_ERR_PATH_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Invalid-path-arg"; if (OS_rmdir("tmpDir") == OS_FS_ERR_PATH_INVALID) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#5 Nominal"; @@ -769,17 +761,17 @@ void UT_os_removedir_test() if (OS_mkdir(g_dirName, 755) != OS_SUCCESS) { testDesc = "#5 Nominal - Dir-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_removedir_test_exit_tag; } memset(g_fileName, '\0', sizeof(g_fileName)); UT_os_sprintf(g_fileName, "%s/rmdir_File1.txt", g_dirName); - status = OS_OpenCreate(&fileDesc, g_fileName, OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + status = OS_OpenCreate(&fileDesc, g_fileName, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); if (status < 0) { testDesc = "#5 Nominal - File-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } /* Must close and remove all files before the directory can be removed */ @@ -788,32 +780,31 @@ void UT_os_removedir_test() if (OS_rmdir(g_dirName) != OS_SUCCESS) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); goto UT_os_removedir_test_exit_tag; } memset(g_fileName, '\0', sizeof(g_fileName)); UT_os_sprintf(g_fileName, "%s/rmdir_File2.txt", g_dirName); - status = OS_OpenCreate(&fileDesc, g_fileName, OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + status = OS_OpenCreate(&fileDesc, g_fileName, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); if (status < 0) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); UT_os_removedir_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* * Internal helper function -**--------------------------------------------------------------------------------*/ + **--------------------------------------------------------------------------------*/ void UT_os_read_n_sort_dirs(osal_id_t dirh) { - int i=0; + int i = 0; os_dirent_t dirEntry; - for (i=0; i < UT_OS_FILE_MAX_DIRS; i++) + for (i = 0; i < UT_OS_FILE_MAX_DIRS; i++) strcpy(g_dirItems[i], " "); while (OS_DirectoryRead(dirh, &dirEntry) == OS_SUCCESS) diff --git a/src/unit-tests/osfile-test/ut_osfile_dirio_test.h b/src/unit-tests/osfile-test/ut_osfile_dirio_test.h index 875435d2e..e118631c8 100644 --- a/src/unit-tests/osfile-test/ut_osfile_dirio_test.h +++ b/src/unit-tests/osfile-test/ut_osfile_dirio_test.h @@ -37,7 +37,7 @@ ** Macros **--------------------------------------------------------------------------------*/ -#define UT_OS_FILE_LIST_LEN (OS_MAX_FILE_SYSTEMS + 10) +#define UT_OS_FILE_LIST_LEN (OS_MAX_FILE_SYSTEMS + 10) /*--------------------------------------------------------------------------------* ** Data types @@ -64,7 +64,7 @@ void UT_os_removedir_test(void); /*--------------------------------------------------------------------------------*/ -#endif /* _UT_OSFILE_DIRIO_H_ */ +#endif /* _UT_OSFILE_DIRIO_H_ */ /*================================================================================* ** End of File: ut_osfile_dirio.h diff --git a/src/unit-tests/osfile-test/ut_osfile_fileio_test.c b/src/unit-tests/osfile-test/ut_osfile_fileio_test.c index 01f109f74..6ab152a27 100644 --- a/src/unit-tests/osfile-test/ut_osfile_fileio_test.c +++ b/src/unit-tests/osfile-test/ut_osfile_fileio_test.c @@ -34,7 +34,7 @@ ** Macros **--------------------------------------------------------------------------------*/ -#define UT_OS_FILE_LIST_LEN (OS_MAX_NUM_OPEN_FILES + 10) +#define UT_OS_FILE_LIST_LEN (OS_MAX_NUM_OPEN_FILES + 10) /*--------------------------------------------------------------------------------* ** Data types @@ -44,24 +44,24 @@ ** External global variables **--------------------------------------------------------------------------------*/ -extern char* g_fsAddrPtr; +extern char *g_fsAddrPtr; -extern char g_longPathName[UT_OS_PATH_BUFF_SIZE]; -extern char g_longFileName[UT_OS_PATH_BUFF_SIZE]; -extern char g_invalidPath[UT_OS_PATH_BUFF_SIZE]; +extern char g_longPathName[UT_OS_PATH_BUFF_SIZE]; +extern char g_longFileName[UT_OS_PATH_BUFF_SIZE]; +extern char g_invalidPath[UT_OS_PATH_BUFF_SIZE]; -extern char* g_mntName; +extern char *g_mntName; /*--------------------------------------------------------------------------------* ** Global variables **--------------------------------------------------------------------------------*/ -char g_fNames[UT_OS_FILE_LIST_LEN][UT_OS_FILE_BUFF_SIZE]; -int32 g_fStatus[UT_OS_FILE_LIST_LEN]; -osal_id_t g_fDescs[UT_OS_FILE_LIST_LEN]; +char g_fNames[UT_OS_FILE_LIST_LEN][UT_OS_FILE_BUFF_SIZE]; +int32 g_fStatus[UT_OS_FILE_LIST_LEN]; +osal_id_t g_fDescs[UT_OS_FILE_LIST_LEN]; -char g_readBuff[UT_OS_IO_BUFF_SIZE]; -char g_writeBuff[UT_OS_IO_BUFF_SIZE]; +char g_readBuff[UT_OS_IO_BUFF_SIZE]; +char g_writeBuff[UT_OS_IO_BUFF_SIZE]; /*--------------------------------------------------------------------------------* ** External function prototypes @@ -105,13 +105,13 @@ char g_writeBuff[UT_OS_IO_BUFF_SIZE]; *--------------------------------------------------------------------------------*/ void UT_os_initfs_test() { - int32 res = 0; - const char* testDesc; + int32 res = 0; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "#1 Init-not-call-first - Test case not applicable on platform"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); /*-----------------------------------------------------*/ testDesc = "#2 Nominal"; @@ -121,19 +121,18 @@ void UT_os_initfs_test() if (res == OS_ERR_NOT_IMPLEMENTED) { testDesc = "API not implemented"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); } else if (res == OS_SUCCESS) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); } else { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } return; - } /*--------------------------------------------------------------------------------* @@ -210,61 +209,58 @@ void UT_os_initfs_test() **--------------------------------------------------------------------------------*/ void UT_os_createfile_test() { - const char* testDesc; - int32 res=0, i=0, j=0; - osal_id_t fd; + const char *testDesc; + int32 res = 0, i = 0, j = 0; + osal_id_t fd; /*-----------------------------------------------------*/ testDesc = "API not implemented"; - if (OS_OpenCreate(NULL, NULL, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE) == - OS_ERR_NOT_IMPLEMENTED) + if (OS_OpenCreate(NULL, NULL, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_createfile_test_exit_tag; } /*-----------------------------------------------------*/ testDesc = "#1 Null-pointer-arg"; - if (OS_OpenCreate(NULL, "file", OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE) == - OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (OS_OpenCreate(NULL, "file", OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE) == OS_INVALID_POINTER) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); - if (OS_OpenCreate(&fd, NULL, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE) == - OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (OS_OpenCreate(&fd, NULL, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE) == OS_INVALID_POINTER) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-path-arg"; if (OS_OpenCreate(&fd, g_invalidPath, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE) == - OS_FS_ERR_PATH_INVALID) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + OS_FS_ERR_PATH_INVALID) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Path-too-long-arg"; if (OS_OpenCreate(&fd, g_longPathName, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE) == - OS_FS_ERR_PATH_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + OS_FS_ERR_PATH_TOO_LONG) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 Name-too-long-arg"; if (OS_OpenCreate(&fd, g_longFileName, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE) == - OS_FS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + OS_FS_ERR_NAME_TOO_LONG) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#5 Invalid-permission-arg"; @@ -273,9 +269,9 @@ void UT_os_createfile_test() UT_os_sprintf(g_fNames[0], "%s/Create_InvPerm.txt", g_mntName); res = OS_OpenCreate(&fd, g_fNames[0], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, 123); if (res == OS_ERROR) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_remove(g_fNames[0]); @@ -283,27 +279,28 @@ void UT_os_createfile_test() /*-----------------------------------------------------*/ testDesc = "#6 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#7 File-descriptors-full"; - for (i=0; i <= OS_MAX_NUM_OPEN_FILES; i++) + for (i = 0; i <= OS_MAX_NUM_OPEN_FILES; i++) { memset(g_fNames[i], '\0', sizeof(g_fNames[i])); UT_os_sprintf(g_fNames[i], "%s/tmpFile%d.txt", g_mntName, (int)i); - g_fStatus[i] = OS_OpenCreate(&g_fDescs[i], g_fNames[i], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); + g_fStatus[i] = + OS_OpenCreate(&g_fDescs[i], g_fNames[i], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); if (g_fStatus[i] < 0) break; } if ((i == OS_MAX_NUM_OPEN_FILES) && (g_fStatus[i] == OS_ERR_NO_FREE_IDS)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ - for (j=0; j < i; j++) + for (j = 0; j < i; j++) { OS_close(g_fDescs[j]); OS_remove(g_fNames[j]); @@ -315,15 +312,14 @@ void UT_os_createfile_test() g_fStatus[5] = OS_OpenCreate(&g_fDescs[5], g_fNames[5], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); g_fStatus[6] = OS_OpenCreate(&g_fDescs[6], g_fNames[6], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); - if ((OS_close(g_fDescs[5]) != OS_SUCCESS) || (OS_close(g_fDescs[6]) != OS_SUCCESS) || + if ((OS_close(g_fDescs[5]) != OS_SUCCESS) || (OS_close(g_fDescs[6]) != OS_SUCCESS) || (OS_remove(g_fNames[5]) != OS_SUCCESS) || (OS_remove(g_fNames[6]) != OS_SUCCESS)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); UT_os_createfile_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -401,61 +397,55 @@ void UT_os_createfile_test() **--------------------------------------------------------------------------------*/ void UT_os_openfile_test() { - const char* testDesc; - int32 res=0, i=0, j=0, continueFlg=0; - osal_id_t fd; + const char *testDesc; + int32 res = 0, i = 0, j = 0, continueFlg = 0; + osal_id_t fd; /*-----------------------------------------------------*/ testDesc = "API not implemented"; - if (OS_OpenCreate(&fd, NULL, OS_FILE_FLAG_NONE, OS_READ_WRITE) == - OS_ERR_NOT_IMPLEMENTED) + if (OS_OpenCreate(&fd, NULL, OS_FILE_FLAG_NONE, OS_READ_WRITE) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_openfile_test_exit_tag; } /*-----------------------------------------------------*/ testDesc = "#1 Null-pointer-arg"; - if (OS_OpenCreate(&fd, NULL, OS_FILE_FLAG_NONE, OS_READ_WRITE) == - OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (OS_OpenCreate(&fd, NULL, OS_FILE_FLAG_NONE, OS_READ_WRITE) == OS_INVALID_POINTER) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); - if (OS_OpenCreate(NULL, "file", OS_FILE_FLAG_NONE, OS_READ_WRITE) == - OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (OS_OpenCreate(NULL, "file", OS_FILE_FLAG_NONE, OS_READ_WRITE) == OS_INVALID_POINTER) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-path-arg"; - if (OS_OpenCreate(&fd, g_invalidPath, OS_FILE_FLAG_NONE, OS_READ_WRITE) == - OS_FS_ERR_PATH_INVALID) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (OS_OpenCreate(&fd, g_invalidPath, OS_FILE_FLAG_NONE, OS_READ_WRITE) == OS_FS_ERR_PATH_INVALID) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Path-too-long-arg"; - if (OS_OpenCreate(&fd, g_longPathName, OS_FILE_FLAG_NONE, OS_READ_WRITE) == - OS_FS_ERR_PATH_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (OS_OpenCreate(&fd, g_longPathName, OS_FILE_FLAG_NONE, OS_READ_WRITE) == OS_FS_ERR_PATH_TOO_LONG) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 Name-too-long-arg"; - if (OS_OpenCreate(&fd, g_longFileName, OS_FILE_FLAG_NONE, OS_READ_WRITE) == - OS_FS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (OS_OpenCreate(&fd, g_longFileName, OS_FILE_FLAG_NONE, OS_READ_WRITE) == OS_FS_ERR_NAME_TOO_LONG) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#5 Invalid-permission-arg"; @@ -464,9 +454,9 @@ void UT_os_openfile_test() UT_os_sprintf(g_fNames[0], "%s/Open_InvPerm.txt", g_mntName); res = OS_OpenCreate(&fd, g_fNames[0], OS_FILE_FLAG_NONE, 123); if (res == OS_ERROR) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_remove(g_fNames[0]); @@ -474,21 +464,22 @@ void UT_os_openfile_test() /*-----------------------------------------------------*/ testDesc = "#6 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#7 File-descriptors-full"; continueFlg = 1; - for (i=0; i < OS_MAX_NUM_OPEN_FILES; i++) + for (i = 0; i < OS_MAX_NUM_OPEN_FILES; i++) { memset(g_fNames[i], '\0', sizeof(g_fNames[i])); UT_os_sprintf(g_fNames[i], "%s/tmpFile%d.txt", g_mntName, (int)i); - g_fStatus[i] = OS_OpenCreate(&g_fDescs[i], g_fNames[i], OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); + g_fStatus[i] = + OS_OpenCreate(&g_fDescs[i], g_fNames[i], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); if (g_fStatus[i] < OS_SUCCESS) { testDesc = "#7 File-descriptors-full - File-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); continueFlg = 0; break; } @@ -496,7 +487,7 @@ void UT_os_openfile_test() if (continueFlg && (OS_close(g_fDescs[i]) != OS_SUCCESS)) { testDesc = "#7 File-descriptors-full - File-close failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); continueFlg = 0; break; } @@ -504,7 +495,7 @@ void UT_os_openfile_test() if (continueFlg) { - for (i=0; i <= OS_MAX_NUM_OPEN_FILES; i++) + for (i = 0; i <= OS_MAX_NUM_OPEN_FILES; i++) { g_fStatus[i] = OS_OpenCreate(&g_fDescs[i], g_fNames[i], OS_FILE_FLAG_NONE, OS_WRITE_ONLY); if (g_fStatus[i] < 0) @@ -512,12 +503,12 @@ void UT_os_openfile_test() } if ((i == OS_MAX_NUM_OPEN_FILES) && (g_fStatus[i] < OS_SUCCESS)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ - for (j=0; j < i; j++) + for (j = 0; j < i; j++) { OS_close(g_fDescs[j]); OS_remove(g_fNames[j]); @@ -527,34 +518,33 @@ void UT_os_openfile_test() /*-----------------------------------------------------*/ testDesc = "#8 Nominal"; - g_fStatus[5] = OS_OpenCreate(&g_fDescs[5], g_fNames[5], OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); - g_fStatus[6] = OS_OpenCreate(&g_fDescs[6], g_fNames[6], OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); + g_fStatus[5] = OS_OpenCreate(&g_fDescs[5], g_fNames[5], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + g_fStatus[6] = OS_OpenCreate(&g_fDescs[6], g_fNames[6], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); if ((g_fStatus[5] < OS_SUCCESS) || (g_fStatus[6] < OS_SUCCESS)) { testDesc = "#8 Nominal - File-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_openfile_test_exit_tag; } if ((OS_close(g_fDescs[5]) != OS_SUCCESS) || (OS_close(g_fDescs[6]) != OS_SUCCESS)) { testDesc = "#8 Nominal - File-close failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_openfile_test_exit_tag; } g_fStatus[5] = OS_OpenCreate(&g_fDescs[5], g_fNames[5], OS_FILE_FLAG_NONE, OS_READ_WRITE); g_fStatus[6] = OS_OpenCreate(&g_fDescs[6], g_fNames[6], OS_FILE_FLAG_NONE, OS_WRITE_ONLY); - if ((OS_close(g_fDescs[5]) != OS_SUCCESS) || (OS_close(g_fDescs[6]) != OS_SUCCESS) || + if ((OS_close(g_fDescs[5]) != OS_SUCCESS) || (OS_close(g_fDescs[6]) != OS_SUCCESS) || (OS_remove(g_fNames[5]) != OS_SUCCESS) || (OS_remove(g_fNames[6]) != OS_SUCCESS)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); UT_os_openfile_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -597,15 +587,15 @@ void UT_os_openfile_test() **--------------------------------------------------------------------------------*/ void UT_os_closefile_test() { - const char* testDesc; - char tmpBuff[UT_OS_IO_BUFF_SIZE]; + const char *testDesc; + char tmpBuff[UT_OS_IO_BUFF_SIZE]; /*-----------------------------------------------------*/ testDesc = "API not implemented"; if (OS_close(UT_OBJID_INCORRECT) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_closefile_test_exit_tag; } @@ -613,14 +603,14 @@ void UT_os_closefile_test() testDesc = "#1 Invalid-file-desc-arg"; if (OS_close(UT_OBJID_INCORRECT) == OS_ERR_INVALID_ID) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#3 Nominal"; @@ -628,28 +618,26 @@ void UT_os_closefile_test() memset(g_fNames[0], '\0', sizeof(g_fNames[0])); UT_os_sprintf(g_fNames[0], "%s/Close_Nominal.txt", g_mntName); - g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], - OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); if (g_fStatus[0] < 0) { testDesc = "#3 Nominal - File-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_closefile_test_exit_tag; } if ((OS_close(g_fDescs[0]) != OS_SUCCESS) || (OS_write(g_fDescs[0], tmpBuff, sizeof(tmpBuff)) != OS_ERR_INVALID_ID) || - (OS_read(g_fDescs[0], tmpBuff, sizeof(tmpBuff)) != OS_ERR_INVALID_ID)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + (OS_read(g_fDescs[0], tmpBuff, sizeof(tmpBuff)) != OS_ERR_INVALID_ID)) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); /* Reset test environment */ OS_remove(g_fNames[0]); UT_os_closefile_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -707,14 +695,14 @@ void UT_os_closefile_test() **--------------------------------------------------------------------------------*/ void UT_os_readfile_test() { - const char* testDesc; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; if (OS_read(UT_OBJID_INCORRECT, NULL, 0) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_readfile_test_exit_tag; } @@ -723,19 +711,18 @@ void UT_os_readfile_test() memset(g_fNames[0], '\0', sizeof(g_fNames[0])); UT_os_sprintf(g_fNames[0], "%s/Read_NullPtr.txt", g_mntName); - g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], - OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); if (g_fStatus[0] < 0) { testDesc = "#1 Null-pointer-arg - File-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { if (OS_read(g_fDescs[0], NULL, sizeof(g_readBuff)) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_close(g_fDescs[0]); @@ -746,14 +733,14 @@ void UT_os_readfile_test() testDesc = "#2 Invalid-file-desc-arg"; if (OS_read(UT_OBJID_INCORRECT, g_readBuff, sizeof(g_readBuff)) == OS_ERR_INVALID_ID) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#4 Nominal"; @@ -761,12 +748,11 @@ void UT_os_readfile_test() memset(g_fNames[0], '\0', sizeof(g_fNames[0])); UT_os_sprintf(g_fNames[0], "%s/Read_Nominal.txt", g_mntName); - g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], - OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); if (g_fStatus[0] < 0) { testDesc = "#4 Nominal - File-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_readfile_test_exit_tag; } @@ -775,7 +761,7 @@ void UT_os_readfile_test() if (OS_write(g_fDescs[0], g_writeBuff, strlen(g_writeBuff)) != strlen(g_writeBuff)) { testDesc = "#4 Nominal - File-write failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); /* Reset test environment */ OS_close(g_fDescs[0]); @@ -787,7 +773,7 @@ void UT_os_readfile_test() if (OS_close(g_fDescs[0]) != OS_SUCCESS) { testDesc = "#4 Nominal - File-close failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); /* Reset test environment */ OS_remove(g_fNames[0]); @@ -795,12 +781,11 @@ void UT_os_readfile_test() goto UT_os_readfile_test_exit_tag; } - g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], - OS_FILE_FLAG_NONE, OS_READ_WRITE); + g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], OS_FILE_FLAG_NONE, OS_READ_WRITE); if (g_fStatus[0] < 0) { testDesc = "#4 Nominal - File-open failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); /* Reset test environment */ OS_remove(g_fNames[0]); @@ -811,20 +796,21 @@ void UT_os_readfile_test() memset(g_readBuff, '\0', sizeof(g_readBuff)); if ((OS_read(g_fDescs[0], g_readBuff, strlen(g_writeBuff)) == strlen(g_writeBuff)) && (strncmp(g_readBuff, g_writeBuff, strlen(g_writeBuff)) == 0)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_close(g_fDescs[0]); OS_remove(g_fNames[0]); - UT_OS_LOG("OS_read() success test -- Write to file:\n\t%s\n", g_writeBuff);; - UT_OS_LOG("OS_read() success test -- Read from file:\n\t%s\n", g_readBuff);; + UT_OS_LOG("OS_read() success test -- Write to file:\n\t%s\n", g_writeBuff); + ; + UT_OS_LOG("OS_read() success test -- Read from file:\n\t%s\n", g_readBuff); + ; UT_os_readfile_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -881,14 +867,14 @@ void UT_os_readfile_test() **--------------------------------------------------------------------------------*/ void UT_os_writefile_test() { - const char* testDesc; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; if (OS_write(UT_OBJID_INCORRECT, NULL, 0) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_writefile_test_exit_tag; } @@ -897,19 +883,18 @@ void UT_os_writefile_test() memset(g_fNames[0], '\0', sizeof(g_fNames[0])); UT_os_sprintf(g_fNames[0], "%s/Write_NullPtr.txt", g_mntName); - g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], - OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); if (g_fStatus[0] < 0) { testDesc = "#1 Null-pointer-arg - File-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { if (OS_write(g_fDescs[0], NULL, sizeof(g_writeBuff)) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_close(g_fDescs[0]); @@ -920,14 +905,14 @@ void UT_os_writefile_test() testDesc = "#2 Invalid-file-desc-arg"; if (OS_write(UT_OBJID_INCORRECT, g_writeBuff, sizeof(g_writeBuff)) == OS_ERR_INVALID_ID) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#4 Nominal"; @@ -935,12 +920,11 @@ void UT_os_writefile_test() memset(g_fNames[0], '\0', sizeof(g_fNames[0])); UT_os_sprintf(g_fNames[0], "%s/Write_Nominal.txt", g_mntName); - g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], - OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); if (g_fStatus[0] < OS_SUCCESS) { testDesc = "#4 Nominal - File-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_writefile_test_exit_tag; } @@ -948,7 +932,7 @@ void UT_os_writefile_test() strcpy(g_writeBuff, "TO BE OR NOT TO BE, THAT IS A QUESTION."); if (OS_write(g_fDescs[0], g_writeBuff, strlen(g_writeBuff)) != strlen(g_writeBuff)) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_close(g_fDescs[0]); @@ -960,7 +944,7 @@ void UT_os_writefile_test() if (OS_close(g_fDescs[0]) != OS_SUCCESS) { testDesc = "#4 Nominal - File-close failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); /* Reset test environment */ OS_remove(g_fNames[0]); @@ -968,12 +952,11 @@ void UT_os_writefile_test() goto UT_os_writefile_test_exit_tag; } - g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], - OS_FILE_FLAG_NONE, OS_READ_WRITE); + g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], OS_FILE_FLAG_NONE, OS_READ_WRITE); if (g_fStatus[0] < 0) { testDesc = "#4 Nominal - File-open failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); /* Reset test environment */ OS_remove(g_fNames[0]); @@ -984,20 +967,21 @@ void UT_os_writefile_test() memset(g_readBuff, '\0', sizeof(g_readBuff)); if ((OS_read(g_fDescs[0], g_readBuff, strlen(g_writeBuff)) == strlen(g_writeBuff)) && (strncmp(g_readBuff, g_writeBuff, strlen(g_writeBuff)) == 0)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_close(g_fDescs[0]); OS_remove(g_fNames[0]); - UT_OS_LOG("OS_write() success test -- Write to file:\n\t%s\n", g_writeBuff);; - UT_OS_LOG("OS_write() success test -- Read from file:\n\t%s\n", g_readBuff);; + UT_OS_LOG("OS_write() success test -- Write to file:\n\t%s\n", g_writeBuff); + ; + UT_OS_LOG("OS_write() success test -- Read from file:\n\t%s\n", g_readBuff); + ; UT_os_writefile_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -1052,15 +1036,15 @@ void UT_os_writefile_test() **--------------------------------------------------------------------------------*/ void UT_os_lseekfile_test() { - const char* testDesc; - int32 buffLen=0, pos1=0, pos2=0, pos3=0; + const char *testDesc; + int32 buffLen = 0, pos1 = 0, pos2 = 0, pos3 = 0; /*-----------------------------------------------------*/ testDesc = "API not implemented"; if (OS_lseek(UT_OBJID_INCORRECT, 0, OS_SEEK_CUR) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_lseekfile_test_exit_tag; } @@ -1068,28 +1052,27 @@ void UT_os_lseekfile_test() testDesc = "#1 Invalid-file-desc-arg"; if (OS_lseek(UT_OBJID_INCORRECT, 0, OS_SEEK_SET) == OS_ERR_INVALID_ID) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-whence-arg"; memset(g_fNames[0], '\0', sizeof(g_fNames[0])); UT_os_sprintf(g_fNames[0], "%s/Seek_InvWhence.txt", g_mntName); - g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], - OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); if (g_fStatus[0] < 0) { testDesc = "#2 Invalid-whence-arg - File-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { if (OS_lseek(g_fDescs[0], 0, 123456) == OS_ERROR) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); OS_close(g_fDescs[0]); } @@ -1100,7 +1083,7 @@ void UT_os_lseekfile_test() /*-----------------------------------------------------*/ testDesc = "#3 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#4 Nominal"; @@ -1108,12 +1091,11 @@ void UT_os_lseekfile_test() memset(g_fNames[0], '\0', sizeof(g_fNames[0])); UT_os_sprintf(g_fNames[0], "%s/Seek_Nominal.txt", g_mntName); - g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], - OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); if (g_fStatus[0] < 0) { testDesc = "#4 Nominal - File-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_lseekfile_test_exit_tag; } @@ -1124,19 +1106,18 @@ void UT_os_lseekfile_test() if (OS_write(g_fDescs[0], g_writeBuff, buffLen) != buffLen) { testDesc = "#4 Nominal - File-write failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_lseekfile_test_exit_tag; } pos1 = OS_lseek(g_fDescs[0], 10, OS_SEEK_SET); pos2 = OS_lseek(g_fDescs[0], 7, OS_SEEK_CUR); pos3 = OS_lseek(g_fDescs[0], -16, OS_SEEK_END); - if ((pos1 < 0) || (g_writeBuff[pos1] != 'F') || - (pos2 < 0) || (g_writeBuff[pos2] != 'P') || - (pos3 < 0) || (g_writeBuff[pos3] != 'E')) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + if ((pos1 < 0) || (g_writeBuff[pos1] != 'F') || (pos2 < 0) || (g_writeBuff[pos2] != 'P') || (pos3 < 0) || + (g_writeBuff[pos3] != 'E')) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); /* Reset test environment */ OS_close(g_fDescs[0]); @@ -1144,7 +1125,6 @@ void UT_os_lseekfile_test() UT_os_lseekfile_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -1161,20 +1141,19 @@ void UT_os_lseekfile_test() **--------------------------------------------------------------------------------*/ void UT_os_chmodfile_test() { - const char* testDesc; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; if (OS_chmod(NULL, 0644) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_chmodfile_test_exit_tag; } UT_os_chmodfile_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -1235,47 +1214,46 @@ void UT_os_chmodfile_test() **--------------------------------------------------------------------------------*/ void UT_os_statfile_test() { - const char* testDesc; - os_fstat_t fstats1, fstats2; + const char *testDesc; + os_fstat_t fstats1, fstats2; /*-----------------------------------------------------*/ testDesc = "API not implemented"; if (OS_stat(NULL, NULL) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_statfile_test_exit_tag; } /*-----------------------------------------------------*/ testDesc = "#1 Null-pointer-arg"; - if ((OS_stat(NULL, &fstats1) == OS_INVALID_POINTER) && - (OS_stat(g_fNames[0], NULL) == OS_INVALID_POINTER)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if ((OS_stat(NULL, &fstats1) == OS_INVALID_POINTER) && (OS_stat(g_fNames[0], NULL) == OS_INVALID_POINTER)) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-path-arg"; if (OS_stat(g_invalidPath, &fstats1) == OS_FS_ERR_PATH_INVALID) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Path-too-long-arg"; if (OS_stat(g_longPathName, &fstats1) == OS_FS_ERR_PATH_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#5 Nominal"; @@ -1283,18 +1261,17 @@ void UT_os_statfile_test() memset(g_fNames[0], '\0', sizeof(g_fNames[0])); UT_os_sprintf(g_fNames[0], "%s/Stat_Nominal.txt", g_mntName); - g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], - OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); if (g_fStatus[0] < 0) { testDesc = "#5 Nominal - File-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_statfile_test_exit_tag; } if (OS_stat(g_fNames[0], &fstats1) != OS_SUCCESS) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); goto UT_os_statfile_test_exit_tag; } @@ -1303,34 +1280,33 @@ void UT_os_statfile_test() if (OS_write(g_fDescs[0], g_writeBuff, strlen(g_writeBuff)) != strlen(g_writeBuff)) { testDesc = "#5 Nominal - File-write failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_statfile_test_exit_tag; } if (OS_close(g_fDescs[0]) != OS_SUCCESS) { testDesc = "#5 Nominal - File-close failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_statfile_test_exit_tag; } if (OS_stat(g_fNames[0], &fstats2) != OS_SUCCESS) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); goto UT_os_statfile_test_exit_tag; } if (memcmp(&fstats1, &fstats2, sizeof(fstats1)) != 0) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_remove(g_fNames[0]); UT_os_statfile_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -1389,15 +1365,15 @@ void UT_os_statfile_test() **--------------------------------------------------------------------------------*/ void UT_os_removefile_test() { - os_fstat_t fstats; - const char* testDesc; + os_fstat_t fstats; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; if (OS_remove(NULL) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_removefile_test_exit_tag; } @@ -1405,38 +1381,38 @@ void UT_os_removefile_test() testDesc = "#1 Null-pointer-arg"; if (OS_remove(NULL) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-path-arg"; if (OS_remove(g_invalidPath) == OS_FS_ERR_PATH_INVALID) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Path-too-long-arg"; if (OS_remove(g_longPathName) == OS_FS_ERR_PATH_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 Name-too-long-arg"; if (OS_remove(g_longFileName) == OS_FS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#5 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#6 Nominal"; @@ -1444,12 +1420,11 @@ void UT_os_removefile_test() memset(g_fNames[0], '\0', sizeof(g_fNames[0])); UT_os_sprintf(g_fNames[0], "%s/Remove_Nominal.txt", g_mntName); - g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], - OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); if (g_fStatus[0] < 0) { testDesc = "#6 Nominal - File-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_removefile_test_exit_tag; } @@ -1457,18 +1432,17 @@ void UT_os_removefile_test() if (OS_remove(g_fNames[0]) != OS_SUCCESS) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); goto UT_os_removefile_test_exit_tag; } if (OS_stat(g_fNames[0], &fstats) == OS_ERROR) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); UT_os_removefile_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -1527,15 +1501,15 @@ void UT_os_removefile_test() **--------------------------------------------------------------------------------*/ void UT_os_renamefile_test() { - os_fstat_t fstats; - const char* testDesc; + os_fstat_t fstats; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; if (OS_rename(NULL, NULL) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_renamefile_test_exit_tag; } @@ -1547,40 +1521,39 @@ void UT_os_renamefile_test() UT_os_sprintf(g_fNames[0], "%s/oldName.txt", g_mntName); UT_os_sprintf(g_fNames[1], "%s/newName.txt", g_mntName); - if ((OS_rename(NULL, g_fNames[1]) == OS_INVALID_POINTER) && - (OS_rename(g_fNames[0], NULL) == OS_INVALID_POINTER)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if ((OS_rename(NULL, g_fNames[1]) == OS_INVALID_POINTER) && (OS_rename(g_fNames[0], NULL) == OS_INVALID_POINTER)) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-path-arg"; if (OS_rename(g_invalidPath, g_invalidPath) == OS_FS_ERR_PATH_INVALID) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Path-too-long-arg"; if (OS_rename(g_longPathName, g_longPathName) == OS_FS_ERR_PATH_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 Name-too-long-arg"; if (OS_rename(g_longFileName, g_longFileName) == OS_FS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#5 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#6 Nominal"; @@ -1590,25 +1563,24 @@ void UT_os_renamefile_test() UT_os_sprintf(g_fNames[0], "%s/Rename_Nom_Old.txt", g_mntName); UT_os_sprintf(g_fNames[1], "%s/Rename_Nom_New.txt", g_mntName); - g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], - OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); if (g_fStatus[0] < 0) { testDesc = "#6 Nominal - File-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_renamefile_test_exit_tag; } if (OS_rename(g_fNames[0], g_fNames[1]) != OS_SUCCESS) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); goto UT_os_renamefile_test_exit_tag; } if (OS_stat(g_fNames[0], &fstats) == OS_ERROR) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_close(g_fDescs[0]); @@ -1616,7 +1588,6 @@ void UT_os_renamefile_test() UT_os_renamefile_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -1679,15 +1650,15 @@ void UT_os_renamefile_test() **--------------------------------------------------------------------------------*/ void UT_os_copyfile_test() { - os_fstat_t fstats; - const char* testDesc; + os_fstat_t fstats; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; if (OS_cp(NULL, NULL) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_copyfile_test_exit_tag; } @@ -1699,40 +1670,39 @@ void UT_os_copyfile_test() UT_os_sprintf(g_fNames[0], "%s/oldName.txt", g_mntName); UT_os_sprintf(g_fNames[1], "%s/newName.txt", g_mntName); - if ((OS_cp(NULL, g_fNames[1]) == OS_INVALID_POINTER) && - (OS_cp(g_fNames[0], NULL) == OS_INVALID_POINTER)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if ((OS_cp(NULL, g_fNames[1]) == OS_INVALID_POINTER) && (OS_cp(g_fNames[0], NULL) == OS_INVALID_POINTER)) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-path-arg"; if (OS_cp(g_invalidPath, g_invalidPath) == OS_FS_ERR_PATH_INVALID) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Path-too-long-arg"; if (OS_cp(g_longPathName, g_longPathName) == OS_FS_ERR_PATH_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 Name-too-long-arg"; if (OS_cp(g_longFileName, g_longFileName) == OS_FS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#5 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#6 Nominal"; @@ -1745,36 +1715,35 @@ void UT_os_copyfile_test() if (OS_stat(g_fNames[1], &fstats) != OS_ERROR) { testDesc = "#6 Nominal - File-stat failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_copyfile_test_exit_tag; } - g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], - OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); if (g_fStatus[0] < 0) { testDesc = "#6 Nominal - File-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_copyfile_test_exit_tag; } if (OS_close(g_fDescs[0]) != OS_SUCCESS) { testDesc = "#6 Nominal - File-close failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_copyfile_test_exit_tag; } if (OS_cp(g_fNames[0], g_fNames[1]) != OS_SUCCESS) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); goto UT_os_copyfile_test_exit_tag; } if (OS_stat(g_fNames[1], &fstats) == OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_remove(g_fNames[0]); @@ -1782,7 +1751,6 @@ void UT_os_copyfile_test() UT_os_copyfile_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -1848,15 +1816,15 @@ void UT_os_copyfile_test() **--------------------------------------------------------------------------------*/ void UT_os_movefile_test() { - os_fstat_t fstats; - const char* testDesc; + os_fstat_t fstats; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; if (OS_mv(NULL, NULL) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_movefile_test_exit_tag; } @@ -1868,40 +1836,39 @@ void UT_os_movefile_test() UT_os_sprintf(g_fNames[0], "%s/oldName.txt", g_mntName); UT_os_sprintf(g_fNames[1], "%s/newName.txt", g_mntName); - if ((OS_mv(NULL, g_fNames[1]) == OS_INVALID_POINTER) && - (OS_mv(g_fNames[0], NULL) == OS_INVALID_POINTER)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if ((OS_mv(NULL, g_fNames[1]) == OS_INVALID_POINTER) && (OS_mv(g_fNames[0], NULL) == OS_INVALID_POINTER)) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-path-arg"; if (OS_mv(g_invalidPath, g_invalidPath) == OS_FS_ERR_PATH_INVALID) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Path-too-long-arg"; if (OS_mv(g_longPathName, g_longPathName) == OS_FS_ERR_PATH_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 Name-too-long-arg"; if (OS_mv(g_longFileName, g_longFileName) == OS_FS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#5 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#6 Nominal"; @@ -1914,16 +1881,15 @@ void UT_os_movefile_test() if (OS_stat(g_fNames[1], &fstats) != OS_ERROR) { testDesc = "#6 Nominal - File-stat failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_movefile_test_exit_tag; } - g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], - OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); if (g_fStatus[0] < 0) { testDesc = "#6 Nominal - File-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_movefile_test_exit_tag; } @@ -1931,28 +1897,26 @@ void UT_os_movefile_test() if (OS_close(g_fDescs[0]) != OS_SUCCESS) { testDesc = "#6 Nominal - File-close failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_movefile_test_exit_tag; } if (OS_mv(g_fNames[0], g_fNames[1]) != OS_SUCCESS) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); goto UT_os_movefile_test_exit_tag; } - if ((OS_stat(g_fNames[1], &fstats) == OS_SUCCESS) && - (OS_stat(g_fNames[0], &fstats) != OS_SUCCESS)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if ((OS_stat(g_fNames[1], &fstats) == OS_SUCCESS) && (OS_stat(g_fNames[0], &fstats) != OS_SUCCESS)) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_remove(g_fNames[1]); UT_os_movefile_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -2008,16 +1972,16 @@ void UT_os_movefile_test() **--------------------------------------------------------------------------------*/ void UT_os_outputtofile_test() { - int res; - const char* cmd=NULL; - const char* testDesc; + int res; + const char *cmd = NULL; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; if (OS_ShellOutputToFile(NULL, OS_OBJECT_ID_UNDEFINED) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_outputtofile_test_exit_tag; } @@ -2025,34 +1989,33 @@ void UT_os_outputtofile_test() testDesc = "#1 Null-pointer-arg"; if (OS_ShellOutputToFile(NULL, OS_OBJECT_ID_UNDEFINED) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-file-desc-arg"; if (OS_ShellOutputToFile("ls", UT_OBJID_INCORRECT) == OS_ERR_INVALID_ID) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#4 Nominal"; memset(g_fNames[0], '\0', sizeof(g_fNames[0])); UT_os_sprintf(g_fNames[0], "%s/Output_Nominal.txt", g_mntName); - g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], - OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); if (g_fStatus[0] < 0) { testDesc = "#4 Nominal - File-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_outputtofile_test_exit_tag; } @@ -2060,20 +2023,20 @@ void UT_os_outputtofile_test() res = OS_ShellOutputToFile(cmd, g_fDescs[0]); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_outputtofile_test_exit_tag; } if (res != OS_SUCCESS) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); goto UT_os_outputtofile_test_exit_tag; } if (OS_lseek(g_fDescs[0], 0, OS_SEEK_SET) != OS_SUCCESS) { testDesc = "#4 Nominal - File-lseek failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } else { @@ -2081,15 +2044,15 @@ void UT_os_outputtofile_test() if (OS_read(g_fDescs[0], g_readBuff, sizeof(g_readBuff)) <= 0) { testDesc = "#4 Nominal - File-read failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else if (strstr(g_readBuff, "UT_os_outputtofile_test") != NULL) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); } else { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } } @@ -2099,7 +2062,6 @@ void UT_os_outputtofile_test() UT_os_outputtofile_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -2153,15 +2115,15 @@ void UT_os_outputtofile_test() void UT_os_getfdinfo_test() { OS_file_prop_t fdProps; - const char* testDesc; - const char* fileName="GetInfo_Nom.txt"; + const char * testDesc; + const char * fileName = "GetInfo_Nom.txt"; /*-----------------------------------------------------*/ testDesc = "API not implemented"; if (OS_FDGetInfo(OS_OBJECT_ID_UNDEFINED, NULL) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_getfdinfo_test_exit_tag; } @@ -2171,22 +2133,21 @@ void UT_os_getfdinfo_test() memset(g_fNames[0], '\0', sizeof(g_fNames[0])); UT_os_sprintf(g_fNames[0], "%s/GetInfo_Null.txt", g_mntName); - g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], - OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); if (g_fStatus[0] < 0) { testDesc = "#1 Null-pointer-arg - File-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { if (OS_FDGetInfo(g_fDescs[0], NULL) != OS_INVALID_POINTER) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } else { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); } OS_close(g_fDescs[0]); @@ -2197,56 +2158,53 @@ void UT_os_getfdinfo_test() testDesc = "#2 Invalid-file-desc-arg"; if (OS_FDGetInfo(UT_OBJID_INCORRECT, &fdProps) == OS_ERR_INVALID_ID) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#4 Nominal"; memset(g_fNames[0], '\0', sizeof(g_fNames[0])); UT_os_sprintf(g_fNames[0], "%s/%s", g_mntName, fileName); - g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], - OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); + g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); if (g_fStatus[0] < 0) { testDesc = "#4 Nominal - File-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_getfdinfo_test_exit_tag; } memset(&fdProps, 0x00, sizeof(fdProps)); - if (OS_FDGetInfo(g_fDescs[0], &fdProps) != OS_SUCCESS || - strcmp(fdProps.Path, g_fNames[0]) != 0) + if (OS_FDGetInfo(g_fDescs[0], &fdProps) != OS_SUCCESS || strcmp(fdProps.Path, g_fNames[0]) != 0) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); goto UT_os_getfdinfo_test_exit_tag; } if (OS_close(g_fDescs[0]) != OS_SUCCESS) { testDesc = "#4 Nominal - File-close failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_getfdinfo_test_exit_tag; } memset(&fdProps, 0x00, sizeof(fdProps)); if (OS_FDGetInfo(g_fDescs[0], &fdProps) == OS_ERR_INVALID_ID) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_remove(g_fNames[0]); UT_os_getfdinfo_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -2283,14 +2241,14 @@ void UT_os_getfdinfo_test() **--------------------------------------------------------------------------------*/ void UT_os_checkfileopen_test() { - const char* testDesc; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; if (OS_FileOpenCheck(NULL) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_checkfileopen_test_exit_tag; } @@ -2298,9 +2256,9 @@ void UT_os_checkfileopen_test() testDesc = "#1 Null-pointer-arg"; if (OS_FileOpenCheck(NULL) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 File-not-opened"; @@ -2308,27 +2266,26 @@ void UT_os_checkfileopen_test() memset(g_fNames[0], '\0', sizeof(g_fNames[0])); UT_os_sprintf(g_fNames[0], "%s/FChk_UnOpened.txt", g_mntName); - g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], - OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); if (g_fStatus[0] < 0) { testDesc = "#2 File-not-opened - File-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { if (OS_close(g_fDescs[0]) != OS_SUCCESS) { testDesc = "#2 File-not-opened - File-close failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else if (OS_FileOpenCheck(g_fNames[0]) != OS_ERROR) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } else { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); } } @@ -2341,19 +2298,18 @@ void UT_os_checkfileopen_test() memset(g_fNames[0], '\0', sizeof(g_fNames[0])); UT_os_sprintf(g_fNames[0], "%s/FileChk_Nominal.txt", g_mntName); - g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], - OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); if (g_fStatus[0] < 0) { testDesc = "#3 Nominal - File-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_checkfileopen_test_exit_tag; } if (OS_FileOpenCheck(g_fNames[0]) == OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_close(g_fDescs[0]); @@ -2361,7 +2317,6 @@ void UT_os_checkfileopen_test() UT_os_checkfileopen_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -2396,21 +2351,21 @@ void UT_os_checkfileopen_test() **--------------------------------------------------------------------------------*/ void UT_os_closeallfiles_test() { - const char* testDesc; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; if (OS_CloseAllFiles() == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_closeallfiles_test_exit_tag; } /*-----------------------------------------------------*/ testDesc = "#1 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#2 Nominal"; @@ -2422,31 +2377,27 @@ void UT_os_closeallfiles_test() UT_os_sprintf(g_fNames[1], "%s/CloseAll_Nom_2.txt", g_mntName); UT_os_sprintf(g_fNames[2], "%s/CloseAll_Nom_3.txt", g_mntName); - g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], - OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); - g_fStatus[1] = OS_OpenCreate(&g_fDescs[1], g_fNames[1], - OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); - g_fStatus[2] = OS_OpenCreate(&g_fDescs[2], g_fNames[2], - OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + g_fStatus[1] = OS_OpenCreate(&g_fDescs[1], g_fNames[1], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + g_fStatus[2] = OS_OpenCreate(&g_fDescs[2], g_fNames[2], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); if ((g_fStatus[0] < 0) || (g_fStatus[1] < 0) || (g_fStatus[2] < 0)) { testDesc = "#2 Nominal - File-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_closeallfiles_test_exit_tag; } if (OS_CloseAllFiles() != OS_SUCCESS) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); goto UT_os_closeallfiles_test_exit_tag; } - if ((OS_FileOpenCheck(g_fNames[0]) == OS_ERROR) && - (OS_FileOpenCheck(g_fNames[1]) == OS_ERROR) && + if ((OS_FileOpenCheck(g_fNames[0]) == OS_ERROR) && (OS_FileOpenCheck(g_fNames[1]) == OS_ERROR) && (OS_FileOpenCheck(g_fNames[2]) == OS_ERROR)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_remove(g_fNames[0]); @@ -2455,7 +2406,6 @@ void UT_os_closeallfiles_test() UT_os_closeallfiles_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -2502,14 +2452,14 @@ void UT_os_closeallfiles_test() **--------------------------------------------------------------------------------*/ void UT_os_closefilebyname_test() { - const char* testDesc; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; if (OS_CloseFileByName(NULL) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_closefilebyname_test_exit_tag; } @@ -2517,54 +2467,52 @@ void UT_os_closefilebyname_test() testDesc = "#1 Null-pointer-arg"; if (OS_CloseFileByName(NULL) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-path-arg"; if (OS_CloseFileByName(g_invalidPath) == OS_FS_ERR_PATH_INVALID) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#4 Nominal"; memset(g_fNames[0], '\0', sizeof(g_fNames[0])); UT_os_sprintf(g_fNames[0], "%s/Close_Nominal.txt", g_mntName); - g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], - OS_FILE_FLAG_CREATE|OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + g_fStatus[0] = OS_OpenCreate(&g_fDescs[0], g_fNames[0], OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); if (g_fStatus[0] < 0) { testDesc = "#4 Nominal - File-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_closefilebyname_test_exit_tag; } if (OS_CloseFileByName(g_fNames[0]) != OS_SUCCESS) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); goto UT_os_closefilebyname_test_exit_tag; } if (OS_FileOpenCheck(g_fNames[0]) == OS_ERROR) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_remove(g_fNames[0]); UT_os_closefilebyname_test_exit_tag: return; - } /*================================================================================* diff --git a/src/unit-tests/osfile-test/ut_osfile_fileio_test.h b/src/unit-tests/osfile-test/ut_osfile_fileio_test.h index c21fc77ed..9db8da7f1 100644 --- a/src/unit-tests/osfile-test/ut_osfile_fileio_test.h +++ b/src/unit-tests/osfile-test/ut_osfile_fileio_test.h @@ -80,7 +80,7 @@ void UT_os_closefilebyname_test(void); /*--------------------------------------------------------------------------------*/ -#endif /* _UT_OSFILE_FILEIO_H_ */ +#endif /* _UT_OSFILE_FILEIO_H_ */ /*================================================================================* ** End of File: ut_osfile_fileio.h diff --git a/src/unit-tests/osfile-test/ut_osfile_test.c b/src/unit-tests/osfile-test/ut_osfile_test.c index 3a57b07c8..a2c84d821 100644 --- a/src/unit-tests/osfile-test/ut_osfile_test.c +++ b/src/unit-tests/osfile-test/ut_osfile_test.c @@ -46,14 +46,14 @@ ** Global variables **--------------------------------------------------------------------------------*/ -char* g_fsAddrPtr = NULL; +char *g_fsAddrPtr = NULL; -char g_longPathName[UT_OS_PATH_BUFF_SIZE]; -char g_longFileName[UT_OS_PATH_BUFF_SIZE]; -char g_invalidPath[UT_OS_PATH_BUFF_SIZE]; +char g_longPathName[UT_OS_PATH_BUFF_SIZE]; +char g_longFileName[UT_OS_PATH_BUFF_SIZE]; +char g_invalidPath[UT_OS_PATH_BUFF_SIZE]; -const char* g_devName = "/ramdev3"; -const char* g_mntName = "/drive3"; +const char *g_devName = "/ramdev3"; +const char *g_mntName = "/drive3"; /*--------------------------------------------------------------------------------* ** External function prototypes @@ -64,7 +64,7 @@ const char* g_mntName = "/drive3"; **--------------------------------------------------------------------------------*/ int32 UT_os_setup_fs(void); -void UT_os_teardown_fs(void); +void UT_os_teardown_fs(void); void UT_os_init_file_misc(void); @@ -79,14 +79,16 @@ int32 UT_os_setup_fs() res = OS_mkfs(g_fsAddrPtr, g_devName, "RAM3", 512, 64); if (res != OS_SUCCESS) { - UT_OS_LOG("OS_mkfs() returns %d\n", (int)res);; + UT_OS_LOG("OS_mkfs() returns %d\n", (int)res); + ; goto UT_os_setup_fs_exit_tag; } res = OS_mount(g_devName, g_mntName); if (res != OS_SUCCESS) { - UT_OS_LOG("OS_mount() returns %d\n", (int)res);; + UT_OS_LOG("OS_mount() returns %d\n", (int)res); + ; OS_rmfs(g_devName); goto UT_os_setup_fs_exit_tag; } @@ -108,17 +110,17 @@ void UT_os_teardown_fs() void UT_os_init_file_misc() { memset(g_longPathName, 'Y', sizeof(g_longPathName)); - g_longPathName[0] = '/'; - g_longPathName[sizeof(g_longPathName)-1] = '\0'; + g_longPathName[0] = '/'; + g_longPathName[sizeof(g_longPathName) - 1] = '\0'; /* * The "g_longFileName" should be within the OS_MAX_PATH_LEN limit, * but the filename portion of it exceeds the OS_MAX_FILE_NAME limit. */ memset(g_longFileName, 'Z', sizeof(g_longFileName)); - g_longFileName[0] = '/'; - g_longFileName[4] = '/'; - g_longFileName[OS_MAX_FILE_NAME+9] = '\0'; + g_longFileName[0] = '/'; + g_longFileName[4] = '/'; + g_longFileName[OS_MAX_FILE_NAME + 9] = '\0'; memset(g_invalidPath, '\0', sizeof(g_invalidPath)); strcpy(g_invalidPath, "/InvalidMnt/log1.txt"); diff --git a/src/unit-tests/osfile-test/ut_osfile_test.h b/src/unit-tests/osfile-test/ut_osfile_test.h index 0f61dd53c..a5d2497e3 100644 --- a/src/unit-tests/osfile-test/ut_osfile_test.h +++ b/src/unit-tests/osfile-test/ut_osfile_test.h @@ -57,7 +57,7 @@ /*--------------------------------------------------------------------------------*/ -#endif /* _UT_OSFILE_TEST_H_ */ +#endif /* _UT_OSFILE_TEST_H_ */ /*================================================================================* ** End of File: ut_osfile_test.h diff --git a/src/unit-tests/osfilesys-test/ut_osfilesys_diskio_test.c b/src/unit-tests/osfilesys-test/ut_osfilesys_diskio_test.c index 61ed62874..1002252fd 100644 --- a/src/unit-tests/osfilesys-test/ut_osfilesys_diskio_test.c +++ b/src/unit-tests/osfilesys-test/ut_osfilesys_diskio_test.c @@ -42,17 +42,17 @@ ** External global variables **--------------------------------------------------------------------------------*/ -extern char* g_fsAddrPtr; +extern char *g_fsAddrPtr; extern int32 g_blkSize; extern int32 g_blkCnt; -extern char g_fsLongName[UT_OS_PATH_BUFF_SIZE]; -extern char g_physDriveName[UT_OS_PHYS_NAME_BUFF_SIZE]; +extern char g_fsLongName[UT_OS_PATH_BUFF_SIZE]; +extern char g_physDriveName[UT_OS_PHYS_NAME_BUFF_SIZE]; -extern char g_volNames[UT_OS_FILESYS_LIST_LEN][UT_OS_NAME_BUFF_SIZE]; -extern char g_devNames[UT_OS_FILESYS_LIST_LEN][UT_OS_FILE_BUFF_SIZE]; -extern char g_mntNames[UT_OS_FILESYS_LIST_LEN][UT_OS_FILE_BUFF_SIZE]; +extern char g_volNames[UT_OS_FILESYS_LIST_LEN][UT_OS_NAME_BUFF_SIZE]; +extern char g_devNames[UT_OS_FILESYS_LIST_LEN][UT_OS_FILE_BUFF_SIZE]; +extern char g_mntNames[UT_OS_FILESYS_LIST_LEN][UT_OS_FILE_BUFF_SIZE]; /*--------------------------------------------------------------------------------* ** Global variables @@ -125,8 +125,8 @@ extern char g_mntNames[UT_OS_FILESYS_LIST_LEN][UT_OS_FILE_BUFF_SIZE]; **--------------------------------------------------------------------------------*/ void UT_os_initfs_test() { - const char* testDesc; - int32 res=0, i=0, j=0; + const char *testDesc; + int32 res = 0, i = 0, j = 0; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -134,41 +134,37 @@ void UT_os_initfs_test() res = OS_initfs(NULL, NULL, NULL, g_blkSize, g_blkCnt); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_initfs_test_exit_tag; } /*-----------------------------------------------------*/ testDesc = "#1 Null-pointer-arg"; - if ((OS_initfs(g_fsAddrPtr, NULL, g_volNames[1], 0, 0) == - OS_INVALID_POINTER) && - (OS_initfs(g_fsAddrPtr, g_devNames[1], NULL, 0, 0) == - OS_INVALID_POINTER)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if ((OS_initfs(g_fsAddrPtr, NULL, g_volNames[1], 0, 0) == OS_INVALID_POINTER) && + (OS_initfs(g_fsAddrPtr, g_devNames[1], NULL, 0, 0) == OS_INVALID_POINTER)) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Path-too-long-arg"; - if ((OS_initfs(g_fsAddrPtr, g_fsLongName, g_volNames[2], g_blkSize, g_blkCnt) == - OS_FS_ERR_PATH_TOO_LONG) && - (OS_initfs(g_fsAddrPtr, g_devNames[2], g_fsLongName, g_blkSize, g_blkCnt) == - OS_FS_ERR_PATH_TOO_LONG)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if ((OS_initfs(g_fsAddrPtr, g_fsLongName, g_volNames[2], g_blkSize, g_blkCnt) == OS_FS_ERR_PATH_TOO_LONG) && + (OS_initfs(g_fsAddrPtr, g_devNames[2], g_fsLongName, g_blkSize, g_blkCnt) == OS_FS_ERR_PATH_TOO_LONG)) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#4 Disk-full"; - for (i=0; i <= OS_MAX_FILE_SYSTEMS; i++) + for (i = 0; i <= OS_MAX_FILE_SYSTEMS; i++) { memset(g_devNames[i], '\0', sizeof(g_devNames[i])); UT_os_sprintf(g_devNames[i], "/ramdev%d", (int)i); @@ -181,12 +177,12 @@ void UT_os_initfs_test() /* Only need to check the last call to OS_initfs() */ if (res == OS_FS_ERR_DEVICE_NOT_FREE) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ - for (j=0; j < i; j++) + for (j = 0; j < i; j++) OS_rmfs(g_devNames[j]); /*-----------------------------------------------------*/ @@ -194,18 +190,17 @@ void UT_os_initfs_test() if (OS_initfs(g_fsAddrPtr, g_devNames[5], g_volNames[5], g_blkSize, g_blkCnt) != OS_SUCCESS) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); goto UT_os_initfs_test_exit_tag; } if (OS_rmfs(g_devNames[5]) == OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); UT_os_initfs_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -263,8 +258,8 @@ void UT_os_initfs_test() **--------------------------------------------------------------------------------*/ void UT_os_makefs_test() { - const char* testDesc; - int32 res=0, i=0, j=0; + const char *testDesc; + int32 res = 0, i = 0, j = 0; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -272,7 +267,7 @@ void UT_os_makefs_test() res = OS_mkfs(g_fsAddrPtr, NULL, NULL, g_blkSize, g_blkCnt); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_makefs_test_exit_tag; } @@ -281,30 +276,28 @@ void UT_os_makefs_test() if ((OS_mkfs(g_fsAddrPtr, NULL, g_volNames[1], 0, 0) == OS_INVALID_POINTER) && (OS_mkfs(g_fsAddrPtr, g_devNames[1], NULL, 0, 0) == OS_INVALID_POINTER)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Path-too-long-arg"; - if ((OS_mkfs(g_fsAddrPtr, g_fsLongName, g_volNames[2], g_blkSize, g_blkCnt) == - OS_FS_ERR_PATH_TOO_LONG) && - (OS_mkfs(g_fsAddrPtr, g_devNames[2], g_fsLongName, g_blkSize, g_blkCnt) == - OS_FS_ERR_PATH_TOO_LONG)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if ((OS_mkfs(g_fsAddrPtr, g_fsLongName, g_volNames[2], g_blkSize, g_blkCnt) == OS_FS_ERR_PATH_TOO_LONG) && + (OS_mkfs(g_fsAddrPtr, g_devNames[2], g_fsLongName, g_blkSize, g_blkCnt) == OS_FS_ERR_PATH_TOO_LONG)) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#4 Disk-full"; - for (i=0; i <= OS_MAX_FILE_SYSTEMS; i++) + for (i = 0; i <= OS_MAX_FILE_SYSTEMS; i++) { memset(g_devNames[i], '\0', sizeof(g_devNames[i])); UT_os_sprintf(g_devNames[i], "/ramdev%d", (int)i); @@ -317,12 +310,12 @@ void UT_os_makefs_test() /* Only need to check the last call to OS_mkfs() */ if (res == OS_FS_ERR_DEVICE_NOT_FREE) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ - for (j=0; j < i; j++) + for (j = 0; j < i; j++) OS_rmfs(g_devNames[j]); /*-----------------------------------------------------*/ @@ -330,18 +323,17 @@ void UT_os_makefs_test() if (OS_mkfs(g_fsAddrPtr, g_devNames[5], g_volNames[5], g_blkSize, g_blkCnt) != OS_SUCCESS) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); goto UT_os_makefs_test_exit_tag; } if (OS_rmfs(g_devNames[5]) == OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); UT_os_makefs_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -383,8 +375,8 @@ void UT_os_makefs_test() **--------------------------------------------------------------------------------*/ void UT_os_removefs_test() { - int32 res=0; - const char* testDesc; + int32 res = 0; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -392,7 +384,7 @@ void UT_os_removefs_test() res = OS_rmfs(NULL); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_removefs_test_exit_tag; } @@ -400,17 +392,17 @@ void UT_os_removefs_test() testDesc = "#1 Null-pointer-arg"; if (OS_rmfs(NULL) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-device-arg"; if (OS_rmfs(g_devNames[2]) == OS_ERR_NAME_NOT_FOUND) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Nominal"; @@ -418,22 +410,21 @@ void UT_os_removefs_test() if (OS_mkfs(g_fsAddrPtr, g_devNames[3], g_volNames[3], g_blkSize, g_blkCnt) != OS_SUCCESS) { testDesc = "#3 Nominal - File-system-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_removefs_test_exit_tag; } if ((OS_rmfs(g_devNames[3]) == OS_SUCCESS) && (OS_mkfs(g_fsAddrPtr, g_devNames[3], g_volNames[3], g_blkSize, g_blkCnt) == OS_SUCCESS)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_rmfs(g_devNames[3]); UT_os_removefs_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -480,8 +471,8 @@ void UT_os_removefs_test() **--------------------------------------------------------------------------------*/ void UT_os_mount_test() { - int32 res=0; - const char* testDesc; + int32 res = 0; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -489,26 +480,25 @@ void UT_os_mount_test() res = OS_mount(NULL, NULL); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_mount_test_exit_tag; } /*-----------------------------------------------------*/ testDesc = "#1 Null-pointer-arg"; - if ((OS_mount(NULL, g_mntNames[1]) == OS_INVALID_POINTER) && - (OS_mount(g_devNames[1], NULL) == OS_INVALID_POINTER)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if ((OS_mount(NULL, g_mntNames[1]) == OS_INVALID_POINTER) && (OS_mount(g_devNames[1], NULL) == OS_INVALID_POINTER)) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-device-arg"; if (OS_mount("ramdev0", g_mntNames[2]) == OS_ERR_NAME_NOT_FOUND) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Nominal"; @@ -516,15 +506,15 @@ void UT_os_mount_test() if (OS_mkfs(g_fsAddrPtr, g_devNames[3], g_volNames[3], g_blkSize, g_blkCnt) != OS_SUCCESS) { testDesc = "#3 Nominal - File-system-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_mount_test_exit_tag; } if ((OS_mount(g_devNames[3], g_mntNames[3]) == OS_SUCCESS) && (OS_mount(g_devNames[3], g_mntNames[3]) == OS_ERR_NAME_NOT_FOUND)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_unmount(g_mntNames[3]); @@ -585,8 +575,8 @@ void UT_os_mount_test() **--------------------------------------------------------------------------------*/ void UT_os_unmount_test() { - int32 res=0; - const char* testDesc; + int32 res = 0; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -594,7 +584,7 @@ void UT_os_unmount_test() res = OS_unmount(NULL); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_unmount_test_exit_tag; } @@ -602,25 +592,25 @@ void UT_os_unmount_test() testDesc = "#1 Null-pointer-arg"; if (OS_unmount(NULL) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Path-too-long-arg"; if (OS_unmount(g_fsLongName) == OS_FS_ERR_PATH_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Invalid-mount-point-arg"; if (OS_unmount(g_mntNames[3]) == OS_ERR_NAME_NOT_FOUND) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 Nominal"; @@ -628,23 +618,21 @@ void UT_os_unmount_test() if (OS_mkfs(g_fsAddrPtr, g_devNames[4], g_volNames[4], g_blkSize, g_blkCnt) != OS_SUCCESS) { testDesc = "#3 Nominal - File-system-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_unmount_test_exit_tag; } - if ((OS_mount(g_devNames[4], g_mntNames[4]) == OS_SUCCESS) && - (OS_unmount(g_mntNames[4]) == OS_SUCCESS) && + if ((OS_mount(g_devNames[4], g_mntNames[4]) == OS_SUCCESS) && (OS_unmount(g_mntNames[4]) == OS_SUCCESS) && (OS_unmount(g_mntNames[4]) == OS_ERR_NAME_NOT_FOUND)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_rmfs(g_devNames[4]); UT_os_unmount_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -697,9 +685,9 @@ void UT_os_unmount_test() ** --------------------------------------------------------------------------------*/ void UT_os_getphysdrivename_test() { - int32 res=0; - const char* testDesc; - char physDevName[UT_OS_PHYS_NAME_BUFF_SIZE]; + int32 res = 0; + const char *testDesc; + char physDevName[UT_OS_PHYS_NAME_BUFF_SIZE]; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -707,7 +695,7 @@ void UT_os_getphysdrivename_test() res = OS_FS_GetPhysDriveName(NULL, NULL); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_getphysicaldrivename_test_exit_tag; } @@ -716,25 +704,25 @@ void UT_os_getphysdrivename_test() if ((OS_FS_GetPhysDriveName(NULL, g_mntNames[1]) == OS_INVALID_POINTER) && (OS_FS_GetPhysDriveName(physDevName, NULL) == OS_INVALID_POINTER)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Path-too-long-arg"; if (OS_FS_GetPhysDriveName(physDevName, g_fsLongName) == OS_FS_ERR_PATH_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Invalid-mount-point-arg"; if (OS_FS_GetPhysDriveName(physDevName, g_mntNames[3]) == OS_ERR_NAME_NOT_FOUND) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 Nominal"; @@ -742,23 +730,23 @@ void UT_os_getphysdrivename_test() if (OS_mkfs(g_fsAddrPtr, g_devNames[4], g_volNames[4], g_blkSize, g_blkCnt) != OS_SUCCESS) { testDesc = "#4 Nominal - File-system-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_getphysicaldrivename_test_exit_tag; } if (OS_mount(g_devNames[4], g_mntNames[4]) != OS_SUCCESS) { testDesc = "#4 Nominal - File-system-mount failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_getphysicaldrivename_test_exit_tag; } memset(physDevName, '\0', sizeof(physDevName)); if ((OS_FS_GetPhysDriveName(physDevName, g_mntNames[4]) == OS_SUCCESS) && (strncmp(physDevName, g_physDriveName, strlen(g_physDriveName)) == 0)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_unmount(g_mntNames[4]); @@ -766,7 +754,6 @@ void UT_os_getphysdrivename_test() UT_os_getphysicaldrivename_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -794,8 +781,8 @@ void UT_os_getphysdrivename_test() void UT_os_getfsinfo_test(void) { os_fsinfo_t fsInfo; - int32 res=0; - const char* testDesc; + int32 res = 0; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -803,7 +790,7 @@ void UT_os_getfsinfo_test(void) res = OS_GetFsInfo(&fsInfo); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_getfsinfo_test_exit_tag; } @@ -811,21 +798,20 @@ void UT_os_getfsinfo_test(void) testDesc = "#1 Null-pointer-arg"; if (OS_GetFsInfo(NULL) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Nominal"; if (OS_GetFsInfo(&fsInfo) == OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); UT_os_getfsinfo_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -877,9 +863,9 @@ void UT_os_getfsinfo_test(void) ** --------------------------------------------------------------------------------*/ void UT_os_translatepath_test() { - int32 res=0; - const char* testDesc; - char localPath[UT_OS_LOCAL_PATH_BUFF_SIZE]; + int32 res = 0; + const char *testDesc; + char localPath[UT_OS_LOCAL_PATH_BUFF_SIZE]; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -887,7 +873,7 @@ void UT_os_translatepath_test() res = OS_TranslatePath(NULL, NULL); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_translatepath_test_exit_tag; } @@ -896,42 +882,41 @@ void UT_os_translatepath_test() if ((OS_TranslatePath(NULL, localPath) == OS_INVALID_POINTER) && (OS_TranslatePath(g_mntNames[1], NULL) == OS_INVALID_POINTER)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Path-too-long-arg"; if (OS_TranslatePath(g_fsLongName, localPath) == OS_FS_ERR_PATH_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Invalid-virtual-path-arg"; if ((OS_TranslatePath("cf", localPath) == OS_FS_ERR_PATH_INVALID) && (OS_TranslatePath("/foobar", localPath) == OS_FS_ERR_PATH_INVALID)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 Nominal"; - if (OS_mkfs(g_fsAddrPtr, g_devNames[4], g_volNames[4], g_blkSize, g_blkCnt) != - OS_SUCCESS) + if (OS_mkfs(g_fsAddrPtr, g_devNames[4], g_volNames[4], g_blkSize, g_blkCnt) != OS_SUCCESS) { testDesc = "#4 Nominal - File-system-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_translatepath_test_exit_tag; } if (OS_mount(g_devNames[4], g_mntNames[4]) != OS_SUCCESS) { testDesc = "#4 Nominal - File-system-mount failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); /* Reset test environment */ OS_rmfs(g_devNames[4]); @@ -941,9 +926,9 @@ void UT_os_translatepath_test() if ((OS_TranslatePath(g_mntNames[4], localPath) == OS_SUCCESS) && (strncmp(localPath, g_physDriveName, strlen(g_physDriveName)) == 0)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_unmount(g_mntNames[4]); @@ -951,7 +936,6 @@ void UT_os_translatepath_test() UT_os_translatepath_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -992,16 +976,16 @@ void UT_os_translatepath_test() ** --------------------------------------------------------------------------------*/ void UT_os_checkfs_test() { - const char* testDesc; - int res; - char driveName[UT_OS_PATH_BUFF_SIZE]; + const char *testDesc; + int res; + char driveName[UT_OS_PATH_BUFF_SIZE]; /*-----------------------------------------------------*/ testDesc = "API not implemented"; if (OS_chkfs(NULL, 0) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_checkfs_test_exit_tag; } @@ -1009,25 +993,25 @@ void UT_os_checkfs_test() testDesc = "#1 Null-pointer-arg"; if (OS_chkfs(NULL, 0) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Path-too-long-arg"; memset(driveName, 'A', sizeof(driveName)); - driveName[sizeof(driveName)-1] = '\0'; + driveName[sizeof(driveName) - 1] = '\0'; if (OS_chkfs(driveName, 0) == OS_FS_ERR_PATH_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#4 Nominal"; @@ -1035,14 +1019,14 @@ void UT_os_checkfs_test() if (OS_mkfs(g_fsAddrPtr, g_devNames[5], g_volNames[5], g_blkSize, g_blkCnt) != OS_SUCCESS) { testDesc = "#4 Nominal - File-system-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_checkfs_test_exit_tag; } if (OS_mount(g_devNames[5], g_mntNames[5]) != OS_SUCCESS) { testDesc = "#4 Nominal - File-system-mount failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_checkfs_test_exit_tag; } @@ -1050,15 +1034,15 @@ void UT_os_checkfs_test() if (res == OS_ERR_NOT_IMPLEMENTED) { testDesc = "#4 Nominal - Not implemented in API"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); } else if (res == OS_SUCCESS) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); } else { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } /* Reset test environment */ @@ -1067,7 +1051,6 @@ void UT_os_checkfs_test() UT_os_checkfs_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -1116,14 +1099,14 @@ void UT_os_checkfs_test() ** --------------------------------------------------------------------------------*/ void UT_os_fsblocksfree_test() { - const char* testDesc; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; if (OS_fsBlocksFree(NULL) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_fsblocksfree_test_exit_tag; } @@ -1131,22 +1114,22 @@ void UT_os_fsblocksfree_test() testDesc = "#1 Null-pointer-arg"; if (OS_fsBlocksFree(NULL) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); - /*-----------------------------------------------------*/ + /*-----------------------------------------------------*/ testDesc = "#2 Path-too-long-arg"; if (OS_fsBlocksFree(g_fsLongName) == OS_FS_ERR_PATH_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#4 Nominal"; @@ -1154,21 +1137,21 @@ void UT_os_fsblocksfree_test() if (OS_mkfs(g_fsAddrPtr, g_devNames[4], g_volNames[4], g_blkSize, g_blkCnt) != OS_SUCCESS) { testDesc = "#4 Nominal - File-system-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_fsblocksfree_test_exit_tag; } if (OS_mount(g_devNames[4], g_mntNames[4]) != OS_SUCCESS) { testDesc = "#4 Nominal - File-system-mount failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_fsblocksfree_test_exit_tag; } if (OS_fsBlocksFree(g_mntNames[4]) >= 0) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_unmount(g_mntNames[4]); @@ -1176,7 +1159,6 @@ void UT_os_fsblocksfree_test() UT_os_fsblocksfree_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -1225,15 +1207,15 @@ void UT_os_fsblocksfree_test() ** --------------------------------------------------------------------------------*/ void UT_os_fsbytesfree_test() { - uint64 retBytes=0; - const char* testDesc; + uint64 retBytes = 0; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; if (OS_fsBytesFree(NULL, NULL) == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_fsbytesfree_test_exit_tag; } @@ -1242,22 +1224,22 @@ void UT_os_fsbytesfree_test() if ((OS_fsBytesFree(NULL, &retBytes) == OS_INVALID_POINTER) && (OS_fsBytesFree(g_mntNames[1], NULL) == OS_INVALID_POINTER)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Path-too-long-arg"; if (OS_fsBytesFree(g_fsLongName, &retBytes) == OS_FS_ERR_PATH_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#4 Nominal"; @@ -1265,21 +1247,21 @@ void UT_os_fsbytesfree_test() if (OS_mkfs(g_fsAddrPtr, g_devNames[4], g_volNames[4], g_blkSize, g_blkCnt) != OS_SUCCESS) { testDesc = "#4 Nominal - File-system-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_fsbytesfree_test_exit_tag; } if (OS_mount(g_devNames[4], g_mntNames[4]) != OS_SUCCESS) { testDesc = "#4 Nominal - File-system-mount failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_fsbytesfree_test_exit_tag; } if (OS_fsBytesFree(g_mntNames[4], &retBytes) == OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_unmount(g_mntNames[4]); @@ -1287,7 +1269,6 @@ void UT_os_fsbytesfree_test() UT_os_fsbytesfree_test_exit_tag: return; - } /*================================================================================* diff --git a/src/unit-tests/osfilesys-test/ut_osfilesys_diskio_test.h b/src/unit-tests/osfilesys-test/ut_osfilesys_diskio_test.h index 16c47c009..65e4e4f37 100644 --- a/src/unit-tests/osfilesys-test/ut_osfilesys_diskio_test.h +++ b/src/unit-tests/osfilesys-test/ut_osfilesys_diskio_test.h @@ -37,7 +37,7 @@ ** Macros **--------------------------------------------------------------------------------*/ -#define UT_OS_FILESYS_LIST_LEN (OS_MAX_FILE_SYSTEMS + 10) +#define UT_OS_FILESYS_LIST_LEN (OS_MAX_FILE_SYSTEMS + 10) /*--------------------------------------------------------------------------------* ** Data types @@ -74,7 +74,7 @@ void UT_os_fsbytesfree_test(void); /*--------------------------------------------------------------------------------*/ -#endif /* _UT_OSFILESYS_DISKIO_TEST_H_ */ +#endif /* _UT_OSFILESYS_DISKIO_TEST_H_ */ /*================================================================================* ** End of File: ut_osfilesys_diskio_test.h diff --git a/src/unit-tests/osfilesys-test/ut_osfilesys_test.c b/src/unit-tests/osfilesys-test/ut_osfilesys_test.c index 910dba9ba..719da6629 100644 --- a/src/unit-tests/osfilesys-test/ut_osfilesys_test.c +++ b/src/unit-tests/osfilesys-test/ut_osfilesys_test.c @@ -34,8 +34,8 @@ ** Macros **--------------------------------------------------------------------------------*/ -#define UT_OS_FS_BLOCK_SIZE 512 -#define UT_OS_FS_MAX_BLOCKS 20 +#define UT_OS_FS_BLOCK_SIZE 512 +#define UT_OS_FS_MAX_BLOCKS 20 /*--------------------------------------------------------------------------------* ** Data types @@ -49,17 +49,17 @@ ** Global variables **--------------------------------------------------------------------------------*/ -char* g_fsAddrPtr = NULL; +char *g_fsAddrPtr = NULL; int32 g_blkSize = UT_OS_FS_BLOCK_SIZE; int32 g_blkCnt = UT_OS_FS_MAX_BLOCKS; -char g_fsLongName[UT_OS_PATH_BUFF_SIZE]; -char g_physDriveName[UT_OS_PHYS_NAME_BUFF_SIZE]; +char g_fsLongName[UT_OS_PATH_BUFF_SIZE]; +char g_physDriveName[UT_OS_PHYS_NAME_BUFF_SIZE]; -char g_volNames[UT_OS_FILESYS_LIST_LEN][UT_OS_NAME_BUFF_SIZE]; -char g_devNames[UT_OS_FILESYS_LIST_LEN][UT_OS_FILE_BUFF_SIZE]; -char g_mntNames[UT_OS_FILESYS_LIST_LEN][UT_OS_FILE_BUFF_SIZE]; +char g_volNames[UT_OS_FILESYS_LIST_LEN][UT_OS_NAME_BUFF_SIZE]; +char g_devNames[UT_OS_FILESYS_LIST_LEN][UT_OS_FILE_BUFF_SIZE]; +char g_mntNames[UT_OS_FILESYS_LIST_LEN][UT_OS_FILE_BUFF_SIZE]; /*--------------------------------------------------------------------------------* ** Local function prototypes @@ -74,8 +74,8 @@ void UT_os_init_fs_misc(void); void UT_os_init_fs_misc() { memset(g_fsLongName, 'X', sizeof(g_fsLongName)); - g_fsLongName[0] = '/'; - g_fsLongName[sizeof(g_fsLongName)-1] = '\0'; + g_fsLongName[0] = '/'; + g_fsLongName[sizeof(g_fsLongName) - 1] = '\0'; strcpy(g_devNames[0], "/ramdev0"); strcpy(g_volNames[0], " "); diff --git a/src/unit-tests/osfilesys-test/ut_osfilesys_test.h b/src/unit-tests/osfilesys-test/ut_osfilesys_test.h index 186daf091..71e1074bb 100644 --- a/src/unit-tests/osfilesys-test/ut_osfilesys_test.h +++ b/src/unit-tests/osfilesys-test/ut_osfilesys_test.h @@ -56,7 +56,7 @@ /*--------------------------------------------------------------------------------*/ -#endif /* _UT_OSFILESYS_TEST_H_ */ +#endif /* _UT_OSFILESYS_TEST_H_ */ /*================================================================================* ** End of File: ut_osfilesys_test.h diff --git a/src/unit-tests/osloader-test/ut_module.c b/src/unit-tests/osloader-test/ut_module.c index 03838c3cf..72ae8ac68 100644 --- a/src/unit-tests/osloader-test/ut_module.c +++ b/src/unit-tests/osloader-test/ut_module.c @@ -20,11 +20,9 @@ void MODULE_NAME(void) { - volatile int i; - i = 1; - i = i + 1; /* squelch set-but-not-used compiler warning */ - (void)i; - return; + volatile int i; + i = 1; + i = i + 1; /* squelch set-but-not-used compiler warning */ + (void)i; + return; } - - diff --git a/src/unit-tests/osloader-test/ut_osloader_module_test.c b/src/unit-tests/osloader-test/ut_osloader_module_test.c index c45ac9ee0..ba8d6ffcc 100644 --- a/src/unit-tests/osloader-test/ut_osloader_module_test.c +++ b/src/unit-tests/osloader-test/ut_osloader_module_test.c @@ -67,14 +67,14 @@ **--------------------------------------------------------------------------------*/ void UT_os_module_load_test() { - int i; - int32 res = 0; - const char* testDesc; - uint32 test_setup_invalid = 0; - osal_id_t module_id; - osal_id_t module_id2; - char module_name[UT_OS_NAME_BUFF_SIZE]; - char module_file_name[UT_OS_PATH_BUFF_SIZE]; + int i; + int32 res = 0; + const char *testDesc; + uint32 test_setup_invalid = 0; + osal_id_t module_id; + osal_id_t module_id2; + char module_name[UT_OS_NAME_BUFF_SIZE]; + char module_file_name[UT_OS_PATH_BUFF_SIZE]; /*-----------------------------------------------------*/ testDesc = "API Not implemented"; @@ -82,7 +82,7 @@ void UT_os_module_load_test() res = OS_ModuleLoad(0, "TestModule", UT_OS_GENERIC_MODULE_NAME1); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_module_load_test_exit_tag; } @@ -91,54 +91,53 @@ void UT_os_module_load_test() res = OS_ModuleLoad(0, "TestModule", UT_OS_GENERIC_MODULE_NAME1); if (res == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Null-pointer-arg-2"; res = OS_ModuleLoad(&module_id, 0, UT_OS_GENERIC_MODULE_NAME1); if (res == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Null-pointer-arg-3"; res = OS_ModuleLoad(&module_id, "TestModule", 0); if (res == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 No-free-IDs"; /* Setup */ - for ( i = 0; i< OS_MAX_MODULES; i++ ) + for (i = 0; i < OS_MAX_MODULES; i++) { snprintf(module_name, sizeof(module_name), UT_OS_GENERIC_MODULE_NAME_TEMPLATE, i); snprintf(module_file_name, sizeof(module_file_name), UT_OS_GENERIC_MODULE_FILE_TEMPLATE, i); res = OS_ModuleLoad(&module_id, module_name, module_file_name); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#4 No-free-IDs - Module Load failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); test_setup_invalid = 1; break; } } - if ( test_setup_invalid == 0 ) + if (test_setup_invalid == 0) { res = OS_ModuleLoad(&module_id, "OneTooMany", UT_OS_GENERIC_MODULE_NAME2); if (res == OS_ERR_NO_FREE_IDS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } /* Reset test environment */ OS_DeleteAllObjects(); @@ -148,18 +147,18 @@ void UT_os_module_load_test() /* Setup */ res = OS_ModuleLoad(&module_id2, "DUPLICATE", UT_OS_GENERIC_MODULE_NAME2); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#5 Duplicate-name - Module Load failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_ModuleLoad(&module_id, "DUPLICATE", UT_OS_GENERIC_MODULE_NAME2); if (res == OS_ERR_NAME_TAKEN) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ res = OS_ModuleUnload(module_id2); @@ -168,23 +167,22 @@ void UT_os_module_load_test() /*-----------------------------------------------------*/ testDesc = "#6 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#7 Nominal"; res = OS_ModuleLoad(&module_id, "Good", UT_OS_GENERIC_MODULE_NAME2); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_SUCCESS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ res = OS_ModuleUnload(module_id); UT_os_module_load_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -197,9 +195,9 @@ void UT_os_module_load_test() **--------------------------------------------------------------------------------*/ void UT_os_module_unload_test() { - int32 res = 0; - const char* testDesc; - osal_id_t module_id; + int32 res = 0; + const char *testDesc; + osal_id_t module_id; /*-----------------------------------------------------*/ testDesc = "API Not implemented"; @@ -207,7 +205,7 @@ void UT_os_module_unload_test() res = OS_ModuleUnload(OS_OBJECT_ID_UNDEFINED); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_module_unload_test_exit_tag; } @@ -215,38 +213,37 @@ void UT_os_module_unload_test() testDesc = "#1 Invalid-ID-arg"; res = OS_ModuleUnload(UT_OBJID_INCORRECT); - if ( res == OS_ERR_INVALID_ID ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_ERR_INVALID_ID) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#3 Nominal"; /* Setup */ res = OS_ModuleLoad(&module_id, "Good", UT_OS_GENERIC_MODULE_NAME2); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#3 Nominal - Module Load failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_ModuleUnload(module_id); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_SUCCESS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } UT_os_module_unload_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -259,10 +256,10 @@ void UT_os_module_unload_test() **--------------------------------------------------------------------------------*/ void UT_os_module_info_test() { - int32 res = 0; - const char* testDesc; - osal_id_t module_id; - OS_module_prop_t module_info; + int32 res = 0; + const char * testDesc; + osal_id_t module_id; + OS_module_prop_t module_info; /*-----------------------------------------------------*/ testDesc = "API Not implemented"; @@ -270,7 +267,7 @@ void UT_os_module_info_test() res = OS_ModuleInfo(OS_OBJECT_ID_UNDEFINED, &module_info); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_module_info_test_exit_tag; } @@ -278,44 +275,43 @@ void UT_os_module_info_test() testDesc = "#1 Invalid-pointer-arg"; res = OS_ModuleInfo(OS_OBJECT_ID_UNDEFINED, NULL); - if ( res == OS_INVALID_POINTER ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_INVALID_POINTER) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-ID-arg"; res = OS_ModuleInfo(UT_OBJID_INCORRECT, &module_info); - if ( res == OS_ERR_INVALID_ID ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_ERR_INVALID_ID) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Nominal"; /* Setup */ res = OS_ModuleLoad(&module_id, "Good", UT_OS_GENERIC_MODULE_NAME2); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { testDesc = "#3 Nominal - Module Load failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { res = OS_ModuleInfo(module_id, &module_info); - if ( res == OS_SUCCESS ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_SUCCESS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); res = OS_ModuleUnload(module_id); } UT_os_module_info_test_exit_tag: return; - } /*================================================================================* diff --git a/src/unit-tests/osloader-test/ut_osloader_module_test.h b/src/unit-tests/osloader-test/ut_osloader_module_test.h index ea435a94c..c27ee25b1 100644 --- a/src/unit-tests/osloader-test/ut_osloader_module_test.h +++ b/src/unit-tests/osloader-test/ut_osloader_module_test.h @@ -59,7 +59,7 @@ void UT_os_module_info_test(void); /*--------------------------------------------------------------------------------*/ -#endif /* _UT_OSLOADER_MODULE_TEST_H_ */ +#endif /* _UT_OSLOADER_MODULE_TEST_H_ */ /*================================================================================* ** End of File: ut_osloader_module_test.h diff --git a/src/unit-tests/osloader-test/ut_osloader_symtable_test.c b/src/unit-tests/osloader-test/ut_osloader_symtable_test.c index 0ec59dae9..aa951f616 100644 --- a/src/unit-tests/osloader-test/ut_osloader_symtable_test.c +++ b/src/unit-tests/osloader-test/ut_osloader_symtable_test.c @@ -66,10 +66,10 @@ void UT_os_symbol_lookup_test() { - int32 res = 0; - const char* testDesc; - cpuaddr symbol_addr; - osal_id_t module_id; + int32 res = 0; + const char *testDesc; + cpuaddr symbol_addr; + osal_id_t module_id; /*-----------------------------------------------------*/ testDesc = "API Not implemented"; @@ -77,7 +77,7 @@ void UT_os_symbol_lookup_test() res = OS_SymbolLookup(&symbol_addr, "main"); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_symbol_lookup_test_exit_tag; } @@ -85,45 +85,45 @@ void UT_os_symbol_lookup_test() testDesc = "#1 Invalid-pointer-arg-1"; res = OS_SymbolLookup(0, "main"); - if ( res == OS_INVALID_POINTER ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_INVALID_POINTER) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-pointer-arg-2"; res = OS_SymbolLookup(&symbol_addr, 0); - if ( res == OS_INVALID_POINTER ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_INVALID_POINTER) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Symbol-not-found"; res = OS_SymbolLookup(&symbol_addr, "ThisSymbolIsNotFound"); - if ( res == OS_ERROR ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_ERROR) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 Nominal"; /* Setup */ res = OS_ModuleLoad(&module_id, "Mod1", UT_OS_GENERIC_MODULE_NAME2); - if ( res != OS_SUCCESS ) + if (res != OS_SUCCESS) { - UT_OS_TEST_RESULT( "#4 Nominal - Module Load failed", UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT("#4 Nominal - Module Load failed", UTASSERT_CASETYPE_TSF); } else { res = OS_SymbolLookup(&symbol_addr, "module1"); if (res == OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ res = OS_ModuleUnload(module_id); @@ -131,7 +131,6 @@ void UT_os_symbol_lookup_test() UT_os_symbol_lookup_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -145,8 +144,8 @@ void UT_os_symbol_lookup_test() **--------------------------------------------------------------------------------*/ void UT_os_symbol_table_dump_test() { - int32 res = 0; - const char* testDesc; + int32 res = 0; + const char *testDesc; /* * Note that even if the functionality is not implemented, @@ -157,20 +156,20 @@ void UT_os_symbol_table_dump_test() /*-----------------------------------------------------*/ testDesc = "#1 Invalid-pointer-arg"; - res = OS_SymbolTableDump(0,10000); - if ( res == OS_INVALID_POINTER ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + res = OS_SymbolTableDump(0, 10000); + if (res == OS_INVALID_POINTER) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Invalid-path"; res = OS_SymbolTableDump("/this/path/is/invalid.dat", 10000); - if ( res == OS_FS_ERR_PATH_INVALID ) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (res == OS_FS_ERR_PATH_INVALID) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Nominal"; @@ -179,15 +178,15 @@ void UT_os_symbol_table_dump_test() if (res == OS_ERR_NOT_IMPLEMENTED) { /* allowed, not applicable on this system */ - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); } - else if ( res == OS_SUCCESS ) + else if (res == OS_SUCCESS) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); } else { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } } diff --git a/src/unit-tests/osloader-test/ut_osloader_symtable_test.h b/src/unit-tests/osloader-test/ut_osloader_symtable_test.h index 94938bf63..eae16753a 100644 --- a/src/unit-tests/osloader-test/ut_osloader_symtable_test.h +++ b/src/unit-tests/osloader-test/ut_osloader_symtable_test.h @@ -55,10 +55,10 @@ void UT_os_symbol_lookup_test(void); void UT_os_symbol_table_dump_test(void); - + /*--------------------------------------------------------------------------------*/ -#endif /* _UT_OSLOADER_SYMTABLE_TEST_H_ */ +#endif /* _UT_OSLOADER_SYMTABLE_TEST_H_ */ /*================================================================================* ** End of File: ut_osloader_symtable_test.h diff --git a/src/unit-tests/osloader-test/ut_osloader_test.h b/src/unit-tests/osloader-test/ut_osloader_test.h index be73cd845..07cca7b47 100644 --- a/src/unit-tests/osloader-test/ut_osloader_test.h +++ b/src/unit-tests/osloader-test/ut_osloader_test.h @@ -57,7 +57,7 @@ /*--------------------------------------------------------------------------------*/ -#endif /* _UT_OSLOADER_TEST_H_ */ +#endif /* _UT_OSLOADER_TEST_H_ */ /*================================================================================* ** End of File: ut_osloader_test.h diff --git a/src/unit-tests/osloader-test/ut_osloader_test_platforms.h b/src/unit-tests/osloader-test/ut_osloader_test_platforms.h index bda449bd5..f15858a3b 100644 --- a/src/unit-tests/osloader-test/ut_osloader_test_platforms.h +++ b/src/unit-tests/osloader-test/ut_osloader_test_platforms.h @@ -35,14 +35,15 @@ ** Macros **--------------------------------------------------------------------------------*/ -#define UT_OS_GENERIC_MODULE_DIR "/utmod/" -#define UT_OS_GENERIC_MODULE_BASENAME "MODULE" +#define UT_OS_GENERIC_MODULE_DIR "/utmod/" +#define UT_OS_GENERIC_MODULE_BASENAME "MODULE" -#define UT_OS_GENERIC_MODULE_NAME1 UT_OS_GENERIC_MODULE_DIR UT_OS_GENERIC_MODULE_BASENAME "0" OS_MODULE_FILE_EXTENSION -#define UT_OS_GENERIC_MODULE_NAME2 UT_OS_GENERIC_MODULE_DIR UT_OS_GENERIC_MODULE_BASENAME "1" OS_MODULE_FILE_EXTENSION +#define UT_OS_GENERIC_MODULE_NAME1 UT_OS_GENERIC_MODULE_DIR UT_OS_GENERIC_MODULE_BASENAME "0" OS_MODULE_FILE_EXTENSION +#define UT_OS_GENERIC_MODULE_NAME2 UT_OS_GENERIC_MODULE_DIR UT_OS_GENERIC_MODULE_BASENAME "1" OS_MODULE_FILE_EXTENSION -#define UT_OS_GENERIC_MODULE_NAME_TEMPLATE UT_OS_GENERIC_MODULE_BASENAME "%d" -#define UT_OS_GENERIC_MODULE_FILE_TEMPLATE UT_OS_GENERIC_MODULE_DIR UT_OS_GENERIC_MODULE_NAME_TEMPLATE OS_MODULE_FILE_EXTENSION +#define UT_OS_GENERIC_MODULE_NAME_TEMPLATE UT_OS_GENERIC_MODULE_BASENAME "%d" +#define UT_OS_GENERIC_MODULE_FILE_TEMPLATE \ + UT_OS_GENERIC_MODULE_DIR UT_OS_GENERIC_MODULE_NAME_TEMPLATE OS_MODULE_FILE_EXTENSION /*--------------------------------------------------------------------------------* ** Data types @@ -62,7 +63,7 @@ /*--------------------------------------------------------------------------------*/ -#endif /* _UT_OSLOADER_TEST_PLATFORMS_H_ */ +#endif /* _UT_OSLOADER_TEST_PLATFORMS_H_ */ /*================================================================================* ** End of File: ut_osloader_test_platforms.h diff --git a/src/unit-tests/osnetwork-test/ut_osnetwork_misc_test.c b/src/unit-tests/osnetwork-test/ut_osnetwork_misc_test.c index f601503a6..c58b98780 100644 --- a/src/unit-tests/osnetwork-test/ut_osnetwork_misc_test.c +++ b/src/unit-tests/osnetwork-test/ut_osnetwork_misc_test.c @@ -80,8 +80,8 @@ **--------------------------------------------------------------------------------*/ void UT_os_networkgetid_test() { - int32 res = 0; - const char* testDesc; + int32 res = 0; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API Not implemented"; @@ -89,14 +89,14 @@ void UT_os_networkgetid_test() res = OS_NetworkGetID(); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_networkgetid_test_exit_tag; } /*-----------------------------------------------------*/ testDesc = "#1 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#2 Nominal"; @@ -106,11 +106,10 @@ void UT_os_networkgetid_test() /* NOTE: This API does not return error codes. * Any return value could be valid */ UT_OS_LOG("OS_NetworkGetID() return value=%ld", (long)res); - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_MIR); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_MIR); UT_os_networkgetid_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -151,9 +150,9 @@ void UT_os_networkgetid_test() **--------------------------------------------------------------------------------*/ void UT_os_networkgethostname_test() { - int32 res = 0; - const char* testDesc; - char buffer[UT_OS_IO_BUFF_SIZE]; + int32 res = 0; + const char *testDesc; + char buffer[UT_OS_IO_BUFF_SIZE]; /*-----------------------------------------------------*/ testDesc = "API Not implemented"; @@ -161,46 +160,44 @@ void UT_os_networkgethostname_test() res = OS_NetworkGetHostName(buffer, sizeof(buffer)); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_networkgethostname_test_exit_tag; } - /*-----------------------------------------------------*/ testDesc = "#1 Null-pointer-arg"; res = OS_NetworkGetHostName(NULL, 0); if (res == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Zero-name-length-arg"; res = OS_NetworkGetHostName(buffer, 0); if (res == OS_ERROR) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 OS-call-failure"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#4 Nominal"; res = OS_NetworkGetHostName(buffer, sizeof(buffer)); if (res == OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); UT_os_networkgethostname_test_exit_tag: return; - } /*================================================================================* diff --git a/src/unit-tests/osnetwork-test/ut_osnetwork_misc_test.h b/src/unit-tests/osnetwork-test/ut_osnetwork_misc_test.h index c862360d8..1ecca7390 100644 --- a/src/unit-tests/osnetwork-test/ut_osnetwork_misc_test.h +++ b/src/unit-tests/osnetwork-test/ut_osnetwork_misc_test.h @@ -58,7 +58,7 @@ void UT_os_networkgethostname_test(void); /*--------------------------------------------------------------------------------*/ -#endif /* _UT_OSNETWORK_MISC_TEST_H_ */ +#endif /* _UT_OSNETWORK_MISC_TEST_H_ */ /*================================================================================* ** End of File: ut_osnetwork_misc_test.h diff --git a/src/unit-tests/osnetwork-test/ut_osnetwork_test.h b/src/unit-tests/osnetwork-test/ut_osnetwork_test.h index 490edf3a6..447e9a9a3 100644 --- a/src/unit-tests/osnetwork-test/ut_osnetwork_test.h +++ b/src/unit-tests/osnetwork-test/ut_osnetwork_test.h @@ -56,7 +56,7 @@ /*--------------------------------------------------------------------------------*/ -#endif /* _UT_OSNETWORK_TEST_H_ */ +#endif /* _UT_OSNETWORK_TEST_H_ */ /*================================================================================* ** End of File: ut_osnetwork_test.h diff --git a/src/unit-tests/osprintf-test/ut_osprintf.c b/src/unit-tests/osprintf-test/ut_osprintf.c index c7f840aae..f6da52c2b 100644 --- a/src/unit-tests/osprintf-test/ut_osprintf.c +++ b/src/unit-tests/osprintf-test/ut_osprintf.c @@ -43,13 +43,13 @@ FILE *UT_logfile; ** Global variables */ unsigned OS_printf_enabled = 1; -int ut_passed; -int ut_failed; -char cMsg[UT_MAX_MESSAGE_LENGTH]; -char cNum[UT_MAX_MESSAGE_LENGTH]; -char strg_buf[BUF_LEN]; -char trunc_buf[BUF_LEN]; -char fill_strg[BUF_LEN]; +int ut_passed; +int ut_failed; +char cMsg[UT_MAX_MESSAGE_LENGTH]; +char cNum[UT_MAX_MESSAGE_LENGTH]; +char strg_buf[BUF_LEN]; +char trunc_buf[BUF_LEN]; +char fill_strg[BUF_LEN]; /* ** Functions @@ -168,8 +168,7 @@ void UT_Text(char *out_text) /* ** Output result of a test */ -void UT_Report(int test, char *fun_name, char *info, - char *test_num, char *test_seq) +void UT_Report(int test, char *fun_name, char *info, char *test_num, char *test_seq) { if (test == UT_PASS) { @@ -208,21 +207,21 @@ void UT_Report(int test, char *fun_name, char *info, */ void UT_itoa(int value, char *string, int radix, int out_len) { - char revertedStr[50]; - int revertedLength = 0; - unsigned int length = 0; - unsigned int neg = 0; - unsigned int digit_value = 0; + char revertedStr[50]; + int revertedLength = 0; + unsigned int length = 0; + unsigned int neg = 0; + unsigned int digit_value = 0; unsigned int uvalue; if ((radix == 10) && (value < 0)) { - neg = 1; + neg = 1; uvalue = -value; } else { - uvalue = (unsigned int) value; + uvalue = (unsigned int)value; } revertedLength = 0; @@ -296,8 +295,7 @@ void UT_ReportFailures(void) UT_Text(cMsg); #ifndef OSP_ARINC653 - printf("\nosprintf PASSED %d tests.\nosprintf FAILED %d tests.\n\n", - ut_passed, ut_failed); + printf("\nosprintf PASSED %d tests.\nosprintf FAILED %d tests.\n\n", ut_passed, ut_failed); #endif } diff --git a/src/unit-tests/osprintf-test/ut_osprintf.h b/src/unit-tests/osprintf-test/ut_osprintf.h index 0a1f5785d..1a691fd79 100644 --- a/src/unit-tests/osprintf-test/ut_osprintf.h +++ b/src/unit-tests/osprintf-test/ut_osprintf.h @@ -66,18 +66,18 @@ int putchar(int); /* ** Macro Definitions */ -#define BUF_LEN 200 +#define BUF_LEN 200 #define UT_MAX_MESSAGE_LENGTH 300 -#define UT_TRUE 1 -#define UT_FALSE 0 -#define UT_PASS 0 -#define UT_FAIL 1 +#define UT_TRUE 1 +#define UT_FALSE 0 +#define UT_PASS 0 +#define UT_FAIL 1 /* ** Function prototypes */ void init_test(void); -int check_test(char *expected, char *actual); +int check_test(char *expected, char *actual); void UT_osprintf_d(void); void UT_osprintf_i(void); @@ -104,8 +104,7 @@ void UT_osprintf_printf(void); #endif void UT_Text(char *out_text); -void UT_Report(int test, char *fun_name, char *info, - char *test_num, char *test_seq); +void UT_Report(int test, char *fun_name, char *info, char *test_num, char *test_seq); void UT_itoa(int value, char *string, int radix, int out_len); void UT_ReportFailures(void); diff --git a/src/unit-tests/osprintf-test/ut_osprintf_c.c b/src/unit-tests/osprintf-test/ut_osprintf_c.c index e7b582267..28990c2e4 100644 --- a/src/unit-tests/osprintf-test/ut_osprintf_c.c +++ b/src/unit-tests/osprintf-test/ut_osprintf_c.c @@ -36,18 +36,17 @@ extern char trunc_buf[]; void UT_osprintf_c(void) { char *test_fmt = "c"; /* Test format character(s) */ - int i; + int i; struct { char *test_num; /* Test identifier; sequential numbers */ - char test_val; /* Test value */ - int max_len; /* Maximum output string length */ + char test_val; /* Test value */ + int max_len; /* Maximum output string length */ char *format; /* Format string */ char *expected; /* Expected result */ char *description; /* Test description */ - } osp_tests[] = - { + } osp_tests[] = { {"01", 'k', 1, "%c", "k", "%c"}, {"02", 'w', 5, "$$$%c$$$", "$$$w$$$", "%c embedded"}, {"03", '?', 19, "%20c", " ?", "%c with minimum field size"}, @@ -63,10 +62,7 @@ void UT_osprintf_c(void) /* Perform sprintf test */ init_test(); sprintf(strg_buf, osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(osp_tests[i].expected, strg_buf), - "SPRINTF", - osp_tests[i].description, - test_fmt, + UT_Report(check_test(osp_tests[i].expected, strg_buf), "SPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); /* Truncate expected string in preparation for snprintf test */ @@ -79,12 +75,8 @@ void UT_osprintf_c(void) /* Perform snprintf test */ init_test(); - snprintf(strg_buf, osp_tests[i].max_len, - osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(trunc_buf, strg_buf), - "SNPRINTF", - osp_tests[i].description, - test_fmt, + snprintf(strg_buf, osp_tests[i].max_len, osp_tests[i].format, osp_tests[i].test_val); + UT_Report(check_test(trunc_buf, strg_buf), "SNPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); } } diff --git a/src/unit-tests/osprintf-test/ut_osprintf_d.c b/src/unit-tests/osprintf-test/ut_osprintf_d.c index fd705c5d9..ef33168d6 100644 --- a/src/unit-tests/osprintf-test/ut_osprintf_d.c +++ b/src/unit-tests/osprintf-test/ut_osprintf_d.c @@ -36,18 +36,17 @@ extern char trunc_buf[]; void UT_osprintf_d(void) { char *test_fmt = "d"; /* Test format character(s) */ - int i; + int i; struct { char *test_num; /* Test identifier; sequential numbers */ - int test_val; /* Test value */ - int max_len; /* Maximum output string length */ + int test_val; /* Test value */ + int max_len; /* Maximum output string length */ char *format; /* Format string */ char *expected; /* Expected result */ char *description; /* Test description */ - } osp_tests[] = - { + } osp_tests[] = { {"01", 98765, 5, "%d", "98765", "%d only"}, {"02", 46372, 8, "$$$%d$$$", "$$$46372$$$", "%d embedded, positive value"}, {"03", 98765, 5, "% d", " 98765", "%d with space for sign, positive value"}, @@ -55,28 +54,45 @@ void UT_osprintf_d(void) {"05", 91827, 4, "%4d", "91827", "%d with minimum field size < number of digits, positive value"}, {"06", 33225, 8, "%.10d", "0000033225", "%d with precision field size > number of digits, positive value"}, {"07", 33225, 5, "%.3d", "33225", "%d with precision field size < number of digits, positive value"}, - {"08", 12345, 8, "%9.7d", " 0012345", "%d with minimum field size > precision field size > number of digits, positive value"}, - {"09", 12345, 6, "%9.3d", " 12345", "%d with minimum field size > number of digits > precision field size, positive value"}, - {"10", 12345, 3, "%4.2d", "12345", "%d with number of digits > minimum field size > precision field size, positive value"}, - {"11", 12345, 7, "%7.9d", "000012345", "%d with precision field size > minimum field size > number of digits, positive value"}, - {"12", 12345, 8, "%3.9d", "000012345", "%d with precision field size > number of digits > minimum field size, positive value"}, - {"13", 12345, 4, "%2.4d", "12345", "%d with number of digits > precision field size > minimum field size, positive value"}, - {"14", 98765, 17, "%-.20d", "00000000000000098765", "%d with left-justify and precision field size > number of digits, positive value"}, - {"15", 98765, 5, "%-.3d", "98765", "%d with left-justify and precision field size < number of digits, positive value"}, + {"08", 12345, 8, "%9.7d", " 0012345", + "%d with minimum field size > precision field size > number of digits, positive value"}, + {"09", 12345, 6, "%9.3d", " 12345", + "%d with minimum field size > number of digits > precision field size, positive value"}, + {"10", 12345, 3, "%4.2d", "12345", + "%d with number of digits > minimum field size > precision field size, positive value"}, + {"11", 12345, 7, "%7.9d", "000012345", + "%d with precision field size > minimum field size > number of digits, positive value"}, + {"12", 12345, 8, "%3.9d", "000012345", + "%d with precision field size > number of digits > minimum field size, positive value"}, + {"13", 12345, 4, "%2.4d", "12345", + "%d with number of digits > precision field size > minimum field size, positive value"}, + {"14", 98765, 17, "%-.20d", "00000000000000098765", + "%d with left-justify and precision field size > number of digits, positive value"}, + {"15", 98765, 5, "%-.3d", "98765", + "%d with left-justify and precision field size < number of digits, positive value"}, {"16", 98765, 4, "%+d", "+98765", "%d with sign, positive value"}, {"17", 46372, 9, "$$$%+d$$$", "$$$+46372$$$", "%d sign and embedded, positive value"}, {"18", 91827, 8, "%+8d", " +91827", "%d with sign and minimum field size > number of digits, positive value"}, {"19", 91827, 5, "%+4d", "+91827", "%d with sign and minimum field size < number of digits, positive value"}, - {"20", 33225, 10, "%+.10d", "+0000033225", "%d with sign and precision field size > number of digits, positive value"}, + {"20", 33225, 10, "%+.10d", "+0000033225", + "%d with sign and precision field size > number of digits, positive value"}, {"21", 33225, 4, "%+.3d", "+33225", "%d with sign and precision field size < number of digits, positive value"}, - {"22", 12345, 6, "%+9.7d", " +0012345", "%d with sign and minimum field size > precision field size > number of digits, positive value"}, - {"23", 12345, 7, "%+9.3d", " +12345", "%d with sign and minimum field size > number of digits > precision field size, positive value"}, - {"24", 12345, 2, "%+4.2d", "+12345", "%d with sign and number of digits > minimum field size > precision field size, positive value"}, - {"25", 12345, 6, "%+7.9d", "+000012345", "%d with sign and precision field size > minimum field size > number of digits, positive value"}, - {"26", 12345, 8, "%+3.9d", "+000012345", "%d with sign and precision field size > number of digits > minimum field size, positive value"}, - {"27", 12345, 5, "%+2.4d", "+12345", "%d with sign and number of digits > precision field size > minimum field size, positive value"}, - {"28", 98765, 16, "%+-.20d", "+00000000000000098765", "%d with sign and left-justify and precision field size > number of digits, positive value"}, - {"29", 98765, 5, "%+-.3d", "+98765", "%d with sign and left-justify and precision field size < number of digits, positive value"}, + {"22", 12345, 6, "%+9.7d", " +0012345", + "%d with sign and minimum field size > precision field size > number of digits, positive value"}, + {"23", 12345, 7, "%+9.3d", " +12345", + "%d with sign and minimum field size > number of digits > precision field size, positive value"}, + {"24", 12345, 2, "%+4.2d", "+12345", + "%d with sign and number of digits > minimum field size > precision field size, positive value"}, + {"25", 12345, 6, "%+7.9d", "+000012345", + "%d with sign and precision field size > minimum field size > number of digits, positive value"}, + {"26", 12345, 8, "%+3.9d", "+000012345", + "%d with sign and precision field size > number of digits > minimum field size, positive value"}, + {"27", 12345, 5, "%+2.4d", "+12345", + "%d with sign and number of digits > precision field size > minimum field size, positive value"}, + {"28", 98765, 16, "%+-.20d", "+00000000000000098765", + "%d with sign and left-justify and precision field size > number of digits, positive value"}, + {"29", 98765, 5, "%+-.3d", "+98765", + "%d with sign and left-justify and precision field size < number of digits, positive value"}, {"30", 98765, 3, "%+d", "+98765", "%d with sign, positive value"}, {"31", -98765, 2, "%d", "-98765", "%d, negative value"}, {"32", -46372, 8, "$$$%d$$$", "$$$-46372$$$", "%d embedded, negative value"}, @@ -85,28 +101,46 @@ void UT_osprintf_d(void) {"35", -91827, 5, "%4d", "-91827", "%d with minimum field size < number of digits, negative value"}, {"36", -33225, 7, "%.10d", "-0000033225", "%d with precision field size > number of digits, negative value"}, {"37", -33225, 4, "%.3d", "-33225", "%d with precision field size < number of digits, negative value"}, - {"38", -12345, 8, "%9.7d", " -0012345", "%d with minimum field size > precision field size > number of digits, negative value"}, - {"39", -12345, 9, "%9.3d", " -12345", "%d with minimum field size > number of digits > precision field size, negative value"}, - {"40", -12345, 5, "%4.2d", "-12345", "%d with number of digits > minimum field size > precision field size, negative value"}, - {"41", -12345, 7, "%7.9d", "-000012345", "%d with precision field size > minimum field size > number of digits, negative value"}, - {"42", -12345, 8, "%3.9d", "-000012345", "%d with precision field size > number of digits > minimum field size, negative value"}, - {"43", -12345, 5, "%2.4d", "-12345", "%d with number of digits > precision field size > minimum field size, negative value"}, - {"44", -98765, 20, "%-.20d", "-00000000000000098765", "%d with left-justify and precision field size > number of digits, negative value"}, - {"45", -98765, 5, "%-.3d", "-98765", "%d with left-justify and precision field size < number of digits, negative value"}, + {"38", -12345, 8, "%9.7d", " -0012345", + "%d with minimum field size > precision field size > number of digits, negative value"}, + {"39", -12345, 9, "%9.3d", " -12345", + "%d with minimum field size > number of digits > precision field size, negative value"}, + {"40", -12345, 5, "%4.2d", "-12345", + "%d with number of digits > minimum field size > precision field size, negative value"}, + {"41", -12345, 7, "%7.9d", "-000012345", + "%d with precision field size > minimum field size > number of digits, negative value"}, + {"42", -12345, 8, "%3.9d", "-000012345", + "%d with precision field size > number of digits > minimum field size, negative value"}, + {"43", -12345, 5, "%2.4d", "-12345", + "%d with number of digits > precision field size > minimum field size, negative value"}, + {"44", -98765, 20, "%-.20d", "-00000000000000098765", + "%d with left-justify and precision field size > number of digits, negative value"}, + {"45", -98765, 5, "%-.3d", "-98765", + "%d with left-justify and precision field size < number of digits, negative value"}, {"46", -98765, 6, "%+d", "-98765", "%d with sign, negative value"}, {"47", -46372, 8, "$$$%+d$$$", "$$$-46372$$$", "%d sign and embedded, negative value"}, {"48", -91827, 7, "%+8d", " -91827", "%d with sign and minimum field size > number of digits, negative value"}, {"49", -91827, 5, "%+4d", "-91827", "%d with sign and minimum field size < number of digits, negative value"}, - {"50", -33225, 9, "%+.10d", "-0000033225", "%d with sign and precision field size > number of digits, negative value"}, - {"51", -33225, 5, "%+.3d", "-33225", "%d with sign and precision field size < number of digits, negative value"}, - {"52", -12345, 6, "%+9.7d", " -0012345", "%d with sign and minimum field size > precision field size > number of digits, negative value"}, - {"53", -12345, 7, "%+9.3d", " -12345", "%d with sign and minimum field size > number of digits > precision field size, negative value"}, - {"54", -12345, 5, "%+4.2d", "-12345", "%d with sign and number of digits > minimum field size > precision field size, negative value"}, - {"55", -12345, 8, "%+7.9d", "-000012345", "%d with sign and precision field size > minimum field size > number of digits, negative value"}, - {"56", -12345, 7, "%+3.9d", "-000012345", "%d with sign and precision field size > number of digits > minimum field size, negative value"}, - {"57", -12345, 6, "%+2.4d", "-12345", "%d with sign and number of digits > precision field size > minimum field size, negative value"}, - {"58", -98765, 13, "%+-.20d", "-00000000000000098765", "%d with sign and left-justify and precision field size > number of digits, negative value"}, - {"59", -98765, 4, "%+-.3d", "-98765", "%d with sign and left-justify and precision field size < number of digits, negative value"}, + {"50", -33225, 9, "%+.10d", "-0000033225", + "%d with sign and precision field size > number of digits, negative value"}, + {"51", -33225, 5, "%+.3d", "-33225", + "%d with sign and precision field size < number of digits, negative value"}, + {"52", -12345, 6, "%+9.7d", " -0012345", + "%d with sign and minimum field size > precision field size > number of digits, negative value"}, + {"53", -12345, 7, "%+9.3d", " -12345", + "%d with sign and minimum field size > number of digits > precision field size, negative value"}, + {"54", -12345, 5, "%+4.2d", "-12345", + "%d with sign and number of digits > minimum field size > precision field size, negative value"}, + {"55", -12345, 8, "%+7.9d", "-000012345", + "%d with sign and precision field size > minimum field size > number of digits, negative value"}, + {"56", -12345, 7, "%+3.9d", "-000012345", + "%d with sign and precision field size > number of digits > minimum field size, negative value"}, + {"57", -12345, 6, "%+2.4d", "-12345", + "%d with sign and number of digits > precision field size > minimum field size, negative value"}, + {"58", -98765, 13, "%+-.20d", "-00000000000000098765", + "%d with sign and left-justify and precision field size > number of digits, negative value"}, + {"59", -98765, 4, "%+-.3d", "-98765", + "%d with sign and left-justify and precision field size < number of digits, negative value"}, {"60", -98765, 5, "%+d", "-98765", "%d with sign, negative value"}, {"61", 0, 6, "%d", "0", "%d, zero value"}, {"62", 162534, 5, "%08d", "00162534", "%d with zero padding, positive value"}, @@ -120,11 +154,7 @@ void UT_osprintf_d(void) /* Perform sprintf test */ init_test(); sprintf(strg_buf, osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(osp_tests[i].expected, - strg_buf), - "SPRINTF", - osp_tests[i].description, - test_fmt, + UT_Report(check_test(osp_tests[i].expected, strg_buf), "SPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); /* Truncate expected string in preparation for snprintf test */ @@ -137,12 +167,8 @@ void UT_osprintf_d(void) /* Perform snprintf test */ init_test(); - snprintf(strg_buf, osp_tests[i].max_len, - osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(trunc_buf, strg_buf), - "SNPRINTF", - osp_tests[i].description, - test_fmt, + snprintf(strg_buf, osp_tests[i].max_len, osp_tests[i].format, osp_tests[i].test_val); + UT_Report(check_test(trunc_buf, strg_buf), "SNPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); } } diff --git a/src/unit-tests/osprintf-test/ut_osprintf_f.c b/src/unit-tests/osprintf-test/ut_osprintf_f.c index 55c10ccd2..08ca59d6f 100644 --- a/src/unit-tests/osprintf-test/ut_osprintf_f.c +++ b/src/unit-tests/osprintf-test/ut_osprintf_f.c @@ -36,18 +36,17 @@ extern char trunc_buf[]; void UT_osprintf_f(void) { char *test_fmt = "f"; /* Test format character(s) */ - int i; + int i; struct { - char *test_num; /* Test identifier; sequential numbers */ - float test_val; /* Test value */ - int max_len; /* Maximum output string length */ - char *format; /* Format string */ - char *expected; /* Expected result */ - char *description; /* Test description */ - } osp_tests[] = - { + char *test_num; /* Test identifier; sequential numbers */ + float test_val; /* Test value */ + int max_len; /* Maximum output string length */ + char *format; /* Format string */ + char *expected; /* Expected result */ + char *description; /* Test description */ + } osp_tests[] = { {"01", 5.230, 6, "%f", "5.230000", "%f, positive value"}, {"02", 2.1056, 9, "$$$%f$$$", "$$$2.105600$$$", "%f embedded, positive value"}, {"03", 91827.3, 4, "%3f", "91827.296875", "%f with maximum field size, positive value"}, @@ -77,10 +76,7 @@ void UT_osprintf_f(void) /* Perform sprintf test */ init_test(); sprintf(strg_buf, osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(osp_tests[i].expected, strg_buf), - "SPRINTF", - osp_tests[i].description, - test_fmt, + UT_Report(check_test(osp_tests[i].expected, strg_buf), "SPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); /* Truncate expected string in preparation for snprintf test */ @@ -93,12 +89,8 @@ void UT_osprintf_f(void) /* Perform snprintf test */ init_test(); - snprintf(strg_buf, osp_tests[i].max_len, - osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(trunc_buf, strg_buf), - "SNPRINTF", - osp_tests[i].description, - test_fmt, + snprintf(strg_buf, osp_tests[i].max_len, osp_tests[i].format, osp_tests[i].test_val); + UT_Report(check_test(trunc_buf, strg_buf), "SNPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); } } diff --git a/src/unit-tests/osprintf-test/ut_osprintf_i.c b/src/unit-tests/osprintf-test/ut_osprintf_i.c index 555ef58e3..83ed728ca 100644 --- a/src/unit-tests/osprintf-test/ut_osprintf_i.c +++ b/src/unit-tests/osprintf-test/ut_osprintf_i.c @@ -36,18 +36,17 @@ extern char trunc_buf[]; void UT_osprintf_i(void) { char *test_fmt = "i"; /* Test format character(s) */ - int i; + int i; struct { char *test_num; /* Test identifier; sequential numbers */ - int test_val; /* Test value */ - int max_len; /* Maximum output string length */ + int test_val; /* Test value */ + int max_len; /* Maximum output string length */ char *format; /* Format string */ char *expected; /* Expected result */ char *description; /* Test description */ - } osp_tests[] = - { + } osp_tests[] = { {"01", 98765, 5, "%i", "98765", "%i, positive value"}, {"02", 46372, 9, "$$$%i$$$", "$$$46372$$$", "%i embedded, positive value"}, {"03", 98765, 5, "% i", " 98765", "%i with space for sign, positive value"}, @@ -55,58 +54,93 @@ void UT_osprintf_i(void) {"05", 91827, 2, "%4i", "91827", "%i with minimum field size < number of digits, positive value"}, {"06", 33225, 7, "%.10i", "0000033225", "%i with precision field size > number of digits, positive value"}, {"07", 33225, 3, "%.3i", "33225", "%i with precision field size < number of digits, positive value"}, - {"08", 12345, 5, "%9.7i", " 0012345", "%i with minimum field size > precision field size > number of digits, positive value"}, - {"09", 12345, 5, "%9.3i", " 12345", "%i with minimum field size > number of digits > precision field size, positive value"}, - {"10", 12345, 5, "%4.2i", "12345", "%i with number of digits > minimum field size > precision field size, positive value"}, - {"11", 12345, 8, "%7.9i", "000012345", "%i with precision field size > minimum field size > number of digits, positive value"}, - {"12", 12345, 7, "%3.9i", "000012345", "%i with precision field size > number of digits > minimum field size, positive value"}, - {"13", 12345, 4, "%2.4i", "12345", "%i with number of digits > precision field size > minimum field size, positive value"}, - {"14", 98765, 5, "%-.20i", "00000000000000098765", "%i with left-justify and precision field size > number of digits, positive value"}, - {"15", 98765, 5, "%-.3i", "98765", "%i with left-justify and precision field size < number of digits, positive value"}, + {"08", 12345, 5, "%9.7i", " 0012345", + "%i with minimum field size > precision field size > number of digits, positive value"}, + {"09", 12345, 5, "%9.3i", " 12345", + "%i with minimum field size > number of digits > precision field size, positive value"}, + {"10", 12345, 5, "%4.2i", "12345", + "%i with number of digits > minimum field size > precision field size, positive value"}, + {"11", 12345, 8, "%7.9i", "000012345", + "%i with precision field size > minimum field size > number of digits, positive value"}, + {"12", 12345, 7, "%3.9i", "000012345", + "%i with precision field size > number of digits > minimum field size, positive value"}, + {"13", 12345, 4, "%2.4i", "12345", + "%i with number of digits > precision field size > minimum field size, positive value"}, + {"14", 98765, 5, "%-.20i", "00000000000000098765", + "%i with left-justify and precision field size > number of digits, positive value"}, + {"15", 98765, 5, "%-.3i", "98765", + "%i with left-justify and precision field size < number of digits, positive value"}, {"16", 98765, 5, "%+i", "+98765", "%i with sign, positive value"}, {"17", 46372, 5, "$$$%+d$$$", "$$$+46372$$$", "%i sign and embedded, positive value"}, {"18", 91827, 6, "%+8i", " +91827", "%i with sign and minimum field size > number of digits, positive value"}, {"19", 91827, 4, "%+4i", "+91827", "%i with sign and minimum field size < number of digits, positive value"}, - {"20", 33225, 8, "%+.10i", "+0000033225", "%i with sign and precision field size > number of digits, positive value"}, + {"20", 33225, 8, "%+.10i", "+0000033225", + "%i with sign and precision field size > number of digits, positive value"}, {"21", 33225, 5, "%+.3i", "+33225", "%i with sign and precision field size < number of digits, positive value"}, - {"22", 12345, 5, "%+9.7i", " +0012345", "%i with sign and minimum field size > precision field size > number of digits, positive value"}, - {"23", 12345, 5, "%+9.3i", " +12345", "%i with sign and minimum field size > number of digits > precision field size, positive value"}, - {"24", 12345, 5, "%+4.2i", "+12345", "%i with sign and number of digits > minimum field size > precision field size, positive value"}, - {"25", 12345, 8, "%+7.9i", "+000012345", "%i with sign and precision field size > minimum field size > number of digits, positive value"}, - {"26", 12345, 7, "%+3.9i", "+000012345", "%i with sign and precision field size > number of digits > minimum field size, positive value"}, - {"27", 12345, 5, "%+2.4i", "+12345", "%i with sign and number of digits > precision field size > minimum field size, positive value"}, - {"28", 98765, 16, "%+-.20i", "+00000000000000098765", "%i with sign and left-justify and precision field size > number of digits, positive value"}, - {"29", 98765, 5, "%+-.3i", "+98765", "%i with sign and left-justify and precision field size < number of digits, positive value"}, + {"22", 12345, 5, "%+9.7i", " +0012345", + "%i with sign and minimum field size > precision field size > number of digits, positive value"}, + {"23", 12345, 5, "%+9.3i", " +12345", + "%i with sign and minimum field size > number of digits > precision field size, positive value"}, + {"24", 12345, 5, "%+4.2i", "+12345", + "%i with sign and number of digits > minimum field size > precision field size, positive value"}, + {"25", 12345, 8, "%+7.9i", "+000012345", + "%i with sign and precision field size > minimum field size > number of digits, positive value"}, + {"26", 12345, 7, "%+3.9i", "+000012345", + "%i with sign and precision field size > number of digits > minimum field size, positive value"}, + {"27", 12345, 5, "%+2.4i", "+12345", + "%i with sign and number of digits > precision field size > minimum field size, positive value"}, + {"28", 98765, 16, "%+-.20i", "+00000000000000098765", + "%i with sign and left-justify and precision field size > number of digits, positive value"}, + {"29", 98765, 5, "%+-.3i", "+98765", + "%i with sign and left-justify and precision field size < number of digits, positive value"}, {"30", 98765, 4, "%+i", "+98765", "%i with sign, positive value"}, {"31", -98765, 6, "%i", "-98765", "%i, negative value"}, {"32", -46372, 6, "$$$%i$$$", "$$$-46372$$$", "%i embedded, negative value"}, {"33", -98765, 5, "% i", "-98765", "%i with space for sign, negative value"}, {"34", -91827, 9, "%10i", " -91827", "%i with minimum field size > number of digits, negative value"}, - {"35", -91827, 6, "%4i", "-91827", "%i with minimum field size < number of digits, negative value"}, + {"35", -91827, 6, "%4i", "-91827", "%i with minimum field size < number of digits, negative value"}, {"36", -33225, 9, "%.10i", "-0000033225", "%i with precision field size > number of digits, negative value"}, {"37", -33225, 5, "%.3i", "-33225", "%i with precision field size < number of digits, negative value"}, - {"38", -12345, 8, "%9.7i", " -0012345", "%i with minimum field size > precision field size > number of digits, negative value"}, - {"39", -12345, 7, "%9.3i", " -12345", "%i with minimum field size > number of digits > precision field size, negative value"}, - {"40", -12345, 6, "%4.2i", "-12345", "%i with number of digits > minimum field size > precision field size, negative value"}, - {"41", -12345, 7, "%7.9i", "-000012345", "%i with precision field size > minimum field size > number of digits, negative value"}, - {"42", -12345, 8, "%3.9i", "-000012345", "%i with precision field size > number of digits > minimum field size, negative value"}, - {"43", -12345, 5, "%2.4i", "-12345", "%i with number of digits > precision field size > minimum field size, negative value"}, - {"44", -98765, 18, "%-.20i", "-00000000000000098765", "%i with left-justify and precision field size > number of digits, negative value"}, - {"45", -98765, 5, "%-.3i", "-98765", "%i with left-justify and precision field size < number of digits, negative value"}, + {"38", -12345, 8, "%9.7i", " -0012345", + "%i with minimum field size > precision field size > number of digits, negative value"}, + {"39", -12345, 7, "%9.3i", " -12345", + "%i with minimum field size > number of digits > precision field size, negative value"}, + {"40", -12345, 6, "%4.2i", "-12345", + "%i with number of digits > minimum field size > precision field size, negative value"}, + {"41", -12345, 7, "%7.9i", "-000012345", + "%i with precision field size > minimum field size > number of digits, negative value"}, + {"42", -12345, 8, "%3.9i", "-000012345", + "%i with precision field size > number of digits > minimum field size, negative value"}, + {"43", -12345, 5, "%2.4i", "-12345", + "%i with number of digits > precision field size > minimum field size, negative value"}, + {"44", -98765, 18, "%-.20i", "-00000000000000098765", + "%i with left-justify and precision field size > number of digits, negative value"}, + {"45", -98765, 5, "%-.3i", "-98765", + "%i with left-justify and precision field size < number of digits, negative value"}, {"46", -98765, 6, "%+i", "-98765", "%i with sign, negative value"}, {"47", -46372, 7, "$$$%+d$$$", "$$$-46372$$$", "%i sign and embedded, negative value"}, {"48", -91827, 5, "%+8i", " -91827", "%i with sign and minimum field size > number of digits, negative value"}, {"49", -91827, 5, "%+4i", "-91827", "%i with sign and minimum field size < number of digits, negative value"}, - {"50", -33225, 7, "%+.10i", "-0000033225", "%i with sign and precision field size > number of digits, negative value"}, - {"51", -33225, 5, "%+.3i", "-33225", "%i with sign and precision field size < number of digits, negative value"}, - {"52", -12345, 7, "%+9.7i", " -0012345", "%i with sign and minimum field size > precision field size > number of digits, negative value"}, - {"53", -12345, 8, "%+9.3i", " -12345", "%i with sign and minimum field size > number of digits > precision field size, negative value"}, - {"54", -12345, 4, "%+4.2i", "-12345", "%i with sign and number of digits > minimum field size > precision field size, negative value"}, - {"55", -12345, 8, "%+7.9i", "-000012345", "%i with sign and precision field size > minimum field size > number of digits, negative value"}, - {"56", -12345, 7, "%+3.9i", "-000012345", "%i with sign and precision field size > number of digits > minimum field size, negative value"}, - {"57", -12345, 5, "%+2.4i", "-12345", "%i with sign and number of digits > precision field size > minimum field size, negative value"}, - {"58", -98765, 19, "%+-.20i", "-00000000000000098765", "%i with sign and left-justify and precision field size > number of digits, negative value"}, - {"59", -98765, 6, "%+-.3i", "-98765", "%i with sign and left-justify and precision field size < number of digits, negative value"}, + {"50", -33225, 7, "%+.10i", "-0000033225", + "%i with sign and precision field size > number of digits, negative value"}, + {"51", -33225, 5, "%+.3i", "-33225", + "%i with sign and precision field size < number of digits, negative value"}, + {"52", -12345, 7, "%+9.7i", " -0012345", + "%i with sign and minimum field size > precision field size > number of digits, negative value"}, + {"53", -12345, 8, "%+9.3i", " -12345", + "%i with sign and minimum field size > number of digits > precision field size, negative value"}, + {"54", -12345, 4, "%+4.2i", "-12345", + "%i with sign and number of digits > minimum field size > precision field size, negative value"}, + {"55", -12345, 8, "%+7.9i", "-000012345", + "%i with sign and precision field size > minimum field size > number of digits, negative value"}, + {"56", -12345, 7, "%+3.9i", "-000012345", + "%i with sign and precision field size > number of digits > minimum field size, negative value"}, + {"57", -12345, 5, "%+2.4i", "-12345", + "%i with sign and number of digits > precision field size > minimum field size, negative value"}, + {"58", -98765, 19, "%+-.20i", "-00000000000000098765", + "%i with sign and left-justify and precision field size > number of digits, negative value"}, + {"59", -98765, 6, "%+-.3i", "-98765", + "%i with sign and left-justify and precision field size < number of digits, negative value"}, {"60", -98765, 5, "%+i", "-98765", "%i with sign, negative value"}, {"61", 0, 6, "%i", "0", "%i, zero value"}, {"62", 162534, 5, "%08i", "00162534", "%i with zero padding, positive value"}, @@ -120,10 +154,7 @@ void UT_osprintf_i(void) /* Perform sprintf test */ init_test(); sprintf(strg_buf, osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(osp_tests[i].expected, strg_buf), - "SPRINTF", - osp_tests[i].description, - test_fmt, + UT_Report(check_test(osp_tests[i].expected, strg_buf), "SPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); /* Truncate expected string in preparation for snprintf test */ @@ -136,13 +167,8 @@ void UT_osprintf_i(void) /* Perform snprintf test */ init_test(); - snprintf(strg_buf, osp_tests[i].max_len, - osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(trunc_buf, strg_buf), - "SNPRINTF", - osp_tests[i].description, - test_fmt, + snprintf(strg_buf, osp_tests[i].max_len, osp_tests[i].format, osp_tests[i].test_val); + UT_Report(check_test(trunc_buf, strg_buf), "SNPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); } } - diff --git a/src/unit-tests/osprintf-test/ut_osprintf_ld.c b/src/unit-tests/osprintf-test/ut_osprintf_ld.c index 47e73d641..9236fa157 100644 --- a/src/unit-tests/osprintf-test/ut_osprintf_ld.c +++ b/src/unit-tests/osprintf-test/ut_osprintf_ld.c @@ -36,18 +36,17 @@ extern char trunc_buf[]; void UT_osprintf_ld(void) { char *test_fmt = "ld"; /* Test format character(s) */ - int i; + int i; struct { - char *test_num; /* Test identifier; sequential numbers */ - long int test_val; /* Test value */ - int max_len; /* Maximum output string length */ - char *format; /* Format string */ - char *expected; /* Expected result */ - char *description; /* Test description */ - } osp_tests[] = - { + char * test_num; /* Test identifier; sequential numbers */ + long int test_val; /* Test value */ + int max_len; /* Maximum output string length */ + char * format; /* Format string */ + char * expected; /* Expected result */ + char * description; /* Test description */ + } osp_tests[] = { {"01", 12798765, 5, "%ld", "12798765", "%ld, positive value"}, {"02", 43246372, 9, "$$$%ld$$$", "$$$43246372$$$", "%ld embedded, positive value"}, {"03", 63198765, 9, "% ld", " 63198765", "%ld with space for sign, positive value"}, @@ -55,58 +54,100 @@ void UT_osprintf_ld(void) {"05", 54691827, 5, "%4ld", "54691827", "%ld with minimum field size < number of digits, positive value"}, {"06", 77833225, 7, "%.10ld", "0077833225", "%ld with precision field size > number of digits, positive value"}, {"07", 99933225, 6, "%.3ld", "99933225", "%ld with precision field size < number of digits, positive value"}, - {"08", 12345789, 8, "%12.10ld", " 0012345789", "%ld with minimum field size > precision field size > number of digits, positive value"}, - {"09", 12345987, 7, "%12.3ld", " 12345987", "%ld with minimum field size > number of digits > precision field size, positive value"}, - {"10", 12345444, 8, "%4.2ld", "12345444", "%ld with number of digits > minimum field size > precision field size, positive value"}, - {"11", 12345321, 10, "%10.12ld", "000012345321", "%ld with precision field size > minimum field size > number of digits, positive value"}, - {"12", 12333345, 9, "%6.12ld", "000012333345", "%ld with precision field size > number of digits > minimum field size, positive value"}, - {"13", 12345777, 8, "%2.4ld", "12345777", "%ld with number of digits > precision field size > minimum field size, positive value"}, - {"14", 98765321, 15, "%-.20ld", "00000000000098765321", "%ld with left-justify and precision field size > number of digits, positive value"}, - {"15", 98765111, 8, "%-.3ld", "98765111", "%ld with left-justify and precision field size < number of digits, positive value"}, + {"08", 12345789, 8, "%12.10ld", " 0012345789", + "%ld with minimum field size > precision field size > number of digits, positive value"}, + {"09", 12345987, 7, "%12.3ld", " 12345987", + "%ld with minimum field size > number of digits > precision field size, positive value"}, + {"10", 12345444, 8, "%4.2ld", "12345444", + "%ld with number of digits > minimum field size > precision field size, positive value"}, + {"11", 12345321, 10, "%10.12ld", "000012345321", + "%ld with precision field size > minimum field size > number of digits, positive value"}, + {"12", 12333345, 9, "%6.12ld", "000012333345", + "%ld with precision field size > number of digits > minimum field size, positive value"}, + {"13", 12345777, 8, "%2.4ld", "12345777", + "%ld with number of digits > precision field size > minimum field size, positive value"}, + {"14", 98765321, 15, "%-.20ld", "00000000000098765321", + "%ld with left-justify and precision field size > number of digits, positive value"}, + {"15", 98765111, 8, "%-.3ld", "98765111", + "%ld with left-justify and precision field size < number of digits, positive value"}, {"16", 98765222, 8, "%+ld", "+98765222", "%ld with sign, positive value"}, {"17", 46372333, 7, "$$$%+ld$$$", "$$$+46372333$$$", "%ld sign and embedded, positive value"}, - {"18", 91827444, 6, "%+11ld", " +91827444", "%ld with sign and minimum field size > number of digits, positive value"}, - {"19", 91827555, 5, "%+4ld", "+91827555", "%ld with sign and minimum field size < number of digits, positive value"}, - {"20", 33225666, 7, "%+.13ld", "+0000033225666", "%ld with sign and precision field size > number of digits, positive value"}, - {"21", 33225777, 8, "%+.3ld", "+33225777", "%ld with sign and precision field size < number of digits, positive value"}, - {"22", 12345888, 9, "%+12.10ld", " +0012345888", "%ld with sign and minimum field size > precision field size > number of digits, positive value"}, - {"23", 12345999, 10, "%+12.3ld", " +12345999", "%ld with sign and minimum field size > number of digits > precision field size, positive value"}, - {"24", 12345000, 8, "%+4.2ld", "+12345000", "%ld with sign and number of digits > minimum field size > precision field size, positive value"}, - {"25", 12345121, 9, "%+10.12ld", "+000012345121", "%ld with sign and precision field size > minimum field size > number of digits, positive value"}, - {"26", 12345232, 8, "%+6.12ld", "+000012345232", "%ld with sign and precision field size > number of digits > minimum field size, positive value"}, - {"27", 12345343, 6, "%+2.4ld", "+12345343", "%ld with sign and number of digits > precision field size > minimum field size, positive value"}, - {"28", 98765454, 19, "%+-.20ld", "+00000000000098765454", "%ld with sign and left-justify and precision field size > number of digits, positive value"}, - {"29", 98765565, 7, "%+-.3ld", "+98765565", "%ld with sign and left-justify and precision field size < number of digits, positive value"}, + {"18", 91827444, 6, "%+11ld", " +91827444", + "%ld with sign and minimum field size > number of digits, positive value"}, + {"19", 91827555, 5, "%+4ld", "+91827555", + "%ld with sign and minimum field size < number of digits, positive value"}, + {"20", 33225666, 7, "%+.13ld", "+0000033225666", + "%ld with sign and precision field size > number of digits, positive value"}, + {"21", 33225777, 8, "%+.3ld", "+33225777", + "%ld with sign and precision field size < number of digits, positive value"}, + {"22", 12345888, 9, "%+12.10ld", " +0012345888", + "%ld with sign and minimum field size > precision field size > number of digits, positive value"}, + {"23", 12345999, 10, "%+12.3ld", " +12345999", + "%ld with sign and minimum field size > number of digits > precision field size, positive value"}, + {"24", 12345000, 8, "%+4.2ld", "+12345000", + "%ld with sign and number of digits > minimum field size > precision field size, positive value"}, + {"25", 12345121, 9, "%+10.12ld", "+000012345121", + "%ld with sign and precision field size > minimum field size > number of digits, positive value"}, + {"26", 12345232, 8, "%+6.12ld", "+000012345232", + "%ld with sign and precision field size > number of digits > minimum field size, positive value"}, + {"27", 12345343, 6, "%+2.4ld", "+12345343", + "%ld with sign and number of digits > precision field size > minimum field size, positive value"}, + {"28", 98765454, 19, "%+-.20ld", "+00000000000098765454", + "%ld with sign and left-justify and precision field size > number of digits, positive value"}, + {"29", 98765565, 7, "%+-.3ld", "+98765565", + "%ld with sign and left-justify and precision field size < number of digits, positive value"}, {"30", 98765676, 8, "%+ld", "+98765676", "%ld with sign, positive value"}, {"31", -98765787, 9, "%ld", "-98765787", "%ld, negative value"}, {"32", -46372898, 10, "$$$%ld$$$", "$$$-46372898$$$", "%ld embedded, negative value"}, {"33", -98765909, 9, "% ld", "-98765909", "%ld with space for sign, negative value"}, - {"34", -91827121, 8, "%13ld", " -91827121", "%ld with minimum field size > number of digits, negative value"}, + {"34", -91827121, 8, "%13ld", " -91827121", + "%ld with minimum field size > number of digits, negative value"}, {"35", -91827232, 5, "%4ld", "-91827232", "%ld with minimum field size < number of digits, negative value"}, - {"36", -33225343, 8, "%.13ld", "-0000033225343", "%ld with precision field size > number of digits, negative value"}, + {"36", -33225343, 8, "%.13ld", "-0000033225343", + "%ld with precision field size > number of digits, negative value"}, {"37", -33225454, 6, "%.3ld", "-33225454", "%ld with precision field size < number of digits, negative value"}, - {"38", -12345565, 7, "%12.10ld", " -0012345565", "%ld with minimum field size > precision field size > number of digits, negative value"}, - {"39", -12345676, 8, "%12.4ld", " -12345676", "%ld with minimum field size > number of digits > precision field size, negative value"}, - {"40", -12345787, 9, "%4.2ld", "-12345787", "%ld with number of digits > minimum field size > precision field size, negative value"}, - {"41", -12345898, 11, "%7.12ld", "-000012345898", "%ld with precision field size > minimum field size > number of digits, negative value"}, - {"42", -12345909, 10, "%3.12ld", "-000012345909", "%ld with precision field size > number of digits > minimum field size, negative value"}, - {"43", -12345101, 9, "%2.4ld", "-12345101", "%ld with number of digits > precision field size > minimum field size, negative value"}, - {"44", -98765292, 10, "%-.20ld", "-00000000000098765292", "%ld with left-justify and precision field size > number of digits, negative value"}, - {"45", -98765383, 8, "%-.3ld", "-98765383", "%ld with left-justify and precision field size < number of digits, negative value"}, + {"38", -12345565, 7, "%12.10ld", " -0012345565", + "%ld with minimum field size > precision field size > number of digits, negative value"}, + {"39", -12345676, 8, "%12.4ld", " -12345676", + "%ld with minimum field size > number of digits > precision field size, negative value"}, + {"40", -12345787, 9, "%4.2ld", "-12345787", + "%ld with number of digits > minimum field size > precision field size, negative value"}, + {"41", -12345898, 11, "%7.12ld", "-000012345898", + "%ld with precision field size > minimum field size > number of digits, negative value"}, + {"42", -12345909, 10, "%3.12ld", "-000012345909", + "%ld with precision field size > number of digits > minimum field size, negative value"}, + {"43", -12345101, 9, "%2.4ld", "-12345101", + "%ld with number of digits > precision field size > minimum field size, negative value"}, + {"44", -98765292, 10, "%-.20ld", "-00000000000098765292", + "%ld with left-justify and precision field size > number of digits, negative value"}, + {"45", -98765383, 8, "%-.3ld", "-98765383", + "%ld with left-justify and precision field size < number of digits, negative value"}, {"46", -98765474, 9, "%+ld", "-98765474", "%ld with sign, negative value"}, {"47", -46372565, 8, "$$$%+ld$$$", "$$$-46372565$$$", "%ld sign and embedded, negative value"}, - {"48", -91827112, 7, "%+11ld", " -91827112", "%ld with sign and minimum field size > number of digits, negative value"}, - {"49", -91827223, 6, "%+4ld", "-91827223", "%ld with sign and minimum field size < number of digits, negative value"}, - {"50", -33225334, 11, "%+.13ld", "-0000033225334", "%ld with sign and precision field size > number of digits, negative value"}, - {"51", -33225445, 9, "%+.3ld", "-33225445", "%ld with sign and precision field size < number of digits, negative value"}, - {"52", -12345556, 11, "%+12.10ld", " -0012345556", "%ld with sign and minimum field size > precision field size > number of digits, negative value"}, - {"53", -12345667, 10, "%+12.3ld", " -12345667", "%ld with sign and minimum field size > number of digits > precision field size, negative value"}, - {"54", -12345778, 9, "%+4.2ld", "-12345778", "%ld with sign and number of digits > minimum field size > precision field size, negative value"}, - {"55", -12345889, 10, "%+7.12ld", "-000012345889", "%ld with sign and precision field size > minimum field size > number of digits, negative value"}, - {"56", -12345990, 9, "%+3.12ld", "-000012345990", "%ld with sign and precision field size > number of digits > minimum field size, negative value"}, - {"57", -12345221, 8, "%+2.4ld", "-12345221", "%ld with sign and number of digits > precision field size > minimum field size, negative value"}, - {"58", -98765332, 7, "%+-.20ld", "-00000000000098765332", "%ld with sign and left-justify and precision field size > number of digits, negative value"}, - {"59", -98765443, 6, "%+-.3ld", "-98765443", "%ld with sign and left-justify and precision field size < number of digits, negative value"}, + {"48", -91827112, 7, "%+11ld", " -91827112", + "%ld with sign and minimum field size > number of digits, negative value"}, + {"49", -91827223, 6, "%+4ld", "-91827223", + "%ld with sign and minimum field size < number of digits, negative value"}, + {"50", -33225334, 11, "%+.13ld", "-0000033225334", + "%ld with sign and precision field size > number of digits, negative value"}, + {"51", -33225445, 9, "%+.3ld", "-33225445", + "%ld with sign and precision field size < number of digits, negative value"}, + {"52", -12345556, 11, "%+12.10ld", " -0012345556", + "%ld with sign and minimum field size > precision field size > number of digits, negative value"}, + {"53", -12345667, 10, "%+12.3ld", " -12345667", + "%ld with sign and minimum field size > number of digits > precision field size, negative value"}, + {"54", -12345778, 9, "%+4.2ld", "-12345778", + "%ld with sign and number of digits > minimum field size > precision field size, negative value"}, + {"55", -12345889, 10, "%+7.12ld", "-000012345889", + "%ld with sign and precision field size > minimum field size > number of digits, negative value"}, + {"56", -12345990, 9, "%+3.12ld", "-000012345990", + "%ld with sign and precision field size > number of digits > minimum field size, negative value"}, + {"57", -12345221, 8, "%+2.4ld", "-12345221", + "%ld with sign and number of digits > precision field size > minimum field size, negative value"}, + {"58", -98765332, 7, "%+-.20ld", "-00000000000098765332", + "%ld with sign and left-justify and precision field size > number of digits, negative value"}, + {"59", -98765443, 6, "%+-.3ld", "-98765443", + "%ld with sign and left-justify and precision field size < number of digits, negative value"}, {"60", -98765554, 5, "%+ld", "-98765554", "%ld with sign, negative value"}, {"61", 0, 6, "%ld", "0", "%ld, zero value"}, {"62", 16253409, 5, "%010ld", "0016253409", "%ld with zero padding, positive value"}, @@ -120,10 +161,7 @@ void UT_osprintf_ld(void) /* Perform sprintf test */ init_test(); sprintf(strg_buf, osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(osp_tests[i].expected, strg_buf), - "SPRINTF", - osp_tests[i].description, - test_fmt, + UT_Report(check_test(osp_tests[i].expected, strg_buf), "SPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); /* Truncate expected string in preparation for snprintf test */ @@ -136,12 +174,8 @@ void UT_osprintf_ld(void) /* Perform snprintf test */ init_test(); - snprintf(strg_buf, osp_tests[i].max_len, - osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(trunc_buf, strg_buf), - "SNPRINTF", - osp_tests[i].description, - test_fmt, + snprintf(strg_buf, osp_tests[i].max_len, osp_tests[i].format, osp_tests[i].test_val); + UT_Report(check_test(trunc_buf, strg_buf), "SNPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); } } diff --git a/src/unit-tests/osprintf-test/ut_osprintf_lf.c b/src/unit-tests/osprintf-test/ut_osprintf_lf.c index cd134fcd8..bba38dcd2 100644 --- a/src/unit-tests/osprintf-test/ut_osprintf_lf.c +++ b/src/unit-tests/osprintf-test/ut_osprintf_lf.c @@ -36,30 +36,31 @@ extern char trunc_buf[]; void UT_osprintf_lf(void) { char *test_fmt = "lf"; /* Test format character(s) */ - int i; + int i; struct { - char *test_num; /* Test identifier; sequential numbers */ - double test_val; /* Test value */ - int max_len; /* Maximum output string length */ - char *format; /* Format string */ - char *expected; /* Expected result */ - char *description; /* Test description */ - } osp_tests[] = - { + char * test_num; /* Test identifier; sequential numbers */ + double test_val; /* Test value */ + int max_len; /* Maximum output string length */ + char * format; /* Format string */ + char * expected; /* Expected result */ + char * description; /* Test description */ + } osp_tests[] = { {"01", 9876543.125, 14, "%lf", "9876543.125000", "%lf, positive value"}, {"02", 4637210.36, 12, "$$$%lf$$$", "$$$4637210.360000$$$", "%lf embedded, positive value"}, {"03", 9182755.2756, 9, "%3lf", "9182755.275600", "%lf with maximum field size, positive value"}, {"04", 12554.08, 5, "%.7lf", "12554.0800000", "%lf with precision, positive value"}, - {"05", 123456.2311, 11, "%9.7lf", "123456.2311000", "%lf with precision and maximum field size, positive value"}, + {"05", 123456.2311, 11, "%9.7lf", "123456.2311000", + "%lf with precision and maximum field size, positive value"}, {"06", 9876543.6765, 15, "%-20lf", "9876543.676500 ", "%lf with left-justify, positive value"}, {"07", 9876543.001, 13, "%+lf", "+9876543.001000", "%lf with sign, positive value"}, {"08", -9876543.1987, 12, "%lf", "-9876543.198700", "%lf, negative value"}, {"09", -4637210.871, 14, "$$$%lf$$$", "$$$-4637210.871000$$$", "%lf embedded, negative value"}, {"10", -9182755.22222, 15, "%3lf", "-9182755.222220", "%lf with maximum field size, negative value"}, {"11", -3355.6109, 11, "%.5lf", "-3355.61090", "%lf with precision, negative value"}, - {"12", -123456.7, 14, "%15.4lf", " -123456.7000", "%lf with precision and maximum field size, negative value"}, + {"12", -123456.7, 14, "%15.4lf", " -123456.7000", + "%lf with precision and maximum field size, negative value"}, {"13", -9876543.64388, 17, "%-20lf", "-9876543.643880 ", "%lf with left-justify, negative value"}, {"14", 0.0, 4, "%lf", "0.000000", "%lf, zero value"}, {"15", 123456789.0, 6, "%10.0lf", " 123456789", "%lf, no fraction, positive value"}, @@ -77,10 +78,7 @@ void UT_osprintf_lf(void) /* Perform sprintf test */ init_test(); sprintf(strg_buf, osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(osp_tests[i].expected, strg_buf), - "SPRINTF", - osp_tests[i].description, - test_fmt, + UT_Report(check_test(osp_tests[i].expected, strg_buf), "SPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); /* Truncate expected string in preparation for snprintf test */ @@ -93,12 +91,8 @@ void UT_osprintf_lf(void) /* Perform snprintf test */ init_test(); - snprintf(strg_buf, osp_tests[i].max_len, - osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(trunc_buf, strg_buf), - "SNPRINTF", - osp_tests[i].description, - test_fmt, + snprintf(strg_buf, osp_tests[i].max_len, osp_tests[i].format, osp_tests[i].test_val); + UT_Report(check_test(trunc_buf, strg_buf), "SNPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); } } diff --git a/src/unit-tests/osprintf-test/ut_osprintf_li.c b/src/unit-tests/osprintf-test/ut_osprintf_li.c index eb4c82d2b..b366e3966 100644 --- a/src/unit-tests/osprintf-test/ut_osprintf_li.c +++ b/src/unit-tests/osprintf-test/ut_osprintf_li.c @@ -36,18 +36,17 @@ extern char trunc_buf[]; void UT_osprintf_li(void) { char *test_fmt = "li"; /* Test format character(s) */ - int i; + int i; struct { - char *test_num; /* Test identifier; sequential numbers */ - long int test_val; /* Test value */ - int max_len; /* Maximum output string length */ - char *format; /* Format string */ - char *expected; /* Expected result */ - char *description; /* Test description */ - } osp_tests[] = - { + char * test_num; /* Test identifier; sequential numbers */ + long int test_val; /* Test value */ + int max_len; /* Maximum output string length */ + char * format; /* Format string */ + char * expected; /* Expected result */ + char * description; /* Test description */ + } osp_tests[] = { {"01", 12798765, 7, "%li", "12798765", "%li, positive value"}, {"02", 43246372, 9, "$$$%li$$$", "$$$43246372$$$", "%li embedded, positive value"}, {"03", 63198765, 8, "% li", " 63198765", "%li with space for sign, positive value"}, @@ -55,58 +54,100 @@ void UT_osprintf_li(void) {"05", 54691827, 5, "%4li", "54691827", "%li with minimum field size < number of digits, positive value"}, {"06", 77833225, 8, "%.10li", "0077833225", "%li with precision field size > number of digits, positive value"}, {"07", 99933225, 5, "%.3li", "99933225", "%li with precision field size < number of digits, positive value"}, - {"08", 12345789, 10, "%12.10li", " 0012345789", "%li with minimum field size > precision field size > number of digits, positive value"}, - {"09", 12345987, 12, "%12.3li", " 12345987", "%li with minimum field size > number of digits > precision field size, positive value"}, - {"10", 12345444, 8, "%4.2li", "12345444", "%li with number of digits > minimum field size > precision field size, positive value"}, - {"11", 12345321, 11, "%10.12li", "000012345321", "%li with precision field size > minimum field size > number of digits, positive value"}, - {"12", 12333345, 7, "%6.12li", "000012333345", "%li with precision field size > number of digits > minimum field size, positive value"}, - {"13", 12345777, 5, "%2.4li", "12345777", "%li with number of digits > precision field size > minimum field size, positive value"}, - {"14", 98765321, 19, "%-.20li", "00000000000098765321", "%li with left-justify and precision field size > number of digits, positive value"}, - {"15", 98765111, 7, "%-.3li", "98765111", "%li with left-justify and precision field size < number of digits, positive value"}, + {"08", 12345789, 10, "%12.10li", " 0012345789", + "%li with minimum field size > precision field size > number of digits, positive value"}, + {"09", 12345987, 12, "%12.3li", " 12345987", + "%li with minimum field size > number of digits > precision field size, positive value"}, + {"10", 12345444, 8, "%4.2li", "12345444", + "%li with number of digits > minimum field size > precision field size, positive value"}, + {"11", 12345321, 11, "%10.12li", "000012345321", + "%li with precision field size > minimum field size > number of digits, positive value"}, + {"12", 12333345, 7, "%6.12li", "000012333345", + "%li with precision field size > number of digits > minimum field size, positive value"}, + {"13", 12345777, 5, "%2.4li", "12345777", + "%li with number of digits > precision field size > minimum field size, positive value"}, + {"14", 98765321, 19, "%-.20li", "00000000000098765321", + "%li with left-justify and precision field size > number of digits, positive value"}, + {"15", 98765111, 7, "%-.3li", "98765111", + "%li with left-justify and precision field size < number of digits, positive value"}, {"16", 98765222, 10, "%+li", "+98765222", "%li with sign, positive value"}, {"17", 46372333, 9, "$$$%+li$$$", "$$$+46372333$$$", "%li sign and embedded, positive value"}, - {"18", 91827444, 8, "%+11li", " +91827444", "%li with sign and minimum field size > number of digits, positive value"}, - {"19", 91827555, 7, "%+4li", "+91827555", "%li with sign and minimum field size < number of digits, positive value"}, - {"20", 33225666, 2, "%+.13li", "+0000033225666", "%li with sign and precision field size > number of digits, positive value"}, - {"21", 33225777, 5, "%+.3li", "+33225777", "%li with sign and precision field size < number of digits, positive value"}, - {"22", 12345888, 9, "%+12.10li", " +0012345888", "%li with sign and minimum field size > precision field size > number of digits, positive value"}, - {"23", 12345999, 8, "%+12.3li", " +12345999", "%li with sign and minimum field size > number of digits > precision field size, positive value"}, - {"24", 12345000, 9, "%+4.2li", "+12345000", "%li with sign and number of digits > minimum field size > precision field size, positive value"}, - {"25", 12345121, 11, "%+10.12li", "+000012345121", "%li with sign and precision field size > minimum field size > number of digits, positive value"}, - {"26", 12345232, 10, "%+6.12li", "+000012345232", "%li with sign and precision field size > number of digits > minimum field size, positive value"}, - {"27", 12345343, 7, "%+2.4li", "+12345343", "%li with sign and number of digits > precision field size > minimum field size, positive value"}, - {"28", 98765454, 15, "%+-.20li", "+00000000000098765454", "%li with sign and left-justify and precision field size > number of digits, positive value"}, - {"29", 98765565, 8, "%+-.3li", "+98765565", "%li with sign and left-justify and precision field size < number of digits, positive value"}, + {"18", 91827444, 8, "%+11li", " +91827444", + "%li with sign and minimum field size > number of digits, positive value"}, + {"19", 91827555, 7, "%+4li", "+91827555", + "%li with sign and minimum field size < number of digits, positive value"}, + {"20", 33225666, 2, "%+.13li", "+0000033225666", + "%li with sign and precision field size > number of digits, positive value"}, + {"21", 33225777, 5, "%+.3li", "+33225777", + "%li with sign and precision field size < number of digits, positive value"}, + {"22", 12345888, 9, "%+12.10li", " +0012345888", + "%li with sign and minimum field size > precision field size > number of digits, positive value"}, + {"23", 12345999, 8, "%+12.3li", " +12345999", + "%li with sign and minimum field size > number of digits > precision field size, positive value"}, + {"24", 12345000, 9, "%+4.2li", "+12345000", + "%li with sign and number of digits > minimum field size > precision field size, positive value"}, + {"25", 12345121, 11, "%+10.12li", "+000012345121", + "%li with sign and precision field size > minimum field size > number of digits, positive value"}, + {"26", 12345232, 10, "%+6.12li", "+000012345232", + "%li with sign and precision field size > number of digits > minimum field size, positive value"}, + {"27", 12345343, 7, "%+2.4li", "+12345343", + "%li with sign and number of digits > precision field size > minimum field size, positive value"}, + {"28", 98765454, 15, "%+-.20li", "+00000000000098765454", + "%li with sign and left-justify and precision field size > number of digits, positive value"}, + {"29", 98765565, 8, "%+-.3li", "+98765565", + "%li with sign and left-justify and precision field size < number of digits, positive value"}, {"30", 98765676, 7, "%+li", "+98765676", "%li with sign, positive value"}, {"31", -98765787, 6, "%li", "-98765787", "%li, negative value"}, {"32", -46372898, 15, "$$$%li$$$", "$$$-46372898$$$", "%li embedded, negative value"}, {"33", -98765909, 9, "% li", "-98765909", "%li with space for sign, negative value"}, - {"34", -91827121, 11, "%13li", " -91827121", "%li with minimum field size > number of digits, negative value"}, + {"34", -91827121, 11, "%13li", " -91827121", + "%li with minimum field size > number of digits, negative value"}, {"35", -91827232, 5, "%4li", "-91827232", "%li with minimum field size < number of digits, negative value"}, - {"36", -33225343, 8, "%.13li", "-0000033225343", "%li with precision field size > number of digits, negative value"}, + {"36", -33225343, 8, "%.13li", "-0000033225343", + "%li with precision field size > number of digits, negative value"}, {"37", -33225454, 7, "%.3li", "-33225454", "%li with precision field size < number of digits, negative value"}, - {"38", -12345565, 9, "%12.10li", " -0012345565", "%li with minimum field size > precision field size > number of digits, negative value"}, - {"39", -12345676, 8, "%12.4li", " -12345676", "%li with minimum field size > number of digits > precision field size, negative value"}, - {"40", -12345787, 4, "%4.2li", "-12345787", "%li with number of digits > minimum field size > precision field size, negative value"}, - {"41", -12345898, 10, "%7.12li", "-000012345898", "%li with precision field size > minimum field size > number of digits, negative value"}, - {"42", -12345909, 9, "%3.12li", "-000012345909", "%li with precision field size > number of digits > minimum field size, negative value"}, - {"43", -12345101, 7, "%2.4li", "-12345101", "%li with number of digits > precision field size > minimum field size, negative value"}, - {"44", -98765292, 18, "%-.20li", "-00000000000098765292", "%li with left-justify and precision field size > number of digits, negative value"}, - {"45", -98765383, 7, "%-.3li", "-98765383", "%li with left-justify and precision field size < number of digits, negative value"}, + {"38", -12345565, 9, "%12.10li", " -0012345565", + "%li with minimum field size > precision field size > number of digits, negative value"}, + {"39", -12345676, 8, "%12.4li", " -12345676", + "%li with minimum field size > number of digits > precision field size, negative value"}, + {"40", -12345787, 4, "%4.2li", "-12345787", + "%li with number of digits > minimum field size > precision field size, negative value"}, + {"41", -12345898, 10, "%7.12li", "-000012345898", + "%li with precision field size > minimum field size > number of digits, negative value"}, + {"42", -12345909, 9, "%3.12li", "-000012345909", + "%li with precision field size > number of digits > minimum field size, negative value"}, + {"43", -12345101, 7, "%2.4li", "-12345101", + "%li with number of digits > precision field size > minimum field size, negative value"}, + {"44", -98765292, 18, "%-.20li", "-00000000000098765292", + "%li with left-justify and precision field size > number of digits, negative value"}, + {"45", -98765383, 7, "%-.3li", "-98765383", + "%li with left-justify and precision field size < number of digits, negative value"}, {"46", -98765474, 8, "%+li", "-98765474", "%li with sign, negative value"}, {"47", -46372565, 10, "$$$%+li$$$", "$$$-46372565$$$", "%li sign and embedded, negative value"}, - {"48", -91827112, 9, "%+11li", " -91827112", "%li with sign and minimum field size > number of digits, negative value"}, - {"49", -91827223, 5, "%+4li", "-91827223", "%li with sign and minimum field size < number of digits, negative value"}, - {"50", -33225334, 11, "%+.13li", "-0000033225334", "%li with sign and precision field size > number of digits, negative value"}, - {"51", -33225445, 8, "%+.3li", "-33225445", "%li with sign and precision field size < number of digits, negative value"}, - {"52", -12345556, 12, "%+12.10li", " -0012345556", "%li with sign and minimum field size > precision field size > number of digits, negative value"}, - {"53", -12345667, 10, "%+12.3li", " -12345667", "%li with sign and minimum field size > number of digits > precision field size, negative value"}, - {"54", -12345778, 6, "%+4.2li", "-12345778", "%li with sign and number of digits > minimum field size > precision field size, negative value"}, - {"55", -12345889, 9, "%+7.12li", "-000012345889", "%li with sign and precision field size > minimum field size > number of digits, negative value"}, - {"56", -12345990, 11, "%+3.12li", "-000012345990", "%li with sign and precision field size > number of digits > minimum field size, negative value"}, - {"57", -12345221, 7, "%+2.4li", "-12345221", "%li with sign and number of digits > precision field size > minimum field size, negative value"}, - {"58", -98765332, 15, "%+-.20li", "-00000000000098765332", "%li with sign and left-justify and precision field size > number of digits, negative value"}, - {"59", -98765443, 7, "%+-.3li", "-98765443", "%li with sign and left-justify and precision field size < number of digits, negative value"}, + {"48", -91827112, 9, "%+11li", " -91827112", + "%li with sign and minimum field size > number of digits, negative value"}, + {"49", -91827223, 5, "%+4li", "-91827223", + "%li with sign and minimum field size < number of digits, negative value"}, + {"50", -33225334, 11, "%+.13li", "-0000033225334", + "%li with sign and precision field size > number of digits, negative value"}, + {"51", -33225445, 8, "%+.3li", "-33225445", + "%li with sign and precision field size < number of digits, negative value"}, + {"52", -12345556, 12, "%+12.10li", " -0012345556", + "%li with sign and minimum field size > precision field size > number of digits, negative value"}, + {"53", -12345667, 10, "%+12.3li", " -12345667", + "%li with sign and minimum field size > number of digits > precision field size, negative value"}, + {"54", -12345778, 6, "%+4.2li", "-12345778", + "%li with sign and number of digits > minimum field size > precision field size, negative value"}, + {"55", -12345889, 9, "%+7.12li", "-000012345889", + "%li with sign and precision field size > minimum field size > number of digits, negative value"}, + {"56", -12345990, 11, "%+3.12li", "-000012345990", + "%li with sign and precision field size > number of digits > minimum field size, negative value"}, + {"57", -12345221, 7, "%+2.4li", "-12345221", + "%li with sign and number of digits > precision field size > minimum field size, negative value"}, + {"58", -98765332, 15, "%+-.20li", "-00000000000098765332", + "%li with sign and left-justify and precision field size > number of digits, negative value"}, + {"59", -98765443, 7, "%+-.3li", "-98765443", + "%li with sign and left-justify and precision field size < number of digits, negative value"}, {"60", -98765554, 5, "%+li", "-98765554", "%li with sign, negative value"}, {"61", 0, 6, "%li", "0", "%li, zero value"}, {"62", 16253409, 5, "%010li", "0016253409", "%li with zero padding, positive value"}, @@ -120,10 +161,7 @@ void UT_osprintf_li(void) /* Perform sprintf test */ init_test(); sprintf(strg_buf, osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(osp_tests[i].expected, strg_buf), - "SPRINTF", - osp_tests[i].description, - test_fmt, + UT_Report(check_test(osp_tests[i].expected, strg_buf), "SPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); /* Truncate expected string in preparation for snprintf test */ @@ -136,12 +174,8 @@ void UT_osprintf_li(void) /* Perform snprintf test */ init_test(); - snprintf(strg_buf, osp_tests[i].max_len, - osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(trunc_buf, strg_buf), - "SNPRINTF", - osp_tests[i].description, - test_fmt, + snprintf(strg_buf, osp_tests[i].max_len, osp_tests[i].format, osp_tests[i].test_val); + UT_Report(check_test(trunc_buf, strg_buf), "SNPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); } } diff --git a/src/unit-tests/osprintf-test/ut_osprintf_lu.c b/src/unit-tests/osprintf-test/ut_osprintf_lu.c index c6052db41..182c55620 100644 --- a/src/unit-tests/osprintf-test/ut_osprintf_lu.c +++ b/src/unit-tests/osprintf-test/ut_osprintf_lu.c @@ -36,21 +36,20 @@ extern char trunc_buf[]; void UT_osprintf_lu(void) { char *test_fmt = "lu"; /* Test format character(s) */ - int i; + int i; #ifdef OSP_ARINC653 #pragma ghs nowarning 68 #endif struct { - char *test_num; /* Test identifier; sequential numbers */ - unsigned long int test_val; /* Test value */ - int max_len; /* Maximum output string length */ - char *format; /* Format string */ - char *expected; /* Expected result */ - char *description; /* Test description */ - } osp_tests[] = - { + char * test_num; /* Test identifier; sequential numbers */ + unsigned long int test_val; /* Test value */ + int max_len; /* Maximum output string length */ + char * format; /* Format string */ + char * expected; /* Expected result */ + char * description; /* Test description */ + } osp_tests[] = { {"01", 9876543, 6, "%lu", "9876543", "%lu, negative value"}, {"02", 4637210, 12, "$$$%lu$$$", "$$$4637210$$$", "%lu embedded"}, {"03", 9182755, 6, "%3lu", "9182755", "%lu with maximum field size"}, @@ -72,10 +71,7 @@ void UT_osprintf_lu(void) /* Perform sprintf test */ init_test(); sprintf(strg_buf, osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(osp_tests[i].expected, strg_buf), - "SPRINTF", - osp_tests[i].description, - test_fmt, + UT_Report(check_test(osp_tests[i].expected, strg_buf), "SPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); /* Truncate expected string in preparation for snprintf test */ @@ -88,12 +84,8 @@ void UT_osprintf_lu(void) /* Perform snprintf test */ init_test(); - snprintf(strg_buf, osp_tests[i].max_len, - osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(trunc_buf, strg_buf), - "SNPRINTF", - osp_tests[i].description, - test_fmt, + snprintf(strg_buf, osp_tests[i].max_len, osp_tests[i].format, osp_tests[i].test_val); + UT_Report(check_test(trunc_buf, strg_buf), "SNPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); } } diff --git a/src/unit-tests/osprintf-test/ut_osprintf_lx.c b/src/unit-tests/osprintf-test/ut_osprintf_lx.c index e83e6af42..72678d73c 100644 --- a/src/unit-tests/osprintf-test/ut_osprintf_lx.c +++ b/src/unit-tests/osprintf-test/ut_osprintf_lx.c @@ -36,21 +36,20 @@ extern char trunc_buf[]; void UT_osprintf_lx(void) { char *test_fmt = "lx"; /* Test format character(s) */ - int i; + int i; #ifdef OSP_ARINC653 #pragma ghs nowarning 68 #endif struct { - char *test_num; /* Test identifier; sequential numbers */ - unsigned long int test_val; /* Test value */ - int max_len; /* Maximum output string length */ - char *format; /* Format string */ - char *expected; /* Expected result */ - char *description; /* Test description */ - } osp_tests[] = - { + char * test_num; /* Test identifier; sequential numbers */ + unsigned long int test_val; /* Test value */ + int max_len; /* Maximum output string length */ + char * format; /* Format string */ + char * expected; /* Expected result */ + char * description; /* Test description */ + } osp_tests[] = { {"01", 0x9a8b7c6d, 5, "%lx", "9a8b7c6d", "%lx"}, {"02", 0xdd46ee21, 12, "$$$%lx$$$", "$$$dd46ee21$$$", "%lx embedded"}, {"03", 0x9ccc8275, 7, "%3lx", "9ccc8275", "%lx with minimum field size < number of digits"}, @@ -71,10 +70,7 @@ void UT_osprintf_lx(void) /* Perform sprintf test */ init_test(); sprintf(strg_buf, osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(osp_tests[i].expected, strg_buf), - "SPRINTF", - osp_tests[i].description, - test_fmt, + UT_Report(check_test(osp_tests[i].expected, strg_buf), "SPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); /* Truncate expected string in preparation for snprintf test */ @@ -87,12 +83,8 @@ void UT_osprintf_lx(void) /* Perform snprintf test */ init_test(); - snprintf(strg_buf, osp_tests[i].max_len, - osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(trunc_buf, strg_buf), - "SNPRINTF", - osp_tests[i].description, - test_fmt, + snprintf(strg_buf, osp_tests[i].max_len, osp_tests[i].format, osp_tests[i].test_val); + UT_Report(check_test(trunc_buf, strg_buf), "SNPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); } } diff --git a/src/unit-tests/osprintf-test/ut_osprintf_lx_uc.c b/src/unit-tests/osprintf-test/ut_osprintf_lx_uc.c index 6cc5ccf9a..ab98a17a4 100644 --- a/src/unit-tests/osprintf-test/ut_osprintf_lx_uc.c +++ b/src/unit-tests/osprintf-test/ut_osprintf_lx_uc.c @@ -36,21 +36,20 @@ extern char trunc_buf[]; void UT_osprintf_lX(void) { char *test_fmt = "lx"; /* Test format character(s) */ - int i; + int i; #ifdef OSP_ARINC653 #pragma ghs nowarning 68 #endif struct { - char *test_num; /* Test identifier; sequential numbers */ - unsigned long int test_val; /* Test value */ - int max_len; /* Maximum output string length */ - char *format; /* Format string */ - char *expected; /* Expected result */ - char *description; /* Test description */ - } osp_tests[] = - { + char * test_num; /* Test identifier; sequential numbers */ + unsigned long int test_val; /* Test value */ + int max_len; /* Maximum output string length */ + char * format; /* Format string */ + char * expected; /* Expected result */ + char * description; /* Test description */ + } osp_tests[] = { {"01", 0x9a8b7c6d, 8, "%lX", "9A8B7C6D", "%lX"}, {"02", 0xdd46ee21, 8, "$$$%lX$$$", "$$$DD46EE21$$$", "%lX embedded"}, {"03", 0x9ccc8275, 7, "%3lX", "9CCC8275", "%lX with minimum field size < number of digits"}, @@ -71,10 +70,7 @@ void UT_osprintf_lX(void) /* Perform sprintf test */ init_test(); sprintf(strg_buf, osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(osp_tests[i].expected, strg_buf), - "SPRINTF", - osp_tests[i].description, - test_fmt, + UT_Report(check_test(osp_tests[i].expected, strg_buf), "SPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); /* Truncate expected string in preparation for snprintf test */ @@ -87,12 +83,8 @@ void UT_osprintf_lX(void) /* Perform snprintf test */ init_test(); - snprintf(strg_buf, osp_tests[i].max_len, - osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(trunc_buf, strg_buf), - "SNPRINTF", - osp_tests[i].description, - test_fmt, + snprintf(strg_buf, osp_tests[i].max_len, osp_tests[i].format, osp_tests[i].test_val); + UT_Report(check_test(trunc_buf, strg_buf), "SNPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); } } diff --git a/src/unit-tests/osprintf-test/ut_osprintf_misc.c b/src/unit-tests/osprintf-test/ut_osprintf_misc.c index fff847829..a191f1c79 100644 --- a/src/unit-tests/osprintf-test/ut_osprintf_misc.c +++ b/src/unit-tests/osprintf-test/ut_osprintf_misc.c @@ -34,171 +34,146 @@ extern char strg_buf[]; *****************************************************************************/ void UT_osprintf_misc(void) { - int test_int; - long test_long; + int test_int; + long test_long; unsigned test_unsigned; unsigned test_hex; - char *test_num = "misc"; - int return_value; + char * test_num = "misc"; + int return_value; #ifndef UT_NO_FLOAT - float test_float; + float test_float; double test_double; - char test_char; + char test_char; #endif /* Test representing percent character using %% */ init_test(); sprintf(strg_buf, "Show percent character .%%."); - UT_Report(check_test("Show percent character .%.", strg_buf), "SPRINTF", - "Represent percent character using %%", + UT_Report(check_test("Show percent character .%.", strg_buf), "SPRINTF", "Represent percent character using %%", test_num, "01"); /* Test representing percent character using %%, truncated */ init_test(); snprintf(strg_buf, 11, "Show percent character .%%."); - UT_Report(check_test("Show perce", strg_buf), "SNPRINTF", - "Represent percent character using %%, truncated", + UT_Report(check_test("Show perce", strg_buf), "SNPRINTF", "Represent percent character using %%, truncated", test_num, "01"); /* Test format string ending with percent character */ init_test(); sprintf(strg_buf, "End with percent character %"); - UT_Report(check_test("End with percent character ", strg_buf), "SPRINTF", - "End with percent character", - test_num, "02"); + UT_Report(check_test("End with percent character ", strg_buf), "SPRINTF", "End with percent character", test_num, + "02"); /* Test representing percent character using %%, truncated */ init_test(); snprintf(strg_buf, 11, "End with percent character %"); - UT_Report(check_test("End with p", strg_buf), "SNPRINTF", - "End with percent character, truncated", - test_num, "02"); + UT_Report(check_test("End with p", strg_buf), "SNPRINTF", "End with percent character, truncated", test_num, "02"); /* Test null format string */ init_test(); sprintf(strg_buf, ""); - UT_Report(check_test("", strg_buf), "SPRINTF", - "Null format string", - test_num, "03"); + UT_Report(check_test("", strg_buf), "SPRINTF", "Null format string", test_num, "03"); /* Test representing percent character using %%, truncated */ init_test(); snprintf(strg_buf, 5, ""); - UT_Report(check_test("", strg_buf), "SNPRINTF", - "Null format string", - test_num, "03"); + UT_Report(check_test("", strg_buf), "SNPRINTF", "Null format string", test_num, "03"); /* Test too many decimals in format width/precision modifier */ init_test(); return_value = sprintf(strg_buf, "Too many decimals"); - UT_Report(return_value < 0, "SPRINTF", - "Invalid format string", - test_num, "04"); + UT_Report(return_value < 0, "SPRINTF", "Invalid format string", test_num, "04"); /* Test too many decimals in format width/precision modifier, truncated */ init_test(); return_value = snprintf(strg_buf, 23, "Too many decimals"); - UT_Report(return_value < 0, "SNPRINTF", - "Invalid format string", - test_num, "04"); + UT_Report(return_value < 0, "SNPRINTF", "Invalid format string", test_num, "04"); /* Test multiple parameters */ init_test(); - test_int = 121; - test_long = -9876222; + test_int = 121; + test_long = -9876222; test_unsigned = 5432; - test_hex = 72635; - sprintf(strg_buf, "Multiple parameters %d:%d, %d:%d, %d:%d, %d:%d", - 1, test_int, 2, test_long, 3, test_unsigned, 4, test_hex); + test_hex = 72635; + sprintf(strg_buf, "Multiple parameters %d:%d, %d:%d, %d:%d, %d:%d", 1, test_int, 2, test_long, 3, test_unsigned, 4, + test_hex); UT_Report(check_test("Multiple parameters 1:121, 2:-9876222, " - "3:5432, 4:72635", strg_buf), "SPRINTF", - "Multiple parameters", - test_num, "05"); + "3:5432, 4:72635", + strg_buf), + "SPRINTF", "Multiple parameters", test_num, "05"); /* Test multiple parameters, truncated */ init_test(); - test_int = 121; - test_long = -9876222; + test_int = 121; + test_long = -9876222; test_unsigned = 5432; - test_hex = 72635; - snprintf(strg_buf, 52, "Multiple parameters %d:%d, %d:%d, %d:%d, %d:%d", - 1, test_int, 2, test_long, 3, test_unsigned, 4, test_hex); + test_hex = 72635; + snprintf(strg_buf, 52, "Multiple parameters %d:%d, %d:%d, %d:%d, %d:%d", 1, test_int, 2, test_long, 3, + test_unsigned, 4, test_hex); UT_Report(check_test("Multiple parameters 1:121, 2:-9876222, " - "3:5432, 4:72", strg_buf), "SNPRINTF", - "Multiple parameters", - test_num, "05"); + "3:5432, 4:72", + strg_buf), + "SNPRINTF", "Multiple parameters", test_num, "05"); #ifndef UT_NO_FLOAT /* Test combination of types */ init_test(); - test_int = -123; - test_long = 9876543; + test_int = -123; + test_long = 9876543; test_unsigned = 4321; - test_hex = 0xa1b2; - test_float = -2.3456; - test_double = 6543.123456; - test_char = '$'; + test_hex = 0xa1b2; + test_float = -2.3456; + test_double = 6543.123456; + test_char = '$'; sprintf(strg_buf, "int = %d long = %ld uns = %u hex = 0x%x flt = %f " - "dbl = %lf chr = %c", - test_int, test_long, test_unsigned, test_hex, - test_float, test_double, test_char); + "dbl = %lf chr = %c", + test_int, test_long, test_unsigned, test_hex, test_float, test_double, test_char); UT_Report(check_test("int = -123 long = 9876543 uns = 4321 hex = " - "0xa1b2 flt = -2.345600 dbl = 6543.123456 " - "chr = $", strg_buf), "SPRINTF", - "Combination of types", - test_num, "06"); + "0xa1b2 flt = -2.345600 dbl = 6543.123456 " + "chr = $", + strg_buf), + "SPRINTF", "Combination of types", test_num, "06"); /* Test combination of types, truncated */ init_test(); - test_int = -123; - test_long = 9876543; + test_int = -123; + test_long = 9876543; test_unsigned = 4321; - test_hex = 0xa1b2; - test_float = -2.3456; - test_double = 6543.123456; - test_char = '$'; + test_hex = 0xa1b2; + test_float = -2.3456; + test_double = 6543.123456; + test_char = '$'; snprintf(strg_buf, 16, "int = %d long = %ld uns = %u hex = 0x%x flt = %f " - "dbl = %lf chr = %c", - test_int, test_long, test_unsigned, test_hex, - test_float, test_double, test_char); - UT_Report(check_test("int = -123 lon", strg_buf), "SNPRINTF", - "Combination of types, truncated", - test_num, "06"); + "dbl = %lf chr = %c", + test_int, test_long, test_unsigned, test_hex, test_float, test_double, test_char); + UT_Report(check_test("int = -123 lon", strg_buf), "SNPRINTF", "Combination of types, truncated", test_num, "06"); /* Test combination of types 2 */ init_test(); - test_int = -123; - test_long = 9876543; + test_int = -123; + test_long = 9876543; test_unsigned = 4321; - test_hex = 0xa1b2; - test_float = -2.3456; - test_double = 6543.123456; - test_char = '$'; - sprintf(strg_buf, - "flt = %f dbl = %lf flt = %f", - test_float, test_double, test_float); - UT_Report(check_test("flt = -2.345600 dbl = 6543.123456 flt = -2.345600", - strg_buf), "SPRINTF", - "Combination of types 2", - test_num, "07"); + test_hex = 0xa1b2; + test_float = -2.3456; + test_double = 6543.123456; + test_char = '$'; + sprintf(strg_buf, "flt = %f dbl = %lf flt = %f", test_float, test_double, test_float); + UT_Report(check_test("flt = -2.345600 dbl = 6543.123456 flt = -2.345600", strg_buf), "SPRINTF", + "Combination of types 2", test_num, "07"); /* Test combination of types 2, truncated */ init_test(); - test_int = -123; - test_long = 9876543; + test_int = -123; + test_long = 9876543; test_unsigned = 4321; - test_hex = 0xa1b2; - test_float = -2.3456; - test_double = 6543.123456; - test_char = '$'; - snprintf(strg_buf, 10, - "flt = %f dbl = %lf flt = %f", - test_float, test_double, test_float); - UT_Report(check_test("flt = -2.", strg_buf), "SNPRINTF", - "Combination of types 2", - test_num, "07"); + test_hex = 0xa1b2; + test_float = -2.3456; + test_double = 6543.123456; + test_char = '$'; + snprintf(strg_buf, 10, "flt = %f dbl = %lf flt = %f", test_float, test_double, test_float); + UT_Report(check_test("flt = -2.", strg_buf), "SNPRINTF", "Combination of types 2", test_num, "07"); #endif } diff --git a/src/unit-tests/osprintf-test/ut_osprintf_offset.c b/src/unit-tests/osprintf-test/ut_osprintf_offset.c index 0670fe750..f9874edb9 100644 --- a/src/unit-tests/osprintf-test/ut_osprintf_offset.c +++ b/src/unit-tests/osprintf-test/ut_osprintf_offset.c @@ -36,154 +36,30 @@ extern int OS_printf_break; extern int OS_printf_skip; extern int OS_printf_enabled; - -unsigned long testPattern[12][10] = -{ - { - 0x12ab34cd, - 0x19999991, - 0x18888881, - 0x17777771, - 0x16666661, - 0x15555551, - 0x14444441, - 0x13333331, - 0x12222221, - 0x11111111 - }, - { - 0x23bc45de, - 0x29999992, - 0x28888882, - 0x27777772, - 0x26666662, - 0x25555552, - 0x24444442, - 0x23333332, - 0x22222222, - 0x21111112 - }, - { - 0x34cd56ef, - 0x39999993, - 0x38888883, - 0x37777773, - 0x36666663, - 0x35555553, - 0x34444443, - 0x33333333, - 0x32222223, - 0x31111113 - }, - { - 0x45ab67cd, - 0x49999994, - 0x48888884, - 0x47777774, - 0x46666664, - 0x45555554, - 0x44444444, - 0x43333334, - 0x42222224, - 0x41111114 - }, - { - 0x56bc78de, - 0x59999995, - 0x58888885, - 0x57777775, - 0x56666665, - 0x55555555, - 0x54444445, - 0x53333335, - 0x52222225, - 0x51111115 - }, - { - 0x67cd78ef, - 0x69999996, - 0x68888886, - 0x67777776, - 0x66666666, - 0x65555556, - 0x64444446, - 0x63333336, - 0x62222226, - 0x61111116 - }, - { - 0x78ab9acd, - 0x79999997, - 0x78888887, - 0x77777777, - 0x76666667, - 0x75555557, - 0x74444447, - 0x73333337, - 0x72222227, - 0x71111117 - }, - { - 0x89bcabde, - 0x89999998, - 0x88888888, - 0x87777778, - 0x86666668, - 0x85555558, - 0x84444448, - 0x83333338, - 0x82222228, - 0x81111118 - }, - { - 0x9acdbcef, - 0x99999999, - 0x98888889, - 0x97777779, - 0x96666669, - 0x95555559, - 0x94444449, - 0x93333339, - 0x92222229, - 0x91111119 - }, - { - 0xababcdcd, - 0xa999999a, - 0xa888888a, - 0xa777777a, - 0xa666666a, - 0xa555555a, - 0xa444444a, - 0xa333333a, - 0xa222222a, - 0xa111111a - }, - { - 0xbcbcdede, - 0xb999999b, - 0xb888888b, - 0xb777777b, - 0xb666666b, - 0xb555555b, - 0xb444444b, - 0xb333333b, - 0xb222222b, - 0xb111111b - }, - { - 0xcdcdefef, - 0xc999999c, - 0xc888888c, - 0xc777777c, - 0xc666666c, - 0xc555555c, - 0xc444444c, - 0xc333333c, - 0xc222222c, - 0xc111111c - } -}; +unsigned long testPattern[12][10] = {{0x12ab34cd, 0x19999991, 0x18888881, 0x17777771, 0x16666661, 0x15555551, + 0x14444441, 0x13333331, 0x12222221, 0x11111111}, + {0x23bc45de, 0x29999992, 0x28888882, 0x27777772, 0x26666662, 0x25555552, + 0x24444442, 0x23333332, 0x22222222, 0x21111112}, + {0x34cd56ef, 0x39999993, 0x38888883, 0x37777773, 0x36666663, 0x35555553, + 0x34444443, 0x33333333, 0x32222223, 0x31111113}, + {0x45ab67cd, 0x49999994, 0x48888884, 0x47777774, 0x46666664, 0x45555554, + 0x44444444, 0x43333334, 0x42222224, 0x41111114}, + {0x56bc78de, 0x59999995, 0x58888885, 0x57777775, 0x56666665, 0x55555555, + 0x54444445, 0x53333335, 0x52222225, 0x51111115}, + {0x67cd78ef, 0x69999996, 0x68888886, 0x67777776, 0x66666666, 0x65555556, + 0x64444446, 0x63333336, 0x62222226, 0x61111116}, + {0x78ab9acd, 0x79999997, 0x78888887, 0x77777777, 0x76666667, 0x75555557, + 0x74444447, 0x73333337, 0x72222227, 0x71111117}, + {0x89bcabde, 0x89999998, 0x88888888, 0x87777778, 0x86666668, 0x85555558, + 0x84444448, 0x83333338, 0x82222228, 0x81111118}, + {0x9acdbcef, 0x99999999, 0x98888889, 0x97777779, 0x96666669, 0x95555559, + 0x94444449, 0x93333339, 0x92222229, 0x91111119}, + {0xababcdcd, 0xa999999a, 0xa888888a, 0xa777777a, 0xa666666a, 0xa555555a, + 0xa444444a, 0xa333333a, 0xa222222a, 0xa111111a}, + {0xbcbcdede, 0xb999999b, 0xb888888b, 0xb777777b, 0xb666666b, 0xb555555b, + 0xb444444b, 0xb333333b, 0xb222222b, 0xb111111b}, + {0xcdcdefef, 0xc999999c, 0xc888888c, 0xc777777c, 0xc666666c, 0xc555555c, + 0xc444444c, 0xc333333c, 0xc222222c, 0xc111111c}}; void UT_osprintf_CalcOffsets(void) { @@ -191,90 +67,58 @@ void UT_osprintf_CalcOffsets(void) /* Determine variadic offsets */ CalcOffset_CFE_ES_WriteToSysLog("CFE_ES_WriteToSysLog test %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", - testPattern[0][0], testPattern[0][1], - testPattern[0][2], testPattern[0][3], - testPattern[0][4], testPattern[0][5], - testPattern[0][6], testPattern[0][7], + testPattern[0][0], testPattern[0][1], testPattern[0][2], testPattern[0][3], + testPattern[0][4], testPattern[0][5], testPattern[0][6], testPattern[0][7], testPattern[0][8], testPattern[0][9]); - CalcOffset_EVS_SendEvent(111, 222, - "EVS_SendEvent test %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", - testPattern[1][0], testPattern[1][1], - testPattern[1][2], testPattern[1][3], - testPattern[1][4], testPattern[1][5], - testPattern[1][6], testPattern[1][7], - testPattern[1][8], testPattern[1][9]); - CalcOffset_CFE_EVS_SendEvent(333, 444, - "CFE_EVS_SendEvent test %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", - testPattern[2][0], testPattern[2][1], - testPattern[2][2], testPattern[2][3], - testPattern[2][4], testPattern[2][5], - testPattern[2][6], testPattern[2][7], + CalcOffset_EVS_SendEvent(111, 222, "EVS_SendEvent test %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", testPattern[1][0], + testPattern[1][1], testPattern[1][2], testPattern[1][3], testPattern[1][4], + testPattern[1][5], testPattern[1][6], testPattern[1][7], testPattern[1][8], + testPattern[1][9]); + CalcOffset_CFE_EVS_SendEvent(333, 444, "CFE_EVS_SendEvent test %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", + testPattern[2][0], testPattern[2][1], testPattern[2][2], testPattern[2][3], + testPattern[2][4], testPattern[2][5], testPattern[2][6], testPattern[2][7], testPattern[2][8], testPattern[2][9]); - CalcOffset_CFE_EVS_SendEventWithAppID(555, 666, 7, - "CFE_EVS_SendEventWithAppID test %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", - testPattern[3][0], testPattern[3][1], - testPattern[3][2], testPattern[3][3], - testPattern[3][4], testPattern[3][5], - testPattern[3][6], testPattern[3][7], - testPattern[3][8], testPattern[3][9]); - CalcOffset_CFE_EVS_SendTimedEvent(Time, 888, 999, - "CFE_EVS_SendTimedEvent test %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", - testPattern[4][0], testPattern[4][1], - testPattern[4][2], testPattern[4][3], - testPattern[4][4], testPattern[4][5], - testPattern[4][6], testPattern[4][7], - testPattern[4][8], testPattern[4][9]); - CalcOffset_OS_printf("OS_printf test %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", - testPattern[5][0], testPattern[5][1], - testPattern[5][2], testPattern[5][3], - testPattern[5][4], testPattern[5][5], - testPattern[5][6], testPattern[5][7], - testPattern[5][8], testPattern[5][9]); - CalcOffset_OS_sprintf(cMsg, "OS_sprintf test %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", - testPattern[6][0], testPattern[6][1], - testPattern[6][2], testPattern[6][3], - testPattern[6][4], testPattern[6][5], - testPattern[6][6], testPattern[6][7], - testPattern[6][8], testPattern[6][9]); - CalcOffset_OS_snprintf(cMsg, 100, "OS_snprintf test %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", - testPattern[7][0], testPattern[7][1], - testPattern[7][2], testPattern[7][3], - testPattern[7][4], testPattern[7][5], - testPattern[7][6], testPattern[7][7], - testPattern[7][8], testPattern[7][9]); - CalcOffset_OS_printf_stub("OS_printf stub test %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", - testPattern[8][0], testPattern[8][1], - testPattern[8][2], testPattern[8][3], - testPattern[8][4], testPattern[8][5], - testPattern[8][6], testPattern[8][7], - testPattern[8][8], testPattern[8][9]); + CalcOffset_CFE_EVS_SendEventWithAppID( + 555, 666, 7, "CFE_EVS_SendEventWithAppID test %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", testPattern[3][0], + testPattern[3][1], testPattern[3][2], testPattern[3][3], testPattern[3][4], testPattern[3][5], + testPattern[3][6], testPattern[3][7], testPattern[3][8], testPattern[3][9]); + CalcOffset_CFE_EVS_SendTimedEvent( + Time, 888, 999, "CFE_EVS_SendTimedEvent test %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", testPattern[4][0], + testPattern[4][1], testPattern[4][2], testPattern[4][3], testPattern[4][4], testPattern[4][5], + testPattern[4][6], testPattern[4][7], testPattern[4][8], testPattern[4][9]); + CalcOffset_OS_printf("OS_printf test %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", testPattern[5][0], testPattern[5][1], + testPattern[5][2], testPattern[5][3], testPattern[5][4], testPattern[5][5], testPattern[5][6], + testPattern[5][7], testPattern[5][8], testPattern[5][9]); + CalcOffset_OS_sprintf(cMsg, "OS_sprintf test %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", testPattern[6][0], + testPattern[6][1], testPattern[6][2], testPattern[6][3], testPattern[6][4], testPattern[6][5], + testPattern[6][6], testPattern[6][7], testPattern[6][8], testPattern[6][9]); + CalcOffset_OS_snprintf(cMsg, 100, "OS_snprintf test %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", testPattern[7][0], + testPattern[7][1], testPattern[7][2], testPattern[7][3], testPattern[7][4], + testPattern[7][5], testPattern[7][6], testPattern[7][7], testPattern[7][8], + testPattern[7][9]); + CalcOffset_OS_printf_stub("OS_printf stub test %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", testPattern[8][0], + testPattern[8][1], testPattern[8][2], testPattern[8][3], testPattern[8][4], + testPattern[8][5], testPattern[8][6], testPattern[8][7], testPattern[8][8], + testPattern[8][9]); CalcOffset_CFE_ES_WriteToSysLog_stub("CFE_ES_WriteToSysLog stub test %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", - testPattern[9][0], testPattern[9][1], - testPattern[9][2], testPattern[9][3], - testPattern[9][4], testPattern[9][5], - testPattern[9][6], testPattern[9][7], + testPattern[9][0], testPattern[9][1], testPattern[9][2], testPattern[9][3], + testPattern[9][4], testPattern[9][5], testPattern[9][6], testPattern[9][7], testPattern[9][8], testPattern[9][9]); - CalcOffset_CFE_EVS_SendEvent_stub(333, 444, - "CFE_EVS_SendEvent stub test %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", - testPattern[10][0], testPattern[10][1], - testPattern[10][2], testPattern[10][3], - testPattern[10][4], testPattern[10][5], - testPattern[10][6], testPattern[10][7], + CalcOffset_CFE_EVS_SendEvent_stub(333, 444, "CFE_EVS_SendEvent stub test %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", + testPattern[10][0], testPattern[10][1], testPattern[10][2], testPattern[10][3], + testPattern[10][4], testPattern[10][5], testPattern[10][6], testPattern[10][7], testPattern[10][8], testPattern[10][9]); - CalcOffset_CFE_EVS_SendEventWithAppID_stub(555, 666, 5, - "CFE_EVS_SendEventWithAppID stub test %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", - testPattern[11][0], testPattern[11][1], - testPattern[11][2], testPattern[11][3], - testPattern[11][4], testPattern[11][5], - testPattern[11][6], testPattern[11][7], - testPattern[11][8], testPattern[11][9]); + CalcOffset_CFE_EVS_SendEventWithAppID_stub( + 555, 666, 5, "CFE_EVS_SendEventWithAppID stub test %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", testPattern[11][0], + testPattern[11][1], testPattern[11][2], testPattern[11][3], testPattern[11][4], testPattern[11][5], + testPattern[11][6], testPattern[11][7], testPattern[11][8], testPattern[11][9]); } void UT_ShowHex(unsigned char *ptr, int numBytes) { - int i, j; - unsigned char *bytePtr = (unsigned char *) ptr; - char hMsg[3000]; + int i, j; + unsigned char *bytePtr = (unsigned char *)ptr; + char hMsg[3000]; strcpy(hMsg, "args = "); @@ -298,19 +142,19 @@ void UT_ShowHex(unsigned char *ptr, int numBytes) /* Determine the offset, breakpoint, and skip values for a variadic function */ void UT_CheckArgumentOffset(va_list ptr, int tpIndex) { - int i = 0; - int offset = -1; - int breakpoint = 0; - int skip = 0; - int max_allowed_offset = 20; - int max_allowed_skip = 100; - int num_parms = 10; - unsigned char *bytePtr = (unsigned char *) ptr; - unsigned char *testPtr = (void *) &testPattern[tpIndex][0]; - -/* - UT_ShowHex(ptr, 440); -*/ + int i = 0; + int offset = -1; + int breakpoint = 0; + int skip = 0; + int max_allowed_offset = 20; + int max_allowed_skip = 100; + int num_parms = 10; + unsigned char *bytePtr = (unsigned char *)ptr; + unsigned char *testPtr = (void *)&testPattern[tpIndex][0]; + + /* + UT_ShowHex(ptr, 440); + */ while (offset < max_allowed_offset && i < sizeof(unsigned long)) { @@ -391,10 +235,10 @@ void UT_CheckArgumentOffset(va_list ptr, int tpIndex) /* Mimic actual CFE_ES_WriteToSysLog() */ int32 CalcOffset_CFE_ES_WriteToSysLog(const char *SpecStringPtr, ...) { - char TmpString[CFE_ES_MAX_SYSLOG_MSG_SIZE]; - char MsgWithoutTime[CFE_EVS_MAX_MESSAGE_LENGTH]; + char TmpString[CFE_ES_MAX_SYSLOG_MSG_SIZE]; + char MsgWithoutTime[CFE_EVS_MAX_MESSAGE_LENGTH]; CFE_TIME_SysTime_t time = {0, 0}; - va_list Ptr; + va_list Ptr; va_start(Ptr, SpecStringPtr, 0, 0, 0); OS_vsnprintfDummy(MsgWithoutTime, 1, SpecStringPtr, Ptr); @@ -416,14 +260,11 @@ int32 CalcOffset_CFE_ES_WriteToSysLog(const char *SpecStringPtr, ...) } /* Mimic actual EVS_SendEvent() */ -int32 CalcOffset_EVS_SendEvent(uint16 EventID, - uint16 EventType, - const char *Spec, - ...) +int32 CalcOffset_EVS_SendEvent(uint16 EventID, uint16 EventType, const char *Spec, ...) { - CFE_EVS_Packet_t EVS_Packet; + CFE_EVS_Packet_t EVS_Packet; CFE_TIME_SysTime_t Time = {0, 0}; - va_list Ptr; + va_list Ptr; EVS_IsFilteredDummy(0, EventID, EventType); CFE_SB_InitMsgDummy(&EVS_Packet, 1, sizeof(CFE_EVS_Packet_t), 1); @@ -439,15 +280,12 @@ int32 CalcOffset_EVS_SendEvent(uint16 EventID, } /* Mimic actual CFE_EVS_SendEvent() */ -int32 CalcOffset_CFE_EVS_SendEvent(uint16 EventID, - uint16 EventType, - const char *Spec, - ...) +int32 CalcOffset_CFE_EVS_SendEvent(uint16 EventID, uint16 EventType, const char *Spec, ...) { - CFE_EVS_Packet_t EVS_Packet; - uint32 AppID = 0; - CFE_TIME_SysTime_t Time = {0, 0}; - va_list Ptr; + CFE_EVS_Packet_t EVS_Packet; + uint32 AppID = 0; + CFE_TIME_SysTime_t Time = {0, 0}; + va_list Ptr; EVS_GetAppIDDummy(&AppID); EVS_NotRegisteredDummy(AppID); @@ -466,15 +304,11 @@ int32 CalcOffset_CFE_EVS_SendEvent(uint16 EventID, /* Mimic actual CFE_EVS_SendEventWithAppID() */ /* THIS IS RETURNING THE WRONG SKIP VALUE!!! (off by -2) */ -int32 CalcOffset_CFE_EVS_SendEventWithAppID(uint16 EventID, - uint16 EventType, - uint32 AppID, - const char *Spec, - ...) +int32 CalcOffset_CFE_EVS_SendEventWithAppID(uint16 EventID, uint16 EventType, uint32 AppID, const char *Spec, ...) { - CFE_EVS_Packet_t EVS_Packet; + CFE_EVS_Packet_t EVS_Packet; CFE_TIME_SysTime_t Time = {0, 0}; - va_list Ptr; + va_list Ptr; EVS_NotRegisteredDummy(AppID); EVS_IsFilteredDummy(AppID, EventID, EventType); @@ -491,15 +325,12 @@ int32 CalcOffset_CFE_EVS_SendEventWithAppID(uint16 EventID, } /* Mimic actual CFE_EVS_SendTimedEvent() */ -int32 CalcOffset_CFE_EVS_SendTimedEvent(CFE_TIME_SysTime_t Time, - uint16 EventID, - uint16 EventType, - const char *Spec, +int32 CalcOffset_CFE_EVS_SendTimedEvent(CFE_TIME_SysTime_t Time, uint16 EventID, uint16 EventType, const char *Spec, ...) { CFE_EVS_Packet_t EVS_Packet; - uint32 AppID = 0; - va_list Ptr; + uint32 AppID = 0; + va_list Ptr; EVS_GetAppIDDummy(&AppID); EVS_NotRegisteredDummy(AppID); @@ -523,7 +354,7 @@ void CalcOffset_OS_printf(const char *format, ...) va_start(varg, format, 0, 0, 0); OS_vsnprintfDummy(0, -1, format, varg) - UT_Text("\nOS_printf Argument Calculation:\n"); + UT_Text("\nOS_printf Argument Calculation:\n"); UT_CheckArgumentOffset(varg, 5); va_end(varg); } @@ -532,7 +363,7 @@ void CalcOffset_OS_printf(const char *format, ...) int CalcOffset_OS_sprintf(char *out, const char *format, ...) { va_list varg; - int length; + int length; va_start(varg, format, 0, 0, 0); length = OS_vsnprintfDummy(out, -1, format, varg); @@ -540,22 +371,22 @@ int CalcOffset_OS_sprintf(char *out, const char *format, ...) UT_Text("\nOS_sprintf Argument Calculation:\n"); UT_CheckArgumentOffset(varg, 6); va_end(varg); - return(length); + return (length); } /* Mimic actual and stub OS_snprintf() */ int CalcOffset_OS_snprintf(char *out, unsigned max_len, const char *format, ...) { va_list varg; - int length; + int length; va_start(varg, format, 0, 0, 0); - length = OS_vsnprintfDummy(out, (int) max_len - 1, format, varg); + length = OS_vsnprintfDummy(out, (int)max_len - 1, format, varg); UT_Text("\nOS_snprintf Argument Calculation:\n"); UT_CheckArgumentOffset(varg, 7); va_end(varg); - return(length); + return (length); } /* Mimic stub OS_printf() */ @@ -587,10 +418,7 @@ int32 CalcOffset_CFE_ES_WriteToSysLog_stub(const char *pSpecString, ...) } /* Mimic stub CFE_EVS_SendEvent() */ -int32 CalcOffset_CFE_EVS_SendEvent_stub(uint16 EventID, - uint16 EventType, - const char *Spec, - ...) +int32 CalcOffset_CFE_EVS_SendEvent_stub(uint16 EventID, uint16 EventType, const char *Spec, ...) { char BigBuf[CFE_EVS_MAX_MESSAGE_LENGTH]; va_list Ptr; @@ -606,11 +434,7 @@ int32 CalcOffset_CFE_EVS_SendEvent_stub(uint16 EventID, } /* Mimic stub CFE_EVS_SendEventWithAppID() */ -int32 CalcOffset_CFE_EVS_SendEventWithAppID_stub(uint16 EventID, - uint16 EventType, - uint32 AppID, - const char *Spec, - ...) +int32 CalcOffset_CFE_EVS_SendEventWithAppID_stub(uint16 EventID, uint16 EventType, uint32 AppID, const char *Spec, ...) { char BigBuf[CFE_EVS_MAX_MESSAGE_LENGTH]; va_list Ptr; @@ -618,9 +442,8 @@ int32 CalcOffset_CFE_EVS_SendEventWithAppID_stub(uint16 EventID, va_start(Ptr, Spec, 0, 0, 0); OS_vsnprintfDummy(BigBuf, CFE_EVS_MAX_MESSAGE_LENGTH, Spec, Ptr); UT_AddEventToHistoryDummy(EventID); - OS_snprintfDummy(cMsg, UT_MAX_MESSAGE_LENGTH, - " CFE_EVS_SendEvent from app %lu: %u, %u - %s", - AppID, EventID, EventType, BigBuf); + OS_snprintfDummy(cMsg, UT_MAX_MESSAGE_LENGTH, " CFE_EVS_SendEvent from app %lu: %u, %u - %s", AppID, EventID, + EventType, BigBuf); UT_Text("\nCFE_EVS_SendEventWithAppID Stub Argument Calculation:\n"); UT_CheckArgumentOffset(Ptr, 11); diff --git a/src/unit-tests/osprintf-test/ut_osprintf_offset.h b/src/unit-tests/osprintf-test/ut_osprintf_offset.h index 31bb4fece..f86c4c2cf 100644 --- a/src/unit-tests/osprintf-test/ut_osprintf_offset.h +++ b/src/unit-tests/osprintf-test/ut_osprintf_offset.h @@ -40,59 +40,36 @@ #include "cfe_mission_cfg.h" #include "osprintf.h" -void UT_ShowHex(unsigned char *, int); -void UT_CheckArgumentOffset(va_list, int); -void UT_osprintf_CalcOffsets(void); -int32 CalcOffset_CFE_ES_WriteToSysLog(const char *, ...); -int32 CalcOffset_EVS_SendEvent(uint16, - uint16, - const char *, - ...); -int32 CalcOffset_CFE_EVS_SendEvent(uint16, - uint16, - const char *, - ...); -int32 CalcOffset_CFE_EVS_SendEventWithAppID(uint16, - uint16, - uint32, - const char *, - ...); -int32 CalcOffset_CFE_EVS_SendTimedEvent(CFE_TIME_SysTime_t, - uint16, - uint16, - const char *, - ...); -void CalcOffset_OS_printf(const char *, ...); -int CalcOffset_OS_sprintf(char *, const char *, ...); -int CalcOffset_OS_snprintf(char *, unsigned, const char *, ...); -void CalcOffset_OS_printf_stub(const char *, ...); -int32 CalcOffset_CFE_ES_WriteToSysLog_stub(const char *, ...); -int32 CalcOffset_CFE_EVS_SendEvent_stub(uint16, - uint16, - const char *, - ...); -int32 CalcOffset_CFE_EVS_SendEventWithAppID_stub(uint16, - uint16, - uint32, - const char *, - ...); -void CFE_TIME_PrintDummy(char *, CFE_TIME_SysTime_t); -unsigned char EVS_IsFilteredDummy(uint32, uint16, - uint16); -void CFE_SB_InitMsgDummy(void *, uint16, uint16, unsigned char); +void UT_ShowHex(unsigned char *, int); +void UT_CheckArgumentOffset(va_list, int); +void UT_osprintf_CalcOffsets(void); +int32 CalcOffset_CFE_ES_WriteToSysLog(const char *, ...); +int32 CalcOffset_EVS_SendEvent(uint16, uint16, const char *, ...); +int32 CalcOffset_CFE_EVS_SendEvent(uint16, uint16, const char *, ...); +int32 CalcOffset_CFE_EVS_SendEventWithAppID(uint16, uint16, uint32, const char *, ...); +int32 CalcOffset_CFE_EVS_SendTimedEvent(CFE_TIME_SysTime_t, uint16, uint16, const char *, ...); +void CalcOffset_OS_printf(const char *, ...); +int CalcOffset_OS_sprintf(char *, const char *, ...); +int CalcOffset_OS_snprintf(char *, unsigned, const char *, ...); +void CalcOffset_OS_printf_stub(const char *, ...); +int32 CalcOffset_CFE_ES_WriteToSysLog_stub(const char *, ...); +int32 CalcOffset_CFE_EVS_SendEvent_stub(uint16, uint16, const char *, ...); +int32 CalcOffset_CFE_EVS_SendEventWithAppID_stub(uint16, uint16, uint32, const char *, ...); +void CFE_TIME_PrintDummy(char *, CFE_TIME_SysTime_t); +unsigned char EVS_IsFilteredDummy(uint32, uint16, uint16); +void CFE_SB_InitMsgDummy(void *, uint16, uint16, unsigned char); CFE_TIME_SysTime_t CFE_TIME_GetTimeDummy(void); -void EVS_SendPacketDummy(uint32, CFE_TIME_SysTime_t, - CFE_EVS_Packet_t *); -long int EVS_GetAppIDDummy(uint32 *); -long int EVS_NotRegisteredDummy(uint32); -int OS_vsnprintfDummy(char *, int, const char *, ...); -void OS_printfDummy(const char *, ...); -int OS_snprintfDummy(char *, unsigned, const char *, ...); -char *strcatDummy(char *, const char *); -char *strncatDummy(char *, const char *, int); -char *strncpyDummy(char *, const char *, int); -int strlenDummy(const char *); -void UT_AddEventToHistoryDummy(uint16 EventID); +void EVS_SendPacketDummy(uint32, CFE_TIME_SysTime_t, CFE_EVS_Packet_t *); +long int EVS_GetAppIDDummy(uint32 *); +long int EVS_NotRegisteredDummy(uint32); +int OS_vsnprintfDummy(char *, int, const char *, ...); +void OS_printfDummy(const char *, ...); +int OS_snprintfDummy(char *, unsigned, const char *, ...); +char * strcatDummy(char *, const char *); +char * strncatDummy(char *, const char *, int); +char * strncpyDummy(char *, const char *, int); +int strlenDummy(const char *); +void UT_AddEventToHistoryDummy(uint16 EventID); #endif /* UT_OSPRINTF_OFFSET_H_ */ diff --git a/src/unit-tests/osprintf-test/ut_osprintf_offset_dummy.c b/src/unit-tests/osprintf-test/ut_osprintf_offset_dummy.c index 626da17d5..d462d49a1 100644 --- a/src/unit-tests/osprintf-test/ut_osprintf_offset_dummy.c +++ b/src/unit-tests/osprintf-test/ut_osprintf_offset_dummy.c @@ -23,22 +23,14 @@ #include "ut_osprintf.h" #include "ut_osprintf_offset.h" -void CFE_TIME_PrintDummy(char *PrintBuffer, CFE_TIME_SysTime_t TimeToPrint) -{ -} +void CFE_TIME_PrintDummy(char *PrintBuffer, CFE_TIME_SysTime_t TimeToPrint) {} -unsigned char EVS_IsFilteredDummy(uint32 AppID, - uint16 EventID, uint16 EventType) +unsigned char EVS_IsFilteredDummy(uint32 AppID, uint16 EventID, uint16 EventType) { return 0; } -void CFE_SB_InitMsgDummy(void *MsgPtr, - uint16 MsgId, - uint16 Length, - unsigned char Clear) -{ -} +void CFE_SB_InitMsgDummy(void *MsgPtr, uint16 MsgId, uint16 Length, unsigned char Clear) {} CFE_TIME_SysTime_t CFE_TIME_GetTimeDummy(void) { @@ -47,10 +39,7 @@ CFE_TIME_SysTime_t CFE_TIME_GetTimeDummy(void) return Time; } -void EVS_SendPacketDummy(uint32 AppID, CFE_TIME_SysTime_t Time, - CFE_EVS_Packet_t *EVS_PktPtr) -{ -} +void EVS_SendPacketDummy(uint32 AppID, CFE_TIME_SysTime_t Time, CFE_EVS_Packet_t *EVS_PktPtr) {} long int EVS_GetAppIDDummy(uint32 *AppIdPtr) { @@ -62,15 +51,12 @@ long int EVS_NotRegisteredDummy(uint32 AppID) return 0; } -int OS_vsnprintfDummy(char *out_buffer, int max_len, - const char *format, ...) +int OS_vsnprintfDummy(char *out_buffer, int max_len, const char *format, ...) { return 0; } -void OS_printfDummy(const char *format, ...) -{ -} +void OS_printfDummy(const char *format, ...) {} int OS_snprintfDummy(char *out_buffer, unsigned max_len, const char *format, ...) { @@ -97,7 +83,5 @@ int strlenDummy(const char *in) return 0; } -void UT_AddEventToHistoryDummy(uint16 EventID) -{ -} +void UT_AddEventToHistoryDummy(uint16 EventID) {} #endif diff --git a/src/unit-tests/osprintf-test/ut_osprintf_p.c b/src/unit-tests/osprintf-test/ut_osprintf_p.c index 02fa58fe0..4d5ce8ec9 100644 --- a/src/unit-tests/osprintf-test/ut_osprintf_p.c +++ b/src/unit-tests/osprintf-test/ut_osprintf_p.c @@ -36,18 +36,17 @@ extern char trunc_buf[]; void UT_osprintf_p(void) { char *test_fmt = "p"; /* Test format character(s) */ - int i; + int i; struct { - char *test_num; /* Test identifier; sequential numbers */ - long int test_val; /* Test value */ - int max_len; /* Maximum output string length */ - char *format; /* Format string */ - char *expected; /* Expected result */ - char *description; /* Test description */ - } osp_tests[] = - { + char * test_num; /* Test identifier; sequential numbers */ + long int test_val; /* Test value */ + int max_len; /* Maximum output string length */ + char * format; /* Format string */ + char * expected; /* Expected result */ + char * description; /* Test description */ + } osp_tests[] = { {"01", 98765, 5, "%p", "0x181cd", "%p"}, {"02", 46372, 10, "$$$%p$$$", "$$$0xb524$$$", "%p embedded"}, {"03", 91827, 5, "%3p", "0x166b3", "%p with minimum field size"}, @@ -64,11 +63,8 @@ void UT_osprintf_p(void) { /* Perform sprintf test */ init_test(); - sprintf(strg_buf, osp_tests[i].format, (void *) osp_tests[i].test_val); - UT_Report(check_test(osp_tests[i].expected, strg_buf), - "SPRINTF", - osp_tests[i].description, - test_fmt, + sprintf(strg_buf, osp_tests[i].format, (void *)osp_tests[i].test_val); + UT_Report(check_test(osp_tests[i].expected, strg_buf), "SPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); /* Truncate expected string in preparation for snprintf test */ @@ -81,12 +77,8 @@ void UT_osprintf_p(void) /* Perform snprintf test */ init_test(); - snprintf(strg_buf, osp_tests[i].max_len, - osp_tests[i].format, (void *) osp_tests[i].test_val); - UT_Report(check_test(trunc_buf, strg_buf), - "SNPRINTF", - osp_tests[i].description, - test_fmt, + snprintf(strg_buf, osp_tests[i].max_len, osp_tests[i].format, (void *)osp_tests[i].test_val); + UT_Report(check_test(trunc_buf, strg_buf), "SNPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); } } diff --git a/src/unit-tests/osprintf-test/ut_osprintf_printf.c b/src/unit-tests/osprintf-test/ut_osprintf_printf.c index ff676ad35..182261db2 100644 --- a/src/unit-tests/osprintf-test/ut_osprintf_printf.c +++ b/src/unit-tests/osprintf-test/ut_osprintf_printf.c @@ -38,20 +38,12 @@ void UT_osprintf_printf(void) { /* Perform printf enabled test */ OS_printf("%s", "printf_test_string\n"); - UT_Report(UT_PASS, - "PRINTF", - "Output to console", - "%s", - "01"); + UT_Report(UT_PASS, "PRINTF", "Output to console", "%s", "01"); /* Perform printf disabled test */ OS_printf_enabled = 0; OS_printf("%s", "printf_test_string_disabled\n"); - UT_Report(UT_PASS, - "PRINTF", - "Output to console disabled", - "%s", - "02"); + UT_Report(UT_PASS, "PRINTF", "Output to console disabled", "%s", "02"); OS_printf_enabled = 1; } #endif diff --git a/src/unit-tests/osprintf-test/ut_osprintf_s.c b/src/unit-tests/osprintf-test/ut_osprintf_s.c index 30c306cd6..9ee055b4d 100644 --- a/src/unit-tests/osprintf-test/ut_osprintf_s.c +++ b/src/unit-tests/osprintf-test/ut_osprintf_s.c @@ -36,18 +36,17 @@ extern char trunc_buf[]; void UT_osprintf_s(void) { char *test_fmt = "s"; /* Test format character(s) */ - int i; + int i; struct { - char *test_num; /* Test identifier; sequential numbers */ - char test_val[30]; /* Test value */ - int max_len; /* Maximum output string length */ - char *format; /* Format string */ - char *expected; /* Expected result */ - char *description; /* Test description */ - } osp_tests[] = - { + char *test_num; /* Test identifier; sequential numbers */ + char test_val[30]; /* Test value */ + int max_len; /* Maximum output string length */ + char *format; /* Format string */ + char *expected; /* Expected result */ + char *description; /* Test description */ + } osp_tests[] = { {"01", "123456789abcd", 7, "%s", "123456789abcd", "%s"}, {"02", "123456789abcd", 7, "$$$%s$$$", "$$$123456789abcd$$$", "%s embedded"}, {"03", "123456789abcd", 11, "%20s", " 123456789abcd", "%s with minimum field size"}, @@ -65,10 +64,7 @@ void UT_osprintf_s(void) /* Perform sprintf test */ init_test(); sprintf(strg_buf, osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(osp_tests[i].expected, strg_buf), - "SPRINTF", - osp_tests[i].description, - test_fmt, + UT_Report(check_test(osp_tests[i].expected, strg_buf), "SPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); /* Truncate expected string in preparation for snprintf test */ @@ -81,12 +77,8 @@ void UT_osprintf_s(void) /* Perform snprintf test */ init_test(); - snprintf(strg_buf, osp_tests[i].max_len, - osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(trunc_buf, strg_buf), - "SNPRINTF", - osp_tests[i].description, - test_fmt, + snprintf(strg_buf, osp_tests[i].max_len, osp_tests[i].format, osp_tests[i].test_val); + UT_Report(check_test(trunc_buf, strg_buf), "SNPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); } } diff --git a/src/unit-tests/osprintf-test/ut_osprintf_u.c b/src/unit-tests/osprintf-test/ut_osprintf_u.c index c84b918dd..ff9bcafd8 100644 --- a/src/unit-tests/osprintf-test/ut_osprintf_u.c +++ b/src/unit-tests/osprintf-test/ut_osprintf_u.c @@ -36,18 +36,17 @@ extern char trunc_buf[]; void UT_osprintf_u(void) { char *test_fmt = "u"; /* Test format character(s) */ - int i; + int i; struct { char *test_num; /* Test identifier; sequential numbers */ - int test_val; /* Test value */ - int max_len; /* Maximum output string length */ + int test_val; /* Test value */ + int max_len; /* Maximum output string length */ char *format; /* Format string */ char *expected; /* Expected result */ char *description; /* Test description */ - } osp_tests[] = - { + } osp_tests[] = { {"01", 98765, 5, "%u", "98765", "%u"}, {"02", 46372, 10, "$$$%u$$$", "$$$46372$$$", "%u embedded"}, {"03", 91827, 5, "%3u", "91827", "%u with maximum field size"}, @@ -66,10 +65,7 @@ void UT_osprintf_u(void) /* Perform sprintf test */ init_test(); sprintf(strg_buf, osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(osp_tests[i].expected, strg_buf), - "SPRINTF", - osp_tests[i].description, - test_fmt, + UT_Report(check_test(osp_tests[i].expected, strg_buf), "SPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); /* Truncate expected string in preparation for snprintf test */ @@ -82,12 +78,8 @@ void UT_osprintf_u(void) /* Perform snprintf test */ init_test(); - snprintf(strg_buf, osp_tests[i].max_len, - osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(trunc_buf, strg_buf), - "SNPRINTF", - osp_tests[i].description, - test_fmt, + snprintf(strg_buf, osp_tests[i].max_len, osp_tests[i].format, osp_tests[i].test_val); + UT_Report(check_test(trunc_buf, strg_buf), "SNPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); } } diff --git a/src/unit-tests/osprintf-test/ut_osprintf_x.c b/src/unit-tests/osprintf-test/ut_osprintf_x.c index 29e362ab0..aebc3d671 100644 --- a/src/unit-tests/osprintf-test/ut_osprintf_x.c +++ b/src/unit-tests/osprintf-test/ut_osprintf_x.c @@ -36,21 +36,20 @@ extern char trunc_buf[]; void UT_osprintf_x(void) { char *test_fmt = "x"; /* Test format character(s) */ - int i; + int i; #ifdef OSP_ARINC653 #pragma ghs nowarning 68 #endif struct { - char *test_num; /* Test identifier; sequential numbers */ - unsigned int test_val; /* Test value */ - int max_len; /* Maximum output string length */ - char *format; /* Format string */ - char *expected; /* Expected result */ - char *description; /* Test description */ - } osp_tests[] = - { + char * test_num; /* Test identifier; sequential numbers */ + unsigned int test_val; /* Test value */ + int max_len; /* Maximum output string length */ + char * format; /* Format string */ + char * expected; /* Expected result */ + char * description; /* Test description */ + } osp_tests[] = { {"01", 0xa8b7, 3, "%x", "a8b7", "%x"}, {"02", 0xff123, 10, "$$$%x$$$", "$$$ff123$$$", "%x embedded"}, {"03", 0xd1827, 5, "%3x", "d1827", "%x with minimum field size < number of digits"}, @@ -71,10 +70,7 @@ void UT_osprintf_x(void) /* Perform sprintf test */ init_test(); sprintf(strg_buf, osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(osp_tests[i].expected, strg_buf), - "SPRINTF", - osp_tests[i].description, - test_fmt, + UT_Report(check_test(osp_tests[i].expected, strg_buf), "SPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); /* Truncate expected string in preparation for snprintf test */ @@ -87,12 +83,8 @@ void UT_osprintf_x(void) /* Perform snprintf test */ init_test(); - snprintf(strg_buf, osp_tests[i].max_len, - osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(trunc_buf, strg_buf), - "SNPRINTF", - osp_tests[i].description, - test_fmt, + snprintf(strg_buf, osp_tests[i].max_len, osp_tests[i].format, osp_tests[i].test_val); + UT_Report(check_test(trunc_buf, strg_buf), "SNPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); } } diff --git a/src/unit-tests/osprintf-test/ut_osprintf_x_uc.c b/src/unit-tests/osprintf-test/ut_osprintf_x_uc.c index 946ba9e0b..ceac0202a 100644 --- a/src/unit-tests/osprintf-test/ut_osprintf_x_uc.c +++ b/src/unit-tests/osprintf-test/ut_osprintf_x_uc.c @@ -36,21 +36,20 @@ extern char trunc_buf[]; void UT_osprintf_X(void) { char *test_fmt = "x"; /* Test format character(s) */ - int i; + int i; #ifdef OSP_ARINC653 #pragma ghs nowarning 68 #endif struct { - char *test_num; /* Test identifier; sequential numbers */ - unsigned int test_val; /* Test value */ - int max_len; /* Maximum output string length */ - char *format; /* Format string */ - char *expected; /* Expected result */ - char *description; /* Test description */ - } osp_tests[] = - { + char * test_num; /* Test identifier; sequential numbers */ + unsigned int test_val; /* Test value */ + int max_len; /* Maximum output string length */ + char * format; /* Format string */ + char * expected; /* Expected result */ + char * description; /* Test description */ + } osp_tests[] = { {"01", 0xa8b7, 3, "%X", "A8B7", "%X"}, {"02", 0xff123, 10, "$$$%X$$$", "$$$FF123$$$", "%X embedded"}, {"03", 0xd1827, 5, "%3X", "D1827", "%X with minimum field size < number of digits"}, @@ -71,10 +70,7 @@ void UT_osprintf_X(void) /* Perform sprintf test */ init_test(); sprintf(strg_buf, osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(osp_tests[i].expected, strg_buf), - "SPRINTF", - osp_tests[i].description, - test_fmt, + UT_Report(check_test(osp_tests[i].expected, strg_buf), "SPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); /* Truncate expected string in preparation for snprintf test */ @@ -87,12 +83,8 @@ void UT_osprintf_X(void) /* Perform snprintf test */ init_test(); - snprintf(strg_buf, osp_tests[i].max_len, - osp_tests[i].format, osp_tests[i].test_val); - UT_Report(check_test(trunc_buf, strg_buf), - "SNPRINTF", - osp_tests[i].description, - test_fmt, + snprintf(strg_buf, osp_tests[i].max_len, osp_tests[i].format, osp_tests[i].test_val); + UT_Report(check_test(trunc_buf, strg_buf), "SNPRINTF", osp_tests[i].description, test_fmt, osp_tests[i].test_num); } } diff --git a/src/unit-tests/ostimer-test/ut_ostimer_test.c b/src/unit-tests/ostimer-test/ut_ostimer_test.c index affb5a4b5..6b6716f37 100644 --- a/src/unit-tests/ostimer-test/ut_ostimer_test.c +++ b/src/unit-tests/ostimer-test/ut_ostimer_test.c @@ -46,14 +46,14 @@ ** Global variables **--------------------------------------------------------------------------------*/ -const char* g_timerNames[UT_OS_TIMER_LIST_LEN]; -char g_longTimerName[UT_OS_NAME_BUFF_SIZE]; +const char *g_timerNames[UT_OS_TIMER_LIST_LEN]; +char g_longTimerName[UT_OS_NAME_BUFF_SIZE]; -uint32 g_cbLoopCntMax = 5; -uint32 g_toleranceVal = 0; -uint32 g_timerFirst = 0; -int32 g_status = 0; -osal_id_t g_timerId; +uint32 g_cbLoopCntMax = 5; +uint32 g_toleranceVal = 0; +uint32 g_timerFirst = 0; +int32 g_status = 0; +osal_id_t g_timerId; /*--------------------------------------------------------------------------------* ** Local function prototypes @@ -74,28 +74,27 @@ void UT_os_setup_timerset_test(void); void UT_os_timercallback(osal_id_t timerId) { - int deltaTime = 0; - static int32 loopCnt = 0, res = 0; - static uint32 prevIntervalTime = 0; - static uint32 currIntervalTime = 0; - static OS_time_t currTime = {0,0}, endTime = {0,0}; + int deltaTime = 0; + static int32 loopCnt = 0, res = 0; + static uint32 prevIntervalTime = 0; + static uint32 currIntervalTime = 0; + static OS_time_t currTime = {0, 0}, endTime = {0, 0}; if (OS_ObjectIdEqual(timerId, g_timerId)) { if (g_timerFirst) { - g_timerFirst = 0; - g_status = 0; + g_timerFirst = 0; + g_status = 0; prevIntervalTime = 0; - res = 0; - loopCnt = 0; + res = 0; + loopCnt = 0; OS_GetLocalTime(&currTime); } OS_GetLocalTime(&endTime); - currIntervalTime = 1000000 * (endTime.seconds - currTime.seconds) + - endTime.microsecs - currTime.microsecs; + currIntervalTime = 1000000 * (endTime.seconds - currTime.seconds) + endTime.microsecs - currTime.microsecs; if (currIntervalTime >= prevIntervalTime) deltaTime = currIntervalTime - prevIntervalTime; @@ -106,7 +105,7 @@ void UT_os_timercallback(osal_id_t timerId) res = -1; loopCnt++; - currTime = endTime; + currTime = endTime; prevIntervalTime = currIntervalTime; if (loopCnt == g_cbLoopCntMax) @@ -121,7 +120,7 @@ void UT_os_timercallback(osal_id_t timerId) void UT_os_init_timer_misc() { memset(g_longTimerName, 'Y', sizeof(g_longTimerName)); - g_longTimerName[sizeof(g_longTimerName)-1] = '\0'; + g_longTimerName[sizeof(g_longTimerName) - 1] = '\0'; } /*--------------------------------------------------------------------------------*/ @@ -129,7 +128,7 @@ void UT_os_init_timer_misc() void UT_os_setup_timercreate_test() { memset(g_longTimerName, 'Y', sizeof(g_longTimerName)); - g_longTimerName[sizeof(g_longTimerName)-1] = '\0'; + g_longTimerName[sizeof(g_longTimerName) - 1] = '\0'; g_timerNames[0] = "Create_NotImpl"; g_timerNames[1] = "Create_NullPtr"; @@ -183,7 +182,6 @@ void UT_os_setup_timerset_test() g_timerNames[4] = "Set_Nominal"; } - /*--------------------------------------------------------------------------------* ** Main **--------------------------------------------------------------------------------*/ @@ -197,32 +195,11 @@ void UtTest_Setup(void) UT_os_init_timer_misc(); - UtTest_Add( - UT_os_timercreate_test, - UT_os_setup_timercreate_test, - NULL, - "OS_TimerCreate"); - UtTest_Add( - UT_os_timerdelete_test, - UT_os_setup_timerdelete_test, - NULL, - "OS_TimerDelete"); - UtTest_Add( - UT_os_timergetidbyname_test, - UT_os_setup_timergetidbyname_test, - NULL, - "OS_TimerGetIdByName"); - UtTest_Add( - UT_os_timergetinfo_test, - UT_os_setup_timergetinfo_test, - NULL, - "OS_TimerGetInfo"); - UtTest_Add( - UT_os_timerset_test, - UT_os_setup_timerset_test, - NULL, - "OS_TimerSet"); - + UtTest_Add(UT_os_timercreate_test, UT_os_setup_timercreate_test, NULL, "OS_TimerCreate"); + UtTest_Add(UT_os_timerdelete_test, UT_os_setup_timerdelete_test, NULL, "OS_TimerDelete"); + UtTest_Add(UT_os_timergetidbyname_test, UT_os_setup_timergetidbyname_test, NULL, "OS_TimerGetIdByName"); + UtTest_Add(UT_os_timergetinfo_test, UT_os_setup_timergetinfo_test, NULL, "OS_TimerGetInfo"); + UtTest_Add(UT_os_timerset_test, UT_os_setup_timerset_test, NULL, "OS_TimerSet"); } /*================================================================================* diff --git a/src/unit-tests/ostimer-test/ut_ostimer_test.h b/src/unit-tests/ostimer-test/ut_ostimer_test.h index 20a83f70e..100e80b49 100644 --- a/src/unit-tests/ostimer-test/ut_ostimer_test.h +++ b/src/unit-tests/ostimer-test/ut_ostimer_test.h @@ -56,7 +56,7 @@ /*--------------------------------------------------------------------------------*/ -#endif /* _UT_OSTIMER_TEST_H_ */ +#endif /* _UT_OSTIMER_TEST_H_ */ /*================================================================================* ** End of File: ut_ostimer_test.h diff --git a/src/unit-tests/ostimer-test/ut_ostimer_timerio_test.c b/src/unit-tests/ostimer-test/ut_ostimer_timerio_test.c index 2098a30f2..d1e0a15e9 100644 --- a/src/unit-tests/ostimer-test/ut_ostimer_timerio_test.c +++ b/src/unit-tests/ostimer-test/ut_ostimer_timerio_test.c @@ -42,14 +42,14 @@ ** External global variables **--------------------------------------------------------------------------------*/ -extern char* g_timerNames[UT_OS_TIMER_LIST_LEN]; -extern char g_longTimerName[UT_OS_NAME_BUFF_SIZE]; +extern char *g_timerNames[UT_OS_TIMER_LIST_LEN]; +extern char g_longTimerName[UT_OS_NAME_BUFF_SIZE]; -extern uint32 g_cbLoopCntMax; -extern uint32 g_toleranceVal; -extern uint32 g_timerFirst; -extern int32 g_status; -extern osal_id_t g_timerId; +extern uint32 g_cbLoopCntMax; +extern uint32 g_toleranceVal; +extern uint32 g_timerFirst; +extern int32 g_status; +extern osal_id_t g_timerId; /*--------------------------------------------------------------------------------* ** External function prototypes @@ -61,8 +61,8 @@ extern void UT_os_timercallback(osal_id_t timerId); ** Global variables **--------------------------------------------------------------------------------*/ -uint32 g_clkAccuracy = 0; -osal_id_t g_timerIds[UT_OS_TIMER_LIST_LEN]; +uint32 g_clkAccuracy = 0; +osal_id_t g_timerIds[UT_OS_TIMER_LIST_LEN]; /*--------------------------------------------------------------------------------* ** Local function prototypes @@ -102,8 +102,8 @@ osal_id_t g_timerIds[UT_OS_TIMER_LIST_LEN]; *--------------------------------------------------------------------------------*/ void UT_os_timerinit_test() { - int32 res=0; - const char* testDesc; + int32 res = 0; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "#1 Init-not-call-first"; @@ -111,14 +111,14 @@ void UT_os_timerinit_test() res = OS_TimerCreate(&g_timerIds[0], "Timer #0", &g_clkAccuracy, &UT_os_timercallback); if (res != OS_SUCCESS) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); } else { /* Reset test environment */ OS_TimerDelete(g_timerIds[0]); - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } /*-----------------------------------------------------*/ @@ -128,30 +128,30 @@ void UT_os_timerinit_test() if (res == OS_ERR_NOT_IMPLEMENTED) { testDesc = "API not implemented"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); } else if (res == OS_SUCCESS) { res = OS_TimerCreate(&g_timerIds[0], "Timer #0", &g_clkAccuracy, &UT_os_timercallback); if (res == OS_SUCCESS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_TimerDelete(g_timerIds[0]); } else { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } return; - } /*--------------------------------------------------------------------------------* -** Syntax: int32 OS_TimerCreate(uint32 *timer_id, const char *timer_name, uint32 *clock_accuracy, OS_TimerCallback_t callback_ptr) +** Syntax: int32 OS_TimerCreate(uint32 *timer_id, const char *timer_name, uint32 *clock_accuracy, OS_TimerCallback_t +*callback_ptr) ** Purpose: Creates a new timer and associates it with a callback routine ** Parameters: *timer_id - a pointer that will hold the timer id ** *timer_name - a pointer that holds the name of the timer to be created @@ -226,9 +226,9 @@ void UT_os_timerinit_test() **--------------------------------------------------------------------------------*/ void UT_os_timercreate_test() { - const char* testDesc; - int32 res=0, i=0, j=0; - char tmpStr[UT_OS_NAME_BUFF_SIZE]; + const char *testDesc; + int32 res = 0, i = 0, j = 0; + char tmpStr[UT_OS_NAME_BUFF_SIZE]; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -236,7 +236,7 @@ void UT_os_timercreate_test() res = OS_TimerCreate(&g_timerIds[0], g_timerNames[0], &g_clkAccuracy, &UT_os_timercallback); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_timercreate_test_exit_tag; } @@ -246,24 +246,20 @@ void UT_os_timercreate_test() /*-----------------------------------------------------*/ testDesc = "#1 Null-pointer-arg"; - if ((OS_TimerCreate(NULL, g_timerNames[1], &g_clkAccuracy, &UT_os_timercallback) == - OS_INVALID_POINTER) && - (OS_TimerCreate(&g_timerIds[1], NULL, &g_clkAccuracy, &UT_os_timercallback) == - OS_INVALID_POINTER) && - (OS_TimerCreate(&g_timerIds[1], g_timerNames[1], NULL, &UT_os_timercallback) == - OS_INVALID_POINTER)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if ((OS_TimerCreate(NULL, g_timerNames[1], &g_clkAccuracy, &UT_os_timercallback) == OS_INVALID_POINTER) && + (OS_TimerCreate(&g_timerIds[1], NULL, &g_clkAccuracy, &UT_os_timercallback) == OS_INVALID_POINTER) && + (OS_TimerCreate(&g_timerIds[1], g_timerNames[1], NULL, &UT_os_timercallback) == OS_INVALID_POINTER)) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Name-too-long"; - if (OS_TimerCreate(&g_timerIds[2], g_longTimerName, &g_clkAccuracy, &UT_os_timercallback) == - OS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (OS_TimerCreate(&g_timerIds[2], g_longTimerName, &g_clkAccuracy, &UT_os_timercallback) == OS_ERR_NAME_TOO_LONG) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Name equal to OS_MAX_API_NAME characters test"; @@ -272,22 +268,19 @@ void UT_os_timercreate_test() memset(&tmpStr[0], 'a', OS_MAX_API_NAME); tmpStr[OS_MAX_API_NAME] = '\0'; - if (OS_TimerCreate(&g_timerIds[2], tmpStr, &g_clkAccuracy, &UT_os_timercallback) == - OS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (OS_TimerCreate(&g_timerIds[2], tmpStr, &g_clkAccuracy, &UT_os_timercallback) == OS_ERR_NAME_TOO_LONG) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 Name-taken"; - if ((OS_TimerCreate(&g_timerIds[3], g_timerNames[3], &g_clkAccuracy, &UT_os_timercallback) == - OS_SUCCESS) && - (OS_TimerCreate(&g_timerIds[4], g_timerNames[3], &g_clkAccuracy, &UT_os_timercallback) == - OS_ERR_NAME_TAKEN)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if ((OS_TimerCreate(&g_timerIds[3], g_timerNames[3], &g_clkAccuracy, &UT_os_timercallback) == OS_SUCCESS) && + (OS_TimerCreate(&g_timerIds[4], g_timerNames[3], &g_clkAccuracy, &UT_os_timercallback) == OS_ERR_NAME_TAKEN)) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_TimerDelete(g_timerIds[3]); @@ -295,7 +288,7 @@ void UT_os_timercreate_test() /*-----------------------------------------------------*/ testDesc = "#5 No-free-IDs"; - for (i=0; i <= OS_MAX_TIMEBASES; i++) + for (i = 0; i <= OS_MAX_TIMEBASES; i++) { memset(tmpStr, '\0', sizeof(tmpStr)); UT_os_sprintf(tmpStr, "Timer #%d", (int)i); @@ -307,34 +300,33 @@ void UT_os_timercreate_test() if (i < OS_MAX_TIMEBASES) { testDesc = "#4 No-free-IDs - Timer-created failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else if (res == OS_ERR_NO_FREE_IDS) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); } else { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } /* Reset test environment */ - for (j=0; j < i; j++) + for (j = 0; j < i; j++) OS_TimerDelete(g_timerIds[j]); /*-----------------------------------------------------*/ testDesc = "#6 Invalid-arg"; - if (OS_TimerCreate(&g_timerIds[5], g_timerNames[5], &g_clkAccuracy, NULL) == - OS_TIMER_ERR_INVALID_ARGS) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + if (OS_TimerCreate(&g_timerIds[5], g_timerNames[5], &g_clkAccuracy, NULL) == OS_TIMER_ERR_INVALID_ARGS) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#7 Timer-unavailable"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#8 Nominal"; @@ -343,20 +335,18 @@ void UT_os_timercreate_test() if (res == OS_SUCCESS) { if ((OS_TimerGetIdByName(&g_timerIds[8], g_timerNames[7]) == OS_SUCCESS) && - OS_ObjectIdEqual(g_timerIds[7], g_timerIds[8]) && - (OS_TimerDelete(g_timerIds[7]) == OS_SUCCESS)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + OS_ObjectIdEqual(g_timerIds[7], g_timerIds[8]) && (OS_TimerDelete(g_timerIds[7]) == OS_SUCCESS)) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } else { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } UT_os_timercreate_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -403,8 +393,8 @@ void UT_os_timercreate_test() **--------------------------------------------------------------------------------*/ void UT_os_timerdelete_test() { - int32 res=0; - const char* testDesc; + int32 res = 0; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -412,7 +402,7 @@ void UT_os_timerdelete_test() res = OS_TimerDelete(UT_OBJID_INCORRECT); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_timerdelete_test_exit_tag; } @@ -420,14 +410,14 @@ void UT_os_timerdelete_test() testDesc = "#1 Invalid-id-arg"; if (OS_TimerDelete(UT_OBJID_INCORRECT) == OS_ERR_INVALID_ID) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Internal-error"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#3 Nominal"; @@ -436,22 +426,21 @@ void UT_os_timerdelete_test() if (res != OS_SUCCESS) { testDesc = "#3 Nominal - Timer-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_timerdelete_test_exit_tag; } if (OS_TimerDelete(g_timerIds[3]) == OS_SUCCESS) { if ((OS_TimerGetIdByName(&g_timerIds[4], g_timerNames[3]) == OS_ERR_NAME_NOT_FOUND) && - (OS_TimerCreate(&g_timerIds[3], g_timerNames[3], &g_clkAccuracy, &UT_os_timercallback) == - OS_SUCCESS)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + (OS_TimerCreate(&g_timerIds[3], g_timerNames[3], &g_clkAccuracy, &UT_os_timercallback) == OS_SUCCESS)) + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } else { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } /* Reset test environment */ @@ -459,7 +448,6 @@ void UT_os_timerdelete_test() UT_os_timerdelete_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -515,9 +503,9 @@ void UT_os_timerdelete_test() **--------------------------------------------------------------------------------*/ void UT_os_timerset_test() { - int32 res=0; - const char* testDesc; - uint32 startTime=0, intervalTime=0; + int32 res = 0; + const char *testDesc; + uint32 startTime = 0, intervalTime = 0; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -525,7 +513,7 @@ void UT_os_timerset_test() res = OS_TimerSet(UT_OBJID_INCORRECT, startTime, intervalTime); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_timerset_test_exit_tag; } @@ -534,14 +522,14 @@ void UT_os_timerset_test() res = OS_TimerSet(UT_OBJID_INCORRECT, 10000, 10000); if (res == OS_ERR_INVALID_ID) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Internal-error"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_INFO); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_INFO); /*-----------------------------------------------------*/ testDesc = "#3 Interval-too-short"; @@ -550,33 +538,32 @@ void UT_os_timerset_test() if (res != OS_SUCCESS) { testDesc = "#3 Interval-too-short - Timer-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { - g_status = 0; - g_timerId = g_timerIds[3]; + g_status = 0; + g_timerId = g_timerIds[3]; g_timerFirst = 1; g_cbLoopCntMax = 10; startTime = 1000; intervalTime = 5; g_toleranceVal = 0; - UT_OS_LOG("\nOS_TimerSet() - #3 Interval-too-short (clk_accuracy=%d)\n", - (int)g_clkAccuracy); + UT_OS_LOG("\nOS_TimerSet() - #3 Interval-too-short (clk_accuracy=%d)\n", (int)g_clkAccuracy); res = OS_TimerSet(g_timerIds[3], startTime, intervalTime); if (res == OS_SUCCESS) { while (!g_status) OS_TaskDelay(1); if (g_status < 0) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } else { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } /* Reset test environment */ OS_TimerDelete(g_timerIds[3]); @@ -589,41 +576,39 @@ void UT_os_timerset_test() if (res != OS_SUCCESS) { testDesc = "#4 Nominal - Timer-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_timerset_test_exit_tag; } else { - g_status = 0; - g_timerId = g_timerIds[4]; + g_status = 0; + g_timerId = g_timerIds[4]; g_timerFirst = 1; g_cbLoopCntMax = 10; startTime = 1000; intervalTime = 500000; - g_toleranceVal = intervalTime / 20; /* 5% */ - UT_OS_LOG("\nOS_TimerSet() - #1 Nominal condition (clk_accuracy=%d)\n", - (int)g_clkAccuracy); + g_toleranceVal = intervalTime / 20; /* 5% */ + UT_OS_LOG("\nOS_TimerSet() - #1 Nominal condition (clk_accuracy=%d)\n", (int)g_clkAccuracy); res = OS_TimerSet(g_timerIds[4], startTime, intervalTime); if (res == OS_SUCCESS) { while (!g_status) OS_TaskDelay(1); if (g_status > 0) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); - else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); + else + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } else { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } /* Reset test environment */ - OS_TimerDelete(g_timerIds[4]); + OS_TimerDelete(g_timerIds[4]); } UT_os_timerset_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -670,8 +655,8 @@ void UT_os_timerset_test() **--------------------------------------------------------------------------------*/ void UT_os_timergetidbyname_test() { - int32 res=0; - const char* testDesc; + int32 res = 0; + const char *testDesc; /*-----------------------------------------------------*/ testDesc = "API not implemented"; @@ -679,7 +664,7 @@ void UT_os_timergetidbyname_test() res = OS_TimerGetIdByName(&g_timerIds[0], g_timerNames[0]); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_timergetidbyname_test_exit_tag; } @@ -688,25 +673,25 @@ void UT_os_timergetidbyname_test() if ((OS_TimerGetIdByName(NULL, g_timerNames[1]) == OS_INVALID_POINTER) && (OS_TimerGetIdByName(&g_timerIds[1], NULL) == OS_INVALID_POINTER)) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#2 Name-too-long"; if (OS_TimerGetIdByName(&g_timerIds[2], g_longTimerName) == OS_ERR_NAME_TOO_LONG) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Name-not-found"; if (OS_TimerGetIdByName(&g_timerIds[3], g_timerNames[3]) == OS_ERR_NAME_NOT_FOUND) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#4 Nominal"; @@ -715,22 +700,21 @@ void UT_os_timergetidbyname_test() if (res != OS_SUCCESS) { testDesc = "#4 Nominal - Timer-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); goto UT_os_timergetidbyname_test_exit_tag; } res = OS_TimerGetIdByName(&g_timerIds[5], g_timerNames[4]); if ((res == OS_SUCCESS) && OS_ObjectIdEqual(g_timerIds[4], g_timerIds[5])) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_TimerDelete(g_timerIds[4]); UT_os_timergetidbyname_test_exit_tag: return; - } /*--------------------------------------------------------------------------------* @@ -772,8 +756,8 @@ void UT_os_timergetidbyname_test() **--------------------------------------------------------------------------------*/ void UT_os_timergetinfo_test() { - int32 res=0; - const char* testDesc; + int32 res = 0; + const char * testDesc; OS_timer_prop_t timerProps; /*-----------------------------------------------------*/ @@ -782,7 +766,7 @@ void UT_os_timergetinfo_test() res = OS_TimerGetInfo(UT_OBJID_INCORRECT, &timerProps); if (res == OS_ERR_NOT_IMPLEMENTED) { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_NA); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_NA); goto UT_os_timergetinfo_test_exit_tag; } @@ -793,14 +777,14 @@ void UT_os_timergetinfo_test() if (res != OS_SUCCESS) { testDesc = "#1 Null-pointer-arg - Timer-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { if (OS_TimerGetInfo(g_timerIds[1], NULL) == OS_INVALID_POINTER) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /* Reset test environment */ OS_TimerDelete(g_timerIds[1]); @@ -810,10 +794,9 @@ void UT_os_timergetinfo_test() testDesc = "#2 Invalid-id-arg"; if (OS_TimerGetInfo(UT_OBJID_INCORRECT, &timerProps) == OS_ERR_INVALID_ID) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); - + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); /*-----------------------------------------------------*/ testDesc = "#3 Nominal"; @@ -822,7 +805,7 @@ void UT_os_timergetinfo_test() if (res != OS_SUCCESS) { testDesc = "#3 Nominal - Timer-create failed"; - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_TSF); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_TSF); } else { @@ -831,13 +814,13 @@ void UT_os_timergetinfo_test() if (res == OS_SUCCESS) { if (strcmp(timerProps.name, g_timerNames[3]) == 0) - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_PASS); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_PASS); else - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } else { - UT_OS_TEST_RESULT( testDesc, UTASSERT_CASETYPE_FAILURE); + UT_OS_TEST_RESULT(testDesc, UTASSERT_CASETYPE_FAILURE); } /* Reset test environment */ @@ -846,7 +829,6 @@ void UT_os_timergetinfo_test() UT_os_timergetinfo_test_exit_tag: return; - } /*================================================================================* diff --git a/src/unit-tests/ostimer-test/ut_ostimer_timerio_test.h b/src/unit-tests/ostimer-test/ut_ostimer_timerio_test.h index 7804fd29b..22ad95c14 100644 --- a/src/unit-tests/ostimer-test/ut_ostimer_timerio_test.h +++ b/src/unit-tests/ostimer-test/ut_ostimer_timerio_test.h @@ -37,7 +37,7 @@ ** Macros **--------------------------------------------------------------------------------*/ -#define UT_OS_TIMER_LIST_LEN (OS_MAX_TIMERS + 10) +#define UT_OS_TIMER_LIST_LEN (OS_MAX_TIMERS + 10) /*--------------------------------------------------------------------------------* ** Data types @@ -64,7 +64,7 @@ void UT_os_timergetinfo_test(void); /*--------------------------------------------------------------------------------*/ -#endif /* _UT_OSTIMER_TIMERIO_TEST_H_ */ +#endif /* _UT_OSTIMER_TIMERIO_TEST_H_ */ /*================================================================================* ** End of File: ut_ostimer_timerio_test.h diff --git a/src/ut-stubs/osapi-utstub-binsem.c b/src/ut-stubs/osapi-utstub-binsem.c index dc19b7b96..77f94d94e 100644 --- a/src/ut-stubs/osapi-utstub-binsem.c +++ b/src/ut-stubs/osapi-utstub-binsem.c @@ -34,7 +34,7 @@ #include "utstub-helpers.h" -UT_DEFAULT_STUB(OS_BinSemAPI_Init,(void)) +UT_DEFAULT_STUB(OS_BinSemAPI_Init, (void)) /*****************************************************************************/ /** @@ -87,7 +87,7 @@ int32 OS_BinSemFlush(osal_id_t sem_id) { UT_Stub_RegisterContextGenericArg(UT_KEY(OS_BinSemFlush), sem_id); - int32 status; + int32 status; status = UT_DEFAULT_IMPL(OS_BinSemFlush); @@ -117,8 +117,7 @@ int32 OS_BinSemFlush(osal_id_t sem_id) ** Returns either a user-defined status flag, OS_ERROR, or OS_SUCCESS. ** ******************************************************************************/ -int32 OS_BinSemCreate(osal_id_t *sem_id, const char *sem_name, - uint32 sem_initial_value, uint32 options) +int32 OS_BinSemCreate(osal_id_t *sem_id, const char *sem_name, uint32 sem_initial_value, uint32 options) { UT_Stub_RegisterContext(UT_KEY(OS_BinSemCreate), sem_id); UT_Stub_RegisterContext(UT_KEY(OS_BinSemCreate), sem_name); @@ -194,7 +193,7 @@ int32 OS_BinSemGetInfo(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop) status = UT_DEFAULT_IMPL(OS_BinSemGetInfo); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_BinSemGetInfo), bin_prop, sizeof(*bin_prop)) < sizeof(*bin_prop)) + UT_Stub_CopyToLocal(UT_KEY(OS_BinSemGetInfo), bin_prop, sizeof(*bin_prop)) < sizeof(*bin_prop)) { UT_ObjIdCompose(1, UT_OBJTYPE_TASK, &bin_prop->creator); strncpy(bin_prop->name, "Name", OS_MAX_API_NAME - 1); @@ -204,7 +203,6 @@ int32 OS_BinSemGetInfo(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop) return status; } - /*****************************************************************************/ /** ** \brief OS_BinSemDelete stub function @@ -277,7 +275,7 @@ int32 OS_BinSemTimedWait(osal_id_t sem_id, uint32 msecs) * Stub function for OS_BinSemGetIdByName() * *****************************************************************************/ -int32 OS_BinSemGetIdByName (osal_id_t *sem_id, const char *sem_name) +int32 OS_BinSemGetIdByName(osal_id_t *sem_id, const char *sem_name) { UT_Stub_RegisterContext(UT_KEY(OS_BinSemGetIdByName), sem_id); UT_Stub_RegisterContext(UT_KEY(OS_BinSemGetIdByName), sem_name); @@ -287,11 +285,10 @@ int32 OS_BinSemGetIdByName (osal_id_t *sem_id, const char *sem_name) status = UT_DEFAULT_IMPL(OS_BinSemGetIdByName); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_BinSemGetIdByName), sem_id, sizeof(*sem_id)) < sizeof(*sem_id)) + UT_Stub_CopyToLocal(UT_KEY(OS_BinSemGetIdByName), sem_id, sizeof(*sem_id)) < sizeof(*sem_id)) { UT_ObjIdCompose(1, UT_OBJTYPE_BINSEM, sem_id); } return status; } - diff --git a/src/ut-stubs/osapi-utstub-bsp.c b/src/ut-stubs/osapi-utstub-bsp.c index cbaae0265..cb0262844 100644 --- a/src/ut-stubs/osapi-utstub-bsp.c +++ b/src/ut-stubs/osapi-utstub-bsp.c @@ -18,7 +18,6 @@ * limitations under the License. */ - /** * \file osapi-utstub-bsp.c * \author joseph.p.hickey@nasa.gov @@ -54,17 +53,15 @@ uint32 OS_BSP_GetArgC(void) OS_BSP_GetArgV See full description in header ------------------------------------------------------------------*/ -char * const * OS_BSP_GetArgV(void) +char *const *OS_BSP_GetArgV(void) { void *buffer; int32 status; status = UT_DEFAULT_IMPL(OS_BSP_GetArgV); - if (status == 0 && - UT_Stub_CopyToLocal(UT_KEY(OS_BSP_GetArgV), &buffer, sizeof(buffer)) < sizeof(buffer)) + if (status == 0 && UT_Stub_CopyToLocal(UT_KEY(OS_BSP_GetArgV), &buffer, sizeof(buffer)) < sizeof(buffer)) { buffer = NULL; } return buffer; } - diff --git a/src/ut-stubs/osapi-utstub-clock.c b/src/ut-stubs/osapi-utstub-clock.c index 871e71ecc..7aaa20498 100644 --- a/src/ut-stubs/osapi-utstub-clock.c +++ b/src/ut-stubs/osapi-utstub-clock.c @@ -34,7 +34,6 @@ #include "utstub-helpers.h" - /***************************************************************************** * * Stub function for OS_GetLocalTime() @@ -44,22 +43,22 @@ int32 OS_GetLocalTime(OS_time_t *time_struct) { UT_Stub_RegisterContext(UT_KEY(OS_GetLocalTime), time_struct); - int32 status; + int32 status; uint32 count; status = UT_DEFAULT_IMPL(OS_GetLocalTime); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_GetLocalTime), time_struct, sizeof(*time_struct)) < sizeof(*time_struct)) + UT_Stub_CopyToLocal(UT_KEY(OS_GetLocalTime), time_struct, sizeof(*time_struct)) < sizeof(*time_struct)) { - count = UT_GetStubCount(UT_KEY(OS_GetLocalTime)); + count = UT_GetStubCount(UT_KEY(OS_GetLocalTime)); time_struct->microsecs = 10000 * (count % 100); - time_struct->seconds = 1 + (count / 100); + time_struct->seconds = 1 + (count / 100); } return status; -}/* end OS_GetLocalTime */ +} /* end OS_GetLocalTime */ /***************************************************************************** * @@ -77,4 +76,3 @@ int32 OS_SetLocalTime(OS_time_t *time_struct) return status; } /*end OS_SetLocalTime */ - diff --git a/src/ut-stubs/osapi-utstub-common.c b/src/ut-stubs/osapi-utstub-common.c index 0f1bd1cb7..6ebc96c8a 100644 --- a/src/ut-stubs/osapi-utstub-common.c +++ b/src/ut-stubs/osapi-utstub-common.c @@ -34,7 +34,6 @@ #include "utstub-helpers.h" - /***************************************************************************** * * Stub function for OS_API_Init() @@ -72,7 +71,7 @@ int32 OS_NotifyEvent(OS_Event_t event, osal_id_t object_id, void *data) * Stub function for OS_RegisterEventHandler() * *****************************************************************************/ -int32 OS_RegisterEventHandler (OS_EventHandler_t handler) +int32 OS_RegisterEventHandler(OS_EventHandler_t handler) { UT_Stub_RegisterContextGenericArg(UT_KEY(OS_RegisterEventHandler), handler); @@ -83,7 +82,6 @@ int32 OS_RegisterEventHandler (OS_EventHandler_t handler) return status; } - /***************************************************************************** * * Stub function for OS_ApplicationExit() @@ -140,4 +138,3 @@ void OS_ApplicationShutdown(uint8 flag) UT_DEFAULT_IMPL(OS_ApplicationShutdown); } - diff --git a/src/ut-stubs/osapi-utstub-countsem.c b/src/ut-stubs/osapi-utstub-countsem.c index 048fc2c44..f6cc0db10 100644 --- a/src/ut-stubs/osapi-utstub-countsem.c +++ b/src/ut-stubs/osapi-utstub-countsem.c @@ -34,16 +34,14 @@ #include "utstub-helpers.h" - -UT_DEFAULT_STUB(OS_CountSemAPI_Init,(void)) +UT_DEFAULT_STUB(OS_CountSemAPI_Init, (void)) /***************************************************************************** * * Stub function for OS_CountSemCreate() * *****************************************************************************/ -int32 OS_CountSemCreate(osal_id_t *sem_id, const char *sem_name, - uint32 sem_initial_value, uint32 options) +int32 OS_CountSemCreate(osal_id_t *sem_id, const char *sem_name, uint32 sem_initial_value, uint32 options) { UT_Stub_RegisterContext(UT_KEY(OS_CountSemCreate), sem_id); UT_Stub_RegisterContext(UT_KEY(OS_CountSemCreate), sem_name); @@ -102,13 +100,12 @@ int32 OS_CountSemDelete(osal_id_t sem_id) return status; } - /***************************************************************************** * * Stub for OS_CountSemGive() function * *****************************************************************************/ -int32 OS_CountSemGive ( osal_id_t sem_id ) +int32 OS_CountSemGive(osal_id_t sem_id) { UT_Stub_RegisterContextGenericArg(UT_KEY(OS_CountSemGive), sem_id); @@ -124,7 +121,7 @@ int32 OS_CountSemGive ( osal_id_t sem_id ) * Stub for OS_CountSemTake() function * *****************************************************************************/ -int32 OS_CountSemTake ( osal_id_t sem_id ) +int32 OS_CountSemTake(osal_id_t sem_id) { UT_Stub_RegisterContextGenericArg(UT_KEY(OS_CountSemTake), sem_id); @@ -140,7 +137,7 @@ int32 OS_CountSemTake ( osal_id_t sem_id ) * Stub for OS_CountSemTimedWait() function * *****************************************************************************/ -int32 OS_CountSemTimedWait ( osal_id_t sem_id, uint32 msecs ) +int32 OS_CountSemTimedWait(osal_id_t sem_id, uint32 msecs) { UT_Stub_RegisterContextGenericArg(UT_KEY(OS_CountSemTimedWait), sem_id); UT_Stub_RegisterContextGenericArg(UT_KEY(OS_CountSemTimedWait), msecs); @@ -157,7 +154,7 @@ int32 OS_CountSemTimedWait ( osal_id_t sem_id, uint32 msecs ) * Stub for OS_CountSemGetIdByName() function * *****************************************************************************/ -int32 OS_CountSemGetIdByName (osal_id_t *sem_id, const char *sem_name) +int32 OS_CountSemGetIdByName(osal_id_t *sem_id, const char *sem_name) { UT_Stub_RegisterContext(UT_KEY(OS_CountSemGetIdByName), sem_id); UT_Stub_RegisterContext(UT_KEY(OS_CountSemGetIdByName), sem_name); @@ -167,7 +164,7 @@ int32 OS_CountSemGetIdByName (osal_id_t *sem_id, const char *sem_name) status = UT_DEFAULT_IMPL(OS_CountSemGetIdByName); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_CountSemGetIdByName), sem_id, sizeof(*sem_id)) < sizeof(*sem_id)) + UT_Stub_CopyToLocal(UT_KEY(OS_CountSemGetIdByName), sem_id, sizeof(*sem_id)) < sizeof(*sem_id)) { UT_ObjIdCompose(1, UT_OBJTYPE_COUNTSEM, sem_id); } @@ -201,16 +198,12 @@ int32 OS_CountSemGetInfo(osal_id_t sem_id, OS_count_sem_prop_t *count_prop) status = UT_DEFAULT_IMPL(OS_CountSemGetInfo); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_CountSemGetInfo), count_prop, sizeof(*count_prop)) < sizeof(*count_prop)) + UT_Stub_CopyToLocal(UT_KEY(OS_CountSemGetInfo), count_prop, sizeof(*count_prop)) < sizeof(*count_prop)) { UT_ObjIdCompose(1, UT_OBJTYPE_TASK, &count_prop->creator); strncpy(count_prop->name, "Name", OS_MAX_API_NAME - 1); count_prop->name[OS_MAX_API_NAME - 1] = '\0'; } - return status; } - - - diff --git a/src/ut-stubs/osapi-utstub-dir.c b/src/ut-stubs/osapi-utstub-dir.c index 5268e2bae..a918974d1 100644 --- a/src/ut-stubs/osapi-utstub-dir.c +++ b/src/ut-stubs/osapi-utstub-dir.c @@ -34,15 +34,14 @@ #include "utstub-helpers.h" - -UT_DEFAULT_STUB(OS_DirAPI_Init,(void)) +UT_DEFAULT_STUB(OS_DirAPI_Init, (void)) /***************************************************************************** * * Stub for OS_mkdir() function * *****************************************************************************/ -int32 OS_mkdir (const char *path, uint32 access) +int32 OS_mkdir(const char *path, uint32 access) { UT_Stub_RegisterContext(UT_KEY(OS_mkdir), path); UT_Stub_RegisterContextGenericArg(UT_KEY(OS_mkdir), access); @@ -59,7 +58,7 @@ int32 OS_mkdir (const char *path, uint32 access) * Stub for OS_rmdir() function * *****************************************************************************/ -int32 OS_rmdir (const char *path) +int32 OS_rmdir(const char *path) { UT_Stub_RegisterContext(UT_KEY(OS_rmdir), path); @@ -70,8 +69,6 @@ int32 OS_rmdir (const char *path) return Status; } - - /***************************************************************************** * * Stub for OS_DirectoryOpen() function @@ -95,7 +92,6 @@ int32 OS_DirectoryOpen(osal_id_t *dir_id, const char *path) *dir_id = UT_STUB_FAKE_OBJECT_ID; } - return Status; } @@ -146,7 +142,7 @@ int32 OS_DirectoryRead(osal_id_t dir_id, os_dirent_t *dirent) UT_Stub_RegisterContextGenericArg(UT_KEY(OS_DirectoryRead), dir_id); UT_Stub_RegisterContext(UT_KEY(OS_DirectoryRead), dirent); - int32 Status; + int32 Status; uint32 CopySize; Status = UT_DEFAULT_IMPL(OS_DirectoryRead); @@ -162,5 +158,3 @@ int32 OS_DirectoryRead(osal_id_t dir_id, os_dirent_t *dirent) return Status; } - - diff --git a/src/ut-stubs/osapi-utstub-errors.c b/src/ut-stubs/osapi-utstub-errors.c index f3259ff99..082881ae1 100644 --- a/src/ut-stubs/osapi-utstub-errors.c +++ b/src/ut-stubs/osapi-utstub-errors.c @@ -34,7 +34,7 @@ #include "utstub-helpers.h" -int32 OS_GetErrorName(int32 error_num, os_err_name_t* err_name) +int32 OS_GetErrorName(int32 error_num, os_err_name_t *err_name) { UT_Stub_RegisterContextGenericArg(UT_KEY(OS_GetErrorName), error_num); UT_Stub_RegisterContext(UT_KEY(OS_GetErrorName), err_name); @@ -43,10 +43,9 @@ int32 OS_GetErrorName(int32 error_num, os_err_name_t* err_name) status = UT_DEFAULT_IMPL(OS_GetErrorName); - if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_GetErrorName), *err_name, sizeof(*err_name)) == 0) + if (status == OS_SUCCESS && UT_Stub_CopyToLocal(UT_KEY(OS_GetErrorName), *err_name, sizeof(*err_name)) == 0) { - snprintf(*err_name,sizeof(*err_name),"ut%d",(int)error_num); + snprintf(*err_name, sizeof(*err_name), "ut%d", (int)error_num); } return status; diff --git a/src/ut-stubs/osapi-utstub-file.c b/src/ut-stubs/osapi-utstub-file.c index 845bffd6a..710accaed 100644 --- a/src/ut-stubs/osapi-utstub-file.c +++ b/src/ut-stubs/osapi-utstub-file.c @@ -34,8 +34,7 @@ #include "utstub-helpers.h" - -UT_DEFAULT_STUB(OS_FileAPI_Init,(void)) +UT_DEFAULT_STUB(OS_FileAPI_Init, (void)) /***************************************************************************** * @@ -44,7 +43,7 @@ UT_DEFAULT_STUB(OS_FileAPI_Init,(void)) *****************************************************************************/ static int32 UT_GenericReadStub(const char *fname, UT_EntryKey_t fkey, void *buffer, uint32 bsize) { - int32 status; + int32 status; uint32 CopySize; status = UT_DefaultStubImpl(fname, fkey, 0x7FFFFFFF); @@ -82,8 +81,8 @@ static int32 UT_GenericReadStub(const char *fname, UT_EntryKey_t fkey, void *buf *****************************************************************************/ static int32 UT_GenericWriteStub(const char *fname, UT_EntryKey_t fkey, const void *buffer, uint32 bsize) { - int32 status; - uint32 CopySize; + int32 status; + uint32 CopySize; status = UT_DefaultStubImpl(fname, fkey, 0x7FFFFFFF); @@ -119,17 +118,17 @@ int32 OS_creat(const char *path, int32 access) UT_Stub_RegisterContext(UT_KEY(OS_creat), path); UT_Stub_RegisterContextGenericArg(UT_KEY(OS_creat), access); osal_id_t objid; - int32 status; + int32 status; status = UT_DEFAULT_IMPL(OS_creat); if (status == OS_SUCCESS) { - objid = UT_AllocStubObjId(UT_OBJTYPE_FILESTREAM); + objid = UT_AllocStubObjId(UT_OBJTYPE_FILESTREAM); status = OS_ObjectIdToInteger(objid); } - return status; + return status; } /***************************************************************************** @@ -143,13 +142,13 @@ int32 OS_open(const char *path, int32 access, uint32 mode) UT_Stub_RegisterContextGenericArg(UT_KEY(OS_open), access); UT_Stub_RegisterContextGenericArg(UT_KEY(OS_open), mode); osal_id_t objid; - int32 status; + int32 status; status = UT_DEFAULT_IMPL(OS_open); if (status == OS_SUCCESS) { - objid = UT_AllocStubObjId(UT_OBJTYPE_FILESTREAM); + objid = UT_AllocStubObjId(UT_OBJTYPE_FILESTREAM); status = OS_ObjectIdToInteger(objid); } @@ -184,7 +183,6 @@ int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 acc return status; } - /***************************************************************************** * * Stub function for OS_close() @@ -211,9 +209,9 @@ int32 OS_close(osal_id_t filedes) * Stub function for OS_StreamRead() * *****************************************************************************/ -int32 OS_StreamRead(osal_id_t filedes, void *buffer, uint32 nbytes, int32 timeout) +int32 OS_StreamRead(osal_id_t filedes, void *buffer, uint32 nbytes, int32 timeout) { - return UT_GenericReadStub(__func__,UT_KEY(OS_StreamRead),buffer,nbytes); + return UT_GenericReadStub(__func__, UT_KEY(OS_StreamRead), buffer, nbytes); } /***************************************************************************** @@ -221,9 +219,9 @@ int32 OS_StreamRead(osal_id_t filedes, void *buffer, uint32 nbytes, int32 timeo * Stub function for OS_StreamWrite() * *****************************************************************************/ -int32 OS_StreamWrite(osal_id_t filedes, const void *buffer, uint32 nbytes, int32 timeout) +int32 OS_StreamWrite(osal_id_t filedes, const void *buffer, uint32 nbytes, int32 timeout) { - return UT_GenericWriteStub(__func__,UT_KEY(OS_StreamWrite),buffer,nbytes); + return UT_GenericWriteStub(__func__, UT_KEY(OS_StreamWrite), buffer, nbytes); } /***************************************************************************** @@ -237,7 +235,7 @@ int32 OS_read(osal_id_t filedes, void *buffer, uint32 nbytes) UT_Stub_RegisterContext(UT_KEY(OS_read), buffer); UT_Stub_RegisterContextGenericArg(UT_KEY(OS_read), nbytes); - return UT_GenericReadStub(__func__,UT_KEY(OS_read),buffer,nbytes); + return UT_GenericReadStub(__func__, UT_KEY(OS_read), buffer, nbytes); } /***************************************************************************** @@ -251,7 +249,7 @@ int32 OS_write(osal_id_t filedes, const void *buffer, uint32 nbytes) UT_Stub_RegisterContext(UT_KEY(OS_write), buffer); UT_Stub_RegisterContextGenericArg(UT_KEY(OS_write), nbytes); - return UT_GenericWriteStub(__func__,UT_KEY(OS_write),buffer,nbytes); + return UT_GenericWriteStub(__func__, UT_KEY(OS_write), buffer, nbytes); } /***************************************************************************** @@ -259,14 +257,14 @@ int32 OS_write(osal_id_t filedes, const void *buffer, uint32 nbytes) * Stub function for OS_TimedRead() * *****************************************************************************/ -int32 OS_TimedRead(osal_id_t filedes, void *buffer, uint32 nbytes, int32 timeout) +int32 OS_TimedRead(osal_id_t filedes, void *buffer, uint32 nbytes, int32 timeout) { UT_Stub_RegisterContextGenericArg(UT_KEY(OS_TimedRead), filedes); UT_Stub_RegisterContext(UT_KEY(OS_TimedRead), buffer); UT_Stub_RegisterContextGenericArg(UT_KEY(OS_TimedRead), nbytes); UT_Stub_RegisterContextGenericArg(UT_KEY(OS_TimedRead), timeout); - return UT_GenericReadStub(__func__,UT_KEY(OS_TimedRead),buffer,nbytes); + return UT_GenericReadStub(__func__, UT_KEY(OS_TimedRead), buffer, nbytes); } /***************************************************************************** @@ -274,23 +272,22 @@ int32 OS_TimedRead(osal_id_t filedes, void *buffer, uint32 nbytes, int32 timeou * Stub function for OS_TimedWrite() * *****************************************************************************/ -int32 OS_TimedWrite(osal_id_t filedes, const void *buffer, uint32 nbytes, int32 timeout) +int32 OS_TimedWrite(osal_id_t filedes, const void *buffer, uint32 nbytes, int32 timeout) { UT_Stub_RegisterContextGenericArg(UT_KEY(OS_TimedWrite), filedes); UT_Stub_RegisterContext(UT_KEY(OS_TimedWrite), buffer); UT_Stub_RegisterContextGenericArg(UT_KEY(OS_TimedWrite), nbytes); UT_Stub_RegisterContextGenericArg(UT_KEY(OS_TimedWrite), timeout); - return UT_GenericWriteStub(__func__,UT_KEY(OS_TimedWrite),buffer,nbytes); + return UT_GenericWriteStub(__func__, UT_KEY(OS_TimedWrite), buffer, nbytes); } - /***************************************************************************** * * Stub function for OS_chmod() * *****************************************************************************/ -int32 OS_chmod (const char *path, uint32 access) +int32 OS_chmod(const char *path, uint32 access) { UT_Stub_RegisterContext(UT_KEY(OS_chmod), path); UT_Stub_RegisterContextGenericArg(UT_KEY(OS_chmod), access); @@ -302,13 +299,12 @@ int32 OS_chmod (const char *path, uint32 access) return Status; } - /***************************************************************************** * * Stub function for OS_stat() * *****************************************************************************/ -int32 OS_stat (const char *path, os_fstat_t *filestats) +int32 OS_stat(const char *path, os_fstat_t *filestats) { UT_Stub_RegisterContext(UT_KEY(OS_stat), path); UT_Stub_RegisterContext(UT_KEY(OS_stat), filestats); @@ -347,7 +343,7 @@ int32 OS_lseek(osal_id_t filedes, int32 offset, uint32 whence) * Stub function for OS_remove() * *****************************************************************************/ -int32 OS_remove (const char *path) +int32 OS_remove(const char *path) { UT_Stub_RegisterContext(UT_KEY(OS_remove), path); @@ -363,7 +359,7 @@ int32 OS_remove (const char *path) * Stub function for OS_rename() * *****************************************************************************/ -int32 OS_rename (const char *old_filename, const char *new_filename) +int32 OS_rename(const char *old_filename, const char *new_filename) { UT_Stub_RegisterContext(UT_KEY(OS_rename), old_filename); UT_Stub_RegisterContext(UT_KEY(OS_rename), new_filename); @@ -380,7 +376,7 @@ int32 OS_rename (const char *old_filename, const char *new_filename) * Stub function for OS_cp() * *****************************************************************************/ -int32 OS_cp (const char *src, const char *dest) +int32 OS_cp(const char *src, const char *dest) { UT_Stub_RegisterContext(UT_KEY(OS_cp), src); UT_Stub_RegisterContext(UT_KEY(OS_cp), dest); @@ -397,7 +393,7 @@ int32 OS_cp (const char *src, const char *dest) * Stub function for OS_mv() * *****************************************************************************/ -int32 OS_mv (const char *src, const char *dest) +int32 OS_mv(const char *src, const char *dest) { UT_Stub_RegisterContext(UT_KEY(OS_mv), src); UT_Stub_RegisterContext(UT_KEY(OS_mv), dest); @@ -409,18 +405,17 @@ int32 OS_mv (const char *src, const char *dest) return Status; } - /***************************************************************************** * * Stub function for OS_FDGetInfo() * *****************************************************************************/ -int32 OS_FDGetInfo (osal_id_t filedes, OS_file_prop_t *fd_prop) +int32 OS_FDGetInfo(osal_id_t filedes, OS_file_prop_t *fd_prop) { UT_Stub_RegisterContextGenericArg(UT_KEY(OS_FDGetInfo), filedes); UT_Stub_RegisterContext(UT_KEY(OS_FDGetInfo), fd_prop); - int32 status; + int32 status; uint32 CopySize; status = UT_DEFAULT_IMPL(OS_FDGetInfo); @@ -440,7 +435,6 @@ int32 OS_FDGetInfo (osal_id_t filedes, OS_file_prop_t *fd_prop) return status; } - /***************************************************************************** * * Stub function for OS_FileOpenCheck() @@ -492,7 +486,7 @@ int32 OS_CloseAllFiles(void) * Stub function for OS_ShellOutputToFile() * *****************************************************************************/ -int32 OS_ShellOutputToFile(const char* Cmd, osal_id_t filedes) +int32 OS_ShellOutputToFile(const char *Cmd, osal_id_t filedes) { UT_Stub_RegisterContext(UT_KEY(OS_ShellOutputToFile), Cmd); UT_Stub_RegisterContextGenericArg(UT_KEY(OS_ShellOutputToFile), filedes); @@ -507,5 +501,3 @@ int32 OS_ShellOutputToFile(const char* Cmd, osal_id_t filedes) return status; } - - diff --git a/src/ut-stubs/osapi-utstub-filesys.c b/src/ut-stubs/osapi-utstub-filesys.c index ba14917f4..12437d88c 100644 --- a/src/ut-stubs/osapi-utstub-filesys.c +++ b/src/ut-stubs/osapi-utstub-filesys.c @@ -34,17 +34,14 @@ #include "utstub-helpers.h" - -UT_DEFAULT_STUB(OS_FileSysAPI_Init,(void)) - +UT_DEFAULT_STUB(OS_FileSysAPI_Init, (void)) /***************************************************************************** * * Stub function for OS_FileSysAddFixedMap() * *****************************************************************************/ -int32 OS_FileSysAddFixedMap(osal_id_t *filesys_id, const char *phys_path, - const char *virt_path) +int32 OS_FileSysAddFixedMap(osal_id_t *filesys_id, const char *phys_path, const char *virt_path) { UT_Stub_RegisterContext(UT_KEY(OS_FileSysAddFixedMap), filesys_id); UT_Stub_RegisterContext(UT_KEY(OS_FileSysAddFixedMap), phys_path); @@ -63,19 +60,15 @@ int32 OS_FileSysAddFixedMap(osal_id_t *filesys_id, const char *phys_pa *filesys_id = UT_STUB_FAKE_OBJECT_ID; } - - return status; } - /***************************************************************************** * * Stub function for OS_mkfs() * *****************************************************************************/ -int32 OS_mkfs(char *address, const char *devname, const char * volname, uint32 blocksize, - uint32 numblocks) +int32 OS_mkfs(char *address, const char *devname, const char *volname, uint32 blocksize, uint32 numblocks) { UT_Stub_RegisterContext(UT_KEY(OS_mkfs), address); UT_Stub_RegisterContext(UT_KEY(OS_mkfs), devname); @@ -111,8 +104,7 @@ int32 OS_rmfs(const char *devname) * Stub function for OS_initfs() * *****************************************************************************/ -int32 OS_initfs(char *address, const char *devname, const char *volname, - uint32 blocksize, uint32 numblocks) +int32 OS_initfs(char *address, const char *devname, const char *volname, uint32 blocksize, uint32 numblocks) { UT_Stub_RegisterContext(UT_KEY(OS_initfs), address); UT_Stub_RegisterContext(UT_KEY(OS_initfs), devname); @@ -132,7 +124,7 @@ int32 OS_initfs(char *address, const char *devname, const char *volname, * Stub function for OS_mount() * *****************************************************************************/ -int32 OS_mount(const char *devname, const char* mountpoint) +int32 OS_mount(const char *devname, const char *mountpoint) { UT_Stub_RegisterContext(UT_KEY(OS_mount), devname); UT_Stub_RegisterContext(UT_KEY(OS_mount), mountpoint); @@ -191,7 +183,7 @@ int32 OS_fsBytesFree(const char *name, uint64 *bytes_free) status = UT_DEFAULT_IMPL(OS_fsBytesFree); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_fsBytesFree), bytes_free, sizeof(*bytes_free)) < sizeof(*bytes_free)) + UT_Stub_CopyToLocal(UT_KEY(OS_fsBytesFree), bytes_free, sizeof(*bytes_free)) < sizeof(*bytes_free)) { *bytes_free = 10000; } @@ -221,7 +213,7 @@ int32 OS_chkfs(const char *name, bool repair) * Stub function for OS_FS_GetPhysDriveName() * *****************************************************************************/ -int32 OS_FS_GetPhysDriveName(char * PhysDriveName, const char * MountPoint) +int32 OS_FS_GetPhysDriveName(char *PhysDriveName, const char *MountPoint) { UT_Stub_RegisterContext(UT_KEY(OS_FS_GetPhysDriveName), PhysDriveName); UT_Stub_RegisterContext(UT_KEY(OS_FS_GetPhysDriveName), MountPoint); @@ -239,14 +231,14 @@ int32 OS_FS_GetPhysDriveName(char * PhysDriveName, const char * MountPoint) * Stub function for OS_GetFsInfo() * *****************************************************************************/ -int32 OS_GetFsInfo(os_fsinfo_t *filesys_info) +int32 OS_GetFsInfo(os_fsinfo_t *filesys_info) { UT_Stub_RegisterContext(UT_KEY(OS_GetFsInfo), filesys_info); int32 status; status = UT_DEFAULT_IMPL(OS_GetFsInfo); - memset(filesys_info, 0, sizeof (*filesys_info)); + memset(filesys_info, 0, sizeof(*filesys_info)); return status; } @@ -256,7 +248,7 @@ int32 OS_GetFsInfo(os_fsinfo_t *filesys_info) * Stub function for OS_TranslatePath() * *****************************************************************************/ -int32 OS_TranslatePath( const char *VirtualPath, char *LocalPath) +int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath) { UT_Stub_RegisterContext(UT_KEY(OS_TranslatePath), VirtualPath); UT_Stub_RegisterContext(UT_KEY(OS_TranslatePath), LocalPath); @@ -266,12 +258,10 @@ int32 OS_TranslatePath( const char *VirtualPath, char *LocalPath) status = UT_DEFAULT_IMPL(OS_TranslatePath); if (status == OS_SUCCESS && VirtualPath != NULL && LocalPath != NULL && - UT_Stub_CopyToLocal(UT_KEY(OS_TranslatePath), LocalPath, OS_MAX_LOCAL_PATH_LEN) == 0) + UT_Stub_CopyToLocal(UT_KEY(OS_TranslatePath), LocalPath, OS_MAX_LOCAL_PATH_LEN) == 0) { strncpy(LocalPath, VirtualPath, OS_MAX_LOCAL_PATH_LEN); } return status; } - - diff --git a/src/ut-stubs/osapi-utstub-heap.c b/src/ut-stubs/osapi-utstub-heap.c index 7803958eb..3fdf50c6d 100644 --- a/src/ut-stubs/osapi-utstub-heap.c +++ b/src/ut-stubs/osapi-utstub-heap.c @@ -34,7 +34,6 @@ #include "utstub-helpers.h" - /***************************************************************************** * * Stub function for OS_HeapGetInfo() @@ -49,15 +48,13 @@ int32 OS_HeapGetInfo(OS_heap_prop_t *heap_prop) status = UT_DEFAULT_IMPL(OS_HeapGetInfo); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_HeapGetInfo), heap_prop, sizeof(*heap_prop)) < sizeof(*heap_prop)) + UT_Stub_CopyToLocal(UT_KEY(OS_HeapGetInfo), heap_prop, sizeof(*heap_prop)) < sizeof(*heap_prop)) { /* Return some random data */ - heap_prop->free_bytes = (uint32) 12345; - heap_prop->free_blocks = (uint32) 6789; - heap_prop->largest_free_block = (uint32) 100; + heap_prop->free_bytes = (uint32)12345; + heap_prop->free_blocks = (uint32)6789; + heap_prop->largest_free_block = (uint32)100; } return status; } - - diff --git a/src/ut-stubs/osapi-utstub-idmap.c b/src/ut-stubs/osapi-utstub-idmap.c index 460d0befb..a1dbfbfbc 100644 --- a/src/ut-stubs/osapi-utstub-idmap.c +++ b/src/ut-stubs/osapi-utstub-idmap.c @@ -18,7 +18,6 @@ * limitations under the License. */ - /** * \file osapi-utstub-idmap.c * \author joseph.p.hickey@nasa.gov @@ -40,7 +39,7 @@ #include "utstub-helpers.h" #include "os-shared-idmap.h" -UT_DEFAULT_STUB(OS_ObjectIdInit,(void)) +UT_DEFAULT_STUB(OS_ObjectIdInit, (void)) /* Lock/Unlock for global tables */ void OS_Lock_Global(uint32 idtype) @@ -101,13 +100,13 @@ uint32 OS_GetBaseForObjectType(uint32 idtype) *****************************************************************************/ int32 OS_ObjectIdToArrayIndex(uint32 idtype, osal_id_t id, uint32 *ArrayIndex) { - int32 Status; + int32 Status; UT_ObjType_t checktype; Status = UT_DEFAULT_IMPL(OS_ObjectIdToArrayIndex); if (Status == 0 && - UT_Stub_CopyToLocal(UT_KEY(OS_ObjectIdToArrayIndex), ArrayIndex, sizeof(*ArrayIndex)) < sizeof(*ArrayIndex)) + UT_Stub_CopyToLocal(UT_KEY(OS_ObjectIdToArrayIndex), ArrayIndex, sizeof(*ArrayIndex)) < sizeof(*ArrayIndex)) { /* this needs to output something valid or code will break */ UT_ObjIdDecompose(id, ArrayIndex, &checktype); @@ -129,7 +128,7 @@ int32 OS_ObjectIdFinalizeNew(int32 operation_status, OS_common_record_t *record, /* need to actually write something to the output buffer */ if (Status == OS_SUCCESS && record != NULL && outid != NULL && - UT_Stub_CopyToLocal(UT_KEY(OS_ObjectIdFinalizeNew), outid, sizeof(*outid)) < sizeof(*outid)) + UT_Stub_CopyToLocal(UT_KEY(OS_ObjectIdFinalizeNew), outid, sizeof(*outid)) < sizeof(*outid)) { *outid = record->active_id; } @@ -151,15 +150,15 @@ int32 OS_ObjectIdFinalizeDelete(int32 operation_status, OS_common_record_t *reco return Status; } - /***************************************************************************** * * Stub function for OS_ObjectIdFindMatch() * *****************************************************************************/ -int32 OS_ObjectIdGetBySearch(OS_lock_mode_t lock_mode, uint32 idtype, OS_ObjectMatchFunc_t MatchFunc, void *arg, OS_common_record_t **record) +int32 OS_ObjectIdGetBySearch(OS_lock_mode_t lock_mode, uint32 idtype, OS_ObjectMatchFunc_t MatchFunc, void *arg, + OS_common_record_t **record) { - int32 Status; + int32 Status; static OS_common_record_t fake_record; /* by default this stub should return NAME_NOT_FOUND @@ -170,7 +169,7 @@ int32 OS_ObjectIdGetBySearch(OS_lock_mode_t lock_mode, uint32 idtype, OS_ObjectM Status = UT_DEFAULT_IMPL(OS_ObjectIdGetBySearch); if (Status == OS_SUCCESS && record != NULL && - UT_Stub_CopyToLocal(UT_KEY(OS_ObjectIdGetBySearch), record, sizeof(*record)) < sizeof(*record)) + UT_Stub_CopyToLocal(UT_KEY(OS_ObjectIdGetBySearch), record, sizeof(*record)) < sizeof(*record)) { memset(&fake_record, 0, sizeof(fake_record)); UT_ObjIdCompose(1, idtype, &fake_record.active_id); @@ -185,7 +184,7 @@ int32 OS_ObjectIdGetBySearch(OS_lock_mode_t lock_mode, uint32 idtype, OS_ObjectM * Stub function for OS_ObjectIdFindByName(, &fake_record.active_id) * *****************************************************************************/ -int32 OS_ObjectIdFindByName (uint32 idtype, const char *name, osal_id_t *object_id) +int32 OS_ObjectIdFindByName(uint32 idtype, const char *name, osal_id_t *object_id) { int32 Status; @@ -194,10 +193,10 @@ int32 OS_ObjectIdFindByName (uint32 idtype, const char *name, osal_id_t *object_ * up a success response, just register a buffer for * the function */ - Status = UT_DEFAULT_IMPL_RC(OS_ObjectIdFindByName,OS_ERR_NAME_NOT_FOUND); + Status = UT_DEFAULT_IMPL_RC(OS_ObjectIdFindByName, OS_ERR_NAME_NOT_FOUND); if (Status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_ObjectIdFindByName), object_id, sizeof(*object_id)) < sizeof(*object_id)) + UT_Stub_CopyToLocal(UT_KEY(OS_ObjectIdFindByName), object_id, sizeof(*object_id)) < sizeof(*object_id)) { UT_ObjIdCompose(1, idtype, object_id); } @@ -210,17 +209,18 @@ int32 OS_ObjectIdFindByName (uint32 idtype, const char *name, osal_id_t *object_ * Stub function for OS_ObjectIdGetByName(,object_id) * *****************************************************************************/ -int32 OS_ObjectIdGetByName (OS_lock_mode_t lock_mode, uint32 idtype, const char *name, OS_common_record_t **record) +int32 OS_ObjectIdGetByName(OS_lock_mode_t lock_mode, uint32 idtype, const char *name, OS_common_record_t **record) { - int32 Status; - OS_common_record_t *local_record; + int32 Status; + OS_common_record_t * local_record; static OS_common_record_t fake_record; Status = UT_DEFAULT_IMPL(OS_ObjectIdGetByName); if (Status == 0) { - if (UT_Stub_CopyToLocal(UT_KEY(OS_ObjectIdGetByName), &local_record, sizeof(local_record)) < sizeof(local_record)) + if (UT_Stub_CopyToLocal(UT_KEY(OS_ObjectIdGetByName), &local_record, sizeof(local_record)) < + sizeof(local_record)) { memset(&fake_record, 0, sizeof(fake_record)); local_record = &fake_record; @@ -242,12 +242,13 @@ int32 OS_ObjectIdGetByName (OS_lock_mode_t lock_mode, uint32 idtype, const char * Stub function for OS_ObjectIdGetById(, &fake_record.active_id) * *****************************************************************************/ -int32 OS_ObjectIdGetById(OS_lock_mode_t check_mode, uint32 idtype, osal_id_t id, uint32 *array_index, OS_common_record_t **record) +int32 OS_ObjectIdGetById(OS_lock_mode_t check_mode, uint32 idtype, osal_id_t id, uint32 *array_index, + OS_common_record_t **record) { - int32 Status; - uint32 local_id; - UT_ObjType_t checktype; - OS_common_record_t *local_record; + int32 Status; + uint32 local_id; + UT_ObjType_t checktype; + OS_common_record_t * local_record; static OS_common_record_t fake_record; Status = UT_DEFAULT_IMPL(OS_ObjectIdGetById); @@ -263,7 +264,7 @@ int32 OS_ObjectIdGetById(OS_lock_mode_t check_mode, uint32 idtype, osal_id_t id, { memset(&fake_record, 0, sizeof(fake_record)); fake_record.active_id = id; - local_record = &fake_record; + local_record = &fake_record; } /* this needs to output something valid or code will break */ @@ -301,9 +302,9 @@ int32 OS_ObjectIdRefcountDecr(OS_common_record_t *record) *****************************************************************************/ int32 OS_ObjectIdGetNext(uint32 idtype, uint32 *curr_index, OS_common_record_t **record) { - int32 Status; - uint32 local_id; - OS_common_record_t *local_record; + int32 Status; + uint32 local_id; + OS_common_record_t * local_record; static OS_common_record_t fake_record; Status = UT_DEFAULT_IMPL(OS_ObjectIdGetNext); @@ -321,7 +322,8 @@ int32 OS_ObjectIdGetNext(uint32 idtype, uint32 *curr_index, OS_common_record_t * } else { - if (UT_Stub_CopyToLocal(UT_KEY(OS_ObjectIdGetNext), &local_record, sizeof(local_record)) < sizeof(local_record)) + if (UT_Stub_CopyToLocal(UT_KEY(OS_ObjectIdGetNext), &local_record, sizeof(local_record)) < + sizeof(local_record)) { memset(&fake_record, 0, sizeof(fake_record)); UT_ObjIdCompose(local_id, idtype, &fake_record.active_id); @@ -350,9 +352,9 @@ int32 OS_ObjectIdGetNext(uint32 idtype, uint32 *curr_index, OS_common_record_t * *****************************************************************************/ int32 OS_ObjectIdAllocateNew(uint32 idtype, const char *name, uint32 *array_index, OS_common_record_t **record) { - int32 Status; - uint32 local_id; - OS_common_record_t *local_record; + int32 Status; + uint32 local_id; + OS_common_record_t * local_record; static OS_common_record_t fake_record; Status = UT_DEFAULT_IMPL(OS_ObjectIdAllocateNew); @@ -364,14 +366,15 @@ int32 OS_ObjectIdAllocateNew(uint32 idtype, const char *name, uint32 *array_inde local_id = UT_GetStubCount(UT_KEY(OS_ObjectIdAllocateNew)) & 0xFFFF; } - if (UT_Stub_CopyToLocal(UT_KEY(OS_ObjectIdAllocateNew), &local_record, sizeof(local_record)) < sizeof(local_record)) + if (UT_Stub_CopyToLocal(UT_KEY(OS_ObjectIdAllocateNew), &local_record, sizeof(local_record)) < + sizeof(local_record)) { memset(&fake_record, 0, sizeof(fake_record)); UT_ObjIdCompose(local_id, idtype, &fake_record.active_id); local_record = &fake_record; } - *record = local_record; + *record = local_record; *array_index = local_id; } @@ -398,8 +401,7 @@ int32 OS_GetResourceName(osal_id_t object_id, char *buffer, uint32 buffer_size) if (return_code == OS_SUCCESS) { - if (buffer_size > 0 && - UT_Stub_CopyToLocal(UT_KEY(OS_GetResourceName), buffer, buffer_size) == 0) + if (buffer_size > 0 && UT_Stub_CopyToLocal(UT_KEY(OS_GetResourceName), buffer, buffer_size) == 0) { /* return an empty string by default */ buffer[0] = 0; @@ -424,29 +426,29 @@ int32 OS_ConvertToArrayIndex(osal_id_t object_id, uint32 *ArrayIndex) UT_Stub_RegisterContextGenericArg(UT_KEY(OS_ConvertToArrayIndex), object_id); UT_Stub_RegisterContext(UT_KEY(OS_ConvertToArrayIndex), ArrayIndex); - int32 return_code; - - return_code = UT_DEFAULT_IMPL(OS_ConvertToArrayIndex); - - if (return_code == OS_SUCCESS) - { - UT_ObjType_t ObjType; - UT_ObjIdDecompose(object_id, ArrayIndex, &ObjType); - if (ObjType != UT_OBJTYPE_NONE && ObjType < UT_OBJTYPE_MAX) - { - *ArrayIndex %= UT_MAXOBJS[ObjType]; - } - } - else - { - /* - * If set to fail, then set the output to something bizarre - if the code - * actually tries to use this, chances are it will segfault and be fixed - */ - *ArrayIndex = 0xDEADBEEFU; - } - - return return_code; + int32 return_code; + + return_code = UT_DEFAULT_IMPL(OS_ConvertToArrayIndex); + + if (return_code == OS_SUCCESS) + { + UT_ObjType_t ObjType; + UT_ObjIdDecompose(object_id, ArrayIndex, &ObjType); + if (ObjType != UT_OBJTYPE_NONE && ObjType < UT_OBJTYPE_MAX) + { + *ArrayIndex %= UT_MAXOBJS[ObjType]; + } + } + else + { + /* + * If set to fail, then set the output to something bizarre - if the code + * actually tries to use this, chances are it will segfault and be fixed + */ + *ArrayIndex = 0xDEADBEEFU; + } + + return return_code; } /* end OS_ConvertToArrayIndex */ /*-------------------------------------------------------------------------------------- @@ -456,7 +458,7 @@ int32 OS_ConvertToArrayIndex(osal_id_t object_id, uint32 *ArrayIndex) returns: None ---------------------------------------------------------------------------------------*/ -void OS_ForEachObjectOfType (uint32 objtype, osal_id_t creator_id, OS_ArgCallback_t callback_ptr, void *callback_arg) +void OS_ForEachObjectOfType(uint32 objtype, osal_id_t creator_id, OS_ArgCallback_t callback_ptr, void *callback_arg) { UT_Stub_RegisterContextGenericArg(UT_KEY(OS_ForEachObjectOfType), objtype); UT_Stub_RegisterContextGenericArg(UT_KEY(OS_ForEachObjectOfType), creator_id); @@ -464,7 +466,7 @@ void OS_ForEachObjectOfType (uint32 objtype, osal_id_t creator_id, OS_ArgCal UT_Stub_RegisterContext(UT_KEY(OS_ForEachObjectOfType), callback_arg); osal_id_t NextId; - uint32 IdSize; + uint32 IdSize; /* Although this is "void", Invoke the default impl to log it and invoke any hooks */ UT_DEFAULT_IMPL(OS_ForEachObjectOfType); @@ -488,14 +490,14 @@ void OS_ForEachObjectOfType (uint32 objtype, osal_id_t creator_id, OS_ArgCal returns: None ---------------------------------------------------------------------------------------*/ -void OS_ForEachObject (osal_id_t creator_id, OS_ArgCallback_t callback_ptr, void *callback_arg) +void OS_ForEachObject(osal_id_t creator_id, OS_ArgCallback_t callback_ptr, void *callback_arg) { UT_Stub_RegisterContextGenericArg(UT_KEY(OS_ForEachObject), creator_id); UT_Stub_RegisterContextGenericArg(UT_KEY(OS_ForEachObject), callback_ptr); UT_Stub_RegisterContext(UT_KEY(OS_ForEachObject), callback_arg); osal_id_t NextId; - uint32 IdSize; + uint32 IdSize; /* Although this is "void", Invoke the default impl to log it and invoke any hooks */ UT_DEFAULT_IMPL(OS_ForEachObject); @@ -518,54 +520,54 @@ void OS_ForEachObject (osal_id_t creator_id, OS_ArgCallback_t callback_ptr, void returns: The type of object that the ID represents ---------------------------------------------------------------------------------------*/ -uint32 OS_IdentifyObject (osal_id_t object_id) +uint32 OS_IdentifyObject(osal_id_t object_id) { UT_Stub_RegisterContextGenericArg(UT_KEY(OS_IdentifyObject), object_id); UT_ObjType_t ObjType; - uint32 checkindx; - int32 DefaultType; + uint32 checkindx; + int32 DefaultType; UT_ObjIdDecompose(object_id, &checkindx, &ObjType); switch (ObjType) { - case UT_OBJTYPE_TASK: - DefaultType = OS_OBJECT_TYPE_OS_TASK; - break; - case UT_OBJTYPE_QUEUE: - DefaultType = OS_OBJECT_TYPE_OS_QUEUE; - break; - case UT_OBJTYPE_COUNTSEM: - DefaultType = OS_OBJECT_TYPE_OS_COUNTSEM; - break; - case UT_OBJTYPE_BINSEM: - DefaultType = OS_OBJECT_TYPE_OS_BINSEM; - break; - case UT_OBJTYPE_MUTEX: - DefaultType = OS_OBJECT_TYPE_OS_MUTEX; - break; - case UT_OBJTYPE_TIMECB: - DefaultType = OS_OBJECT_TYPE_OS_TIMECB; - break; - case UT_OBJTYPE_MODULE: - DefaultType = OS_OBJECT_TYPE_OS_MODULE; - break; - case UT_OBJTYPE_FILESTREAM: - DefaultType = OS_OBJECT_TYPE_OS_STREAM; - break; - case UT_OBJTYPE_TIMEBASE: - DefaultType = OS_OBJECT_TYPE_OS_TIMEBASE; - break; - case UT_OBJTYPE_DIR: - DefaultType = OS_OBJECT_TYPE_OS_DIR; - break; - case UT_OBJTYPE_FILESYS: - DefaultType = OS_OBJECT_TYPE_OS_FILESYS; - break; - default: - DefaultType = OS_OBJECT_TYPE_UNDEFINED; - break; + case UT_OBJTYPE_TASK: + DefaultType = OS_OBJECT_TYPE_OS_TASK; + break; + case UT_OBJTYPE_QUEUE: + DefaultType = OS_OBJECT_TYPE_OS_QUEUE; + break; + case UT_OBJTYPE_COUNTSEM: + DefaultType = OS_OBJECT_TYPE_OS_COUNTSEM; + break; + case UT_OBJTYPE_BINSEM: + DefaultType = OS_OBJECT_TYPE_OS_BINSEM; + break; + case UT_OBJTYPE_MUTEX: + DefaultType = OS_OBJECT_TYPE_OS_MUTEX; + break; + case UT_OBJTYPE_TIMECB: + DefaultType = OS_OBJECT_TYPE_OS_TIMECB; + break; + case UT_OBJTYPE_MODULE: + DefaultType = OS_OBJECT_TYPE_OS_MODULE; + break; + case UT_OBJTYPE_FILESTREAM: + DefaultType = OS_OBJECT_TYPE_OS_STREAM; + break; + case UT_OBJTYPE_TIMEBASE: + DefaultType = OS_OBJECT_TYPE_OS_TIMEBASE; + break; + case UT_OBJTYPE_DIR: + DefaultType = OS_OBJECT_TYPE_OS_DIR; + break; + case UT_OBJTYPE_FILESYS: + DefaultType = OS_OBJECT_TYPE_OS_FILESYS; + break; + default: + DefaultType = OS_OBJECT_TYPE_UNDEFINED; + break; } return UT_DEFAULT_IMPL_RC(OS_IdentifyObject, DefaultType); diff --git a/src/ut-stubs/osapi-utstub-module.c b/src/ut-stubs/osapi-utstub-module.c index 08102b221..e5d4e4054 100644 --- a/src/ut-stubs/osapi-utstub-module.c +++ b/src/ut-stubs/osapi-utstub-module.c @@ -34,8 +34,7 @@ #include "utstub-helpers.h" - -UT_DEFAULT_STUB(OS_ModuleAPI_Init,(void)) +UT_DEFAULT_STUB(OS_ModuleAPI_Init, (void)) /*****************************************************************************/ /** @@ -61,8 +60,6 @@ int32 dummy_function(void) return status; } - - /*****************************************************************************/ /** ** \brief OS_ModuleLoad stub function @@ -171,7 +168,7 @@ int32 OS_ModuleInfo(osal_id_t module_id, OS_module_prop_t *module_info) status = UT_DEFAULT_IMPL(OS_ModuleInfo); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_ModuleInfo), module_info, sizeof(*module_info)) < sizeof(*module_info)) + UT_Stub_CopyToLocal(UT_KEY(OS_ModuleInfo), module_info, sizeof(*module_info)) < sizeof(*module_info)) { memset(module_info, 0, sizeof(*module_info)); } @@ -216,10 +213,11 @@ int32 OS_SymbolLookup(cpuaddr *symbol_address, const char *symbol_name) { *symbol_address = 0xDEADBEEFU; } - else if (UT_Stub_CopyToLocal(UT_KEY(OS_SymbolLookup), symbol_address, sizeof(*symbol_address)) < sizeof(*symbol_address)) + else if (UT_Stub_CopyToLocal(UT_KEY(OS_SymbolLookup), symbol_address, sizeof(*symbol_address)) < + sizeof(*symbol_address)) { /* return the dummy function when test didn't register anything else */ - *symbol_address = (cpuaddr) &dummy_function; + *symbol_address = (cpuaddr)&dummy_function; } return status; @@ -230,7 +228,7 @@ int32 OS_SymbolLookup(cpuaddr *symbol_address, const char *symbol_name) * Stub function for OS_SymbolTableDump() * *****************************************************************************/ -int32 OS_SymbolTableDump ( const char *filename, uint32 size_limit ) +int32 OS_SymbolTableDump(const char *filename, uint32 size_limit) { UT_Stub_RegisterContext(UT_KEY(OS_SymbolTableDump), filename); UT_Stub_RegisterContextGenericArg(UT_KEY(OS_SymbolTableDump), size_limit); diff --git a/src/ut-stubs/osapi-utstub-mutex.c b/src/ut-stubs/osapi-utstub-mutex.c index e475243e0..0e3d28629 100644 --- a/src/ut-stubs/osapi-utstub-mutex.c +++ b/src/ut-stubs/osapi-utstub-mutex.c @@ -18,7 +18,6 @@ * limitations under the License. */ - /** * \file osapi-utstub-mutex.c * \author joseph.p.hickey@nasa.gov @@ -33,8 +32,7 @@ #include "utstub-helpers.h" - -UT_DEFAULT_STUB(OS_MutexAPI_Init,(void)) +UT_DEFAULT_STUB(OS_MutexAPI_Init, (void)) /*****************************************************************************/ /** @@ -184,7 +182,7 @@ int32 OS_MutSemTake(osal_id_t sem_id) * Stub function for OS_MutSemGetIdByName() * *****************************************************************************/ -int32 OS_MutSemGetIdByName (osal_id_t *sem_id, const char *sem_name) +int32 OS_MutSemGetIdByName(osal_id_t *sem_id, const char *sem_name) { UT_Stub_RegisterContext(UT_KEY(OS_MutSemGetIdByName), sem_id); UT_Stub_RegisterContext(UT_KEY(OS_MutSemGetIdByName), sem_name); @@ -194,7 +192,7 @@ int32 OS_MutSemGetIdByName (osal_id_t *sem_id, const char *sem_name) status = UT_DEFAULT_IMPL(OS_MutSemGetIdByName); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_MutSemGetIdByName), sem_id, sizeof(*sem_id)) < sizeof(*sem_id)) + UT_Stub_CopyToLocal(UT_KEY(OS_MutSemGetIdByName), sem_id, sizeof(*sem_id)) < sizeof(*sem_id)) { UT_ObjIdCompose(1, UT_OBJTYPE_MUTEX, sem_id); } @@ -202,7 +200,6 @@ int32 OS_MutSemGetIdByName (osal_id_t *sem_id, const char *sem_name) return status; } - /*****************************************************************************/ /** ** \brief OS_MutSemGetInfo stub function @@ -229,7 +226,7 @@ int32 OS_MutSemGetInfo(osal_id_t sem_id, OS_mut_sem_prop_t *mut_prop) status = UT_DEFAULT_IMPL(OS_MutSemGetInfo); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_MutSemGetInfo), mut_prop, sizeof(*mut_prop)) < sizeof(*mut_prop)) + UT_Stub_CopyToLocal(UT_KEY(OS_MutSemGetInfo), mut_prop, sizeof(*mut_prop)) < sizeof(*mut_prop)) { strncpy(mut_prop->name, "Name", OS_MAX_API_NAME - 1); mut_prop->name[OS_MAX_API_NAME - 1] = '\0'; @@ -238,6 +235,3 @@ int32 OS_MutSemGetInfo(osal_id_t sem_id, OS_mut_sem_prop_t *mut_prop) return status; } - - - diff --git a/src/ut-stubs/osapi-utstub-network.c b/src/ut-stubs/osapi-utstub-network.c index 772cadaec..de3c9a240 100644 --- a/src/ut-stubs/osapi-utstub-network.c +++ b/src/ut-stubs/osapi-utstub-network.c @@ -34,9 +34,7 @@ #include "utstub-helpers.h" - -UT_DEFAULT_STUB(OS_NetworkAPI_Init,(void)) - +UT_DEFAULT_STUB(OS_NetworkAPI_Init, (void)) int32 OS_NetworkGetHostName(char *host_name, uint32 name_len) { @@ -48,10 +46,10 @@ int32 OS_NetworkGetHostName(char *host_name, uint32 name_len) status = UT_DEFAULT_IMPL(OS_NetworkGetHostName); if (status == OS_SUCCESS && name_len > 0 && - UT_Stub_CopyToLocal(UT_KEY(OS_NetworkGetHostName), host_name, name_len) == 0) + UT_Stub_CopyToLocal(UT_KEY(OS_NetworkGetHostName), host_name, name_len) == 0) { - strncpy(host_name, "ut", name_len-1); - host_name[name_len-1] = 0; + strncpy(host_name, "ut", name_len - 1); + host_name[name_len - 1] = 0; } return status; @@ -65,7 +63,4 @@ int32 OS_NetworkGetID(void) return status; -}/* end OS_NetworkGetID */ - - - +} /* end OS_NetworkGetID */ diff --git a/src/ut-stubs/osapi-utstub-printf.c b/src/ut-stubs/osapi-utstub-printf.c index 04b7c49ba..2ed283e95 100644 --- a/src/ut-stubs/osapi-utstub-printf.c +++ b/src/ut-stubs/osapi-utstub-printf.c @@ -34,7 +34,6 @@ #include "utstub-helpers.h" - int32 OS_ConsoleAPI_Init(void) { return UT_DEFAULT_IMPL(OS_ConsoleAPI_Init); @@ -64,7 +63,7 @@ void OS_printf(const char *string, ...) int32 length = strlen(string); va_list va; - va_start(va,string); + va_start(va, string); status = UT_DefaultStubImplWithArgs(__func__, UT_KEY(OS_printf), 0, va); @@ -75,10 +74,9 @@ void OS_printf(const char *string, ...) * This is merely a way to avoid having to do full-blown printf processing * inside the UT stub (which would make it the full version, not a stub) */ - if (strcmp(string, "%s") == 0 || - strcmp(string, "%s\n") == 0) + if (strcmp(string, "%s") == 0 || strcmp(string, "%s\n") == 0) { - string = va_arg(va,const char *); + string = va_arg(va, const char *); } length = strlen(string); if (length > 0) @@ -89,7 +87,7 @@ void OS_printf(const char *string, ...) * * (this is to ensure a consistent separator in the output buffer) */ - while (length > 0 && string[length-1] == '\n') + while (length > 0 && string[length - 1] == '\n') { --length; } @@ -120,4 +118,3 @@ void OS_printf_enable(void) { UT_DEFAULT_IMPL(OS_printf_enable); } - diff --git a/src/ut-stubs/osapi-utstub-queue.c b/src/ut-stubs/osapi-utstub-queue.c index 71c305501..bcd09e65b 100644 --- a/src/ut-stubs/osapi-utstub-queue.c +++ b/src/ut-stubs/osapi-utstub-queue.c @@ -34,8 +34,7 @@ #include "utstub-helpers.h" - -UT_DEFAULT_STUB(OS_QueueAPI_Init,(void)) +UT_DEFAULT_STUB(OS_QueueAPI_Init, (void)) /*****************************************************************************/ /** @@ -62,11 +61,7 @@ UT_DEFAULT_STUB(OS_QueueAPI_Init,(void)) ** or OS_SUCCESS. ** ******************************************************************************/ -int32 OS_QueueCreate(osal_id_t *queue_id, - const char *queue_name, - uint32 queue_depth, - uint32 data_size, - uint32 flags) +int32 OS_QueueCreate(osal_id_t *queue_id, const char *queue_name, uint32 queue_depth, uint32 data_size, uint32 flags) { UT_Stub_RegisterContext(UT_KEY(OS_QueueCreate), queue_id); UT_Stub_RegisterContext(UT_KEY(OS_QueueCreate), queue_name); @@ -74,7 +69,7 @@ int32 OS_QueueCreate(osal_id_t *queue_id, UT_Stub_RegisterContextGenericArg(UT_KEY(OS_QueueCreate), data_size); UT_Stub_RegisterContextGenericArg(UT_KEY(OS_QueueCreate), flags); - int32 status; + int32 status; status = UT_DEFAULT_IMPL(OS_QueueCreate); @@ -117,7 +112,7 @@ int32 OS_QueueDelete(osal_id_t queue_id) { UT_Stub_RegisterContextGenericArg(UT_KEY(OS_QueueDelete), queue_id); - int32 status; + int32 status; status = UT_DEFAULT_IMPL(OS_QueueDelete); @@ -154,11 +149,7 @@ int32 OS_QueueDelete(osal_id_t queue_id) ** or OS_SUCCESS. ** ******************************************************************************/ -int32 OS_QueueGet(osal_id_t queue_id, - void *data, - uint32 size, - uint32 *size_copied, - int32 timeout) +int32 OS_QueueGet(osal_id_t queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout) { UT_Stub_RegisterContextGenericArg(UT_KEY(OS_QueueGet), queue_id); UT_Stub_RegisterContext(UT_KEY(OS_QueueGet), data); @@ -166,7 +157,7 @@ int32 OS_QueueGet(osal_id_t queue_id, UT_Stub_RegisterContext(UT_KEY(OS_QueueGet), size_copied); UT_Stub_RegisterContextGenericArg(UT_KEY(OS_QueueGet), timeout); - int32 status; + int32 status; status = UT_DEFAULT_IMPL(OS_QueueGet); @@ -212,7 +203,7 @@ int32 OS_QueuePut(osal_id_t queue_id, const void *data, uint32 size, uint32 flag UT_Stub_RegisterContextGenericArg(UT_KEY(OS_QueuePut), size); UT_Stub_RegisterContextGenericArg(UT_KEY(OS_QueuePut), flags); - int32 status; + int32 status; status = UT_DEFAULT_IMPL(OS_QueuePut); @@ -229,7 +220,7 @@ int32 OS_QueuePut(osal_id_t queue_id, const void *data, uint32 size, uint32 flag * Stub function for OS_QueueGetIdByName() * *****************************************************************************/ -int32 OS_QueueGetIdByName (osal_id_t *queue_id, const char *queue_name) +int32 OS_QueueGetIdByName(osal_id_t *queue_id, const char *queue_name) { UT_Stub_RegisterContext(UT_KEY(OS_QueueGetIdByName), queue_id); UT_Stub_RegisterContext(UT_KEY(OS_QueueGetIdByName), queue_name); @@ -239,9 +230,9 @@ int32 OS_QueueGetIdByName (osal_id_t *queue_id, const char *queue_name) status = UT_DEFAULT_IMPL(OS_QueueGetIdByName); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_QueueGetIdByName), queue_id, sizeof(*queue_id)) < sizeof(*queue_id)) + UT_Stub_CopyToLocal(UT_KEY(OS_QueueGetIdByName), queue_id, sizeof(*queue_id)) < sizeof(*queue_id)) { - UT_ObjIdCompose(1, UT_OBJTYPE_QUEUE,queue_id); + UT_ObjIdCompose(1, UT_OBJTYPE_QUEUE, queue_id); } return status; @@ -273,15 +264,12 @@ int32 OS_QueueGetInfo(osal_id_t queue_id, OS_queue_prop_t *queue_prop) status = UT_DEFAULT_IMPL(OS_QueueGetInfo); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_QueueGetInfo), queue_prop, sizeof(*queue_prop)) < sizeof(*queue_prop)) + UT_Stub_CopyToLocal(UT_KEY(OS_QueueGetInfo), queue_prop, sizeof(*queue_prop)) < sizeof(*queue_prop)) { UT_ObjIdCompose(1, UT_OBJTYPE_TASK, &queue_prop->creator); strncpy(queue_prop->name, "Name", OS_MAX_API_NAME - 1); queue_prop->name[OS_MAX_API_NAME - 1] = '\0'; } - return status; } - - diff --git a/src/ut-stubs/osapi-utstub-select.c b/src/ut-stubs/osapi-utstub-select.c index 6be77a36a..96514bd33 100644 --- a/src/ut-stubs/osapi-utstub-select.c +++ b/src/ut-stubs/osapi-utstub-select.c @@ -32,7 +32,6 @@ #include "utstub-helpers.h" - /***************************************************************************** * * Stub function for OS_SelectSingle() @@ -112,11 +111,11 @@ int32 OS_SelectFdClear(OS_FdSet *Set, osal_id_t objid) UT_Stub_RegisterContext(UT_KEY(OS_SelectFdClear), Set); UT_Stub_RegisterContextGenericArg(UT_KEY(OS_SelectFdClear), objid); - int32 return_code; + int32 return_code; - return_code = UT_DEFAULT_IMPL(OS_SelectFdClear); + return_code = UT_DEFAULT_IMPL(OS_SelectFdClear); - return return_code; + return return_code; } /***************************************************************************** @@ -129,10 +128,9 @@ bool OS_SelectFdIsSet(OS_FdSet *Set, osal_id_t objid) UT_Stub_RegisterContext(UT_KEY(OS_SelectFdIsSet), Set); UT_Stub_RegisterContextGenericArg(UT_KEY(OS_SelectFdIsSet), objid); - int32 return_code; + int32 return_code; - return_code = UT_DEFAULT_IMPL(OS_SelectFdIsSet); + return_code = UT_DEFAULT_IMPL(OS_SelectFdIsSet); - return (return_code == 0); + return (return_code == 0); } - diff --git a/src/ut-stubs/osapi-utstub-sockets.c b/src/ut-stubs/osapi-utstub-sockets.c index 7a1618286..5563a0980 100644 --- a/src/ut-stubs/osapi-utstub-sockets.c +++ b/src/ut-stubs/osapi-utstub-sockets.c @@ -32,7 +32,7 @@ #include "utstub-helpers.h" -UT_DEFAULT_STUB(OS_SocketAPI_Init,(void)) +UT_DEFAULT_STUB(OS_SocketAPI_Init, (void)) /***************************************************************************** * @@ -123,7 +123,7 @@ int32 OS_SocketRecvFrom(osal_id_t sock_id, void *buffer, uint32 buflen, OS_SockA UT_Stub_RegisterContext(UT_KEY(OS_SocketRecvFrom), RemoteAddr); UT_Stub_RegisterContextGenericArg(UT_KEY(OS_SocketRecvFrom), timeout); - int32 status; + int32 status; uint32 CopySize; status = UT_DEFAULT_IMPL(OS_SocketRecvFrom); @@ -151,7 +151,6 @@ int32 OS_SocketRecvFrom(osal_id_t sock_id, void *buffer, uint32 buflen, OS_SockA memset(buffer, 0, status); } - return status; } @@ -167,7 +166,7 @@ int32 OS_SocketSendTo(osal_id_t sock_id, const void *buffer, uint32 buflen, cons UT_Stub_RegisterContextGenericArg(UT_KEY(OS_SocketSendTo), buflen); UT_Stub_RegisterContext(UT_KEY(OS_SocketSendTo), RemoteAddr); - int32 status; + int32 status; uint32 CopySize; status = UT_DEFAULT_IMPL_RC(OS_SocketSendTo, 0x7FFFFFFF); @@ -192,13 +191,12 @@ int32 OS_SocketSendTo(osal_id_t sock_id, const void *buffer, uint32 buflen, cons return status; } - /***************************************************************************** * * Stub function for OS_SocketGetIdByName() * *****************************************************************************/ -int32 OS_SocketGetIdByName (osal_id_t *sock_id, const char *sock_name) +int32 OS_SocketGetIdByName(osal_id_t *sock_id, const char *sock_name) { UT_Stub_RegisterContext(UT_KEY(OS_SocketGetIdByName), sock_id); UT_Stub_RegisterContext(UT_KEY(OS_SocketGetIdByName), sock_name); @@ -208,7 +206,7 @@ int32 OS_SocketGetIdByName (osal_id_t *sock_id, const char *sock_name) status = UT_DEFAULT_IMPL(OS_SocketGetIdByName); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_SocketGetIdByName), sock_id, sizeof(*sock_id)) < sizeof(*sock_id)) + UT_Stub_CopyToLocal(UT_KEY(OS_SocketGetIdByName), sock_id, sizeof(*sock_id)) < sizeof(*sock_id)) { UT_ObjIdCompose(1, UT_OBJTYPE_SOCKET, sock_id); } @@ -221,12 +219,12 @@ int32 OS_SocketGetIdByName (osal_id_t *sock_id, const char *sock_name) * Stub function for OS_SocketGetInfo(,sock_id) * *****************************************************************************/ -int32 OS_SocketGetInfo (osal_id_t sock_id, OS_socket_prop_t *sock_prop) +int32 OS_SocketGetInfo(osal_id_t sock_id, OS_socket_prop_t *sock_prop) { UT_Stub_RegisterContextGenericArg(UT_KEY(OS_SocketGetInfo), sock_id); UT_Stub_RegisterContext(UT_KEY(OS_SocketGetInfo), sock_prop); - int32 status; + int32 status; uint32 CopySize; status = UT_DEFAULT_IMPL(OS_SocketGetInfo); @@ -245,7 +243,6 @@ int32 OS_SocketGetInfo (osal_id_t sock_id, OS_socket_prop_t *sock_prop) return status; } - int32 OS_SocketAddrInit(OS_SockAddr_t *Addr, OS_SocketDomain_t Domain) { UT_Stub_RegisterContext(UT_KEY(OS_SocketAddrInit), Addr); @@ -255,8 +252,7 @@ int32 OS_SocketAddrInit(OS_SockAddr_t *Addr, OS_SocketDomain_t Domain) status = UT_DEFAULT_IMPL(OS_SocketAddrInit); - if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_SocketAddrInit), Addr, sizeof(*Addr)) < sizeof(*Addr)) + if (status == OS_SUCCESS && UT_Stub_CopyToLocal(UT_KEY(OS_SocketAddrInit), Addr, sizeof(*Addr)) < sizeof(*Addr)) { memset(Addr, 0, sizeof(*Addr)); } @@ -274,11 +270,10 @@ int32 OS_SocketAddrToString(char *buffer, uint32 buflen, const OS_SockAddr_t *Ad status = UT_DEFAULT_IMPL(OS_SocketAddrToString); - if (status == OS_SUCCESS && buflen > 0 && - UT_Stub_CopyToLocal(UT_KEY(OS_SocketAddrToString), buffer, buflen) == 0) + if (status == OS_SUCCESS && buflen > 0 && UT_Stub_CopyToLocal(UT_KEY(OS_SocketAddrToString), buffer, buflen) == 0) { - strncpy(buffer, "UT-addr", buflen-1); - buffer[buflen-1] = 0; + strncpy(buffer, "UT-addr", buflen - 1); + buffer[buflen - 1] = 0; } return status; @@ -294,7 +289,7 @@ int32 OS_SocketAddrFromString(OS_SockAddr_t *Addr, const char *string) status = UT_DEFAULT_IMPL(OS_SocketAddrFromString); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_SocketAddrFromString), Addr, sizeof(*Addr)) < sizeof(*Addr)) + UT_Stub_CopyToLocal(UT_KEY(OS_SocketAddrFromString), Addr, sizeof(*Addr)) < sizeof(*Addr)) { memset(Addr, 0, sizeof(*Addr)); } @@ -312,7 +307,7 @@ int32 OS_SocketAddrGetPort(uint16 *PortNum, const OS_SockAddr_t *Addr) status = UT_DEFAULT_IMPL(OS_SocketAddrGetPort); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_SocketAddrGetPort), PortNum, sizeof(*PortNum)) < sizeof(*PortNum)) + UT_Stub_CopyToLocal(UT_KEY(OS_SocketAddrGetPort), PortNum, sizeof(*PortNum)) < sizeof(*PortNum)) { *PortNum = 0; } @@ -331,4 +326,3 @@ int32 OS_SocketAddrSetPort(OS_SockAddr_t *Addr, uint16 PortNum) return status; } - diff --git a/src/ut-stubs/osapi-utstub-task.c b/src/ut-stubs/osapi-utstub-task.c index 61d9f111b..097cf8083 100644 --- a/src/ut-stubs/osapi-utstub-task.c +++ b/src/ut-stubs/osapi-utstub-task.c @@ -34,8 +34,7 @@ #include "utstub-helpers.h" -UT_DEFAULT_STUB(OS_TaskAPI_Init,(void)) - +UT_DEFAULT_STUB(OS_TaskAPI_Init, (void)) /*****************************************************************************/ /** @@ -53,11 +52,8 @@ UT_DEFAULT_STUB(OS_TaskAPI_Init,(void)) ** Returns either OS_SUCCESS or OS_ERROR. ** ******************************************************************************/ -int32 OS_TaskCreate(osal_id_t *task_id, const char *task_name, - osal_task_entry function_pointer, - uint32 *stack_pointer, - uint32 stack_size, uint32 priority, - uint32 flags) +int32 OS_TaskCreate(osal_id_t *task_id, const char *task_name, osal_task_entry function_pointer, uint32 *stack_pointer, + uint32 stack_size, uint32 priority, uint32 flags) { UT_Stub_RegisterContext(UT_KEY(OS_TaskCreate), task_id); UT_Stub_RegisterContext(UT_KEY(OS_TaskCreate), task_name); @@ -80,7 +76,6 @@ int32 OS_TaskCreate(osal_id_t *task_id, const char *task_name, *task_id = UT_STUB_FAKE_OBJECT_ID; } - return status; } @@ -116,7 +111,6 @@ int32 OS_TaskDelete(osal_id_t task_id) return status; } - /*****************************************************************************/ /** ** \brief OS_TaskExit stub function @@ -171,7 +165,7 @@ int32 OS_TaskDelay(uint32 millisecond) * Stub function for OS_TaskSetPriority() * *****************************************************************************/ -int32 OS_TaskSetPriority (osal_id_t task_id, uint32 new_priority) +int32 OS_TaskSetPriority(osal_id_t task_id, uint32 new_priority) { UT_Stub_RegisterContextGenericArg(UT_KEY(OS_TaskSetPriority), task_id); UT_Stub_RegisterContextGenericArg(UT_KEY(OS_TaskSetPriority), new_priority); @@ -208,7 +202,6 @@ int32 OS_TaskRegister(void) return status; } - /*****************************************************************************/ /** ** \brief OS_TaskGetId stub function @@ -227,7 +220,7 @@ int32 OS_TaskRegister(void) osal_id_t OS_TaskGetId(void) { osal_id_t TaskId; - int32 status; + int32 status; status = UT_DEFAULT_IMPL_RC(OS_TaskGetId, 1); UT_ObjIdCompose(status, UT_OBJTYPE_TASK, &TaskId); @@ -235,13 +228,12 @@ osal_id_t OS_TaskGetId(void) return TaskId; } - /***************************************************************************** * * Stub function for OS_TaskGetIdByName() * *****************************************************************************/ -int32 OS_TaskGetIdByName (osal_id_t *task_id, const char *task_name) +int32 OS_TaskGetIdByName(osal_id_t *task_id, const char *task_name) { UT_Stub_RegisterContext(UT_KEY(OS_TaskGetIdByName), task_id); UT_Stub_RegisterContext(UT_KEY(OS_TaskGetIdByName), task_name); @@ -251,7 +243,7 @@ int32 OS_TaskGetIdByName (osal_id_t *task_id, const char *task_name) status = UT_DEFAULT_IMPL(OS_TaskGetIdByName); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_TaskGetIdByName), task_id, sizeof(*task_id)) < sizeof(*task_id)) + UT_Stub_CopyToLocal(UT_KEY(OS_TaskGetIdByName), task_id, sizeof(*task_id)) < sizeof(*task_id)) { UT_ObjIdCompose(1, UT_OBJTYPE_TASK, task_id); } @@ -259,7 +251,6 @@ int32 OS_TaskGetIdByName (osal_id_t *task_id, const char *task_name) return status; } - /*****************************************************************************/ /** ** \brief OS_TaskGetInfo stub function @@ -287,11 +278,11 @@ int32 OS_TaskGetInfo(osal_id_t task_id, OS_task_prop_t *task_prop) status = UT_DEFAULT_IMPL(OS_TaskGetInfo); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_TaskGetInfo), task_prop, sizeof(*task_prop)) < sizeof(*task_prop)) + UT_Stub_CopyToLocal(UT_KEY(OS_TaskGetInfo), task_prop, sizeof(*task_prop)) < sizeof(*task_prop)) { UT_ObjIdCompose(1, UT_OBJTYPE_TASK, &task_prop->creator); task_prop->stack_size = 100; - task_prop->priority = 150; + task_prop->priority = 150; strncpy(task_prop->name, "UnitTest", OS_MAX_API_NAME - 1); task_prop->name[OS_MAX_API_NAME - 1] = '\0'; } @@ -322,7 +313,7 @@ int32 OS_TaskFindIdBySystemData(osal_id_t *task_id, const void *sysdata, size_t status = UT_DEFAULT_IMPL(OS_TaskFindIdBySystemData); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_TaskFindIdBySystemData), task_id, sizeof(*task_id)) < sizeof(*task_id)) + UT_Stub_CopyToLocal(UT_KEY(OS_TaskFindIdBySystemData), task_id, sizeof(*task_id)) < sizeof(*task_id)) { UT_ObjIdCompose(1, UT_OBJTYPE_TASK, task_id); } diff --git a/src/ut-stubs/osapi-utstub-time.c b/src/ut-stubs/osapi-utstub-time.c index 909ff8bcc..e6783689d 100644 --- a/src/ut-stubs/osapi-utstub-time.c +++ b/src/ut-stubs/osapi-utstub-time.c @@ -34,14 +34,15 @@ #include "utstub-helpers.h" -UT_DEFAULT_STUB(OS_TimerCbAPI_Init,(void)) +UT_DEFAULT_STUB(OS_TimerCbAPI_Init, (void)) /***************************************************************************** * * Stub function for OS_TimerAdd() * *****************************************************************************/ -int32 OS_TimerAdd(osal_id_t *timer_id, const char *timer_name, osal_id_t timebase_id, OS_ArgCallback_t callback_ptr, void *callback_arg) +int32 OS_TimerAdd(osal_id_t *timer_id, const char *timer_name, osal_id_t timebase_id, OS_ArgCallback_t callback_ptr, + void *callback_arg) { UT_Stub_RegisterContext(UT_KEY(OS_TimerAdd), timer_id); UT_Stub_RegisterContext(UT_KEY(OS_TimerAdd), timer_name); @@ -70,7 +71,8 @@ int32 OS_TimerAdd(osal_id_t *timer_id, const char *timer_name, osal_id_t timebas * Stub function for OS_TimerCreate() * *****************************************************************************/ -int32 OS_TimerCreate(osal_id_t *timer_id, const char *timer_name, uint32 *clock_accuracy, OS_TimerCallback_t callback_ptr) +int32 OS_TimerCreate(osal_id_t *timer_id, const char *timer_name, uint32 *clock_accuracy, + OS_TimerCallback_t callback_ptr) { UT_Stub_RegisterContext(UT_KEY(OS_TimerCreate), timer_id); UT_Stub_RegisterContext(UT_KEY(OS_TimerCreate), timer_name); @@ -111,7 +113,6 @@ int32 OS_TimerSet(osal_id_t timer_id, uint32 start_time, uint32 interval_time) return status; } - /*****************************************************************************/ /** ** \brief OS_TimerDelete stub function @@ -148,7 +149,7 @@ int32 OS_TimerDelete(osal_id_t timer_id) * Stub function for OS_TimerGetIdByName() * *****************************************************************************/ -int32 OS_TimerGetIdByName (osal_id_t *timer_id, const char *timer_name) +int32 OS_TimerGetIdByName(osal_id_t *timer_id, const char *timer_name) { UT_Stub_RegisterContext(UT_KEY(OS_TimerGetIdByName), timer_id); UT_Stub_RegisterContext(UT_KEY(OS_TimerGetIdByName), timer_name); @@ -158,7 +159,7 @@ int32 OS_TimerGetIdByName (osal_id_t *timer_id, const char *timer_name) status = UT_DEFAULT_IMPL(OS_TimerGetIdByName); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_TimerGetIdByName), timer_id, sizeof(*timer_id)) < sizeof(*timer_id)) + UT_Stub_CopyToLocal(UT_KEY(OS_TimerGetIdByName), timer_id, sizeof(*timer_id)) < sizeof(*timer_id)) { UT_ObjIdCompose(1, UT_OBJTYPE_TIMECB, timer_id); } @@ -195,7 +196,7 @@ int32 OS_TimerGetInfo(osal_id_t timer_id, OS_timer_prop_t *timer_prop) status = UT_DEFAULT_IMPL(OS_TimerGetInfo); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_TimerGetInfo), timer_prop, sizeof(*timer_prop)) < sizeof(*timer_prop)) + UT_Stub_CopyToLocal(UT_KEY(OS_TimerGetInfo), timer_prop, sizeof(*timer_prop)) < sizeof(*timer_prop)) { memset(timer_prop, 0, sizeof(*timer_prop)); UT_ObjIdCompose(1, UT_OBJTYPE_TASK, &timer_prop->creator); @@ -203,7 +204,3 @@ int32 OS_TimerGetInfo(osal_id_t timer_id, OS_timer_prop_t *timer_prop) return status; } - - - - diff --git a/src/ut-stubs/osapi-utstub-timebase.c b/src/ut-stubs/osapi-utstub-timebase.c index 95676e73d..96664c7bd 100644 --- a/src/ut-stubs/osapi-utstub-timebase.c +++ b/src/ut-stubs/osapi-utstub-timebase.c @@ -34,8 +34,7 @@ #include "utstub-helpers.h" - -UT_DEFAULT_STUB(OS_TimeBaseAPI_Init,(void)) +UT_DEFAULT_STUB(OS_TimeBaseAPI_Init, (void)) /***************************************************************************** * @@ -64,7 +63,6 @@ int32 OS_TimeBaseCreate(osal_id_t *timebase_id, const char *timebase_name, OS_Ti return status; } - /***************************************************************************** * * Stub for OS_TimeBaseSet() function @@ -83,7 +81,6 @@ int32 OS_TimeBaseSet(osal_id_t timebase_id, uint32 start_time, uint32 interval_t return status; } - /***************************************************************************** * * Stub for OS_TimeBaseDelete() function @@ -105,13 +102,12 @@ int32 OS_TimeBaseDelete(osal_id_t timebase_id) return status; } - /***************************************************************************** * * Stub for OS_TimeBaseGetIdByName() function * *****************************************************************************/ -int32 OS_TimeBaseGetIdByName (osal_id_t *timebase_id, const char *timebase_name) +int32 OS_TimeBaseGetIdByName(osal_id_t *timebase_id, const char *timebase_name) { UT_Stub_RegisterContext(UT_KEY(OS_TimeBaseGetIdByName), timebase_id); UT_Stub_RegisterContext(UT_KEY(OS_TimeBaseGetIdByName), timebase_name); @@ -121,7 +117,7 @@ int32 OS_TimeBaseGetIdByName (osal_id_t *timebase_id, const char *timebase_name) status = UT_DEFAULT_IMPL(OS_TimeBaseGetIdByName); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_TimeBaseGetIdByName), timebase_id, sizeof(*timebase_id)) < sizeof(*timebase_id)) + UT_Stub_CopyToLocal(UT_KEY(OS_TimeBaseGetIdByName), timebase_id, sizeof(*timebase_id)) < sizeof(*timebase_id)) { UT_ObjIdCompose(1, UT_OBJTYPE_TIMEBASE, timebase_id); } @@ -129,13 +125,12 @@ int32 OS_TimeBaseGetIdByName (osal_id_t *timebase_id, const char *timebase_name) return status; } - /***************************************************************************** * * Stub for OS_TimeBaseGetInfo() function * *****************************************************************************/ -int32 OS_TimeBaseGetInfo (osal_id_t timebase_id, OS_timebase_prop_t *timebase_prop) +int32 OS_TimeBaseGetInfo(osal_id_t timebase_id, OS_timebase_prop_t *timebase_prop) { UT_Stub_RegisterContextGenericArg(UT_KEY(OS_TimeBaseGetInfo), timebase_id); UT_Stub_RegisterContext(UT_KEY(OS_TimeBaseGetInfo), timebase_prop); @@ -145,14 +140,13 @@ int32 OS_TimeBaseGetInfo (osal_id_t timebase_id, OS_timebase_prop_t *timebase_pr status = UT_DEFAULT_IMPL(OS_TimeBaseGetInfo); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_TimeBaseGetInfo), timebase_prop, sizeof(*timebase_prop)) < sizeof(*timebase_prop)) + UT_Stub_CopyToLocal(UT_KEY(OS_TimeBaseGetInfo), timebase_prop, sizeof(*timebase_prop)) < sizeof(*timebase_prop)) { UT_ObjIdCompose(1, UT_OBJTYPE_TASK, &timebase_prop->creator); strncpy(timebase_prop->name, "Name", OS_MAX_API_NAME - 1); timebase_prop->name[OS_MAX_API_NAME - 1] = '\0'; } - return status; } @@ -161,7 +155,7 @@ int32 OS_TimeBaseGetInfo (osal_id_t timebase_id, OS_timebase_prop_t *timebase_pr * Stub for OS_TimeBaseGetFreeRun() function * *****************************************************************************/ -int32 OS_TimeBaseGetFreeRun (osal_id_t timebase_id, uint32 *freerun_val) +int32 OS_TimeBaseGetFreeRun(osal_id_t timebase_id, uint32 *freerun_val) { UT_Stub_RegisterContextGenericArg(UT_KEY(OS_TimeBaseGetFreeRun), timebase_id); UT_Stub_RegisterContext(UT_KEY(OS_TimeBaseGetFreeRun), freerun_val); @@ -171,7 +165,7 @@ int32 OS_TimeBaseGetFreeRun (osal_id_t timebase_id, uint32 *freerun_val) status = UT_DEFAULT_IMPL(OS_TimeBaseGetFreeRun); if (status == OS_SUCCESS && - UT_Stub_CopyToLocal(UT_KEY(OS_TimeBaseGetFreeRun), freerun_val, sizeof(*freerun_val)) < sizeof(*freerun_val)) + UT_Stub_CopyToLocal(UT_KEY(OS_TimeBaseGetFreeRun), freerun_val, sizeof(*freerun_val)) < sizeof(*freerun_val)) { int32 tempcount; int32 temprc; @@ -191,7 +185,6 @@ int32 OS_TimeBaseGetFreeRun (osal_id_t timebase_id, uint32 *freerun_val) } return status; - } /***************************************************************************** diff --git a/src/ut-stubs/utstub-helpers.c b/src/ut-stubs/utstub-helpers.c index 9285c7503..ce6750e7d 100644 --- a/src/ut-stubs/utstub-helpers.c +++ b/src/ut-stubs/utstub-helpers.c @@ -34,47 +34,40 @@ #include "utstub-helpers.h" - -const uint32 UT_MAXOBJS[UT_OBJTYPE_MAX] = -{ - [UT_OBJTYPE_TASK] = OS_MAX_TASKS, - [UT_OBJTYPE_QUEUE] = OS_MAX_QUEUES, - [UT_OBJTYPE_COUNTSEM] = OS_MAX_COUNT_SEMAPHORES, - [UT_OBJTYPE_BINSEM] = OS_MAX_BIN_SEMAPHORES, - [UT_OBJTYPE_MUTEX] = OS_MAX_MUTEXES, - [UT_OBJTYPE_TIMECB] = OS_MAX_TIMERS, - [UT_OBJTYPE_MODULE] = OS_MAX_MODULES, - [UT_OBJTYPE_FILESTREAM] = OS_MAX_NUM_OPEN_FILES, - [UT_OBJTYPE_TIMEBASE] = OS_MAX_TIMEBASES, - [UT_OBJTYPE_FILESYS] = OS_MAX_FILE_SYSTEMS, - [UT_OBJTYPE_DIR] = OS_MAX_NUM_OPEN_DIRS -}; - +const uint32 UT_MAXOBJS[UT_OBJTYPE_MAX] = {[UT_OBJTYPE_TASK] = OS_MAX_TASKS, + [UT_OBJTYPE_QUEUE] = OS_MAX_QUEUES, + [UT_OBJTYPE_COUNTSEM] = OS_MAX_COUNT_SEMAPHORES, + [UT_OBJTYPE_BINSEM] = OS_MAX_BIN_SEMAPHORES, + [UT_OBJTYPE_MUTEX] = OS_MAX_MUTEXES, + [UT_OBJTYPE_TIMECB] = OS_MAX_TIMERS, + [UT_OBJTYPE_MODULE] = OS_MAX_MODULES, + [UT_OBJTYPE_FILESTREAM] = OS_MAX_NUM_OPEN_FILES, + [UT_OBJTYPE_TIMEBASE] = OS_MAX_TIMEBASES, + [UT_OBJTYPE_FILESYS] = OS_MAX_FILE_SYSTEMS, + [UT_OBJTYPE_DIR] = OS_MAX_NUM_OPEN_DIRS}; static UT_ObjTypeState_t UT_ObjState[UT_OBJTYPE_MAX]; /** * Initialization function */ -void UT_ClearAllStubObjects (void) +void UT_ClearAllStubObjects(void) { - /* - * Reset the fake ID numbers for create/delete operations - */ - memset(UT_ObjState, 0, sizeof(UT_ObjState)); + /* + * Reset the fake ID numbers for create/delete operations + */ + memset(UT_ObjState, 0, sizeof(UT_ObjState)); } - - /* * Helper function - "allocate" a fake object ID of the given type */ osal_id_t UT_AllocStubObjId(UT_ObjType_t ObjType) { UT_ObjTypeState_t *StatePtr; - uint8 ObjMask; - uint32 indx; - osal_id_t Result; + uint8 ObjMask; + uint32 indx; + osal_id_t Result; UT_Stub_CallOnce(UT_ClearAllStubObjects); @@ -123,10 +116,10 @@ osal_id_t UT_AllocStubObjId(UT_ObjType_t ObjType) void UT_DeleteStubObjId(UT_ObjType_t ObjType, osal_id_t ObjId) { UT_ObjTypeState_t *StatePtr; - uint8 ObjMask; - UT_ObjType_t checktype; - uint32 checkidx; - bool ObjWasValid; + uint8 ObjMask; + UT_ObjType_t checktype; + uint32 checkidx; + bool ObjWasValid; UT_Stub_CallOnce(UT_ClearAllStubObjects); @@ -151,7 +144,7 @@ void UT_DeleteStubObjId(UT_ObjType_t ObjType, osal_id_t ObjId) /* Clear out any bit it could have been */ ObjWasValid = false; - ObjMask = 1 << (checkidx & 0x07); + ObjMask = 1 << (checkidx & 0x07); if ((StatePtr->ValidBits[checkidx >> 3] & ObjMask) != 0) { ObjWasValid = true; @@ -186,12 +179,10 @@ void UT_ObjIdCompose(uint32 indx, UT_ObjType_t objtype, osal_id_t *id) void UT_ObjIdDecompose(osal_id_t id, uint32 *indx, UT_ObjType_t *objtype) { unsigned long idv = OS_ObjectIdToInteger(id); - *indx = idv & 0xFFFFUL; - *objtype = (idv >> 16) ^ 0x4000UL; + *indx = idv & 0xFFFFUL; + *objtype = (idv >> 16) ^ 0x4000UL; } - - /* ** Report and close any sockets found open ** Moved here temporarily to ensure full compatibility with CFE implementation @@ -203,17 +194,14 @@ void UT_ObjIdDecompose(osal_id_t id, uint32 *indx, UT_ObjType_t *objtype) void UT_CheckForOpenSockets(void) { UT_ObjTypeState_t *StatePtr; - uint32 i; + uint32 i; StatePtr = &UT_ObjState[UT_OBJTYPE_QUEUE]; - for (i=0; i <= StatePtr->LastIssueNumber; ++i) + for (i = 0; i <= StatePtr->LastIssueNumber; ++i) { if ((StatePtr->ValidBits[i >> 3] & (1 << (i & 0x07))) != 0) { UtAssert_Failed("UT_Queue %d left open.\n", (int)i); } } - } - - diff --git a/src/ut-stubs/utstub-helpers.h b/src/ut-stubs/utstub-helpers.h index 6501a6a79..5d8997639 100644 --- a/src/ut-stubs/utstub-helpers.h +++ b/src/ut-stubs/utstub-helpers.h @@ -49,8 +49,6 @@ #include "utassert.h" #include "uttools.h" - - typedef enum { UT_OBJTYPE_NONE = 0, @@ -72,7 +70,7 @@ typedef enum /* * A constant to use in stubs where no other value is applicable */ -#define UT_STUB_FAKE_OBJECT_ID ((osal_id_t){0xDEADBEEFU}) +#define UT_STUB_FAKE_OBJECT_ID ((osal_id_t) {0xDEADBEEFU}) /* * Size of the bitmask for the OSAL fake object ID validity table @@ -84,15 +82,14 @@ typedef enum * (Default value of 16 allows for up to 128 objects to be created in * a single test case, far more than anything I've seen yet) */ -#define OSAL_MAX_VALID_PER_TYPE 16 +#define OSAL_MAX_VALID_PER_TYPE 16 typedef struct { uint32 LastIssueNumber; - uint8 ValidBits[OSAL_MAX_VALID_PER_TYPE]; + uint8 ValidBits[OSAL_MAX_VALID_PER_TYPE]; } UT_ObjTypeState_t; - /** * Table lookup for the maximum number of OSAL objects by object type */ @@ -128,5 +125,3 @@ void UT_ObjIdCompose(uint32 indx, UT_ObjType_t objtype, osal_id_t *id); void UT_ObjIdDecompose(osal_id_t id, uint32 *indx, UT_ObjType_t *objtype); #endif - - diff --git a/ut_assert/inc/utassert.h b/ut_assert/inc/utassert.h index 6e9d6e1b3..37c852ec4 100644 --- a/ut_assert/inc/utassert.h +++ b/ut_assert/inc/utassert.h @@ -32,7 +32,7 @@ */ #ifndef _utassert_ -#define _utassert_ +#define _utassert_ /* * Includes @@ -53,19 +53,19 @@ */ typedef enum { - UTASSERT_CASETYPE_NONE, /**< Reserved value, No messages should be used with this */ - UTASSERT_CASETYPE_ABORT, /**< Test sequence abort (major failure, cannot continue) */ - UTASSERT_CASETYPE_FAILURE, /**< Test case failure status messages */ - UTASSERT_CASETYPE_TSF, /**< Test Setup Failure (TSF) status messages */ - UTASSERT_CASETYPE_TTF, /**< Test Teardown Failure (TTF) status messages */ - UTASSERT_CASETYPE_MIR, /**< Manual Inspection Required (MIR) status messages */ - UTASSERT_CASETYPE_NA, /**< Test Not Applicable (NA) status messages */ - UTASSERT_CASETYPE_BEGIN, /**< Beginning of test status messages */ - UTASSERT_CASETYPE_END, /**< End of test status messages */ - UTASSERT_CASETYPE_INFO, /**< All other informational status messages */ - UTASSERT_CASETYPE_PASS, /**< Test case passed (normal) status messages */ - UTASSERT_CASETYPE_DEBUG, /**< Debugging messages */ - UTASSERT_CASETYPE_MAX /**< Reserved value, No messages should be used with this */ + UTASSERT_CASETYPE_NONE, /**< Reserved value, No messages should be used with this */ + UTASSERT_CASETYPE_ABORT, /**< Test sequence abort (major failure, cannot continue) */ + UTASSERT_CASETYPE_FAILURE, /**< Test case failure status messages */ + UTASSERT_CASETYPE_TSF, /**< Test Setup Failure (TSF) status messages */ + UTASSERT_CASETYPE_TTF, /**< Test Teardown Failure (TTF) status messages */ + UTASSERT_CASETYPE_MIR, /**< Manual Inspection Required (MIR) status messages */ + UTASSERT_CASETYPE_NA, /**< Test Not Applicable (NA) status messages */ + UTASSERT_CASETYPE_BEGIN, /**< Beginning of test status messages */ + UTASSERT_CASETYPE_END, /**< End of test status messages */ + UTASSERT_CASETYPE_INFO, /**< All other informational status messages */ + UTASSERT_CASETYPE_PASS, /**< Test case passed (normal) status messages */ + UTASSERT_CASETYPE_DEBUG, /**< Debugging messages */ + UTASSERT_CASETYPE_MAX /**< Reserved value, No messages should be used with this */ } UtAssert_CaseType_t; /** @@ -79,168 +79,162 @@ typedef struct uint32 CaseCount[UTASSERT_CASETYPE_MAX]; } UtAssert_TestCounter_t; - /* * Macro Definitions */ /* A simplified UtAssert that uses the expression itself as the description */ -#define UtAssert_Simple(Expression) \ - UtAssert(Expression, #Expression, __FILE__, __LINE__) +#define UtAssert_Simple(Expression) UtAssert(Expression, #Expression, __FILE__, __LINE__) /* Evaluates a expression as either true or false. true means the test passed, false means the test failed. */ -#define UtAssert_True(Expression, ...) \ - UtAssertEx(Expression, UtAssert_GetContext(), __FILE__, __LINE__, __VA_ARGS__) +#define UtAssert_True(Expression, ...) UtAssertEx(Expression, UtAssert_GetContext(), __FILE__, __LINE__, __VA_ARGS__) /* Evaluates a expression as either true or false. true means the test passed, false means the test failed. */ -#define UtAssert_Bool(Expression, Description) \ - UtAssert(Expression, Description, __FILE__, __LINE__) +#define UtAssert_Bool(Expression, Description) UtAssert(Expression, Description, __FILE__, __LINE__) /* Asserts a test failure */ -#define UtAssert_Failed(...) \ - UtAssertEx(false, UtAssert_GetContext(), __FILE__, __LINE__, __VA_ARGS__) +#define UtAssert_Failed(...) UtAssertEx(false, UtAssert_GetContext(), __FILE__, __LINE__, __VA_ARGS__) /* Compares two integers and determines if they are equal within a specified absolute tolerance. */ -#define UtAssert_IntegerCmpAbs(x, y, Tolerance, Description) \ - UtAssert((abs((x) - (y)) <= (Tolerance)), Description, __FILE__, __LINE__) +#define UtAssert_IntegerCmpAbs(x, y, Tolerance, Description) \ + UtAssert((abs((x) - (y)) <= (Tolerance)), Description, __FILE__, __LINE__) /* Compares two floating point numbers and determines if they are equal within a specified absolute tolerance. */ -#define UtAssert_DoubleCmpAbs(x, y, Tolerance, Description) \ - UtAssert((fabs((x) - (y)) <= (Tolerance)), Description, __FILE__, __LINE__) +#define UtAssert_DoubleCmpAbs(x, y, Tolerance, Description) \ + UtAssert((fabs((x) - (y)) <= (Tolerance)), Description, __FILE__, __LINE__) /* Compares two floating point numbers and determines if they are equal within a specified relative tolerance. */ -#define UtAssert_DoubleCmpRel(x, y, Ratio, Description) \ - UtAssert((fabs((x) - (y))/(x) <= (Ratio)), Description, __FILE__, __LINE__) +#define UtAssert_DoubleCmpRel(x, y, Ratio, Description) \ + UtAssert((fabs((x) - (y)) / (x) <= (Ratio)), Description, __FILE__, __LINE__) /* Compares two strings and determines if they are equal. */ -#define UtAssert_StrCmp(String1, String2, Description) \ - UtAssert((strcmp(String1, String2) == 0), Description, __FILE__, __LINE__) +#define UtAssert_StrCmp(String1, String2, Description) \ + UtAssert((strcmp(String1, String2) == 0), Description, __FILE__, __LINE__) /* Compares at most Length characters of two strings and determines if they are equal. */ -#define UtAssert_StrnCmp(String1, String2, Length, Description) \ - UtAssert((strncmp(String1, String2, Length) == 0), Description, __FILE__, __LINE__) +#define UtAssert_StrnCmp(String1, String2, Length, Description) \ + UtAssert((strncmp(String1, String2, Length) == 0), Description, __FILE__, __LINE__) /* Compares two regions of memory and determines if they are equal. */ -#define UtAssert_MemCmp(Memory1, Memory2, Length, Description) \ - UtAssert((memcmp(Memory1, Memory2, Length) == 0), Description, __FILE__, __LINE__) +#define UtAssert_MemCmp(Memory1, Memory2, Length, Description) \ + UtAssert((memcmp(Memory1, Memory2, Length) == 0), Description, __FILE__, __LINE__) /* Compares a region of memory to a static pattern and determines if they are equal. Note: Use UtMemSet to * fill a region of memory with a static pattern. */ -#define UtAssert_MemCmpValue(Memory, Value, Length, Description) \ - UtAssert((UtMemCmpValue(Memory, Value, Length)), Description, __FILE__, __LINE__) +#define UtAssert_MemCmpValue(Memory, Value, Length, Description) \ + UtAssert((UtMemCmpValue(Memory, Value, Length)), Description, __FILE__, __LINE__) /* Compares a region of memory to a byte count pattern and determines if they are equal. Note: Use UtMemFill to * fill a region of memory with a byte count pattern. */ -#define UtAssert_MemCmpCount(Memory, Length, Description) \ - UtAssert((UtMemCmpCount(Memory, Length)), Description, __FILE__, __LINE__) +#define UtAssert_MemCmpCount(Memory, Length, Description) \ + UtAssert((UtMemCmpCount(Memory, Length)), Description, __FILE__, __LINE__) /* Compares a region of memory with the contents of a binary file and determines if they are equal. Note: Use * UtMem2BinFile to copy a region of memory to a binary file. */ -#define UtAssert_Mem2BinFileCmp(Memory, Filename, Description) \ - UtAssert((UtMem2BinFileCmp(Memory, Filename)), Description, __FILE__, __LINE__) +#define UtAssert_Mem2BinFileCmp(Memory, Filename, Description) \ + UtAssert((UtMem2BinFileCmp(Memory, Filename)), Description, __FILE__, __LINE__) /* A wrapper around UtAssertEx that allows the user to specify the failure type and a more descriptive message */ -#define UtAssert_Type(Type,Expression,...) \ - UtAssertEx(Expression, UTASSERT_CASETYPE_##Type, __FILE__, __LINE__, __VA_ARGS__) +#define UtAssert_Type(Type, Expression, ...) \ + UtAssertEx(Expression, UTASSERT_CASETYPE_##Type, __FILE__, __LINE__, __VA_ARGS__) /** * \brief Compare addresses for equality with an auto-generated description message */ -#define UtAssert_ADDRESS_EQ(actual,expect) do \ -{ \ - void *exp = (void*)(expect); \ - void *act = (void*)(actual); \ - UtAssert_True(act == exp, "%s (%p) == %s (%p)", \ - #actual, act, #expect, exp); \ -} while(0) \ +#define UtAssert_ADDRESS_EQ(actual, expect) \ + do \ + { \ + void *exp = (void *)(expect); \ + void *act = (void *)(actual); \ + UtAssert_True(act == exp, "%s (%p) == %s (%p)", #actual, act, #expect, exp); \ + } while (0) /** * \brief Compare two values for equality with an auto-generated description message * Values will be compared in an "int32" type context. */ -#define UtAssert_INT32_EQ(actual,expect) do \ -{ \ - int32 rcexp = (int32)(expect); \ - int32 rcact = (int32)(actual); \ - UtAssert_True(rcact == rcexp, "%s (%ld) == %s (%ld)", \ - #actual, (long)rcact, \ - #expect, (long)rcexp); \ -} while(0) +#define UtAssert_INT32_EQ(actual, expect) \ + do \ + { \ + int32 rcexp = (int32)(expect); \ + int32 rcact = (int32)(actual); \ + UtAssert_True(rcact == rcexp, "%s (%ld) == %s (%ld)", #actual, (long)rcact, #expect, (long)rcexp); \ + } while (0) /** * \brief Compare two values for equality with an auto-generated description message * Values will be compared in an "uint32" type context. */ -#define UtAssert_UINT32_EQ(actual,expect) do \ -{ \ - uint32 rcexp = (uint32)(expect); \ - uint32 rcact = (uint32)(actual); \ - UtAssert_True(rcact == rcexp, "%s (%lu) == %s (%lu)", \ - #actual, (unsigned long)rcact, \ - #expect, (unsigned long)rcexp); \ -} while(0) +#define UtAssert_UINT32_EQ(actual, expect) \ + do \ + { \ + uint32 rcexp = (uint32)(expect); \ + uint32 rcact = (uint32)(actual); \ + UtAssert_True(rcact == rcexp, "%s (%lu) == %s (%lu)", #actual, (unsigned long)rcact, #expect, \ + (unsigned long)rcexp); \ + } while (0) /** * \brief Confirm a pointer value is not NULL */ -#define UtAssert_NOT_NULL(actual) do \ -{ \ - void* ptr = (void*)(actual); \ - UtAssert_True(ptr != NULL, "%s (%p) != NULL", \ - #actual, ptr); \ -} while(0) +#define UtAssert_NOT_NULL(actual) \ + do \ + { \ + void *ptr = (void *)(actual); \ + UtAssert_True(ptr != NULL, "%s (%p) != NULL", #actual, ptr); \ + } while (0) /** * \brief Confirm a pointer value is NULL */ -#define UtAssert_NULL(actual) do \ -{ \ - void* ptr = (void*)(actual); \ - UtAssert_True(ptr == NULL, "%s (%p) == NULL", \ - #actual, ptr); \ -} while(0) +#define UtAssert_NULL(actual) \ + do \ + { \ + void *ptr = (void *)(actual); \ + UtAssert_True(ptr == NULL, "%s (%p) == NULL", #actual, ptr); \ + } while (0) /** * \brief Confirm an integer value is nonzero */ -#define UtAssert_NONZERO(actual) do \ -{ \ - long val = (long)(actual); \ - UtAssert_True(val != 0, "%s (%ld) != 0", \ - #actual, val); \ -} while(0) +#define UtAssert_NONZERO(actual) \ + do \ + { \ + long val = (long)(actual); \ + UtAssert_True(val != 0, "%s (%ld) != 0", #actual, val); \ + } while (0) /** * \brief Confirm an integer value is nonzero */ -#define UtAssert_ZERO(actual) do \ -{ \ - long val = (long)(actual); \ - UtAssert_True(val == 0, "%s (%ld) == 0", \ - #actual, val); \ -} while(0) +#define UtAssert_ZERO(actual) \ + do \ + { \ + long val = (long)(actual); \ + UtAssert_True(val == 0, "%s (%ld) == 0", #actual, val); \ + } while (0) /** * \brief Confirm that a stub function has been invoked the expected number of times */ -#define UtAssert_STUB_COUNT(stub,expected) do \ -{ \ - uint32 expval = (uint32)(expected); \ - uint32 actval = UT_GetStubCount(UT_KEY(stub)); \ - UtAssert_True(actval == expval, "%s() count (%lu) == %s (%lu)", \ - #stub, (unsigned long)actval, \ - #expected, (unsigned long)expval); \ -} while(0) +#define UtAssert_STUB_COUNT(stub, expected) \ + do \ + { \ + uint32 expval = (uint32)(expected); \ + uint32 actval = UT_GetStubCount(UT_KEY(stub)); \ + UtAssert_True(actval == expval, "%s() count (%lu) == %s (%lu)", #stub, (unsigned long)actval, #expected, \ + (unsigned long)expval); \ + } while (0) /* * Exported Functions */ /* Returns the number of asserts that have passed. */ -uint32 UtAssert_GetPassCount(void); +uint32 UtAssert_GetPassCount(void); /* Returns the number of asserts that have failed. */ -uint32 UtAssert_GetFailCount(void); +uint32 UtAssert_GetFailCount(void); /* Returns the full status of UtAssert counters */ const UtAssert_TestCounter_t *UtAssert_GetCounters(void); @@ -261,13 +255,14 @@ UtAssert_CaseType_t UtAssert_GetContext(void); const char *UtAssert_GetSegmentName(void); /* Base assert function. All asserts must call this function. */ -bool UtAssert(bool Expression, const char *Description, const char *File, uint32 Line); +bool UtAssert(bool Expression, const char *Description, const char *File, uint32 Line); /* * Assert function with CaseType (supports MIR, TSF, NA in addition to FAIL). * Also supports printf-style message strings to allow more dynamic content in the messages */ -bool UtAssertEx(bool Expression, UtAssert_CaseType_t CaseType, const char *File, uint32 Line, const char *MessageFormat, ...) OS_PRINTF(5,6); +bool UtAssertEx(bool Expression, UtAssert_CaseType_t CaseType, const char *File, uint32 Line, const char *MessageFormat, + ...) OS_PRINTF(5, 6); /* * Aborts the entire test @@ -284,7 +279,7 @@ void UtAssert_Abort(const char *Message); * to the current output device. This may be the console or a log file * or something else depending on what BSP is in use. */ -void UtAssert_Message(uint8 MessageType, const char *File, uint32 Line, const char *Spec, ...) OS_PRINTF(4,5); +void UtAssert_Message(uint8 MessageType, const char *File, uint32 Line, const char *Spec, ...) OS_PRINTF(4, 5); /** * The BSP single test case reporting function. @@ -303,7 +298,7 @@ void UtAssert_Message(uint8 MessageType, const char *File, uint32 Line, const ch * \param TestDescr Sequence within the current test Segment */ void UtAssert_DoReport(const char *File, uint32 LineNum, uint32 SegmentNum, uint32 SegmentSeq, uint8 MessageType, - const char *SubsysName, const char *ShortDesc); + const char *SubsysName, const char *ShortDesc); /** * The BSP overall test reporting function. @@ -318,5 +313,4 @@ void UtAssert_DoReport(const char *File, uint32 LineNum, uint32 SegmentNum, uint */ void UtAssert_DoTestSegmentReport(const char *SegmentName, const UtAssert_TestCounter_t *TestCounters); - #endif diff --git a/ut_assert/inc/utlist.h b/ut_assert/inc/utlist.h index d38f08586..be834d128 100644 --- a/ut_assert/inc/utlist.h +++ b/ut_assert/inc/utlist.h @@ -25,7 +25,7 @@ */ #ifndef _utlist_ -#define _utlist_ +#define _utlist_ /* * Includes @@ -38,33 +38,35 @@ */ /* Macros to redefine list functions to look like stack and queue functions */ -#define UtStack_Push UtList_Add -#define UtStack_Pop UtList_RemoveLast -#define UtStack_IsEmpty UtList_IsEmpty -#define UtStack_Depth UtList_Depth - -#define UtQueue_Add UtList_Add -#define UtQueue_Get UtList_RemoveFirst -#define UtQueue_Look UtList_First -#define UtQueue_Delete UtList_DeleteFirst -#define UtQueue_IsEmpty UtList_IsEmpty -#define UtQueue_Depth UtList_Depth +#define UtStack_Push UtList_Add +#define UtStack_Pop UtList_RemoveLast +#define UtStack_IsEmpty UtList_IsEmpty +#define UtStack_Depth UtList_Depth + +#define UtQueue_Add UtList_Add +#define UtQueue_Get UtList_RemoveFirst +#define UtQueue_Look UtList_First +#define UtQueue_Delete UtList_DeleteFirst +#define UtQueue_IsEmpty UtList_IsEmpty +#define UtQueue_Depth UtList_Depth /* * Type Definitions */ -typedef struct UtListNodeTag { - struct UtListNodeTag *Next; - struct UtListNodeTag *Prev; - void *Data; - uint32 DataSize; - uint32 Tag; +typedef struct UtListNodeTag +{ + struct UtListNodeTag *Next; + struct UtListNodeTag *Prev; + void * Data; + uint32 DataSize; + uint32 Tag; } UtListNode_t; - typedef struct { - UtListNode_t *Tags; - uint32 NumberOfTags; +typedef struct +{ + UtListNode_t *Tags; + uint32 NumberOfTags; } UtListHead_t; /* @@ -74,39 +76,39 @@ typedef struct UtListNodeTag { /* Dynamically allocates a new list head. A list head could also just be declared, this function is useful * if you need to dynamically allocate memory for a new list head. Note always free list heads allocated by * this function by calling UtList_Destroy. */ -UtListHead_t *UtList_Create(uint32 NumTags); +UtListHead_t *UtList_Create(uint32 NumTags); /* Frees a list head created by UtList_Create. */ -void UtList_Destroy(UtListHead_t *ListHead); +void UtList_Destroy(UtListHead_t *ListHead); /* Deletes all nodes on the list. */ -void UtList_Reset(UtListNode_t *TagHead); +void UtList_Reset(UtListNode_t *TagHead); /* Merge two lists heads together */ -void UtList_Merge(UtListNode_t *TagHead1, UtListNode_t *TagHead2); +void UtList_Merge(UtListNode_t *TagHead1, UtListNode_t *TagHead2); /* Dynamically adds a new node to the list. Nodes are always added to the end of the list. Memory is dynamically * allocated for the new node and to hold the data pointed to by Data. A Tag field is also provided to be used to * store user defined information with the node. */ -void UtList_Add(UtListHead_t *ListHead, void *Data, uint32 DataSize, uint32 Tag); +void UtList_Add(UtListHead_t *ListHead, void *Data, uint32 DataSize, uint32 Tag); /* Deletes the specified node from the list, this will screw up if you do not pass in a valid DeleteNode. I do not * verify that DeleteNode is a member of the list. */ -void UtList_DeleteNode(UtListNode_t *DeleteNode); +void UtList_DeleteNode(UtListNode_t *DeleteNode); /* Returns true if the list is empty. This is the same as (UtListHead->NumberOfEntries == 0). */ -bool UtList_IsEmpty(UtListNode_t *TagHead); +bool UtList_IsEmpty(UtListNode_t *TagHead); /* Returns the head node of a list for the given tag */ -UtListNode_t *UtList_GetHead(UtListHead_t *ListHead, uint32 Tag); +UtListNode_t *UtList_GetHead(UtListHead_t *ListHead, uint32 Tag); /* Returns the next node in the list, given the current node */ -UtListNode_t *UtList_GetNext(UtListNode_t *ListNode); +UtListNode_t *UtList_GetNext(UtListNode_t *ListNode); /* Returns the data object associated with the current node */ -void *UtList_GetObject(UtListNode_t *ListNode); +void *UtList_GetObject(UtListNode_t *ListNode); /* Check if the current node marks the end of the list */ -bool UtList_IsEnd(UtListNode_t *TagHead, UtListNode_t *ListNode); +bool UtList_IsEnd(UtListNode_t *TagHead, UtListNode_t *ListNode); #endif diff --git a/ut_assert/inc/utstubs.h b/ut_assert/inc/utstubs.h index a5b141962..429c7519b 100644 --- a/ut_assert/inc/utstubs.h +++ b/ut_assert/inc/utstubs.h @@ -36,7 +36,6 @@ * */ - #ifndef _UTSTUBS_H_ #define _UTSTUBS_H_ @@ -56,8 +55,7 @@ typedef cpuaddr UT_EntryKey_t; /** * Macro to obtain a UT_EntryKey_t value from any function name */ -#define UT_KEY(Func) ((UT_EntryKey_t)&Func) - +#define UT_KEY(Func) ((UT_EntryKey_t)&Func) /** * Maximum size of a callback hook context list @@ -65,7 +63,7 @@ typedef cpuaddr UT_EntryKey_t; * This is the maximum number of function arguments that can be passed to a hook * Note that OS_TaskCreate() has (possibly) the highest parameter count in OSAL with 7 parameters */ -#define UT_STUBCONTEXT_MAXSIZE 8 +#define UT_STUBCONTEXT_MAXSIZE 8 /** * Identifies the type of value stored in the ArgPtr field of a UT_StubContext_t object @@ -73,8 +71,8 @@ typedef cpuaddr UT_EntryKey_t; typedef enum { UT_STUBCONTEXT_ARG_TYPE_UNSPECIFIED = 0, - UT_STUBCONTEXT_ARG_TYPE_DIRECT, /**< Indicates "ArgPtr" is a direct copy of the actual parameter value */ - UT_STUBCONTEXT_ARG_TYPE_INDIRECT /**< Indicates "ArgPtr" is a pointer to the argument value on the stack */ + UT_STUBCONTEXT_ARG_TYPE_DIRECT, /**< Indicates "ArgPtr" is a direct copy of the actual parameter value */ + UT_STUBCONTEXT_ARG_TYPE_INDIRECT /**< Indicates "ArgPtr" is a pointer to the argument value on the stack */ } UT_StubContext_Arg_Type_t; /** @@ -83,8 +81,8 @@ typedef enum typedef struct { UT_StubContext_Arg_Type_t Type; - const char *Name; - size_t Size; + const char * Name; + size_t Size; } UT_StubArgMetaData_t; /** @@ -92,8 +90,8 @@ typedef struct */ typedef struct { - uint32 ArgCount; - const void *ArgPtr[UT_STUBCONTEXT_MAXSIZE]; + uint32 ArgCount; + const void * ArgPtr[UT_STUBCONTEXT_MAXSIZE]; UT_StubArgMetaData_t Meta[UT_STUBCONTEXT_MAXSIZE]; } UT_StubContext_t; @@ -101,8 +99,8 @@ typedef struct * Function pointer for user-specified hooks/stub callbacks */ typedef int32 (*UT_HookFunc_t)(void *UserObj, int32 StubRetcode, uint32 CallCount, const UT_StubContext_t *Context); -typedef int32 (*UT_VaHookFunc_t)(void *UserObj, int32 StubRetcode, uint32 CallCount, const UT_StubContext_t *Context, va_list va); - +typedef int32 (*UT_VaHookFunc_t)(void *UserObj, int32 StubRetcode, uint32 CallCount, const UT_StubContext_t *Context, + va_list va); /************************************************************** * Functions for use within test code implementation @@ -226,7 +224,7 @@ void UT_SetHookFunction(UT_EntryKey_t FuncKey, UT_HookFunc_t HookFunc, void *Use * contents of the arguments but the types of arguments aren't known. * * However, some systems have limited support for va_list, so this might not be - * available on those systems. Tests should use the generic (non-va) hook function + * available on those systems. Tests should use the generic (non-va) hook function * unless the arguments are truly necessary. * * \param FuncKey The stub function to add the hook to. @@ -256,8 +254,6 @@ bool UT_GetStubRetcodeAndCount(UT_EntryKey_t FuncKey, int32 *Retcode, int32 *Cou */ uint32 UT_GetStubCount(UT_EntryKey_t FuncKey); - - /************************************************************** * Functions for use within stub function implementation **************************************************************/ @@ -348,8 +344,8 @@ uint32 UT_Stub_CopyFromLocal(UT_EntryKey_t FuncKey, const void *LocalBuffer, uin * \param FuncKey The stub function to entry to use. * \param Parameter Arbitrary parameter to pass. */ -#define UT_Stub_RegisterContext(FuncKey, Parameter) \ - UT_Stub_RegisterContextWithMetaData(FuncKey, #Parameter, UT_STUBCONTEXT_ARG_TYPE_UNSPECIFIED, Parameter, 0) +#define UT_Stub_RegisterContext(FuncKey, Parameter) \ + UT_Stub_RegisterContextWithMetaData(FuncKey, #Parameter, UT_STUBCONTEXT_ARG_TYPE_UNSPECIFIED, Parameter, 0) /** * Registers a single value argument into the context for the hook callback @@ -357,8 +353,9 @@ uint32 UT_Stub_CopyFromLocal(UT_EntryKey_t FuncKey, const void *LocalBuffer, uin * A pointer to the stack value is actually stored into the context, * which can be dereferenced in the hook. */ -#define UT_Stub_RegisterContextGenericArg(FuncKey, Parameter) \ - UT_Stub_RegisterContextWithMetaData(FuncKey, #Parameter, UT_STUBCONTEXT_ARG_TYPE_INDIRECT, &Parameter, sizeof(Parameter)) +#define UT_Stub_RegisterContextGenericArg(FuncKey, Parameter) \ + UT_Stub_RegisterContextWithMetaData(FuncKey, #Parameter, UT_STUBCONTEXT_ARG_TYPE_INDIRECT, &Parameter, \ + sizeof(Parameter)) /** * Registers a single context element for the hook callback @@ -374,8 +371,8 @@ uint32 UT_Stub_CopyFromLocal(UT_EntryKey_t FuncKey, const void *LocalBuffer, uin * \param ParamPtr Pointer to argument data * \param ParamSize The size of the object pointed to, or zero if not known */ -void UT_Stub_RegisterContextWithMetaData(UT_EntryKey_t FuncKey, const char *Name, - UT_StubContext_Arg_Type_t ParamType, const void *ParamPtr, size_t ParamSize); +void UT_Stub_RegisterContextWithMetaData(UT_EntryKey_t FuncKey, const char *Name, UT_StubContext_Arg_Type_t ParamType, + const void *ParamPtr, size_t ParamSize); /** * Retrieve a context argument value by name @@ -395,7 +392,7 @@ void UT_Stub_RegisterContextWithMetaData(UT_EntryKey_t FuncKey, const char *Name * \param ExpectedSize The size of the expected object type * \returns Pointer to buffer containing the value. */ -const void* UT_Hook_GetArgPtr(const UT_StubContext_t *ContextPtr, const char *Name, size_t ExpectedTypeSize); +const void *UT_Hook_GetArgPtr(const UT_StubContext_t *ContextPtr, const char *Name, size_t ExpectedTypeSize); /** * Macro which retrieves a value argument by name. @@ -404,8 +401,8 @@ const void* UT_Hook_GetArgPtr(const UT_StubContext_t *ContextPtr, const char *Na * associated with an argument as the correct/expected type. * */ -#define UT_Hook_GetArgValueByName(ContextPtr,Name,Type) \ - (*(Type const *)UT_Hook_GetArgPtr(ContextPtr,Name,sizeof(Type))) +#define UT_Hook_GetArgValueByName(ContextPtr, Name, Type) \ + (*(Type const *)UT_Hook_GetArgPtr(ContextPtr, Name, sizeof(Type))) /** * Default implementation for a stub function that takes a va_list of arguments. @@ -421,7 +418,6 @@ const void* UT_Hook_GetArgPtr(const UT_StubContext_t *ContextPtr, const char *Na */ int32 UT_DefaultStubImplWithArgs(const char *FunctionName, UT_EntryKey_t FuncKey, int32 DefaultRc, va_list va); - /** * Default implementation for a stub function that should be useful for most cases. * @@ -434,7 +430,6 @@ int32 UT_DefaultStubImplWithArgs(const char *FunctionName, UT_EntryKey_t FuncKey */ int32 UT_DefaultStubImpl(const char *FunctionName, UT_EntryKey_t FuncKey, int32 DefaultRc, ...); - /** * Macro to simplify usage of the UT_DefaultStubImpl() function * @@ -445,7 +440,7 @@ int32 UT_DefaultStubImpl(const char *FunctionName, UT_EntryKey_t FuncKey, int32 * This version should be used on stubs that take no arguments * and are expected to return 0 in the nominal case */ -#define UT_DEFAULT_IMPL(FuncName) UT_DefaultStubImpl(#FuncName, UT_KEY(FuncName), 0) +#define UT_DEFAULT_IMPL(FuncName) UT_DefaultStubImpl(#FuncName, UT_KEY(FuncName), 0) /** * Macro to simplify usage of the UT_DefaultStubImpl() function @@ -457,7 +452,7 @@ int32 UT_DefaultStubImpl(const char *FunctionName, UT_EntryKey_t FuncKey, int32 * This version should be used on stubs that take no arguments * and are expected to return nonzero in the nominal case */ -#define UT_DEFAULT_IMPL_RC(FuncName, Rc) UT_DefaultStubImpl(#FuncName, UT_KEY(FuncName), Rc) +#define UT_DEFAULT_IMPL_RC(FuncName, Rc) UT_DefaultStubImpl(#FuncName, UT_KEY(FuncName), Rc) /** * Macro to simplify usage of the UT_DefaultStubImpl() function @@ -469,8 +464,7 @@ int32 UT_DefaultStubImpl(const char *FunctionName, UT_EntryKey_t FuncKey, int32 * This version should be used on stubs that do take arguments * and are expected to return 0 in the nominal case */ -#define UT_DEFAULT_IMPL_ARGS(FuncName,...) UT_DefaultStubImpl(#FuncName, UT_KEY(FuncName), 0, __VA_ARGS__) - +#define UT_DEFAULT_IMPL_ARGS(FuncName, ...) UT_DefaultStubImpl(#FuncName, UT_KEY(FuncName), 0, __VA_ARGS__) /** * Macro to simplify usage of the UT_DefaultStubImpl() function @@ -479,14 +473,14 @@ int32 UT_DefaultStubImpl(const char *FunctionName, UT_EntryKey_t FuncKey, int32 * where the default items of deferred return codes / force fails are * checked first, then additional functionality is added. */ -#define UT_DEFAULT_IMPL_RC_ARGS(FuncName,Rc,...) UT_DefaultStubImpl(#FuncName, UT_KEY(FuncName), Rc, __VA_ARGS__) +#define UT_DEFAULT_IMPL_RC_ARGS(FuncName, Rc, ...) UT_DefaultStubImpl(#FuncName, UT_KEY(FuncName), Rc, __VA_ARGS__) /** * Macro to simplify usage of the UT_DefaultStubImplWithArgs() function * * This function accepts a list of arguments as a va_list */ -#define UT_DEFAULT_IMPL_VARARGS(FuncName,va) UT_DefaultStubImplWithArgs(#FuncName, UT_KEY(FuncName), 0, va) +#define UT_DEFAULT_IMPL_VARARGS(FuncName, va) UT_DefaultStubImplWithArgs(#FuncName, UT_KEY(FuncName), 0, va) /** * Macro to simplify usage of the UT_DefaultStubImplWithArgs() function @@ -494,8 +488,7 @@ int32 UT_DefaultStubImpl(const char *FunctionName, UT_EntryKey_t FuncKey, int32 * This function accepts a list of arguments as a va_list and * a nonzero default return code */ -#define UT_DEFAULT_IMPL_RC_VARARGS(FuncName,Rc,va) UT_DefaultStubImplWithArgs(#FuncName, UT_KEY(FuncName), Rc, va) - +#define UT_DEFAULT_IMPL_RC_VARARGS(FuncName, Rc, va) UT_DefaultStubImplWithArgs(#FuncName, UT_KEY(FuncName), Rc, va) /** * Macro to simplify usage of the UT_DefaultStubImpl() function @@ -503,8 +496,10 @@ int32 UT_DefaultStubImpl(const char *FunctionName, UT_EntryKey_t FuncKey, int32 * The UT_DEFAULT_STUB can be used as a complete stub implementation * when only deferred return codes / force fails are in use. */ -#define UT_DEFAULT_STUB(FuncName, Args) int32 FuncName Args { return UT_DEFAULT_IMPL(FuncName); } - - +#define UT_DEFAULT_STUB(FuncName, Args) \ + int32 FuncName Args \ + { \ + return UT_DEFAULT_IMPL(FuncName); \ + } #endif /* _UTSTUBS_H_ */ diff --git a/ut_assert/inc/uttest.h b/ut_assert/inc/uttest.h index 143c367b6..fe56cd7fc 100644 --- a/ut_assert/inc/uttest.h +++ b/ut_assert/inc/uttest.h @@ -23,14 +23,14 @@ * * Purpose: This file contains functions to implement a standard way to execute unit tests. * - * Design Notes: + * Design Notes: * By default the only output that is printed to the console is assert failures - * and a summary of the test results after all tests have executed. To enable additional + * and a summary of the test results after all tests have executed. To enable additional * test output define the macro UT_VERBOSE. */ #ifndef _uttest_ -#define _uttest_ +#define _uttest_ #include @@ -48,7 +48,7 @@ * \param Teardown Cleanup function, called after the test function * \param TestName Name of test for logging purposes */ -void UtTest_Add(void (*Test)(void), void (*Setup)(void), void (*Teardown)(void), const char *TestName); +void UtTest_Add(void (*Test)(void), void (*Setup)(void), void (*Teardown)(void), const char *TestName); /** * \brief Registers a setup function @@ -72,7 +72,6 @@ void UtTest_AddSetup(void (*Setup)(void), const char *SequenceName); */ void UtTest_AddTeardown(void (*Teardown)(void), const char *SequenceName); - /** * \brief Early initialization function * @@ -81,7 +80,6 @@ void UtTest_AddTeardown(void (*Teardown)(void), const char *SequenceName); */ void UtTest_EarlyInit(void); - /** * \brief Execute all registered tests * @@ -98,4 +96,3 @@ void UtTest_Run(void); void UtTest_Setup(void); #endif - diff --git a/ut_assert/inc/uttools.h b/ut_assert/inc/uttools.h index 49c03da8c..ecdaf9d6b 100644 --- a/ut_assert/inc/uttools.h +++ b/ut_assert/inc/uttools.h @@ -25,7 +25,7 @@ */ #ifndef _uttools_ -#define _uttools_ +#define _uttools_ /* * Includes @@ -40,42 +40,38 @@ /* Copies a region of memory to a binary file. This file can be reloaded by calling UtBinFile2Mem or it can be * used to verify test results by calling UtMem2BinFileCmp. */ -bool UtMem2BinFile(const void *Memory, const char *Filename, uint32 Length); +bool UtMem2BinFile(const void *Memory, const char *Filename, uint32 Length); /* Copies a binary file to a region of memory. */ -bool UtBinFile2Mem(void *Memory, const char *Filename, uint32 Length); +bool UtBinFile2Mem(void *Memory, const char *Filename, uint32 Length); /* Copies a region of memory to a hex file */ -bool UtMem2HexFile(const void *Memory, const char *Filename, uint32 Length); +bool UtMem2HexFile(const void *Memory, const char *Filename, uint32 Length); /* Fills a region of memory with a byte count pattern. */ -void UtMemFill(void *Memory, uint32 Length); +void UtMemFill(void *Memory, uint32 Length); /* Just like the standard sprintf except it returns a pointer to the result string. The result string * cannot be larger than 256 bytes. */ -char *UtSprintf(const char *Spec, ...); +char *UtSprintf(const char *Spec, ...); /* Calls UtPrintf to print a range of memory as hex bytes. */ -void UtPrintx(const void *Memory, uint32 Length); +void UtPrintx(const void *Memory, uint32 Length); /* Compares a region of memory to a static pattern and determines if they are equal. Note: Use UtMemSet to * fill a region of memory with a static pattern. */ -bool UtMemCmpValue(const void *Memory, uint8 Value, uint32 Length); +bool UtMemCmpValue(const void *Memory, uint8 Value, uint32 Length); /* Compares a region of memory to a byte count pattern and determines if they are equal. Note: Use UtMemFill to * fill a region of memory with a byte count pattern. */ -bool UtMemCmpCount(const void *Memory, uint32 Length); +bool UtMemCmpCount(const void *Memory, uint32 Length); /* Compares a region of memory with the contents of a binary file and determines if they are equal. Note: Use * UtMem2BinFile to copy a region of memory to a binary file. */ -bool UtMem2BinFileCmp(const void *Memory, const char *Filename); - +bool UtMem2BinFileCmp(const void *Memory, const char *Filename); /* Macros to implement simple printf-like functions for unit testing */ -#define UtPrintf(...) UtAssert_Message(UTASSERT_CASETYPE_INFO, __FILE__, __LINE__, __VA_ARGS__) -#define UtDebug(...) UtAssert_Message(UTASSERT_CASETYPE_DEBUG, __FILE__, __LINE__, __VA_ARGS__) - - +#define UtPrintf(...) UtAssert_Message(UTASSERT_CASETYPE_INFO, __FILE__, __LINE__, __VA_ARGS__) +#define UtDebug(...) UtAssert_Message(UTASSERT_CASETYPE_DEBUG, __FILE__, __LINE__, __VA_ARGS__) #endif - diff --git a/ut_assert/src/utassert.c b/ut_assert/src/utassert.c index 954ceaf1f..677614cbf 100644 --- a/ut_assert/src/utassert.c +++ b/ut_assert/src/utassert.c @@ -39,17 +39,17 @@ * Local Data */ -UtAssert_CaseType_t DefaultContext = UTASSERT_CASETYPE_FAILURE; -UtAssert_TestCounter_t UT_SegmentCounters = { 0 }; -UtAssert_TestCounter_t UT_TotalCounters = { 0 }; -static char CurrentSegment[64]; +UtAssert_CaseType_t DefaultContext = UTASSERT_CASETYPE_FAILURE; +UtAssert_TestCounter_t UT_SegmentCounters = {0}; +UtAssert_TestCounter_t UT_TotalCounters = {0}; +static char CurrentSegment[64]; /* * Function Definitions */ void UtAssert_DoReport(const char *File, uint32 LineNum, uint32 SegmentNum, uint32 TestSeq, uint8 MessageType, - const char *SubsysName, const char *ShortDesc) + const char *SubsysName, const char *ShortDesc) { uint32 FileLen; const char *BasePtr; @@ -90,15 +90,14 @@ void UtAssert_DoTestSegmentReport(const char *SegmentName, const UtAssert_TestCo UT_BSP_DoText(UTASSERT_CASETYPE_END, ReportBuffer); } - uint32 UtAssert_GetPassCount(void) { - return(UT_TotalCounters.CaseCount[UTASSERT_CASETYPE_PASS]); + return (UT_TotalCounters.CaseCount[UTASSERT_CASETYPE_PASS]); } uint32 UtAssert_GetFailCount(void) { - return(UT_TotalCounters.CaseCount[UTASSERT_CASETYPE_FAILURE]); + return (UT_TotalCounters.CaseCount[UTASSERT_CASETYPE_FAILURE]); } const UtAssert_TestCounter_t *UtAssert_GetCounters(void) @@ -108,7 +107,7 @@ const UtAssert_TestCounter_t *UtAssert_GetCounters(void) void UtAssert_BeginTest(const char *SegmentName) { - memset(&UT_SegmentCounters, 0, sizeof (UT_SegmentCounters)); + memset(&UT_SegmentCounters, 0, sizeof(UT_SegmentCounters)); strncpy(CurrentSegment, SegmentName, sizeof(CurrentSegment) - 1); CurrentSegment[sizeof(CurrentSegment) - 1] = 0; UT_BSP_StartTestSegment(1 + UT_TotalCounters.TestSegmentCount, SegmentName); @@ -126,7 +125,7 @@ void UtAssert_EndTest(void) if (UT_SegmentCounters.TotalTestCases > 0) { ++UT_TotalCounters.TestSegmentCount; - UT_SegmentCounters.TestSegmentCount = UT_TotalCounters.TestSegmentCount; + UT_SegmentCounters.TestSegmentCount = UT_TotalCounters.TestSegmentCount; UT_TotalCounters.TotalTestCases += UT_SegmentCounters.TotalTestCases; for (Ct = 0; Ct < UTASSERT_CASETYPE_MAX; ++Ct) { @@ -139,7 +138,7 @@ void UtAssert_EndTest(void) UT_BSP_DoText(UTASSERT_CASETYPE_END, "No test cases\n"); } - memset(&UT_SegmentCounters, 0, sizeof (UT_SegmentCounters)); + memset(&UT_SegmentCounters, 0, sizeof(UT_SegmentCounters)); } void UtAssert_SetContext(UtAssert_CaseType_t Context) @@ -157,10 +156,11 @@ bool UtAssert(bool Expression, const char *Description, const char *File, uint32 return UtAssertEx(Expression, UtAssert_GetContext(), File, Line, "%s", Description); } -bool UtAssertEx(bool Expression, UtAssert_CaseType_t CaseType, const char *File, uint32 Line, const char *MessageFormat, ...) +bool UtAssertEx(bool Expression, UtAssert_CaseType_t CaseType, const char *File, uint32 Line, const char *MessageFormat, + ...) { va_list va; - char FinalMessage[256]; + char FinalMessage[256]; ++UT_SegmentCounters.TotalTestCases; @@ -178,7 +178,8 @@ bool UtAssertEx(bool Expression, UtAssert_CaseType_t CaseType, const char *File, vsnprintf(FinalMessage, sizeof(FinalMessage), MessageFormat, va); va_end(va); - UtAssert_DoReport(File, Line, 1 + UT_TotalCounters.TestSegmentCount, UT_SegmentCounters.TotalTestCases, CaseType, CurrentSegment, FinalMessage); + UtAssert_DoReport(File, Line, 1 + UT_TotalCounters.TestSegmentCount, UT_SegmentCounters.TotalTestCases, CaseType, + CurrentSegment, FinalMessage); return Expression; } @@ -190,10 +191,10 @@ void UtAssert_Abort(const char *Message) void UtAssert_Message(uint8 MessageType, const char *File, uint32 Line, const char *Spec, ...) { - va_list va; - char FinalMessage[256]; + va_list va; + char FinalMessage[256]; const char *BaseName; - size_t MsgLen; + size_t MsgLen; if (File != NULL) { diff --git a/ut_assert/src/utbsp.c b/ut_assert/src/utbsp.c index 1569c1fa2..5e8b7998e 100644 --- a/ut_assert/src/utbsp.c +++ b/ut_assert/src/utbsp.c @@ -211,8 +211,7 @@ void UT_BSP_EndTest(const UtAssert_TestCounter_t *TestCounters) OS_BSP_ConsoleOutput_Impl(Message, strlen(Message)); if ((TestCounters->CaseCount[UTASSERT_CASETYPE_FAILURE] > 0) || - (TestCounters->CaseCount[UTASSERT_CASETYPE_TSF] > 0) || - (TestCounters->CaseCount[UTASSERT_CASETYPE_TTF] > 0)) + (TestCounters->CaseCount[UTASSERT_CASETYPE_TSF] > 0) || (TestCounters->CaseCount[UTASSERT_CASETYPE_TTF] > 0)) { OS_BSP_SetExitCode(OS_ERROR); } @@ -253,6 +252,3 @@ void OS_Application_Startup(void) UtTest_Setup(); UtAssert_EndTest(); } - - - diff --git a/ut_assert/src/utglobal.h b/ut_assert/src/utglobal.h index dc8cbf4f3..dcc569781 100644 --- a/ut_assert/src/utglobal.h +++ b/ut_assert/src/utglobal.h @@ -44,19 +44,19 @@ typedef struct { - void (*Test)(void); - void (*Setup)(void); - void (*Teardown)(void); + void (*Test)(void); + void (*Setup)(void); + void (*Teardown)(void); /* Note - the name entry should be long enough to support a GroupName.TestName pattern, * hence why it uses double the OS_MAX_API_NAME length */ - char TestName[OS_MAX_API_NAME*2]; + char TestName[OS_MAX_API_NAME * 2]; } UtTestDataBaseEntry_t; typedef struct { - UtListHead_t *DataBasePtr; - uint32 ExecutedCount; + UtListHead_t *DataBasePtr; + uint32 ExecutedCount; } UtAssert_Global_t; /* @@ -65,4 +65,3 @@ typedef struct extern UtAssert_Global_t UtAssert_Global; #endif /* INCLUDE_UTASSERT_GLOBAL_H_ */ - diff --git a/ut_assert/src/utlist.c b/ut_assert/src/utlist.c index 328503f37..a04376270 100644 --- a/ut_assert/src/utlist.c +++ b/ut_assert/src/utlist.c @@ -45,22 +45,22 @@ UtListHead_t *UtList_Create(uint32 NumTags) UtListNode_t Tags[]; }; struct ListAllocator *NewList; - UtListNode_t *TagHead; - size_t ActualSize; - uint32 i; + UtListNode_t * TagHead; + size_t ActualSize; + uint32 i; ActualSize = sizeof(struct ListAllocator) + (sizeof(UtListNode_t) * NumTags); - NewList = (struct ListAllocator *)malloc(ActualSize); + NewList = (struct ListAllocator *)malloc(ActualSize); memset(NewList, 0, ActualSize); - NewList->Head.Tags = NewList->Tags; + NewList->Head.Tags = NewList->Tags; NewList->Head.NumberOfTags = NumTags; - for (i=0; i < NumTags; ++i) + for (i = 0; i < NumTags; ++i) { - TagHead = &NewList->Head.Tags[i]; - TagHead->Tag = i; + TagHead = &NewList->Head.Tags[i]; + TagHead->Tag = i; TagHead->Next = TagHead; TagHead->Prev = TagHead; } @@ -72,7 +72,7 @@ void UtList_Destroy(UtListHead_t *ListHead) { uint32 i; - for (i=0; i < ListHead->NumberOfTags; ++i) + for (i = 0; i < ListHead->NumberOfTags; ++i) { UtList_Reset(&ListHead->Tags[i]); } @@ -92,24 +92,24 @@ void UtList_Merge(UtListNode_t *TagHead1, UtListNode_t *TagHead2) UtListNode_t *Tail1 = TagHead1->Prev; UtListNode_t *Tail2 = TagHead2->Prev; - Tail1->Next = TagHead2; - Tail2->Next = TagHead1; + Tail1->Next = TagHead2; + Tail2->Next = TagHead1; TagHead1->Prev = Tail2; TagHead2->Prev = Tail1; } void UtList_Insert_After(UtListNode_t *ExistingNode, UtListNode_t *NewNode) { - NewNode->Next = ExistingNode->Next; - NewNode->Prev = ExistingNode; + NewNode->Next = ExistingNode->Next; + NewNode->Prev = ExistingNode; NewNode->Prev->Next = NewNode; NewNode->Next->Prev = NewNode; } void UtList_Insert_Before(UtListNode_t *ExistingNode, UtListNode_t *NewNode) { - NewNode->Next = ExistingNode; - NewNode->Prev = ExistingNode->Prev; + NewNode->Next = ExistingNode; + NewNode->Prev = ExistingNode->Prev; NewNode->Prev->Next = NewNode; NewNode->Next->Prev = NewNode; } @@ -118,8 +118,8 @@ void UtList_Extract(UtListNode_t *ExistingNode) { ExistingNode->Next->Prev = ExistingNode->Prev; ExistingNode->Prev->Next = ExistingNode->Next; - ExistingNode->Next = ExistingNode; - ExistingNode->Prev = ExistingNode; + ExistingNode->Next = ExistingNode; + ExistingNode->Prev = ExistingNode; } UtListNode_t *UtList_NewNode(void *Data, uint32 DataSize) @@ -128,13 +128,13 @@ UtListNode_t *UtList_NewNode(void *Data, uint32 DataSize) { UtListNode_t Node; double AlignDbl; - void* AlignPtr; + void * AlignPtr; long AlignLong; - } *AllocNode; + } * AllocNode; AllocNode = malloc(sizeof(union NodeAllocator) + DataSize); memset(AllocNode, 0, sizeof(union NodeAllocator)); - AllocNode->Node.Data = &AllocNode[1]; + AllocNode->Node.Data = &AllocNode[1]; AllocNode->Node.DataSize = DataSize; memcpy(AllocNode->Node.Data, Data, DataSize); @@ -144,7 +144,6 @@ UtListNode_t *UtList_NewNode(void *Data, uint32 DataSize) return &AllocNode->Node; } - void UtList_Add(UtListHead_t *ListHead, void *Data, uint32 DataSize, uint32 Tag) { UtListNode_t *TagHead; @@ -153,7 +152,7 @@ void UtList_Add(UtListHead_t *ListHead, void *Data, uint32 DataSize, uint32 Tag) TagHead = UtList_GetHead(ListHead, Tag); if (TagHead != NULL) { - NewNode = UtList_NewNode(Data, DataSize); + NewNode = UtList_NewNode(Data, DataSize); NewNode->Tag = Tag; UtList_Insert_Before(TagHead, NewNode); } @@ -172,7 +171,7 @@ void UtList_DeleteNode(UtListNode_t *DeleteNode) bool UtList_IsEmpty(UtListNode_t *TagHead) { - return(TagHead->Next == TagHead); + return (TagHead->Next == TagHead); } UtListNode_t *UtList_GetHead(UtListHead_t *ListHead, uint32 Tag) @@ -196,6 +195,5 @@ void *UtList_GetObject(UtListNode_t *ListNode) bool UtList_IsEnd(UtListNode_t *TagHead, UtListNode_t *ListNode) { - return(TagHead == ListNode); + return (TagHead == ListNode); } - diff --git a/ut_assert/src/utstubs.c b/ut_assert/src/utstubs.c index 6c0a8ab87..79693e2f6 100644 --- a/ut_assert/src/utstubs.c +++ b/ut_assert/src/utstubs.c @@ -44,56 +44,56 @@ #include "utstubs.h" #include "utbsp.h" -#define UT_MAX_FUNC_STUBS 200 -#define UT_APPNAME_MAX_LEN 80 -#define UT_SUBSYS_MAX_LEN 5 -#define UT_MODEFLAG_ALLOC_BUF 0x1U +#define UT_MAX_FUNC_STUBS 200 +#define UT_APPNAME_MAX_LEN 80 +#define UT_SUBSYS_MAX_LEN 5 +#define UT_MODEFLAG_ALLOC_BUF 0x1U typedef enum { - UT_ENTRYTYPE_UNUSED, /**< Unused/available table entries */ - UT_ENTRYTYPE_COUNTER, /**< Records a usage count plus most recent return code */ - UT_ENTRYTYPE_FORCE_FAIL, /**< Always return a designated code from stub */ - UT_ENTRYTYPE_DEFERRED_RC, /**< Return a designated code from stub after "N" calls */ - UT_ENTRYTYPE_DATA_BUFFER, /**< Storage for data buffers to simulate read/write or queue ops */ - UT_ENTRYTYPE_CALLBACK_HOOK, /**< Pointer to a custom callback/hook function */ - UT_ENTRYTYPE_CALLBACK_CONTEXT, /**< Context data for callback/hook function */ - UT_ENTRYTYPE_CALL_ONCE, /**< Records a "call once" directive */ + UT_ENTRYTYPE_UNUSED, /**< Unused/available table entries */ + UT_ENTRYTYPE_COUNTER, /**< Records a usage count plus most recent return code */ + UT_ENTRYTYPE_FORCE_FAIL, /**< Always return a designated code from stub */ + UT_ENTRYTYPE_DEFERRED_RC, /**< Return a designated code from stub after "N" calls */ + UT_ENTRYTYPE_DATA_BUFFER, /**< Storage for data buffers to simulate read/write or queue ops */ + UT_ENTRYTYPE_CALLBACK_HOOK, /**< Pointer to a custom callback/hook function */ + UT_ENTRYTYPE_CALLBACK_CONTEXT, /**< Context data for callback/hook function */ + UT_ENTRYTYPE_CALL_ONCE, /**< Records a "call once" directive */ } UT_EntryType_t; typedef struct { - uint32 Count; - int32 Value; + uint32 Count; + int32 Value; } UT_RetcodeEntry_t; typedef struct { - uint32 Position; - uint32 TotalSize; - uint8 *BasePtr; + uint32 Position; + uint32 TotalSize; + uint8 *BasePtr; } UT_BufferEntry_t; typedef union { - void *Addr; + void * Addr; UT_HookFunc_t Simple; UT_VaHookFunc_t Va; } UT_HookFuncPtr_t; typedef struct { - UT_HookFuncPtr_t Ptr; - void *CallbackArg; - bool IsVarg; + UT_HookFuncPtr_t Ptr; + void * CallbackArg; + bool IsVarg; } UT_CallbackEntry_t; typedef union { - UT_RetcodeEntry_t Rc; - UT_BufferEntry_t Buff; - UT_CallbackEntry_t Cb; - UT_StubContext_t Context; + UT_RetcodeEntry_t Rc; + UT_BufferEntry_t Buff; + UT_CallbackEntry_t Cb; + UT_StubContext_t Context; } UT_EntryData_t; /* @@ -101,14 +101,14 @@ typedef union */ typedef struct { - UT_EntryType_t EntryType; - UT_EntryKey_t FuncKey; - uint32 ModeFlags; - UT_EntryData_t Data; + UT_EntryType_t EntryType; + UT_EntryKey_t FuncKey; + uint32 ModeFlags; + UT_EntryData_t Data; } UT_StubTableEntry_t; -static UT_StubTableEntry_t UT_StubTable[UT_MAX_FUNC_STUBS] = {{ 0 }}; -static uint32 UT_MaxStubSearchLen = 0; +static UT_StubTableEntry_t UT_StubTable[UT_MAX_FUNC_STUBS] = {{0}}; +static uint32 UT_MaxStubSearchLen = 0; /** * Helper function to clear an entry in the stub table. @@ -118,9 +118,8 @@ static uint32 UT_MaxStubSearchLen = 0; static void UT_ClearStubEntry(UT_StubTableEntry_t *StubPtr) { /* Be sure to call free() on any malloc'ed buffers before clearing */ - if (StubPtr->EntryType == UT_ENTRYTYPE_DATA_BUFFER && - StubPtr->Data.Buff.BasePtr != NULL && - (StubPtr->ModeFlags & UT_MODEFLAG_ALLOC_BUF) != 0) + if (StubPtr->EntryType == UT_ENTRYTYPE_DATA_BUFFER && StubPtr->Data.Buff.BasePtr != NULL && + (StubPtr->ModeFlags & UT_MODEFLAG_ALLOC_BUF) != 0) { free(StubPtr->Data.Buff.BasePtr); } @@ -133,26 +132,26 @@ static void UT_ClearStubEntry(UT_StubTableEntry_t *StubPtr) static UT_StubTableEntry_t *UT_GetStubEntry(UT_EntryKey_t FuncKey, UT_EntryType_t TestMode) { - UT_StubTableEntry_t *StubPtr = NULL; - uint32 Idx = FuncKey % (UT_MAX_FUNC_STUBS-1); /* hash the key to determine the start point */ - uint32 SearchLen = 0; - uint32 SearchLimit; - UT_EntryKey_t SearchKey; + UT_StubTableEntry_t *StubPtr = NULL; + uint32 Idx = FuncKey % (UT_MAX_FUNC_STUBS - 1); /* hash the key to determine the start point */ + uint32 SearchLen = 0; + uint32 SearchLimit; + UT_EntryKey_t SearchKey; /* If searching for an unused entry, look through the entire table. * Otherwise bound the search */ if (TestMode == UT_ENTRYTYPE_UNUSED) { SearchLimit = UT_MAX_FUNC_STUBS; - SearchKey = 0; + SearchKey = 0; } else { SearchLimit = UT_MaxStubSearchLen; - SearchKey = FuncKey; + SearchKey = FuncKey; } - while(1) + while (1) { if (SearchLen >= SearchLimit) { @@ -187,10 +186,10 @@ static UT_StubTableEntry_t *UT_GetStubEntry(UT_EntryKey_t FuncKey, UT_EntryType_ void UT_ResetState(UT_EntryKey_t FuncKey) { UT_StubTableEntry_t *StubPtr; - int32 i; + int32 i; StubPtr = UT_StubTable; - for (i=0; i < UT_MAX_FUNC_STUBS; ++i) + for (i = 0; i < UT_MAX_FUNC_STUBS; ++i) { if (FuncKey == 0 || StubPtr->FuncKey == FuncKey) { @@ -208,8 +207,8 @@ void UT_Stub_CallOnce(void (*Func)(void)) { UT_StubTableEntry_t *StubPtr; UT_StubTableEntry_t *OnceEnt; - UT_EntryKey_t FuncKey; - int32 i; + UT_EntryKey_t FuncKey; + int32 i; if (Func == NULL) { @@ -219,14 +218,13 @@ void UT_Stub_CallOnce(void (*Func)(void)) FuncKey = (UT_EntryKey_t)Func; OnceEnt = NULL; StubPtr = UT_StubTable; - for (i=0; i < UT_MAX_FUNC_STUBS; ++i) + for (i = 0; i < UT_MAX_FUNC_STUBS; ++i) { if (StubPtr->EntryType == UT_ENTRYTYPE_UNUSED && OnceEnt == NULL) { OnceEnt = StubPtr; } - else if (StubPtr->EntryType == UT_ENTRYTYPE_CALL_ONCE && - StubPtr->FuncKey == FuncKey) + else if (StubPtr->EntryType == UT_ENTRYTYPE_CALL_ONCE && StubPtr->FuncKey == FuncKey) { OnceEnt = StubPtr; break; @@ -242,7 +240,7 @@ void UT_Stub_CallOnce(void (*Func)(void)) else if (OnceEnt->EntryType == UT_ENTRYTYPE_UNUSED) { OnceEnt->EntryType = UT_ENTRYTYPE_CALL_ONCE; - OnceEnt->FuncKey = FuncKey; + OnceEnt->FuncKey = FuncKey; Func(); } @@ -262,8 +260,8 @@ void UT_SetDeferredRetcode(UT_EntryKey_t FuncKey, int32 Count, int32 Retcode) } else { - StubPtr->FuncKey = FuncKey; - StubPtr->EntryType = UT_ENTRYTYPE_DEFERRED_RC; + StubPtr->FuncKey = FuncKey; + StubPtr->EntryType = UT_ENTRYTYPE_DEFERRED_RC; StubPtr->Data.Rc.Count = Count; StubPtr->Data.Rc.Value = Retcode; } @@ -287,7 +285,7 @@ void UT_ClearDeferredRetcode(UT_EntryKey_t FuncKey) bool UT_Stub_CheckDeferredRetcode(UT_EntryKey_t FuncKey, int32 *Retcode) { - bool Result = false; + bool Result = false; UT_StubTableEntry_t *StubPtr; StubPtr = UT_GetStubEntry(FuncKey, UT_ENTRYTYPE_DEFERRED_RC); @@ -299,7 +297,7 @@ bool UT_Stub_CheckDeferredRetcode(UT_EntryKey_t FuncKey, int32 *Retcode) } if (StubPtr->Data.Rc.Count == 0) { - Result = true; + Result = true; *Retcode = StubPtr->Data.Rc.Value; /* Once the count has reached zero, void the entry */ @@ -327,8 +325,8 @@ void UT_SetForceFail(UT_EntryKey_t FuncKey, int32 Value) if (Rc != NULL) { - Rc->FuncKey = FuncKey; - Rc->EntryType = UT_ENTRYTYPE_FORCE_FAIL; + Rc->FuncKey = FuncKey; + Rc->EntryType = UT_ENTRYTYPE_FORCE_FAIL; Rc->Data.Rc.Value = Value; } else @@ -351,14 +349,14 @@ void UT_ClearForceFail(UT_EntryKey_t FuncKey) bool UT_GetStubRetcodeAndCount(UT_EntryKey_t FuncKey, int32 *Retcode, int32 *Count) { UT_StubTableEntry_t *StubPtr; - bool Result; + bool Result; StubPtr = UT_GetStubEntry(FuncKey, UT_ENTRYTYPE_COUNTER); if (StubPtr != NULL) { - *Count = StubPtr->Data.Rc.Count; + *Count = StubPtr->Data.Rc.Count; *Retcode = StubPtr->Data.Rc.Value; - Result = true; + Result = true; } else { @@ -371,7 +369,7 @@ bool UT_GetStubRetcodeAndCount(UT_EntryKey_t FuncKey, int32 *Retcode, int32 *Cou uint32 UT_GetStubCount(UT_EntryKey_t FuncKey) { UT_StubTableEntry_t *StubPtr; - uint32 Count; + uint32 Count; StubPtr = UT_GetStubEntry(FuncKey, UT_ENTRYTYPE_COUNTER); if (StubPtr != NULL) @@ -388,7 +386,7 @@ uint32 UT_GetStubCount(UT_EntryKey_t FuncKey) bool UT_Stub_CheckForceFail(UT_EntryKey_t FuncKey, int32 *Value) { - bool Result = false; + bool Result = false; UT_StubTableEntry_t *StubPtr; StubPtr = UT_GetStubEntry(FuncKey, UT_ENTRYTYPE_FORCE_FAIL); @@ -417,7 +415,7 @@ void UT_SetDataBuffer(UT_EntryKey_t FuncKey, void *DataBuffer, uint32 BufferSize } else { - StubPtr->FuncKey = FuncKey; + StubPtr->FuncKey = FuncKey; StubPtr->EntryType = UT_ENTRYTYPE_DATA_BUFFER; if (AllocateCopy) { @@ -438,7 +436,7 @@ void UT_SetDataBuffer(UT_EntryKey_t FuncKey, void *DataBuffer, uint32 BufferSize StubPtr->Data.Buff.BasePtr = DataBuffer; } StubPtr->Data.Buff.TotalSize = BufferSize; - StubPtr->Data.Buff.Position = 0; + StubPtr->Data.Buff.Position = 0; } } } @@ -446,23 +444,23 @@ void UT_SetDataBuffer(UT_EntryKey_t FuncKey, void *DataBuffer, uint32 BufferSize void UT_GetDataBuffer(UT_EntryKey_t FuncKey, void **DataBuffer, uint32 *MaxSize, uint32 *Position) { UT_StubTableEntry_t *StubPtr; - void *ResultDataBuffer; - uint32 ResultMaxSize; - uint32 ResultPosition; + void * ResultDataBuffer; + uint32 ResultMaxSize; + uint32 ResultPosition; StubPtr = UT_GetStubEntry(FuncKey, UT_ENTRYTYPE_DATA_BUFFER); if (StubPtr == NULL) { ResultDataBuffer = NULL; - ResultMaxSize = 0; - ResultPosition = 0; + ResultMaxSize = 0; + ResultPosition = 0; } else { ResultDataBuffer = StubPtr->Data.Buff.BasePtr; - ResultMaxSize = StubPtr->Data.Buff.TotalSize; - ResultPosition = StubPtr->Data.Buff.Position; + ResultMaxSize = StubPtr->Data.Buff.TotalSize; + ResultPosition = StubPtr->Data.Buff.Position; } if (DataBuffer != NULL) @@ -481,11 +479,11 @@ void UT_GetDataBuffer(UT_EntryKey_t FuncKey, void **DataBuffer, uint32 *MaxSize, uint32 UT_Stub_CopyToLocal(UT_EntryKey_t FuncKey, void *LocalBuffer, uint32 MaxSize) { - uint32 ActualCopy; + uint32 ActualCopy; UT_StubTableEntry_t *StubPtr; ActualCopy = 0; - StubPtr = UT_GetStubEntry(FuncKey, UT_ENTRYTYPE_DATA_BUFFER); + StubPtr = UT_GetStubEntry(FuncKey, UT_ENTRYTYPE_DATA_BUFFER); if (StubPtr != NULL) { @@ -514,11 +512,11 @@ uint32 UT_Stub_CopyToLocal(UT_EntryKey_t FuncKey, void *LocalBuffer, uint32 MaxS uint32 UT_Stub_CopyFromLocal(UT_EntryKey_t FuncKey, const void *LocalBuffer, uint32 MaxSize) { - uint32 ActualCopy; + uint32 ActualCopy; UT_StubTableEntry_t *StubPtr; ActualCopy = 0; - StubPtr = UT_GetStubEntry(FuncKey, UT_ENTRYTYPE_DATA_BUFFER); + StubPtr = UT_GetStubEntry(FuncKey, UT_ENTRYTYPE_DATA_BUFFER); if (StubPtr != NULL) { @@ -575,11 +573,11 @@ static void UT_DoSetHookFunction(UT_EntryKey_t FuncKey, UT_HookFuncPtr_t Value, else if (StubPtr != NULL && Value.Addr != NULL) { /* Caller wants to set the entry */ - StubPtr->FuncKey = FuncKey; - StubPtr->EntryType = UT_ENTRYTYPE_CALLBACK_HOOK; + StubPtr->FuncKey = FuncKey; + StubPtr->EntryType = UT_ENTRYTYPE_CALLBACK_HOOK; StubPtr->Data.Cb.CallbackArg = UserObj; - StubPtr->Data.Cb.Ptr = Value; - StubPtr->Data.Cb.IsVarg = IsVarg; + StubPtr->Data.Cb.Ptr = Value; + StubPtr->Data.Cb.IsVarg = IsVarg; } } @@ -601,18 +599,18 @@ void UT_SetVaHookFunction(UT_EntryKey_t FuncKey, UT_VaHookFunc_t HookFunc, void UT_DoSetHookFunction(FuncKey, Value, UserObj, true); } -const void* UT_Hook_GetArgPtr(const UT_StubContext_t *ContextPtr, const char *Name, size_t ExpectedTypeSize) +const void *UT_Hook_GetArgPtr(const UT_StubContext_t *ContextPtr, const char *Name, size_t ExpectedTypeSize) { - uint32 i; - const void* Result; + uint32 i; + const void * Result; const UT_StubArgMetaData_t *MetaPtr; static const union { unsigned long AsInt; - void *AsPtr; - double AsFloat; - } ARG_DEFAULT_ZERO_VALUE = { 0 }; + void * AsPtr; + double AsFloat; + } ARG_DEFAULT_ZERO_VALUE = {0}; Result = NULL; for (i = 0; i < ContextPtr->ArgCount; ++i) @@ -620,8 +618,7 @@ const void* UT_Hook_GetArgPtr(const UT_StubContext_t *ContextPtr, const char *Na MetaPtr = &ContextPtr->Meta[i]; if (MetaPtr->Name != NULL) { - if (strcmp(MetaPtr->Name, Name) == 0 && - (MetaPtr->Size == 0 || MetaPtr->Size == ExpectedTypeSize)) + if (strcmp(MetaPtr->Name, Name) == 0 && (MetaPtr->Size == 0 || MetaPtr->Size == ExpectedTypeSize)) { if (MetaPtr->Type == UT_STUBCONTEXT_ARG_TYPE_DIRECT) { @@ -643,8 +640,8 @@ const void* UT_Hook_GetArgPtr(const UT_StubContext_t *ContextPtr, const char *Na */ if (Result == NULL) { - UtAssert_Failed("Requested parameter %s of size %lu which was not provided by the stub", - Name, (unsigned long)ExpectedTypeSize); + UtAssert_Failed("Requested parameter %s of size %lu which was not provided by the stub", Name, + (unsigned long)ExpectedTypeSize); if (ExpectedTypeSize <= sizeof(ARG_DEFAULT_ZERO_VALUE)) { @@ -663,10 +660,10 @@ const void* UT_Hook_GetArgPtr(const UT_StubContext_t *ContextPtr, const char *Na return Result; } -void UT_Stub_RegisterContextWithMetaData(UT_EntryKey_t FuncKey, const char *Name, - UT_StubContext_Arg_Type_t ParamType, const void *ParamPtr, size_t ParamSize) +void UT_Stub_RegisterContextWithMetaData(UT_EntryKey_t FuncKey, const char *Name, UT_StubContext_Arg_Type_t ParamType, + const void *ParamPtr, size_t ParamSize) { - UT_StubTableEntry_t *StubPtr; + UT_StubTableEntry_t * StubPtr; UT_StubArgMetaData_t *MetaPtr; /* @@ -686,13 +683,13 @@ void UT_Stub_RegisterContextWithMetaData(UT_EntryKey_t FuncKey, const char *Name } else { - StubPtr->FuncKey = FuncKey; + StubPtr->FuncKey = FuncKey; StubPtr->EntryType = UT_ENTRYTYPE_CALLBACK_CONTEXT; if (StubPtr->Data.Context.ArgCount < UT_STUBCONTEXT_MAXSIZE) { StubPtr->Data.Context.ArgPtr[StubPtr->Data.Context.ArgCount] = ParamPtr; - MetaPtr = &StubPtr->Data.Context.Meta[StubPtr->Data.Context.ArgCount]; + MetaPtr = &StubPtr->Data.Context.Meta[StubPtr->Data.Context.ArgCount]; MetaPtr->Size = ParamSize; MetaPtr->Type = ParamType; @@ -730,7 +727,6 @@ void UT_Stub_RegisterContextWithMetaData(UT_EntryKey_t FuncKey, const char *Name { MetaPtr->Type = UT_STUBCONTEXT_ARG_TYPE_DIRECT; } - } ++StubPtr->Data.Context.ArgCount; } @@ -744,90 +740,90 @@ void UT_Stub_RegisterContextWithMetaData(UT_EntryKey_t FuncKey, const char *Name */ int32 UT_DefaultStubImplWithArgs(const char *FunctionName, UT_EntryKey_t FuncKey, int32 DefaultRc, va_list va) { - int32 Retcode; - const char *RetcodeString; - UT_StubTableEntry_t *StubPtr; - UT_StubTableEntry_t *ContextTblPtr; - const UT_StubContext_t *ContextPtr; - uint32 Counter; - - if (!UT_Stub_CheckDeferredRetcode(FuncKey, &Retcode)) - { - if (!UT_Stub_CheckForceFail(FuncKey, &Retcode)) - { - Retcode = DefaultRc; - } - } - - if (FunctionName != NULL) - { - if (Retcode == DefaultRc) - { - RetcodeString = "DEFAULT"; - } - else - { - /* Indicate that this invocation got a non-default return code */ - RetcodeString = "*SPECIAL*"; - } - - UtDebug("%s called (%s,%d)", FunctionName, RetcodeString, (int)Retcode); - } - - Counter = 0; - StubPtr = UT_GetStubEntry(FuncKey, UT_ENTRYTYPE_COUNTER); - if (StubPtr == NULL) - { - /* Creating counter entry - repeat search and grab any unused slot */ - StubPtr = UT_GetStubEntry(FuncKey, UT_ENTRYTYPE_UNUSED); - } - - if (StubPtr == NULL) - { - UtAssert_Abort("Cannot set counter - UT_MAX_FUNC_STUBS too low?"); - } - else - { - StubPtr->EntryType = UT_ENTRYTYPE_COUNTER; - StubPtr->FuncKey = FuncKey; - Counter = StubPtr->Data.Rc.Count; - ++StubPtr->Data.Rc.Count; - StubPtr->Data.Rc.Value = Retcode; - } - - /* Handle a user-requested callback hook. - * First see if the stub has a registered context. - */ - ContextTblPtr = UT_GetStubEntry(FuncKey, UT_ENTRYTYPE_CALLBACK_CONTEXT); - if (ContextTblPtr == NULL) - { - ContextPtr = NULL; - } - else - { - ContextPtr = &ContextTblPtr->Data.Context; - } - - StubPtr = UT_GetStubEntry(FuncKey, UT_ENTRYTYPE_CALLBACK_HOOK); - if (StubPtr != NULL) - { - if (StubPtr->Data.Cb.IsVarg) - { - Retcode = (*StubPtr->Data.Cb.Ptr.Va)(StubPtr->Data.Cb.CallbackArg, Retcode, Counter, ContextPtr, va); - } - else - { - Retcode = (*StubPtr->Data.Cb.Ptr.Simple)(StubPtr->Data.Cb.CallbackArg, Retcode, Counter, ContextPtr); - } - } - - /* Always clear the context entry -- the next call will have a different one */ - if (ContextTblPtr != NULL) - { - UT_ClearStubEntry(ContextTblPtr); - } - - return Retcode; + int32 Retcode; + const char * RetcodeString; + UT_StubTableEntry_t * StubPtr; + UT_StubTableEntry_t * ContextTblPtr; + const UT_StubContext_t *ContextPtr; + uint32 Counter; + + if (!UT_Stub_CheckDeferredRetcode(FuncKey, &Retcode)) + { + if (!UT_Stub_CheckForceFail(FuncKey, &Retcode)) + { + Retcode = DefaultRc; + } + } + + if (FunctionName != NULL) + { + if (Retcode == DefaultRc) + { + RetcodeString = "DEFAULT"; + } + else + { + /* Indicate that this invocation got a non-default return code */ + RetcodeString = "*SPECIAL*"; + } + + UtDebug("%s called (%s,%d)", FunctionName, RetcodeString, (int)Retcode); + } + + Counter = 0; + StubPtr = UT_GetStubEntry(FuncKey, UT_ENTRYTYPE_COUNTER); + if (StubPtr == NULL) + { + /* Creating counter entry - repeat search and grab any unused slot */ + StubPtr = UT_GetStubEntry(FuncKey, UT_ENTRYTYPE_UNUSED); + } + + if (StubPtr == NULL) + { + UtAssert_Abort("Cannot set counter - UT_MAX_FUNC_STUBS too low?"); + } + else + { + StubPtr->EntryType = UT_ENTRYTYPE_COUNTER; + StubPtr->FuncKey = FuncKey; + Counter = StubPtr->Data.Rc.Count; + ++StubPtr->Data.Rc.Count; + StubPtr->Data.Rc.Value = Retcode; + } + + /* Handle a user-requested callback hook. + * First see if the stub has a registered context. + */ + ContextTblPtr = UT_GetStubEntry(FuncKey, UT_ENTRYTYPE_CALLBACK_CONTEXT); + if (ContextTblPtr == NULL) + { + ContextPtr = NULL; + } + else + { + ContextPtr = &ContextTblPtr->Data.Context; + } + + StubPtr = UT_GetStubEntry(FuncKey, UT_ENTRYTYPE_CALLBACK_HOOK); + if (StubPtr != NULL) + { + if (StubPtr->Data.Cb.IsVarg) + { + Retcode = (*StubPtr->Data.Cb.Ptr.Va)(StubPtr->Data.Cb.CallbackArg, Retcode, Counter, ContextPtr, va); + } + else + { + Retcode = (*StubPtr->Data.Cb.Ptr.Simple)(StubPtr->Data.Cb.CallbackArg, Retcode, Counter, ContextPtr); + } + } + + /* Always clear the context entry -- the next call will have a different one */ + if (ContextTblPtr != NULL) + { + UT_ClearStubEntry(ContextTblPtr); + } + + return Retcode; } /** @@ -836,13 +832,12 @@ int32 UT_DefaultStubImplWithArgs(const char *FunctionName, UT_EntryKey_t FuncKey */ int32 UT_DefaultStubImpl(const char *FunctionName, UT_EntryKey_t FuncKey, int32 DefaultRc, ...) { - int32 Retcode; + int32 Retcode; va_list va; - va_start(va,DefaultRc); + va_start(va, DefaultRc); Retcode = UT_DefaultStubImplWithArgs(FunctionName, FuncKey, DefaultRc, va); va_end(va); return Retcode; } - diff --git a/ut_assert/src/uttest.c b/ut_assert/src/uttest.c index f4d1ffce1..5aa2ab21f 100644 --- a/ut_assert/src/uttest.c +++ b/ut_assert/src/uttest.c @@ -48,17 +48,18 @@ enum * Function Definitions */ -void UtTest_AddCommon(void (*Test)(void), void (*Setup)(void), void (*Teardown)(void), const char *TestName, uint32 EntryType) +void UtTest_AddCommon(void (*Test)(void), void (*Setup)(void), void (*Teardown)(void), const char *TestName, + uint32 EntryType) { - UtTestDataBaseEntry_t UtTestDataBaseEntry; + UtTestDataBaseEntry_t UtTestDataBaseEntry; memset(&UtTestDataBaseEntry, 0, sizeof(UtTestDataBaseEntry)); - UtTestDataBaseEntry.Test = Test; - UtTestDataBaseEntry.Setup = Setup; + UtTestDataBaseEntry.Test = Test; + UtTestDataBaseEntry.Setup = Setup; UtTestDataBaseEntry.Teardown = Teardown; if (TestName != NULL) { - strncpy(UtTestDataBaseEntry.TestName, TestName, sizeof(UtTestDataBaseEntry.TestName)-1); + strncpy(UtTestDataBaseEntry.TestName, TestName, sizeof(UtTestDataBaseEntry.TestName) - 1); } UtList_Add(UtAssert_Global.DataBasePtr, &UtTestDataBaseEntry, sizeof(UtTestDataBaseEntry_t), EntryType); @@ -79,13 +80,12 @@ void UtTest_AddTeardown(void (*Teardown)(void), const char *SequenceName) UtTest_AddCommon(NULL, NULL, Teardown, SequenceName, UTASSERT_GROUP_TEARDOWN); } - void UtTest_Run(void) { - UtListNode_t *UtListMain; - UtListNode_t *UtListNode; - UtTestDataBaseEntry_t *UtTestDataBaseEntry; - + UtListNode_t * UtListMain; + UtListNode_t * UtListNode; + UtTestDataBaseEntry_t *UtTestDataBaseEntry; + /* * The overall test sequence goes SETUP->TEST->TEARDOWN * @@ -94,31 +94,39 @@ void UtTest_Run(void) * This could also (theoretically) randomize the order of the "TEST" group * while assembling this list, if there was a portable source of entropy. */ - UtListMain = UtList_GetHead(UtAssert_Global.DataBasePtr,UTASSERT_GROUP_DEFAULT); - UtList_Merge(UtListMain, UtList_GetHead(UtAssert_Global.DataBasePtr,UTASSERT_GROUP_SETUP)); - UtList_Merge(UtListMain, UtList_GetHead(UtAssert_Global.DataBasePtr,UTASSERT_GROUP_TEST)); - UtList_Merge(UtListMain, UtList_GetHead(UtAssert_Global.DataBasePtr,UTASSERT_GROUP_TEARDOWN)); - + UtListMain = UtList_GetHead(UtAssert_Global.DataBasePtr, UTASSERT_GROUP_DEFAULT); + UtList_Merge(UtListMain, UtList_GetHead(UtAssert_Global.DataBasePtr, UTASSERT_GROUP_SETUP)); + UtList_Merge(UtListMain, UtList_GetHead(UtAssert_Global.DataBasePtr, UTASSERT_GROUP_TEST)); + UtList_Merge(UtListMain, UtList_GetHead(UtAssert_Global.DataBasePtr, UTASSERT_GROUP_TEARDOWN)); /* * Run through the merged list in order */ - for (UtListNode = UtList_GetNext(UtListMain); - !UtList_IsEnd(UtListMain, UtListNode); - UtListNode = UtList_GetNext(UtListNode)) + for (UtListNode = UtList_GetNext(UtListMain); !UtList_IsEnd(UtListMain, UtListNode); + UtListNode = UtList_GetNext(UtListNode)) { UtTestDataBaseEntry = UtList_GetObject(UtListNode); - + if (UtTestDataBaseEntry != NULL) { UtAssert_BeginTest(UtTestDataBaseEntry->TestName); UtAssert_SetContext(UTASSERT_CASETYPE_TSF); - if (UtTestDataBaseEntry->Setup) { UtTestDataBaseEntry->Setup(); } + if (UtTestDataBaseEntry->Setup) + { + UtTestDataBaseEntry->Setup(); + } UtAssert_SetContext(UTASSERT_CASETYPE_FAILURE); - if (UtTestDataBaseEntry->Test) { UtTestDataBaseEntry->Test(); UtAssert_Global.ExecutedCount++; } + if (UtTestDataBaseEntry->Test) + { + UtTestDataBaseEntry->Test(); + UtAssert_Global.ExecutedCount++; + } UtAssert_SetContext(UTASSERT_CASETYPE_TTF); - if (UtTestDataBaseEntry->Teardown) { UtTestDataBaseEntry->Teardown(); } + if (UtTestDataBaseEntry->Teardown) + { + UtTestDataBaseEntry->Teardown(); + } UtAssert_EndTest(); } @@ -137,5 +145,3 @@ void UtTest_EarlyInit(void) memset(&UtAssert_Global, 0, sizeof(UtAssert_Global)); UtAssert_Global.DataBasePtr = UtList_Create(UTASSERT_GROUP_MAX); } - - diff --git a/ut_assert/src/uttools.c b/ut_assert/src/uttools.c index ccb6bb0bd..aeb21a461 100644 --- a/ut_assert/src/uttools.c +++ b/ut_assert/src/uttools.c @@ -38,8 +38,8 @@ #include "utassert.h" #include "utbsp.h" -#define UT_SNPRINTF_BUF_SIZE 256 -#define UT_SNPRINTF_MAX_BUFS 10 +#define UT_SNPRINTF_BUF_SIZE 256 +#define UT_SNPRINTF_MAX_BUFS 10 /* * Local types/objects @@ -55,25 +55,26 @@ typedef struct bool UtMem2BinFile(const void *Memory, const char *Filename, uint32 Length) { - FILE *fp; + FILE *fp; - if ((fp = fopen(Filename, "w"))) { + if ((fp = fopen(Filename, "w"))) + { fwrite(Memory, Length, 1, fp); fclose(fp); - return(true); + return (true); } else { printf("UtMem2BinFile: Error Opening File: %s, %s\n", Filename, strerror(errno)); UtAssert_True(false, "UtMem2BinFile: Error Opening File"); - return(false); + return (false); } } bool UtBinFile2Mem(void *Memory, const char *Filename, uint32 Length) { - FILE *fp; - bool Success; + FILE *fp; + bool Success; Success = false; if ((fp = fopen(Filename, "r"))) @@ -89,48 +90,54 @@ bool UtBinFile2Mem(void *Memory, const char *Filename, uint32 Length) UtAssert_Failed("UtBinFile2Mem: Error Opening %s: %s", Filename, strerror(errno)); } - return(Success); + return (Success); } bool UtMem2HexFile(const void *Memory, const char *Filename, uint32 Length) { - FILE *fp; - uint32 i; - uint32 j; + FILE * fp; + uint32 i; + uint32 j; - if ((fp = fopen(Filename, "w"))) { + if ((fp = fopen(Filename, "w"))) + { - for (i=0; i < Length; i+=16) { + for (i = 0; i < Length; i += 16) + { fprintf(fp, " %06lX: ", (unsigned long)i); - for (j=0; j < 16; j++) { - if ((i+j) < Length) - fprintf(fp, "%02X ", ((uint8 *)Memory)[i+j]); + for (j = 0; j < 16; j++) + { + if ((i + j) < Length) + fprintf(fp, "%02X ", ((uint8 *)Memory)[i + j]); else fprintf(fp, " "); } fprintf(fp, " "); - for (j=0; j < 16; j++) { - if ((i+j) < Length) - fprintf(fp, "%c", isprint(((uint8 *)Memory)[i+j]) ? ((uint8 *)Memory)[i+j] : '.'); + for (j = 0; j < 16; j++) + { + if ((i + j) < Length) + fprintf(fp, "%c", isprint(((uint8 *)Memory)[i + j]) ? ((uint8 *)Memory)[i + j] : '.'); } fprintf(fp, "\n"); } fclose(fp); - return(true); + return (true); } - else { + else + { printf("UtMem2HexFile: Error Opening File: %s, %s\n", Filename, strerror(errno)); UtAssert_True(false, "UtMem2HexFile: Error Opening File"); - return(false); + return (false); } } void UtMemFill(void *Memory, uint32 Length) { uint32 i; - uint8 *Byte_ptr = Memory; + uint8 *Byte_ptr = Memory; - for(i=0; i < Length; i++) { + for (i = 0; i < Length; i++) + { Byte_ptr[i] = i; } } @@ -138,7 +145,7 @@ void UtMemFill(void *Memory, uint32 Length) void UtMessage(uint8 MessageType, const char *File, uint32 Line, const char *Spec, ...) { UT_Snprintf_Buffer_t Buf; - va_list va; + va_list va; va_start(va, Spec); vsnprintf(Buf.Text, sizeof(Buf.Text), Spec, va); @@ -149,33 +156,35 @@ void UtMessage(uint8 MessageType, const char *File, uint32 Line, const char *Spe char *UtSprintf(const char *Spec, ...) { - va_list Args; + va_list Args; static UT_Snprintf_Buffer_t Buf[UT_SNPRINTF_MAX_BUFS]; - static uint32 TextIndex = 0; + static uint32 TextIndex = 0; ++TextIndex; - if (TextIndex >= UT_SNPRINTF_MAX_BUFS) TextIndex = 0; + if (TextIndex >= UT_SNPRINTF_MAX_BUFS) + TextIndex = 0; va_start(Args, Spec); vsnprintf(Buf[TextIndex].Text, sizeof(Buf[TextIndex].Text), Spec, Args); va_end(Args); - return(Buf[TextIndex].Text); + return (Buf[TextIndex].Text); } void UtPrintx(const void *Memory, uint32 Length) { - uint32 i; - uint32 j; - const uint8 *Byte_ptr = Memory; - char OutputLine[50]; - char *OutPtr; + uint32 i; + uint32 j; + const uint8 *Byte_ptr = Memory; + char OutputLine[50]; + char * OutPtr; - i=0; + i = 0; while (1) { OutPtr = OutputLine; - for (j=0; j < 16 && i < Length; j++, i++) { + for (j = 0; j < 16 && i < Length; j++, i++) + { sprintf(OutPtr, "%02X ", Byte_ptr[i]); OutPtr += 3; } @@ -185,12 +194,14 @@ void UtPrintx(const void *Memory, uint32 Length) bool UtMemCmpValue(const void *Memory, uint8 Value, uint32 Length) { - uint32 i; - const uint8 *Byte_ptr = Memory; + uint32 i; + const uint8 *Byte_ptr = Memory; - for (i=0; i < Length; i++) { - if (Byte_ptr[i] != Value) { - return(false); + for (i = 0; i < Length; i++) + { + if (Byte_ptr[i] != Value) + { + return (false); } } return (true); @@ -198,12 +209,14 @@ bool UtMemCmpValue(const void *Memory, uint8 Value, uint32 Length) bool UtMemCmpCount(const void *Memory, uint32 Length) { - uint32 i; - const uint8 *Byte_ptr = Memory; + uint32 i; + const uint8 *Byte_ptr = Memory; - for (i=0; i < Length; i++) { - if (Byte_ptr[i] != (i & 0xFF)) { - return(false); + for (i = 0; i < Length; i++) + { + if (Byte_ptr[i] != (i & 0xFF)) + { + return (false); } } return (true); @@ -211,29 +224,34 @@ bool UtMemCmpCount(const void *Memory, uint32 Length) bool UtMem2BinFileCmp(const void *Memory, const char *Filename) { - FILE *fp; - const uint8 *MemByte = Memory; - int FileByte; - bool Success; - uint32 i; + FILE * fp; + const uint8 *MemByte = Memory; + int FileByte; + bool Success; + uint32 i; Success = true; - if ((fp = fopen(Filename, "r"))) { + if ((fp = fopen(Filename, "r"))) + { - for (i=0; (FileByte = fgetc(fp)) != EOF; i++) { - if (MemByte[i] != FileByte) { + for (i = 0; (FileByte = fgetc(fp)) != EOF; i++) + { + if (MemByte[i] != FileByte) + { Success = false; - printf("UtMem2BinFileCmp: Miscompare in file: %s, byte offset: %lu, expected: %u, found: %u\n", Filename, (unsigned long)i, (unsigned int)MemByte[i], (unsigned int)FileByte); + printf("UtMem2BinFileCmp: Miscompare in file: %s, byte offset: %lu, expected: %u, found: %u\n", + Filename, (unsigned long)i, (unsigned int)MemByte[i], (unsigned int)FileByte); break; - } + } } fclose(fp); } - else { + else + { Success = false; printf("UtMem2BinFileCmp: Error Opening File: %s, %s\n", Filename, strerror(errno)); UtAssert_True(false, "UtMem2BinFileCmp: Error Opening File"); } - return(Success); + return (Success); }