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

Parameter validation refactor #1

Open
wants to merge 5 commits into
base: parameter-validation
Choose a base branch
from

Conversation

k-stachowiak
Copy link

This PR presents changes suggested for easier client side use of the parameter validation check failure. Limits the parameter validation failure callback to a default function provided with Mbed TLS, that can be substituted by user provided callback at run time.

@k-stachowiak k-stachowiak changed the base branch from development to parameter-validation December 4, 2018 09:48
Introduction of the parameter validation callbacks implemented in terms
of setjmp/longjmp causes certain tests compilation to raise warning
about clobbering certain variables. This happens when the are not
allocated on the stack. Disabling the compiler optimizations prevents
the warnings from being raised. Note that the `-O0` option is present in
the Makefile, whereas it is not used when building with CMake.
@@ -2,7 +2,7 @@
# To compile on SunOS: add "-lsocket -lnsl" to LDFLAGS
# To compile with PKCS11: add "-lpkcs11-helper" to LDFLAGS

CFLAGS ?= -O2
CFLAGS ?= -O0
Copy link
Owner

@simonbutcher simonbutcher Dec 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly as a note to myself....

I don't think this is a good way to suppress a warning.

The actual warning (which is gcc specific) is -Wclobbered, so should be suppressed with -Wno-clobbered. However, clang doesn't recognise the parameter -Wno-clobbered and we don't have a compiler specific means of passing CFLAGS at the moment, so that won't work.

Therefore, if we needed to suppress the warning, may be a better means to suppress it would be in the source file itself to detect gcc and pragma a warning away. The following seems to work:

#if defined(MBEDTLS_CHECK_PARAMS)
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic ignored "-Wno-uninitialized"
#endif
#endif /* MBEDTLS_CHECK_PARAMS */

However - I don't think we should be disabling warnings here, so this shouldn't be needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants