Re: [PATCH v3 2/3] t0021: implementation the rot13-filter.pl script in C
On Mon, Aug 1, 2022 at 8:37 AM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
Show 13 quoted lines
>
> On Sun, Jul 31 2022, Matheus Tavares wrote:
> >
> > +
> > + caps = argv + i;
> > + cap_count = argc - i;
>
> Since you need to change every single caller consider just starting out
> with parse_options() here instead of rolling your own parsing. You could
> use it for --always-delay in any case, but you could also just add a
> --log-path and --capability (an OPT_STRING_LIST), so:
>
> test-tool rot13-filter [--always-delay] --log-path=<path> [--capability <capbility]...
Show 8 quoted lines
> > +
> > + for (i = 0; i < cap_count; i++) {
> > + if (!strcmp(caps[i], "clean"))
> > + has_clean_cap = 1;
> > + else if (!strcmp(caps[i], "smudge"))
> > + has_smudge_cap = 1;
>
> In any case, maybe BUG() in an "else" here with "unknown capability"?> > + fclose(logfile);
>
> Perhaps check the return value & die_errno() if we fail to fclose()
> (happens e.g. if the disk fills up).