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

Implement macro to facilitate argument checking #688

Closed
jphickey opened this issue Dec 14, 2020 · 0 comments · Fixed by #689 or #690
Closed

Implement macro to facilitate argument checking #688

jphickey opened this issue Dec 14, 2020 · 0 comments · Fixed by #689 or #690
Assignees
Milestone

Comments

@jphickey
Copy link
Contributor

Is your feature request related to a problem? Please describe.
OSAL and CFE contain many argument checks at the beginning of functions. These would benefit from a macro to keep them consistent and readable in the application code, as well as offer alternative implementations/options for controlling how these are handled on an application-wide basis.

Describe the solution you'd like
Provide assert-style macros in OSAL that can facilitate argument checking, bug checking, and error handling.

Requester Info
Joseph Hickey, Vantage Systems, Inc.

@jphickey jphickey self-assigned this Dec 14, 2020
jphickey added a commit to jphickey/osal that referenced this issue Dec 14, 2020
Initial implementation of bugcheck/argcheck macros for evaluation.
There are three new macros provided:

BUGREPORT() - report a message about a critical/unexpected condition.
BUGCHECK() - assert on a critical condition where failure may be fatal.
ARGCHECK() - other argument check, failure can be rectified/mitigated.
jphickey added a commit to jphickey/osal that referenced this issue Dec 14, 2020
A specialization of ARGCHECK for the frequently-needed case of
confirming that a supplied string will fit in a fixed-size buffer.

Also makes the BUGCHECK more friendly for error types which may
be non-integer in nature - removes cast to long and printing integer.
jphickey added a commit to jphickey/osal that referenced this issue Dec 15, 2020
Add macros for configurable behavior of argument bug checking.

- BUGCHECK for checking argument values which should never happen
   and indicate bugs if they do.
- ARGCHECK for checking argument values which may happen and can
   be mitigated if they do.

The behavior of BUGCHECK is influenced by two new OSAL config
options, which can disable it completely or make it strict/enforcing
such that it will abort() for debugging if a condition is not met.
jphickey added a commit to jphickey/osal that referenced this issue Dec 15, 2020
Use the new macros to validate arguments to OS API calls.

Also includes coverage test updates, which revealed some
areas where return types were not consistent, and the macro
makes them consistent now.
@jphickey jphickey linked a pull request Dec 15, 2020 that will close this issue
@astrogeco astrogeco added this to the 6.0.0 milestone Dec 18, 2020
astrogeco added a commit that referenced this issue Dec 18, 2020
Fix #688, implement value check and bug report macros
jphickey pushed a commit to jphickey/osal that referenced this issue Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants