do not forget to exit(1) on error - ploot - simple plotting tools
(HTM) git clone git://bitreich.org/ploot git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/ploot
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Tags
(DIR) README
(DIR) LICENSE
---
(DIR) commit 1a79b31f23eda5a963cf1dbb2d8f77b8baae5270
(DIR) parent 97913fd518557ed58a07f52204fef1271af2bb32
(HTM) Author: Josuah Demangeon <mail@josuah.net>
Date: Mon, 7 May 2018 01:13:59 +0200
do not forget to exit(1) on error
as I was pointed out, exit(0) is for normal termination
Diffstat:
M ploot.c | 6 +++---
M plootxt.c | 2 +-
M util.c | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
---
(DIR) diff --git a/ploot.c b/ploot.c
@@ -79,18 +79,18 @@ add_row(Vlist *v, int bufsize, int ncol, int nval, char *line)
char *field, *dot;
if ((field = strsep(&line, ",")) == NULL)
- fprintf(stderr, "%d: missing epoch\n", nval), exit(0);
+ fprintf(stderr, "%d: missing epoch\n", nval), exit(1);
if ((dot = strchr(field, '.')) != NULL)
*dot = '\0';
epoch = eatol(field);
for (; (field = strsep(&line, ",")) != NULL; ncol--, v++) {
if (ncol <= 0)
- fprintf(stderr, "%d: too many fields\n", nval), exit(0);
+ fprintf(stderr, "%d: too many fields\n", nval), exit(1);
bs = add_val(v, bufsize, nval, eatof(field), epoch);
}
if (ncol > 0)
- fprintf(stderr, "%d: too few fields\n", nval), exit(0);
+ fprintf(stderr, "%d: too few fields\n", nval), exit(1);
return bs;
}
(DIR) diff --git a/plootxt.c b/plootxt.c
@@ -232,7 +232,7 @@ main(int argc, char **argv)
nmax = parse_args(argc, argv, max);
ncol = read_labels(labels);
if (ncol != nmax)
- fputs("not as many labels and arguments\n", stderr), exit(0);
+ fputs("not as many labels and arguments\n", stderr), exit(1);
plot(labels, max, ncol);
return 0;
(DIR) diff --git a/util.c b/util.c
@@ -42,7 +42,7 @@ eatof(char *str)
for (s = str; *s != '\0'; s++)
if (!isdigit(*s) && *s != '-' && *s != '.')
- fputs("invalid float format\n", stderr), exit(0);
+ fputs("invalid float format\n", stderr), exit(1);
return atof(str);
}
@@ -53,7 +53,7 @@ eatol(char *str)
for (s = str; *s != '\0'; s++)
if (!isdigit(*s) && *s != '-')
- fputs("invalid number format\n", stderr), exit(0);
+ fputs("invalid number format\n", stderr), exit(1);
return atol(str);
}