[PATCH v2] test/argparse: change initialization to workaround LTO
Stephen Hemminger
stephen at networkplumber.org
Mon Jun 30 17:23:16 CEST 2025
On Mon, 30 Jun 2025 16:20:21 +0100
Bruce Richardson <bruce.richardson at intel.com> wrote:
> We should consider either making this a "do { } while" loop or adding the
> termination condition to the "for" loop statement as normal. For example:
>
> unsigned int i = 0;
>
> obj = backup;
> do {
> obj.args[i] = backup.args[i];
> } while (backup.args[++i].name_long != NULL);
>
> or else:
>
> obj = backup;
> for (i = 0; backup.args[i].name_long != NULL; i++)
> obj.args[i] = backup.args[i];
> obj.args[i] = ARGPARSE_ARG_END();
>
> I'd tend toward the second, myself, but what is in your patch above is fine
> as-is too.
Agree with one of the two is more readable.
I kind of wanted to keep what original code was doing.
More information about the dev
mailing list