Re: [PATCH v2 2/2] bisect: output bisect setup status in bisect log

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

 



On Fri, May 06, 2022 at 11:18:25AM -0700, Junio C Hamano wrote:
> Chris Down <chris@xxxxxxxxxxxxxx> writes:
>
> > +__attribute__((format (printf, 1, 2)))
> > +static void bisect_log_printf(const char *fmt, ...)
> > +{
> > +	va_list ap;
> > +	char buf[1024];
> > +
> > +	va_start(ap, fmt);
> > +	if (vsnprintf(buf, sizeof(buf), fmt, ap) < 0)
> > +		*buf = '\0';
> > +	va_end(ap);
>
> We should just do
>
> 	struct strbuf buf = STRBUF_INIT;
>
> 	va_start(ap, fmt);
> 	strbuf_vaddf(&buf, fmt, ap);
> 	va_end(ap);
>
> > +	printf("%s", buf);
> > +	append_to_file(git_path_bisect_log(), "# %s", buf);
>
> and free the resource with
>
> 	strbuf_release(&buf);
>
> I think.

I don't think so. bisect_log_printf() has only one caller, which is
bisect_print_status(). Couldn't the latter manage its own strbuf without
the need to introduce a new varargs function?

Thanks,
Taylor



[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