From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "SZEDER Gábor" <szeder.dev@gmail.com>,
"John Paul Adrian Glaubitz" <glaubitz@physik.fu-berlin.de>,
"Todd Zullinger" <tmz@pobox.com>,
git@vger.kernel.org
Subject: Re: [PATCH] test-progress: fix test failures on big-endian systems
Date: Mon, 21 Oct 2019 17:51:52 +0900 [thread overview]
Message-ID: <xmqqftjmlbvb.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20191021032144.GB13083@sigill.intra.peff.net> (Jeff King's message of "Sun, 20 Oct 2019 23:21:44 -0400")
Jeff King <peff@peff.net> writes:
> 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.
next prev parent reply other threads:[~2019-10-21 8:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-31 6:37 [BUG]: Testsuite failures on big-endian targets John Paul Adrian Glaubitz
2019-07-31 7:17 ` Todd Zullinger
2019-10-19 21:38 ` John Paul Adrian Glaubitz
2019-10-19 23:37 ` [PATCH] test-progress: fix test failures on big-endian systems SZEDER Gábor
2019-10-19 23:55 ` John Paul Adrian Glaubitz
2019-10-20 0:19 ` Todd Zullinger
2019-10-21 0:52 ` Junio C Hamano
2019-10-21 3:21 ` Jeff King
2019-10-21 8:51 ` Junio C Hamano [this message]
2019-10-21 18:49 ` Jeff King
2019-10-23 1:58 ` Junio C Hamano
2019-10-24 17:24 ` SZEDER Gábor
2019-10-24 17:55 ` Jeff King
2019-10-20 0:26 ` [BUG]: Testsuite failures on big-endian targets Todd Zullinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqftjmlbvb.fsf@gitster-ct.c.googlers.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=glaubitz@physik.fu-berlin.de \
--cc=peff@peff.net \
--cc=szeder.dev@gmail.com \
--cc=tmz@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.