commit 5c6ae89e707b5a1f5685714895b962f4269975ec
parent 1521a6495499ede707eb6cbdf5c21a8dd24f6b31
Author: Paco Esteban <paco@e1e0.net>
Date: Mon, 29 Jun 2020 17:46:02 +0200
"standardize" article_sort error
Diffstat:
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/ssnail.c b/ssnail.c
@@ -61,9 +61,9 @@ static struct article *populate_article_entry(char *, char *);
static const struct ssnail_error *process_dir(char *, char *, int);
static const struct ssnail_error *write_html(struct article *, char *, char *);
+static const struct ssnail_error *article_sort(struct listhead *);
static int gen_html(struct article *);
-static int article_sort(struct listhead *);
__dead static void
usage(void)
@@ -143,10 +143,8 @@ main(int argc, char *argv[])
if ((error = process_dir(srcdir, dstdir, force)) != NULL)
goto done;
- if (article_sort(&head) == -1) {
- error = ssnail_error_msg(2, "sort error");
+ if ((error = article_sort(&head)) != NULL)
goto done;
- }
printf("Generate html files ... \n");
LIST_FOREACH(ap, &head, entries) {
@@ -444,7 +442,7 @@ out:
return error;
}
-static int
+const struct ssnail_error *
article_sort(struct listhead *h)
{
struct article *a1 = NULL, *a2 = NULL;
@@ -453,7 +451,7 @@ article_sort(struct listhead *h)
assert(h != NULL);
if (LIST_EMPTY(h))
- return -1;
+ return ssnail_error_msg(2, "sort empty list");
/* count list elemets */
LIST_FOREACH(a1, h, entries) {
@@ -474,5 +472,5 @@ article_sort(struct listhead *h)
}
}
- return 0;
+ return NULL;
}