ref: 89611f67c9fc7ba21360b88ce5b670e1c6a61e92
parent: d8c16f9d708847553fba2358c3f1670ab90cef2a
author: cbagwell <cbagwell>
date: Sun Sep 19 18:51:08 EDT 2004
warning cleanups
--- a/src/chorus.c
+++ b/src/chorus.c
@@ -84,7 +84,8 @@
long length[MAX_CHORUS];
int *lookup_tab[MAX_CHORUS];
int depth_samples[MAX_CHORUS], samples[MAX_CHORUS];
- int maxsamples, fade_out;
+ int maxsamples;
+ unsigned int fade_out;
} *chorus_t;
/*
--- a/src/echo.c
+++ b/src/echo.c
@@ -70,7 +70,8 @@
double *delay_buf;
float in_gain, out_gain;
float delay[MAX_ECHOS], decay[MAX_ECHOS];
- st_ssize_t samples[MAX_ECHOS], maxsamples, fade_out;
+ st_ssize_t samples[MAX_ECHOS], maxsamples;
+ st_size_t fade_out;
} *echo_t;
/* Private data for SKEL file */
--- a/src/echos.c
+++ b/src/echos.c
@@ -61,7 +61,8 @@
double *delay_buf;
float in_gain, out_gain;
float delay[MAX_ECHOS], decay[MAX_ECHOS];
- st_ssize_t samples[MAX_ECHOS], pointer[MAX_ECHOS], sumsamples;
+ st_ssize_t samples[MAX_ECHOS], pointer[MAX_ECHOS];
+ st_size_t sumsamples;
} *echos_t;
/* Private data for SKEL file */
@@ -109,7 +110,7 @@
echos_t echos = (echos_t) effp->priv;
int i;
float sum_in_volume;
- long j;
+ unsigned long j;
if ( echos->in_gain < 0.0 )
{
--- a/src/misc.c
+++ b/src/misc.c
@@ -464,23 +464,15 @@
* EPERM "Operation not permitted"
*/
if(whence == SEEK_CUR ){
- /* FIXME: This isn't possible with current
- * prototype anyways. Should st_seek support negative
- * offsets?
- */
- if( offset < 0 ){
- st_fail_errno(ft,ST_EINVAL,"Can't seek backwards in pipe");
- } else {
- while ( offset > 0 && !feof(ft->fp) )
- {
- getc(ft->fp);
- offset--;
- }
- if(offset)
- st_fail_errno(ft,ST_EOF,"offset past eof");
- else
- ft->st_errno = ST_SUCCESS;
+ while ( offset > 0 && !feof(ft->fp) )
+ {
+ getc(ft->fp);
+ offset--;
}
+ if(offset)
+ st_fail_errno(ft,ST_EOF,"offset past eof");
+ else
+ ft->st_errno = ST_SUCCESS;
} else {
st_fail_errno(ft,ST_EPERM,"File not seekable");
}
--- a/src/phaser.c
+++ b/src/phaser.c
@@ -115,7 +115,7 @@
int st_phaser_start(eff_t effp)
{
phaser_t phaser = (phaser_t) effp->priv;
- int i;
+ unsigned int i;
phaser->maxsamples = phaser->delay * effp->ininfo.rate / 1000.0;
--- a/src/pitch.c
+++ b/src/pitch.c
@@ -121,7 +121,7 @@
*/
PITCH_FLOAT rate; /* sweep rate, around 1.0 */
- int step; /* size of half a sweep, rounded to integer... */
+ unsigned int step; /* size of half a sweep, rounded to integer... */
PITCH_FLOAT * fade; /* fading factors table lookup, ~ 1.0 -> ~ 0.0 */
int overlap; /* needed overlap */
@@ -129,10 +129,10 @@
PITCH_FLOAT * tmp; /* temporary buffer */
PITCH_FLOAT * acc; /* accumulation buffer */
- int iacc; /* part of acc already output */
+ unsigned int iacc; /* part of acc already output */
st_size_t size; /* size of buffer for processing chunks. */
- int index; /* index of next empty input item. */
+ unsigned int index; /* index of next empty input item. */
st_sample_t *buf; /* bufferize input */
pitch_state_t state; /* buffer management status. */
@@ -382,7 +382,8 @@
int st_pitch_start(eff_t effp)
{
pitch_t pitch = (pitch_t) effp->priv;
- register int sample_rate = effp->outinfo.rate, i;
+ register int sample_rate = effp->outinfo.rate;
+ unsigned int i;
/* check constraints. sox does already take care of that I guess?
*/
@@ -410,7 +411,7 @@
/* size is half of the actual target window size, because of symetry.
*/
- pitch->step = (int) ((pitch->width*(HALF/THOUSAND))*sample_rate);
+ pitch->step = ((pitch->width*(HALF/THOUSAND))*sample_rate);
/* make size odd? do we care? */
/* if (!(size & 1)) size++; */
@@ -469,7 +470,7 @@
else if (pitch->fadeopt == PITCH_FADE_TRA)
{
/* 0 <= coef <= 0.5 */
- register int plat = (int) (pitch->step*pitch->coef);
+ register unsigned int plat = (int) (pitch->step*pitch->coef);
register PITCH_FLOAT slope = ONE / (pitch->step - 2*plat);
for (i=0; i<plat; i++)
--- a/src/resample.c
+++ b/src/resample.c
@@ -88,7 +88,7 @@
long Xoff; /* Xh plus some room for creep */
long Xread; /* X[Xread] is start-position to enter new samples */
long Xp; /* X[Xp] is position to start filter application */
- long Xsize,Ysize; /* size (Floats) of X[],Y[] */
+ unsigned long Xsize,Ysize; /* size (Floats) of X[],Y[] */
Float *X, *Y; /* I/O buffers */
} *resample_t;
@@ -286,7 +286,7 @@
st_fail("resample: Can not handle this sample rate change. Nx not positive: %d", Nx);
return (ST_EOF);
}
- if (Nx > *isamp)
+ if ((unsigned long)Nx > *isamp)
Nx = *isamp;
/*fprintf(stderr,"Nx %d\n",Nx);*/
--- a/src/reverse.c
+++ b/src/reverse.c
@@ -15,7 +15,7 @@
#include <stdio.h>
#ifdef HAVE_UNISTD_H
-#include <unistd.h> /* For SEEK_* defines if not found in stdio */
+#include <unistd.h> /* For SEEK_* defines if not found in stdio */
#endif
#include "st_i.h"
@@ -22,9 +22,9 @@
/* Private data */
typedef struct reversestuff {
- FILE *fp;
- st_size_t pos;
- int phase;
+ FILE *fp;
+ st_size_t pos;
+ int phase;
} *reverse_t;
#define WRITING 0
@@ -36,12 +36,12 @@
int st_reverse_getopts(eff_t effp, int n, char **argv)
{
- if (n)
- {
- st_fail("Reverse effect takes no options.");
- return (ST_EOF);
- }
- return(ST_SUCCESS);
+ if (n)
+ {
+ st_fail("Reverse effect takes no options.");
+ return (ST_EOF);
+ }
+ return(ST_SUCCESS);
}
/*
@@ -50,15 +50,15 @@
int st_reverse_start(eff_t effp)
{
- reverse_t reverse = (reverse_t) effp->priv;
- reverse->fp = tmpfile();
- if (reverse->fp == NULL)
- {
- st_fail("Reverse effect can't create temporary file\n");
- return (ST_EOF);
- }
- reverse->phase = WRITING;
- return (ST_SUCCESS);
+ reverse_t reverse = (reverse_t) effp->priv;
+ reverse->fp = tmpfile();
+ if (reverse->fp == NULL)
+ {
+ st_fail("Reverse effect can't create temporary file\n");
+ return (ST_EOF);
+ }
+ reverse->phase = WRITING;
+ return (ST_SUCCESS);
}
/*
@@ -68,21 +68,21 @@
int st_reverse_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
- reverse_t reverse = (reverse_t) effp->priv;
+ reverse_t reverse = (reverse_t) effp->priv;
- if (reverse->phase != WRITING)
- {
- st_fail("Internal error: reverse_flow called in wrong phase");
- return(ST_EOF);
- }
- if (fwrite((char *)ibuf, sizeof(st_sample_t), *isamp, reverse->fp)
- != *isamp)
- {
- st_fail("Reverse effect write error on temporary file\n");
- return(ST_EOF);
- }
- *osamp = 0;
- return(ST_SUCCESS);
+ if (reverse->phase != WRITING)
+ {
+ st_fail("Internal error: reverse_flow called in wrong phase");
+ return(ST_EOF);
+ }
+ if (fwrite((char *)ibuf, sizeof(st_sample_t), *isamp, reverse->fp)
+ != *isamp)
+ {
+ st_fail("Reverse effect write error on temporary file\n");
+ return(ST_EOF);
+ }
+ *osamp = 0;
+ return(ST_SUCCESS);
}
/*
@@ -91,43 +91,43 @@
int st_reverse_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
- reverse_t reverse = (reverse_t) effp->priv;
- int len, nbytes;
- register int i, j;
- st_sample_t temp;
+ reverse_t reverse = (reverse_t) effp->priv;
+ st_size_t len, nbytes;
+ register int i, j;
+ st_sample_t temp;
- if (reverse->phase == WRITING) {
- fflush(reverse->fp);
- fseek(reverse->fp, 0L, SEEK_END);
- reverse->pos = ftell(reverse->fp);
- if (reverse->pos % sizeof(st_sample_t) != 0)
- {
- st_fail("Reverse effect finds odd temporary file\n");
- return(ST_EOF);
- }
- reverse->phase = READING;
- }
- len = *osamp;
- nbytes = len * sizeof(st_sample_t);
- if (reverse->pos < nbytes) {
- nbytes = reverse->pos;
- len = nbytes / sizeof(st_sample_t);
- }
- reverse->pos -= nbytes;
- fseek(reverse->fp, reverse->pos, SEEK_SET);
- if (fread((char *)obuf, sizeof(st_sample_t), len, reverse->fp) != len)
- {
- st_fail("Reverse effect read error from temporary file\n");
- return(ST_EOF);
- }
- for (i = 0, j = len-1; i < j; i++, j--) {
- temp = obuf[i];
- obuf[i] = obuf[j];
- obuf[j] = temp;
- }
- *osamp = len;
- return(ST_SUCCESS);
-}
+ if (reverse->phase == WRITING) {
+ fflush(reverse->fp);
+ fseek(reverse->fp, 0L, SEEK_END);
+ reverse->pos = ftell(reverse->fp);
+ if (reverse->pos % sizeof(st_sample_t) != 0)
+ {
+ st_fail("Reverse effect finds odd temporary file\n");
+ return(ST_EOF);
+ }
+ reverse->phase = READING;
+ }
+ len = *osamp;
+ nbytes = len * sizeof(st_sample_t);
+ if (reverse->pos < nbytes) {
+ nbytes = reverse->pos;
+ len = nbytes / sizeof(st_sample_t);
+ }
+ reverse->pos -= nbytes;
+ fseek(reverse->fp, reverse->pos, SEEK_SET);
+ if (fread((char *)obuf, sizeof(st_sample_t), len, reverse->fp) != len)
+ {
+ st_fail("Reverse effect read error from temporary file\n");
+ return(ST_EOF);
+ }
+ for (i = 0, j = len-1; i < j; i++, j--) {
+ temp = obuf[i];
+ obuf[i] = obuf[j];
+ obuf[j] = temp;
+ }
+ *osamp = len;
+ return(ST_SUCCESS);
+}
/*
* Close and unlink the temporary file.
@@ -134,8 +134,8 @@
*/
int st_reverse_stop(eff_t effp)
{
- reverse_t reverse = (reverse_t) effp->priv;
+ reverse_t reverse = (reverse_t) effp->priv;
- fclose(reverse->fp);
- return (ST_SUCCESS);
+ fclose(reverse->fp);
+ return (ST_SUCCESS);
}
--- a/src/sox.c
+++ b/src/sox.c
@@ -563,6 +563,7 @@
int e, f, flowstatus;
#ifndef SOXMIX
int current_input;
+ st_ssize_t ilen;
#else
st_size_t s;
st_ssize_t ilen[MAX_INPUT_FILES];
@@ -699,23 +700,24 @@
do {
#ifndef SOXMIX
efftab[0].olen =
- (*file_desc[current_input]->h->read)(file_desc[current_input],
- efftab[0].obuf,
- (st_ssize_t)ST_BUFSIZ);
+ ilen = (*file_desc[current_input]->h->read)(file_desc[current_input],
+ efftab[0].obuf,
+ (st_ssize_t)ST_BUFSIZ);
+
/* FIXME: libst needs the feof() and ferror() concepts
* to see if ST_EOF means a real failure. Until then we
- * must treat ST_EOF as just hiting the end of the buffer.
+ * must treat ST_EOF as just hiting the end of the file.
*/
- if (efftab[0].olen == ST_EOF)
- {
+ if (ilen == ST_EOF)
efftab[0].olen = 0;
- }
+ else
+ efftab[0].olen = ilen;
/* Some file handlers claim 0 bytes instead of returning
* ST_EOF. In either case, attempt to go to the next
* input file.
*/
- if (efftab[0].olen == 0)
+ if (ilen == ST_EOF || efftab[0].olen == 0)
{
if (current_input < input_count-1)
{
--- a/src/stat.c
+++ b/src/stat.c
@@ -167,7 +167,8 @@
st_size_t *isamp, st_size_t *osamp)
{
stat_t stat = (stat_t) effp->priv;
- int len, done, x, x1;
+ int len, done, x;
+ unsigned int x1;
short count;
float magnitude;
float ffa;
@@ -191,7 +192,7 @@
stat->fft_offset = 0;
FFT(1,stat->fft_bits,stat->re,stat->im);
ffa = (float)effp->ininfo.rate/stat->fft_size;
- for (x1= 0; x1 < stat->fft_size/2; x1++)
+ for (x1 = 0; x1 < stat->fft_size/2; x1++)
{
if (x1 == 0 || x1 == 1)
{
@@ -265,7 +266,7 @@
int st_stat_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
stat_t stat = (stat_t) effp->priv;
- int x;
+ unsigned int x;
float magnitude;
float ffa;