From: Joel Rosdahl Date: Wed, 21 Jun 2017 20:14:35 +0000 (+0200) Subject: Fix detection of missing argument to -opt/--options-file X-Git-Tag: v3.3.5~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4d1062eb23234fcacc07b75404f0ebf244f5173;p=thirdparty%2Fccache.git Fix detection of missing argument to -opt/--options-file Closes #171. --- diff --git a/NEWS.txt b/NEWS.txt index d412ea96b..7f61678eb 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -16,6 +16,8 @@ Bug fixes - Fixed matching of directories in the `ignore_headers_in_manifest` configuration option. +- Fixed detection of missing argument to `-opt`/`--options-file`. + ccache 3.3.4 ------------ diff --git a/ccache.c b/ccache.c index 265c5098c..42935e7a8 100644 --- a/ccache.c +++ b/ccache.c @@ -2167,8 +2167,8 @@ cc_process_args(struct args *args, struct args **preprocessor_args, // Handle cuda "-optf" and "--options-file" argument. if (str_eq(argv[i], "-optf") || str_eq(argv[i], "--options-file")) { - if (i > argc) { - cc_log("Expected argument after -optf/--options-file"); + if (i == argc - 1) { + cc_log("Expected argument after %s", argv[i]); stats_update(STATS_ARGS); result = false; goto out; @@ -2269,7 +2269,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args, // Special handling for -x: remember the last specified language before the // input file and strip all -x options from the arguments. if (str_eq(argv[i], "-x")) { - if (i == argc-1) { + if (i == argc - 1) { cc_log("Missing argument to %s", argv[i]); stats_update(STATS_ARGS); result = false; @@ -2290,7 +2290,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args, // We need to work out where the output was meant to go. if (str_eq(argv[i], "-o")) { - if (i == argc-1) { + if (i == argc - 1) { cc_log("Missing argument to %s", argv[i]); stats_update(STATS_ARGS); result = false; @@ -2353,7 +2353,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args, bool separate_argument = (strlen(argv[i]) == 3); if (separate_argument) { // -MF arg - if (i >= argc - 1) { + if (i == argc - 1) { cc_log("Missing argument to %s", argv[i]); stats_update(STATS_ARGS); result = false; @@ -2383,7 +2383,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args, char *relpath; if (strlen(argv[i]) == 3) { // -MQ arg or -MT arg - if (i >= argc - 1) { + if (i == argc - 1) { cc_log("Missing argument to %s", argv[i]); stats_update(STATS_ARGS); result = false; @@ -2500,7 +2500,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args, } if (str_eq(argv[i], "--serialize-diagnostics")) { - if (i >= argc - 1) { + if (i == argc - 1) { cc_log("Missing argument to %s", argv[i]); stats_update(STATS_ARGS); result = false; @@ -2590,7 +2590,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args, // to get better hit rate. A secondary effect is that paths in the standard // error output produced by the compiler will be normalized. if (compopt_takes_path(argv[i])) { - if (i == argc-1) { + if (i == argc - 1) { cc_log("Missing argument to %s", argv[i]); stats_update(STATS_ARGS); result = false; @@ -2642,7 +2642,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args, // Options that take an argument. if (compopt_takes_arg(argv[i])) { - if (i == argc-1) { + if (i == argc - 1) { cc_log("Missing argument to %s", argv[i]); stats_update(STATS_ARGS); result = false;