shithub: sox

Download patch

ref: 6bc6a9bbd45232987198dad3c5fd506e0064c0e3
parent: b22cc88f1a3d9aa53fbd659e45f188497731b687
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Thu Aug 17 16:06:12 EDT 2023

fix warnings

--- a/src/aiff.c
+++ b/src/aiff.c
@@ -364,7 +364,7 @@
     else if (bits <= 16) bits = 16;
     else if (bits <= 24) bits = 24;
     else if (bits <= 32) bits = 32;
-    else if (bits == 64 && enc == SOX_ENCODING_FLOAT) /* no-op */;
+    else if (bits == 64 && enc == SOX_ENCODING_FLOAT) { /* no-op */ }
     else {
       lsx_fail_errno(ft,SOX_EFMT,"unsupported sample size in AIFF header: %d", bits);
       return(SOX_EOF);
@@ -655,7 +655,7 @@
         int hsize =
                 8 /*COMM hdr*/ + 18 /*COMM chunk*/ +
                 8 /*SSND hdr*/ + 12 /*SSND chunk*/;
-        unsigned bits = 0;
+        unsigned bits;
         unsigned i;
         uint64_t size;
         size_t padded_comment_size = 0, comment_size = 0;
@@ -850,10 +850,10 @@
 static int aifcwriteheader(sox_format_t * ft, uint64_t nframes)
 {
         unsigned hsize;
-        unsigned bits = 0;
+        unsigned bits;
         uint64_t size;
         char *ctype = NULL, *cname = NULL;
-        unsigned cname_len = 0, comm_len = 0, comm_padding = 0;
+        unsigned cname_len, comm_len, comm_padding;
 
         if (ft->encoding.encoding == SOX_ENCODING_SIGN2 &&
             ft->encoding.bits_per_sample == 8)
@@ -1146,6 +1146,7 @@
             expon -= 16383;
             f  = ldexp(UnsignedToFloat(hiMant), expon-=31);
             f += ldexp(UnsignedToFloat(loMant), expon-=32);
+            USED(expon);
         }
     }
 
--- a/src/avr.c
+++ b/src/avr.c
@@ -143,6 +143,7 @@
   priv_t * avr = (priv_t *)ft->priv;
   int rc;
 
+  USED(avr);
   if (!ft->seekable) {
     lsx_fail_errno(ft,SOX_EOF,"AVR: file is not seekable");
     return(SOX_EOF);
--- a/src/contrast.c
+++ b/src/contrast.c
@@ -24,7 +24,7 @@
   priv_t * p = (priv_t *)effp->priv;
   p->contrast = 75;
   --argc, ++argv;
-  do {NUMERIC_PARAMETER(contrast, 0, 100)} while (0);
+  do {NUMERIC_PARAMETER(contrast, 0, 100); USED(argv);} while (0);
   p->contrast /= 750; /* shift range to 0 to 0.1333, default 0.1 */
   return argc? lsx_usage(effp) : SOX_SUCCESS;
 }
--- a/src/dat.c
+++ b/src/dat.c
@@ -78,10 +78,10 @@
     int  inpPtr = 0;
     int  inpPtrInc = 0;
     double sampval = 0.0;
-    int retc = 0;
+    int retc;
     char sc = 0;
     size_t done = 0;
-    size_t i=0;
+    size_t i;
 
     /* Always read a complete set of channels */
     nsamp -= (nsamp % ft->signal.channels);
@@ -124,9 +124,9 @@
 {
     priv_t * dat = (priv_t *) ft->priv;
     size_t done = 0;
-    double sampval=0.0;
+    double sampval;
     char s[LINEWIDTH];
-    size_t i=0;
+    size_t i;
 
     /* Always write a complete set of channels */
     nsamp -= (nsamp % ft->signal.channels);
--- a/src/dither.c
+++ b/src/dither.c
@@ -350,6 +350,7 @@
     default: lsx_fail("invalid option `-%c'", optstate.opt); return lsx_usage(effp);
   }
   argc -= optstate.ind, argv += optstate.ind;
+  USED(argv);
   return argc? lsx_usage(effp) : SOX_SUCCESS;
 }
 
--- a/src/downsample.c
+++ b/src/downsample.c
@@ -34,6 +34,7 @@
   --argc, ++argv;
   do { /* break-able block */
     NUMERIC_PARAMETER(factor, 1, 16384)
+    USED(argv);
   } while (0);
   return argc ? lsx_usage(effp) : SOX_SUCCESS;
 }
