shithub: sox

Download patch

ref: 92c826d1e48cf56bc940fcac7c0303d4291b8b11
parent: b26f538e1efb0b1c192587ebeef474691f8cd263
author: idigdoug <idigdoug>
date: Thu Dec 24 02:36:40 EST 2009

Fix warnings from MS Visual Studio build.

--- a/src/biquad.c
+++ b/src/biquad.c
@@ -48,7 +48,7 @@
       !strchr(allowed_width_types, width_type) || (width_type == 's' && p->width > 1))
     return lsx_usage(effp);
   p->width_type = strchr(all_width_types, width_type) - all_width_types;
-  if (p->width_type >= strlen(all_width_types))
+  if ((size_t)p->width_type >= strlen(all_width_types))
     p->width_type = 0;
   if (p->width_type == width_bw_kHz) {
     p->width *= 1000;
--- a/src/dat.c
+++ b/src/dat.c
@@ -135,7 +135,6 @@
       sprintf(s," %15.8g ",dat->timevalue);
       lsx_writes(ft, s);
       for (i=0; i<ft->signal.channels; i++) {
-        SOX_SAMPLE_LOCALS;
         sampval = SOX_SAMPLE_TO_FLOAT_64BIT(*buf++, ft->clips);
         sprintf(s," %15.8g", sampval);
         lsx_writes(ft, s);
--- a/src/dither.c
+++ b/src/dither.c
@@ -179,7 +179,7 @@
   size_t len = *isamp = *osamp = min(*isamp, *osamp);
 
   while (len--) {
-    if (!p->auto_detect || (p->history = ((p->history << 1) + !!(*ibuf & (-1u >> p->prec))))) {
+    if (!p->auto_detect || (p->history = ((p->history << 1) + !!(*ibuf & (((unsigned)-1) >> p->prec))))) {
       int32_t r = RANQD1 >> p->prec;
       double d = ((double)*ibuf++ + r + (p->alt_tpdf? -p->r : (RANQD1 >> p->prec))) / (1 << (32 - p->prec));
       int i = d < 0? d - .5 : d + .5;
--- a/src/dither.h
+++ b/src/dither.h
@@ -11,7 +11,7 @@
   size_t len = *isamp = *osamp = min(*isamp, *osamp);
 
   while (len--) {
-    if (!p->auto_detect || (p->history = ((p->history << 1) + !!(*ibuf & (-1u >> p->prec))))) {
+    if (!p->auto_detect || (p->history = ((p->history << 1) + !!(*ibuf & (((unsigned)-1) >> p->prec))))) {
       int32_t r1 = RANQD1 >> p->prec, r2 = RANQD1 >> p->prec; /* Defer add! */
 #ifdef IIR
       double d1, d, output = 0;
--- a/src/gain.c
+++ b/src/gain.c
@@ -99,7 +99,6 @@
     sox_sample_t * obuf, size_t * isamp, size_t * osamp)
 {
   priv_t * p = (priv_t *)effp->priv;
-  SOX_SAMPLE_LOCALS;
   size_t len;
 
   if (p->do_scan) {
--- a/src/raw.c
+++ b/src/raw.c
@@ -73,6 +73,7 @@
     size_t n, nread; \
     SOX_SAMPLE_LOCALS; \
     ctype *data = lsx_malloc(sizeof(ctype) * len); \
+    LSX_UNUSED_VAR(sox_macro_temp_sample), LSX_UNUSED_VAR(sox_macro_temp_double); \
     nread = lsx_read_ ## type ## _buf(ft, (uctype *)data, len); \
     for (n = 0; n < nread; n++) \
       *buf++ = cast(data[n], ft->clips); \
@@ -100,6 +101,7 @@
     SOX_SAMPLE_LOCALS; \
     size_t n, nwritten; \
     ctype *data = lsx_malloc(sizeof(ctype) * len); \
+    LSX_UNUSED_VAR(sox_macro_temp_sample), LSX_UNUSED_VAR(sox_macro_temp_double); \
     for (n = 0; n < len; n++) \
       data[n] = cast(buf[n], ft->clips); \
     nwritten = lsx_write_ ## type ## _buf(ft, (uctype *)data, len); \
--- a/src/sox.c
+++ b/src/sox.c
@@ -1747,7 +1747,7 @@
         if (!strchr(*names, '/'))
           format_list[formats++] = *names;
   }
-  qsort(format_list, formats, sizeof(*format_list), strcmp_p);
+  qsort((void*)format_list, formats, sizeof(*format_list), strcmp_p);
   for (i = 0; i < formats; i++)
     printf(" %s", format_list[i]);
   putchar('\n');
@@ -1759,12 +1759,12 @@
       for (names = handler->names; *names; ++names)
         format_list[formats++] = *names;
   }
-  qsort(format_list, formats, sizeof(*format_list), strcmp_p);
+  qsort((void*)format_list, formats, sizeof(*format_list), strcmp_p);
   for (i = 0; i < formats; i++)
     printf(" %s", format_list[i]);
   puts("\n");
 
-  free(format_list);
+  free((void*)format_list);
 }
 
 static void display_supported_effects(void)
@@ -1799,8 +1799,8 @@
 "GLOBAL OPTIONS (gopts) (can be specified at any point before the first effect):",
 "--buffer BYTES           Set the size of all processing buffers (default 8192)",
 "--clobber                Don't prompt to overwrite output file (default)",
-"--combine concatenate    Concatenate multiple input files (default for sox, rec)",
-"--combine sequence       Sequence multiple input files (default for play)",
+"--combine concatenate    Concatenate all input files (default for sox, rec)",
+"--combine sequence       Sequence all input files (default for play)",
 "-D, --no-dither          Don't dither automatically",
 "--effects-file FILENAME  File containing effects and options",
 "-G, --guard              Use temporary files to guard against clipping",
@@ -1838,7 +1838,7 @@
 "-v|--volume FACTOR       Input file volume adjustment factor (real number)",
 "--ignore-length          Ignore input file length given in header; read to EOF",
 "-t|--type FILETYPE       File type of audio",
-"-s/-u/-f/-U/-A/-i/-a/-g  Encoding type=signed-integer/unsigned-integer/floating-",
+"-s/-u/-f/-U/-A/-i/-a/-g  Encoding type=signed-integer/unsigned-integer/floating",
 "                         point/mu-law/a-law/ima-adpcm/ms-adpcm/gsm-full-rate",
 "-e|--encoding ENCODING   Set encoding (ENCODING in above list)",
 "-b|--bits BITS           Encoded sample size in bits",
@@ -1864,7 +1864,7 @@
   if (message)
     lsx_fail("%s\n", message);  /* N.B. stderr */
 
-  printf("Usage summary: [gopts] [[fopts] infile]... [fopts]%s [effect [effopts]]...\n\n",
+  printf("Usage summary: [gopts] [[fopts] infile]... [fopts]%s [effect [effopt]]...\n\n",
          sox_mode == sox_play? "" : " outfile");
   for (i = 0; i < array_length(lines); ++i)
     puts(lines[i]);
@@ -2758,7 +2758,7 @@
     combine_method = sox_concatenate;
 
   /* Make sure we got at least the required # of input filenames */
-  if (input_count < (is_serial(combine_method) ? 1 : 2))
+  if (input_count < (size_t)(is_serial(combine_method) ? 1 : 2))
     usage("Not enough input filenames specified");
 
   /* Check for misplaced input/output-specific options */
--- a/src/sox.h
+++ b/src/sox.h
@@ -60,7 +60,7 @@
 typedef uint32_t uint24_t;   /* ditto */
 
 #define SOX_INT_MIN(bits) (1 <<((bits)-1))
-#define SOX_INT_MAX(bits) (-1U>>(33-(bits)))
+#define SOX_INT_MAX(bits) (((unsigned)-1)>>(33-(bits)))
 #define SOX_UINT_MAX(bits) (SOX_INT_MIN(bits)|SOX_INT_MAX(bits))
 
 #define SOX_INT8_MAX  SOX_INT_MAX(8)
@@ -107,7 +107,7 @@
 #define SOX_SAMPLE_TO_UNSIGNED(bits,d,clips) \
   (uint##bits##_t)(SOX_SAMPLE_TO_SIGNED(bits,d,clips)^SOX_INT_MIN(bits))
 #define SOX_SAMPLE_TO_SIGNED(bits,d,clips) \
-  (int##bits##_t)(sox_macro_temp_sample=(d),sox_macro_temp_sample>SOX_SAMPLE_MAX-(1<<(31-bits))?++(clips),SOX_INT_MAX(bits):((uint32_t)(sox_macro_temp_sample+(1<<(31-bits))))>>(32-bits))
+  (int##bits##_t)(LSX_UNUSED_VAR(sox_macro_temp_double),sox_macro_temp_sample=(d),sox_macro_temp_sample>SOX_SAMPLE_MAX-(1<<(31-bits))?++(clips),SOX_INT_MAX(bits):((uint32_t)(sox_macro_temp_sample+(1<<(31-bits))))>>(32-bits))
 #define SOX_SIGNED_TO_SAMPLE(bits,d)((sox_sample_t)(d)<<(32-bits))
 #define SOX_UNSIGNED_TO_SAMPLE(bits,d)(SOX_SIGNED_TO_SAMPLE(bits,d)^SOX_SAMPLE_NEG)
 
@@ -119,8 +119,8 @@
 #define SOX_SIGNED_24BIT_TO_SAMPLE(d,clips) SOX_SIGNED_TO_SAMPLE(24,d)
 #define SOX_UNSIGNED_32BIT_TO_SAMPLE(d,clips) ((sox_sample_t)(d)^SOX_SAMPLE_NEG)
 #define SOX_SIGNED_32BIT_TO_SAMPLE(d,clips) (sox_sample_t)(d)
-#define SOX_FLOAT_32BIT_TO_SAMPLE(d,clips) (sox_sample_t)(sox_macro_temp_double=(d)*(SOX_SAMPLE_MAX+1.),sox_macro_temp_double<SOX_SAMPLE_MIN?++(clips),SOX_SAMPLE_MIN:sox_macro_temp_double>=SOX_SAMPLE_MAX+1.?sox_macro_temp_double>SOX_SAMPLE_MAX+1.?++(clips),SOX_SAMPLE_MAX:SOX_SAMPLE_MAX:sox_macro_temp_double)
-#define SOX_FLOAT_64BIT_TO_SAMPLE(d,clips) (sox_sample_t)(sox_macro_temp_double=(d)*(SOX_SAMPLE_MAX+1.),sox_macro_temp_double<0?sox_macro_temp_double<=SOX_SAMPLE_MIN-.5?++(clips),SOX_SAMPLE_MIN:sox_macro_temp_double-.5:sox_macro_temp_double>=SOX_SAMPLE_MAX+.5?sox_macro_temp_double>SOX_SAMPLE_MAX+1.?++(clips),SOX_SAMPLE_MAX:SOX_SAMPLE_MAX:sox_macro_temp_double+.5)
+#define SOX_FLOAT_32BIT_TO_SAMPLE(d,clips) (sox_sample_t)(LSX_UNUSED_VAR(sox_macro_temp_sample),sox_macro_temp_double=(d)*(SOX_SAMPLE_MAX+1.),sox_macro_temp_double<SOX_SAMPLE_MIN?++(clips),SOX_SAMPLE_MIN:sox_macro_temp_double>=SOX_SAMPLE_MAX+1.?sox_macro_temp_double>SOX_SAMPLE_MAX+1.?++(clips),SOX_SAMPLE_MAX:SOX_SAMPLE_MAX:sox_macro_temp_double)
+#define SOX_FLOAT_64BIT_TO_SAMPLE(d,clips) (sox_sample_t)(LSX_UNUSED_VAR(sox_macro_temp_sample),sox_macro_temp_double=(d)*(SOX_SAMPLE_MAX+1.),sox_macro_temp_double<0?sox_macro_temp_double<=SOX_SAMPLE_MIN-.5?++(clips),SOX_SAMPLE_MIN:sox_macro_temp_double-.5:sox_macro_temp_double>=SOX_SAMPLE_MAX+.5?sox_macro_temp_double>SOX_SAMPLE_MAX+1.?++(clips),SOX_SAMPLE_MAX:SOX_SAMPLE_MAX:sox_macro_temp_double+.5)
 #define SOX_SAMPLE_TO_UNSIGNED_8BIT(d,clips) SOX_SAMPLE_TO_UNSIGNED(8,d,clips)
 #define SOX_SAMPLE_TO_SIGNED_8BIT(d,clips) SOX_SAMPLE_TO_SIGNED(8,d,clips)
 #define SOX_SAMPLE_TO_UNSIGNED_16BIT(d,clips) SOX_SAMPLE_TO_UNSIGNED(16,d,clips)
@@ -129,7 +129,7 @@
 #define SOX_SAMPLE_TO_SIGNED_24BIT(d,clips) SOX_SAMPLE_TO_SIGNED(24,d,clips)
 #define SOX_SAMPLE_TO_UNSIGNED_32BIT(d,clips) (uint32_t)((d)^SOX_SAMPLE_NEG)
 #define SOX_SAMPLE_TO_SIGNED_32BIT(d,clips) (int32_t)(d)
-#define SOX_SAMPLE_TO_FLOAT_32BIT(d,clips) (sox_macro_temp_sample=(d),sox_macro_temp_sample>SOX_SAMPLE_MAX-128?++(clips),1:(((sox_macro_temp_sample+128)&~255)*(1./(SOX_SAMPLE_MAX+1.))))
+#define SOX_SAMPLE_TO_FLOAT_32BIT(d,clips) (LSX_UNUSED_VAR(sox_macro_temp_double),sox_macro_temp_sample=(d),sox_macro_temp_sample>SOX_SAMPLE_MAX-128?++(clips),1:(((sox_macro_temp_sample+128)&~255)*(1./(SOX_SAMPLE_MAX+1.))))
 #define SOX_SAMPLE_TO_FLOAT_64BIT(d,clips) ((d)*(1./(SOX_SAMPLE_MAX+1.)))
 
 
@@ -163,7 +163,7 @@
 
 
 
-#define SOX_SIZE_MAX (size_t)(-sizeof(char))
+#define SOX_SIZE_MAX ((size_t)(-1))
 
 typedef void (*sox_output_message_handler_t)(unsigned level, const char *filename, const char *fmt, va_list ap);
 
@@ -596,6 +596,9 @@
 char const * lsx_find_file_extension(char const * pathname);
 char const * lsx_sigfigs3(double number);
 char const * lsx_sigfigs3p(double percentage);
+void *lsx_realloc(void *ptr, size_t newsize);
+int lsx_strcasecmp(const char * s1, const char * s2);
+int lsx_strncasecmp(char const * s1, char const * s2, size_t n);
 
 /* WARNING END */
 
--- a/src/spectrogram.c
+++ b/src/spectrogram.c
@@ -286,7 +286,6 @@
     p->skip = 0;
   }
   while (!p->truncated) {
-    SOX_SAMPLE_LOCALS;
     if (p->read == p->step_size) {
       memmove(p->buf, p->buf + p->step_size,
           (p->dft_size - p->step_size) * sizeof(*p->buf));
--- a/src/util.h
+++ b/src/util.h
@@ -32,6 +32,12 @@
 #endif
 
 #ifdef _MSC_VER
+#define LSX_UNUSED_VAR(x) ((void)(x))
+#else
+#define LSX_UNUSED_VAR(x) ((void)0)
+#endif
+
+#ifdef _MSC_VER
 
 #define __STDC__ 1
 #define O_BINARY _O_BINARY
--- a/src/waveaudio.c
+++ b/src/waveaudio.c
@@ -284,7 +284,6 @@
 
       for (i = 0; i < ready; ++i)
       {
-        SOX_SAMPLE_LOCALS;
         buf[copied++] = SOX_SIGNED_16BIT_TO_SAMPLE(((int16_t *)header->lpData)[header->dwUser++], dummy);
       }
 
--- a/src/xmalloc.h
+++ b/src/xmalloc.h
@@ -23,7 +23,6 @@
 #include <stddef.h>
 #include <string.h>
 
-void * lsx_realloc(void * ptr, size_t newsize);
 #define lsx_malloc(size) lsx_realloc(NULL, (size))
 #define lsx_calloc(n,s) ((n)*(s)? memset(lsx_malloc((n)*(s)),0,(n)*(s)) : NULL)
 #define lsx_Calloc(v,n)  v = lsx_calloc(n,sizeof(*(v)))