ref: cf89765a24a87c2bf7826489bfb8b7ae8ff03c55
parent: c75c8628a85b1f24e975a5383306feb5e72c8cbf
author: robs <robs>
date: Sun Feb 25 05:54:42 EST 2007
Some warnings clean-ups
--- a/src/8svx.c
+++ b/src/8svx.c
@@ -39,7 +39,7 @@
uint32_t channels, i;
unsigned short rate;
- long chan1_pos;
+ off_t chan1_pos;
if (! ft->seekable)
{
@@ -181,7 +181,7 @@
sox_fail_errno (ft,errno,"Can't position channel %d",i);
return(SOX_EOF);
}
- if (fseeko(p->ch[i],p->nsamples/channels*i,SEEK_CUR))
+ if (fseeko(p->ch[i],(off_t)p->nsamples/channels*i,SEEK_CUR))
{
sox_fail_errno (ft,errno,"Can't seek channel %d",i);
return(SOX_EOF);
@@ -295,7 +295,7 @@
/* append all channel pieces to channel 0 */
/* close temp files */
for (i = 1; i < ft->signal.channels; i++) {
- if (fseeko(p->ch[i], 0, 0))
+ if (fseeko(p->ch[i], (off_t)0, 0))
{
sox_fail_errno (ft,errno,"Can't rewind channel output file %d",i);
return(SOX_EOF);
@@ -327,7 +327,7 @@
#define SVXHEADERSIZE 100
static void svxwriteheader(ft_t ft, sox_size_t nsamples)
{
- int32_t formsize = nsamples + SVXHEADERSIZE - 8;
+ sox_size_t formsize = nsamples + SVXHEADERSIZE - 8;
/* FORM size must be even */
if(formsize % 2 != 0) formsize++;
@@ -352,8 +352,8 @@
sox_writes(ft, "CHAN");
sox_writedw(ft, 4);
- sox_writedw(ft, (ft->signal.channels == 2) ? 6 :
- (ft->signal.channels == 4) ? 15 : 2);
+ sox_writedw(ft, (ft->signal.channels == 2) ? 6u :
+ (ft->signal.channels == 4) ? 15u : 2u);
sox_writes(ft, "BODY");
sox_writedw(ft, nsamples); /* samples in file */
--- a/src/adpcms.c
+++ b/src/adpcms.c
@@ -96,7 +96,6 @@
{
state->file.count = 0;
state->file.pos = 0;
- state->file.eof = 0;
state->store.byte = 0;
state->store.flag = 0;
@@ -161,7 +160,7 @@
sox_size_t n;
uint8_t byte;
- for (n = 0; n < (len&~1) && sox_readb(ft, &byte) == SOX_SUCCESS; n += 2) {
+ for (n = 0; n < (len&~1u) && sox_readb(ft, &byte) == SOX_SUCCESS; n += 2) {
short word = adpcm_decode(byte >> 4, &state->encoder);
*buffer++ = SOX_SIGNED_WORD_TO_SAMPLE(word, ft->clips);
--- a/src/aiff.c
+++ b/src/aiff.c
@@ -792,7 +792,7 @@
/* time stamp of comment, Unix knows of time from 1/1/1970,
Apple knows time from 1/1/1904 */
- sox_writedw(ft, ((int32_t) time(NULL)) + 2082844800);
+ sox_writedw(ft, (unsigned)(time(NULL) + 2082844800));
/* A marker ID of 0 indicates the comment is not associated
with a marker */
@@ -808,7 +808,7 @@
/* COMM chunk -- describes encoding (and #frames) */
sox_writes(ft, "COMM");
sox_writedw(ft, 18); /* COMM chunk size */
- sox_writew(ft, ft->signal.channels); /* nchannels */
+ sox_writew(ft, (int)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);
@@ -818,7 +818,7 @@
sox_writes(ft, "MARK");
if (ft->instr.nloops > 2)
ft->instr.nloops = 2;
- sox_writedw(ft, 2 + 16*ft->instr.nloops);
+ sox_writedw(ft, 2 + 16u*ft->instr.nloops);
sox_writew(ft, ft->instr.nloops);
for(i = 0; i < ft->instr.nloops; i++) {
@@ -969,7 +969,7 @@
/* COMM chunk -- describes encoding (and #frames) */
sox_writes(ft, "COMM");
sox_writedw(ft, 18+4+1+15); /* COMM chunk size */
- sox_writew(ft, ft->signal.channels); /* nchannels */
+ sox_writew(ft, (int)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
@@ -32,6 +32,7 @@
#define DEC_INV_MAGIC 0x0064732e /* '\0ds.' upside-down */
#define SUN_HDRSIZE 24 /* Size of minimal header */
#define SUN_UNSPEC ((unsigned)(~0)) /* Unspecified data size */
+#define SUN_ENCODING_UNKNOWN 0
#define SUN_ULAW 1 /* u-law encoding */
#define SUN_LIN_8 2 /* Linear 8 bits */
#define SUN_LIN_16 3 /* Linear 16 bits */
@@ -61,7 +62,7 @@
static void auwriteheader(ft_t ft, sox_size_t data_size);
-static int sox_auencodingandsize(int sun_encoding, sox_encoding_t * encoding, int * size)
+static int sox_auencodingandsize(uint32_t sun_encoding, sox_encoding_t * encoding, int * size)
{
switch (sun_encoding) {
case SUN_ULAW:
@@ -378,9 +379,9 @@
return(SOX_SUCCESS);
}
-static int sox_ausunencoding(int size, int encoding)
+static unsigned sox_ausunencoding(int size, sox_encoding_t encoding)
{
- int sun_encoding;
+ unsigned sun_encoding;
if (encoding == SOX_ENCODING_ULAW && size == SOX_SIZE_BYTE)
sun_encoding = SUN_ULAW;
@@ -394,8 +395,7 @@
sun_encoding = SUN_LIN_24;
else if (encoding == SOX_ENCODING_FLOAT && size == SOX_SIZE_32BIT)
sun_encoding = SUN_FLOAT;
- else
- sun_encoding = SOX_ENCODING_UNKNOWN;
+ else sun_encoding = SUN_ENCODING_UNKNOWN;
return sun_encoding;
}
@@ -403,13 +403,14 @@
{
uint32_t magic;
uint32_t hdr_size;
- int encoding;
+ uint32_t encoding;
uint32_t sample_rate;
uint32_t channels;
int x;
int comment_size;
- if ((encoding = sox_ausunencoding(ft->signal.size, ft->signal.encoding)) == -1) {
+ encoding = sox_ausunencoding(ft->signal.size, ft->signal.encoding);
+ if (encoding == SUN_ENCODING_UNKNOWN) {
sox_report("Unsupported output encoding/size for Sun/NeXT header or .AU format not specified.");
sox_report("Only U-law, A-law, and signed bytes/words/tri-bytes are supported.");
sox_report("Defaulting to 8khz u-law");
--- a/src/avr.c
+++ b/src/avr.c
@@ -260,7 +260,7 @@
avr_t avr = (avr_t)ft->priv;
int rc;
- int size = avr->size / ft->signal.channels;
+ unsigned size = avr->size / ft->signal.channels;
rc = sox_rawstopwrite(ft);
if (rc)
--- a/src/cvsd.c
+++ b/src/cvsd.c
@@ -421,7 +421,7 @@
pch += sizeof(hdr->Filename);
put16_le(&pch, hdr->Id);
put16_le(&pch, hdr->State);
- put32_le(&pch, hdr->Unixtime);
+ put32_le(&pch, (unsigned)hdr->Unixtime);
put16_le(&pch, hdr->Usender);
put16_le(&pch, hdr->Ureceiver);
put32_le(&pch, hdr->Length);
--- a/src/dat.c
+++ b/src/dat.c
@@ -112,7 +112,7 @@
inpPtr += inpPtrInc;
if (retc != 1) {
sox_fail_errno(ft,SOX_EOF,"Unable to read sample.");
- return (SOX_EOF);
+ return 0;
}
sampval *= SOX_SAMPLE_MAX;
*buf++ = SOX_ROUND_CLIP_COUNT(sampval, ft->clips);
--- a/src/getopt.c
+++ b/src/getopt.c
@@ -1,4 +1,4 @@
-#include "stconfig.h"
+#include "soxconfig.h"
#ifndef HAVE_GETOPT_LONG
/* Getopt for GNU.
--- a/src/getopt1.c
+++ b/src/getopt1.c
@@ -1,4 +1,4 @@
-#include "stconfig.h"
+#include "soxconfig.h"
#ifndef HAVE_GETOPT_LONG
/* getopt_long and getopt_long_only entry points for GNU getopt.
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
--- a/src/gsm.c
+++ b/src/gsm.c
@@ -45,7 +45,7 @@
/* Private data */
struct gsmpriv {
- int channels;
+ unsigned channels;
gsm_signal *samples;
gsm_signal *samplePtr;
gsm_signal *sampleTop;
@@ -56,7 +56,7 @@
static int gsmstart_rw(ft_t ft, int w)
{
struct gsmpriv *p = (struct gsmpriv *) ft->priv;
- int ch;
+ unsigned ch;
ft->signal.encoding = SOX_ENCODING_GSM;
ft->signal.size = SOX_SIZE_BYTE;
@@ -209,7 +209,7 @@
static int sox_gsmstopread(ft_t ft)
{
struct gsmpriv *p = (struct gsmpriv *) ft->priv;
- int ch;
+ unsigned ch;
for (ch=0; ch<p->channels; ch++)
gsm_destroy(p->handle[ch]);
--- a/src/hcom.c
+++ b/src/hcom.c
@@ -298,7 +298,7 @@
}
}
-static void putcode(ft_t ft, long codes[256], long codesize[256], unsigned char c, unsigned char **df)
+static void putcode(ft_t ft, long codes[256], long codesize[256], unsigned c, unsigned char **df)
{
struct readpriv *p = (struct readpriv *) ft->priv;
long code, size;
@@ -321,7 +321,7 @@
}
}
-static void compress(ft_t ft, unsigned char **df, int32_t *dl, float fr)
+static void compress(ft_t ft, unsigned char **df, int32_t *dl, sox_rate_t fr)
{
struct readpriv *p = (struct readpriv *) ft->priv;
int32_t samplerate;
@@ -416,7 +416,7 @@
put32_be(&dfp, *dl);
put32_be(&dfp, p->new_checksum);
put32_be(&dfp, 1);
- samplerate = 22050 / (int32_t)fr;
+ samplerate = 22050 / fr;
put32_be(&dfp, samplerate);
put16_be(&dfp, dictsize);
*df = datafork; /* reassign passed pointer to new datafork */
@@ -434,7 +434,7 @@
/* Compress it all at once */
if (compressed_len)
- compress(ft, &compressed_data, (int32_t *)&compressed_len, (double) ft->signal.rate);
+ compress(ft, &compressed_data, (int32_t *)&compressed_len, ft->signal.rate);
free((char *)p->data);
/* Write the header */
@@ -442,7 +442,7 @@
sox_padbytes(ft, 65-3);
sox_writes(ft, "FSSD");
sox_padbytes(ft, 83-69);
- sox_writedw(ft, (uint32_t)compressed_len); /* compressed_data size */
+ sox_writedw(ft, compressed_len); /* compressed_data size */
sox_writedw(ft, 0); /* rsrc size */
sox_padbytes(ft, 128 - 91);
if (sox_error(ft)) {
@@ -457,7 +457,7 @@
if (rc == SOX_SUCCESS)
/* Pad the compressed_data fork to a multiple of 128 bytes */
- sox_padbytes(ft, 128 - (int) (compressed_len % 128));
+ sox_padbytes(ft, 128u - (compressed_len % 128));
return rc;
}
--- a/src/maud.c
+++ b/src/maud.c
@@ -167,7 +167,7 @@
if (chunksize & 1)
chunksize++;
chunk_buf = (char *) xmalloc(chunksize + 1);
- if (sox_readbuf(ft, chunk_buf, 1, (int)chunksize)
+ if (sox_readbuf(ft, chunk_buf, 1, chunksize)
!= chunksize)
{
sox_fail_errno(ft,SOX_EOF,"MAUD: Unexpected EOF in ANNO header");
--- a/src/misc.c
+++ b/src/misc.c
@@ -243,7 +243,7 @@
}
/* Write byte. */
-int sox_writeb(ft_t ft, uint8_t ub)
+int sox_writeb(ft_t ft, int ub)
{
if (ft->signal.reverse_nibbles)
ub = ((ub & 15) << 4) | (ub >> 4);
@@ -270,7 +270,7 @@
}
/* Write word. */
-int sox_writew(ft_t ft, uint16_t uw)
+int sox_writew(ft_t ft, int uw)
{
if (ft->signal.reverse_bytes)
uw = sox_swapw(uw);
@@ -343,7 +343,7 @@
return(SOX_EOF);
}
if (ft->signal.reverse_bytes)
- *f = sox_swapf(*f);
+ *f = sox_swapf(f);
return SOX_SUCCESS;
}
@@ -353,7 +353,7 @@
float t = f;
if (ft->signal.reverse_bytes)
- t = sox_swapf(t);
+ t = sox_swapf(&t);
if (sox_writebuf(ft, &t, sizeof(float), 1) != 1)
{
sox_fail_errno(ft,errno,writerr);
@@ -412,7 +412,7 @@
*(*p)++ = (val >> 24) & 0xff;
}
-void put16_le(unsigned char **p, int16_t val)
+void put16_le(unsigned char **p, unsigned val)
{
*(*p)++ = val & 0xff;
*(*p)++ = (val >> 8) & 0xff;
@@ -426,7 +426,7 @@
*(*p)++ = val & 0xff;
}
-void put16_be(unsigned char **p, short val)
+void put16_be(unsigned char **p, int val)
{
*(*p)++ = (val >> 8) & 0xff;
*(*p)++ = val & 0xff;
@@ -442,7 +442,7 @@
}
/* return swapped 32-bit float */
-float sox_swapf(float f)
+float sox_swapf(float const * f)
{
union {
uint32_t dw;
@@ -449,7 +449,7 @@
float f;
} u;
- u.f= f;
+ u.f= *f;
u.dw= (u.dw>>24) | ((u.dw>>8)&0xff00) | ((u.dw<<8)&0xff0000) | (u.dw<<24);
return u.f;
}
@@ -662,16 +662,11 @@
} else
sox_fail_errno(ft,SOX_EPERM, "file not seekable");
} else {
- if (fseeko(ft->fp, offset, whence) == -1)
+ if (fseeko(ft->fp, (off_t)offset, whence) == -1)
sox_fail_errno(ft,errno,strerror(errno));
else
ft->sox_errno = SOX_SUCCESS;
}
-
- /* Empty the st file buffer */
- if (ft->sox_errno == SOX_SUCCESS)
- ft->eof = 0;
-
return ft->sox_errno;
}
--- a/src/oss.c
+++ b/src/oss.c
@@ -180,7 +180,6 @@
}
file->count = 0;
file->pos = 0;
- file->eof = 0;
file->buf = (char *)xmalloc(file->size);
if (ioctl(fileno(ft->fp), SNDCTL_DSP_SYNC, NULL) < 0) {
--- a/src/raw.c
+++ b/src/raw.c
@@ -55,7 +55,7 @@
/* Works nicely for starting read and write; sox_rawstart{read,write}
are #defined in sox_i.h */
-int sox_rawstart(ft_t ft, sox_bool default_rate, sox_bool default_channels, sox_encoding_t encoding, signed char size, sox_option_t rev_bits)
+int sox_rawstart(ft_t ft, sox_bool default_rate, sox_bool default_channels, sox_encoding_t encoding, int size, sox_option_t rev_bits)
{
if (default_rate && ft->signal.rate == 0) {
sox_warn("'%s': sample rate not specified; trying 8kHz", ft->filename);
@@ -90,7 +90,6 @@
else ft->signal.reverse_bits = rev_bits;
}
- ft->eof = 0;
return SOX_SUCCESS;
}
@@ -232,12 +231,6 @@
return 0;
}
-static void writeflush(ft_t ft)
-{
- ft->eof = SOX_EOF;
-}
-
-
/* Writes SoX's internal buffer format to buffer of various data types. */
sox_size_t sox_rawwrite(ft_t ft, const sox_sample_t *buf, sox_size_t nsamp)
{
@@ -249,12 +242,6 @@
return 0;
}
-int sox_rawstopwrite(ft_t ft)
-{
- writeflush(ft);
- return SOX_SUCCESS;
-}
-
static int raw_start(ft_t ft) {
return sox_rawstart(ft,sox_false,sox_false,SOX_ENCODING_UNKNOWN,-1,SOX_OPTION_DEFAULT);
}
@@ -262,8 +249,8 @@
static char const * names[] = {"raw", NULL};
static sox_format_t driver = {
names, NULL, SOX_FILE_SEEK,
- raw_start, sox_rawread , sox_rawstopread,
- raw_start, sox_rawwrite, sox_rawstopwrite,
+ raw_start, sox_rawread , sox_format_nothing,
+ raw_start, sox_rawwrite, sox_format_nothing,
sox_rawseek
};
return &driver;
@@ -277,8 +264,8 @@
static char const * names[] = {#id, alt1, alt2, NULL}; \
static sox_format_t driver = { \
names, NULL, 0, \
- id##_start, sox_rawread , sox_rawstopread, \
- id##_start, sox_rawwrite, sox_rawstopwrite, \
+ id##_start, sox_rawread , sox_format_nothing, \
+ id##_start, sox_rawwrite, sox_format_nothing, \
sox_format_nothing_seek \
}; \
return &driver; \
--- a/src/sf.c
+++ b/src/sf.c
@@ -33,7 +33,8 @@
static void readcodes(ft_t ft, SFHEADER *sfhead)
{
char *commentbuf = NULL, *sfcharp, *newline;
- short bsize, finished = 0;
+ sox_size_t bsize;
+ sox_bool finished = sox_false;
SFCODE *sfcodep;
sfcodep = (SFCODE *) &sfcodes(sfhead);
@@ -46,7 +47,7 @@
bsize = sfcodep->bsize - sizeof(SFCODE);
switch(sfcodep->code) {
case SF_END:
- finished = 1;
+ finished = sox_true;
break;
case SF_COMMENT:
commentbuf = (char *) xmalloc(bsize + 1);
@@ -104,7 +105,7 @@
}
memcpy(&sf->info, &sfhead.sfinfo, sizeof(struct sfinfo));
if (ft->signal.reverse_bytes) {
- sf->info.sf_srate = sox_swapf(sf->info.sf_srate);
+ sf->info.sf_srate = sox_swapf(&sf->info.sf_srate);
sf->info.sf_packmode = sox_swapdw(sf->info.sf_packmode);
sf->info.sf_chans = sox_swapdw(sf->info.sf_chans);
}
--- a/src/smp.c
+++ b/src/smp.c
@@ -122,7 +122,7 @@
trailer->loops[i].count = ft->loops[i].count;
} else {
/* set first loop start as FFFFFFFF */
- trailer->loops[i].start = ~0;
+ trailer->loops[i].start = ~0u;
/* to mark it as not set */
trailer->loops[i].end = 0;
trailer->loops[i].type = 0;
@@ -131,12 +131,12 @@
}
for(i = 0; i < 8; i++) { /* write the 8 markers */
strcpy(trailer->markers[i].name, " ");
- trailer->markers[i].position = ~0;
+ trailer->markers[i].position = ~0u;
}
trailer->MIDInote = MIDI_UNITY; /* Unity play back */
trailer->rate = rate;
trailer->SMPTEoffset = 0;
- trailer->CycleSize = -1;
+ trailer->CycleSize = ~0u;
}
/*
--- a/src/sox.c
+++ b/src/sox.c
@@ -102,9 +102,9 @@
static void build_effects_table(void);
static int start_all_effects(void);
static int flow_effect_out(void);
-static int flow_effect(int);
+static int flow_effect(unsigned);
static int drain_effect_out(void);
-static int drain_effect(int);
+static int drain_effect(unsigned);
static void stop_effects(void);
static void delete_effects(void);
@@ -142,9 +142,9 @@
static struct sox_effect efftab[MAX_EFF]; /* left/mono channel effects */
static struct sox_effect efftabR[MAX_EFF];/* right channel effects */
-static int neffects; /* # of effects to run on data */
-static int input_eff; /* last input effect with data */
-static int input_eff_eof; /* has input_eff reached EOF? */
+static unsigned neffects; /* # of effects to run on data */
+static unsigned input_eff; /* last input effect with data */
+static sox_bool input_eff_eof; /* has input_eff reached EOF? */
static struct sox_effect user_efftab[MAX_USER_EFF];
static int nuser_effects;
@@ -884,8 +884,8 @@
*/
static int process(void) {
- int e, flowstatus = 0;
- sox_size_t ws, s, i;
+ int flowstatus = 0;
+ sox_size_t e, ws, s, i;
sox_size_t ilen[MAX_INPUT_FILES];
sox_sample_t *ibuf[MAX_INPUT_FILES];
@@ -1011,7 +1011,7 @@
optimize_trim();
input_eff = 0;
- input_eff_eof = 0;
+ input_eff_eof = sox_false;
/* mark chain as empty */
for(e = 1; e < neffects; e++)
@@ -1230,7 +1230,8 @@
static int start_all_effects(void)
{
- int i, j, ret = SOX_SUCCESS;
+ unsigned i, j;
+ int ret = SOX_SUCCESS;
for (i = 1; i < neffects; i++) {
struct sox_effect * e = &efftab[i];
@@ -1276,13 +1277,13 @@
static int flow_effect_out(void)
{
- int e, havedata, flowstatus = 0;
- size_t len, total;
+ int havedata, flowstatus = 0;
+ size_t e, len, total;
do {
/* run entire chain BACKWARDS: pull, don't push.*/
/* this is because buffering system isn't a nice queueing system */
- for (e = neffects - 1; e && e >= input_eff; e--) {
+ for (e = neffects - 1; e && (int)e >= (int)input_eff; e--) {
/* Do not call flow effect on input if it has reported
* EOF already as that's a waste of time and may
* do bad things.
@@ -1300,7 +1301,7 @@
if (flowstatus == SOX_EOF) {
input_eff = e;
/* Assume next effect hasn't reach EOF yet */
- input_eff_eof = 0;
+ input_eff_eof = sox_false;
}
/* If this buffer contains more input data then break out
@@ -1329,7 +1330,7 @@
&efftab[neffects - 1].obuf[total],
efftab[neffects - 1].olen - total);
- if (len == 0 || ofile->desc->eof) {
+ if (len == 0) {
sox_warn("Error writing: %s", ofile->desc->sox_errstr);
return SOX_EOF;
}
@@ -1349,7 +1350,7 @@
* show no more data.
*/
havedata = 0;
- for (e = neffects - 1; e >= input_eff; e--) {
+ for (e = neffects - 1; (int)e >= (int)input_eff; e--) {
/* If odone and olen are the same then this buffer
* can be reused.
*/
@@ -1380,7 +1381,7 @@
*/
if (input_eff_eof) {
input_eff++;
- input_eff_eof = 0;
+ input_eff_eof = sox_false;
}
/* If the input file is not returning data then
@@ -1395,10 +1396,10 @@
if (efftab[input_eff].olen == 0) {
input_eff++;
/* Assume next effect hasn't reached EOF yet. */
- input_eff_eof = 0;
+ input_eff_eof = sox_false;
} else {
havedata = 1;
- input_eff_eof = (rc == SOX_EOF) ? 1 : 0;
+ input_eff_eof = rc == SOX_EOF;
break;
}
}
@@ -1417,7 +1418,7 @@
return SOX_SUCCESS;
}
-static int flow_effect(int e)
+static int flow_effect(unsigned e)
{
sox_size_t i, done, idone, odone, idonel, odonel, idoner, odoner;
const sox_sample_t *ibuf;
@@ -1526,7 +1527,7 @@
if (input_eff == 0) {
input_eff = 1;
/* Assuming next effect hasn't reached EOF yet. */
- input_eff_eof = 0;
+ input_eff_eof = sox_false;
}
/* Try to prime the pump with some data */
@@ -1536,9 +1537,9 @@
if (efftab[input_eff].olen == 0) {
input_eff++;
/* Assuming next effect hasn't reached EOF yet. */
- input_eff_eof = 0;
+ input_eff_eof = sox_false;
} else {
- input_eff_eof = (rc == SOX_EOF) ? 1 : 0;
+ input_eff_eof = rc == SOX_EOF;
break;
}
}
@@ -1547,7 +1548,7 @@
return flow_effect_out();
}
-static int drain_effect(int e)
+static int drain_effect(unsigned e)
{
sox_ssize_t i, olen, olenl, olenr;
sox_sample_t *obuf;
@@ -1593,7 +1594,7 @@
static void stop_effects(void)
{
- int e;
+ unsigned e;
for (e = 1; e < neffects; e++) {
sox_size_t clips;
@@ -1614,7 +1615,7 @@
static void delete_effects(void)
{
- int e;
+ unsigned e;
for (e = 1; e < neffects; e++) {
int (*delete)(eff_t effp) =
@@ -1627,7 +1628,7 @@
static sox_size_t total_clips(void)
{
- int i;
+ unsigned i;
sox_size_t clips = 0;
for (i = 0; i < file_count; ++i)
clips += files[i]->desc->clips + files[i]->volume_clips;
--- a/src/sox.h
+++ b/src/sox.h
@@ -14,7 +14,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include "ststdint.h"
+#include "soxstdint.h"
/* The following is the API version of libsox. It is not meant
* to follow the version number of SoX but it has historically.
@@ -260,7 +260,6 @@
size_t size; /* Size of buffer */
size_t count; /* Count read in to buffer */
size_t pos; /* Position in buffer */
- unsigned char eof; /* Marker that EOF has been reached */
} sox_fileinfo_t;
@@ -297,16 +296,15 @@
sox_instrinfo_t instr; /* instrument specification */
sox_loopinfo_t loops[SOX_MAX_NLOOPS]; /* Looping specification */
sox_bool seekable; /* can seek on this file */
- char mode; /* read or write mode */
+ char mode; /* read or write mode */
sox_size_t length; /* frames in file, or 0 if unknown. */
sox_size_t clips; /* increment if clipping occurs */
- char *filename; /* file name */
- char *filetype; /* type of file */
- char *comment; /* comment string */
- FILE *fp; /* File stream pointer */
- unsigned char eof; /* Marker that EOF has been reached */
- int sox_errno; /* Failure error codes */
- char sox_errstr[256]; /* Extend Failure text */
+ char *filename; /* file name */
+ char *filetype; /* type of file */
+ char *comment; /* comment string */
+ FILE *fp; /* File stream pointer */
+ int sox_errno; /* Failure error codes */
+ char sox_errstr[256]; /* Extend Failure text */
const sox_format_t *h; /* format struct for this file */
/* The following is a portable trick to align this variable on
* an 8-byte boundery. Once this is done, the buffer alloced
--- a/src/sox_i.h
+++ b/src/sox_i.h
@@ -14,7 +14,7 @@
#ifndef SOX_I_H
#define SOX_I_H
-#include "stconfig.h"
+#include "soxconfig.h"
#include "sox.h"
#include "xmalloc.h"
@@ -104,9 +104,9 @@
int sox_reads(ft_t ft, char *c, sox_size_t len);
int sox_writes(ft_t ft, char *c);
int sox_readb(ft_t ft, uint8_t *ub);
-int sox_writeb(ft_t ft, uint8_t ub);
+int sox_writeb(ft_t ft, int ub);
int sox_readw(ft_t ft, uint16_t *uw);
-int sox_writew(ft_t ft, uint16_t uw);
+int sox_writew(ft_t ft, int uw);
int sox_read3(ft_t ft, uint24_t *u3);
int sox_write3(ft_t ft, uint24_t u3);
int sox_readdw(ft_t ft, uint32_t *udw);
@@ -128,9 +128,9 @@
uint32_t get32_le(unsigned char **p);
uint16_t get16_le(unsigned char **p);
void put32_le(unsigned char **p, uint32_t val);
-void put16_le(unsigned char **p, int16_t val);
+void put16_le(unsigned char **p, unsigned val);
void put32_be(unsigned char **p, int32_t val);
-void put16_be(unsigned char **p, short val);
+void put16_be(unsigned char **p, int val);
/* Utilities to byte-swap values, use libc optimized macros if possible */
#ifdef HAVE_BYTESWAP_H
@@ -140,7 +140,7 @@
#define sox_swapw(uw) (((uw >> 8) | (uw << 8)) & 0xffff)
#define sox_swapdw(udw) ((udw >> 24) | ((udw >> 8) & 0xff00) | ((udw << 8) & 0xff0000) | (udw << 24))
#endif
-float sox_swapf(float f);
+float sox_swapf(float const * f);
uint32_t sox_swap24(uint32_t udw);
double sox_swapd(double d);
@@ -268,7 +268,6 @@
int sox_rawstopread(ft_t ft);
int sox_rawstartwrite(ft_t ft);
sox_size_t sox_rawwrite(ft_t ft, const sox_sample_t *buf, sox_size_t nsamp);
-int sox_rawstopwrite(ft_t ft);
int sox_rawseek(ft_t ft, sox_size_t offset);
/* libsndfile I/O */
@@ -293,10 +292,11 @@
int sox_effect_nothing_drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp);
int sox_effect_nothing_getopts(eff_t effp, int n, char **argv UNUSED);
-int sox_rawstart(ft_t ft, sox_bool default_rate, sox_bool default_channels, sox_encoding_t encoding, signed char size, sox_option_t rev_bits);
+int sox_rawstart(ft_t ft, sox_bool default_rate, sox_bool default_channels, sox_encoding_t encoding, int size, sox_option_t rev_bits);
#define sox_rawstartread(ft) sox_rawstart(ft, sox_false, sox_false, SOX_ENCODING_UNKNOWN, -1, SOX_OPTION_DEFAULT)
#define sox_rawstartwrite sox_rawstartread
#define sox_rawstopread sox_format_nothing
+#define sox_rawstopwrite sox_format_nothing
/*=============================================================================
* Effects
--- a/src/tests.sh
+++ b/src/tests.sh
@@ -96,9 +96,9 @@
(rate=8000; convertToAndFrom al sw uw sl raw Raw dat) || exit 1 # Fixed rate
}
-grep -q "^#define HAVE_LIBFLAC" stconfig.h || skip="flac $skip"
-grep -q "^#define HAVE_LIBOGG" stconfig.h || skip="ogg $skip"
-grep -q "^#define HAVE_SNDFILE_H" stconfig.h || skip="caf $skip"
+grep -q "^#define HAVE_LIBFLAC" soxconfig.h || skip="flac $skip"
+grep -q "^#define HAVE_LIBOGG" soxconfig.h || skip="ogg $skip"
+grep -q "^#define HAVE_SNDFILE_H" soxconfig.h || skip="caf $skip"
rate=44100
samples=23493
--- a/src/vorbis.c
+++ b/src/vorbis.c
@@ -417,7 +417,7 @@
ret = oe_write_page(&ve->og, ft);
if(!ret)
- return (SOX_EOF);
+ return 0;
if(ogg_page_eos(&ve->og))
eos = 1;
--- a/src/wav.c
+++ b/src/wav.c
@@ -885,13 +885,13 @@
}
/* Horrible way to find Cool Edit marker points. Taken from Quake source*/
- ft->loops[0].start = -1;
+ ft->loops[0].start = ~0u;
wav->found_cooledit = 0;
if(ft->seekable){
/*Got this from the quake source. I think it 32bit aligns the chunks
* doubt any machine writing Cool Edit Chunks writes them at an odd
* offset */
- len = (len + 1) & ~1;
+ len = (len + 1) & ~1u;
if (sox_seeki(ft, len, SEEK_CUR) == SOX_SUCCESS &&
findChunk(ft, "LIST", &len) != SOX_EOF)
{
@@ -979,7 +979,7 @@
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) & ~1;
+ len = (len + 1) & ~1u;
sox_seeki(ft, len, SEEK_CUR);
}
}
@@ -1434,7 +1434,7 @@
}
if (wFormatTag == WAVE_FORMAT_GSM610)
- dwDataLength = (dwDataLength+1) & ~1; /*round up to even */
+ dwDataLength = (dwDataLength+1) & ~1u; /*round up to even */
if ((wFormatTag == WAVE_FORMAT_PCM && wBitsPerSample > 16) || wChannels > 2)
{
--- a/src/wve.c
+++ b/src/wve.c
@@ -168,6 +168,7 @@
return(SOX_EOF);
}
wvewriteheader(ft);
+ return SOX_SUCCESS;
}
static void wvewriteheader(ft_t ft)
--- a/src/xa.c
+++ b/src/xa.c
@@ -213,11 +213,11 @@
return done;
}
sox_fail_errno(ft,SOX_EOF,"Premature EOF on .xa input file");
- return SOX_EOF;
+ return 0;
} else {
/* error */
sox_fail_errno(ft,SOX_EOF,"read error on input stream");
- return SOX_EOF;
+ return 0;
}
}
xa->bufPos = 0;
@@ -264,7 +264,7 @@
}
}
if (done == 0) {
- return SOX_EOF;
+ return 0;
}
return done;
}
@@ -293,7 +293,7 @@
static sox_size_t sox_xawrite(ft_t ft, const sox_sample_t *buf UNUSED, sox_size_t len UNUSED)
{
sox_fail_errno(ft, SOX_ENOTSUP, ".XA writing not supported");
- return SOX_EOF;
+ return 0;
}
static int sox_xastopwrite(ft_t ft)