diff options
author | Timo Teräs <timo.teras@iki.fi> | 2020-10-07 21:16:13 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2020-10-07 21:16:35 +0300 |
commit | 5f66b618effe48b8a4ab295b067e379e49518346 (patch) | |
tree | e75fa4b1eddfc221628067e2d593f699ba4e1e44 /src/apk.c | |
parent | 90137499afdecdbcd977805786263b6f883680e7 (diff) | |
download | apk-tools-5f66b618effe48b8a4ab295b067e379e49518346.tar.gz apk-tools-5f66b618effe48b8a4ab295b067e379e49518346.tar.bz2 apk-tools-5f66b618effe48b8a4ab295b067e379e49518346.tar.xz apk-tools-5f66b618effe48b8a4ab295b067e379e49518346.zip |
various changes to make clang not give warnings
Diffstat (limited to 'src/apk.c')
-rw-r--r-- | src/apk.c | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -351,8 +351,9 @@ static int parse_options(int argc, char **argv, struct apk_applet *applet, void if ((unsigned char)*d >= 0xf0) num_short = *d++ & 0x0f; for (; num_short > 0; num_short--) { - assert(*d >= 64 && *d < 128); - short_option_val[*d - 64] = opt->val; + unsigned char ch = *(unsigned char *)d; + assert(ch >= 64 && ch < 128); + short_option_val[ch-64] = opt->val; *sopt++ = *d++; if (opt->has_arg != no_argument) *sopt++ = ':'; @@ -381,13 +382,6 @@ static int parse_options(int argc, char **argv, struct apk_applet *applet, void if (help_requested || r == -ENOTSUP) return usage(applet); - if (applet == NULL) { - if (argc > 1) { - apk_error("'%s' is not an apk command. See 'apk --help'.", argv[1]); - return 1; - } - return usage(NULL); - } return 0; } @@ -497,6 +491,14 @@ int main(int argc, char **argv) r = parse_options(argc, argv, applet, ctx, &dbopts); if (r != 0) goto err; + if (applet == NULL) { + if (argc > 1) { + apk_error("'%s' is not an apk command. See 'apk --help'.", argv[1]); + return 1; + } + return usage(NULL); + } + argc -= optind; argv += optind; if (argc >= 1 && strcmp(argv[0], applet->name) == 0) { |