[PATCH] Improve job/cmd line parsing error logging
authorJens Axboe <jens.axboe@oracle.com>
Thu, 2 Nov 2006 08:12:40 +0000 (09:12 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Thu, 2 Nov 2006 08:12:40 +0000 (09:12 +0100)
Drop jobs when needed and so on.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
init.c
parse.c

diff --git a/init.c b/init.c
index 6ad3c64..b004d89 100644 (file)
--- a/init.c
+++ b/init.c
@@ -932,6 +932,9 @@ int parse_jobs_ini(char *file, int stonewall_flag)
                if (!ret) {
                        fsetpos(f, &off);
                        ret = add_job(td, name, 0);
+               } else {
+                       log_err("fio: job %s dropped\n", name);
+                       put_job(td);
                }
        } while (!ret);
 
@@ -1054,7 +1057,12 @@ static int parse_cmd_line(int argc, char *argv[])
                                        return 0;
                        }
 
-                       parse_cmd_option(opt, val, options, td);
+                       ret = parse_cmd_option(opt, val, options, td);
+                       if (ret) {
+                               log_err("fio: job dropped\n");
+                               put_job(td);
+                               td = NULL;
+                       }
                        break;
                }
                default:
@@ -1184,7 +1192,6 @@ int parse_options(int argc, char *argv[])
 
        if (!thread_number) {
                log_err("No jobs defined(s)\n");
-               usage();
                return 1;
        }
 
diff --git a/parse.c b/parse.c
index 7af6be1..ae8d0d9 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -240,9 +240,6 @@ static int handle_option(struct fio_option *o, const char *ptr, void *data)
                ret = 1;
        }
 
-       if (ret)
-               fprintf(stderr, "fio: failed parsing %s=%s\n", o->name, ptr);
-
        return ret;
 }
 
@@ -257,7 +254,11 @@ int parse_cmd_option(const char *opt, const char *val,
                return 1;
        }
 
-       return handle_option(o, val, data);
+       if (!handle_option(o, val, data))
+               return 0;
+
+       fprintf(stderr, "fio: failed parsing %s=%s\n", opt, val);
+       return 1;
 }
 
 int parse_option(const char *opt, struct fio_option *options, void *data)
@@ -285,5 +286,9 @@ int parse_option(const char *opt, struct fio_option *options, void *data)
                return 1;
        }
 
-       return handle_option(o, post, data);
+       if (!handle_option(o, post, data))
+               return 0;
+
+       fprintf(stderr, "fio: failed parsing %s\n", opt);
+       return 1;
 }