[U-Boot] [PATCH v3 7/7] cmd: Add bind/unbind commands to bind a device to a driver from the command line
Eugeniu Rosca
roscaeugeniu at gmail.com
Wed Jul 11 20:59:51 UTC 2018
Hi,
On Fri, Jun 22, 2018 at 02:25:34PM +0200, Jean-Jacques Hiblot wrote:
> +static int do_bind_unbind(cmd_tbl_t *cmdtp, int flag, int argc,
> + char * const argv[])
> +{
> + int ret;
> + bool bind;
> + bool by_node;
> +
> + if (argc < 2)
> + return CMD_RET_USAGE;
> +
> + bind = (argv[0][0] == 'b');
> + by_node = (argv[1][0] == '/');
> +
> + if (by_node && bind) {
> + if (argc != 3)
> + return CMD_RET_USAGE;
> + ret = bind_by_node_path(argv[1], argv[2]);
> + } else if (by_node && !bind) {
> + if (argc != 2)
> + return CMD_RET_USAGE;
> + ret = unbind_by_node_path(argv[1]);
> + } else if (!by_node && bind) {
> + int index = (argc > 2) ? simple_strtoul(argv[2], NULL, 10) : 0;
> +
> + if (argc != 4)
> + return CMD_RET_USAGE;
> + ret = bind_by_class_index(argv[1], index, argv[3]);
> + } else if (!by_node && !bind) {
> + int index = (argc > 2) ? simple_strtoul(argv[2], NULL, 10) : 0;
> +
> + if (argc == 3)
> + ret = unbind_by_class_index(argv[1], index);
> + else if (argc == 4)
> + ret = unbind_child_by_class_index(argv[1], index,
> + argv[3]);
> + else
> + return CMD_RET_USAGE;
> + }
> +
> + if (ret)
FWIW, gcc 7.3.0 complains at this line:
cmd/bind.c: In function ‘do_bind_unbind’:
cmd/bind.c:236:5: warning: ‘ret’ may be used uninitialized in this function [-Wmaybe-uninitialized]
if (ret)
^
> + return CMD_RET_FAILURE;
> + else
> + return CMD_RET_SUCCESS;
> +}
Best regards,
Eugeniu.
More information about the U-Boot
mailing list