CVS commit: src/usr.bin/mixerctl

2021-12-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 26 15:36:49 UTC 2021

Modified Files:
src/usr.bin/mixerctl: mixerctl.c

Log Message:
mixerctl: add colon after 'Usage', add space after comma


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/mixerctl/mixerctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/mixerctl/mixerctl.c
diff -u src/usr.bin/mixerctl/mixerctl.c:1.29 src/usr.bin/mixerctl/mixerctl.c:1.30
--- src/usr.bin/mixerctl/mixerctl.c:1.29	Fri Dec 17 13:50:10 2021
+++ src/usr.bin/mixerctl/mixerctl.c	Sun Dec 26 15:36:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mixerctl.c,v 1.29 2021/12/17 13:50:10 christos Exp $	*/
+/*	$NetBSD: mixerctl.c,v 1.30 2021/12/26 15:36:49 rillig Exp $	*/
 
 /*
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: mixerctl.c,v 1.29 2021/12/17 13:50:10 christos Exp $");
+__RCSID("$NetBSD: mixerctl.c,v 1.30 2021/12/26 15:36:49 rillig Exp $");
 #endif
 
 #include 
@@ -329,8 +329,8 @@ usage(void)
 {
 	const char *prog = getprogname();
 
-	fprintf(stderr, "Usage\t%s [-d file] [-v] [-n] name ...\n", prog);
-	fprintf(stderr, "\t%s [-d file] [-v] [-n] -w name=value ...\n",prog);
+	fprintf(stderr, "Usage:\t%s [-d file] [-v] [-n] name ...\n", prog);
+	fprintf(stderr, "\t%s [-d file] [-v] [-n] -w name=value ...\n", prog);
 	fprintf(stderr, "\t%s [-d file] [-v] [-n] -a\n", prog);
 	exit(EXIT_FAILURE);
 }



CVS commit: src/usr.bin/mixerctl

2021-12-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 26 15:36:49 UTC 2021

Modified Files:
src/usr.bin/mixerctl: mixerctl.c

Log Message:
mixerctl: add colon after 'Usage', add space after comma


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/mixerctl/mixerctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/mixerctl

2021-12-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Dec 17 13:50:10 UTC 2021

Modified Files:
src/usr.bin/mixerctl: mixerctl.c

Log Message:
fix error messages, usage, add static, more checks for ioctl, KNF


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/mixerctl/mixerctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/mixerctl/mixerctl.c
diff -u src/usr.bin/mixerctl/mixerctl.c:1.28 src/usr.bin/mixerctl/mixerctl.c:1.29
--- src/usr.bin/mixerctl/mixerctl.c:1.28	Fri Dec 17 08:42:06 2021
+++ src/usr.bin/mixerctl/mixerctl.c	Fri Dec 17 08:50:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mixerctl.c,v 1.28 2021/12/17 13:42:06 christos Exp $	*/
+/*	$NetBSD: mixerctl.c,v 1.29 2021/12/17 13:50:10 christos Exp $	*/
 
 /*
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: mixerctl.c,v 1.28 2021/12/17 13:42:06 christos Exp $");
+__RCSID("$NetBSD: mixerctl.c,v 1.29 2021/12/17 13:50:10 christos Exp $");
 #endif
 
 #include 
@@ -46,20 +46,18 @@ __RCSID("$NetBSD: mixerctl.c,v 1.28 2021
 
 #include 
 
-FILE *out = stdout;
-int vflag = 0;
+static FILE *out = stdout;
+static int vflag = 0;
 
-char *prog;
-
-struct field {
+static struct field {
 	char *name;
 	mixer_ctrl_t *valp;
 	mixer_devinfo_t *infp;
 	char changed;
 } *fields, *rfields;
 
-mixer_ctrl_t *values;
-mixer_devinfo_t *infos;
+static mixer_ctrl_t *values;
+static mixer_devinfo_t *infos;
 
 static const char mixer_path[] = _PATH_MIXER;
 
@@ -70,12 +68,12 @@ catstr(char *p, char *q)
 
 	asprintf(, "%s.%s", p, q);
 	if (!r)
-		err(1, "malloc");
+		err(EXIT_FAILURE, "malloc");
 	return r;
 }
 
 static struct field *
-findfield(char *name)
+findfield(const char *name)
 {
 	int i;
 	for (i = 0; fields[i].name; i++)
@@ -134,7 +132,7 @@ prfield(struct field *p, const char *sep
 		break;
 	default:
 		printf("\n");
-		errx(1, "Invalid format.");
+		errx(EXIT_FAILURE, "Invalid format %d", m->type);
 	}
 }
 
@@ -210,7 +208,7 @@ rdfield(struct field *p, char *q)
 		}
 		break;
 	default:
-		errx(1, "Invalid format.");
+		errx(EXIT_FAILURE, "Invalid format %d", m->type);
 	}
 	p->changed = 1;
 	return 1;
@@ -249,7 +247,7 @@ incfield(struct field *p, int inc)
 		}
 		break;
 	default:
-		errx(1, "Invalid format.");
+		errx(EXIT_FAILURE, "Invalid format %d", m->type);
 	}
 	p->changed = 1;
 	return 1;
@@ -300,12 +298,13 @@ wrarg(int fd, char *arg, const char *sep
 	else
 		r = incfield(p, incdec);
 	if (r) {
-		if (ioctl(fd, AUDIO_MIXER_WRITE, p->valp) < 0)
+		if (ioctl(fd, AUDIO_MIXER_WRITE, p->valp) == -1)
 			warn("AUDIO_MIXER_WRITE");
 		else if (sep) {
 			*p->valp = val;
 			prfield(p, ": ", 0);
-			ioctl(fd, AUDIO_MIXER_READ, p->valp);
+			if (ioctl(fd, AUDIO_MIXER_READ, p->valp) == -1)
+warn("AUDIO_MIXER_READ");
 			printf(" -> ");
 			prfield(p, 0, 0);
 			printf("\n");
@@ -328,10 +327,12 @@ prarg(int fd, char *arg, const char *sep
 static inline void __dead
 usage(void)
 {
-	fprintf(out, "%s [-d file] [-v] [-n] name ...\n", prog);
-	fprintf(out, "%s [-d file] [-v] [-n] -w name=value ...\n",prog);
-	fprintf(out, "%s [-d file] [-v] [-n] -a\n", prog);
-	exit(0);
+	const char *prog = getprogname();
+
+	fprintf(stderr, "Usage\t%s [-d file] [-v] [-n] name ...\n", prog);
+	fprintf(stderr, "\t%s [-d file] [-v] [-n] -w name=value ...\n",prog);
+	fprintf(stderr, "\t%s [-d file] [-v] [-n] -a\n", prog);
+	exit(EXIT_FAILURE);
 }
 
 int
@@ -348,7 +349,6 @@ main(int argc, char **argv)
 	if (file == NULL)
 		file = mixer_path;
 
-	prog = *argv;
 
 	while ((ch = getopt(argc, argv, "ad:f:nvw")) != -1) {
 		switch(ch) {
@@ -381,17 +381,17 @@ main(int argc, char **argv)
 
 	fd = open(file, O_RDWR);
 	/* Try with mixer0 but only if using the default device. */
