From 9530053c551fa0e9bad2a0ffda905bb5a9e5e234 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 21 Jun 2019 21:23:28 +0200 Subject: Fix error handling in the case of 1 file argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- loc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/loc.c b/loc.c index bd43584..855ad5b 100644 --- a/loc.c +++ b/loc.c @@ -163,7 +163,10 @@ main(int argc, char *argv[]) n = count(fd, argv[0]); close(fd); } - printf("%zi\n", n); + if (n >= 0) + printf("%zi\n", n); + else + ret = 1; } else { if (!(res = calloc(argc, sizeof(struct result)))) fprintf(stderr, "%s: out of memory\n", argv0), exit(1); -- cgit v1.2.3-70-g09d2