fix warning & bugs in error code paths

This commit is contained in:
Alexandre Ratchov 2012-12-20 19:59:11 +01:00
parent b7a2c05bf9
commit 4cf1ce7f8e
1 changed files with 15 additions and 18 deletions

View File

@ -28,9 +28,9 @@
#define MSGMAX 0x100 /* buffer size */ #define MSGMAX 0x100 /* buffer size */
int verbose = 0; int verbose = 0;
struct mio_hdl *hdl; /* handle to sndiod MIDI port */
int mst, midx, mlen, mready; /* midi parser state */ int mst, midx, mlen, mready; /* midi parser state */
unsigned char mmsg[MSGMAX]; /* resulting midi message */ unsigned char mmsg[MSGMAX]; /* resulting midi message */
struct mio_hdl *hdl; /* handle to sndiod MIDI port */
struct ctl { struct ctl {
char name[SYSEX_NAMELEN]; /* stream name */ char name[SYSEX_NAMELEN]; /* stream name */
@ -48,7 +48,7 @@ unsigned char dumpreq[] = {
}; };
void void
setvol(unsigned cn, unsigned vol) setvol(int cn, int vol)
{ {
#define VOLMSGLEN 3 #define VOLMSGLEN 3
char msg[VOLMSGLEN]; char msg[VOLMSGLEN];
@ -64,7 +64,7 @@ setvol(unsigned cn, unsigned vol)
} }
void void
setmaster(unsigned vol) setmaster(int vol)
{ {
struct sysex msg; struct sysex msg;
@ -83,16 +83,15 @@ setmaster(unsigned vol)
} }
void void
relocate(unsigned hr, unsigned min, unsigned sec, unsigned fr, unsigned fps) relocate(int hr, int min, int sec, int fr, int fps)
{ {
} }
void void
onsysex(unsigned char *buf, unsigned len) onsysex(unsigned char *buf, int len)
{ {
unsigned cn, i; int cn, i;
struct sysex *x = (struct sysex *)buf; struct sysex *x = (struct sysex *)buf;
struct ctl *c;
if (verbose) { if (verbose) {
fprintf(stderr, "sysex: "); fprintf(stderr, "sysex: ");
@ -116,11 +115,11 @@ onsysex(unsigned char *buf, unsigned len)
case SYSEX_AUCAT_SLOTDESC: case SYSEX_AUCAT_SLOTDESC:
cn = x->u.slotdesc.chan; cn = x->u.slotdesc.chan;
if (cn >= MIDI_NCHAN) { if (cn >= MIDI_NCHAN) {
fprintf(stderr, "%u: invalid channel\n"); fprintf(stderr, "%u: invalid channel\n", cn);
exit(1); exit(1);
} }
if (memchr(x->u.slotdesc.name, '\0', SYSEX_NAMELEN) == NULL) { if (memchr(x->u.slotdesc.name, '\0', SYSEX_NAMELEN) == NULL) {
fprintf(stderr, "%u: invalid channel name\n"); fprintf(stderr, "%u: invalid channel name\n", cn);
exit(1); exit(1);
} }
strlcpy(ctls[cn].name, x->u.slotdesc.name, SYSEX_NAMELEN); strlcpy(ctls[cn].name, x->u.slotdesc.name, SYSEX_NAMELEN);
@ -133,9 +132,9 @@ onsysex(unsigned char *buf, unsigned len)
} }
void void
oncommon(unsigned char *buf, unsigned len) oncommon(unsigned char *buf, int len)
{ {
unsigned cn, vol; int cn, vol;
if ((buf[0] & MIDI_CMDMASK) != MIDI_CTL) if ((buf[0] & MIDI_CMDMASK) != MIDI_CTL)
return; return;
@ -147,11 +146,11 @@ oncommon(unsigned char *buf, unsigned len)
} }
void void
oninput(unsigned char *buf, unsigned len) oninput(unsigned char *buf, int len)
{ {
static unsigned voice_len[] = { 3, 3, 3, 3, 2, 2, 3 }; static int voice_len[] = { 3, 3, 3, 3, 2, 2, 3 };
static unsigned common_len[] = { 0, 2, 3, 2, 0, 0, 1, 1 }; static int common_len[] = { 0, 2, 3, 2, 0, 0, 1, 1 };
unsigned c; int c;
for (; len > 0; len--) { for (; len > 0; len--) {
c = *buf; c = *buf;
@ -203,9 +202,7 @@ main(int argc, char **argv)
{ {
char *dev = "snd/0"; char *dev = "snd/0";
unsigned char buf[MSGMAX], *lhs, *rhs; unsigned char buf[MSGMAX], *lhs, *rhs;
unsigned size; int c, cn, vol, size;
unsigned cn, vol;
int c, sep;
while ((c = getopt(argc, argv, "f:v")) != -1) { while ((c = getopt(argc, argv, "f:v")) != -1) {
switch (c) { switch (c) {