@@ -71,6 +72,7 @@
     p->carry = p->factor - ilen;
     olen--; ilen = 0;
   }
+  USED(obuf);
 
   *isamp -= ilen, *osamp -= olen;
   return SOX_SUCCESS;
--- a/src/effects.c
+++ b/src/effects.c
@@ -29,6 +29,7 @@
 
 static int default_function(sox_effect_t * effp UNUSED)
 {
+  USED(effp);
   return SOX_SUCCESS;
 }
 
@@ -36,6 +37,7 @@
 int lsx_flow_copy(sox_effect_t * effp UNUSED, const sox_sample_t * ibuf,
     sox_sample_t * obuf, size_t * isamp, size_t * osamp)
 {
+  USED(effp);
   *isamp = *osamp = min(*isamp, *osamp);
   memcpy(obuf, ibuf, *isamp * sizeof(*obuf));
   return SOX_SUCCESS;
@@ -44,6 +46,7 @@
 /* Inform no more samples to drain */
 static int default_drain(sox_effect_t * effp UNUSED, sox_sample_t *obuf UNUSED, size_t *osamp)
 {
+  USED(effp); USED(obuf);
   *osamp = 0;
   return SOX_EOF;
 }
@@ -51,6 +54,7 @@
 /* Check that no parameters have been given */
 static int default_getopts(sox_effect_t * effp, int argc, char **argv UNUSED)
 {
+  USED(argv);
   return --argc? lsx_usage(effp) : SOX_SUCCESS;
 }
 
@@ -243,7 +247,7 @@
   sox_effect_t *effp1 = chain->effects[n - 1];
   sox_effect_t *effp = chain->effects[n];
   int effstatus = SOX_SUCCESS;
-  size_t f = 0;
+  size_t f;
   size_t idone = effp1->oend - effp1->obeg;
   size_t obeg = sox_globals.bufsiz - effp->oend;
   sox_bool il_change = (effp->flows == 1) !=
@@ -341,7 +345,7 @@
 {
   sox_effect_t *effp = chain->effects[n];
   int effstatus = SOX_SUCCESS;
-  size_t f = 0;
+  size_t f;
   size_t obeg = sox_globals.bufsiz - effp->oend;
   sox_bool il_change = (effp->flows == 1) !=
       (chain->length == n + 1 || chain->effects[n+1]->flows == 1);
--- a/src/fade.c
+++ b/src/fade.c
@@ -209,7 +209,7 @@
 {
     priv_t * fade = (priv_t *) effp->priv;
     /* len is total samples, chcnt counts channels */
-    int len = 0, t_output = 1, more_output = 1;
+    int len, t_output, more_output = 1;
     sox_sample_t t_ibuf;
     size_t chcnt = 0;
 
@@ -342,7 +342,7 @@
 * todo: to optimize performance calculate gain every now and then and interpolate */
 static double fade_gain(uint64_t index, uint64_t range, int type)
 {
-    double retval = 0.0, findex = 0.0;
+    double retval, findex;
 
     /* TODO: does it really have to be contrained to [0.0, 1.0]? */
     findex = max(0.0, min(1.0, 1.0 * index / range));
--- a/src/fir.c
+++ b/src/fir.c
@@ -61,7 +61,7 @@
         return SOX_EOF;
       while ((i = fscanf(file, " #%*[^\n]%c", &c)) >= 0) {
         if (i >= 1) continue; /* found and skipped a comment */
-        if ((i = fscanf(file, "%lf", &d)) > 0) {
+        if (fscanf(file, "%lf", &d) > 0) {
           /* found a coefficient value */
           p->n++;
           p->h = lsx_realloc(p->h, p->n * sizeof(*p->h));
--- a/src/flanger.c
+++ b/src/flanger.c
@@ -79,6 +79,7 @@
     TEXTUAL_PARAMETER(wave_shape, lsx_get_wave_enum())
     NUMERIC_PARAMETER(channel_phase, 0  , 100)
     TEXTUAL_PARAMETER(interpolation, interp_enum)
+    USED(argv);
   } while (0);
 
   if (argc != 0)
@@ -198,6 +199,7 @@
         double a, b;
         double delayed_2 = f->delay_bufs[c]
           [(f->delay_buf_pos + int_delay++) % f->delay_buf_length];
+        USED(int_delay);
         delayed_2 -= delayed_0;
         delayed_1 -= delayed_0;
         a = delayed_2 *.5 - delayed_1;
--- a/src/formats.c
+++ b/src/formats.c
@@ -370,6 +370,9 @@
 
 static int xfclose(FILE * file, lsx_io_type io_type)
 {
+#ifndef HAVE_POPEN
+  USED(io_type);
+#endif
   return
 #ifdef HAVE_POPEN
     io_type != lsx_io_file? pclose(file) :
@@ -418,6 +421,8 @@
       lsx_warn("couldn't set pipe size to %ld bytes: %s\n",
                max_pipe_size, strerror(errno));
   }
+#else
+  USED(f);
 #endif /* do nothing for platforms without F_{GET,SET}PIPE_SZ */
 }
 
@@ -474,7 +479,7 @@
       defined _ISO_STDIO_ISO_H || defined __sgi
   fp->_ptr = fp->_base;
 #elif defined NO_REWIND_PIPE
-  (void)fp;
+  USED(fp);
 #else
   /* To fix this #error, either simply remove the #error line and live without
    * file-type detection with pipes, or add support for your compiler in the
@@ -481,7 +486,7 @@
    * lines above.  Test with cat monkey.wav | ./sox --info - */
   #error FIX NEEDED HERE
   #define NO_REWIND_PIPE
-  (void)fp;
+  USED(fp);
 #endif
 }
 
@@ -500,6 +505,7 @@
   size_t   input_bufsiz = sox_globals.input_bufsiz?
       sox_globals.input_bufsiz : sox_globals.bufsiz;
 
+  USED(buffer); USED(buffer_size);
   if (filetype) {
     if (!(handler = sox_find_format(filetype, sox_false))) {
       lsx_fail("no handler for given file type `%s'", filetype);
@@ -890,6 +896,7 @@
   sox_format_t * ft = lsx_calloc(sizeof(*ft), 1);
   sox_format_handler_t const * handler;
 
+  USED(buffer); USED(buffer_size); USED(buffer_ptr); USED(buffer_size_ptr);
   if (!path || !signal) {
     lsx_fail("must specify file name and signal parameters to write file");
     goto error;
--- a/src/formats_i.c
+++ b/src/formats_i.c
@@ -207,7 +207,8 @@
         /* If a stream peel off chars else EPERM */
         if (whence == SEEK_CUR) {
             while (offset > 0 && !feof((FILE*)ft->fp)) {
-                getc((FILE*)ft->fp);
+                char c = getc((FILE*)ft->fp);
+                USED(c);
                 offset--;
                 ++ft->tell_off;
             }
--- a/src/gain.c
+++ b/src/gain.c
@@ -59,7 +59,7 @@
     lsx_fail("only one of -l, -h may be given");
     return SOX_EOF;
   }
-  do {NUMERIC_PARAMETER(fixed_gain, -HUGE_VAL, HUGE_VAL)} while (0);
+  do {NUMERIC_PARAMETER(fixed_gain, -HUGE_VAL, HUGE_VAL); USED(argv);} while (0);
   p->fixed_gain = dB_to_linear(p->fixed_gain);
   return argc? lsx_usage(effp) : SOX_SUCCESS;
 }
@@ -261,6 +261,7 @@
   argv2[1] = "-n";
   if (argc)
     argv2[argc2++] = *argv, --argc, ++argv;
+  USED(argv);
   return argc? lsx_usage(effp) :
     lsx_gain_effect_fn()->getopts(effp, argc2, argv2);
 }
--- a/src/id3.c
+++ b/src/id3.c
@@ -222,6 +222,6 @@
 #else
 
 /* Stub for format modules */
-void lsx_id3_read_tag(sox_format_t *ft, sox_bool search) { }
+void lsx_id3_read_tag(sox_format_t *ft, sox_bool search) { USED(ft); USED(search); }
 
 #endif
--- a/src/loudness.c
+++ b/src/loudness.c
@@ -37,7 +37,8 @@
   do {                    /* break-able block */
     NUMERIC_PARAMETER(delta,-50 , 15) /* FIXME expand range */
     NUMERIC_PARAMETER(start, 50 , 75) /* FIXME expand range */
-    NUMERIC_PARAMETER(n    ,127 ,2047)
+    NUMERIC_PARAMETER(n    ,127 ,2047);
+    USED(argv);
   } while (0);
   p->n = 2 * p->n + 1;
   return argc? lsx_usage(effp) : SOX_SUCCESS;
--- a/src/noiseprof.c
+++ b/src/noiseprof.c
@@ -152,6 +152,7 @@
     int tracks = effp->in_signal.channels;
     int i;
 
+    USED(obuf);
     *osamp = 0;
 
     if (data->bufdata == 0) {
--- a/src/noisered.c
+++ b/src/noisered.c
@@ -71,6 +71,7 @@
   p->threshold = 0.5;
   do {     /* break-able block */
     NUMERIC_PARAMETER(threshold, 0, 1);
+    USED(argv);
   } while (0);
 
   return argc? lsx_usage(effp) : SOX_SUCCESS;
--- a/src/nulfile.c
+++ b/src/nulfile.c
@@ -34,7 +34,7 @@
 static size_t read_samples(sox_format_t * ft, sox_sample_t * buf, size_t len)
 {
   /* Reading from null generates silence i.e. (sox_sample_t)0. */
-  (void)ft;
+  USED(ft);
   memset(buf, 0, sizeof(sox_sample_t) * len);
   return len; /* Return number of samples "read". */
 }
@@ -43,7 +43,7 @@
     sox_format_t * ft, sox_sample_t const * buf, size_t len)
 {
   /* Writing to null just discards the samples */
-  (void)ft, (void)buf;
+  USED(ft); USED(buf);
   return len; /* Return number of samples "written". */
 }
 
--- a/src/overdrive.c
+++ b/src/overdrive.c
@@ -29,6 +29,7 @@
   do {
     NUMERIC_PARAMETER(gain, 0, 100)
     NUMERIC_PARAMETER(colour, 0, 100)
+    USED(argv);
   } while (0);
   p->gain = dB_to_linear(p->gain);
   p->colour /= 200;
--- a/src/phaser.c
+++ b/src/phaser.c
@@ -81,6 +81,7 @@
   if (argc && sscanf(*argv, "-%1[st]%c", chars, chars + 1) == 1) {
     p->mod_type = *chars == 's'? SOX_WAVE_SINE : SOX_WAVE_TRIANGLE;
     --argc, ++argv;
+    USED(argv);
   }
 
   if (p->in_gain > (1 - p->decay * p->decay))
--- a/src/prc.c
+++ b/src/prc.c
@@ -81,23 +81,23 @@
    check with apparently invalid files.
 
    N.B. All offsets are from start of file. */
-static const char prc_header[41] = {
+static const uint8_t prc_header[41] = {
   /* Header section */
-  '\x37','\x00','\x00','\x10', /* 0x00: File type (UID 1) */
-  '\x6d','\x00','\x00','\x10', /* 0x04: File kind (UID 2) */
-  '\x7e','\x00','\x00','\x10', /* 0x08: Application ID (UID 3) */
-  '\xcf','\xac','\x08','\x55', /* 0x0c: Checksum of UIDs 1-3 */
-  '\x14','\x00','\x00','\x00', /* 0x10: File offset of Section Table Section */
+  0x37,0x00,0x00,0x10, /* 0x00: File type (UID 1) */
+  0x6d,0x00,0x00,0x10, /* 0x04: File kind (UID 2) */
+  0x7e,0x00,0x00,0x10, /* 0x08: Application ID (UID 3) */
+  0xcf,0xac,0x08,0x55, /* 0x0c: Checksum of UIDs 1-3 */
+  0x14,0x00,0x00,0x00, /* 0x10: File offset of Section Table Section */
   /* Section Table Section: a BListL, i.e. a list of longs preceded by
      length byte.
      The longs are in (ID, offset) pairs, each pair identifying a
      section. */
-  '\x04',                      /* 0x14: List has 4 bytes, i.e. 2 pairs */
-  '\x52','\x00','\x00','\x10', /* 0x15: ID: Record Section */
-  '\x34','\x00','\x00','\x00', /* 0x19: Offset to Record Section */
-  '\x89','\x00','\x00','\x10', /* 0x1d: ID: Application ID Section */
-  '\x25','\x00','\x00','\x00', /* 0x21: Offset to Application ID Section */
-  '\x7e','\x00','\x00','\x10', /* 0x25: Application ID Section:
+  0x04,                      /* 0x14: List has 4 bytes, i.e. 2 pairs */
+  0x52,0x00,0x00,0x10, /* 0x15: ID: Record Section */
+  0x34,0x00,0x00,0x00, /* 0x19: Offset to Record Section */
+  0x89,0x00,0x00,0x10, /* 0x1d: ID: Application ID Section */
+  0x25,0x00,0x00,0x00, /* 0x21: Offset to Application ID Section */
+  0x7e,0x00,0x00,0x10, /* 0x25: Application ID Section:
                                   Record.app identifier */
   /* Next comes the string, which can be either case. */
 };
--- a/src/rate.c
+++ b/src/rate.c
@@ -222,21 +222,28 @@
   if (!f->num_taps) {
     int num_taps = 0, dft_length, i;
     int k = phase == 50 && lsx_is_power_of_2(L) && Fn == L? L << 1 : 4;
+fprint(2, "#0\n");
     double * h = lsx_design_lpf(Fp, Fs, Fn, att, &num_taps, -k, -1.);
-
+fprint(2, "#1\n");
     if (phase != 50)
       lsx_fir_to_phase(&h, &num_taps, &f->post_peak, phase);
     else f->post_peak = num_taps / 2;
+fprint(2, "#A\n");
 
     dft_length = lsx_set_dft_length(num_taps);
+fprint(2, "#B\n");
     f->coefs = calloc(dft_length, sizeof(*f->coefs));
+fprint(2, "#C\n");
     for (i = 0; i < num_taps; ++i)
       f->coefs[(i + dft_length - num_taps + 1) & (dft_length - 1)]
         = h[i] / dft_length * 2 * L;
+fprint(2, "#D\n");
     free(h);
     f->num_taps = num_taps;
     f->dft_length = dft_length;
+fprint(2, "#E\n");
     lsx_safe_rdft(dft_length, 1, f->coefs);
+fprint(2, "#F\n");
     lsx_debug("fir_len=%i dft_length=%i Fp=%g Fs=%g Fn=%g att=%g %i/%i",
         num_taps, dft_length, Fp, Fs, Fn, att, L, M);
   }
@@ -404,7 +411,9 @@
       phases = !rational? (1 << phase_bits) : arbL;
       if (!f->interp[0].scalar) {
         int phases0 = max(phases, 19), n0 = 0;
+fprint(2, "#2\n");
         lsx_design_lpf(Fp, Fs, -Fn, attArb, &n0, phases0, f->beta);
+fprint(2, "#3\n");
         num_coefs = n0 / phases0 + 1, num_coefs += num_coefs & !preM;
       }
       if ((num_coefs & 1) && rational && (arbL & 1))
@@ -417,8 +426,10 @@
 
     if (!arb_stage.shared->poly_fir_coefs) {
       int num_taps = num_coefs * phases - 1;
+fprint(2, "#4\n");
       raw_coef_t * coefs = lsx_design_lpf(
           Fp, Fs, Fn, attArb, &num_taps, phases, f->beta);
+fprint(2, "#5\n");
       arb_stage.shared->poly_fir_coefs = prepare_coefs(
           coefs, num_coefs, phases, order, 1);
       lsx_debug("fir_len=%i phases=%i coef_interp=%i size=%s",
@@ -620,6 +631,7 @@
     if ((p->out_rate = lsx_parse_frequency(*argv, &dummy_p)) <= 0 || *dummy_p)
       return lsx_usage(effp);
     argc--; argv++;
+    USED(argv);
     effp->out_signal.rate = p->out_rate;
   }
   return argc? lsx_usage(effp) : SOX_SUCCESS;
--- a/src/rate_half_fir.h
+++ b/src/rate_half_fir.h
@@ -29,6 +29,7 @@
     int j = 0;
     sample_t sum = input[0] * .5;
     CONVOLVE
+    USED(j);
     output[i] = sum;
   }
   fifo_read(&p->fifo, 2 * num_out, NULL);
--- a/src/rate_poly_fir.h
+++ b/src/rate_poly_fir.h
@@ -70,6 +70,7 @@
       sample_t sum = 0;
       int j = 0;
       CONVOLVE
+      USED(j);
       output[i] = sum;
     }
     fifo_read(&p->fifo, p->at.parts.integer, NULL);
--- a/src/rate_poly_fir0.h
+++ b/src/rate_poly_fir0.h
@@ -33,6 +33,7 @@
     sample_t sum = 0;
     int j = 0;
     CONVOLVE
+    USED(j);
     output[i] = sum;
   }
   assert(max_num_out - i >= 0);
--- a/src/repeat.c
+++ b/src/repeat.c
@@ -33,7 +33,7 @@
     p->num_repeats = UINT_MAX;
     return SOX_SUCCESS;
   }
-  do {NUMERIC_PARAMETER(num_repeats, 0, UINT_MAX - 1)} while (0);
+  do {NUMERIC_PARAMETER(num_repeats, 0, UINT_MAX - 1); USED(argv);} while (0);
   return argc? lsx_usage(effp) : SOX_SUCCESS;
 }
 
--- a/src/reverb.c
+++ b/src/reverb.c
@@ -193,6 +193,7 @@
     NUMERIC_PARAMETER(stereo_depth, 0, 100)
     NUMERIC_PARAMETER(pre_delay_ms, 0, 500)
     NUMERIC_PARAMETER(wet_gain_dB, -10, 10)
+    USED(argv);
   } while (0);
 
   return argc ? lsx_usage(effp) : SOX_SUCCESS;
--- a/src/silence.c
+++ b/src/silence.c
@@ -176,6 +176,7 @@
 
         argv++; argv++;
         argc--; argc--;
+        USED(argv); USED(argc);
     }
 
     /* Error checking */
