Fix compiler warnings from new compiler flags.
authorErik de Castro Lopo <erikd@mega-nerd.com>
Tue, 5 Mar 2013 11:19:27 +0000 (22:19 +1100)
committerErik de Castro Lopo <erikd@mega-nerd.com>
Tue, 5 Mar 2013 20:42:08 +0000 (07:42 +1100)
include/share/Makefile.am
include/share/macros.h [new file with mode: 0644]
src/libFLAC/metadata_iterators.c
src/metaflac/operations_shorthand_vorbiscomment.c
src/test_libFLAC++/metadata_manip.cpp
src/test_libFLAC/metadata_manip.c
src/test_seeking/main.c

index a881e77..fd8b947 100644 (file)
@@ -8,6 +8,7 @@ EXTRA_DIST = \
        endswap.h \
        getopt.h \
        grabbag.h \
+       macros.h \
        replaygain_analysis.h \
        replaygain_synthesis.h \
        utf8.h
diff --git a/include/share/macros.h b/include/share/macros.h
new file mode 100644 (file)
index 0000000..5be07a1
--- /dev/null
@@ -0,0 +1,41 @@
+/* libFLAC - Free Lossless Audio Codec library
+ * Copyright (C) 2013  Xiph.org Foundation
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of the Xiph.org Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <errno.h>
+
+/* FLAC_CHECK_RETURN : Check the return value of of the provided function and
+ * print and error message if it fails (ie returns a value < 0).
+ */
+
+#define FLAC_CHECK_RETURN(x) \
+                       {       if ((x) < 0) \
+                                       printf ("%s : %s\n", #x, strerror (errno)) ; \
+                       }
index b321e45..a679165 100644 (file)
@@ -46,6 +46,7 @@
 #include "FLAC/stream_decoder.h"
 #include "share/alloc.h"
 #include "share/compat.h"
+#include "share/macros.h"
 #include "private/macros.h"
 #include "private/memory.h"
 
@@ -3295,8 +3296,8 @@ void set_file_stats_(const char *filename, struct stat *stats)
        (void)chmod(filename, stats->st_mode);
        (void)utime(filename, &srctime);
 #if !defined _MSC_VER && !defined __BORLANDC__ && !defined __MINGW32__
-       (void)chown(filename, stats->st_uid, -1);
-       (void)chown(filename, -1, stats->st_gid);
+       FLAC_CHECK_RETURN(chown(filename, stats->st_uid, -1));
+       FLAC_CHECK_RETURN(chown(filename, -1, stats->st_gid));
 #endif
 }
 
index 5233832..a8d5cd1 100644 (file)
@@ -302,8 +302,7 @@ FLAC__bool import_vc_from(const char *filename, FLAC__StreamMetadata *block, con
        }
 
        ret = true;
-       while(ret && !feof(f)) {
-               fgets(line, sizeof(line), f);
+       while(ret && !feof(f) && fgets(line, sizeof(line), f) != NULL) {
                if(!feof(f)) {
                        char *p = strchr(line, '\n');
                        if(0 == p) {
index 1d75dca..f278e53 100644 (file)
@@ -32,6 +32,7 @@
 #include "FLAC++/metadata.h"
 #include "share/grabbag.h"
 #include "share/compat.h"
+#include "share/macros.h"
 extern "C" {
 #include "test_libs_common/file_utils_flac.h"
 }
@@ -270,8 +271,8 @@ void set_file_stats_(const char *filename, struct stat *stats)
        (void)chmod(filename, stats->st_mode);
        (void)utime(filename, &srctime);
 #if !defined _MSC_VER && !defined __MINGW32__ && !defined __EMX__
-       (void)chown(filename, stats->st_uid, (gid_t)(-1));
-       (void)chown(filename, (uid_t)(-1), stats->st_gid);
+       FLAC_CHECK_RETURN(chown(filename, stats->st_uid, (gid_t)(-1)));
+       FLAC_CHECK_RETURN(chown(filename, (uid_t)(-1), stats->st_gid));
 #endif
 }
 
index a3d021f..e720056 100644 (file)
@@ -37,6 +37,7 @@
 #include "FLAC/metadata.h"
 #include "share/grabbag.h"
 #include "share/compat.h"
+#include "share/macros.h"
 #include "test_libs_common/file_utils_flac.h"
 #include "test_libs_common/metadata_utils.h"
 #include "metadata.h"
@@ -260,8 +261,8 @@ static void set_file_stats_(const char *filename, struct stat *stats)
        (void)chmod(filename, stats->st_mode);
        (void)utime(filename, &srctime);
 #if !defined _MSC_VER && !defined __MINGW32__
-       (void)chown(filename, stats->st_uid, -1);
-       (void)chown(filename, -1, stats->st_gid);
+       FLAC_CHECK_RETURN(chown(filename, stats->st_uid, -1));
+       FLAC_CHECK_RETURN(chown(filename, -1, stats->st_gid));
 #endif
 }
 
index 629ee16..c9f9567 100644 (file)
@@ -167,8 +167,8 @@ static FLAC__bool read_pcm_(FLAC__int32 *pcm[], const char *rawfilename, const c
                signed char c;
                for(i = 0; i < samples; i++) {
                        for(j = 0; j < channels; j++) {
-                               fread(&c, 1, 1, f);
-                               pcm[j][i] = c;
+                               if (fread(&c, 1, 1, f) == 1)
+                                       pcm[j][i] = c;
                        }
                }
        }
@@ -176,8 +176,8 @@ static FLAC__bool read_pcm_(FLAC__int32 *pcm[], const char *rawfilename, const c
                unsigned char c[2];
                for(i = 0; i < samples; i++) {
                        for(j = 0; j < channels; j++) {
-                               fread(&c, 1, 2, f);
-                               pcm[j][i] = ((int)((signed char)c[0])) << 8 | (int)c[1];
+                               if (fread(&c, 1, 2, f) == 2)
+                                       pcm[j][i] = ((int)((signed char)c[0])) << 8 | (int)c[1];
                        }
                }
        }