Hi Sean, On Sun, 28 Feb 2021 at 16:47, Sean Anderson <sean...@gmail.com> wrote: > > This is fairly straightforward. This allows > part uuid mmc 0 foo > To be rewritten as > env set foo $(part uuid mmc 0) > or even (if the variable is not required to be environmental) > foo=$(part uuid mmc 0) > > Signed-off-by: Sean Anderson <sean...@gmail.com> > --- > > cmd/part.c | 18 ++++++++++++++---- > 1 file changed, 14 insertions(+), 4 deletions(-) > > diff --git a/cmd/part.c b/cmd/part.c > index 3395c17b89..97e70d79ff 100644 > --- a/cmd/part.c > +++ b/cmd/part.c > @@ -19,9 +19,12 @@ > #include <config.h> > #include <command.h> > #include <env.h> > +#include <malloc.h> > #include <part.h> > #include <vsprintf.h> > > +DECLARE_GLOBAL_DATA_PTR; > + > enum cmd_part_info { > CMD_PART_INFO_START = 0, > CMD_PART_INFO_SIZE, > @@ -43,12 +46,19 @@ static int do_part_uuid(int argc, char *const argv[]) > if (part < 0) > return 1; > > - if (argc > 2) > + if (argc > 2) { > env_set(argv[2], info.uuid); > - else > - printf("%s\n", info.uuid); > + } else { > + size_t result_size = sizeof(info.uuid) + 1; > > - return 0; > + gd->cmd_result = malloc(result_size); > + if (!gd->cmd_result) > + return CMD_RET_FAILURE; > + > + snprintf(gd->cmd_result, result_size, "%s\n", info.uuid); > + } > + > + return CMD_RET_SUCCESS;
I suppose I prefer 0 to CMD_RET_SUCCESS, since 0 is the universal success code in U-Boot, and using the enum obscures that a bit. But I don't feel strongly about it. Regards, Simon