From: Stefan Sperling Subject: Re: avoid allocating too much errors in cmd_info To: Omar Polo Cc: gameoftrees@openbsd.org Date: Fri, 5 Aug 2022 19:44:27 +0200 On Fri, Aug 05, 2022 at 12:49:54PM +0200, Omar Polo wrote: > sure, but it still smells like a flag to me -- just a bit less than > with my diff tho :) It does. But it also serves as an example of storing a specific error on a pathlist item, which might get carried over elsewhere. ok stsp@ > diff /home/op/w/got > commit - 575dd20f850659c3caa159936f3fa7e88867b8a7 > path + /home/op/w/got > blob - 77ab232b3e3dd99d8500f2e4792976396ecafda9 > file + got/got.c > --- got/got.c > +++ got/got.c > @@ -13095,8 +13095,7 @@ cmd_info(int argc, char *argv[]) > * Assume this path will fail. This will be corrected > * in print_path_info() in case the path does suceeed. > */ > - pe->data = (void *)got_error_path(pe->path, > - GOT_ERR_BAD_PATH); > + pe->data = (void *)got_error(GOT_ERR_BAD_PATH); > } > error = got_worktree_path_info(worktree, &paths, > print_path_info, &paths, check_cancelled, NULL); > @@ -13104,7 +13103,11 @@ cmd_info(int argc, char *argv[]) > goto done; > TAILQ_FOREACH(pe, &paths, entry) { > if (pe->data != NULL) { > - error = pe->data; /* bad path */ > + const struct got_error *perr; > + > + perr = (const struct got_error *)pe->data; > + error = got_error_fmt(perr->code, "%s", > + pe->path); > break; > } > } > >