Sun Aug 28 01:17:48 2011 UTC ()
ANSIfy. Add static. Add __dead.
(joerg)
diff -r1.19 -r1.20 src/usr.bin/audio/common/audio.c
diff -r1.16 -r1.17 src/usr.bin/audio/common/libaudio.h
diff -r1.6 -r1.7 src/usr.bin/audio/common/sun.c
diff -r1.9 -r1.10 src/usr.bin/audio/common/wav.c
diff -r1.38 -r1.39 src/usr.bin/audio/ctl/ctl.c
diff -r1.53 -r1.54 src/usr.bin/audio/play/play.c
diff -r1.50 -r1.51 src/usr.bin/audio/record/record.c
--- src/usr.bin/audio/common/audio.c 2008/05/29 14:51:27 1.19
+++ src/usr.bin/audio/common/audio.c 2011/08/28 01:17:47 1.20
@@ -1,4 +1,4 @@
-/* $NetBSD: audio.c,v 1.19 2008/05/29 14:51:27 mrg Exp $ */
+/* $NetBSD: audio.c,v 1.20 2011/08/28 01:17:47 joerg Exp $ */
/*
* Copyright (c) 1999 Matthew R. Green
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: audio.c,v 1.19 2008/05/29 14:51:27 mrg Exp $");
+__RCSID("$NetBSD: audio.c,v 1.20 2011/08/28 01:17:47 joerg Exp $");
#endif
@@ -51,7 +51,7 @@
/* what format am i? */
-struct {
+static const struct {
const char *fname;
int fno;
} formats[] = {
@@ -67,8 +67,7 @@
};
int
-audio_format_from_str(str)
- char *str;
+audio_format_from_str(char *str)
{
int i;
@@ -81,7 +80,7 @@
/* back and forth between encodings */
-struct {
+static const struct {
const char *ename;
int eno;
} encs[] = {
@@ -110,8 +109,7 @@
const char *
-audio_enc_from_val(val)
- int val;
+audio_enc_from_val(int val)
{
int i;
@@ -122,8 +120,7 @@
}
int
-audio_enc_to_val(enc)
- const char *enc;
+audio_enc_to_val(const char *enc)
{
int i;
@@ -137,9 +134,7 @@
}
void
-decode_int(arg, intp)
- const char *arg;
- int *intp;
+decode_int(const char *arg, int *intp)
{
char *ep;
int ret;
@@ -154,9 +149,7 @@
}
void
-decode_time(arg, tvp)
- const char *arg;
- struct timeval *tvp;
+decode_time(const char *arg, struct timeval *tvp)
{
char *s, *colon, *dot;
char *copy = strdup(arg);
@@ -206,9 +199,7 @@
* decode a string into an encoding value.
*/
void
-decode_encoding(arg, encp)
- const char *arg;
- int *encp;
+decode_encoding(const char *arg, int *encp)
{
size_t len;
int i;
@@ -222,7 +213,7 @@
errx(1, "unknown encoding `%s'", arg);
}
-const char *const audio_errlist[] = {
+static const char *const audio_errlist[] = {
"error zero", /* nothing? */
"no audio entry", /* AUDIO_ENOENT */
"short header", /* AUDIO_ESHORTHDR */
@@ -233,8 +224,7 @@
};
const char *
-audio_errstring(errval)
- int errval;
+audio_errstring(int errval)
{
errval = -errval;
--- src/usr.bin/audio/common/libaudio.h 2009/06/18 02:37:27 1.16
+++ src/usr.bin/audio/common/libaudio.h 2011/08/28 01:17:47 1.17
@@ -1,4 +1,4 @@
-/* $NetBSD: libaudio.h,v 1.16 2009/06/18 02:37:27 mrg Exp $ */
+/* $NetBSD: libaudio.h,v 1.17 2011/08/28 01:17:47 joerg Exp $ */
/*
* Copyright (c) 1999, 2009 Matthew R. Green
@@ -158,6 +158,8 @@
/* returns size of header, or -ve for failure */
ssize_t audio_wav_parse_hdr (void *, size_t, u_int *, u_int *, u_int *, u_int *, size_t *);
+
+extern int verbose;
/*
* audio routine error codes
--- src/usr.bin/audio/common/sun.c 2008/05/29 14:51:27 1.6
+++ src/usr.bin/audio/common/sun.c 2011/08/28 01:17:47 1.7
@@ -1,4 +1,4 @@
-/* $NetBSD: sun.c,v 1.6 2008/05/29 14:51:27 mrg Exp $ */
+/* $NetBSD: sun.c,v 1.7 2011/08/28 01:17:47 joerg Exp $ */
/*
* Copyright (c) 2002 Matthew R. Green
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: sun.c,v 1.6 2008/05/29 14:51:27 mrg Exp $");
+__RCSID("$NetBSD: sun.c,v 1.7 2011/08/28 01:17:47 joerg Exp $");
#endif
@@ -52,7 +52,7 @@
/*
* SunOS/NeXT .au format helpers
*/
-struct {
+static const struct {
int file_encoding;
int encoding;
int precision;
@@ -80,10 +80,7 @@
};
int
-audio_sun_to_encoding(sun_encoding, encp, precp)
- int sun_encoding;
- u_int *encp;
- u_int *precp;
+audio_sun_to_encoding(int sun_encoding, u_int *encp, u_int *precp)
{
int i;
@@ -97,10 +94,7 @@
}
int
-audio_encoding_to_sun(encoding, precision, sunep)
- int encoding;
- int precision;
- int *sunep;
+audio_encoding_to_sun(int encoding, int precision, int *sunep)
{
int i;
--- src/usr.bin/audio/common/wav.c 2009/06/18 02:37:27 1.9
+++ src/usr.bin/audio/common/wav.c 2011/08/28 01:17:47 1.10
@@ -1,4 +1,4 @@
-/* $NetBSD: wav.c,v 1.9 2009/06/18 02:37:27 mrg Exp $ */
+/* $NetBSD: wav.c,v 1.10 2011/08/28 01:17:47 joerg Exp $ */
/*
* Copyright (c) 2002, 2009 Matthew R. Green
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: wav.c,v 1.9 2009/06/18 02:37:27 mrg Exp $");
+__RCSID("$NetBSD: wav.c,v 1.10 2011/08/28 01:17:47 joerg Exp $");
#endif
@@ -51,7 +51,7 @@
#include "libaudio.h"
-struct {
+static const struct {
int wenc;
const char *wname;
} wavencs[] = {
@@ -77,8 +77,6 @@
return (wavencs[i].wname);
}
-extern int verbose;
-
/*
* sample header is:
*
@@ -92,14 +90,8 @@
* find a .wav header, etc. returns header length on success
*/
ssize_t
-audio_wav_parse_hdr(hdr, sz, enc, prec, sample, channels, datasize)
- void *hdr;
- size_t sz;
- u_int *enc;
- u_int *prec;
- u_int *sample;
- u_int *channels;
- size_t *datasize;
+audio_wav_parse_hdr(void *hdr, size_t sz, u_int *enc, u_int *prec,
+ u_int *sample, u_int *channels, size_t *datasize)
{
char *where = hdr, *owhere;
wav_audioheaderpart part;
--- src/usr.bin/audio/ctl/ctl.c 2009/04/11 10:43:09 1.38
+++ src/usr.bin/audio/ctl/ctl.c 2011/08/28 01:17:48 1.39
@@ -1,4 +1,4 @@
-/* $NetBSD: ctl.c,v 1.38 2009/04/11 10:43:09 lukem Exp $ */
+/* $NetBSD: ctl.c,v 1.39 2011/08/28 01:17:48 joerg Exp $ */
/*
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: ctl.c,v 1.38 2009/04/11 10:43:09 lukem Exp $");
+__RCSID("$NetBSD: ctl.c,v 1.39 2011/08/28 01:17:48 joerg Exp $");
#endif
@@ -51,23 +51,22 @@
#include "libaudio.h"
-struct field *findfield (const char *name);
-void prfield (struct field *p, const char *sep);
-void rdfield (struct field *p, char *q);
-void getinfo (int fd);
-void audioctl_write (int, int, char *[]);
-void usage (void);
-int main (int argc, char **argv);
+static struct field *findfield(const char *name);
+static void prfield(const struct field *p, const char *sep);
+static void rdfield(struct field *p, char *q);
+static void getinfo(int fd);
+static void audioctl_write(int, int, char *[]);
+__dead static void usage(void);
-audio_device_t adev;
+static audio_device_t adev;
-audio_info_t info;
+static audio_info_t info;
-char encbuf[1000];
+static char encbuf[1000];
-int properties, fullduplex, rerror;
+static int properties, fullduplex, rerror;
-struct field {
+static struct field {
const char *name;
void *valp;
int format;
@@ -140,7 +139,7 @@
{ .name = NULL },
};
-static struct {
+static const struct {
const char *name;
u_int prop;
} props[] = {
@@ -150,9 +149,8 @@
{ .name = NULL },
};
-struct field *
-findfield(name)
- const char *name;
+static struct field *
+findfield(const char *name)
{
int i;
for (i = 0; fields[i].name; i++)
@@ -161,10 +159,8 @@
return 0;
}
-void
-prfield(p, sep)
- struct field *p;
- const char *sep;
+static void
+prfield(const struct field *p, const char *sep)
{
u_int v;
const char *cm, *encstr;
@@ -174,25 +170,25 @@
printf("%s%s", p->name, sep);
switch(p->format) {
case STRING:
- printf("%s", (char*)p->valp);
+ printf("%s", (const char*)p->valp);
break;
case INT:
- printf("%d", *(int*)p->valp);
+ printf("%d", *(const int*)p->valp);
break;
case UINT:
- printf("%u", *(u_int*)p->valp);
+ printf("%u", *(const u_int*)p->valp);
break;
case XINT:
- printf("0x%x", *(u_int*)p->valp);
+ printf("0x%x", *(const u_int*)p->valp);
break;
case UCHAR:
- printf("%u", *(u_char*)p->valp);
+ printf("%u", *(const u_char*)p->valp);
break;
case ULONG:
- printf("%lu", *(u_long*)p->valp);
+ printf("%lu", *(const u_long*)p->valp);
break;
case P_R:
- v = *(u_int*)p->valp;
+ v = *(const u_int*)p->valp;
cm = "";
if (v & AUMODE_PLAY) {
if (v & AUMODE_PLAY_ALL)
@@ -235,10 +231,8 @@
}
}
-void
-rdfield(p, q)
- struct field *p;
- char *q;
+static void
+rdfield(struct field *p, char *q)
{
int enc;
u_int u;
@@ -289,9 +283,8 @@
p->flags |= SET;
}
-void
-getinfo(fd)
- int fd;
+static void
+getinfo(int fd)
{
int pos, i;
@@ -322,8 +315,8 @@
err(1, "AUDIO_GETINFO");
}
-void
-usage()
+static void
+usage(void)
{
const char *prog = getprogname();
@@ -334,9 +327,7 @@
}
int
-main(argc, argv)
- int argc;
- char **argv;
+main(int argc, char *argv[])
{
int fd, i, ch;
int aflag = 0, wflag = 0;
@@ -428,11 +419,8 @@
exit(0);
}
-void
-audioctl_write(fd, argc, argv)
- int fd;
- int argc;
- char *argv[];
+static void
+audioctl_write(int fd, int argc, char *argv[])
{
struct field *p;
--- src/usr.bin/audio/play/play.c 2010/12/29 18:48:40 1.53
+++ src/usr.bin/audio/play/play.c 2011/08/28 01:17:48 1.54
@@ -1,4 +1,4 @@
-/* $NetBSD: play.c,v 1.53 2010/12/29 18:48:40 wiz Exp $ */
+/* $NetBSD: play.c,v 1.54 2011/08/28 01:17:48 joerg Exp $ */
/*
* Copyright (c) 1999, 2000, 2001, 2002, 2010 Matthew R. Green
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: play.c,v 1.53 2010/12/29 18:48:40 wiz Exp $");
+__RCSID("$NetBSD: play.c,v 1.54 2011/08/28 01:17:48 joerg Exp $");
#endif
@@ -51,35 +51,32 @@
#include "libaudio.h"
-int main(int, char *[]);
-void usage(void);
-void play(char *);
-void play_fd(const char *, int);
-ssize_t audioctl_write_fromhdr(void *, size_t, int, size_t *, const char *);
-void cleanup(int) __dead;
+static void usage(void) __dead;
+static void play(char *);
+static void play_fd(const char *, int);
+static ssize_t audioctl_write_fromhdr(void *, size_t, int, size_t *, const char *);
+static void cleanup(int) __dead;
-audio_info_t info;
-int volume;
-int balance;
-int port;
-int fflag;
-int qflag;
+static audio_info_t info;
+static int volume;
+static int balance;
+static int port;
+static int fflag;
+static int qflag;
int verbose;
-int sample_rate;
-int encoding;
-char *encoding_str;
-int precision;
-int channels;
+static int sample_rate;
+static int encoding;
+static char *encoding_str;
+static int precision;
+static int channels;
-char const *play_errstring = NULL;
-size_t bufsize;
-int audiofd;
-int exitstatus = EXIT_SUCCESS;
+static char const *play_errstring = NULL;
+static size_t bufsize;
+static int audiofd;
+static int exitstatus = EXIT_SUCCESS;
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
size_t len;
int ch;
@@ -204,9 +201,8 @@
cleanup(0);
}
-void
-cleanup(signo)
- int signo;
+static void
+cleanup(int signo)
{
(void)ioctl(audiofd, AUDIO_FLUSH, NULL);
@@ -218,9 +214,8 @@
exit(exitstatus);
}
-void
-play(file)
- char *file;
+static void
+play(char *file)
{
struct stat sb;
void *addr, *oaddr;
@@ -307,10 +302,8 @@
/*
* play the file on the file descriptor fd
*/
-void
-play_fd(file, fd)
- const char *file;
- int fd;
+static void
+play_fd(const char *file, int fd)
{
char *buffer = malloc(bufsize);
ssize_t hdrlen;
@@ -373,13 +366,8 @@
* XXX this should probably be mostly part of libaudio, but it
* uses the local "info" variable. blah... fix me!
*/
-ssize_t
-audioctl_write_fromhdr(hdr, fsz, fd, datasize, file)
- void *hdr;
- size_t fsz;
- int fd;
- size_t *datasize;
- const char *file;
+static ssize_t
+audioctl_write_fromhdr(void *hdr, size_t fsz, int fd, size_t *datasize, const char *file)
{
sun_audioheader *sunhdr;
ssize_t hdr_len = 0;
@@ -468,8 +456,8 @@
return (hdr_len);
}
-void
-usage()
+static void
+usage(void)
{
fprintf(stderr, "Usage: %s [-hiqV] [options] files\n", getprogname());
--- src/usr.bin/audio/record/record.c 2010/12/29 18:49:41 1.50
+++ src/usr.bin/audio/record/record.c 2011/08/28 01:17:48 1.51
@@ -1,4 +1,4 @@
-/* $NetBSD: record.c,v 1.50 2010/12/29 18:49:41 wiz Exp $ */
+/* $NetBSD: record.c,v 1.51 2011/08/28 01:17:48 joerg Exp $ */
/*
* Copyright (c) 1999, 2002, 2003, 2005, 2010 Matthew R. Green
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: record.c,v 1.50 2010/12/29 18:49:41 wiz Exp $");
+__RCSID("$NetBSD: record.c,v 1.51 2011/08/28 01:17:48 joerg Exp $");
#endif
@@ -55,42 +55,39 @@
#include "libaudio.h"
#include "auconv.h"
-audio_info_t info, oinfo;
-ssize_t total_size = -1;
-const char *device;
-int format = AUDIO_FORMAT_DEFAULT;
-char *header_info;
-char default_info[8] = { '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0' };
-int audiofd, outfd;
-int qflag, aflag, fflag;
+static audio_info_t info, oinfo;
+static ssize_t total_size = -1;
+static const char *device;
+static int format = AUDIO_FORMAT_DEFAULT;
+static char *header_info;
+static char default_info[8] = { '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0' };
+static int audiofd, outfd;
+static int qflag, aflag, fflag;
int verbose;
-int monitor_gain, omonitor_gain;
-int gain;
-int balance;
-int port;
-int encoding;
-char *encoding_str;
-int precision;
-int sample_rate;
-int channels;
-struct timeval record_time;
-struct timeval start_time;
+static int monitor_gain, omonitor_gain;
+static int gain;
+static int balance;
+static int port;
+static int encoding;
+static char *encoding_str;
+static int precision;
+static int sample_rate;
+static int channels;
+static struct timeval record_time;
+static struct timeval start_time;
-void (*conv_func) (u_char *, int);
+static void (*conv_func) (u_char *, int);
-void usage (void);
-int main (int, char *[]);
-int timeleft (struct timeval *, struct timeval *);
-void cleanup (int) __dead;
-int write_header_sun (void **, size_t *, int *);
-int write_header_wav (void **, size_t *, int *);
-void write_header (void);
-void rewrite_header (void);
+static void usage (void) __dead;
+static int timeleft (struct timeval *, struct timeval *);
+static void cleanup (int) __dead;
+static int write_header_sun (void **, size_t *, int *);
+static int write_header_wav (void **, size_t *, int *);
+static void write_header (void);
+static void rewrite_header (void);
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
u_char *buffer;
size_t len, bufsize = 0;
@@ -348,9 +345,7 @@
}
int
-timeleft(start_tvp, record_tvp)
- struct timeval *start_tvp;
- struct timeval *record_tvp;
+timeleft(struct timeval *start_tvp, struct timeval *record_tvp)
{
struct timeval now, diff;
@@ -362,8 +357,7 @@
}
void
-cleanup(signo)
- int signo;
+cleanup(int signo)
{
rewrite_header();
@@ -381,11 +375,8 @@
exit(0);
}
-int
-write_header_sun(hdrp, lenp, leftp)
- void **hdrp;
- size_t *lenp;
- int *leftp;
+static int
+write_header_sun(void **hdrp, size_t *lenp, int *leftp)
{
static int warned = 0;
static sun_audioheader auh;
@@ -478,11 +469,8 @@
return 0;
}
-int
-write_header_wav(hdrp, lenp, leftp)
- void **hdrp;
- size_t *lenp;
- int *leftp;
+static int
+write_header_wav(void **hdrp, size_t *lenp, int *leftp)
{
/*
* WAV header we write looks like this:
@@ -709,8 +697,8 @@
return 0;
}
-void
-write_header()
+static void
+write_header(void)
{
struct iovec iv[3];
int veclen, left, tlen;
@@ -759,8 +747,8 @@
err(1, "could not write audio header");
}
-void
-rewrite_header()
+static void
+rewrite_header(void)
{
/* can't do this here! */
@@ -772,8 +760,8 @@
write_header();
}
-void
-usage()
+static void
+usage(void)
{
fprintf(stderr, "Usage: %s [-afhqV] [options] {files ...|-}\n",