]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
efi_loader: treat UEFI variable name as const
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Thu, 9 Sep 2021 05:12:14 +0000 (07:12 +0200)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Mon, 25 Oct 2021 19:13:06 +0000 (21:13 +0200)
UEFI variable names are typically constants and hence should be defined as
const. Unfortunately some of our API functions do not define the parameters
for UEFI variable names as const. This requires unnecessary conversions.

Adjust parameters of several internal functions to tre UEFI variable names
as const.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
include/efi_loader.h
include/efi_variable.h
lib/efi_loader/efi_tcg2.c
lib/efi_loader/efi_var_common.c
lib/efi_loader/efi_var_mem.c
lib/efi_loader/efi_variable.c
lib/efi_loader/efi_variable_tee.c

index 3e5ac3804249b859449e4f428b112cadef48aae1..f6d65a6c0c29c2be9c9822dee7b03de523cc3bb5 100644 (file)
@@ -818,7 +818,7 @@ efi_status_t EFIAPI efi_query_variable_info(
                        u64 *remaining_variable_storage_size,
                        u64 *maximum_variable_size);
 
-void *efi_get_var(u16 *name, const efi_guid_t *vendor, efi_uintn_t *size);
+void *efi_get_var(const u16 *name, const efi_guid_t *vendor, efi_uintn_t *size);
 
 /*
  * See section 3.1.3 in the v2.7 UEFI spec for more details on
index 0440d356bc896ce463fa8829eec1ca47d4aafa3e..8f666b23096be52c6d0a1283296c0cb9e8792e54 100644 (file)
@@ -32,7 +32,8 @@ enum efi_auth_var_type {
  * @timep:             authentication time (seconds since start of epoch)
  * Return:             status code
  */
-efi_status_t efi_get_variable_int(u16 *variable_name, const efi_guid_t *vendor,
+efi_status_t efi_get_variable_int(const u16 *variable_name,
+                                 const efi_guid_t *vendor,
                                  u32 *attributes, efi_uintn_t *data_size,
                                  void *data, u64 *timep);
 
@@ -47,7 +48,8 @@ efi_status_t efi_get_variable_int(u16 *variable_name, const efi_guid_t *vendor,
  * @ro_check:          check the read only read only bit in attributes
  * Return:             status code
  */
-efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor,
+efi_status_t efi_set_variable_int(const u16 *variable_name,
+                                 const efi_guid_t *vendor,
                                  u32 attributes, efi_uintn_t data_size,
                                  const void *data, bool ro_check);
 
@@ -224,7 +226,7 @@ void efi_var_mem_del(struct efi_var_entry *var);
  * @time:              time of authentication (as seconds since start of epoch)
  * Result:             status code
  */
-efi_status_t efi_var_mem_ins(u16 *variable_name,
+efi_status_t efi_var_mem_ins(const u16 *variable_name,
                             const efi_guid_t *vendor, u32 attributes,
                             const efi_uintn_t size1, const void *data1,
                             const efi_uintn_t size2, const void *data2,
@@ -251,7 +253,8 @@ efi_status_t efi_init_secure_state(void);
  * @guid:      guid of UEFI variable
  * Return:     identifier for authentication related variables
  */
-enum efi_auth_var_type efi_auth_var_get_type(u16 *name, const efi_guid_t *guid);
+enum efi_auth_var_type efi_auth_var_get_type(const u16 *name,
+                                            const efi_guid_t *guid);
 
 /**
  * efi_get_next_variable_name_mem() - Runtime common code across efi variable
@@ -280,8 +283,9 @@ efi_get_next_variable_name_mem(efi_uintn_t *variable_name_size, u16 *variable_na
  * Return:             status code
  */
 efi_status_t __efi_runtime
-efi_get_variable_mem(u16 *variable_name, const efi_guid_t *vendor, u32 *attributes,
-                    efi_uintn_t *data_size, void *data, u64 *timep);
+efi_get_variable_mem(const u16 *variable_name, const efi_guid_t *vendor,
+                    u32 *attributes, efi_uintn_t *data_size, void *data,
+                    u64 *timep);
 
 /**
  * efi_get_variable_runtime() - runtime implementation of GetVariable()
index 74f0bef23965c7b752c04c974d433336bf958b9a..cd214ded3c5616f88fd2c6ef62f814d40a3fbe25 100644 (file)
@@ -1366,7 +1366,7 @@ static efi_status_t efi_append_scrtm_version(struct udevice *dev)
  * Return:     status code
  */
 static efi_status_t tcg2_measure_variable(struct udevice *dev, u32 pcr_index,
-                                         u32 event_type, u16 *var_name,
+                                         u32 event_type, const u16 *var_name,
                                          const efi_guid_t *guid,
                                          efi_uintn_t data_size, u8 *data)
 {
index a00bbf16206d2d6e4a5f93f04ba95d3730ab19e4..e179932124a547c8a0e0f363a60df821e17f0502 100644 (file)
@@ -374,7 +374,8 @@ bool efi_secure_boot_enabled(void)
        return efi_secure_boot;
 }
 
-enum efi_auth_var_type efi_auth_var_get_type(u16 *name, const efi_guid_t *guid)
+enum efi_auth_var_type efi_auth_var_get_type(const u16 *name,
+                                            const efi_guid_t *guid)
 {
        for (size_t i = 0; i < ARRAY_SIZE(name_type); ++i) {
                if (!u16_strcmp(name, name_type[i].name) &&
@@ -393,7 +394,7 @@ enum efi_auth_var_type efi_auth_var_get_type(u16 *name, const efi_guid_t *guid)
  *
  * Return:     buffer with variable data or NULL
  */
-void *efi_get_var(u16 *name, const efi_guid_t *vendor, efi_uintn_t *size)
+void *efi_get_var(const u16 *name, const efi_guid_t *vendor, efi_uintn_t *size)
 {
        efi_status_t ret;
        void *buf = NULL;
index 3d335a8274682fcd5ee689f6a524baaacbbdee9f..13909b1d263836f0c1625c7479f685ef7f03918c 100644 (file)
@@ -134,7 +134,7 @@ void __efi_runtime efi_var_mem_del(struct efi_var_entry *var)
 }
 
 efi_status_t __efi_runtime efi_var_mem_ins(
-                               u16 *variable_name,
+                               const u16 *variable_name,
                                const efi_guid_t *vendor, u32 attributes,
                                const efi_uintn_t size1, const void *data1,
                                const efi_uintn_t size2, const void *data2,
@@ -274,8 +274,9 @@ efi_status_t efi_var_mem_init(void)
 }
 
 efi_status_t __efi_runtime
-efi_get_variable_mem(u16 *variable_name, const efi_guid_t *vendor, u32 *attributes,
-                    efi_uintn_t *data_size, void *data, u64 *timep)
+efi_get_variable_mem(const u16 *variable_name, const efi_guid_t *vendor,
+                    u32 *attributes, efi_uintn_t *data_size, void *data,
+                    u64 *timep)
 {
        efi_uintn_t old_size;
        struct efi_var_entry *var;
index fa2b6bc7a8697670f0163026b8eb88d73122cfa8..5adc7f821a804cf8f804df1d673bc1704576d2ae 100644 (file)
@@ -45,7 +45,7 @@
  *
  * Return:     status code
  */
-static efi_status_t efi_variable_authenticate(u16 *variable,
+static efi_status_t efi_variable_authenticate(const u16 *variable,
                                              const efi_guid_t *vendor,
                                              efi_uintn_t *data_size,
                                              const void **data, u32 given_attr,
@@ -194,7 +194,7 @@ err:
        return ret;
 }
 #else
-static efi_status_t efi_variable_authenticate(u16 *variable,
+static efi_status_t efi_variable_authenticate(const u16 *variable,
                                              const efi_guid_t *vendor,
                                              efi_uintn_t *data_size,
                                              const void **data, u32 given_attr,
@@ -205,7 +205,7 @@ static efi_status_t efi_variable_authenticate(u16 *variable,
 #endif /* CONFIG_EFI_SECURE_BOOT */
 
 efi_status_t __efi_runtime
-efi_get_variable_int(u16 *variable_name, const efi_guid_t *vendor,
+efi_get_variable_int(const u16 *variable_name, const efi_guid_t *vendor,
                     u32 *attributes, efi_uintn_t *data_size, void *data,
                     u64 *timep)
 {
@@ -219,7 +219,8 @@ efi_get_next_variable_name_int(efi_uintn_t *variable_name_size,
        return efi_get_next_variable_name_mem(variable_name_size, variable_name, vendor);
 }
 
-efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor,
+efi_status_t efi_set_variable_int(const u16 *variable_name,
+                                 const efi_guid_t *vendor,
                                  u32 attributes, efi_uintn_t data_size,
                                  const void *data, bool ro_check)
 {
index 51920bcb51aaf248a2a37c3b8d9fbc3cfd7cb36d..281f886124af5a778c262a9f970d496c6a51de01 100644 (file)
@@ -284,7 +284,8 @@ out:
  * StMM can store internal attributes and properties for variables, i.e enabling
  * R/O variables
  */
-static efi_status_t set_property_int(u16 *variable_name, efi_uintn_t name_size,
+static efi_status_t set_property_int(const u16 *variable_name,
+                                    efi_uintn_t name_size,
                                     const efi_guid_t *vendor,
                                     struct var_check_property *var_property)
 {
@@ -317,7 +318,8 @@ out:
        return ret;
 }
 
-static efi_status_t get_property_int(u16 *variable_name, efi_uintn_t name_size,
+static efi_status_t get_property_int(const u16 *variable_name,
+                                    efi_uintn_t name_size,
                                     const efi_guid_t *vendor,
                                     struct var_check_property *var_property)
 {
@@ -361,7 +363,8 @@ out:
        return ret;
 }
 
-efi_status_t efi_get_variable_int(u16 *variable_name, const efi_guid_t *vendor,
+efi_status_t efi_get_variable_int(const u16 *variable_name,
+                                 const efi_guid_t *vendor,
                                  u32 *attributes, efi_uintn_t *data_size,
                                  void *data, u64 *timep)
 {
@@ -502,9 +505,10 @@ out:
        return ret;
 }
 
-efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor,
-                                 u32 attributes, efi_uintn_t data_size,
-                                 const void *data, bool ro_check)
+efi_status_t efi_set_variable_int(const u16 *variable_name,
+                                 const efi_guid_t *vendor, u32 attributes,
+                                 efi_uintn_t data_size, const void *data,
+                                 bool ro_check)
 {
        efi_status_t ret, alt_ret = EFI_SUCCESS;
        struct var_check_property var_property;