git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Make the git-fsck-objects diagnostics more useful

From
Petr Baudis <pasky@suse.cz>
Date
Sep 21, 2005, 08:19 UTC
Message-ID
<20050921081954.GB24902@pasky.or.cz>
In-Reply-To
<200509201955.j8KJtWAr003157@laptop11.inf.utfsm.cl>

Dear diary, on Tue, Sep 20, 2005 at 09:55:32PM CEST, I got a letter where Horst von Brand <vonbrand@inf.utfsm.cl> told me that...

Show 11 quoted lines
> > +static void objreport(struct object *obj, const char *severity,
> > +                      const char *err, va_list params)
> > +{
> > +	fprintf(stderr, "%s in %s %s: ",
> > +	        severity, obj->type, sha1_to_hex(obj->sha1));
> > +	vfprintf(stderr, err, params);
> > +	fputs("\n", stderr);
> > +}
> 
> Is this legal? I am under the impression you have to call
> va_start()/va_end() always, even if you just pass the va_list down.

va_list will probably be/contain some pointer, and with va_start() you "seed" it to point at the stack after the given parameter and slurp the additional function parameters from there. If you already have it initialized, va_start() makes no sense.

> The comp.lang.c FAQ <http://www.eskimo.com/~scs/C-faq/q15.5.html> agrees
> with me here... it should be:
That says nothing about passing va_list down.
Show 12 quoted lines
> static void objreport(struct object *obj, const char *severity,
>                       const char *err, ...)
> {
> 	va_list params;
> 	
> 	fprintf(stderr, "%s in %s %s: ",
> 	        severity, obj->type, sha1_to_hex(obj->sha1));
> 	va_start(params, err);
>         vfprintf(stderr, err, params);	
> 	va_end(params);
> 	fputs("\n", stderr);
> }

How do you then call objreport() ? params would contain another va_list if you called it the same as before, which would probably surprise vfprintf() a bit.

BTW, we do the same in usage.c.
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
VI has two modes: the one in which it beeps and the one in which
it doesn't.
Previous: Horst von BrandNext: Johannes Schindelin
Message 2 of 4 in “Re: [PATCH] Make the git-fsck-objects diagnostics more useful”
  1. Horst von BrandSep 20, 2005
  2. Petr BaudisSep 21, 2005
  3. Johannes SchindelinSep 21, 2005
  4. Michael RichardsonMay 29, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.