Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/videolan/dav1d.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorNathan E. Egge <unlord@xiph.org>2021-02-11 17:50:48 +0300
committerJean-Baptiste Kempf <jb@videolan.org>2021-02-12 12:27:24 +0300
commitecf153b1ae4933177c026bbd513431c02b067054 (patch)
tree555eac08e2d3bf3f5d5646a88b9fd62f411939e7 /tools
parentb44ec4539046b6220e5dafb4b5f6061a8c4f80a3 (diff)
Silence -Warray-bounds warning on some gcc versions
Diffstat (limited to 'tools')
-rw-r--r--tools/dav1d_cli_parse.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/tools/dav1d_cli_parse.c b/tools/dav1d_cli_parse.c
index 1b4466d..7790ca7 100644
--- a/tools/dav1d_cli_parse.c
+++ b/tools/dav1d_cli_parse.c
@@ -208,24 +208,26 @@ static const EnumParseTable cpu_mask_tbl[] = {
{ "avx2", X86_CPU_MASK_AVX2 },
{ "avx512icl", X86_CPU_MASK_AVX512ICL },
#endif
- { 0 },
+ { "none", 0 },
};
+#define ARRAY_SIZE(n) (sizeof(n)/sizeof(*(n)))
+
static unsigned parse_enum(char *optarg, const EnumParseTable *const tbl,
- const int option, const char *app)
+ const int tbl_sz, const int option, const char *app)
{
char str[1024];
strcpy(str, "any of ");
- for (int n = 0; tbl[n].str; n++) {
+ for (int n = 0; n < tbl_sz; n++) {
if (!strcmp(tbl[n].str, optarg))
return tbl[n].val;
if (n) {
- if (!tbl[n + 1].str)
- strcat(str, " or ");
- else
+ if (n < tbl_sz - 1)
strcat(str, ", ");
+ else
+ strcat(str, " or ");
}
strcat(str, tbl[n].str);
}
@@ -339,7 +341,7 @@ void parse(const int argc, char *const *const argv,
fprintf(stderr, "%s\n", dav1d_version());
exit(0);
case ARG_CPU_MASK:
- dav1d_set_cpu_flags_mask(parse_enum(optarg, cpu_mask_tbl,
+ dav1d_set_cpu_flags_mask(parse_enum(optarg, cpu_mask_tbl, ARRAY_SIZE(cpu_mask_tbl),
ARG_CPU_MASK, argv[0]));
break;
default: