Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Feb 2024 23:22:43 GMT
From:      Christos Margiolis <christos@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 750a5298fee0 - stable/14 - mixer(8): Improve error messsages and warnings
Message-ID:  <202402262322.41QNMh90028299@gitrepo.freebsd.org>

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

URL: https://cgit.FreeBSD.org/src/commit/?id=750a5298fee0bd38bf5c9ec98554e2e3617b0294

commit 750a5298fee0bd38bf5c9ec98554e2e3617b0294
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2024-02-12 10:58:55 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2024-02-26 23:22:30 +0000

    mixer(8): Improve error messsages and warnings
    
    No functional change intended.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      2 weeks
    Reviewed by:    dev_submerge.ch, imp
    Differential Revision:  https://reviews.freebsd.org/D43793
    
    (cherry picked from commit 09ba07011a627e3ea05e0be8ee6db76fd2371540)
---
 usr.sbin/mixer/mixer.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/usr.sbin/mixer/mixer.c b/usr.sbin/mixer/mixer.c
index bb868fb5ca9b..043c8c412857 100644
--- a/usr.sbin/mixer/mixer.c
+++ b/usr.sbin/mixer/mixer.c
@@ -66,9 +66,10 @@ main(int argc, char *argv[])
 			aflag = 1;
 			break;
 		case 'd':
+			errno = 0;
 			dunit = strtol(optarg, NULL, 10);
 			if (errno == EINVAL || errno == ERANGE)
-				err(1, "strtol");
+				err(1, "strtol(%s)", optarg);
 			dflag = 1;
 			break;
 		case 'f':
@@ -92,11 +93,11 @@ main(int argc, char *argv[])
 	/* Print all mixers and exit. */
 	if (aflag) {
 		if ((n = mixer_get_nmixers()) < 0)
-			err(1, "mixer_get_nmixers");
+			errx(1, "no mixers present in the system");
 		for (i = 0; i < n; i++) {
 			(void)snprintf(buf, sizeof(buf), "/dev/mixer%d", i);
 			if ((m = mixer_open(buf)) == NULL)
-				err(1, "mixer_open: %s", buf);
+				errx(1, "%s: no such mixer", buf);
 			initctls(m);
 			if (sflag)
 				printrecsrc(m, oflag);
@@ -111,7 +112,7 @@ main(int argc, char *argv[])
 	}
 
 	if ((m = mixer_open(name)) == NULL)
-		err(1, "mixer_open: %s", name);
+		errx(1, "%s: no such mixer", name);
 
 	initctls(m);
 
@@ -212,7 +213,7 @@ initctls(struct mixer *m)
 	}
 	if (rc) {
 		(void)mixer_close(m);
-		err(1, "cannot make controls");
+		errx(1, "cannot make mixer controls");
 	}
 }
 
@@ -315,7 +316,7 @@ set_dunit(struct mixer *m, int dunit)
 		return (-1);
 	}
 	if (mixer_set_dunit(m, dunit) < 0) {
-		warn("cannot set default unit to: %d", dunit);
+		warn("cannot set default unit to %d", dunit);
 		return (-1);
 	}
 	printf("default_unit: %d -> %d\n", n, dunit);



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