Re: [PATCH v7 1/7] run-command: add duplicate_output_fn to run_processes_parallel_opts
- From
Calvin Wan <calvinwan@google.com>
- Date
- Feb 8, 2023, 22:54 UTC
- Message-ID
- <CAFySSZDeC-zc7wS7WXE+bAijVQkuin5GwLRnJ2ok7C9PRaH3+g@mail.gmail.com>
- In-Reply-To
- <cd528776-caa8-6372-0ca5-db0545947fba@dunelm.org.uk>
Show 14 quoted lines
> > + } else {
> > + if (opts->duplicate_output)
> > + opts->duplicate_output(&pp->children[i].err,
> > + strlen(pp->children[i].err.buf) - n,
>
> Looking at how this is used in patch 7 I think it would be better to
> pass a const char*, length pair rather than a struct strbuf*, offset pair.
> i.e.
> opts->duplicate_output(pp->children[i].err.buf +
> pp->children[i].err.len - n, n, ...)
>
> That would make it clear that we do not expect duplicate_output() to
> alter the buffer and would avoid the duplicate_output() having to add
> the offset to the start of the buffer to find the new data.I don't think that would work since pp->children[i].err.buf + pp->children[i].err.len - n wouldn't end up as a const char* unless I'm missing something?