mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Oleksij Rempel <o.rempel@pengutronix.de>, barebox@lists.infradead.org
Subject: Re: [PATCH v1] of: add sanity check for machine compatible string
Date: Wed, 29 May 2024 12:30:16 +0200	[thread overview]
Message-ID: <f654f2dc-2741-4e7e-92fe-e22fdef46ef2@pengutronix.de> (raw)
In-Reply-To: <20240529093308.502072-1-o.rempel@pengutronix.de>

On 29.05.24 11:33, Oleksij Rempel wrote:
> Add a sanity check in of_get_machine_compatible to ensure we fall back
> to the default hostname "barebox" when the machine compatible string is
> empty. This prevents scenarios where no hostname is set, which can occur
> when starting an STM32 version of Barebox as a second stage on top of
> Barebox prior to commit 1da26bfb9da2 ("common: don't fixup empty serial/
> machine_compatible strings"). This fallback makes debugging easier in
> case someone faces a similar issue.
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

> ---
>  drivers/of/base.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 2213165fd7..62d84786ae 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -3416,7 +3416,7 @@ const char *of_get_machine_compatible(void)
>  		return NULL;
>  
>  	p = strchr(name, ',');
> -	return p ? p + 1 : name;
> +	return nonempty(p ? p + 1 : name);

An alternative would be return `p ? p + 1 : nonempty(name);`, but that's
not really more readable, so the current change is alright.

Thanks!
Ahmad

>  }
>  EXPORT_SYMBOL(of_get_machine_compatible);
>  

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




  reply	other threads:[~2024-05-29 10:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-29  9:33 Oleksij Rempel
2024-05-29 10:30 ` Ahmad Fatoum [this message]
2024-05-30 13:27 ` Sascha Hauer

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=f654f2dc-2741-4e7e-92fe-e22fdef46ef2@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=o.rempel@pengutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox