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

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

From
Horst von Brand <vonbrand@inf.utfsm.cl>
Date
Sep 20, 2005, 19:55 UTC
Message-ID
<200509201955.j8KJtWAr003157@laptop11.inf.utfsm.cl>
In-Reply-To
<pasky@ucw.cz>
Petr Baudis <pasky@ucw.cz> wrote:
Show 32 quoted lines
> Actually report what exactly is wrong with the object, instead of an
> ambiguous 'bad sha1 file' or such. In places where we already do, unify
> the format and clean the messages up.
> 
> Signed-off-by: Petr Baudis <pasky@suse.cz>
> 
> ---
> commit ff0b3368b45a07ac080574eb721a607892413b99
> tree c5e730edddb7679bee63a7d76fb088a7378a9d8b
> parent 12913234050c07785b7fc5929e4c8b5f80606609
> author Petr Baudis <pasky@suse.cz> Tue, 20 Sep 2005 20:54:33 +0200
> committer Petr Baudis <xpasky@machine.(none)> Tue, 20 Sep 2005 20:54:33 +0200
> 
>  fsck-objects.c |   82 +++++++++++++++++++++++++++++++++-----------------------
>  1 files changed, 48 insertions(+), 34 deletions(-)
> 
> diff --git a/fsck-objects.c b/fsck-objects.c
> --- a/fsck-objects.c
> +++ b/fsck-objects.c
> @@ -20,6 +20,35 @@ static int check_strict = 0;
>  static int keep_cache_objects = 0; 
>  static unsigned char head_sha1[20];
>  
> +
> +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.

The comp.lang.c FAQ <http://www.eskimo.com/~scs/C-faq/q15.5.html> agrees with me here... it should be:

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);
}
[Yes, I know. "We all are using gcc and glibc on Linux". But anyway.]
-- 
Dr. Horst H. von Brand                   User #22616 counter.li.org
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513
Next: Petr Baudis
Message 1 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.