[PATCH v2 4/5] include: u-boot: aes: make disabled cipher stubs static inline

Pranav Rajendran <[email protected]>
Newsgroups org.u-boot-project.lists.u-boot
Message-ID <[email protected]>
image_aes_encrypt(), image_aes_add_cipher_data() and image_aes_decrypt()
are defined directly in this header, with full bodies rather than just
prototypes, whenever the corresponding IMAGE_ENABLE_ENCRYPT/DECRYPT
feature macro is 0. On target that is always the encrypt side, since
ciphering is host-tool only.

Those definitions have external linkage, so a second translation unit
including this header under the same disabled configuration collides
with the first at link time. Only boot/image-cipher.c currently
includes the header on target, so this has not been reachable before,
but it stops any other file - such as a unit test - from including it
too.

Make the disabled-path stubs static inline, as is conventional for
header-defined no-op fallbacks, so the header can be included from more
than one translation unit.

Signed-off-by: Pranav Rajendran <[email protected]>
---
v2:
- New in v2. Needed by patch 5: the new fit_cipher test suite is a
  second translation unit including this header under the same
  disabled configuration, which failed to link before this change.

 include/u-boot/aes.h | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/include/u-boot/aes.h b/include/u-boot/aes.h
index acbc50b9e6f..d72322c1013 100644
--- a/include/u-boot/aes.h
+++ b/include/u-boot/aes.h
@@ -16,15 +16,16 @@ int image_aes_encrypt(struct image_cipher_info *info,
 int image_aes_add_cipher_data(struct image_cipher_info *info, void *keydest,
 			      void *fit, int node_noffset);
 #else
-int image_aes_encrypt(struct image_cipher_info *info,
-		      const unsigned char *data, int size,
-		      unsigned char **cipher, int *cipher_len)
+static inline int image_aes_encrypt(struct image_cipher_info *info,
+				    const unsigned char *data, int size,
+				    unsigned char **cipher, int *cipher_len)
 {
 	return -ENXIO;
 }
 
-int image_aes_add_cipher_data(struct image_cipher_info *info, void *keydest,
-			      void *fit, int node_noffset)
+static inline int image_aes_add_cipher_data(struct image_cipher_info *info,
+					    void *keydest, void *fit,
+					    int node_noffset)
 {
 	return -ENXIO;
 }
@@ -35,9 +36,9 @@ int image_aes_decrypt(struct image_cipher_info *info,
 		      const void *cipher, size_t cipher_len,
 		      void **data, size_t *size);
 #else
-int image_aes_decrypt(struct image_cipher_info *info,
-		      const void *cipher, size_t cipher_len,
-		      void **data, size_t *size)
+static inline int image_aes_decrypt(struct image_cipher_info *info,
+				    const void *cipher, size_t cipher_len,
+				    void **data, size_t *size)
 {
 	return -ENXIO;
 }
-- 
2.50.1 (Apple Git-155)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.