-
Notifications
You must be signed in to change notification settings - Fork 1
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
base: parameter-validation
Are you sure you want to change the base?
Parameter validation refactor #1
Conversation
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 |
There was a problem hiding this comment.
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.
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.