ref: b97d97a4acc6ca29e831d22e8fa94bf4cb5c4b2e
parent: 47134f81bfadd4dd8616803e6e60158df7c7a834
author: rrt <rrt>
date: Fri Apr 13 11:41:56 EDT 2007
Fix lots of compiler warnings. Sadly there are two classes that I can't think of a good way to fix right now: 1. A warning about parameter sizes of floats, even when parameter and prototype match; this is because of architectures like i386 that can't actually pass a float (but it still works, of course). 2. More seriously (because the warnings are more numerous) similar warnings about read and write functions. These warnings are mostly bogus; I believe they arise for similar reasons (inability of calling conventions to deal with integral types smaller than a word) but again they work. If anyone else has ideas on how to reduce the noise without compromising the code, I'd be grateful.
--- a/src/8svx.c
+++ b/src/8svx.c
@@ -140,7 +140,7 @@
sox_readdw(ft, &chunksize);
if (chunksize & 1)
chunksize++;
- sox_seeki(ft,chunksize,SEEK_CUR);
+ sox_seeki(ft,(int32_t)chunksize,SEEK_CUR);
continue;
}
@@ -341,7 +341,7 @@
sox_writedw(ft, nsamples/ft->signal.channels); /* samples, 1-shot */
sox_writedw(ft, 0); /* samples, repeat */
sox_writedw(ft, 0); /* samples per repeat cycle */
- sox_writew(ft, (int) ft->signal.rate); /* samples per second */
+ sox_writew(ft, (uint16_t)ft->signal.rate); /* samples per second */
sox_writeb(ft,1); /* number of octabes */
sox_writeb(ft,0); /* data compression (none) */
sox_writew(ft,1); sox_writew(ft,0); /* volume */
--- a/src/aiff.c
+++ b/src/aiff.c
@@ -63,7 +63,7 @@
new_offset += (channel_block - alignment);
new_offset += aiff->dataStart;
- ft->sox_errno = sox_seeki(ft, new_offset, SEEK_SET);
+ ft->sox_errno = sox_seeki(ft, (sox_ssize_t)new_offset, SEEK_SET);
if (ft->sox_errno == SOX_SUCCESS)
aiff->nsamples = ft->length - (new_offset / ft->signal.size);
@@ -94,7 +94,8 @@
unsigned short nmarks = 0;
unsigned short sustainLoopBegin = 0, sustainLoopEnd = 0,
releaseLoopBegin = 0, releaseLoopEnd = 0;
- sox_size_t seekto = 0, ssndsize = 0;
+ sox_ssize_t seekto = 0;
+ sox_size_t ssndsize = 0;
char *author;
char *copyright;
char *nametext;
@@ -180,7 +181,7 @@
break;
/* else, seek to end of sound and hunt for more */
seekto = sox_tell(ft);
- sox_seeki(ft, chunksize, SEEK_CUR);
+ sox_seeki(ft, (sox_ssize_t)chunksize, SEEK_CUR);
}
else if (strncmp(buf, "MARK", 4) == 0) {
/* MARK chunk */
@@ -491,7 +492,7 @@
/* print out the MIDI key allocations, loop points, directions etc */
static void reportInstrument(ft_t ft)
{
- int loopNum;
+ unsigned loopNum;
if(ft->instr.nloops > 0)
sox_report("AIFF Loop markers:");
@@ -735,10 +736,9 @@
int hsize =
8 /*COMM hdr*/ + 18 /*COMM chunk*/ +
8 /*SSND hdr*/ + 12 /*SSND chunk*/;
- int bits = 0;
- int i;
- int padded_comment_size = 0;
- int comment_size = 0;
+ unsigned bits = 0;
+ unsigned i;
+ sox_size_t padded_comment_size = 0, comment_size = 0;
sox_size_t comment_chunk_size = 0;
/* MARK and INST chunks */
@@ -812,7 +812,7 @@
/* COMM chunk -- describes encoding (and #frames) */
sox_writes(ft, "COMM");
sox_writedw(ft, 18); /* COMM chunk size */
- sox_writew(ft, (int)ft->signal.channels); /* nchannels */
+ sox_writew(ft, ft->signal.channels); /* nchannels */
sox_writedw(ft, nframes); /* number of frames */
sox_writew(ft, bits); /* sample width, in bits */
write_ieee_extended(ft, (double)ft->signal.rate);
@@ -839,10 +839,10 @@
sox_writes(ft, "INST");
sox_writedw(ft, 20);
/* random MIDI shit that we default on */
- sox_writeb(ft, ft->instr.MIDInote);
+ sox_writeb(ft, (uint8_t)ft->instr.MIDInote);
sox_writeb(ft, 0); /* detune */
- sox_writeb(ft, ft->instr.MIDIlow);
- sox_writeb(ft, ft->instr.MIDIhi);
+ sox_writeb(ft, (uint8_t)ft->instr.MIDIlow);
+ sox_writeb(ft, (uint8_t)ft->instr.MIDIhi);
sox_writeb(ft, 1); /* low velocity */
sox_writeb(ft, 127); /* hi velocity */
sox_writew(ft, 0); /* gain */
@@ -937,10 +937,10 @@
static int aifcwriteheader(ft_t ft, sox_size_t nframes)
{
- int hsize =
+ unsigned hsize =
12 /*FVER*/ + 8 /*COMM hdr*/ + 18+4+1+15 /*COMM chunk*/ +
8 /*SSND hdr*/ + 12 /*SSND chunk*/;
- int bits = 0;
+ unsigned bits = 0;
if (ft->signal.encoding == SOX_ENCODING_SIGN2 &&
ft->signal.size == SOX_SIZE_BYTE)
@@ -973,7 +973,7 @@
/* COMM chunk -- describes encoding (and #frames) */
sox_writes(ft, "COMM");
sox_writedw(ft, 18+4+1+15); /* COMM chunk size */
- sox_writew(ft, (int)ft->signal.channels); /* nchannels */
+ sox_writew(ft, ft->signal.channels); /* nchannels */
sox_writedw(ft, nframes); /* number of frames */
sox_writew(ft, bits); /* sample width, in bits */
write_ieee_extended(ft, (double)ft->signal.rate);
--- a/src/au.c
+++ b/src/au.c
@@ -132,7 +132,7 @@
new_offset += (channel_block - alignment);
new_offset += au->dataStart;
- ft->sox_errno = sox_seeki(ft, new_offset, SEEK_SET);
+ ft->sox_errno = sox_seeki(ft, (sox_ssize_t)new_offset, SEEK_SET);
}
return(ft->sox_errno);
--- a/src/cdr.c
+++ b/src/cdr.c
@@ -125,7 +125,6 @@
{
cdr_t cdr = (cdr_t) ft->priv;
int padsamps = SECTORSIZE - (cdr->samples % SECTORSIZE);
- short zero;
int rc;
/* Flush buffer before writing anything else */
@@ -134,12 +133,10 @@
if (rc)
return rc;
- zero = 0;
-
if (padsamps != SECTORSIZE)
{
while (padsamps > 0) {
- sox_writew(ft, zero);
+ sox_writew(ft, 0);
padsamps--;
}
}
--- a/src/gsm.c
+++ b/src/gsm.c
@@ -107,8 +107,8 @@
static sox_size_t sox_gsmread(ft_t ft, sox_ssample_t *buf, sox_size_t samp)
{
- size_t done = 0;
- int r, ch, chans;
+ size_t done = 0, r;
+ int ch, chans;
gsm_signal *gbuff;
struct gsmpriv *p = (struct gsmpriv *) ft->priv;
--- a/src/maud.c
+++ b/src/maud.c
@@ -184,7 +184,7 @@
sox_readdw(ft, &chunksize);
if (chunksize & 1)
chunksize++;
- sox_seeki(ft, chunksize, SEEK_CUR);
+ sox_seeki(ft, (sox_ssize_t)chunksize, SEEK_CUR);
continue;
}
--- a/src/misc.c
+++ b/src/misc.c
@@ -162,9 +162,9 @@
return fflush(ft->fp);
}
-sox_size_t sox_tell(ft_t ft)
+sox_ssize_t sox_tell(ft_t ft)
{
- return (sox_size_t)ftello(ft->fp);
+ return (sox_ssize_t)ftello(ft->fp);
}
int sox_eof(ft_t ft)
--- a/src/prc.c
+++ b/src/prc.c
@@ -130,7 +130,7 @@
new_offset += (channel_block - alignment);
new_offset += prc->data_start;
- return sox_seeki(ft, new_offset, SEEK_SET);
+ return sox_seeki(ft, (sox_ssize_t)new_offset, SEEK_SET);
}
static int startread(ft_t ft)
--- a/src/raw.c
+++ b/src/raw.c
@@ -48,7 +48,7 @@
if (alignment != 0)
new_offset += (channel_block - alignment);
- ft->sox_errno = sox_seeki(ft, new_offset, SEEK_SET);
+ ft->sox_errno = sox_seeki(ft, (sox_ssize_t)new_offset, SEEK_SET);
return ft->sox_errno;
}
@@ -93,13 +93,13 @@
return SOX_SUCCESS;
}
-#define READ_SAMPLES_FUNC(type, size, sign, ctype, cast) \
+#define READ_SAMPLES_FUNC(type, size, sign, ctype, uctype, cast) \
sox_size_t sox_read_ ## sign ## type ## _samples( \
ft_t ft, sox_ssample_t *buf, sox_size_t len) \
{ \
sox_size_t n, nread; \
ctype *data = xmalloc(sizeof(ctype) * len); \
- if ((nread = sox_read_ ## type ## _buf(ft, data, len)) != len) \
+ if ((nread = sox_read_ ## type ## _buf(ft, (uctype *)data, len)) != len) \
sox_fail_errno(ft, errno, sox_readerr); \
for (n = 0; n < nread; n++) \
*buf++ = cast(data[n], ft->clips); \
@@ -107,20 +107,20 @@
return nread; \
}
-static READ_SAMPLES_FUNC(b, 1, u, uint8_t, SOX_UNSIGNED_BYTE_TO_SAMPLE)
-static READ_SAMPLES_FUNC(b, 1, s, int8_t, SOX_SIGNED_BYTE_TO_SAMPLE)
-static READ_SAMPLES_FUNC(b, 1, ulaw, uint8_t, SOX_ULAW_BYTE_TO_SAMPLE)
-static READ_SAMPLES_FUNC(b, 1, alaw, uint8_t, SOX_ALAW_BYTE_TO_SAMPLE)
-static READ_SAMPLES_FUNC(w, 2, u, uint16_t, SOX_UNSIGNED_WORD_TO_SAMPLE)
-static READ_SAMPLES_FUNC(w, 2, s, int16_t, SOX_SIGNED_WORD_TO_SAMPLE)
-static READ_SAMPLES_FUNC(3, 3, u, uint24_t, SOX_UNSIGNED_24BIT_TO_SAMPLE)
-static READ_SAMPLES_FUNC(3, 3, s, int24_t, SOX_SIGNED_24BIT_TO_SAMPLE)
-static READ_SAMPLES_FUNC(dw, 4, u, uint32_t, SOX_UNSIGNED_DWORD_TO_SAMPLE)
-static READ_SAMPLES_FUNC(dw, 4, s, int32_t, SOX_SIGNED_DWORD_TO_SAMPLE)
-static READ_SAMPLES_FUNC(f, sizeof(float), su, float, SOX_FLOAT_DWORD_TO_SAMPLE)
-static READ_SAMPLES_FUNC(df, sizeof(double), su, double, SOX_FLOAT_DDWORD_TO_SAMPLE)
+static READ_SAMPLES_FUNC(b, 1, u, uint8_t, uint8_t, SOX_UNSIGNED_BYTE_TO_SAMPLE)
+static READ_SAMPLES_FUNC(b, 1, s, int8_t, uint8_t, SOX_SIGNED_BYTE_TO_SAMPLE)
+static READ_SAMPLES_FUNC(b, 1, ulaw, uint8_t, uint8_t, SOX_ULAW_BYTE_TO_SAMPLE)
+static READ_SAMPLES_FUNC(b, 1, alaw, uint8_t, uint8_t, SOX_ALAW_BYTE_TO_SAMPLE)
+static READ_SAMPLES_FUNC(w, 2, u, uint16_t, uint16_t, SOX_UNSIGNED_WORD_TO_SAMPLE)
+static READ_SAMPLES_FUNC(w, 2, s, int16_t, uint16_t, SOX_SIGNED_WORD_TO_SAMPLE)
+static READ_SAMPLES_FUNC(3, 3, u, uint24_t, uint24_t, SOX_UNSIGNED_24BIT_TO_SAMPLE)
+static READ_SAMPLES_FUNC(3, 3, s, int24_t, uint24_t, SOX_SIGNED_24BIT_TO_SAMPLE)
+static READ_SAMPLES_FUNC(dw, 4, u, uint32_t, uint32_t, SOX_UNSIGNED_DWORD_TO_SAMPLE)
+static READ_SAMPLES_FUNC(dw, 4, s, int32_t, uint32_t, SOX_SIGNED_DWORD_TO_SAMPLE)
+static READ_SAMPLES_FUNC(f, sizeof(float), su, float, float, SOX_FLOAT_DWORD_TO_SAMPLE)
+static READ_SAMPLES_FUNC(df, sizeof(double), su, double, double, SOX_FLOAT_DDWORD_TO_SAMPLE)
-#define WRITE_SAMPLES_FUNC(type, size, sign, ctype, cast) \
+#define WRITE_SAMPLES_FUNC(type, size, sign, ctype, uctype, cast) \
sox_size_t sox_write_ ## sign ## type ## _samples( \
ft_t ft, sox_ssample_t *buf, sox_size_t len) \
{ \
@@ -128,24 +128,24 @@
ctype *data = xmalloc(sizeof(ctype) * len); \
for (n = 0; n < len; n++) \
data[n] = cast(buf[n], ft->clips); \
- if ((nwritten = sox_write_ ## type ## _buf(ft, data, len)) != len) \
+ if ((nwritten = sox_write_ ## type ## _buf(ft, (uctype *)data, len)) != len) \
sox_fail_errno(ft, errno, sox_writerr); \
free(data); \
return nwritten; \
}
-static WRITE_SAMPLES_FUNC(b, 1, u, uint8_t, SOX_SAMPLE_TO_UNSIGNED_BYTE)
-static WRITE_SAMPLES_FUNC(b, 1, s, int8_t, SOX_SAMPLE_TO_SIGNED_BYTE)
-static WRITE_SAMPLES_FUNC(b, 1, ulaw, uint8_t, SOX_SAMPLE_TO_ULAW_BYTE)
-static WRITE_SAMPLES_FUNC(b, 1, alaw, uint8_t, SOX_SAMPLE_TO_ALAW_BYTE)
-static WRITE_SAMPLES_FUNC(w, 2, u, uint16_t, SOX_SAMPLE_TO_UNSIGNED_WORD)
-static WRITE_SAMPLES_FUNC(w, 2, s, int16_t, SOX_SAMPLE_TO_SIGNED_WORD)
-static WRITE_SAMPLES_FUNC(3, 3, u, uint24_t, SOX_SAMPLE_TO_UNSIGNED_24BIT)
-static WRITE_SAMPLES_FUNC(3, 3, s, int24_t, SOX_SAMPLE_TO_SIGNED_24BIT)
-static WRITE_SAMPLES_FUNC(dw, 4, u, uint32_t, SOX_SAMPLE_TO_UNSIGNED_DWORD)
-static WRITE_SAMPLES_FUNC(dw, 4, s, int32_t, SOX_SAMPLE_TO_SIGNED_DWORD)
-static WRITE_SAMPLES_FUNC(f, sizeof(float), su, float, SOX_SAMPLE_TO_FLOAT_DWORD)
-static WRITE_SAMPLES_FUNC(df, sizeof(double), su, double, SOX_SAMPLE_TO_FLOAT_DDWORD)
+static WRITE_SAMPLES_FUNC(b, 1, u, uint8_t, uint8_t, SOX_SAMPLE_TO_UNSIGNED_BYTE)
+static WRITE_SAMPLES_FUNC(b, 1, s, int8_t, uint8_t, SOX_SAMPLE_TO_SIGNED_BYTE)
+static WRITE_SAMPLES_FUNC(b, 1, ulaw, uint8_t, uint8_t, SOX_SAMPLE_TO_ULAW_BYTE)
+static WRITE_SAMPLES_FUNC(b, 1, alaw, uint8_t, uint8_t, SOX_SAMPLE_TO_ALAW_BYTE)
+static WRITE_SAMPLES_FUNC(w, 2, u, uint16_t, uint16_t, SOX_SAMPLE_TO_UNSIGNED_WORD)
+static WRITE_SAMPLES_FUNC(w, 2, s, int16_t, uint16_t, SOX_SAMPLE_TO_SIGNED_WORD)
+static WRITE_SAMPLES_FUNC(3, 3, u, uint24_t, uint24_t, SOX_SAMPLE_TO_UNSIGNED_24BIT)
+static WRITE_SAMPLES_FUNC(3, 3, s, int24_t, uint24_t, SOX_SAMPLE_TO_SIGNED_24BIT)
+static WRITE_SAMPLES_FUNC(dw, 4, u, uint32_t, uint32_t, SOX_SAMPLE_TO_UNSIGNED_DWORD)
+static WRITE_SAMPLES_FUNC(dw, 4, s, int32_t, uint32_t, SOX_SAMPLE_TO_SIGNED_DWORD)
+static WRITE_SAMPLES_FUNC(f, sizeof(float), su, float, float, SOX_SAMPLE_TO_FLOAT_DWORD)
+static WRITE_SAMPLES_FUNC(df, sizeof(double), su, double, double, SOX_SAMPLE_TO_FLOAT_DDWORD)
typedef sox_size_t (ft_io_fun)(ft_t ft, sox_ssample_t *buf, sox_size_t len);
--- a/src/sf.c
+++ b/src/sf.c
@@ -81,7 +81,7 @@
new_offset += (channel_block - alignment);
new_offset += sf->dataStart;
- return sox_seeki(ft, new_offset, SEEK_SET);
+ return sox_seeki(ft, (sox_ssize_t)new_offset, SEEK_SET);
}
/*
--- a/src/smp.c
+++ b/src/smp.c
@@ -38,8 +38,8 @@
struct loop {
uint32_t start; /* Sample count into sample data, not byte count */
uint32_t end; /* end point */
- char type; /* 0 = loop off, 1 = forward, 2 = forw/back */
- short count; /* No of times to loop */
+ unsigned char type; /* 0 = loop off, 1 = forward, 2 = forw/back */
+ unsigned short count; /* No of times to loop */
};
/* Samplevision marker definition structure */
@@ -162,7 +162,7 @@
}
sox_writedw(ft, trailer->markers[i].position);
}
- sox_writeb(ft, trailer->MIDInote);
+ sox_writeb(ft, (uint8_t)(trailer->MIDInote));
sox_writedw(ft, trailer->rate);
sox_writedw(ft, trailer->SMPTEoffset);
sox_writedw(ft, trailer->CycleSize);
@@ -186,7 +186,7 @@
new_offset += (channel_block - alignment);
new_offset += smp->dataStart;
- ft->sox_errno = sox_seeki(ft, new_offset, SEEK_SET);
+ ft->sox_errno = sox_seeki(ft, (sox_ssize_t)new_offset, SEEK_SET);
if( ft->sox_errno == SOX_SUCCESS )
smp->NoOfSamps = ft->length - (new_offset / ft->signal.size);
@@ -203,9 +203,8 @@
static int sox_smpstartread(ft_t ft)
{
smp_t smp = (smp_t) ft->priv;
- int i;
int namelen, commentlen;
- sox_size_t samplestart;
+ sox_size_t samplestart, i;
struct smpheader header;
struct smptrailer trailer;
@@ -254,7 +253,7 @@
/* seek from the current position (the start of sample data) by */
/* NoOfSamps * sizeof(int16_t) */
- if (sox_seeki(ft, smp->NoOfSamps * 2, 1) == -1)
+ if (sox_seeki(ft, (sox_ssize_t)(smp->NoOfSamps * 2), 1) == -1)
{
sox_fail_errno(ft,errno,"SMP unable to seek to trailer");
return(SOX_EOF);
@@ -266,7 +265,7 @@
}
/* seek back to the beginning of the data */
- if (sox_seeki(ft, samplestart, 0) == -1)
+ if (sox_seeki(ft, (sox_ssize_t)samplestart, 0) == -1)
{
sox_fail_errno(ft,errno,"SMP unable to seek back to start of sample data");
return(SOX_EOF);
@@ -375,7 +374,7 @@
while(done < len) {
datum = (int) SOX_SAMPLE_TO_SIGNED_WORD(*buf++, ft->clips);
- sox_writew(ft, datum);
+ sox_writew(ft, (uint16_t)datum);
smp->NoOfSamps++;
done++;
}
--- a/src/sndfile.c
+++ b/src/sndfile.c
@@ -140,7 +140,7 @@
sndfile_t sf = (sndfile_t)ft->priv;
/* FIXME: We assume int == sox_sample_t here */
- return (sox_size_t)sf_read_int(sf->sf_file, (int *)buf, len);
+ return (sox_size_t)sf_read_int(sf->sf_file, (int *)buf, (sf_count_t)len);
}
/*
@@ -326,7 +326,7 @@
sndfile_t sf = (sndfile_t)ft->priv;
/* FIXME: We assume int == sox_sample_t here */
- return (sox_size_t)sf_write_int(sf->sf_file, (int *)buf, len);
+ return (sox_size_t)sf_write_int(sf->sf_file, (int *)buf, (sf_count_t)len);
}
/*
@@ -342,7 +342,7 @@
int sox_sndfile_seek(ft_t ft, sox_size_t offset)
{
sndfile_t sf = (sndfile_t)ft->priv;
- sf_seek(sf->sf_file, offset / ft->signal.channels, SEEK_CUR);
+ sf_seek(sf->sf_file, (sf_count_t)(offset / ft->signal.channels), SEEK_CUR);
return SOX_SUCCESS;
}
--- a/src/sndrtool.c
+++ b/src/sndrtool.c
@@ -31,7 +31,7 @@
sox_writedw (ft,nsamples);
sox_writedw (ft,0);
sox_writedw (ft,nsamples);
- sox_writew (ft,(int) ft->signal.rate);
+ sox_writew (ft, ft->signal.rate);
sox_writew (ft,0);
sox_writew (ft,10);
sox_writew (ft,4);
@@ -57,7 +57,7 @@
new_offset += (channel_block - alignment);
new_offset += snd->dataStart;
- return sox_seeki(ft, new_offset, SEEK_SET);
+ return sox_seeki(ft, (sox_ssize_t)new_offset, SEEK_SET);
}
static int sox_sndtstartread(ft_t ft)
--- a/src/sox.h
+++ b/src/sox.h
@@ -101,7 +101,7 @@
#define SOX_SIGNED_WORD_TO_SAMPLE(d,clips) SOX_SIGNED_TO_SAMPLE(16,d)
#define SOX_UNSIGNED_24BIT_TO_SAMPLE(d,clips) SOX_UNSIGNED_TO_SAMPLE(24,d)
#define SOX_SIGNED_24BIT_TO_SAMPLE(d,clips) SOX_SIGNED_TO_SAMPLE(24,d)
-#define SOX_UNSIGNED_DWORD_TO_SAMPLE(d,clips) (sox_ssample_t)((d)^SOX_SAMPLE_NEG)
+#define SOX_UNSIGNED_DWORD_TO_SAMPLE(d,clips) ((sox_ssample_t)(d)^SOX_SAMPLE_NEG)
#define SOX_SIGNED_DWORD_TO_SAMPLE(d,clips) (sox_ssample_t)(d)
#define SOX_FLOAT_DWORD_TO_SAMPLE SOX_FLOAT_DDWORD_TO_SAMPLE
#define SOX_FLOAT_DDWORD_TO_SAMPLE(d,clips) (sox_macro_temp_double=(d),sox_macro_temp_double<-1?++(clips),(-SOX_SAMPLE_MAX):sox_macro_temp_double>1?++(clips),SOX_SAMPLE_MAX:(sox_ssample_t)((uint32_t)((double)(sox_macro_temp_double)*SOX_SAMPLE_MAX+(SOX_SAMPLE_MAX+.5))-SOX_SAMPLE_MAX))
@@ -140,7 +140,7 @@
* and increment a counter if clipping occurs.
*/
#define SOX_24BIT_CLIP_COUNT(l, clips) \
- ((l) >= ((sox_ssample_t)1 << 23)? ++(clips), ((sox_sample_t)1 << 23) - 1 : \
+ ((l) >= ((sox_ssample_t)1 << 23)? ++(clips), ((sox_ssample_t)1 << 23) - 1 : \
(l) <=-((sox_ssample_t)1 << 23)? ++(clips),-((sox_ssample_t)1 << 23) + 1 : (l))
@@ -229,8 +229,8 @@
{
sox_size_t start; /* first sample */
sox_size_t length; /* length */
- unsigned int count; /* number of repeats, 0=forever */
- signed char type; /* 0=no, 1=forward, 2=forward/back */
+ unsigned int count; /* number of repeats, 0=forever */
+ unsigned char type; /* 0=no, 1=forward, 2=forward/back */
} sox_loopinfo_t;
/* Instrument parameters */
@@ -242,7 +242,7 @@
char MIDInote; /* for unity pitch playback */
char MIDIlow, MIDIhi;/* MIDI pitch-bend range */
char loopmode; /* semantics of loop data */
- signed char nloops; /* number of active loops (max SOX_MAX_NLOOPS) */
+ unsigned nloops; /* number of active loops (max SOX_MAX_NLOOPS) */
} sox_instrinfo_t;
/* Loop modes, upper 4 bits mask the loop blass, lower 4 bits describe */
--- a/src/sox_i.h
+++ b/src/sox_i.h
@@ -135,7 +135,7 @@
int sox_seeki(ft_t ft, sox_ssize_t offset, int whence);
sox_size_t sox_filelength(ft_t ft);
int sox_flush(ft_t ft);
-sox_size_t sox_tell(ft_t ft);
+sox_ssize_t sox_tell(ft_t ft);
int sox_eof(ft_t ft);
int sox_error(ft_t ft);
void sox_rewind(ft_t ft);
--- a/src/sphere.c
+++ b/src/sphere.c
@@ -150,7 +150,7 @@
if (ft->seekable) {
/* Check first four bytes of data to see if it's shorten compressed. */
- sox_size_t pos = sox_tell(ft);
+ sox_ssize_t pos = sox_tell(ft);
sox_reads(ft, sphere->shorten_check, 4);
if (!strcmp(sphere->shorten_check,"ajkg")) {
--- a/src/voc.c
+++ b/src/voc.c
@@ -477,7 +477,7 @@
sox_ssample_t datum;
sox_writeb(ft, 0); /* End of file block code */
- sox_seeki(ft, v->blockseek, 0); /* seek back to block length */
+ sox_seeki(ft, (sox_ssize_t)v->blockseek, 0); /* seek back to block length */
sox_seeki(ft, 1, 1); /* seek forward one */
if (v->silent) {
sox_writew(ft, v->samples);
--- a/src/vorbis.c
+++ b/src/vorbis.c
@@ -360,7 +360,7 @@
}
quality = ft->signal.compression;
}
- vorbis_encode_init_vbr(&ve->vi, (int)ft->signal.channels, (int)ft->signal.rate, quality / 10);
+ vorbis_encode_init_vbr(&ve->vi, (int)ft->signal.channels, (int)ft->signal.rate, (float)(quality / 10));
vorbis_analysis_init(&ve->vd, &ve->vi);
vorbis_block_init(&ve->vd, &ve->vb);
--- a/src/wav.c
+++ b/src/wav.c
@@ -359,7 +359,7 @@
break; /* Found the given chunk */
/* skip to next chunk */
- if (*len == 0 || sox_seeki(ft, *len, SEEK_CUR) != SOX_SUCCESS)
+ if (*len == 0 || sox_seeki(ft, (sox_ssize_t)(*len), SEEK_CUR) != SOX_SUCCESS)
{
sox_fail_errno(ft,SOX_EHDR,
"WAV chunk appears to have invalid size %d.", *len);
@@ -803,7 +803,7 @@
}
/* Skip anything left over from fmt chunk */
- sox_seeki(ft, len, SEEK_CUR);
+ sox_seeki(ft, (sox_ssize_t)len, SEEK_CUR);
/* for non-PCM formats, there's a 'fact' chunk before
* the upcoming 'data' chunk */
@@ -891,7 +891,7 @@
* doubt any machine writing Cool Edit Chunks writes them at an odd
* offset */
len = (len + 1) & ~1u;
- if (sox_seeki(ft, len, SEEK_CUR) == SOX_SUCCESS &&
+ if (sox_seeki(ft, (sox_ssize_t)len, SEEK_CUR) == SOX_SUCCESS &&
findChunk(ft, "LIST", &len) != SOX_EOF)
{
ft->comment = (char*)xmalloc(256);
@@ -938,7 +938,7 @@
strcat(ft->comment,text);
}
if (strlen(text) < len)
- sox_seeki(ft, len - strlen(text), SEEK_CUR);
+ sox_seeki(ft, (sox_ssize_t)(len - strlen(text)), SEEK_CUR);
}
else if (strncmp(magic,"ISFT",4) == 0)
{
@@ -957,12 +957,12 @@
strcat(ft->comment,text);
}
if (strlen(text) < len)
- sox_seeki(ft, len - strlen(text), SEEK_CUR);
+ sox_seeki(ft, (sox_ssize_t)(len - strlen(text)), SEEK_CUR);
}
else if (strncmp(magic,"cue ",4) == 0)
{
sox_debug("Chunk cue ");
- sox_seeki(ft,len-4,SEEK_CUR);
+ sox_seeki(ft,(sox_ssize_t)(len-4),SEEK_CUR);
sox_readdw(ft,&dwLoopPos);
ft->loops[0].start = dwLoopPos;
}
@@ -972,19 +972,19 @@
sox_readdw(ft,&dwLoopPos);
ft->loops[0].length = dwLoopPos - ft->loops[0].start;
if (len > 4)
- sox_seeki(ft, len - 4, SEEK_CUR);
+ sox_seeki(ft, (sox_ssize_t)(len - 4), SEEK_CUR);
}
else
{
sox_debug("Attempting to seek beyond unsupported chunk '%c%c%c%c' of length %d bytes", magic[0], magic[1], magic[2], magic[3], len);
len = (len + 1) & ~1u;
- sox_seeki(ft, len, SEEK_CUR);
+ sox_seeki(ft, (sox_ssize_t)len, SEEK_CUR);
}
}
}
}
sox_clearerr(ft);
- sox_seeki(ft,wav->dataStart,SEEK_SET);
+ sox_seeki(ft,(sox_ssize_t)wav->dataStart,SEEK_SET);
}
return SOX_SUCCESS;
}
@@ -1455,7 +1455,7 @@
sox_writes(ft, "WAVE");
sox_writes(ft, "fmt ");
sox_writedw(ft, wFmtSize);
- sox_writew(ft, isExtensible? WAVE_FORMAT_EXTENSIBLE : wFormatTag);
+ sox_writew(ft, isExtensible ? WAVE_FORMAT_EXTENSIBLE : wFormatTag);
sox_writew(ft, wChannels);
sox_writedw(ft, dwSamplesPerSecond);
sox_writedw(ft, dwAvgBytesPerSec);
@@ -1465,7 +1465,7 @@
if (isExtensible)
{
size_t i;
- static const char guid[14] = "\x00\x00\x00\x00\x10\x00\x80\x00\x00\xAA\x00\x38\x9B\x71";
+ static const unsigned char guid[14] = "\x00\x00\x00\x00\x10\x00\x80\x00\x00\xAA\x00\x38\x9B\x71";
sox_writew(ft, 22);
sox_writew(ft, wBitsPerSample); /* No padding in container */
sox_writedw(ft, 0); /* Speaker mapping not specified */
@@ -1490,8 +1490,8 @@
sox_writew(ft, wSamplesPerBlock);
sox_writew(ft, 7); /* nCoefs */
for (i=0; i<7; i++) {
- sox_writew(ft, iCoef[i][0]);
- sox_writew(ft, iCoef[i][1]);
+ sox_writew(ft, (uint16_t)(iCoef[i][0]));
+ sox_writew(ft, (uint16_t)(iCoef[i][1]));
}
break;
case WAVE_FORMAT_GSM610:
@@ -1690,7 +1690,7 @@
wav->blockAlign * ft->signal.channels / 2;
gsmoff -= gsmoff % (wav->blockAlign * ft->signal.channels);
- ft->sox_errno = sox_seeki(ft, gsmoff + wav->dataStart, SEEK_SET);
+ ft->sox_errno = sox_seeki(ft, (sox_ssize_t)(gsmoff + wav->dataStart), SEEK_SET);
if (ft->sox_errno != SOX_SUCCESS)
return SOX_EOF;
@@ -1716,7 +1716,7 @@
new_offset += (channel_block - alignment);
new_offset += wav->dataStart;
- ft->sox_errno = sox_seeki(ft, (sox_size_t)new_offset, SEEK_SET);
+ ft->sox_errno = sox_seeki(ft, new_offset, SEEK_SET);
if( ft->sox_errno == SOX_SUCCESS )
wav->numSamples = (ft->length / ft->signal.channels) -
--- a/src/wav.h
+++ b/src/wav.h
@@ -5,27 +5,27 @@
/* purloined from public Microsoft RIFF docs */
-#define WAVE_FORMAT_UNKNOWN (0x0000)
-#define WAVE_FORMAT_PCM (0x0001)
-#define WAVE_FORMAT_ADPCM (0x0002)
-#define WAVE_FORMAT_IEEE_FLOAT (0x0003)
-#define WAVE_FORMAT_ALAW (0x0006)
-#define WAVE_FORMAT_MULAW (0x0007)
-#define WAVE_FORMAT_OKI_ADPCM (0x0010)
-#define WAVE_FORMAT_IMA_ADPCM (0x0011)
-#define WAVE_FORMAT_DIGISTD (0x0015)
-#define WAVE_FORMAT_DIGIFIX (0x0016)
-#define WAVE_FORMAT_DOLBY_AC2 (0x0030)
-#define WAVE_FORMAT_GSM610 (0x0031)
-#define WAVE_FORMAT_ROCKWELL_ADPCM (0x003b)
-#define WAVE_FORMAT_ROCKWELL_DIGITALK (0x003c)
-#define WAVE_FORMAT_G721_ADPCM (0x0040)
-#define WAVE_FORMAT_G728_CELP (0x0041)
-#define WAVE_FORMAT_MPEG (0x0050)
-#define WAVE_FORMAT_MPEGLAYER3 (0x0055)
-#define WAVE_FORMAT_G726_ADPCM (0x0064)
-#define WAVE_FORMAT_G722_ADPCM (0x0065)
-#define WAVE_FORMAT_EXTENSIBLE (0xfffe)
+#define WAVE_FORMAT_UNKNOWN (0x0000U)
+#define WAVE_FORMAT_PCM (0x0001U)
+#define WAVE_FORMAT_ADPCM (0x0002U)
+#define WAVE_FORMAT_IEEE_FLOAT (0x0003U)
+#define WAVE_FORMAT_ALAW (0x0006U)
+#define WAVE_FORMAT_MULAW (0x0007U)
+#define WAVE_FORMAT_OKI_ADPCM (0x0010U)
+#define WAVE_FORMAT_IMA_ADPCM (0x0011U)
+#define WAVE_FORMAT_DIGISTD (0x0015U)
+#define WAVE_FORMAT_DIGIFIX (0x0016U)
+#define WAVE_FORMAT_DOLBY_AC2 (0x0030U)
+#define WAVE_FORMAT_GSM610 (0x0031U)
+#define WAVE_FORMAT_ROCKWELL_ADPCM (0x003bU)
+#define WAVE_FORMAT_ROCKWELL_DIGITALK (0x003cU)
+#define WAVE_FORMAT_G721_ADPCM (0x0040U)
+#define WAVE_FORMAT_G728_CELP (0x0041U)
+#define WAVE_FORMAT_MPEG (0x0050U)
+#define WAVE_FORMAT_MPEGLAYER3 (0x0055U)
+#define WAVE_FORMAT_G726_ADPCM (0x0064U)
+#define WAVE_FORMAT_G722_ADPCM (0x0065U)
+#define WAVE_FORMAT_EXTENSIBLE (0xfffeU)
#endif /* WAV_H_INCLUDED */
--- a/src/wve.c
+++ b/src/wve.c
@@ -40,7 +40,7 @@
new_offset += (channel_block - alignment);
new_offset += wve->dataStart;
- return sox_seeki(ft, offset, SEEK_SET);
+ return sox_seeki(ft, (sox_ssize_t)offset, SEEK_SET);
}
static int sox_wvestartread(ft_t ft)