On Mon, Sep 05, 2022 at 11:55:38AM +0200, Ahmad Fatoum wrote: > We don't need to duplicate argv[i], because it persists for the lieftime s/lieftime/lifetime/ > of print_tutorial_step. We can thus drop the strdup and while at it, > just drop the redundant step variable altogether. > > Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> > --- > commands/tutorial.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/commands/tutorial.c b/commands/tutorial.c > index 444177764311..afe5b66f0b0a 100644 > --- a/commands/tutorial.c > +++ b/commands/tutorial.c > @@ -84,7 +84,6 @@ out: > static int do_tutorial_next(int argc, char *argv[]) > { > int opt, i; > - char *step = NULL; > char *oldcwd; > ssize_t ret = 0; > bool is_prev = *argv[0] == 'p'; > @@ -121,14 +120,12 @@ static int do_tutorial_next(int argc, char *argv[]) > next_step = next_step > 0 ? next_step - 1 : 0; > > if (optind == argc) { > - step = steps.gl_pathv[next_step]; > - ret = print_tutorial_step(step); > + ret = print_tutorial_step(steps.gl_pathv[next_step]); > if (ret == 0 && !is_prev) > next_step = (next_step + 1) % steps.gl_pathc; > } else { > for (i = optind; i < argc; i++) { > - step = strdup(argv[i]); > - ret = print_tutorial_step(step); > + ret = print_tutorial_step(argv[i]); > if (ret) > break; > } > -- > 2.30.2 > > > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |