Fix compiler warnings from new compiler flags.

This commit is contained in:
Erik de Castro Lopo
2013-03-05 22:19:27 +11:00
parent 05609d5b4b
commit 91790ef965
7 changed files with 56 additions and 12 deletions

View File

@@ -8,6 +8,7 @@ EXTRA_DIST = \
endswap.h \ endswap.h \
getopt.h \ getopt.h \
grabbag.h \ grabbag.h \
macros.h \
replaygain_analysis.h \ replaygain_analysis.h \
replaygain_synthesis.h \ replaygain_synthesis.h \
utf8.h utf8.h

41
include/share/macros.h Normal file
View File

@@ -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)) ; \
}

View File

@@ -46,6 +46,7 @@
#include "FLAC/stream_decoder.h" #include "FLAC/stream_decoder.h"
#include "share/alloc.h" #include "share/alloc.h"
#include "share/compat.h" #include "share/compat.h"
#include "share/macros.h"
#include "private/macros.h" #include "private/macros.h"
#include "private/memory.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)chmod(filename, stats->st_mode);
(void)utime(filename, &srctime); (void)utime(filename, &srctime);
#if !defined _MSC_VER && !defined __BORLANDC__ && !defined __MINGW32__ #if !defined _MSC_VER && !defined __BORLANDC__ && !defined __MINGW32__
(void)chown(filename, stats->st_uid, -1); FLAC_CHECK_RETURN(chown(filename, stats->st_uid, -1));
(void)chown(filename, -1, stats->st_gid); FLAC_CHECK_RETURN(chown(filename, -1, stats->st_gid));
#endif #endif
} }

View File

@@ -302,8 +302,7 @@ FLAC__bool import_vc_from(const char *filename, FLAC__StreamMetadata *block, con
} }
ret = true; ret = true;
while(ret && !feof(f)) { while(ret && !feof(f) && fgets(line, sizeof(line), f) != NULL) {
fgets(line, sizeof(line), f);
if(!feof(f)) { if(!feof(f)) {
char *p = strchr(line, '\n'); char *p = strchr(line, '\n');
if(0 == p) { if(0 == p) {

View File

@@ -32,6 +32,7 @@
#include "FLAC++/metadata.h" #include "FLAC++/metadata.h"
#include "share/grabbag.h" #include "share/grabbag.h"
#include "share/compat.h" #include "share/compat.h"
#include "share/macros.h"
extern "C" { extern "C" {
#include "test_libs_common/file_utils_flac.h" #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)chmod(filename, stats->st_mode);
(void)utime(filename, &srctime); (void)utime(filename, &srctime);
#if !defined _MSC_VER && !defined __MINGW32__ && !defined __EMX__ #if !defined _MSC_VER && !defined __MINGW32__ && !defined __EMX__
(void)chown(filename, stats->st_uid, (gid_t)(-1)); FLAC_CHECK_RETURN(chown(filename, stats->st_uid, (gid_t)(-1)));
(void)chown(filename, (uid_t)(-1), stats->st_gid); FLAC_CHECK_RETURN(chown(filename, (uid_t)(-1), stats->st_gid));
#endif #endif
} }

View File

@@ -37,6 +37,7 @@
#include "FLAC/metadata.h" #include "FLAC/metadata.h"
#include "share/grabbag.h" #include "share/grabbag.h"
#include "share/compat.h" #include "share/compat.h"
#include "share/macros.h"
#include "test_libs_common/file_utils_flac.h" #include "test_libs_common/file_utils_flac.h"
#include "test_libs_common/metadata_utils.h" #include "test_libs_common/metadata_utils.h"
#include "metadata.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)chmod(filename, stats->st_mode);
(void)utime(filename, &srctime); (void)utime(filename, &srctime);
#if !defined _MSC_VER && !defined __MINGW32__ #if !defined _MSC_VER && !defined __MINGW32__
(void)chown(filename, stats->st_uid, -1); FLAC_CHECK_RETURN(chown(filename, stats->st_uid, -1));
(void)chown(filename, -1, stats->st_gid); FLAC_CHECK_RETURN(chown(filename, -1, stats->st_gid));
#endif #endif
} }

View File

@@ -167,7 +167,7 @@ static FLAC__bool read_pcm_(FLAC__int32 *pcm[], const char *rawfilename, const c
signed char c; signed char c;
for(i = 0; i < samples; i++) { for(i = 0; i < samples; i++) {
for(j = 0; j < channels; j++) { for(j = 0; j < channels; j++) {
fread(&c, 1, 1, f); if (fread(&c, 1, 1, f) == 1)
pcm[j][i] = c; pcm[j][i] = c;
} }
} }
@@ -176,7 +176,7 @@ static FLAC__bool read_pcm_(FLAC__int32 *pcm[], const char *rawfilename, const c
unsigned char c[2]; unsigned char c[2];
for(i = 0; i < samples; i++) { for(i = 0; i < samples; i++) {
for(j = 0; j < channels; j++) { for(j = 0; j < channels; j++) {
fread(&c, 1, 2, f); if (fread(&c, 1, 2, f) == 2)
pcm[j][i] = ((int)((signed char)c[0])) << 8 | (int)c[1]; pcm[j][i] = ((int)((signed char)c[0])) << 8 | (int)c[1];
} }
} }