[Intel-gfx] [PATCH i-g-t 3/5] lib/igt_core: 0 is a valid val for long options
Petri Latvala
petri.latvala at intel.com
Fri May 31 10:05:49 UTC 2019
On Wed, May 29, 2019 at 04:27:35PM -0700, Lucas De Marchi wrote:
> This is usually used by long options when working with enum to set long
> option values. So replace the strchr() with a memchr() to take that into
> account.
>
> Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
Reviewed-by: Petri Latvala <petri.latvala at intel.com>
The latter strchr-memchr change is needless but meh.
> ---
> lib/igt_core.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/lib/igt_core.c b/lib/igt_core.c
> index 814f5c72..a0b7e581 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -680,6 +680,7 @@ static int common_init(int *argc, char **argv,
> };
> char *short_opts;
> const char *std_short_opts = "h";
> + size_t std_short_opts_len = strlen(std_short_opts);
> struct option *combined_opts;
> int extra_opt_count;
> int all_opt_count;
> @@ -713,7 +714,7 @@ static int common_init(int *argc, char **argv,
>
> /* check for conflicts with standard short options */
> if (extra_long_opts[extra_opt_count].val != ':'
> - && (conflicting_char = strchr(std_short_opts, extra_long_opts[extra_opt_count].val))) {
> + && (conflicting_char = memchr(std_short_opts, extra_long_opts[extra_opt_count].val, std_short_opts_len))) {
> igt_critical("Conflicting long and short option 'val' representation between --%s and -%c\n",
> extra_long_opts[extra_opt_count].name,
> *conflicting_char);
> @@ -727,7 +728,7 @@ static int common_init(int *argc, char **argv,
> continue;
>
> /* check for conflicts with standard short options */
> - if (strchr(std_short_opts, extra_short_opts[i])) {
> + if (memchr(std_short_opts, extra_short_opts[i], std_short_opts_len)) {
> igt_critical("Conflicting short option: -%c\n", std_short_opts[i]);
> assert(0);
> }
> --
> 2.21.0
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
More information about the Intel-gfx
mailing list