Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Jan 2022 09:27:35 GMT
From:      Wolfram Schneider <wosch@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 72a0982cd529 - main - improve error handling
Message-ID:  <202201300927.20U9RZ30022198@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by wosch:

URL: https://cgit.FreeBSD.org/src/commit/?id=72a0982cd529c7cdeee7fd4eb7b1fd8bfdd545cb

commit 72a0982cd529c7cdeee7fd4eb7b1fd8bfdd545cb
Author:     Wolfram Schneider <wosch@FreeBSD.org>
AuthorDate: 2022-01-30 09:27:21 +0000
Commit:     Wolfram Schneider <wosch@FreeBSD.org>
CommitDate: 2022-01-30 09:27:21 +0000

    improve error handling
---
 usr.bin/locate/code/locate.code.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/usr.bin/locate/code/locate.code.c b/usr.bin/locate/code/locate.code.c
index 4decf5a2e864..23fa043b12af 100644
--- a/usr.bin/locate/code/locate.code.c
+++ b/usr.bin/locate/code/locate.code.c
@@ -144,7 +144,8 @@ main(int argc, char *argv[])
 		err(1, "%s", argv[0]);
 
 	/* First copy bigram array to stdout. */
-	(void)fgets(bigrams, BGBUFSIZE + 1, fp);
+	if (fgets(bigrams, BGBUFSIZE + 1, fp) == NULL)
+		err(1, "get bigram array");
 
 	if (fwrite(bigrams, 1, BGBUFSIZE, stdout) != BGBUFSIZE)
 		err(1, "stdout");
@@ -246,9 +247,11 @@ main(int argc, char *argv[])
 			oldpath = buf2;
 		}
 	}
+
 	/* Non-zero status if there were errors */
 	if (fflush(stdout) != 0 || ferror(stdout))
-		exit(1);
+		errx(1, "stdout");
+
 	exit(0);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202201300927.20U9RZ30022198>