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

Re: [PATCH] test-progress: fix test failures on big-endian systems

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 21, 2019, 08:51 UTC
Message-ID
<xmqqftjmlbvb.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20191021032144.GB13083@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 34 quoted lines
> I wondered if we could be a bit more clever with the definition of
> "struct option". Something like:
>
> diff --git a/parse-options.h b/parse-options.h
> index 38a33a087e..99c7ff466d 100644
> --- a/parse-options.h
> +++ b/parse-options.h
> @@ -126,7 +126,10 @@ struct option {
>  	enum parse_opt_type type;
>  	int short_name;
>  	const char *long_name;
> -	void *value;
> +	union {
> +		int *intp;
> +		const char *strp;
> +	} value;
>  	const char *argh;
>  	const char *help;
>  
>
> which would let the compiler complain about the type mismatch (of course
> it can't help you if you assign to "intp" while trying to parse a
> string).
>
> Initializing the union from a compound literal becomes more painful,
> but:
>
>   1. That's mostly hidden behind OPT_INTEGER(), etc.
>
>   2. I think we're OK with named initializers these days. I.e., I think:
>
>         { OPTION_INTEGER, 'f', "--foo", { .intp = &foo } }
>
>      would work OK.

The side that actually use .vale would need to change for obvious reasons, which may be painful, but I agree it would have easily prevented the regression from happening in the first place.

Thanks for a food for thought.
Previous: Jeff KingNext: Jeff King
Message 9 of 14 in “[BUG]: Testsuite failures on big-endian targets”
  1. John Paul Adrian GlaubitzJul 31, 2019
  2. Todd ZullingerJul 31, 2019
  3. John Paul Adrian GlaubitzOct 19, 2019
  4. test-progress: fix test failures on big-endian systemsSZEDER Gábor, Oct 19, 2019
  5. John Paul Adrian GlaubitzOct 19, 2019
  6. Todd ZullingerOct 20, 2019
  7. Junio C HamanoOct 21, 2019
  8. Jeff KingOct 21, 2019
  9. Junio C HamanoOct 21, 2019
  10. Jeff KingOct 21, 2019
  11. Junio C HamanoOct 23, 2019
  12. SZEDER GáborOct 24, 2019
  13. Jeff KingOct 24, 2019
  14. Todd ZullingerOct 20, 2019

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.