-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
We have two common.h files with duplicated content #9454
Comments
I cannot find |
Oh, sorry, I meant |
There is one thing that can be a problem here. I wanted to comment on that for some time but have not found the time to do so. |
@ronald-cron-arm I think we have basically the same base idea: each repository has a “common” header file, they have different names, they each include their respective build_info, and the mbedtls common header includes the tf-psa-crypto header. Then you propose to also split out the crypto common file thematically, and I propose to also distinguish between x509 and tls common. I have no strong opinion on either of these topics. |
Thanks for your response, I think I understand better the proposal now but regarding
I am not sure to fully follow. Thus currently in #include "common.h"
#if defined(MBEDTLS_SSL_CLI_C)
#if defined(MBEDTLS_SSL_PROTO_TLS1_3) || defined(MBEDTLS_SSL_PROTO_TLS1_2)
#include <string.h>
#include "debug_internal.h"
#include "mbedtls/error.h"
#include "mbedtls/platform.h"
#include "ssl_client.h"
#include "ssl_misc.h"
#include "ssl_tls13_keys.h"
#include "ssl_debug_helpers.h"
... Is the proposal to move to: #if defined(MBEDTLS_SSL_CLI_C)
#if defined(MBEDTLS_SSL_PROTO_TLS1_3) || defined(MBEDTLS_SSL_PROTO_TLS1_2)
#include <string.h>
#include "debug_internal.h"
#include "mbedtls/error.h"
#include "mbedtls/platform.h"
#include "ssl_client.h"
#include "ssl_misc.h"
#include "ssl_tls13_keys.h"
#include "ssl_debug_helpers.h"
... or #include "ssl_misc.h"
#if defined(MBEDTLS_SSL_CLI_C)
#if defined(MBEDTLS_SSL_PROTO_TLS1_3) || defined(MBEDTLS_SSL_PROTO_TLS1_2)
#include <string.h>
#include "debug_internal.h"
#include "mbedtls/error.h"
#include "mbedtls/platform.h"
#include "ssl_client.h"
#include "ssl_tls13_keys.h"
#include "ssl_debug_helpers.h"
... in both cases we will hit some troubles I'd say. |
I propose to move |
Well sometimes when you change the order of includes you have some surprises and I am not completely confident in the sanity of the header inclusions in the library. But we can try it. Interestingly |
The main gotcha I can think of wrt include order is that sometimes we have ifdefs before including the config, so they go through the “not defined” path even when the configuration defines that symbol. But that is precisely a problem we won't run into, since we're ensuring that |
@gilles-peskine-arm thanks for the discussion. @Harry-Ramsey I think I understand now where we want to go with this issue. Hopefully the discussion above will be helpful for you as well. |
It would seem that changing the header order with |
Then I would suggest to go for a less disruptive change. In Mbed TLS (not tf-psa-crypto), replace |
Since 90ca414, we have both
library/common.h
andtf-psa-crypto/core/common.h
, with identical content (if we remember to keep them in synch). This is a problem for two reasons.Having duplicated code is intrinsically problematic for maintenance. (The reason I found out about the duplication is that I changed one copy and struggled to understand why my changes apparently had no effect.)
In addition, having two files with the same name is problematic because it can break the build for users who don't use our build scripts and just treat our source code as a bunch of
.c
and.h
files. This is not uncommon and we do want to support it (even if it's a best-effort which we can't really test).What I think we should do is:
common.h
intf-psa-crypto/core
— it should have been moved rather than copied. (Note: we may want togit rm tf-psa-crypto/core/common.h; git commit; git mv library/common.h tf-psa-crypto/core; git commit
so that git understands that patches totf-psa-crypto/core/common.h
need to be backported tolibrary/common.h
.)common.h
inlibrary/x509_internal.h
andlibrary/ssl_misc.h
, and make sure every x509/ssl source file includes the respective internal header.(This doesn't allow building Mbed TLS without TF-PSA-Crypto, but that is not an objective of Mbed TLS 4.x.)
The text was updated successfully, but these errors were encountered: