[U-Boot] [PATCH v3 03/21] efi: Move the init check inside efi_init_obj_list()

Heinrich Schuchardt xypron.glpk at gmx.de
Mon Feb 19 19:35:47 UTC 2018


On 02/19/2018 04:48 PM, Simon Glass wrote:
> Rather than having the caller check this variable and the callee set it,
> move all access to the variable inside the function. This reduces the
> logic needed to call efi_init_obj_list().
> 
> Fix the spelling of initalized at the same time to fix a patman warning on
> this patch.

We should have only one location from wehre we call efi_init_obj_list().

We should be able to distinguish between a successful and a failed 
initialization. If the initialization has failed we should not allow 
bootefi to execute.

This patch is duplicate to the
https://lists.denx.de/pipermail/u-boot/2018-February/320487.html
patch series.

Regards

Heinrich

> 
> Signed-off-by: Simon Glass <sjg at chromium.org>
> Reviewed: Heinrich Schuchardt <xypron.glpk at gmx.de>
> ---
> 
> Changes in v3:
> - Avoid adding a new call to efi_init_obj_list()
> - Fix spelling of initalized
> 
> Changes in v2: None
> 
>   cmd/bootefi.c | 15 +++++++--------
>   1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> index 2106ed9c8c..064c069757 100644
> --- a/cmd/bootefi.c
> +++ b/cmd/bootefi.c
> @@ -22,7 +22,7 @@
>   
>   DECLARE_GLOBAL_DATA_PTR;
>   
> -static uint8_t efi_obj_list_initalized;
> +static uint8_t efi_obj_list_initialised;
>   
>   static struct efi_device_path *bootefi_image_path;
>   static struct efi_device_path *bootefi_device_path;
> @@ -30,7 +30,9 @@ static struct efi_device_path *bootefi_device_path;
>   /* Initialize and populate EFI object list */
>   static void efi_init_obj_list(void)
>   {
> -	efi_obj_list_initalized = 1;
> +	if (efi_obj_list_initialised)
> +		return;
> +	efi_obj_list_initialised = 1;
>   
>   	/* Initialize EFI driver uclass */
>   	efi_driver_init();
> @@ -184,8 +186,7 @@ static efi_status_t do_bootefi_exec(void *efi, void *fdt,
>   	}
>   
>   	/* Initialize and populate EFI object list */
> -	if (!efi_obj_list_initalized)
> -		efi_init_obj_list();
> +	efi_init_obj_list();
>   
>   	efi_setup_loaded_image(&loaded_image_info, &loaded_image_info_obj,
>   			       device_path, image_path);
> @@ -284,8 +285,7 @@ static int do_bootefi_bootmgr_exec(unsigned long fdt_addr)
>   	efi_status_t r;
>   
>   	/* Initialize and populate EFI object list */
> -	if (!efi_obj_list_initalized)
> -		efi_init_obj_list();
> +	efi_init_obj_list();
>   
>   	/*
>   	 * gd lives in a fixed register which may get clobbered while we execute
> @@ -350,8 +350,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>   		 */
>   		efi_save_gd();
>   		/* Initialize and populate EFI object list */
> -		if (!efi_obj_list_initalized)
> -			efi_init_obj_list();
> +		efi_init_obj_list();
>   		/* Transfer environment variable efi_selftest as load options */
>   		set_load_options(&loaded_image_info, "efi_selftest");
>   		/* Execute the test */
> 



More information about the U-Boot mailing list