sandbox: Disintangle declarations in do_host_bind()
This function has a strange mix of declarations and argument parsing which is a bit hard to follow and harder to modify. Separate out the declarations at the start of the function and adjust the ordering of the code slightly. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
a5bc9abcee
commit
1503c2c790
13
cmd/host.c
13
cmd/host.c
|
@ -41,16 +41,21 @@ static int do_host_save(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
static int do_host_bind(struct cmd_tbl *cmdtp, int flag, int argc,
|
static int do_host_bind(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
char *const argv[])
|
char *const argv[])
|
||||||
{
|
{
|
||||||
|
const char *dev_str;
|
||||||
|
char *file;
|
||||||
|
char *ep;
|
||||||
|
int dev;
|
||||||
|
|
||||||
if (argc < 2 || argc > 3)
|
if (argc < 2 || argc > 3)
|
||||||
return CMD_RET_USAGE;
|
return CMD_RET_USAGE;
|
||||||
char *ep;
|
dev_str = argv[1];
|
||||||
char *dev_str = argv[1];
|
dev = simple_strtoul(dev_str, &ep, 16);
|
||||||
char *file = argc >= 3 ? argv[2] : NULL;
|
|
||||||
int dev = simple_strtoul(dev_str, &ep, 16);
|
|
||||||
if (*ep) {
|
if (*ep) {
|
||||||
printf("** Bad device specification %s **\n", dev_str);
|
printf("** Bad device specification %s **\n", dev_str);
|
||||||
return CMD_RET_USAGE;
|
return CMD_RET_USAGE;
|
||||||
}
|
}
|
||||||
|
file = argc >= 3 ? argv[2] : NULL;
|
||||||
|
|
||||||
return !!host_dev_bind(dev, file);
|
return !!host_dev_bind(dev, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue