mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Marco Felsch <m.felsch@pengutronix.de>, barebox@lists.infradead.org
Subject: Re: [PATCH] restart: fix restart handler by name selection
Date: Thu, 2 Jul 2026 15:40:31 +0200	[thread overview]
Message-ID: <f81603e6-d35b-4b73-a113-21d7be6f1066@pengutronix.de> (raw)
In-Reply-To: <20260622172121.1736295-1-m.felsch@pengutronix.de>

Hello,

On 6/22/26 7:21 PM, Marco Felsch wrote:
> Commit d20a9a455d8d ("restart: allow selecting restart handler by device
> name") introduce a bug, while adding the support to select a restart
> handler by device name.
> 
> The list_for_each_entry() loop should sort out all restart handler which
> don't match the user requested restart handler. Instead all restart
> handlers which don't have a device associated are honored as well
> because the if condition is always 0 in this case.
> 
> Split the if to fix this and add a helper variable to make the code more
> readable.
> 
> Fixes: d20a9a455d8d ("restart: allow selecting restart handler by device name")
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>

Why do we have restart handlers without a device name?

Cheers,
Ahmad

> ---
>  common/restart.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/common/restart.c b/common/restart.c
> index 391d7bd3773c..85519912170d 100644
> --- a/common/restart.c
> +++ b/common/restart.c
> @@ -117,8 +117,13 @@ struct restart_handler *restart_handler_get_by_name(const char *name, int flags)
>  
>  	list_for_each_entry(tmp, &restart_handler_list, list) {
>  		if (name) {
> -			if ((tmp->name && strcmp(name, tmp->name)) &&
> -			    (tmp->dev && strcmp(name, dev_name(tmp->dev))))
> +			bool found = false;
> +
> +			if (tmp->name && !strcmp(name, tmp->name))
> +				found = true;
> +			if (tmp->dev && !strcmp(name, dev_name(tmp->dev)))
> +				found = true;
> +			if (!found)
>  				continue;
>  		}
>  

-- 
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 |




  parent reply	other threads:[~2026-07-02 13:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-22 17:21 Marco Felsch
2026-07-02  7:58 ` Sascha Hauer
2026-07-02 13:40 ` Ahmad Fatoum [this message]
2026-07-02 13:51   ` Marco Felsch
2026-07-02 14:02     ` Ahmad Fatoum

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=f81603e6-d35b-4b73-a113-21d7be6f1066@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=m.felsch@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