From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eugeniu Rosca Date: Wed, 11 Jul 2018 22:59:51 +0200 Subject: [U-Boot] [PATCH v3 7/7] cmd: Add bind/unbind commands to bind a device to a driver from the command line In-Reply-To: <1529670334-21974-8-git-send-email-jjhiblot@ti.com> References: <1529670334-21974-1-git-send-email-jjhiblot@ti.com> <1529670334-21974-8-git-send-email-jjhiblot@ti.com> Message-ID: <20180711205951.GA25014@x230> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit To: u-boot@lists.denx.de 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.