[Flac-dev] PATCH : Fix missing protoypes

Erik de Castro Lopo erikd-flac at mega-nerd.com
Sat Jul 14 19:01:52 PDT 2007


Hi all,

I added -Wmissing-prototypes -Wstrict-prototypes to the CFLAGS and
found that there were a number warnings generated.

The patch below fixes those warnings and adds the two -W flags to
configure.in.

Cheers,
Erik

----------------------8<----------------------8<----------------------
--- src/metaflac/operations_shorthand.h	1970-01-01 00:00:00 +0000
+++ src/metaflac/operations_shorthand.h	2007-07-15 01:17:57 +0000
@@ -0,0 +1,25 @@
+/* metaflac - Command-line FLAC metadata editor
+ * Copyright (C) 2001,2002,2003,2004,2005,2006,2007  Josh Coalson
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#include "options.h"
+
+FLAC__bool do_shorthand_operation__picture(const char *filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write);
+FLAC__bool do_shorthand_operation__cuesheet(const char *filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write);
+FLAC__bool do_shorthand_operation__add_seekpoints(const char *filename, FLAC__Metadata_Chain *chain, const char *specification, FLAC__bool *needs_write);
+FLAC__bool do_shorthand_operation__streaminfo(const char *filename, FLAC__bool prefix_with_filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write);
+FLAC__bool do_shorthand_operation__vorbis_comment(const char *filename, FLAC__bool prefix_with_filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write, FLAC__bool raw);

--- src/share/utf8/iconvert.h	1970-01-01 00:00:00 +0000
+++ src/share/utf8/iconvert.h	2007-07-15 00:55:11 +0000
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2001 Edmund Grimley Evans <edmundo at rano.org>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#if HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#ifdef HAVE_ICONV
+
+/*
+ * Convert data from one encoding to another. Return:
+ *
+ *  -2 : memory allocation failed
+ *  -1 : unknown encoding
+ *   0 : data was converted exactly
+ *   1 : data was converted inexactly
+ *   2 : data was invalid (but still converted)
+ *
+ * We convert in two steps, via UTF-8, as this is the only
+ * reliable way of distinguishing between invalid input
+ * and valid input which iconv refuses to transliterate.
+ * We convert from UTF-8 twice, because we have no way of
+ * knowing whether the conversion was exact if iconv returns
+ * E2BIG (due to a bug in the specification of iconv).
+ * An alternative approach is to assume that the output of
+ * iconv is never more than 4 times as long as the input,
+ * but I prefer to avoid that assumption if possible.
+ */
+
+int iconvert(const char *fromcode, const char *tocode,
+	     const char *from, size_t fromlen,
+	     char **to, size_t *tolen) ;
+
+#endif /* HAVE_ICONV */

--- configure.in	2007-07-14 08:45:49 +0000
+++ configure.in	2007-07-15 01:45:52 +0000
@@ -280,7 +280,7 @@
 else
 	OUR_CFLAGS_HEAD="$OUR_CFLAGS_HEAD -DNDEBUG"
 	if test "x$GCC" = xyes; then
-		OUR_CFLAGS_HEAD="$OUR_CFLAGS_HEAD -O3 -funroll-loops -finline-functions -Wall -W -Winline -DFLaC__INLINE=__inline__"
+		OUR_CFLAGS_HEAD="$OUR_CFLAGS_HEAD -O3 -funroll-loops -finline-functions -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Winline -DFLaC__INLINE=__inline__"
 	fi
 fi
 CFLAGS="$OUR_CFLAGS_HEAD $CFLAGS"

--- src/flac/local_string_utils.c	2007-07-14 08:45:49 +0000
+++ src/flac/local_string_utils.c	2007-07-15 00:56:58 +0000
@@ -8,6 +8,7 @@
 #include <string.h>
 
 #include "utils.h"
+#include "local_string_utils.h"
 
 /*	$OpenBSD: strlcpy.c,v 1.8 2003/06/17 21:56:24 millert Exp $
  *

--- src/libFLAC/metadata_iterators.c	2007-07-14 08:45:49 +0000
+++ src/libFLAC/metadata_iterators.c	2007-07-15 00:48:41 +0000
@@ -1198,6 +1198,7 @@
 	return true;
 }
 
+static
 FLAC__StreamDecoderReadStatus chain_read_ogg_read_cb_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
 {
 	FLAC__Metadata_Chain *chain = (FLAC__Metadata_Chain*)client_data;
@@ -2318,6 +2319,7 @@
 	return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK;
 }
 
+static
 FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_picture_cstring_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__byte **data, FLAC__uint32 *length, FLAC__uint32 length_len)
 {
 	FLAC__byte buffer[sizeof(FLAC__uint32)];

--- src/libFLAC/stream_encoder.c	2007-07-14 08:45:49 +0000
+++ src/libFLAC/stream_encoder.c	2007-07-15 00:50:25 +0000
@@ -1417,6 +1417,7 @@
 	return true;
 }
 
+FLAC_API FLAC__bool FLAC__stream_encoder_set_do_md5(FLAC__StreamEncoder *encoder, FLAC__bool value) ;
 FLAC_API FLAC__bool FLAC__stream_encoder_set_do_md5(FLAC__StreamEncoder *encoder, FLAC__bool value)
 {
 	FLAC__ASSERT(0 != encoder);
@@ -1744,6 +1745,7 @@
  * These three functions are not static, but not publically exposed in
  * include/FLAC/ either.  They are used by the test suite.
  */
+FLAC_API FLAC__bool FLAC__stream_encoder_disable_constant_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value) ;
 FLAC_API FLAC__bool FLAC__stream_encoder_disable_constant_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value)
 {
 	FLAC__ASSERT(0 != encoder);
@@ -1755,6 +1757,7 @@
 	return true;
 }
 
+FLAC_API FLAC__bool FLAC__stream_encoder_disable_fixed_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value) ;
 FLAC_API FLAC__bool FLAC__stream_encoder_disable_fixed_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value)
 {
 	FLAC__ASSERT(0 != encoder);
@@ -1766,6 +1769,7 @@
 	return true;
 }
 
+FLAC_API FLAC__bool FLAC__stream_encoder_disable_verbatim_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value) ;
 FLAC_API FLAC__bool FLAC__stream_encoder_disable_verbatim_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value)
 {
 	FLAC__ASSERT(0 != encoder);
@@ -1842,6 +1846,7 @@
 	return encoder->protected_->streamable_subset;
 }
 
+FLAC_API FLAC__bool FLAC__stream_encoder_get_do_md5(const FLAC__StreamEncoder *encoder) ;
 FLAC_API FLAC__bool FLAC__stream_encoder_get_do_md5(const FLAC__StreamEncoder *encoder)
 {
 	FLAC__ASSERT(0 != encoder);

--- src/metaflac/operations.c	2007-07-14 08:45:49 +0000
+++ src/metaflac/operations.c	2007-07-15 01:13:06 +0000
@@ -29,6 +29,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include "operations_shorthand.h"
 
 static void show_version(void);
 static FLAC__bool do_major_operation(const CommandLineOptions *options);

--- src/metaflac/operations_shorthand_cuesheet.c	2007-07-14 08:45:49 +0000
+++ src/metaflac/operations_shorthand_cuesheet.c	2007-07-15 01:13:41 +0000
@@ -27,6 +27,7 @@
 #include "utils.h"
 #include "FLAC/assert.h"
 #include "share/grabbag.h"
+#include "operations_shorthand.h"
 
 static FLAC__bool import_cs_from(const char *filename, FLAC__StreamMetadata **cuesheet, const char *cs_filename, FLAC__bool *needs_write, FLAC__uint64 lead_out_offset, FLAC__bool is_cdda, Argument_AddSeekpoint *add_seekpoint_link);
 static FLAC__bool export_cs_to(const char *filename, const FLAC__StreamMetadata *cuesheet, const char *cs_filename);

--- src/metaflac/operations_shorthand_picture.c	2007-07-14 08:45:49 +0000
+++ src/metaflac/operations_shorthand_picture.c	2007-07-15 01:12:34 +0000
@@ -26,6 +26,7 @@
 #include "utils.h"
 #include "FLAC/assert.h"
 #include "share/grabbag.h" /* for grabbag__picture_parse_specification() etc */
+#include "operations_shorthand.h"
 
 static FLAC__bool import_pic_from(const char *filename, FLAC__StreamMetadata **picture, const char *specification, FLAC__bool *needs_write);
 static FLAC__bool export_pic_to(const char *filename, const FLAC__StreamMetadata *picture, const char *pic_filename);

--- src/metaflac/operations_shorthand_seektable.c	2007-07-14 08:45:49 +0000
+++ src/metaflac/operations_shorthand_seektable.c	2007-07-15 01:14:39 +0000
@@ -25,6 +25,7 @@
 #include "FLAC/stream_decoder.h"
 #include "FLAC/metadata.h"
 #include "share/grabbag.h"
+#include "operations_shorthand.h"
 
 static FLAC__bool populate_seekpoint_values(const char *filename, FLAC__StreamMetadata *block, FLAC__bool *needs_write);
 

--- src/metaflac/operations_shorthand_streaminfo.c	2007-07-14 08:45:49 +0000
+++ src/metaflac/operations_shorthand_streaminfo.c	2007-07-15 01:17:31 +0000
@@ -25,6 +25,7 @@
 #include "FLAC/assert.h"
 #include "FLAC/metadata.h"
 #include <string.h>
+#include "operations_shorthand.h"
 
 FLAC__bool do_shorthand_operation__streaminfo(const char *filename, FLAC__bool prefix_with_filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write)
 {

--- src/metaflac/operations_shorthand_vorbiscomment.c	2007-07-14 08:45:49 +0000
+++ src/metaflac/operations_shorthand_vorbiscomment.c	2007-07-15 01:18:12 +0000
@@ -28,6 +28,7 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
+#include "operations_shorthand.h"
 
 static FLAC__bool remove_vc_all(const char *filename, FLAC__StreamMetadata *block, FLAC__bool *needs_write);
 static FLAC__bool remove_vc_field(const char *filename, FLAC__StreamMetadata *block, const char *field_name, FLAC__bool *needs_write);

--- src/share/utf8/iconvert.c	2007-07-14 08:45:49 +0000
+++ src/share/utf8/iconvert.c	2007-07-15 00:55:28 +0000
@@ -28,6 +28,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "iconvert.h"
+
 /*
  * Convert data from one encoding to another. Return:
  *

--- src/share/utf8/utf8.c	2007-07-14 08:45:49 +0000
+++ src/share/utf8/utf8.c	2007-07-15 00:55:50 +0000
@@ -227,9 +227,7 @@
 #include <langinfo.h>
 #endif
 
-int iconvert(const char *fromcode, const char *tocode,
-	     const char *from, size_t fromlen,
-	     char **to, size_t *tolen);
+#include "iconvert.h"
 
 static const char *current_charset(void)
 {

--- src/test_libFLAC/bitwriter.c	2007-07-14 08:45:49 +0000
+++ src/test_libFLAC/bitwriter.c	2007-07-15 01:25:48 +0000
@@ -22,6 +22,7 @@
 
 #include "FLAC/assert.h"
 #include "private/bitwriter.h" /* from the libFLAC private include area */
+#include "bitwriter.h"
 #include <stdio.h>
 #include <string.h> /* for memcmp() */
 

--- src/test_libFLAC/format.c	2007-07-14 08:45:49 +0000
+++ src/test_libFLAC/format.c	2007-07-15 01:25:59 +0000
@@ -22,6 +22,7 @@
 
 #include "FLAC/assert.h"
 #include "FLAC/format.h"
+#include "format.h"
 #include <stdio.h>
 
 static const char *true_false_string_[2] = { "false", "true" };

--- src/test_libFLAC/metadata.h	2007-07-14 08:45:49 +0000
+++ src/test_libFLAC/metadata.h	2007-07-15 01:26:07 +0000
@@ -22,5 +22,7 @@
 #include "FLAC/ordinals.h"
 
 FLAC__bool test_metadata(void);
+FLAC__bool test_metadata_file_manipulation(void);
+FLAC__bool test_metadata_object(void) ;
 
 #endif

--- src/test_libFLAC/metadata_manip.c	2007-07-14 08:45:49 +0000
+++ src/test_libFLAC/metadata_manip.c	2007-07-15 01:24:02 +0000
@@ -42,6 +42,7 @@
 #include "share/grabbag.h"
 #include "test_libs_common/file_utils_flac.h"
 #include "test_libs_common/metadata_utils.h"
+#include "metadata.h"
 
 
 /******************************************************************************
@@ -184,6 +185,7 @@
  * This wad of functions supports filename- and callback-based chain reading/writing.
  * Everything up to set_file_stats_() is copied from libFLAC/metadata_iterators.c
  */
+static
 FLAC__bool open_tempfile_(const char *filename, FILE **tempfile, char **tempfilename)
 {
 	static const char *tempfile_suffix = ".metadata_edit";
@@ -199,6 +201,7 @@
 	return true;
 }
 
+static
 void cleanup_tempfile_(FILE **tempfile, char **tempfilename)
 {
 	if(0 != *tempfile) {
@@ -213,6 +216,7 @@
 	}
 }
 
+static
 FLAC__bool transport_tempfile_(const char *filename, FILE **tempfile, char **tempfilename)
 {
 	FLAC__ASSERT(0 != filename);
@@ -243,6 +247,7 @@
 	return true;
 }
 
+static
 FLAC__bool get_file_stats_(const char *filename, struct stat *stats)
 {
 	FLAC__ASSERT(0 != filename);
@@ -250,6 +255,7 @@
 	return (0 == stat(filename, stats));
 }
 
+static
 void set_file_stats_(const char *filename, struct stat *stats)
 {
 	struct utimbuf srctime;

--- src/test_libFLAC/metadata_object.c	2007-07-14 08:45:49 +0000
+++ src/test_libFLAC/metadata_object.c	2007-07-15 01:26:52 +0000
@@ -23,6 +23,7 @@
 #include "FLAC/assert.h"
 #include "FLAC/metadata.h"
 #include "test_libs_common/metadata_utils.h"
+#include "metadata.h"
 #include <stdio.h>
 #include <stdlib.h> /* for malloc() */
 #include <string.h> /* for memcmp() */

----------------------8<----------------------8<----------------------


-- 
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"Using Java as a general purpose application development language
is like going big game hunting armed with Nerf weapons."
-- Author Unknown


More information about the Flac-dev mailing list