From 0f272f1492fd217e38eda4dcb6e1b8f1ff68e211 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Wed, 13 Apr 2016 13:46:37 +1200 Subject: Ditch stdbool and EXIT_* --- fractal-gen.c | 25 ++++++++++++------------- fractal-gen.h | 2 +- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/fractal-gen.c b/fractal-gen.c index 7f651b6..e76f6be 100644 --- a/fractal-gen.c +++ b/fractal-gen.c @@ -30,7 +30,6 @@ #include #include -#include #include #include #include @@ -64,20 +63,20 @@ int main(int argc, char **argv) if (generator == NULL) { fprintf(stderr, "Don't call this directly, call a symlink to me\n"); - return EXIT_FAILURE; + return 1; } - if (!args_parse_okay(argc, argv)) + if (parse_args(argc, argv)) { show_help(); - return EXIT_FAILURE; + return 1; } /* Allocate memory for sections */ if ((sections = malloc(sizeof(data_section)*cores)) == NULL) { perror("malloc"); - return EXIT_FAILURE; + return 1; } ram_nice = (size*size)/clust_total; @@ -120,7 +119,7 @@ int main(int argc, char **argv) free(sections[i].data); free(sections); - return EXIT_FAILURE; + return 1; } sections[i].core = i; sections[i].datasize = x; @@ -159,7 +158,7 @@ int main(int argc, char **argv) } -bool args_parse_okay(int argc, char **argv) +int parse_args(int argc, char **argv) { char opt = '\0'; @@ -186,7 +185,7 @@ bool args_parse_okay(int argc, char **argv) /* redundant case for '?', but explicitness is best */ case '?': default: - return false; + return 1; break; } } @@ -197,13 +196,13 @@ bool args_parse_okay(int argc, char **argv) if (size <= 0) { fprintf(stderr, "ERROR: size must be positive\n"); - return false; + return 1; } if (iterat <= 0) { fprintf(stderr, "ERROR: max iteration count must be positive\n"); - return false; + return 1; } /* Interlacing is column-based, can't have more workers than columns */ @@ -216,15 +215,15 @@ bool args_parse_okay(int argc, char **argv) if (size % clust_total != 0) { fprintf(stderr, "ERROR: image size must be an exact multiple of clust_total\n"); - return false; + return 1; } if (cores <= 0) { fprintf(stderr, "ERROR: core counts should be positive\n"); - return false; + return 1; } - return true; + return 0; } diff --git a/fractal-gen.h b/fractal-gen.h index ef7c532..392f43a 100644 --- a/fractal-gen.h +++ b/fractal-gen.h @@ -48,7 +48,7 @@ char *argv0; typedef void* (*generator_func)(void *); -bool args_parse_okay(int argc, char **argv); +int parse_args(int argc, char **argv); generator_func select_generator(const char* name); void show_help(); -- cgit v1.1