Module Name:    src
Committed By:   christos
Date:           Fri May  4 11:48:12 UTC 2012

Modified Files:
        src/lib/libossaudio: ossaudio.c soundcard.h

Log Message:
- match regular ioctl prototype (3rd argument is optional)
- fix lint issues


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.19 -r1.20 src/lib/libossaudio/soundcard.h

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

Modified files:

Index: src/lib/libossaudio/ossaudio.c
diff -u src/lib/libossaudio/ossaudio.c:1.26 src/lib/libossaudio/ossaudio.c:1.27
--- src/lib/libossaudio/ossaudio.c:1.26	Tue Sep 13 15:10:18 2011
+++ src/lib/libossaudio/ossaudio.c	Fri May  4 07:48:12 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.26 2011/09/13 19:10:18 christos Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.27 2012/05/04 11:48:12 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: ossaudio.c,v 1.26 2011/09/13 19:10:18 christos Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.27 2012/05/04 11:48:12 christos Exp $");
 
 /*
  * This is an OSS (Linux) sound API emulator.
@@ -44,6 +44,7 @@ __RCSID("$NetBSD: ossaudio.c,v 1.26 2011
 #include <sys/audioio.h>
 #include <sys/stat.h>
 #include <errno.h>
+#include <stdarg.h>
 
 #include "soundcard.h"
 #undef ioctl
@@ -59,15 +60,22 @@ static void setblocksize(int, struct aud
 
 static int audio_ioctl(int, unsigned long, void *);
 static int mixer_ioctl(int, unsigned long, void *);
-static int opaque_to_enum(struct audiodevinfo *di, audio_mixer_name_t *label, int opq);
-static int enum_to_ord(struct audiodevinfo *di, int enm);
-static int enum_to_mask(struct audiodevinfo *di, int enm);
+static int opaque_to_enum(struct audiodevinfo *, audio_mixer_name_t *, int);
+static int enum_to_ord(struct audiodevinfo *, int);
+static int enum_to_mask(struct audiodevinfo *, int);
 
 #define INTARG (*(int*)argp)
 
 int
-_oss_ioctl(int fd, unsigned long com, void *argp)
+_oss_ioctl(int fd, unsigned long com, ...)
 {
+	va_list ap;
+	void *argp;
+
+	va_start(ap, com);
+	argp = va_arg(ap, void *);
+	va_end(ap);
+
 	if (IOCGROUP(com) == 'P')
 		return audio_ioctl(fd, com, argp);
 	else if (IOCGROUP(com) == 'M')
@@ -352,10 +360,11 @@ audio_ioctl(int fd, unsigned long com, v
 			return retval;
 		setblocksize(fd, &tmpinfo);
 		bufinfo.fragsize = tmpinfo.blocksize;
-		bufinfo.fragments = tmpinfo.hiwat -
-			(tmpinfo.play.seek + tmpinfo.blocksize - 1)/tmpinfo.blocksize;
+		bufinfo.fragments = tmpinfo.hiwat - (tmpinfo.play.seek
+		    + tmpinfo.blocksize - 1) / tmpinfo.blocksize;
 		bufinfo.fragstotal = tmpinfo.hiwat;
-		bufinfo.bytes = tmpinfo.hiwat * tmpinfo.blocksize - tmpinfo.play.seek;
+		bufinfo.bytes = tmpinfo.hiwat * tmpinfo.blocksize
+		    - tmpinfo.play.seek;
 		*(struct audio_buf_info *)argp = bufinfo;
 		break;
 	case SNDCTL_DSP_GETISPACE:
@@ -364,10 +373,11 @@ audio_ioctl(int fd, unsigned long com, v
 			return retval;
 		setblocksize(fd, &tmpinfo);
 		bufinfo.fragsize = tmpinfo.blocksize;
-		bufinfo.fragments = tmpinfo.hiwat -
-			(tmpinfo.record.seek + tmpinfo.blocksize - 1)/tmpinfo.blocksize;
+		bufinfo.fragments = tmpinfo.hiwat - (tmpinfo.record.seek +
+		    tmpinfo.blocksize - 1) / tmpinfo.blocksize;
 		bufinfo.fragstotal = tmpinfo.hiwat;
-		bufinfo.bytes = tmpinfo.hiwat * tmpinfo.blocksize - tmpinfo.record.seek;
+		bufinfo.bytes = tmpinfo.hiwat * tmpinfo.blocksize
+		    - tmpinfo.record.seek;
 		*(struct audio_buf_info *)argp = bufinfo;
 		break;
 	case SNDCTL_DSP_NONBLOCK:
@@ -567,7 +577,7 @@ getdevinfo(int fd)
 	static struct audiodevinfo devcache = { 0 };
 	struct audiodevinfo *di = &devcache;
 	struct stat sb;
-	int mlen, dlen;
+	size_t mlen, dlen;
 
 	/* Figure out what device it is so we can check if the
 	 * cached data is valid.
@@ -604,7 +614,8 @@ getdevinfo(int fd)
 				mlen = strlen(mi.label.name);
 				if (dlen < mlen
 				    && mi.label.name[mlen-dlen-1] == '.'
-				    && strcmp(dp->name, mi.label.name + mlen - dlen) == 0)
+				    && strcmp(dp->name,
+				    mi.label.name + mlen - dlen) == 0)
 					break;
 			}
 			if (dp->code >= 0) {
@@ -658,10 +669,10 @@ mixer_ioctl(int fd, unsigned long com, v
 	struct mixer_info *omi;
 	struct audio_device adev;
 	mixer_ctrl_t mc;
-	int idat;
+	u_long idat, n;
 	int i;
 	int retval;
-	int l, r, n, error, e;
+	int l, r, error, e;
 
 	idat = 0;
 	di = getdevinfo(fd);
@@ -739,7 +750,8 @@ mixer_ioctl(int fd, unsigned long com, v
 				if (idat & (1 << i)) {
 					if (di->devmap[i] == -1)
 						return EINVAL;
-					mc.un.mask |= enum_to_mask(di, di->devmap[i]);
+					mc.un.mask |=
+					    enum_to_mask(di, di->devmap[i]);
 				}
 			}
 		}
@@ -753,14 +765,16 @@ mixer_ioctl(int fd, unsigned long com, v
 			mc.dev = di->devmap[n];
 			mc.type = AUDIO_MIXER_VALUE;
 		    doread:
-			mc.un.value.num_channels = di->stereomask & (1<<n) ? 2 : 1;
+			mc.un.value.num_channels =
+			    di->stereomask & (1 << (u_int)n) ? 2 : 1;
 			retval = ioctl(fd, AUDIO_MIXER_READ, &mc);
 			if (retval < 0)
 				return retval;
 			if (mc.type != AUDIO_MIXER_VALUE)
 				return EINVAL;
 			if (mc.un.value.num_channels != 2) {
-				l = r = mc.un.value.level[AUDIO_MIXER_LEVEL_MONO];
+				l = r =
+				    mc.un.value.level[AUDIO_MIXER_LEVEL_MONO];
 			} else {
 				l = mc.un.value.level[AUDIO_MIXER_LEVEL_LEFT];
 				r = mc.un.value.level[AUDIO_MIXER_LEVEL_RIGHT];
@@ -775,17 +789,18 @@ mixer_ioctl(int fd, unsigned long com, v
 			if (di->devmap[n] == -1)
 				return EINVAL;
 			idat = INTARG;
-			l = FROM_OSSVOL( idat       & 0xff);
+			l = FROM_OSSVOL((u_int)idat & 0xff);
 			r = FROM_OSSVOL(((u_int)idat >> 8) & 0xff);
 			mc.dev = di->devmap[n];
 			mc.type = AUDIO_MIXER_VALUE;
-			if (di->stereomask & (1<<n)) {
+			if (di->stereomask & (1 << (u_int)n)) {
 				mc.un.value.num_channels = 2;
 				mc.un.value.level[AUDIO_MIXER_LEVEL_LEFT] = l;
 				mc.un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = r;
 			} else {
 				mc.un.value.num_channels = 1;
-				mc.un.value.level[AUDIO_MIXER_LEVEL_MONO] = (l+r)/2;
+				mc.un.value.level[AUDIO_MIXER_LEVEL_MONO] =
+				    (l + r) / 2;
 			}
 			retval = ioctl(fd, AUDIO_MIXER_WRITE, &mc);
 			if (retval < 0)
@@ -799,7 +814,7 @@ mixer_ioctl(int fd, unsigned long com, v
 			return -1;
 		}
 	}
-	INTARG = idat;
+	INTARG = (int)idat;
 	return 0;
 }
 

Index: src/lib/libossaudio/soundcard.h
diff -u src/lib/libossaudio/soundcard.h:1.19 src/lib/libossaudio/soundcard.h:1.20
--- src/lib/libossaudio/soundcard.h:1.19	Mon Sep  5 21:20:18 2011
+++ src/lib/libossaudio/soundcard.h	Fri May  4 07:48:12 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: soundcard.h,v 1.19 2011/09/06 01:20:18 jmcneill Exp $	*/
+/*	$NetBSD: soundcard.h,v 1.20 2012/05/04 11:48:12 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -302,13 +302,13 @@ typedef struct buffmem_desc {
  * happening if it is pulled in later.
  */
 #include <sys/ioctl.h>
-#define ioctl(x,y,z) _oss_ioctl(x,y,z)
+#define ioctl(x, y, ...) _oss_ioctl(x, y, __VA_ARGS__)
 #endif
 
 #include <sys/cdefs.h>
 
 __BEGIN_DECLS
-int _oss_ioctl(int fd, unsigned long com, void *argp);
+int _oss_ioctl(int, unsigned long, ...);
 __END_DECLS
 
 #endif /* !_SOUNDCARD_H_ */

Reply via email to