]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Fix detection of missing argument to -opt/--options-file
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 21 Jun 2017 20:14:35 +0000 (22:14 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 21 Jun 2017 20:14:35 +0000 (22:14 +0200)
Closes #171.

NEWS.txt
ccache.c

index d412ea96b958204d77de35c98a26910d9d9fc158..7f61678ebdd062d5b655a607e0a3a7de76b72289 100644 (file)
--- 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
 ------------
index 265c5098c06637d558a38f5804cae5a059479147..42935e7a87ed49deb0a3835d4a4f616846af2be3 100644 (file)
--- 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;