lib/crypto, efi_loader: avoid multiple inclusions of header files
PATCH 1/1 lib/crypto, efi_loader: avoid multiple inclusions of header files
By adding extra symbols, we can now avoid including x509_parser and pkcs7_parser.h files multiple times.
--- lib/crypto/pkcs7_parser.h | 4 ++++ lib/crypto/x509_parser.h | 4 ++++ lib/efi_loader/efi_image_loader.c | 1 + lib/efi_loader/efi_signature.c | 1 + 4 files changed, 10 insertions(+)
lib/crypto/pkcs7_parser.h +4 -0
@@ -5,6 +5,9 @@* Written by David Howells (dhowells at redhat.com) */ +#ifndef _PKCS7_PARSER_H +#define _PKCS7_PARSER_H +#include <linux/oid_registry.h> #include <crypto/pkcs7.h> #include "x509_parser.h"
@@ -63,3 +66,4 @@ struct pkcs7_message {size_t data_hdrlen;/* Length of Data ASN.1 header */ const void *data; /* Content Data (or 0) */ }; +#endif /* _PKCS7_PARSER_H */
lib/crypto/x509_parser.h +4 -0
@@ -5,6 +5,9 @@* Written by David Howells (dhowells at redhat.com) */ +#ifndef _X509_PARSER_H +#define _X509_PARSER_H +#include <linux/time.h> #include <crypto/public_key.h> #include <keys/asymmetric-type.h>
@@ -55,3 +58,4 @@ extern int x509_decode_time(time64_t *_t, size_t hdrlen,*/ extern int x509_get_sig_params (struct x509_certificate *cert);extern int x509_check_for_self_signed (struct x509_certificate *cert); +#endif /* _X509_PARSER_H */
lib/efi_loader/efi_image_loader.c +1 -0
@@ -14,6 +14,7 @@#include <pe.h> #include <sort.h> #include "../lib/crypto/pkcs7_parser.h" +#include "../lib/crypto/x509_parser.h" const efi_guid_t efi_global_variable_guid =EFI_GLOBAL_VARIABLE_GUID ;const efi_guid_t efi_guid_device_path =EFI_DEVICE_PATH_PROTOCOL_GUID ;
lib/efi_loader/efi_signature.c +1 -0
@@ -15,6 +15,7 @@#include <u-boot/rsa.h> #include <u-boot/sha256.h> #include "../lib/crypto/pkcs7_parser.h" +#include "../lib/crypto/x509_parser.h" const efi_guid_t efi_guid_image_security_database =EFI_IMAGE_SECURITY_DATABASE_GUID ;
Signature · 1 line
2.25.2
PATCH 1/1 lib/crypto, efi_loader: avoid multiple inclusions of header files
Quoted 55 lines · AKASHI Takahiro
By adding extra symbols, we can now avoid including
x509_parserandpkcs7_parser.hfiles multiple times.Signed-off-by AKASHI Takahiro <[email protected]>Suggested-by Heinrich Schuchardt <[email protected]>--- lib/crypto/pkcs7_parser.h | 4 ++++ lib/crypto/x509_parser.h | 4 ++++ lib/efi_loader/efi_image_loader.c | 1 + lib/efi_loader/efi_signature.c | 1 + 4 files changed, 10 insertions(+)lib/crypto/pkcs7_parser.h +4
-0@@ -5,6 +5,9 @@* Written by David Howells (dhowells at redhat.com) */ +#ifndef _PKCS7_PARSER_H +#define _PKCS7_PARSER_H +#include <linux/oid_registry.h> #include <crypto/pkcs7.h> #include "x509_parser.h" @@ -63,3 +66,4 @@ struct pkcs7_message {size_t data_hdrlen;/* Length of Data ASN.1 header */ const void *data; /* Content Data (or 0) */ }; +#endif /* _PKCS7_PARSER_H */ lib/crypto/x509_parser.h +4
-0@@ -5,6 +5,9 @@* Written by David Howells (dhowells at redhat.com) */ +#ifndef _X509_PARSER_H +#define _X509_PARSER_H +#include <linux/time.h> #include <crypto/public_key.h> #include <keys/asymmetric-type.h> @@ -55,3 +58,4 @@ extern int x509_decode_time(time64_t *_t, size_t hdrlen,*/ extern int x509_get_sig_params (struct x509_certificate *cert);extern int x509_check_for_self_signed (struct x509_certificate *cert); +#endif /* _X509_PARSER_H */ lib/efi_loader/efi_image_loader.c +0
-0
lib/efi_loader/efi_image_loader.c line 17
Quoted 4 lines
lib/efi_loader/efi_image_loader.c +1
-0@@ -14,6 +14,7 @@#include <pe.h> #include <sort.h> #include "../lib/crypto/pkcs7_parser.h" +#include "../lib/crypto/x509_parser.h"
As pkcs7_parser.h includes x509_parser.h there is no reason to include it again.
lib/efi_loader/efi_signature.c line 18
Quoted 12 lines
lib/efi_loader/efi_image_loader.c +0
-0const efi_guid_t efi_global_variable_guid =EFI_GLOBAL_VARIABLE_GUID ;const efi_guid_t efi_guid_device_path =EFI_DEVICE_PATH_PROTOCOL_GUID ;lib/efi_loader/efi_signature.c +1
-0@@ -15,6 +15,7 @@#include <u-boot/rsa.h> #include <u-boot/sha256.h> #include "../lib/crypto/pkcs7_parser.h" +#include "../lib/crypto/x509_parser.h"
Same here.
The rest is correct and should be merged.
Best regards
Heinrich
Quoted 4 lines
lib/efi_loader/efi_signature.c +0
-0const efi_guid_t efi_guid_image_security_database =EFI_IMAGE_SECURITY_DATABASE_GUID ;
PATCH 1/1 lib/crypto, efi_loader: avoid multiple inclusions of header files
Heinrich,
Quoted 55 lines · Heinrich Schuchardt
Quoted 54 lines · AKASHI Takahiro
By adding extra symbols, we can now avoid including
x509_parserandpkcs7_parser.hfiles multiple times.Signed-off-by AKASHI Takahiro <[email protected]>Suggested-by Heinrich Schuchardt <[email protected]>--- lib/crypto/pkcs7_parser.h | 4 ++++ lib/crypto/x509_parser.h | 4 ++++ lib/efi_loader/efi_image_loader.c | 1 + lib/efi_loader/efi_signature.c | 1 + 4 files changed, 10 insertions(+)lib/crypto/pkcs7_parser.h +4
-0@@ -5,6 +5,9 @@* Written by David Howells (dhowells at redhat.com) */ +#ifndef _PKCS7_PARSER_H +#define _PKCS7_PARSER_H +#include <linux/oid_registry.h> #include <crypto/pkcs7.h> #include "x509_parser.h" @@ -63,3 +66,4 @@ struct pkcs7_message {size_t data_hdrlen;/* Length of Data ASN.1 header */ const void *data; /* Content Data (or 0) */ }; +#endif /* _PKCS7_PARSER_H */ lib/crypto/x509_parser.h +4
-0@@ -5,6 +5,9 @@* Written by David Howells (dhowells at redhat.com) */ +#ifndef _X509_PARSER_H +#define _X509_PARSER_H +#include <linux/time.h> #include <crypto/public_key.h> #include <keys/asymmetric-type.h> @@ -55,3 +58,4 @@ extern int x509_decode_time(time64_t *_t, size_t hdrlen,*/ extern int x509_get_sig_params (struct x509_certificate *cert);extern int x509_check_for_self_signed (struct x509_certificate *cert); +#endif /* _X509_PARSER_H */ lib/efi_loader/efi_image_loader.c +0
-0
Quoted 8 lines
lib/efi_loader/efi_image_loader.c line 17
Quoted 5 lines
lib/efi_loader/efi_image_loader.c +1
-0@@ -14,6 +14,7 @@#include <pe.h> #include <sort.h> #include "../lib/crypto/pkcs7_parser.h" +#include "../lib/crypto/x509_parser.h" As
pkcs7_parser.hincludesx509_parser.hthere is no reason to include it again.
No, I don't think so.
My style of coding is that, if a symbol is used in a C file and it is defined in a header file, the header file should be *directly* included in the C file.
I believe that it is the common way so that we can avoid any "implicit" dependencies among header files.
Thanks,
-Takahiro Akashi
Quoted 26 lines
lib/efi_loader/efi_signature.c line 18
Quoted 12 lines
lib/efi_loader/efi_image_loader.c +0
-0const efi_guid_t efi_global_variable_guid =EFI_GLOBAL_VARIABLE_GUID ;const efi_guid_t efi_guid_device_path =EFI_DEVICE_PATH_PROTOCOL_GUID ;lib/efi_loader/efi_signature.c +1
-0@@ -15,6 +15,7 @@#include <u-boot/rsa.h> #include <u-boot/sha256.h> #include "../lib/crypto/pkcs7_parser.h" +#include "../lib/crypto/x509_parser.h" Same here.
The rest is correct and should be merged.
Best regards
Heinrich
Quoted 4 lines
lib/efi_loader/efi_signature.c +0
-0const efi_guid_t efi_guid_image_security_database =EFI_IMAGE_SECURITY_DATABASE_GUID ;
PATCH 1/1 lib/crypto, efi_loader: avoid multiple inclusions of header files
Quoted 67 lines · AKASHI Takahiro
Heinrich,
Quoted 55 lines · Heinrich Schuchardt
Quoted 54 lines · AKASHI Takahiro
By adding extra symbols, we can now avoid including
x509_parserandpkcs7_parser.hfiles multiple times.Signed-off-by AKASHI Takahiro <[email protected]>Suggested-by Heinrich Schuchardt <[email protected]>--- lib/crypto/pkcs7_parser.h | 4 ++++ lib/crypto/x509_parser.h | 4 ++++ lib/efi_loader/efi_image_loader.c | 1 + lib/efi_loader/efi_signature.c | 1 + 4 files changed, 10 insertions(+)lib/crypto/pkcs7_parser.h +4
-0@@ -5,6 +5,9 @@* Written by David Howells (dhowells at redhat.com) */ +#ifndef _PKCS7_PARSER_H +#define _PKCS7_PARSER_H +#include <linux/oid_registry.h> #include <crypto/pkcs7.h> #include "x509_parser.h" @@ -63,3 +66,4 @@ struct pkcs7_message {size_t data_hdrlen;/* Length of Data ASN.1 header */ const void *data; /* Content Data (or 0) */ }; +#endif /* _PKCS7_PARSER_H */ lib/crypto/x509_parser.h +4
-0@@ -5,6 +5,9 @@* Written by David Howells (dhowells at redhat.com) */ +#ifndef _X509_PARSER_H +#define _X509_PARSER_H +#include <linux/time.h> #include <crypto/public_key.h> #include <keys/asymmetric-type.h> @@ -55,3 +58,4 @@ extern int x509_decode_time(time64_t *_t, size_t hdrlen,*/ extern int x509_get_sig_params (struct x509_certificate *cert);extern int x509_check_for_self_signed (struct x509_certificate *cert); +#endif /* _X509_PARSER_H */ lib/efi_loader/efi_image_loader.c +0
-0Quoted 8 lines
lib/efi_loader/efi_image_loader.c line 17
Quoted 5 lines
lib/efi_loader/efi_image_loader.c +1
-0@@ -14,6 +14,7 @@#include <pe.h> #include <sort.h> #include "../lib/crypto/pkcs7_parser.h" +#include "../lib/crypto/x509_parser.h" As
pkcs7_parser.hincludesx509_parser.hthere is no reason to include it again.
Quoted 7 lines
No, I don't think so.
My style of coding is that, if a symbol is used in a C file and it is defined in a header file, the header file should be *directly* included in the C file.
I believe that it is the common way so that we can avoid any "implicit" dependencies among header files.
We want U-Boot to build as fast as possible. So we should not include anything twice. When looking through the rest of the U-Boot code you will have noticed that we do not include malloc.h and stdio.h everywhere because it is included via common.h.
As an example of a patch removing other unnecessary includes see for instance:
cmd: fat: remove unused includesfd0e30b43b6b2401e68dc32c357869c617d4fdd1
Best regards
Heinrich
Quoted 31 lines
Thanks,
-Takahiro AkashiQuoted 26 lines
lib/efi_loader/efi_signature.c line 18
Quoted 12 lines
lib/efi_loader/efi_image_loader.c +0
-0const efi_guid_t efi_global_variable_guid =EFI_GLOBAL_VARIABLE_GUID ;const efi_guid_t efi_guid_device_path =EFI_DEVICE_PATH_PROTOCOL_GUID ;lib/efi_loader/efi_signature.c +1
-0@@ -15,6 +15,7 @@#include <u-boot/rsa.h> #include <u-boot/sha256.h> #include "../lib/crypto/pkcs7_parser.h" +#include "../lib/crypto/x509_parser.h" Same here.
The rest is correct and should be merged.
Best regards
Heinrich
Quoted 4 lines
lib/efi_loader/efi_signature.c +0
-0const efi_guid_t efi_guid_image_security_database =EFI_IMAGE_SECURITY_DATABASE_GUID ;
PATCH 1/1 lib/crypto, efi_loader: avoid multiple inclusions of header files
Heinrich,
Quoted 76 lines · Heinrich Schuchardt
Quoted 67 lines · AKASHI Takahiro
Heinrich,
Quoted 55 lines · Heinrich Schuchardt
Quoted 54 lines · AKASHI Takahiro
By adding extra symbols, we can now avoid including
x509_parserandpkcs7_parser.hfiles multiple times.Signed-off-by AKASHI Takahiro <[email protected]>Suggested-by Heinrich Schuchardt <[email protected]>--- lib/crypto/pkcs7_parser.h | 4 ++++ lib/crypto/x509_parser.h | 4 ++++ lib/efi_loader/efi_image_loader.c | 1 + lib/efi_loader/efi_signature.c | 1 + 4 files changed, 10 insertions(+)lib/crypto/pkcs7_parser.h +4
-0@@ -5,6 +5,9 @@* Written by David Howells (dhowells at redhat.com) */ +#ifndef _PKCS7_PARSER_H +#define _PKCS7_PARSER_H +#include <linux/oid_registry.h> #include <crypto/pkcs7.h> #include "x509_parser.h" @@ -63,3 +66,4 @@ struct pkcs7_message {size_t data_hdrlen;/* Length of Data ASN.1 header */ const void *data; /* Content Data (or 0) */ }; +#endif /* _PKCS7_PARSER_H */ lib/crypto/x509_parser.h +4
-0@@ -5,6 +5,9 @@* Written by David Howells (dhowells at redhat.com) */ +#ifndef _X509_PARSER_H +#define _X509_PARSER_H +#include <linux/time.h> #include <crypto/public_key.h> #include <keys/asymmetric-type.h> @@ -55,3 +58,4 @@ extern int x509_decode_time(time64_t *_t, size_t hdrlen,*/ extern int x509_get_sig_params (struct x509_certificate *cert);extern int x509_check_for_self_signed (struct x509_certificate *cert); +#endif /* _X509_PARSER_H */ lib/efi_loader/efi_image_loader.c +0
-0Quoted 8 lines
lib/efi_loader/efi_image_loader.c line 17
Quoted 5 lines
lib/efi_loader/efi_image_loader.c +1
-0@@ -14,6 +14,7 @@#include <pe.h> #include <sort.h> #include "../lib/crypto/pkcs7_parser.h" +#include "../lib/crypto/x509_parser.h" As
pkcs7_parser.hincludesx509_parser.hthere is no reason to include it again.Quoted 7 lines
No, I don't think so.
My style of coding is that, if a symbol is used in a C file and it is defined in a header file, the header file should be *directly* included in the C file.
I believe that it is the common way so that we can avoid any "implicit" dependencies among header files.
Quoted 4 lines
We want U-Boot to build as fast as possible. So we should not include anything twice. When looking through the rest of the U-Boot code you will have noticed that we do not include
malloc.handstdio.heverywhere because it is included viacommon.h.
The same comment here.
-Takahiro Akashi
Quoted 42 lines
As an example of a patch removing other unnecessary includes see for instance:
cmd: fat: remove unused includes
fd0e30b43b6b2401e68dc32c357869c617d4fdd1Best regards
Heinrich
Quoted 31 lines
Thanks,
-Takahiro AkashiQuoted 26 lines
lib/efi_loader/efi_signature.c line 18
Quoted 12 lines
lib/efi_loader/efi_image_loader.c +0
-0const efi_guid_t efi_global_variable_guid =EFI_GLOBAL_VARIABLE_GUID ;const efi_guid_t efi_guid_device_path =EFI_DEVICE_PATH_PROTOCOL_GUID ;lib/efi_loader/efi_signature.c +1
-0@@ -15,6 +15,7 @@#include <u-boot/rsa.h> #include <u-boot/sha256.h> #include "../lib/crypto/pkcs7_parser.h" +#include "../lib/crypto/x509_parser.h" Same here.
The rest is correct and should be merged.
Best regards
Heinrich
Quoted 4 lines
lib/efi_loader/efi_signature.c +0
-0const efi_guid_t efi_guid_image_security_database =EFI_IMAGE_SECURITY_DATABASE_GUID ;
PATCH 1/1 lib/crypto, efi_loader: avoid multiple inclusions of header files
Quoted 13 lines · AKASHI Takahiro
Heinrich,
Quoted 10 lines · Heinrich Schuchardt
Quoted 9 lines · AKASHI Takahiro
Heinrich,
Quoted 6 lines · Heinrich Schuchardt
Quoted 5 lines · AKASHI Takahiro
By adding extra symbols, we can now avoid including
x509_parserandpkcs7_parser.hfiles multiple times.Signed-off-by AKASHI Takahiro <[email protected]>Suggested-by Heinrich Schuchardt <[email protected]>
Patch is merged. Thanks - Heinrich