Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Feb 2023 20:40:40 GMT
From:      =?utf-8?Q?Dag-Erling=20Sm=C3=B8rgrav?= <des@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 1b11dd2108ca - stable/13 - df: Return non-zero status on write failure.
Message-ID:  <202302092040.319Keel2093881@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=1b11dd2108ca90a707c7f8976f409bf249509c94

commit 1b11dd2108ca90a707c7f8976f409bf249509c94
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2023-01-17 13:40:05 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2023-02-09 20:32:56 +0000

    df: Return non-zero status on write failure.
    
    While here, complete the libxo conversion and switch return value to standard constants.
    
    MFC after:      1 week
    Sponsored by:   Klara, Inc.
    Differential revision: https://reviews.freebsd.org/D38097
    
    (cherry picked from commit c968598479917f52022b86d0089a9835ddcf2799)
---
 bin/df/df.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/bin/df/df.c b/bin/df/df.c
index 627d8b1c861d..9f7588a68d4f 100644
--- a/bin/df/df.c
+++ b/bin/df/df.c
@@ -52,7 +52,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/stat.h>
 #include <sys/mount.h>
 #include <sys/sysctl.h>
-#include <err.h>
 #include <getopt.h>
 #include <libutil.h>
 #include <locale.h>
@@ -204,7 +203,7 @@ main(int argc, char *argv[])
 	argc -= optind;
 	argv += optind;
 
-	rv = 0;
+	rv = EXIT_SUCCESS;
 	if (!*argv) {
 		/* everything (modulo -t) */
 		mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
@@ -226,14 +225,14 @@ main(int argc, char *argv[])
 		if (stat(*argv, &stbuf) < 0) {
 			if ((mntpt = getmntpt(*argv)) == NULL) {
 				xo_warn("%s", *argv);
-				rv = 1;
+				rv = EXIT_FAILURE;
 				continue;
 			}
 		} else if (S_ISCHR(stbuf.st_mode)) {
 			mntpt = getmntpt(*argv);
 			if (mntpt == NULL) {
 				xo_warnx("%s: not mounted", *argv);
-				rv = 1;
+				rv = EXIT_FAILURE;
 				continue;
 			}
 		} else {
@@ -246,7 +245,7 @@ main(int argc, char *argv[])
 		 */
 		if (statfs(mntpt, &statfsbuf) < 0) {
 			xo_warn("%s", mntpt);
-			rv = 1;
+			rv = EXIT_FAILURE;
 			continue;
 		}
 
@@ -257,7 +256,7 @@ main(int argc, char *argv[])
 		 * we've been given (-l, -t, etc.).
 		 */
 		if (checkvfsselected(statfsbuf.f_fstypename) != 0) {
-			rv = 1;
+			rv = EXIT_FAILURE;
 			continue;
 		}
 
@@ -286,7 +285,8 @@ main(int argc, char *argv[])
 		prtstat(&totalbuf, &maxwidths);
 
 	xo_close_container("storage-system-information");
-	xo_finish();
+	if (xo_finish() < 0)
+		rv = EXIT_FAILURE;
 	exit(rv);
 }
 
@@ -322,7 +322,7 @@ makevfslist(char *fslist, int *skip)
 		if (*nextcp == ',')
 			i++;
 	if ((av = malloc((size_t)(i + 2) * sizeof(char *))) == NULL) {
-		warnx("malloc failed");
+		xo_warnx("malloc failed");
 		return (NULL);
 	}
 	nextcp = fslist;



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