Re: [RFC PATCH v1 07/12] efi: Replace strstarts() by str_has_prefix().

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 4 Dec 2020 at 18:06, <laniel_francis@xxxxxxxxxxxxxxxxxxx> wrote:
>
> From: Francis Laniel <laniel_francis@xxxxxxxxxxxxxxxxxxx>
>
> The two functions indicates if a string begins with a given prefix.
> The only difference is that strstarts() returns a bool while str_has_prefix()
> returns the length of the prefix if the string begins with it or 0 otherwise.
>

Why?

> Signed-off-by: Francis Laniel <laniel_francis@xxxxxxxxxxxxxxxxxxx>
> ---
>  drivers/firmware/efi/libstub/efi-stub-helper.c |  2 +-
>  drivers/firmware/efi/libstub/gop.c             | 10 +++++-----
>  2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
> index aa8da0a49829..a502f549d900 100644
> --- a/drivers/firmware/efi/libstub/efi-stub-helper.c
> +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
> @@ -230,7 +230,7 @@ efi_status_t efi_parse_options(char const *cmdline)
>                         if (parse_option_str(val, "debug"))
>                                 efi_loglevel = CONSOLE_LOGLEVEL_DEBUG;
>                 } else if (!strcmp(param, "video") &&
> -                          val && strstarts(val, "efifb:")) {
> +                          val && str_has_prefix(val, "efifb:")) {
>                         efi_parse_option_graphics(val + strlen("efifb:"));
>                 }
>         }
> diff --git a/drivers/firmware/efi/libstub/gop.c b/drivers/firmware/efi/libstub/gop.c
> index ea5da307d542..fbe95b3cc96a 100644
> --- a/drivers/firmware/efi/libstub/gop.c
> +++ b/drivers/firmware/efi/libstub/gop.c
> @@ -39,7 +39,7 @@ static bool parse_modenum(char *option, char **next)
>  {
>         u32 m;
>
> -       if (!strstarts(option, "mode="))
> +       if (!str_has_prefix(option, "mode="))
>                 return false;
>         option += strlen("mode=");
>         m = simple_strtoull(option, &option, 0);
> @@ -65,10 +65,10 @@ static bool parse_res(char *option, char **next)
>         h = simple_strtoull(option, &option, 10);
>         if (*option == '-') {
>                 option++;
> -               if (strstarts(option, "rgb")) {
> +               if (str_has_prefix(option, "rgb")) {
>                         option += strlen("rgb");
>                         pf = PIXEL_RGB_RESERVED_8BIT_PER_COLOR;
> -               } else if (strstarts(option, "bgr")) {
> +               } else if (str_has_prefix(option, "bgr")) {
>                         option += strlen("bgr");
>                         pf = PIXEL_BGR_RESERVED_8BIT_PER_COLOR;
>                 } else if (isdigit(*option))
> @@ -90,7 +90,7 @@ static bool parse_res(char *option, char **next)
>
>  static bool parse_auto(char *option, char **next)
>  {
> -       if (!strstarts(option, "auto"))
> +       if (!str_has_prefix(option, "auto"))
>                 return false;
>         option += strlen("auto");
>         if (*option && *option++ != ',')
> @@ -103,7 +103,7 @@ static bool parse_auto(char *option, char **next)
>
>  static bool parse_list(char *option, char **next)
>  {
> -       if (!strstarts(option, "list"))
> +       if (!str_has_prefix(option, "list"))
>                 return false;
>         option += strlen("list");
>         if (*option && *option++ != ',')
> --
> 2.20.1
>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux