Fix a bunch of compiler warnings with gcc-4.6.

This commit is contained in:
Erik de Castro Lopo 2011-03-28 18:43:05 +11:00
parent 33cd8bdb46
commit 9b8d1e0f2f
14 changed files with 32 additions and 57 deletions

View File

@ -1,3 +1,8 @@
2011-03-28 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/* tests/* programs/*
Fix a bunch of compiler warnings with gcc-4.6.
2011-03-25 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/util.tpl

View File

@ -271,12 +271,12 @@ copy_metadata (SNDFILE *outfile, SNDFILE *infile, int channels)
{ SF_INSTRUMENT inst ;
SF_BROADCAST_INFO_2K binfo ;
const char *str ;
int k, err = 0, chanmap [256] ;
int k, chanmap [256] ;
for (k = SF_STR_FIRST ; k <= SF_STR_LAST ; k++)
{ str = sf_get_string (infile, k) ;
if (str != NULL)
err = sf_set_string (outfile, k, str) ;
sf_set_string (outfile, k, str) ;
} ;
memset (&inst, 0, sizeof (inst)) ;

View File

@ -357,7 +357,7 @@ alsa_write_float (snd_pcm_t *alsa_dev, float *data, int frames, int channels)
static int opensoundsys_open_device (int channels, int srate) ;
static void
static int
opensoundsys_play (int argc, char *argv [])
{ static short buffer [BUFFER_LEN] ;
SNDFILE *sndfile ;
@ -415,7 +415,7 @@ opensoundsys_play (int argc, char *argv [])
sf_close (sndfile) ;
} ;
return ;
return writecount ;
} /* opensoundsys_play */
static int

View File

@ -75,9 +75,8 @@ broadcast_var_set (SF_PRIVATE *psf, const SF_BROADCAST_INFO * info, size_t datas
if (psf->file.mode == SFM_WRITE)
{ char added_history [256] ;
size_t added_history_len ;
added_history_len = gen_coding_history (added_history, sizeof (added_history), &(psf->sf)) ;
gen_coding_history (added_history, sizeof (added_history), &(psf->sf)) ;
psf_strlcat (psf->broadcast_16k->coding_history, sizeof (psf->broadcast_16k->coding_history), added_history) ;
} ;

View File

@ -63,8 +63,7 @@ static int mpc2k_read_header (SF_PRIVATE *psf) ;
int
mpc2k_open (SF_PRIVATE *psf)
{ int subformat ;
int error = 0 ;
{ int error = 0 ;
if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0))
{ if ((error = mpc2k_read_header (psf)))
@ -74,8 +73,6 @@ mpc2k_open (SF_PRIVATE *psf)
if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_MPC2K)
return SFE_BAD_OPEN_FORMAT ;
subformat = SF_CODEC (psf->sf.format) ;
if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
{ if (mpc2k_write_header (psf, SF_FALSE))
return psf->error ;

View File

@ -999,7 +999,7 @@ streams_open (stream_set *set)
static stream_processor *
find_stream_processor (stream_set *set, ogg_page *page)
{ uint32_t serial = ogg_page_serialno (page) ;
int i, found = 0 ;
int i ;
int invalid = 0 ;
stream_processor *stream ;
@ -1008,7 +1008,6 @@ find_stream_processor (stream_set *set, ogg_page *page)
{
if (serial == set->streams [i].serial)
{ /* We have a match! */
found = 1 ;
stream = & (set->streams [i]) ;
set->in_headers = 0 ;
@ -1102,7 +1101,6 @@ ogg_length_aux (SF_PRIVATE * psf)
{
ogg_sync_state osync ;
ogg_page page ;
int gotpage = 0 ;
sf_count_t len = 0 ;
stream_set *processors ;
@ -1115,7 +1113,6 @@ ogg_length_aux (SF_PRIVATE * psf)
while (ogg_length_get_next_page (psf, &osync, &page))
{
stream_processor *p = find_stream_processor (processors, &page) ;
gotpage = 1 ;
if (!p)
{ len = 0 ;

View File

@ -805,7 +805,6 @@ static void
current_sf_info_test (const char *filename)
{ SNDFILE *outfile, *infile ;
SF_INFO outinfo, ininfo ;
sf_count_t last_count ;
print_test_name ("current_sf_info_test", filename) ;
@ -833,8 +832,6 @@ current_sf_info_test (const char *filename)
memset (&ininfo, 0, sizeof (ininfo)) ;
infile = test_open_file_or_die (filename, SFM_READ, &ininfo, SF_TRUE, __LINE__) ;
last_count = ininfo.frames ;
test_write_double_or_die (outfile, 0, double_data, BUFFER_LEN, __LINE__) ;
sf_command (infile, SFC_GET_CURRENT_SF_INFO, &ininfo, sizeof (ininfo)) ;

View File

@ -244,15 +244,13 @@ static void
update_header_sub (const char *filename, int typemajor, int write_mode)
{ SNDFILE *outfile, *infile ;
SF_INFO sfinfo ;
int k, frames ;
int k ;
sfinfo.samplerate = 44100 ;
sfinfo.format = (typemajor | SF_FORMAT_PCM_16) ;
sfinfo.channels = 1 ;
sfinfo.frames = 0 ;
frames = BUFFER_LEN / sfinfo.channels ;
outfile = test_open_file_or_die (filename, write_mode, &sfinfo, SF_TRUE, __LINE__) ;
for (k = 0 ; k < BUFFER_LEN ; k++)

View File

@ -220,7 +220,6 @@ static void
zero_data_test (const char *filename, int format)
{ SNDFILE *file ;
SF_INFO sfinfo ;
int frames ;
switch (format & SF_FORMAT_TYPEMASK)
{ case SF_FORMAT_OGG :
@ -238,8 +237,6 @@ zero_data_test (const char *filename, int format)
sfinfo.channels = 1 ;
sfinfo.frames = 0 ;
frames = BUFFER_LEN / sfinfo.channels ;
file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
sf_close (file) ;
@ -261,7 +258,6 @@ filesystem_full_test (int format)
struct stat buf ;
const char *filename = "/dev/full", *errorstr ;
int frames ;
#if (defined (WIN32) || defined (_WIN32))
/* Can't run this test on Win32 so return. */
@ -288,8 +284,6 @@ filesystem_full_test (int format)
sfinfo.channels = 1 ;
sfinfo.frames = 0 ;
frames = BUFFER_LEN / sfinfo.channels ;
if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) != NULL)
{ printf ("\n\nLine %d : Error, file should not have openned.\n", __LINE__ - 1) ;
exit (1) ;
@ -321,7 +315,6 @@ permission_test (const char *filename, int typemajor)
SNDFILE *file ;
SF_INFO sfinfo ;
const char *errorstr ;
int frames ;
/* Make sure errno is zero before doing anything else. */
errno = 0 ;
@ -360,8 +353,6 @@ permission_test (const char *filename, int typemajor)
sfinfo.channels = 1 ;
sfinfo.frames = 0 ;
frames = BUFFER_LEN / sfinfo.channels ;
if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) != NULL)
{ printf ("\n\nLine %d : Error, file should not have opened.\n", __LINE__ - 1) ;
exit (1) ;

View File

@ -60,7 +60,7 @@ raw_offset_test (const char *filename, int typeminor)
{ SNDFILE *sndfile ;
SF_INFO sfinfo ;
sf_count_t start ;
int k, frames ;
int k ;
print_test_name ("raw_offset_test", filename) ;
@ -69,8 +69,6 @@ raw_offset_test (const char *filename, int typeminor)
sfinfo.channels = 1 ;
sfinfo.frames = 0 ;
frames = BUFFER_LEN / sfinfo.channels ;
sndfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_TRUE, __LINE__) ;
start = 0 ;

View File

@ -156,7 +156,7 @@ string_start_end_test (const char *filename, int typemajor)
{ const char *cptr ;
SNDFILE *file ;
SF_INFO sfinfo ;
int frames, errors = 0 ;
int errors = 0 ;
typemajor = typemajor ;
@ -167,8 +167,6 @@ string_start_end_test (const char *filename, int typemajor)
sfinfo.frames = 0 ;
sfinfo.format = typemajor | SF_FORMAT_PCM_16 ;
frames = BUFFER_LEN / sfinfo.channels ;
file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
/* Write stuff at start of file. */
@ -305,7 +303,7 @@ string_start_test (const char *filename, int typemajor)
{ const char *cptr ;
SNDFILE *file ;
SF_INFO sfinfo ;
int frames, errors = 0 ;
int errors = 0 ;
print_test_name ("string_start_test", filename) ;
@ -323,8 +321,6 @@ string_start_test (const char *filename, int typemajor)
break ;
} ;
frames = BUFFER_LEN / sfinfo.channels ;
file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
/* Write stuff at start of file. */

View File

@ -468,12 +468,11 @@ hexdump_file (const char * filename, sf_count_t offset, sf_count_t length)
void
dump_log_buffer (SNDFILE *file)
{ static char buffer [LOG_BUFFER_SIZE] ;
int count ;
memset (buffer, 0, LOG_BUFFER_SIZE) ;
/* Get the log buffer data. */
count = sf_command (file, SFC_GET_LOG_INFO, buffer, LOG_BUFFER_SIZE) ;
sf_command (file, SFC_GET_LOG_INFO, buffer, LOG_BUFFER_SIZE) ;
if (strlen (buffer) < 1)
puts ("Log buffer empty.\n") ;

View File

@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#if HAVE_UNISTD_H
#include <unistd.h>
@ -103,7 +104,7 @@ show_fstat_error (void)
static char data [256] ;
STATBUF statbuf ;
int fd, mode, flags, ignored ;
int fd, mode, flags ;
if (sizeof (statbuf.st_size) != sizeof (INT64))
{ printf ("\n\nLine %d: Error, sizeof (statbuf.st_size) != 8.\n\n", __LINE__) ;
@ -119,7 +120,7 @@ show_fstat_error (void)
{ printf ("\n\nLine %d: open() failed : %s\n\n", __LINE__, strerror (errno)) ;
return ;
} ;
ignored = write (fd, data, sizeof (data)) ;
assert (write (fd, data, sizeof (data)) > 0) ;
close (fd) ;
printf ("1) Re-open file in read/write mode and write another %d bytes at the end.\n", SIGNED_SIZEOF (data)) ;
@ -130,7 +131,7 @@ show_fstat_error (void)
return ;
} ;
LSEEK (fd, 0, SEEK_END) ;
ignored = write (fd, data, sizeof (data)) ;
assert (write (fd, data, sizeof (data)) > 0) ;
printf ("2) Now use system (\"%s %s\") to show the file length.\n\n", dir_cmd, filename) ;
@ -140,7 +141,7 @@ show_fstat_error (void)
strncat (data, " ", sizeof (data) - 1 - strlen (data)) ;
strncat (data, filename, sizeof (data) - 1 - strlen (data)) ;
ignored = system (data) ;
assert (system (data) >= 0) ;
puts ("") ;
printf ("3) Now use fstat() to get the file length.\n") ;
@ -168,7 +169,7 @@ show_lseek_error (void)
static char data [256] ;
INT64 retval ;
int fd, mode, flags, ignored ;
int fd, mode, flags ;
puts ("\n64 bit lseek() test.\n--------------------") ;
@ -179,7 +180,7 @@ show_lseek_error (void)
{ printf ("\n\nLine %d: open() failed : %s\n\n", __LINE__, strerror (errno)) ;
return ;
} ;
ignored = write (fd, data, sizeof (data)) ;
assert (write (fd, data, sizeof (data)) > 0) ;
close (fd) ;
printf ("1) Re-open file in read/write mode and write another %d bytes at the end.\n", SIGNED_SIZEOF (data)) ;
@ -191,7 +192,7 @@ show_lseek_error (void)
} ;
LSEEK (fd, 0, SEEK_END) ;
ignored = write (fd, data, sizeof (data)) ;
assert (write (fd, data, sizeof (data)) > 0) ;
printf ("2) Now use system (\"%s %s\") to show the file length.\n\n", dir_cmd, filename) ;
@ -201,7 +202,7 @@ show_lseek_error (void)
strncat (data, " ", sizeof (data) - 1 - strlen (data)) ;
strncat (data, filename, sizeof (data) - 1 - strlen (data)) ;
ignored = system (data) ;
assert (system (data) >= 0) ;
puts ("") ;
printf ("3) Now use lseek() to go to the end of the file.\n") ;
@ -226,7 +227,7 @@ show_stat_fstat_error (void)
static char data [256] ;
int fd, mode, flags ;
int stat_size, fstat_size, ignored ;
int stat_size, fstat_size ;
struct stat buf ;
/* Known to fail on WinXP. */
@ -241,7 +242,7 @@ show_stat_fstat_error (void)
return ;
} ;
ignored = write (fd, data, sizeof (data)) ;
assert (write (fd, data, sizeof (data)) > 0) ;
printf ("1) Now call stat and fstat on the file and retreive the file lengths.\n") ;
@ -279,7 +280,7 @@ write_to_closed_file (void)
{ const char * filename = "closed_write_test.txt" ;
struct stat buf ;
FILE * file ;
int fd, ignored ;
int fd ;
puts ("\nWrite to closed file test.\n--------------------------") ;
@ -293,7 +294,7 @@ write_to_closed_file (void)
fd = fileno (file) ;
printf ("2) Write some text via the file descriptor.\n") ;
ignored = write (fd, "a\n", 2) ;
assert (write (fd, "a\n", 2) > 0) ;
printf ("3) Now we close the file using fclose().\n") ;
fclose (file) ;

View File

@ -434,8 +434,8 @@ static void write_seek_extend_test (const char * filename, int format) ;
static void
pcm_test_[+ (get "type_name") +] (const char *filename, int format, int long_file_ok)
{ SF_INFO sfinfo ;
[+ (get "data_type") +] *orig, *test ;
int k, items, allow_fd ;
[+ (get "data_type") +] *orig ;
int k, allow_fd ;
/* Sd2 files cannot be opened from an existing file descriptor. */
allow_fd = ((format & SF_FORMAT_TYPEMASK) == SF_FORMAT_SD2) ? SF_FALSE : SF_TRUE ;
@ -450,13 +450,10 @@ pcm_test_[+ (get "type_name") +] (const char *filename, int format, int long_fil
gen_windowed_sine_double (orig_data.d, DATA_LENGTH, [+ (get "max_val") +]) ;
orig = orig_data.[+ (get "data_field") +] ;
test = test_data.[+ (get "data_field") +] ;
/* Make this a macro so gdb steps over it in one go. */
CONVERT_DATA (k, DATA_LENGTH, orig, orig_data.d) ;
items = DATA_LENGTH ;
/* Some test broken out here. */
mono_[+ (get "type_name") +]_test (filename, format, long_file_ok, allow_fd) ;