shithub: sox

Download patch

ref: fdfceb50375dd40150d5a4e91a55a8b027313500
parent: 474a967478522a31d6ad690752ae4c9ecc5bce0d
author: Doug Cook <idigdoug@users.sourceforge.net>
date: Mon Mar 21 20:53:09 EDT 2011

Clean up some warnings

Enable /W4 warning level in VC2010 build. Some W4 warnings were then disabled.
Enable some additional VC2010 warnings that are disabled even with /W4.
Fix the new warnings.

--- a/msvc10/LibSoX.vcxproj
+++ b/msvc10/LibSoX.vcxproj
@@ -64,11 +64,11 @@
       <RuntimeTypeInfo>false</RuntimeTypeInfo>
       <PrecompiledHeader>
       </PrecompiledHeader>
-      <WarningLevel>Level3</WarningLevel>
+      <WarningLevel>Level4</WarningLevel>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
       <CallingConvention>Cdecl</CallingConvention>
-      <DisableSpecificWarnings>4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+      <DisableSpecificWarnings>4100;4125;4127;4131;4295;4310;4244;4706;%(DisableSpecificWarnings)</DisableSpecificWarnings>
     </ClCompile>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -86,11 +86,11 @@
       <RuntimeTypeInfo>false</RuntimeTypeInfo>
       <PrecompiledHeader>
       </PrecompiledHeader>
-      <WarningLevel>Level3</WarningLevel>
+      <WarningLevel>Level4</WarningLevel>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
       <CallingConvention>Cdecl</CallingConvention>
-      <DisableSpecificWarnings>4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+      <DisableSpecificWarnings>4100;4125;4127;4131;4295;4310;4244;4706;%(DisableSpecificWarnings)</DisableSpecificWarnings>
     </ClCompile>
   </ItemDefinitionGroup>
   <ItemGroup>
--- a/msvc10/SoX/soxconfig.h
+++ b/msvc10/SoX/soxconfig.h
@@ -20,6 +20,24 @@
 
 #define PACKAGE_EXTRA "msvc"
 
+/* Enable some extra warnings.
+   Track the number of times each warning has been helpful. */
+#pragma warning(3: 4287) /* 0 - constant sign mismatch */
+#pragma warning(3: 4296) /* 1 - expression is always false */
+#pragma warning(3: 4365) /* 0 - conversion sign mismatch */
+#pragma warning(3: 4431) /* 0 - default int assumed */
+#pragma warning(3: 4545) /* 0 - comma expression */
+#pragma warning(3: 4546) /* 0 - comma expression */
+#pragma warning(3: 4547) /* 0 - comma expression */
+#pragma warning(3: 4548) /* 0 - comma expression */
+#pragma warning(3: 4549) /* 0 - comma expression */
+#pragma warning(3: 4555) /* 0 - expression has no effect */
+#pragma warning(3: 4628) /* 0 - digraph */
+#pragma warning(3: 4826) /* 0 - conversion sign extension */
+#pragma warning(3: 4837) /* 0 - trigraph */
+#pragma warning(3: 4905) /* 0 - string assignment mismatch */
+#pragma warning(3: 4906) /* 0 - string assignment mismatch */
+
 /* Special behavior defined by win32-ltdl: "./" is replaced with the name of the
    directory containing sox.exe. */
 #define PKGLIBDIR "./soxlib"
--- a/src/formats.c
+++ b/src/formats.c
@@ -617,7 +617,7 @@
 
 static void set_output_format(sox_format_t * ft)
 {
-  sox_encoding_t e;
+  sox_encoding_t e = SOX_ENCODING_UNKNOWN;
   unsigned i, s;
   unsigned const * encodings = ft->handler.write_formats;
 #define enc_arg(T) (T)encodings[i++]
--- a/src/lpc10.c
+++ b/src/lpc10.c
@@ -103,7 +103,7 @@
 static int read_bits(sox_format_t * ft, INT32 *bits, int len)
 {
   int i;
-  uint8_t c;
+  uint8_t c = 0;
 
   /* Unpack the array bits into coded_frame. */
   for (i = 0; i < len; i++) {
--- a/src/mp3.c
+++ b/src/mp3.c
@@ -575,7 +575,7 @@
     depadded = sox_true;
     p->mad_stream_buffer(&p->Stream, p->mp3_buffer + padding, leftover + read - padding);
 
-    while (to_skip_samples >= 0) {  /* Decode frame headers */
+    while (sox_true) {  /* Decode frame headers */
       static unsigned short samples;
       p->Stream.error = MAD_ERROR_NONE;
       
@@ -625,7 +625,7 @@
         p->FrameCount = offset / samples;
         to_skip_samples = offset % samples;
 
-        if (SOX_SUCCESS != lsx_seeki(ft, (p->FrameCount * consumed / 64) + tagsize, SEEK_SET))
+        if (SOX_SUCCESS != lsx_seeki(ft, (off_t)(p->FrameCount * consumed / 64 + tagsize), SEEK_SET))
           return SOX_EOF;
 
         /* Reset Stream for refilling buffer */
--- a/src/waveaudio.c
+++ b/src/waveaudio.c
@@ -331,7 +331,7 @@
 {
   size_t copied = 0;
   priv_t *priv = (priv_t*)ft->priv;
-  if (priv == NULL) return SOX_EOF;
+  if (priv == NULL) return (size_t)SOX_EOF;
 
   while (!priv->error && copied < len)
   {
@@ -399,7 +399,7 @@
   unsigned clips = 0;
   size_t copied = 0;
   priv_t *priv = (priv_t*)ft->priv;
-  if (priv == NULL) return SOX_EOF;
+  if (priv == NULL) return (size_t)SOX_EOF;
 
   while (!priv->error && copied < len)
   {