mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH 2/3] bbu: command: Make sure specified update handler exists
Date: Thu, 4 Oct 2018 13:38:15 -0700	[thread overview]
Message-ID: <CAHQ1cqHiati+mx6_bkks2sKK7z+Jutj51HdJj8czGeUDY3prBg@mail.gmail.com> (raw)
In-Reply-To: <20180927114255.GY4097@pengutronix.de>

On Thu, Sep 27, 2018 at 4:42 AM Sascha Hauer <s.hauer@pengutronix.de> wrote:
>
> Hi Andrey,
>
> On Wed, Sep 26, 2018 at 09:11:28PM -0700, Andrey Smirnov wrote:
> > @@ -57,6 +62,30 @@ static int do_barebox_update(int argc, char *argv[])
> >               }
> >       }
> >
> > +     if (data.handler_name && data.devicefile) {
> > +             printf("Both TARGET and DEVICE are provided. "
> > +                    "Ignoring the latter\n");
> > +
> > +             data.devicefile = NULL;
> > +     }
> > +
> > +     if (data.handler_name &&
> > +         !bbu_find_handler_by_name(data.handler_name)) {
> > +             printf("handler '%s' does not exist\n",
> > +                    data.handler_name);
> > +             goto error;
> > +     } else if (data.devicefile &&
> > +                !bbu_find_handler_by_device(data.devicefile)) {
> > +             printf("handler for '%s' does not exist\n",
> > +                    data.devicefile);
> > +             goto error;
> > +     } if (!data.handler_name &&
> > +           !data.devicefile &&
> > +           !bbu_find_handler_by_name(NULL)) {
> > +             printf("default handler does not exist\n");
> > +             goto error;
> > +     }
>
> There should be a linebreak before the last if().
>
> Maybe it should be rewritten as:
>
>         if (data.handler_name)
>                 handler = bbu_find_handler_by_name();
>         else if (data.devicefile)
>                 handler = bbu_find_handler_by_device();
>         else
>                 handler = bbu_find_handler_by_name();
>
> barebox_update() currently repeats these steps, so I think it would be a
> next logical step to pass this handler to barebox_update() instead of
> searching it there again.
>

Yeah, makes sense. Will change in v2.

Thanks,
Andrey Smirnov

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2018-10-04 20:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-27  4:11 [PATCH 0/3] Additional error checking for barebox_update Andrey Smirnov
2018-09-27  4:11 ` [PATCH 1/3] bbu: Expose bbu_find_handler_by_*() functions Andrey Smirnov
2018-09-27  4:11 ` [PATCH 2/3] bbu: command: Make sure specified update handler exists Andrey Smirnov
2018-09-27 11:42   ` Sascha Hauer
2018-10-04 20:38     ` Andrey Smirnov [this message]
2018-09-27  4:11 ` [PATCH 3/3] bbu: Simplify bbu_find_handler_by_device() Andrey Smirnov

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=CAHQ1cqHiati+mx6_bkks2sKK7z+Jutj51HdJj8czGeUDY3prBg@mail.gmail.com \
    --to=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@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