--- a/src/skeleff.c
+++ b/src/skeleff.c
@@ -63,7 +63,6 @@
 static int flow(sox_effect_t * effp, const sox_sample_t *ibuf, sox_sample_t *obuf,
                            size_t *isamp, size_t *osamp)
 {
-  priv_t * UNUSED p = (priv_t *)effp->priv;
   size_t len, done;
 
   switch (effp->out_signal.channels) {
@@ -95,6 +94,7 @@
  */
 static int drain(sox_effect_t UNUSED * effp, sox_sample_t UNUSED *obuf, size_t *osamp)
 {
+  USED(effp); USED(obuf);
   *osamp = 0;
   /* Return SOX_EOF when drain
    * will not output any more samples.
@@ -108,6 +108,7 @@
  */
 static int stop(sox_effect_t UNUSED * effp)
 {
+  USED(effp);
   return SOX_SUCCESS;
 }
 
@@ -117,6 +118,7 @@
  */
 static int lsx_kill(sox_effect_t UNUSED * effp)
 {
+  USED(effp);
   return SOX_SUCCESS;
 }
 
--- a/src/skelform.c
+++ b/src/skelform.c
@@ -77,7 +77,6 @@
  */
 static size_t read_samples(sox_format_t * ft, sox_sample_t *buf, size_t len)
 {
-  priv_t * UNUSED sk = (priv_t *)ft->priv;
   size_t done;
   unsigned char sample;
 
@@ -110,13 +109,12 @@
  */
 static int stopread(sox_format_t UNUSED * ft)
 {
+  USED(ft);
   return SOX_SUCCESS;
 }
 
 static int startwrite(sox_format_t * ft)
 {
-  priv_t * UNUSED sk = (priv_t *)ft->priv;
-
   /* If you have to seek around the output file. */
   /* If header contains a length value then seeking will be
    * required.  Instead of failing, it's sometimes nice to
@@ -151,10 +149,8 @@
  */
 static size_t write_samples(sox_format_t * ft, const sox_sample_t *buf, size_t len)
 {
-  priv_t * sk = (priv_t *)ft->priv;
   size_t done = 0;
 
-  (void)sk;
   switch (ft->encoding.bits_per_sample) {
   case 8:
     switch (ft->encoding.encoding) {
@@ -177,6 +173,7 @@
 
 static int stopwrite(sox_format_t UNUSED * ft)
 {
+  USED(ft);
   /* All samples are already written out. */
   /* If file header needs fixing up, for example it needs the number
      of samples in a field, seek back and write them here. */
@@ -185,6 +182,7 @@
 
 static int soxseek(sox_format_t UNUSED * ft, uint64_t UNUSED offset)
 {
+  USED(ft); USED(offset);
   /* Seek relative to current position. */
   return SOX_SUCCESS;
 }
--- a/src/sox-fmt.c
+++ b/src/sox-fmt.c
@@ -28,7 +28,7 @@
   uint64_t num_samples;
   double   rate;
 
-  if (lsx_readdw(ft, (uint32_t *)&magic_))
+  if (lsx_readdw(ft, (uint32_t *)magic_))
     return SOX_EOF;
 
   if (memcmp(magic[MACHINE_IS_BIGENDIAN], magic_, sizeof(magic_))) {
--- a/src/sox.c
+++ b/src/sox.c
@@ -1251,7 +1251,7 @@
     return;
   if (all_done || since(&then, .1, sox_false)) {
     double read_time = (double)read_wide_samples / combiner_signal.rate;
-    double left_time = 0, in_time = 0, percentage = 0;
+    double left_time = 0, in_time, percentage = 0;
     char buf[128];
 
     if (input_wide_samples) {
@@ -1332,6 +1332,8 @@
        */
       user_restart_eff = sox_true;
     }
+#else
+    USED(ch);
 #endif
   }
 
--- a/src/sox.h
+++ b/src/sox.h
@@ -724,8 +724,10 @@
 Declares the temporary local variables that are required when using SOX
 conversion macros.
 */
-#define SOX_SAMPLE_LOCALS sox_sample_t sox_macro_temp_sample LSX_UNUSED; \
-  double sox_macro_temp_double LSX_UNUSED
+#define SOX_SAMPLE_LOCALS sox_sample_t sox_macro_temp_sample LSX_UNUSED = 0.0; \
+  double sox_macro_temp_double LSX_UNUSED = 0.0; \
+  USED(sox_macro_temp_sample); \
+  USED(sox_macro_temp_double)
 
 /**
 Client API:
--- a/src/sphere.c
+++ b/src/sphere.c
@@ -27,7 +27,7 @@
   unsigned long header_size_ul = 0, num_samples_ul = 0;
   sox_encoding_t encoding = SOX_ENCODING_SIGN2;
   size_t     header_size, bytes_read;
-  size_t     num_samples = 0;
+  size_t     num_samples;
   unsigned       bytes_per_sample = 0;
   unsigned       channels = 1;
   unsigned       rate = 16000;
--- a/src/stat.c
+++ b/src/stat.c
@@ -205,6 +205,7 @@
 {
   priv_t * stat = (priv_t *) effp->priv;
 
+  USED(obuf);
   /* When we run out of samples, then we need to pad buffer with
    * zeros and then run FFT one last time to process any unprocessed
    * samples.
@@ -299,9 +300,9 @@
         fprintf(stderr,"\nTry: -t raw -e signed-integer -b 8 \n");
       else
         fprintf(stderr,"\nTry: -t raw -e unsigned-integer -b 8 \n");
-    } else if (x <= 1.0 / 3.0)
-      ;                         /* correctly decoded */
-    else if (x >= 0.5 && x <= 2.0) { /* use ULAW */
+    } else if (x <= 1.0 / 3.0) {
+      /* correctly decoded */
+    } else if (x >= 0.5 && x <= 2.0) { /* use ULAW */
       if (effp->in_encoding->encoding == SOX_ENCODING_ULAW)
         fprintf(stderr,"\nTry: -t raw -e unsigned-integer -b 8 \n");
       else
--- a/src/stats.c
+++ b/src/stats.c
@@ -132,6 +132,7 @@
     *x = result;
   min = -fmax(fabs(min), fabs(max));
   mask = SOX_FLOAT_64BIT_TO_SAMPLE(min, dummy) << 1;
+  USED(dummy);
   for (; result && (mask & SOX_SAMPLE_MIN); --result, mask <<= 1);
   return result;
 }
--- a/src/tempo.c
+++ b/src/tempo.c
@@ -63,7 +63,7 @@
   size_t j, best_pos, prev_best_pos = (t->search + 1) >> 1, step = 64;
   size_t i = best_pos = t->quick_search? prev_best_pos : 0;
   float diff, least_diff = difference(new_win + t->channels * i, f, t->channels * t->overlap);
-  int k = 0;
+  int k;
 
   if (t->quick_search) do { /* hierarchical search */
     for (k = -1; k <= 1; k += 2) for (j = 1; j < 4 || step == 64; ++j) {
@@ -233,6 +233,7 @@
     NUMERIC_PARAMETER(segment_ms  , 10 , 120)
     NUMERIC_PARAMETER(search_ms   , 0  , 30 )
     NUMERIC_PARAMETER(overlap_ms  , 0  , 30 )
+    USED(argv);
   } while (0);
 
   if (p->segment_ms == HUGE_VAL)
--- a/src/trim.c
+++ b/src/trim.c
@@ -158,6 +158,7 @@
   priv_t *p = (priv_t*) effp->priv;
   *osamp = 0; /* only checking for errors */
 
+  USED(obuf);
   if (p->current_pos + 1 == p->num_pos &&
       p->pos[p->current_pos].sample == p->samples_read &&
       p->copying) /* would stop here anyway */
--- a/src/tx16w.c
+++ b/src/tx16w.c
@@ -180,7 +180,7 @@
 static size_t read_samples(sox_format_t * ft, sox_sample_t *buf, size_t len)
 {
     priv_t * sk = (priv_t *) ft->priv;
-    size_t done = 0;
+    size_t done;
     unsigned char uc1,uc2,uc3;
     unsigned short s1,s2;
 
--- a/src/upsample.c
+++ b/src/upsample.c
@@ -27,7 +27,7 @@
   priv_t * p = (priv_t *)effp->priv;
   p->factor = 2;
   --argc, ++argv;
-  do {NUMERIC_PARAMETER(factor, 1, 256)} while (0);
+  do {NUMERIC_PARAMETER(factor, 1, 256); USED(argv);} while (0);
   return argc? lsx_usage(effp) : SOX_SUCCESS;
 }
 
--- a/src/util.c
+++ b/src/util.c
@@ -156,6 +156,7 @@
   int failed = 0;
   lsx_dlhandle dl = NULL;
 
+  USED(library_names);
   /* Track enough information to give a good error message about one failure.
    * Let failed symbol load override failed library open, and let failed
    * library open override missing static symbols.
@@ -300,5 +301,7 @@
     lt_dlclose(dl);
     lt_dlexit();
   }
+#else
+  USED(dl);
 #endif /* HAVE_LIBLTDL */
 }
--- a/src/wav.c
+++ b/src/wav.c
@@ -529,6 +529,7 @@
     priv_t *wav = ft->priv;
     int bps = (wav->bitsPerSample + 7) / 8;
 
+    USED(len);
     if (bps == 1) {
         ft->encoding.encoding = SOX_ENCODING_UNSIGNED;
     } else if (bps <= 4) {
@@ -603,7 +604,7 @@
     { WAVE_FORMAT_OLIADPCM,             "Olivetti ADPCM" },
     { WAVE_FORMAT_OLISBC,               "Olivetti CELP" },
     { WAVE_FORMAT_OLIOPR,               "Olivetti OPR" },
-    { NULL }
+    { -1, NULL }
 };
 
 static const struct wave_format *wav_find_format(unsigned tag)
@@ -752,7 +753,7 @@
     int i;
 
     for (i = 0; i < 4; i++)
-        if (p[i] < 0x20 || p[i] > 0x7f)
+        if ((uint8_t)p[i] < 0x20 || (uint8_t)p[i] > 0x7f)
             return sox_false;
 
     return sox_true;
@@ -912,6 +913,7 @@
 
         if (qwRiffLength == UINT32_MAX)
             qwRiffLength = ds64_riff_size;
+        USED(qwRiffLength);
     }
 
     if (!have_fmt) {
@@ -1228,9 +1230,9 @@
     uint16_t wFormatTag = 0;      /* data format */
     uint16_t wChannels;           /* number of channels */
     uint32_t dwSamplesPerSecond;  /* samples per second per channel*/
-    uint32_t dwAvgBytesPerSec=0;  /* estimate of bytes per second needed */
+    uint32_t dwAvgBytesPerSec;    /* estimate of bytes per second needed */
     uint32_t wBlockAlign=0;       /* byte alignment of a basic sample block */
-    uint16_t wBitsPerSample=0;    /* bits per sample */
+    uint16_t wBitsPerSample;      /* bits per sample */
     /* fmt chunk extension (not PCM) */
     uint16_t wExtSize=0;          /* extra bytes in the format extension */
     uint16_t wSamplesPerBlock;    /* samples per channel per block */
@@ -1238,7 +1240,7 @@
 
     /* fact chunk (not PCM) */
     uint32_t dwFactSize=4;        /* length of the fact chunk */
-    uint64_t dwSamplesWritten=0;  /* windows doesnt seem to use this*/
+    uint64_t dwSamplesWritten;    /* windows doesnt seem to use this*/
 
     /* data chunk */
     uint64_t dwDataLength;        /* length of sound data in bytes */
@@ -1246,7 +1248,7 @@
 
     /* internal variables, intermediate values etc */
     int bytespersample; /* (uncompressed) bytes per sample (per channel) */
-    uint64_t blocksWritten = 0;
+    uint64_t blocksWritten;
     sox_bool isExtensible = sox_false;    /* WAVE_FORMAT_EXTENSIBLE? */
 
     if (ft->signal.channels > UINT16_MAX) {