* [PATCH] restart: fix restart handler by name selection
@ 2026-06-22 17:21 Marco Felsch
2026-07-02 7:58 ` Sascha Hauer
2026-07-02 13:40 ` Ahmad Fatoum
0 siblings, 2 replies; 5+ messages in thread
From: Marco Felsch @ 2026-06-22 17:21 UTC (permalink / raw)
To: barebox
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>
---
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;
}
--
2.47.3
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] restart: fix restart handler by name selection
2026-06-22 17:21 [PATCH] restart: fix restart handler by name selection Marco Felsch
@ 2026-07-02 7:58 ` Sascha Hauer
2026-07-02 13:40 ` Ahmad Fatoum
1 sibling, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2026-07-02 7:58 UTC (permalink / raw)
To: barebox, Marco Felsch
On Mon, 22 Jun 2026 19:21:19 +0200, 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.
>
> [...]
Applied, thanks!
[1/1] restart: fix restart handler by name selection
https://git.pengutronix.de/cgit/barebox/commit/?id=8bd9cab774e9 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] restart: fix restart handler by name selection
2026-06-22 17:21 [PATCH] restart: fix restart handler by name selection Marco Felsch
2026-07-02 7:58 ` Sascha Hauer
@ 2026-07-02 13:40 ` Ahmad Fatoum
2026-07-02 13:51 ` Marco Felsch
1 sibling, 1 reply; 5+ messages in thread
From: Ahmad Fatoum @ 2026-07-02 13:40 UTC (permalink / raw)
To: Marco Felsch, barebox
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 |
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] restart: fix restart handler by name selection
2026-07-02 13:40 ` Ahmad Fatoum
@ 2026-07-02 13:51 ` Marco Felsch
2026-07-02 14:02 ` Ahmad Fatoum
0 siblings, 1 reply; 5+ messages in thread
From: Marco Felsch @ 2026-07-02 13:51 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox
On 26-07-02, Ahmad Fatoum wrote:
> 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?
Because it's not required for them to have a device associated, e.g.
each restart_handler_register_fn() user doesn't have a device set.
Regards,
Marco
>
> 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 |
>
>
--
#gernperDu
#CallMeByMyFirstName
Pengutronix e.K. | |
Steuerwalder Str. 21 | https://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] restart: fix restart handler by name selection
2026-07-02 13:51 ` Marco Felsch
@ 2026-07-02 14:02 ` Ahmad Fatoum
0 siblings, 0 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2026-07-02 14:02 UTC (permalink / raw)
To: Marco Felsch; +Cc: barebox
On 7/2/26 3:51 PM, Marco Felsch wrote:
> On 26-07-02, Ahmad Fatoum wrote:
>> 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?
>
> Because it's not required for them to have a device associated, e.g.
> each restart_handler_register_fn() user doesn't have a device set.
Ah, thanks for fixing.
Cheers,
Ahmad
>
> Regards,
> Marco
>
>>
>> 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 |
>>
>>
>
--
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 |
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-07-02 14:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-22 17:21 [PATCH] restart: fix restart handler by name selection Marco Felsch
2026-07-02 7:58 ` Sascha Hauer
2026-07-02 13:40 ` Ahmad Fatoum
2026-07-02 13:51 ` Marco Felsch
2026-07-02 14:02 ` Ahmad Fatoum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox