From 800eab3e52e427f40c069aea5e52a8d59bca513f Mon Sep 17 00:00:00 2001 From: David Phillips Date: Fri, 8 Apr 2016 12:56:14 +1200 Subject: Improve error messages for command line arguments --- fractal-gen.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/fractal-gen.c b/fractal-gen.c index cc4d6d2..7f651b6 100644 --- a/fractal-gen.c +++ b/fractal-gen.c @@ -194,34 +194,34 @@ bool args_parse_okay(int argc, char **argv) /* Extend number of threads to multiplier value */ cores *= thread_mult; - /* Interlacing is column-based, can't have more workers than columns */ - if (cores > size) + if (size <= 0) { - cores = size; - fprintf(stderr, "WARN: Capping number of threads to image size (%d)\n", cores); + fprintf(stderr, "ERROR: size must be positive\n"); + return false; } - if (size % clust_total != 0) + if (iterat <= 0) { - fprintf(stderr, "ERROR: image size must be an exact multiple of clust_total\n"); + fprintf(stderr, "ERROR: max iteration count must be positive\n"); return false; } - if (size <= 0) + /* Interlacing is column-based, can't have more workers than columns */ + if (cores > size) { - fprintf(stderr, "size should be positive\n"); - return false; + cores = size; + fprintf(stderr, "WARN: Capping number of threads to image size (%d)\n", cores); } - if (iterat <= 0) + if (size % clust_total != 0) { - fprintf(stderr, "iteration count should be positive\n"); + fprintf(stderr, "ERROR: image size must be an exact multiple of clust_total\n"); return false; } if (cores <= 0) { - fprintf(stderr, "core counts should be positive\n"); + fprintf(stderr, "ERROR: core counts should be positive\n"); return false; } return true; -- cgit v1.1