From: Omar Polo Subject: Re: teach got patch how to strip To: Stefan Sperling Cc: gameoftrees@openbsd.org Date: Thu, 07 Apr 2022 13:35:07 +0200 Stefan Sperling wrote: > Flipping them around seems more obvious to me, in terms of style. indeed, it reads better. thanks! > diff 9d6cabd51222f7506db617ee8a7b282823dde999 /home/stsp/src/got > blob - 9a0217a5e7d82ee2539af6b0e563a2c537f26621 > file + lib/path.c > --- lib/path.c > +++ lib/path.c > @@ -125,16 +125,16 @@ got_path_strip(char **out, const char *path, int n) > p = path; > *out = NULL; > > - while (n > 0 && (c = strchr(path, '/')) != NULL) { > - path = c + 1; > + while (n > 0 && (c = strchr(p, '/')) != NULL) { > + p = c + 1; > n--; > } > > if (n > 0) > return got_error_fmt(GOT_ERR_BAD_PATH, > - "can't strip %d path-components from %s", n, p); > + "can't strip %d path-components from %s", n, path); > > - if ((*out = strdup(path)) == NULL) > + if ((*out = strdup(p)) == NULL) > return got_error_from_errno("strdup"); > return NULL; > }