Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osal Integration candidate: 2021-02-02 #774

Merged
merged 40 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
abebf1c
Fix #742, make sure all pointers are checked for null
zanzaben Jan 20, 2021
4a77997
Fix #742, remove null checks from internal methods.
zanzaben Jan 22, 2021
e77e657
Fix #602, bring OSAL code coverage back up to 100%
jphickey Jan 22, 2021
3b2c729
Fix #765, add null pointer check.
zanzaben Jan 27, 2021
72da4f2
Fix #771, Add workflow timeout and format check
skliper Feb 3, 2021
1ebb788
Merge pull request #768 from jphickey/fix-602-codecoverage
astrogeco Feb 3, 2021
6787dfe
Merge pull request #766 from zanzaben/fix742_null_pointer_cleanup
astrogeco Feb 3, 2021
a51fc93
Fix #777, Static allocation of DummyVec in OSC_INUM_TO_IVEC stub
skliper Feb 9, 2021
b9a7697
Fix #783, Initialize locals flagged in static analysis
skliper Feb 9, 2021
58006ae
Fix #785, Clean commented out code
skliper Feb 9, 2021
dd2368d
Fix #788, Resolve coercion alters value warnings
skliper Feb 10, 2021
44e0afc
Fix #790, Return status from OS_ConsoleAPI_Init
skliper Feb 10, 2021
0e76b63
Fix #796, Update os-impl-no-sockets.c to match APIs
skliper Feb 10, 2021
721e042
Fix #797, Update os-impl-no-symtab.c to match APIs
skliper Feb 10, 2021
15ab294
Fix #793, Remove unreachable code in OS_SocketOpen_Impl for BSD socket
skliper Feb 11, 2021
8c83486
Fix #781, Terminate UT macro variadic lists
skliper Feb 9, 2021
6900275
Fix #803, Add check of semaphore to avoid unreachable code in posix O…
skliper Feb 11, 2021
efa1844
Fix #808, length-limited string length checks
jphickey Feb 12, 2021
6173a57
Fix #809, cast args to printf in queue-test
jphickey Feb 8, 2021
66b48f6
Fix #775, Add CodeQL analysis to workflow
skliper Feb 8, 2021
6e43c8e
Merge pull request #772 from skliper/fix771-workflow_updates
astrogeco Feb 12, 2021
3577bbc
Merge pull request #776 from skliper/fix775-add_codeql
astrogeco Feb 12, 2021
e964f1e
Merge pull request #786 from skliper/fix785-rm_commented_out_code
astrogeco Feb 12, 2021
eab4422
Merge pull request #784 from skliper/fix783-uninit_locals
astrogeco Feb 12, 2021
e882996
Merge pull request #789 from skliper/fix788-coercion_alters_value
astrogeco Feb 12, 2021
c878647
Merge pull request #802 from skliper/fix793-socket-dead-code
astrogeco Feb 12, 2021
f7c6d85
Merge pull request #782 from skliper/fix781-terminate_va_list
astrogeco Feb 12, 2021
f237243
Merge pull request #804 from skliper/fix803-unreachable_binsemcreate
astrogeco Feb 12, 2021
7448a5e
Merge pull request #792 from skliper/fix790_os_consoleapi_init_rtn
astrogeco Feb 12, 2021
68d0e7f
Merge pull request #778 from skliper/fix777-inum_to_ivec
astrogeco Feb 12, 2021
a966ca7
Merge pull request #801 from skliper/fix797-no_symtab
astrogeco Feb 12, 2021
920fde8
Merge pull request #800 from skliper/fix796-no_sockets
astrogeco Feb 12, 2021
a8e0955
Fix #805, Null terminate when using strncpy
skliper Feb 11, 2021
c24982d
Merge pull request #800 from skliper/fix796-no_sockets
astrogeco Feb 12, 2021
a97e4f9
Merge pull request #807 from skliper/fix805-null_termination
astrogeco Feb 12, 2021
9888e3f
Merge pull request #811 from jphickey/fix-809-printf-format
astrogeco Feb 12, 2021
842fe88
Merge pull request #810 from jphickey/fix-808-strnlen
astrogeco Feb 12, 2021
831100a
Fix #796, Apply formatting
skliper Feb 12, 2021
28e60f3
Merge pull request #773 from skliper/fix769-apply_formatting
astrogeco Feb 12, 2021
fec2d91
Bump to v5.1.0-rc1+dev262
astrogeco Feb 12, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
58 changes: 58 additions & 0 deletions .github/workflows/codeql-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: "CodeQL Analysis"

on:
push:
pull_request:

env:
SIMULATION: native
ENABLE_UNIT_TESTS: true
OMIT_DEPRECATED: true
BUILDTYPE: release

jobs:

CodeQL-Build:
runs-on: ubuntu-18.04
timeout-minutes: 15

steps:
# Checks out a copy of your repository on the ubuntu-latest machine
- name: Checkout bundle
uses: actions/checkout@v2
with:
repository: nasa/cFS
submodules: true

- name: Checkout submodule
uses: actions/checkout@v2
with:
path: osal

- name: Check versions
run: git submodule

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: c
queries: +security-extended, security-and-quality

# Setup the build system
- name: Set up for build
run: |
cp ./cfe/cmake/Makefile.sample Makefile
cp -r ./cfe/cmake/sample_defs sample_defs
make prep

# Build the code
- name: Build
run: |
make osal
make native/default_cpu1/osal/tests/
make native/default_cpu1/osal/unit-test-coverage/
make native/default_cpu1/osal/unit-tests/
make native/default_cpu1/osal/ut-stubs/

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
53 changes: 53 additions & 0 deletions .github/workflows/format-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Format Check

# Run on main push and pull requests
on:
push:
branches:
- main
pull_request:

jobs:

static-analysis:
name: Run format check
runs-on: ubuntu-18.04
timeout-minutes: 15

steps:

- name: Install format checker
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main'
sudo apt-get update && sudo apt-get install clang-format-10

- name: Checkout bundle
uses: actions/checkout@v2
with:
repository: nasa/cFS

- name: Checkout
uses: actions/checkout@v2
with:
path: repo

- name: Generate format differences
run: |
cd repo
find . -name "*.[ch]" -exec clang-format-10 -i -style=file {} +
git diff > $GITHUB_WORKSPACE/style_differences.txt

- name: Archive Static Analysis Artifacts
uses: actions/upload-artifact@v2
with:
name: style_differences
path: style_differences.txt

- name: Error on differences
run: |
if [[ -s style_differences.txt ]];
then
cat style_differences.txt
exit -1
fi
1 change: 1 addition & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
static-analysis:
name: Run cppcheck
runs-on: ubuntu-18.04
timeout-minutes: 15

strategy:
fail-fast: false
Expand Down
61 changes: 0 additions & 61 deletions .travis.yml

This file was deleted.

25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Travis-CI: [![Build Status](https://travis-ci.com/nasa/osal.svg)](https://travis-ci.com/nasa/osal)
![Static Analysis](https://github.com/nasa/osal/workflows/Static%20Analysis/badge.svg)
![Format Check](https://github.com/nasa/osal/workflows/Format%20Check/badge.svg)

# Core Flight System : Framework : Operating System Abstraction Layer

Expand All @@ -10,6 +11,28 @@ The autogenerated OSAL user's guide can be viewed at <https://github.com/nasa/cF

## Version History

### Development Build: 5.1.0-rc1+dev262

- Adds test cases for `OS_ObjectIdFinalizeDelete`, `OS_DeleteAllObjects`, and others to get 100% line and function coverage on VxWorks and shared/portable layers.
- Ensures APIs check for `NULL` inputs or have documentation stating that a null value is allowed.
- Adds timeout to static analysis check and adds format check. Removes old .travis.yml and updates badges in readme.
- Adds Code QL analysis on push to main and pull requests (to main)
- Cleans commented-out code in tests to address static analysis warnings
- Initializes local variables to avoid returning uninitialized values from stubs and address static-analysis findings
- Replaces two local return codes defined as `uint32` with `int32` to resolve static-analysis warnings
- Simplifies switch statements based on previous checks. Removes unreachable, dead code to resolve static-analysis warnings
- Terminates unit test macros variadic lists with `NULL` to address CWE-121 CodeQL warning
- Adds a check to send the semaphore to avoid unreachable code
- Adds a status return to `OS_ConsoleAPI_Init` so debug warnings will get reported correctly on errors.
- Declares `DummyVec` as static to avoid warning and returning stack allocated memory when returning `VecTbl` in `OSC_INUM_TO_IVEC` stub
- Updates types in `os-impl-no-symtab.c` to match latest APIs
- Updates types in `os-impl-no-symtab.c` to match latest APIs
- Fixes missing `NULL` terminations and applies the standard "sizeof" pattern where appropriate. No longer truncates filename in `OS_ModuleInfo`.
- Fixes `%u` conversion in RTEMS so to address build warning
- Create a wrapper around `memchr()` that mimics the non-C99 function `strnlen()` defined in POSIX-2008. Use this instead of `strlen()` whenever the string being checked either originates in or will be copied into a fixed-length array buffer. No behavior changes except if a bug causes strings to be unterminated.
- No behavior change, applies the standard formatting using `clang-format`
- See <https://github.com/nasa/osal/pull/774>

### Development Build: 5.1.0-rc1+dev221

- Fixes `printf` format to correctly build in RTEMS-5.
Expand Down
2 changes: 1 addition & 1 deletion src/bsp/generic-linux/src/generic_linux_bsp_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ typedef struct
*/
extern OS_BSP_GenericLinuxGlobalData_t OS_BSP_GenericLinuxGlobal;

#endif /* GENERIC_LINUX_BSP_INTERNAL_H */
#endif /* GENERIC_LINUX_BSP_INTERNAL_H */
2 changes: 1 addition & 1 deletion src/bsp/generic-vxworks/src/generic_vxworks_bsp_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
*/
#include "bsp-impl.h"

#endif /* GENERIC_VXWORKS_BSP_INTERNAL_H */
#endif /* GENERIC_VXWORKS_BSP_INTERNAL_H */
16 changes: 8 additions & 8 deletions src/bsp/pc-rtems/src/bsp_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,16 +370,16 @@ 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_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_MAXIMUM_DRIVERS 10
#define CONFIGURE_MAXIMUM_POSIX_KEYS 4
#ifdef _RTEMS_5_
#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS (OS_MAX_NUM_OPEN_FILES + 8)
#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS (OS_MAX_NUM_OPEN_FILES + 8)
#else
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS (OS_MAX_NUM_OPEN_FILES + 8)
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS (OS_MAX_NUM_OPEN_FILES + 8)
#endif

#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
Expand Down
6 changes: 3 additions & 3 deletions src/bsp/pc-rtems/src/pcrtems_bsp_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
* Handle the differences between RTEMS 5 and 4.11 copyright notice
*/
#ifdef _RTEMS_5_
#define OSAL_BSP_COPYRIGHT_NOTICE rtems_get_copyright_notice()
#define OSAL_BSP_COPYRIGHT_NOTICE rtems_get_copyright_notice()
#else
#define OSAL_BSP_COPYRIGHT_NOTICE _Copyright_Notice
#define OSAL_BSP_COPYRIGHT_NOTICE _Copyright_Notice
#endif

/*
Expand Down Expand Up @@ -73,4 +73,4 @@ typedef struct
*/
extern OS_BSP_PcRtemsGlobalData_t OS_BSP_PcRtemsGlobal;

#endif /* PCRTEMS_BSP_INTERNAL_H */
#endif /* PCRTEMS_BSP_INTERNAL_H */
2 changes: 0 additions & 2 deletions src/os/inc/osapi-binsem.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@
#include "osconfig.h"
#include "common_types.h"


/** @defgroup OSSemaphoreStates OSAL Semaphore State Defines
* @{
*/
#define OS_SEM_FULL 1 /**< @brief Semaphore full state */
#define OS_SEM_EMPTY 0 /**< @brief Semaphore empty state */
/**@}*/


/** @brief OSAL binary semaphore properties */
typedef struct
{
Expand Down
1 change: 0 additions & 1 deletion src/os/inc/osapi-bsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "osconfig.h"
#include "common_types.h"


/****************************************************************************************
BSP LOW-LEVEL IMPLEMENTATION FUNCTIONS
****************************************************************************************/
Expand Down
17 changes: 6 additions & 11 deletions src/os/inc/osapi-clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,17 @@
*/
typedef struct
{
int64 ticks; /**< Ticks elapsed since reference point */
int64 ticks; /**< Ticks elapsed since reference point */
} OS_time_t;


/**
* @brief Multipliers/divisors to convert ticks into standardized units
*
*
* Various fixed conversion factor constants used by the conversion routines
*
*
* A 100ns tick time allows max intervals of about +/- 14000 years in
* a 64-bit signed integer value.
*
*
* @note Applications should not directly use these values, but rather use
* conversion routines below to obtain standardized units (seconds/microseconds/etc).
*/
Expand Down Expand Up @@ -99,7 +98,6 @@ int32 OS_GetLocalTime(OS_time_t *time_struct);
*/
int32 OS_SetLocalTime(const OS_time_t *time_struct);


/*-------------------------------------------------------------------------------------*/
/*
* Accessor / Unit Conversion routines for OS_time_t
Expand Down Expand Up @@ -217,7 +215,6 @@ static inline uint32 OS_TimeGetSubsecondsPart(OS_time_t tm)
return (uint32)((frac - 1) / (OS_TIME_TICKS_PER_SECOND >> 2));
}


/*-------------------------------------------------------------------------------------*/
/**
* @brief Get milliseconds portion (fractional part only) from an OS_time_t object
Expand Down Expand Up @@ -351,7 +348,6 @@ static inline OS_time_t OS_TimeAssembleFromMilliseconds(int64 seconds, uint32 mi
return result;
}


/*-------------------------------------------------------------------------------------*/
/**
* @brief Assemble/Convert a number of seconds + subseconds into an OS_time_t interval
Expand Down Expand Up @@ -387,7 +383,7 @@ static inline OS_time_t OS_TimeAssembleFromSubseconds(int64 seconds, uint32 subs
*/
static inline OS_time_t OS_TimeAdd(OS_time_t time1, OS_time_t time2)
{
return ((OS_time_t) { time1.ticks + time2.ticks });
return ((OS_time_t) {time1.ticks + time2.ticks});
}

/*-------------------------------------------------------------------------------------*/
Expand All @@ -401,10 +397,9 @@ static inline OS_time_t OS_TimeAdd(OS_time_t time1, OS_time_t time2)
*/
static inline OS_time_t OS_TimeSubtract(OS_time_t time1, OS_time_t time2)
{
return ((OS_time_t) { time1.ticks - time2.ticks });
return ((OS_time_t) {time1.ticks - time2.ticks});
}


/**@}*/

#endif
2 changes: 0 additions & 2 deletions src/os/inc/osapi-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "osconfig.h"
#include "common_types.h"


/**
* @brief A set of events that can be used with BSP event callback routines
*/
Expand Down Expand Up @@ -98,7 +97,6 @@ typedef enum
*/
typedef int32 (*OS_EventHandler_t)(OS_Event_t event, osal_id_t object_id, void *data);


/** @defgroup OSAPICore OSAL Core Operation APIs
*
* These are for OSAL core operations for startup/initialization, running, and shutdown.
Expand Down
2 changes: 0 additions & 2 deletions src/os/inc/osapi-constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#define OS_PEND (-1)
#define OS_CHECK (0)


/**
* @brief Initializer for the osal_id_t type which will not match any valid value
*/
Expand All @@ -54,5 +53,4 @@
*/
#define OS_MAX_LOCAL_PATH_LEN (OS_MAX_PATH_LEN + OS_FS_PHYS_NAME_LEN)


#endif
Loading