git: 09ba07011a62 - main - mixer(8): Improve error messsages and warnings
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 12 Feb 2024 11:00:19 UTC
The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=09ba07011a627e3ea05e0be8ee6db76fd2371540 commit 09ba07011a627e3ea05e0be8ee6db76fd2371540 Author: Christos Margiolis <christos@FreeBSD.org> AuthorDate: 2024-02-12 10:58:55 +0000 Commit: Christos Margiolis <christos@FreeBSD.org> CommitDate: 2024-02-12 10:59:58 +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 --- 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);