[nfs-utils,5/5] nfsdcld: Fix a few Coverity Scan CHECKED_RETURN errors.
diff mbox series

Message ID 20200710203700.2546112-6-smayhew@redhat.com
State New
Headers show
Series
  • nfsdcld: Fix a number of Coverity Scan
Related show

Commit Message

Scott Mayhew July 10, 2020, 8:37 p.m. UTC
Signed-off-by: Scott Mayhew <smayhew@redhat.com>
---
 utils/nfsdcld/legacy.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Patch
diff mbox series

diff --git a/utils/nfsdcld/legacy.c b/utils/nfsdcld/legacy.c
index 9e9f758..b89374c 100644
--- a/utils/nfsdcld/legacy.c
+++ b/utils/nfsdcld/legacy.c
@@ -51,18 +51,19 @@  legacy_load_clients_from_recdir(int *num_records)
 	char recdirname[PATH_MAX+1];
 	char buf[NFS4_OPAQUE_LIMIT];
 	char *nl;
+	ssize_t n;
 
 	fd = open(NFSD_RECDIR_FILE, O_RDONLY);
 	if (fd < 0) {
 		xlog(D_GENERAL, "Unable to open %s: %m", NFSD_RECDIR_FILE);
 		return;
 	}
-	if (read(fd, recdirname, PATH_MAX) < 0) {
+	n = read(fd, recdirname, PATH_MAX);
+	close(fd);
+	if (n < 0) {
 		xlog(D_GENERAL, "Unable to read from %s: %m", NFSD_RECDIR_FILE);
-		close(fd);
 		return;
 	}
-	close(fd);
 	/* the output from the proc file isn't null-terminated */
 	recdirname[PATH_MAX] = '\0';
 	nl = strchr(recdirname, '\n');
@@ -118,18 +119,19 @@  legacy_clear_recdir(void)
 	char recdirname[PATH_MAX+1];
 	char dirname[PATH_MAX];
 	char *nl;
+	ssize_t n;
 
 	fd = open(NFSD_RECDIR_FILE, O_RDONLY);
 	if (fd < 0) {
 		xlog(D_GENERAL, "Unable to open %s: %m", NFSD_RECDIR_FILE);
 		return;
 	}
-	if (read(fd, recdirname, PATH_MAX) < 0) {
+	n = read(fd, recdirname, PATH_MAX);
+	close(fd);
+	if (n < 0) {
 		xlog(D_GENERAL, "Unable to read from %s: %m", NFSD_RECDIR_FILE);
-		close(fd);
 		return;
 	}
-	close(fd);
 	/* the output from the proc file isn't null-terminated */
 	recdirname[PATH_MAX] = '\0';
 	nl = strchr(recdirname, '\n');