All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Roy Franz <roy.franz@linaro.org>
Cc: keir@xen.org, ian.campbell@citrix.com, tim@xen.org,
	xen-devel@lists.xen.org, stefano.stabellini@citrix.com,
	linaro-uefi@lists.linaro.org, fu.wei@linaro.org
Subject: Re: [PATCH V2 06/12] add read_config_file() function for XEN EFI config file
Date: Thu, 24 Jul 2014 08:32:27 +0100	[thread overview]
Message-ID: <53D0D2AB020000780002560B@mail.emea.novell.com> (raw)
In-Reply-To: <1405989815-25236-7-git-send-email-roy.franz@linaro.org>

>>> On 22.07.14 at 02:43, <roy.franz@linaro.org> wrote:
> Move open-coded reading of the XEN EFI configuration file into a shared
> fuction read_config_file().

If the function is shared, why is it being placed in the x86 file instead
of the shared one (with again no declaration added to the shared
header)?

> +bool_t __init read_config_file(EFI_FILE_HANDLE *cfg_dir_handle,
> +                             struct file *cfg, CHAR16 *cfg_file_name,
> +                             union string *section,
> +                             CHAR16 *xen_file_name)
> +{
> +    /*
> +     * This allocation is internal to the EFI stub, so any address is
> +     * fine.
> +     */
> +    EFI_PHYSICAL_ADDRESS max = ~0;

Ah, okay, here comes the answer to the question I asked in an
earlier patch. However, using AllocateMaxAddress with an
unlimited address seems kind of bogus. I'd prefer this to be done
cleanly by passing a boolean into the function and having that one
use AllocateMaxAddress or AllocateAnyPages.

> +
> +    /* Read and parse the config file. */
> +    if ( !cfg_file_name )
> +    {
> +        CHAR16 *tail;
> +
> +        while ( (tail = point_tail(xen_file_name)) != NULL )
> +        {
> +            wstrcpy(tail, L".cfg");
> +            if ( read_file(*cfg_dir_handle, xen_file_name, cfg, max) )
> +                break;
> +            *tail = 0;
> +        }
> +        if ( !tail )
> +            return 0;
> +        PrintStr(L"Using configuration file '");
> +        PrintStr(xen_file_name);
> +        PrintStr(L"'\r\n");
> +    }
> +    else if ( !read_file(*cfg_dir_handle, cfg_file_name, cfg, max) )
> +        return 0;
> +    pre_parse(cfg);
> +
> +    if ( section->w )
> +        w2s(section);
> +    else
> +        section->s = get_value(cfg, "global", "default");
> +
> +
> +    for ( ; ; )
> +    {
> +        union string dom0_kernel_name;
> +        dom0_kernel_name.s = get_value(cfg, section->s, "kernel");
> +        if ( dom0_kernel_name.s )
> +            break;
> +        dom0_kernel_name.s = get_value(cfg, "global", "chain");

Please name the variable differently if it is used for other than the
purpose its current name implies.

Also there are again blank line issues above - I'm not going to
repeat respective comments made in an earlier patch, implying
that you'll take care of these issues throughout the series.

> @@ -855,53 +917,11 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
>      if ( EFI_ERROR(status) )
>          gop = NULL;
>  
> -    /* Read and parse the config file. */
> -    if ( !cfg_file_name )
> -    {
> -        CHAR16 *tail;
> +    if ( !read_config_file(&dir_handle, &cfg, cfg_file_name, &section,
> +                           file_name) )
> +        blexit(L"Unable to read configuration file.");
>  
> -        while ( (tail = point_tail(file_name)) != NULL )
> -        {
> -            wstrcpy(tail, L".cfg");
> -            if ( read_file(dir_handle, file_name, &cfg, max_addr) )
> -                break;
> -            *tail = 0;
> -        }
> -        if ( !tail )
> -            blexit(L"No configuration file found.");
> -        PrintStr(L"Using configuration file '");
> -        PrintStr(file_name);
> -        PrintStr(L"'\r\n");
> -    }
> -    else if ( !read_file(dir_handle, cfg_file_name, &cfg, max_addr) )
> -        blexit(L"Configuration file not found.");
> -    pre_parse(&cfg);
> -
> -    if ( section.w )
> -        w2s(&section);
> -    else
> -        section.s = get_value(&cfg, "global", "default");
> -
> -    for ( ; ; )
> -    {
> -        name.s = get_value(&cfg, section.s, "kernel");
> -        if ( name.s )
> -            break;
> -        name.s = get_value(&cfg, "global", "chain");
> -        if ( !name.s )
> -            break;
> -        efi_bs->FreePages(cfg.addr, PFN_UP(cfg.size));
> -        cfg.addr = 0;
> -        if ( !read_file(dir_handle, s2w(&name), &cfg, max_addr) )
> -        {
> -            PrintStr(L"Chained configuration file '");
> -            PrintStr(name.w);
> -            efi_bs->FreePool(name.w);
> -            blexit(L"'not found.");
> -        }
> -        pre_parse(&cfg);
> -        efi_bs->FreePool(name.w);
> -    }
> +    name.s = get_value(&cfg, section.s, "kernel");
>      if ( !name.s )
>          blexit(L"No Dom0 kernel image specified.");

This redundant lookup can be avoided by having the function return
not just a bool_t.

Jan

  reply	other threads:[~2014-07-24  7:32 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-22  0:43 [PATCH V2 00/12] arm64 EFI stub Roy Franz
2014-07-22  0:43 ` [PATCH V2 01/12] Create efi-shared.[ch], and move string functions Roy Franz
2014-07-23 16:31   ` Jan Beulich
2014-07-28 15:41     ` Ian Campbell
2014-07-28 15:52       ` Jan Beulich
2014-07-28 15:56         ` Ian Campbell
2014-07-28 16:00           ` Jan Beulich
2014-07-28 16:04             ` Ian Campbell
2014-07-28 16:10               ` Jan Beulich
2014-08-06 23:55                 ` Roy Franz
2014-08-07  6:17                   ` Jan Beulich
2014-08-09  0:27                     ` Roy Franz
2014-08-06 23:42     ` Roy Franz
2014-07-22  0:43 ` [PATCH V2 02/12] rename printErrMsg to PrintErrMesgExit Roy Franz
2014-07-23 16:33   ` Jan Beulich
2014-07-22  0:43 ` [PATCH V2 03/12] Refactor get_parent_handle for sharing Roy Franz
2014-07-23 16:37   ` Jan Beulich
2014-07-22  0:43 ` [PATCH V2 04/12] Refactor read_file() so it can be shared Roy Franz
2014-07-24  7:09   ` Jan Beulich
2014-08-06 18:38     ` Roy Franz
2014-08-07  6:20       ` Jan Beulich
2014-08-07 17:26         ` Roy Franz
2014-07-22  0:43 ` [PATCH V2 05/12] replace split_value() with truncate_string() Roy Franz
2014-07-24  7:19   ` Jan Beulich
2014-08-06 22:37     ` Roy Franz
2014-08-07  6:24       ` Jan Beulich
2014-08-18 23:38         ` Roy Franz
2014-08-19 12:56           ` Jan Beulich
2014-07-22  0:43 ` [PATCH V2 06/12] add read_config_file() function for XEN EFI config file Roy Franz
2014-07-24  7:32   ` Jan Beulich [this message]
2014-08-06 22:42     ` Roy Franz
2014-07-22  0:43 ` [PATCH V2 07/12] create handle_cmdline() function Roy Franz
2014-07-24  7:36   ` Jan Beulich
2014-07-28 15:44     ` Ian Campbell
2014-07-28 15:57       ` Jan Beulich
2014-07-22  0:43 ` [PATCH V2 08/12] Refactor get_argv() for sharing Roy Franz
2014-07-24  7:38   ` Jan Beulich
2014-07-22  0:43 ` [PATCH V2 09/12] Move shared EFI functions to efi-shared.c Roy Franz
2014-07-22  0:43 ` [PATCH V2 10/12] add arm64 cache flushing code from linux Roy Franz
2014-07-28 15:53   ` Ian Campbell
2014-07-28 16:24     ` Ian Campbell
2014-07-22  0:43 ` [PATCH V2 11/12] Add fdt_create_empty_tree() function Roy Franz
2014-07-22 16:36   ` [Linaro-uefi] " Julien Grall
2014-07-22 17:12     ` Roy Franz
2014-07-22 17:15       ` Julien Grall
2014-07-23  9:58         ` Ian Campbell
2014-07-23 16:15           ` Roy Franz
2014-07-22  0:43 ` [PATCH V2 12/12] Add EFI stub for arm64 Roy Franz
2014-07-29  9:46   ` Ian Campbell
2014-07-28 15:30 ` [PATCH V2 00/12] arm64 EFI stub Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53D0D2AB020000780002560B@mail.emea.novell.com \
    --to=jbeulich@suse.com \
    --cc=fu.wei@linaro.org \
    --cc=ian.campbell@citrix.com \
    --cc=keir@xen.org \
    --cc=linaro-uefi@lists.linaro.org \
    --cc=roy.franz@linaro.org \
    --cc=stefano.stabellini@citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.