Re: [PATCH v7 1/7] run-command: add duplicate_output_fn to run_processes_parallel_opts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Calvin

On 08/02/2023 22:54, Calvin Wan wrote:
+                     } 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?

You can still pass it to a function that takes a const char* though and change type of the callback to

typedef void (*duplicate_output_fn)(const char *out, size_t offset,
				    void *pp_cb, void *pp_task_cb);

Best Wishes

Phillip



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux