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.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to