From: Masahiro Yamada <yamada.m@jp.panasonic.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/8] dm: core: remove meaningless if conditional
Date: Mon, 17 Nov 2014 20:19:34 +0900 [thread overview]
Message-ID: <20141117201934.7D24.AA925319@jp.panasonic.com> (raw)
In-Reply-To: <CAPnjgZ0Cwt2E8FePapukeY9tu3huNfgo+cwUdU-nheDJ==q+Tw@mail.gmail.com>
Hi Simon,
On Mon, 17 Nov 2014 09:14:15 +0000
Simon Glass <sjg@chromium.org> wrote:
> Hi Masahiro,
>
> On 17 November 2014 08:19, Masahiro Yamada <yamada.m@jp.panasonic.com> wrote:
> > If the variable "ret" is equal to "-ENOENT", it is trapped at [1] and
> > never reaches [2]. At [3], the condition "ret != -ENOENT" is always
> > true.
> >
> > if (ret == -ENOENT) { <------------------ [1]
> > continue;
> > } else if (ret == -ENODEV) {
> > dm_dbg("Device '%s' has no compatible string\n", name);
> > break;
> > } else if (ret) { <------------------ [2]
> > dm_warn("Device tree error at offset %d\n", offset);
> > if (!result || ret != -ENOENT) <------------------ [3]
> > result = ret;
> > break;
> > }
> >
> > Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
> > ---
> >
> > drivers/core/lists.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/drivers/core/lists.c b/drivers/core/lists.c
> > index 3a1ea85..0aad56d 100644
> > --- a/drivers/core/lists.c
> > +++ b/drivers/core/lists.c
> > @@ -136,8 +136,7 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
> > break;
> > } else if (ret) {
> > dm_warn("Device tree error at offset %d\n", offset);
> > - if (!result || ret != -ENOENT)
> > - result = ret;
> > + result = ret;
>
> Thanks for the clear explanation.
> It looks good, except my intent was to return the first error, hence
> the 'if (!result ...'.
>
> Your code will return the last error. Can we preserve the current bahaviour?
Do you mean, like this?
dm_warn("Device tree error at offset %d\n", offset);
if (!result)
result = ret;
break;
I think there is no difference in the behaviour, because
this "for" loop is escaped out at the first encounter with an error
except -ENOENT.
Here is the only line to set "result" and it is followed by "break" statement,
so the last error is also the first error, I think.
Best Regards
Masahiro Yamada
next prev parent reply other threads:[~2014-11-17 11:19 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-17 8:19 [U-Boot] [PATCH 0/8] dm: core: abolish "u-boot, dm-pre-reloc" property and various refactorings Masahiro Yamada
2014-11-17 8:19 ` [U-Boot] [PATCH 1/8] dm: core: a trivial clean up Masahiro Yamada
2014-11-17 9:08 ` Simon Glass
2014-11-23 13:00 ` Simon Glass
2014-11-17 8:19 ` [U-Boot] [PATCH 2/8] dm: core: remove meaningless if conditional Masahiro Yamada
2014-11-17 9:14 ` Simon Glass
2014-11-17 11:19 ` Masahiro Yamada [this message]
2014-11-17 18:23 ` Simon Glass
2014-11-23 13:00 ` Simon Glass
2014-11-17 8:19 ` [U-Boot] [PATCH 3/8] dm: core: remove unnecessary return condition in driver lookup Masahiro Yamada
2014-11-17 9:14 ` Simon Glass
2014-11-23 13:00 ` Simon Glass
2014-11-17 8:19 ` [U-Boot] [PATCH 4/8] dm: core: remove unnecessary return condition in uclass lookup Masahiro Yamada
2014-11-17 9:16 ` Simon Glass
2014-11-23 13:00 ` Simon Glass
2014-11-17 8:19 ` [U-Boot] [PATCH 5/8] dm: core: refactor linker lists lookup code Masahiro Yamada
2014-11-17 9:18 ` Simon Glass
2014-11-17 8:19 ` [U-Boot] [PATCH 6/8] dm: core: look up drivers more efficiently Masahiro Yamada
2014-11-17 9:22 ` Simon Glass
2014-11-17 11:49 ` Masahiro Yamada
2014-11-17 18:25 ` Simon Glass
2014-11-17 8:19 ` [U-Boot] [PATCH 7/8] dm: core: declare pre-reloc drivers with U_BOOT_DRIVER_F Masahiro Yamada
2014-11-17 9:24 ` Simon Glass
2014-11-17 8:19 ` [U-Boot] [PATCH 8/8] dm: core: abolish u-boot, dm-pre-reloc property Masahiro Yamada
2014-11-17 18:17 ` Simon Glass
2014-11-18 12:51 ` Masahiro Yamada
2014-11-18 14:37 ` Simon Glass
2014-11-19 9:21 ` Masahiro Yamada
2014-11-20 16:44 ` Simon Glass
2014-11-20 17:16 ` Stephen Warren
2014-11-21 9:59 ` Masahiro Yamada
2014-11-24 22:29 ` Simon Glass
2014-11-25 3:18 ` Masahiro Yamada
2014-11-26 20:54 ` Simon Glass
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=20141117201934.7D24.AA925319@jp.panasonic.com \
--to=yamada.m@jp.panasonic.com \
--cc=u-boot@lists.denx.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