Fix type of cot_desc_ptr
authorSandrine Bailleux <sandrine.bailleux@arm.com>
Fri, 7 Jun 2019 12:33:51 +0000 (14:33 +0200)
committerSandrine Bailleux <sandrine.bailleux@arm.com>
Thu, 13 Jun 2019 10:53:17 +0000 (12:53 +0200)
The chain of trust description and the pointer pointing to its first
element were incompatible, thus requiring an explicit type cast for
the assignment.

- cot_desc was an array of
  const pointers to const image descriptors.

- cot_desc_ptr was a const pointer to
  (non-constant) pointers to const image descriptors.

Thus, trying to assign cot_desc to cot_desc_ptr (with no cast) would
generate the following compiler warning:

drivers/auth/tbbr/tbbr_cot.c:826:14: warning: initialization discards
  â€˜const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
 REGISTER_COT(cot_desc);
              ^~~~~~~~

Change-Id: Iae62dd1bdb43fe379e3843d96461d47cc2f68a06
Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
drivers/auth/auth_mod.c
include/drivers/auth/auth_mod.h

index 01f8f2905682ac5f0d3aa51280c6d4d657e98eab..a6538c4e5cad510bf45e365cccae157d7b8fac22 100644 (file)
@@ -31,7 +31,7 @@
 #pragma weak plat_set_nv_ctr2
 
 /* Pointer to CoT */
-extern const auth_img_desc_t **const cot_desc_ptr;
+extern const auth_img_desc_t *const *const cot_desc_ptr;
 extern unsigned int auth_img_flags[MAX_NUMBER_IDS];
 
 static int cmp_auth_param_type_desc(const auth_param_type_desc_t *a,
index 39f5372e51256b81a6fef0ae5fa56034b87211f8..6c48124b55323be781f3c9b7629946f2a950cacf 100644 (file)
@@ -40,11 +40,10 @@ int auth_mod_verify_img(unsigned int img_id,
 
 /* Macro to register a CoT defined as an array of auth_img_desc_t pointers */
 #define REGISTER_COT(_cot) \
-       const auth_img_desc_t **const cot_desc_ptr = \
-                       (const auth_img_desc_t **const)_cot; \
+       const auth_img_desc_t *const *const cot_desc_ptr = (_cot); \
        unsigned int auth_img_flags[MAX_NUMBER_IDS]
 
-extern const auth_img_desc_t **const cot_desc_ptr;
+extern const auth_img_desc_t *const *const cot_desc_ptr;
 extern unsigned int auth_img_flags[MAX_NUMBER_IDS];
 
 #endif /* TRUSTED_BOARD_BOOT */