shithub: sox

Download patch

ref: e24ea5f28db4a83cd388b8727f2a8551e1dac0c3
parent: caab355441e86570d9f646afc8530c1e7ccf7f6e
author: Ulrich Klauer <ulrich@chirlu.de>
date: Tue Oct 11 19:53:47 EDT 2011

Fix "may be undefined" compiler warnings

Apply patch by Cristian Morales Vega (patch tracker #3072301) to
correct most cases where the execution order of expressions is
undefined (increment operators applied to variables that appear
more than once in an expression etc.).

--- a/ChangeLog
+++ b/ChangeLog
@@ -56,6 +56,10 @@
 
   o Fix several memory leaks. [3309913] (Jin-Myung Won and Ulrich Klauer)
 
+Internal improvements:
+
+  o Fix compiler warnings. [P. 3072301] (Cristian Morales Vega)
+
 sox-14.3.2	2011-02-27
 ----------
 
--- a/src/bend.c
+++ b/src/bend.c
@@ -109,7 +109,8 @@
   }
   argc -= optstate.ind, argv += optstate.ind;
 
-  p->bends = lsx_calloc(p->nbends = argc, sizeof(*p->bends));
+  p->nbends = argc;
+  p->bends = lsx_calloc(p->nbends, sizeof(*p->bends));
   return parse(effp, argv, 0.);     /* No rate yet; parse with dummy */
 }
 
--- a/src/fir.c
+++ b/src/fir.c
@@ -36,8 +36,11 @@
   --argc, ++argv;
   if (argc == 1)
     p->filename = argv[0], --argc;
-  else for (; argc && sscanf(*argv, "%lf%c", &d, &c) == 1; --argc, ++argv)
-    (p->h = lsx_realloc(p->h, ++p->n * sizeof(*p->h)))[p->n - 1] = d;
+  else for (; argc && sscanf(*argv, "%lf%c", &d, &c) == 1; --argc, ++argv) {
+    p->n++;
+    p->h = lsx_realloc(p->h, p->n * sizeof(*p->h));
+    p->h[p->n - 1] = d;
+  }
   return argc? lsx_usage(effp) : SOX_SUCCESS;
 }
 
@@ -55,8 +58,11 @@
       if (!file)
         return SOX_EOF;
       while (fscanf(file, " #%*[^\n]%c", &c) + (i = fscanf(file, "%lf", &d)) >0)
-        if (i > 0)
-          (p->h = lsx_realloc(p->h, ++p->n * sizeof(*p->h)))[p->n - 1] = d;
+        if (i > 0) {
+          p->n++;
+          p->h = lsx_realloc(p->h, p->n * sizeof(*p->h));
+          p->h[p->n - 1] = d;
+        }
       lsx_report("%i coefficients", p->n);
       if (!feof(file)) {
         lsx_fail("error reading coefficient file");
--- a/src/pad.c
+++ b/src/pad.c
@@ -59,7 +59,8 @@
 {
   priv_t * p = (priv_t *)effp->priv;
   --argc, ++argv;
-  p->pads = lsx_calloc(p->npads = argc, sizeof(*p->pads));
+  p->npads = argc;
+  p->pads = lsx_calloc(p->npads, sizeof(*p->pads));
   return parse(effp, argv, 1e5); /* No rate yet; parse with dummy */
 }
 
--- a/src/remix.c
+++ b/src/remix.c
@@ -121,7 +121,8 @@
     lsx_fail("must specify at least one output channel");
     return SOX_EOF;
   }
-  p->out_specs = lsx_calloc(p->num_out_channels = argc, sizeof(*p->out_specs));
+  p->num_out_channels = argc;
+  p->out_specs = lsx_calloc(p->num_out_channels, sizeof(*p->out_specs));
   return parse(effp, argv, 1); /* No channels yet; parse with dummy */
 }
 
--- a/src/splice.c
+++ b/src/splice.c
@@ -165,7 +165,8 @@
     else if (!strcmp(*argv, "-q")) p->fade_type = Cosine_4  , --argc, ++argv;
     else if (!strcmp(*argv, "-h")) p->fade_type = Cosine_2  , --argc, ++argv;
   }
-  p->splices = lsx_calloc(p->nsplices = argc, sizeof(*p->splices));
+  p->nsplices = argc;
+  p->splices = lsx_calloc(p->nsplices, sizeof(*p->splices));
   return parse(effp, argv, 1e5); /* No rate yet; parse with dummy */
 }