Browse Source

Fix compile-time warnings

Fix warnings generated by GCC -Wall -Wextra flags.
develop
Damien Goutte-Gattat 6 years ago
parent
commit
5b0b1ce8fd
  1. 10
      lib/hexio.c
  2. 6
      src/asysex.c
  3. 14
      src/kmxtool.c
  4. 10
      src/microx.c
  5. 7
      src/midi.c
  6. 3
      src/sysex.c

10
lib/hexio.c

@ -35,7 +35,8 @@
int
fprinthd(FILE *f, unsigned char *buffer, size_t len, unsigned offset)
{
int i, j, n;
unsigned int i, j;
int n;
if ( ! f || ! buffer ) {
errno = EINVAL;
@ -70,7 +71,8 @@ fprinthd(FILE *f, unsigned char *buffer, size_t len, unsigned offset)
int
fprinth(FILE *f, unsigned char *buffer, size_t len)
{
int i, n;
unsigned int i;
int n;
if ( ! f || ! buffer ) {
errno = EINVAL;
@ -183,7 +185,7 @@ freadha(FILE *f, unsigned char **buffer, size_t *len)
while ( (n = freadh(f, buf, sizeof(buf))) > 0 ) {
if ( *len < m + n ) {
#ifdef EXIT_ENOMEM
#ifdef EXIT_ON_ENOMEM
*len += BLOCK_SIZE;
*buffer = xrealloc(*buffer, *len);
#else
@ -279,7 +281,7 @@ freadhda(FILE *f, unsigned char **buffer, size_t *len)
while ( (n = freadhd(f, buf, sizeof(buf), &s)) > 0 ) {
if ( *len < m + n ) {
#ifdef EXIT_ENOMEM
#ifdef EXIT_ON_ENOMEM
*len += BLOCK_SIZE;
*buffer = xrealloc(*buffer, *len);
#else

6
src/asysex.c

@ -24,6 +24,7 @@
#include <stdlib.h>
#include <locale.h>
#include <getopt.h>
#include <err.h>
#include <sysex.h>
#include <xmem.h>
@ -129,7 +130,7 @@ do_query(midi_io_t *midi, FILE *in, FILE *out, print_midi_fn_t print_midi)
n = freadha(in, &query, NULL);
if ( n < 2 || query[0] != 0xF0 || query[n-1] != 0xF7 )
errx(EXIT_FAILURE, "invalid SysEx input (%d)", n);
errx(EXIT_FAILURE, "invalid SysEx input (%lu)", n);
if ( (n = midi_write(midi, query, n)) < 0 )
errx(EXIT_FAILURE, "cannot send MIDI data");
@ -168,7 +169,8 @@ identify_device(midi_io_t *midi)
int
main(int argc, char **argv)
{
char c, *port;
char c;
const char *port;
int mode;
print_midi_fn_t print_midi;

14
src/kmxtool.c

@ -104,12 +104,12 @@ cleanup(void)
static void
print_microx_status(struct kmx_microx_status *s)
{
static char *modes[] = { "COMBI PLAY", "COMBI EDIT", "PROG PLAY",
"PROG EDIT", "MULTI", "GLOBAL" };
static char *clock[] = { "Internal", "Ext-MIDI", "Ext-USB", "AUTO" };
static char *flter[] = { "All", "Odd", "Even" };
static char *yesno[] = { "No", "Yes" };
static char *bnkmp[] = { "KORG", "GM" };
static const char *modes[] = { "COMBI PLAY", "COMBI EDIT", "PROG PLAY",
"PROG EDIT", "MULTI", "GLOBAL" };
static const char *clock[] = { "Internal", "Ext-MIDI", "Ext-USB", "AUTO" };
static const char *flter[] = { "All", "Odd", "Even" };
static const char *yesno[] = { "No", "Yes" };
static const char *bnkmp[] = { "KORG", "GM" };
printf("Global channel: %d\n", s->global_channel);
printf("Active mode: %s\n",
@ -237,7 +237,7 @@ main(int argc, char **argv)
setlocale(LC_ALL, "");
atexit(cleanup);
port = NULL;
port = param = NULL;
mode = MODE_STATUS;
while ( (c = getopt_long(argc, argv, "hvp:sd:l:L",

10
src/microx.c

@ -508,6 +508,10 @@ kmx_microx_get_dump_size(struct kmx_microx_dump *dump)
if ( dump->program == KMX_MICROX_DUMP_ALL )
s *= MICROX_N_EXTSET;
break;
default: /* Should never happen. */
s = 0;
break;
}
return s;
@ -633,8 +637,8 @@ kmx_microx_read_dump(midi_io_t *midi,
unsigned char *data,
size_t len)
{
size_t n;
int i, j, k, m;
ssize_t n;
unsigned i, j, k, m;
unsigned char reply[1024];
j = k = m = 0;
@ -715,7 +719,7 @@ kmx_microx_dump(midi_io_t *midi,
unsigned char *data,
size_t len)
{
size_t n;
ssize_t n;
unsigned char query[] = { 0xF0, /* SysEx message begin */
0x42, /* KORG manufacturer ID */
0x30, /* Global channel */

7
src/midi.c

@ -136,7 +136,8 @@ alsa_midi_write(midi_io_t *midi, unsigned char *buffer, size_t len)
/* Flush reading buffer. */
midi->pos = midi->len = 0;
if ( (n = snd_rawmidi_write(midi->alsa.out, buffer, len)) != len ) {
if ( (n = snd_rawmidi_write(midi->alsa.out, buffer, len)) < 0 ||
(unsigned)n != len ) {
midi->error = n;
n = -1;
}
@ -312,7 +313,7 @@ static void
oss_midi_get_ports(char ***ports, size_t *n, size_t *max)
{
char name[32];
size_t k;
int k;
struct dirent **namelist;
if ( (k = scandir("/dev", &namelist, oss_midi_device, alphasort)) != -1 ) {
@ -470,7 +471,7 @@ midi_error(midi_io_t *midi)
char **
midi_get_ports(void)
{
char **ports, name[32];
char **ports;
size_t n, max;
ports = NULL;

3
src/sysex.c

@ -56,7 +56,8 @@
ssize_t
sysex_read(midi_io_t *midi, unsigned char *data, size_t len)
{
int byte, loop, n, p;
int byte, loop;
unsigned n, p;
loop = 1;
n = p = 0;

Loading…
Cancel
Save