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.