On 01/14/20 10:25, Gerd Hoffmann wrote:
> Call find_prio("HALT") only once, on first is_bootprio_strict() call.
> Store the result in a variable and reuse it on subsequent calls.
> 
> Signed-off-by: Gerd Hoffmann <[email protected]>
> ---
>  src/boot.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/boot.c b/src/boot.c
> index 5182ab426b9f..afeb36a3319a 100644
> --- a/src/boot.c
> +++ b/src/boot.c
> @@ -297,7 +297,11 @@ find_prio(const char *glob)
>  
>  u8 is_bootprio_strict(void)
>  {
> -    return find_prio("HALT") >= 0;
> +    static int prio_halt = -2;
> +
> +    if (prio_halt == -2)
> +        prio_halt = find_prio("HALT");
> +    return prio_halt >= 0;
>  }
>  
>  int bootprio_find_pci_device(struct pci_device *pci)
> 

General question. Is it safe to use static variables in this file with
initializers, i.e. without assigning their initial values through
statements?

What happens at reset? In particular, the "bootorder" fw_cfg file may
change across reset. (I'm not certain if specifically "HALT" can change
in "bootorder" across reset.)

I've found two static variables in this file:

static BootDevice *BootDevices VARVERIFY32INIT;
static int BootDeviceCount;

They seem to be set explicitly (in assignment statements) in the
loadBootDevices() function. "BootDeviceCount" seems to support my
concern, because

    BootDeviceCount = 0;

is otherwise redundant, given:

static int BootDeviceCount;

I realize this is a very basic question to someone closely familiar with
the SeaBIOS architecture. Thanks for bearing with me!

Laszlo
_______________________________________________
SeaBIOS mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to