-	if (fd < 0 && file == mixer_path) {
+	if (fd == -1 && file == mixer_path) {
 		file = _PATH_MIXER0;
 		fd = open(file, O_RDWR);
 	}
 
-	if (fd < 0)
-		err(1, "%s", file);
+	if (fd == -1)
+		err(EXIT_FAILURE, "Can't open `%s'", file);
 
 	for (ndev = 0; ; ndev++) {
 		dinfo.index = ndev;
-		if (ioctl(fd, AUDIO_MIXER_DEVINFO, ) < 0)
+		if (ioctl(fd, AUDIO_MIXER_DEVINFO, ) == -1)
 			break;
 	}
 	rfields = calloc(ndev, sizeof *rfields);
@@ -401,7 +401,8 @@ main(int argc, char **argv)
 
 	for (i = 0; i < ndev; i++) {
 		infos[i].index = i;
-		ioctl(fd, AUDIO_MIXER_DEVINFO, [i]);
+		if (ioctl(fd, AUDIO_MIXER_DEVINFO, [i]) == -1)
+			warn("AUDIO_MIXER_DEVINFO for %d", i);
 	}
 
 	for (i = 0; i < ndev; i++) {
@@ -415,10 +416,11 @@ main(int argc, char **argv)
 		values[i].type = infos[i].type;
 		if (infos[i].type != AUDIO_MIXER_CLASS) {
 			values[i].un.value.num_channels = 2;
-			if (ioctl(fd, AUDIO_MIXER_READ, [i]) < 0) {
+			if (ioctl(fd, AUDIO_MIXER_READ, [i]) == -1) {
 values[i].un.value.num_channels = 1;
-if (ioctl(fd, AUDIO_MIXER_READ, [i]) < 0)
-	err(1, "AUDIO_MIXER_READ");
+if (ioctl(fd, 

CVS commit: src/usr.bin/mixerctl

2021-12-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Dec 17 13:42:06 UTC 2021

Modified Files:
src/usr.bin/mixerctl: mixerctl.c

Log Message:
Provide a clipping function and use it to prevent setting values out of bounds.
(from RVP)


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/mixerctl/mixerctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/mixerctl/mixerctl.c
diff -u src/usr.bin/mixerctl/mixerctl.c:1.27 src/usr.bin/mixerctl/mixerctl.c:1.28
--- src/usr.bin/mixerctl/mixerctl.c:1.27	Thu Feb 23 09:09:11 2017
+++ src/usr.bin/mixerctl/mixerctl.c	Fri Dec 17 08:42:06 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mixerctl.c,v 1.27 2017/02/23 14:09:11 kre Exp $	*/
+/*	$NetBSD: mixerctl.c,v 1.28 2021/12/17 13:42:06 christos Exp $	*/
 
 /*
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: mixerctl.c,v 1.27 2017/02/23 14:09:11 kre Exp $");
+__RCSID("$NetBSD: mixerctl.c,v 1.28 2021/12/17 13:42:06 christos Exp $");
 #endif
 
 #include 
@@ -139,6 +139,16 @@ prfield(struct field *p, const char *sep
 }
 
 static int
+clip(int vol)
+{
+	if (vol <= AUDIO_MIN_GAIN)
+		return AUDIO_MIN_GAIN;
+	if (vol >= AUDIO_MAX_GAIN)
+		return AUDIO_MAX_GAIN;
+	return vol;
+}
+
+static int
 rdfield(struct field *p, char *q)
 {
 	mixer_ctrl_t *m;
@@ -181,17 +191,18 @@ rdfield(struct field *p, char *q)
 	case AUDIO_MIXER_VALUE:
 		if (m->un.value.num_channels == 1) {
 			if (sscanf(q, "%d", ) == 1) {
-m->un.value.level[0] = v;
+m->un.value.level[0] = clip(v);
 			} else {
 warnx("Bad number %s", q);
 return 0;
 			}
 		} else {
 			if (sscanf(q, "%d,%d", , ) == 2) {
-m->un.value.level[0] = v0;
-m->un.value.level[1] = v1;
+m->un.value.level[0] = clip(v0);
+m->un.value.level[1] = clip(v1);
 			} else if (sscanf(q, "%d", ) == 1) {
-m->un.value.level[0] = m->un.value.level[1] = v;
+m->un.value.level[0] =
+m->un.value.level[1] = clip(v);
 			} else {
 warnx("Bad numbers %s", q);
 return 0;
@@ -234,11 +245,7 @@ incfield(struct field *p, int inc)
 		for (i = 0; i < m->un.value.num_channels; i++) {
 			v = m->un.value.level[i];
 			v += inc;
-			if (v < AUDIO_MIN_GAIN)
-v = AUDIO_MIN_GAIN;
-			if (v > AUDIO_MAX_GAIN)
-v = AUDIO_MAX_GAIN;
-			m->un.value.level[i] = v;
+			m->un.value.level[i] = clip(v);
 		}
 		break;
 	default:



CVS commit: src/usr.bin/mixerctl

2021-12-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Dec 17 13:42:06 UTC 2021

Modified Files:
src/usr.bin/mixerctl: mixerctl.c

Log Message:
Provide a clipping function and use it to prevent setting values out of bounds.
(from RVP)


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/mixerctl/mixerctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/mixerctl

2017-02-23 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Feb 23 14:09:11 UTC 2017

Modified Files:
src/usr.bin/mixerctl: mixerctl.c

Log Message:
Generate usage error for bad usage, before attempting any other operations.
This means that "mixerctl" (no args) will generate a usage msg, even when
/dev/mixer cannot be opened (or any other device given via -d or $MIXERDEVICE)

While here, get rid of "goto usage" replacing the usage: with a
static inline void __dead function...  The compiler ought to optimise
the calls into essentially the same code as existed with the goto version,
but this is much cleaner.

Also, mixerctl falls back on /dev/mixer0 if /dev/mixer cannot be opened.
(that is old code - probably from when /dev/mixer was first added)

It used to do that when called as mixerctl -d /dev/mixer or with
"MIXERDEVICE=/dev/mixer mixerctl...".   No longer.  Now the fallback (which
is probably obsolete now anyway) only happens when the user doesn't specify
any mixer device (by either method) and the default of /dev/mixer is used.
In other cases, only the device specified is tried.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/mixerctl/mixerctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/mixerctl/mixerctl.c
diff -u src/usr.bin/mixerctl/mixerctl.c:1.26 src/usr.bin/mixerctl/mixerctl.c:1.27
--- src/usr.bin/mixerctl/mixerctl.c:1.26	Sun Oct 28 02:01:15 2012
+++ src/usr.bin/mixerctl/mixerctl.c	Thu Feb 23 14:09:11 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mixerctl.c,v 1.26 2012/10/28 02:01:15 isaki Exp $	*/
+/*	$NetBSD: mixerctl.c,v 1.27 2017/02/23 14:09:11 kre Exp $	*/
 
 /*
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: mixerctl.c,v 1.26 2012/10/28 02:01:15 isaki Exp $");
+__RCSID("$NetBSD: mixerctl.c,v 1.27 2017/02/23 14:09:11 kre Exp $");
 #endif
 
 #include 
@@ -61,6 +61,8 @@ struct field {
 mixer_ctrl_t *values;
 mixer_devinfo_t *infos;
 
+static const char mixer_path[] = _PATH_MIXER;
+
 static char *
 catstr(char *p, char *q)
 {
@@ -316,6 +318,15 @@ prarg(int fd, char *arg, const char *sep
 		prfield(p, sep, vflag), fprintf(out, "\n");
 }
 
+static inline void __dead
+usage(void)
+{
+	fprintf(out, "%s [-d file] [-v] [-n] name ...\n", prog);
+	fprintf(out, "%s [-d file] [-v] [-n] -w name=value ...\n",prog);
+	fprintf(out, "%s [-d file] [-v] [-n] -a\n", prog);
+	exit(0);
+}
+
 int
 main(int argc, char **argv)
 {
@@ -328,7 +339,7 @@ main(int argc, char **argv)
 
 	file = getenv("MIXERDEVICE");
 	if (file == NULL)
-		file = _PATH_MIXER;
+		file = mixer_path;
 
 	prog = *argv;
 
@@ -352,19 +363,18 @@ main(int argc, char **argv)
 			break;
 		case '?':
 		default:
-		usage:
-			fprintf(out, "%s [-d file] [-v] [-n] name ...\n", prog);
-			fprintf(out, "%s [-d file] [-v] [-n] -w name=value ...\n",prog);
-			fprintf(out, "%s [-d file] [-v] [-n] -a\n", prog);
-			exit(0);
+			usage();
 		}
 	}
 	argc -= optind;
 	argv += optind;
 
+	if (aflag ? (argc != 0 || wflag) : argc == 0)
+		usage();
+
 	fd = open(file, O_RDWR);
-	/* Try with mixer0. */
-	if (fd < 0 && strcmp(file, _PATH_MIXER) == 0) {
+	/* Try with mixer0 but only if using the default device. */
+	if (fd < 0 && file == mixer_path) {
 		file = _PATH_MIXER0;
 		fd = open(file, O_RDWR);
 	}
@@ -442,6 +452,6 @@ main(int argc, char **argv)
 			argv++;
 		}
 	} else
-		goto usage;
+		usage();
 	exit(0);
 }



CVS commit: src/usr.bin/mixerctl

2017-02-23 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Feb 23 14:09:11 UTC 2017

Modified Files:
src/usr.bin/mixerctl: mixerctl.c

Log Message:
Generate usage error for bad usage, before attempting any other operations.
This means that "mixerctl" (no args) will generate a usage msg, even when
/dev/mixer cannot be opened (or any other device given via -d or $MIXERDEVICE)

While here, get rid of "goto usage" replacing the usage: with a
static inline void __dead function...  The compiler ought to optimise
the calls into essentially the same code as existed with the goto version,
but this is much cleaner.

Also, mixerctl falls back on /dev/mixer0 if /dev/mixer cannot be opened.
(that is old code - probably from when /dev/mixer was first added)

It used to do that when called as mixerctl -d /dev/mixer or with
"MIXERDEVICE=/dev/mixer mixerctl...".   No longer.  Now the fallback (which
is probably obsolete now anyway) only happens when the user doesn't specify
any mixer device (by either method) and the default of /dev/mixer is used.
In other cases, only the device specified is tried.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/mixerctl/mixerctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/mixerctl

2012-10-27 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Oct 28 01:51:20 UTC 2012

Modified Files:
src/usr.bin/mixerctl: mixerctl.c

Log Message:
Avoid SEGV even if audio device has no mixer features.
Fix PR/47003


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/mixerctl/mixerctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/mixerctl/mixerctl.c
diff -u src/usr.bin/mixerctl/mixerctl.c:1.24 src/usr.bin/mixerctl/mixerctl.c:1.25
--- src/usr.bin/mixerctl/mixerctl.c:1.24	Tue Jul 14 21:02:24 2009
+++ src/usr.bin/mixerctl/mixerctl.c	Sun Oct 28 01:51:20 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mixerctl.c,v 1.24 2009/07/14 21:02:24 apb Exp $	*/
+/*	$NetBSD: mixerctl.c,v 1.25 2012/10/28 01:51:20 isaki Exp $	*/
 
 /*
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 #include sys/cdefs.h
 
 #ifndef lint
-__RCSID($NetBSD: mixerctl.c,v 1.24 2009/07/14 21:02:24 apb Exp $);
+__RCSID($NetBSD: mixerctl.c,v 1.25 2012/10/28 01:51:20 isaki Exp $);
 #endif
 
 #include stdio.h
@@ -429,7 +429,7 @@ main(int argc, char **argv)
 	}
 
 	if (argc == 0  aflag  !wflag) {
-		for(i = 0; fields[i].name; i++) {
+		for(i = 0; i  j; i++) {
 			prfield(fields[i], sep, vflag);
 			fprintf(out, \n);
 		}



CVS commit: src/usr.bin/mixerctl

2012-10-27 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Oct 28 02:01:15 UTC 2012

Modified Files:
src/usr.bin/mixerctl: mixerctl.c

Log Message:
Fix indent and style. no functional changes.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/mixerctl/mixerctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/mixerctl/mixerctl.c
diff -u src/usr.bin/mixerctl/mixerctl.c:1.25 src/usr.bin/mixerctl/mixerctl.c:1.26
--- src/usr.bin/mixerctl/mixerctl.c:1.25	Sun Oct 28 01:51:20 2012
+++ src/usr.bin/mixerctl/mixerctl.c	Sun Oct 28 02:01:15 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mixerctl.c,v 1.25 2012/10/28 01:51:20 isaki Exp $	*/
+/*	$NetBSD: mixerctl.c,v 1.26 2012/10/28 02:01:15 isaki Exp $	*/
 
 /*
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 #include sys/cdefs.h
 
 #ifndef lint
-__RCSID($NetBSD: mixerctl.c,v 1.25 2012/10/28 01:51:20 isaki Exp $);
+__RCSID($NetBSD: mixerctl.c,v 1.26 2012/10/28 02:01:15 isaki Exp $);
 #endif
 
 #include stdio.h
@@ -76,7 +76,7 @@ static struct field *
 findfield(char *name)
 {
 	int i;
-	for(i = 0; fields[i].name; i++)
+	for (i = 0; fields[i].name; i++)
 		if (strcmp(fields[i].name, name) == 0)
 			return fields[i];
 	return 0;
@@ -93,26 +93,26 @@ prfield(struct field *p, const char *sep
 	m = p-valp;
 	switch(m-type) {
 	case AUDIO_MIXER_ENUM:
-		for(i = 0; i  p-infp-un.e.num_mem; i++)
+		for (i = 0; i  p-infp-un.e.num_mem; i++)
 			if (p-infp-un.e.member[i].ord == m-un.ord)
 fprintf(out, %s,
-	p-infp-un.e.member[i].label.name);
+p-infp-un.e.member[i].label.name);
 		if (prvalset) {
 			fprintf(out,   [ );
-			for(i = 0; i  p-infp-un.e.num_mem; i++)
+			for (i = 0; i  p-infp-un.e.num_mem; i++)
 fprintf(out, %s ,
 p-infp-un.e.member[i].label.name);
 			fprintf(out, ]);
 		}
 		break;
 	case AUDIO_MIXER_SET:
-		for(n = i = 0; i  p-infp-un.s.num_mem; i++)
+		for (n = i = 0; i  p-infp-un.s.num_mem; i++)
 			if (m-un.mask  p-infp-un.s.member[i].mask)
 fprintf(out, %s%s, n++ ? , : ,
-	p-infp-un.s.member[i].label.name);
+p-infp-un.s.member[i].label.name);
 		if (prvalset) {
 			fprintf(out,   { );
-			for(i = 0; i  p-infp-un.s.num_mem; i++)
+			for (i = 0; i  p-infp-un.s.num_mem; i++)
 fprintf(out, %s ,
 p-infp-un.s.member[i].label.name);
 			fprintf(out, });
@@ -123,7 +123,7 @@ prfield(struct field *p, const char *sep
 			fprintf(out, %d, m-un.value.level[0]);
 		else
 			fprintf(out, %d,%d, m-un.value.level[0], 
-			   m-un.value.level[1]);
+			m-un.value.level[1]);
 		if (prvalset) {
 			fprintf(out,  %s, p-infp-un.v.units.name);
 			if (p-infp-un.v.delta)
@@ -147,7 +147,7 @@ rdfield(struct field *p, char *q)
 	m = p-valp;
 	switch(m-type) {
 	case AUDIO_MIXER_ENUM:
-		for(i = 0; i  p-infp-un.e.num_mem; i++)
+		for (i = 0; i  p-infp-un.e.num_mem; i++)
 			if (strcmp(p-infp-un.e.member[i].label.name, q) == 0)
 break;
 		if (i  p-infp-un.e.num_mem)
@@ -159,13 +159,13 @@ rdfield(struct field *p, char *q)
 		break;
 	case AUDIO_MIXER_SET:
 		mask = 0;
-		for(v = 0; q  *q; q = s) {
+		for (v = 0; q  *q; q = s) {
 			s = strchr(q, ',');
 			if (s)
 *s++ = 0;
-			for(i = 0; i  p-infp-un.s.num_mem; i++)
+			for (i = 0; i  p-infp-un.s.num_mem; i++)
 if (strcmp(p-infp-un.s.member[i].label.name,
-	   q) == 0)
+q) == 0)
 	break;
 			if (i  p-infp-un.s.num_mem) {
 mask |= p-infp-un.s.member[i].mask;
@@ -214,7 +214,7 @@ incfield(struct field *p, int inc)
 	case AUDIO_MIXER_ENUM:
 		m-un.ord += inc;
 		if (m-un.ord  0)
-			m-un.ord = p-infp-un.e.num_mem-1;
+			m-un.ord = p-infp-un.e.num_mem - 1;
 		if (m-un.ord = p-infp-un.e.num_mem)
 			m-un.ord = 0;
 		break;
@@ -276,7 +276,7 @@ wrarg(int fd, char *arg, const char *sep
 			incdec *= -1;
 		*(q-1) = 0;
 		q = NULL;
-	} else		
+	} else
 		*q++ = 0;
 
 	p = findfield(arg);
@@ -353,26 +353,26 @@ main(int argc, char **argv)
 		case '?':
 		default:
 		usage:
-		fprintf(out, %s [-d file] [-v] [-n] name ...\n, prog);
-		fprintf(out, %s [-d file] [-v] [-n] -w name=value ...\n,prog);
-		fprintf(out, %s [-d file] [-v] [-n] -a\n, prog);
-		exit(0);
+			fprintf(out, %s [-d file] [-v] [-n] name ...\n, prog);
+			fprintf(out, %s [-d file] [-v] [-n] -w name=value ...\n,prog);
+			fprintf(out, %s [-d file] [-v] [-n] -a\n, prog);
+			exit(0);
 		}
 	}
 	argc -= optind;
 	argv += optind;
-
+
 	fd = open(file, O_RDWR);
-/* Try with mixer0. */
-if (fd  0  strcmp(file, _PATH_MIXER) == 0) {
-	file = _PATH_MIXER0;
-fd = open(file, O_RDWR);
-}
+	/* Try with mixer0. */
+	if (fd  0  strcmp(file, _PATH_MIXER) == 0) {
+		file = _PATH_MIXER0;
+		fd = open(file, O_RDWR);
+	}
 
 	if (fd  0)
 		err(1, %s, file);
 
-	for(ndev = 0; ; ndev++) {
+	for (ndev = 0; ; ndev++) {
 		dinfo.index = ndev;
 		if (ioctl(fd, AUDIO_MIXER_DEVINFO, dinfo)  0)
 			break;
@@ -382,18 +382,18 @@ 

CVS commit: src/usr.bin/mixerctl

2012-10-27 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Oct 28 01:51:20 UTC 2012

Modified Files:
src/usr.bin/mixerctl: mixerctl.c

Log Message:
Avoid SEGV even if audio device has no mixer features.
Fix PR/47003


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/mixerctl/mixerctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/mixerctl

2012-10-27 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Oct 28 02:01:15 UTC 2012

Modified Files:
src/usr.bin/mixerctl: mixerctl.c

Log Message:
Fix indent and style. no functional changes.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/mixerctl/mixerctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/mixerctl

2010-05-14 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri May 14 17:20:06 UTC 2010

Modified Files:
src/usr.bin/mixerctl: mixerctl.1

Log Message:
Resort sections to canonical order


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/mixerctl/mixerctl.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/mixerctl/mixerctl.1
diff -u src/usr.bin/mixerctl/mixerctl.1:1.24 src/usr.bin/mixerctl/mixerctl.1:1.25
--- src/usr.bin/mixerctl/mixerctl.1:1.24	Wed Aug 19 15:26:59 2009
+++ src/usr.bin/mixerctl/mixerctl.1	Fri May 14 17:20:06 2010
@@ -1,4 +1,4 @@
-.\ $NetBSD: mixerctl.1,v 1.24 2009/08/19 15:26:59 joerg Exp $
+.\ $NetBSD: mixerctl.1,v 1.25 2010/05/14 17:20:06 joerg Exp $
 .\
 .\ Copyright (c) 1997 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -166,6 +166,11 @@
 record.record.source=mic  [ mic cd dac ]
 monitor.monitor=0 volume
 .Ed
+.Sh COMPATIBILITY
+The old
+.Fl f
+flag is still supported.
+This support will be removed eventually.
 .Sh SEE ALSO
 .Xr audioctl 1 ,
 .Xr audio 4 ,
@@ -176,8 +181,3 @@
 .Nm
 command first appeared in
 .Nx 1.3 .
-.Sh COMPATIBILITY
-The old
-.Fl f
-flag is still supported.
-This support will be removed eventually.



CVS commit: src/usr.bin/mixerctl

2010-05-14 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri May 14 17:20:06 UTC 2010

Modified Files:
src/usr.bin/mixerctl: mixerctl.1

Log Message:
Resort sections to canonical order


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/mixerctl/mixerctl.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/mixerctl

2009-08-19 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Wed Aug 19 15:26:59 UTC 2009

Modified Files:
src/usr.bin/mixerctl: mixerctl.1

Log Message:
Fix-up syntax after wizd.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/mixerctl/mixerctl.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/mixerctl/mixerctl.1
diff -u src/usr.bin/mixerctl/mixerctl.1:1.23 src/usr.bin/mixerctl/mixerctl.1:1.24
--- src/usr.bin/mixerctl/mixerctl.1:1.23	Fri Aug 15 21:10:57 2008
+++ src/usr.bin/mixerctl/mixerctl.1	Wed Aug 19 15:26:59 2009
@@ -1,4 +1,4 @@
-.\ $NetBSD: mixerctl.1,v 1.23 2008/08/15 21:10:57 wiz Exp $
+.\ $NetBSD: mixerctl.1,v 1.24 2009/08/19 15:26:59 joerg Exp $
 .\
 .\ Copyright (c) 1997 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -99,7 +99,7 @@
 flag shows the possible values of enumeration and set valued
 variables.
 Enumerated values are shown in brackets
-.Pp Dq []
+.Pq Dq []
 and set values are shown in curly braces
 .Pq Dq {} .
 .Pp