[easytag] Avoid mixed declarations and code



commit e21d924d7230cd839510aced4a1c4db0f037352f
Author: David King <amigadave amigadave com>
Date:   Tue Feb 5 17:54:43 2013 +0000

    Avoid mixed declarations and code
    
    Enable the warning (and make it an error) to prevent mixed declarations
    and code creeping in.

 configure.ac  |    2 +-
 src/picture.c |    3 ++-
 src/vcedit.c  |    4 ++--
 3 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 33ad726..9821a0d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -239,7 +239,7 @@ AC_SEARCH_LIBS([gethostbyname], [nsl socket], [],
      AC_MSG_RESULT([$have_ws2])])
 
 dnl Check that the compiler accepts the given warning flags.
-warning_flags="-Wall -Wstrict-prototypes -Wnested-externs -Werror=missing-prototypes -Werror=implicit-function-declaration -Werror=pointer-arith -Werror=init-self -Werror=format-security -Werror=format=2 -Werror=missing-include-dirs"
+warning_flags="-Wall -Wstrict-prototypes -Wnested-externs -Werror=missing-prototypes -Werror=implicit-function-declaration -Werror=pointer-arith -Werror=init-self -Werror=format-security -Werror=format=2 -Werror=missing-include-dirs -Werror=declaration-after-statement"
 
 realsave_CFLAGS="$CFLAGS"
 for option in $warning_flags; do
diff --git a/src/picture.c b/src/picture.c
index 3ba2373..954d9bb 100644
--- a/src/picture.c
+++ b/src/picture.c
@@ -1083,6 +1083,7 @@ Picture_Load_File_Data (const gchar *filename)
     gchar *buffer = 0;
     size_t size = 0;
     struct stat st;
+    FILE *fd;
 
 #ifdef G_OS_WIN32
     // Strange : on Win32, the file seems to be in UTF-8, so we can't load files with accentuated characters...
@@ -1102,7 +1103,7 @@ Picture_Load_File_Data (const gchar *filename)
     size = st.st_size;
     buffer = g_malloc(size);
 
-    FILE *fd = fopen(filename, "rb");
+    fd = fopen(filename, "rb");
     if (!fd)
     {
         gchar *filename_utf8;
diff --git a/src/vcedit.c b/src/vcedit.c
index 1d4136d..e687db4 100644
--- a/src/vcedit.c
+++ b/src/vcedit.c
@@ -264,6 +264,8 @@ vcedit_open_callbacks(vcedit_state *state, void *in,
     char *buffer;
     int bytes,i;
     int chunks = 0;
+    int headerpackets = 0;
+    oggpack_buffer opb;
     ogg_packet *header;
     ogg_packet  header_main;
     ogg_packet  header_comments;
@@ -326,7 +328,6 @@ vcedit_open_callbacks(vcedit_state *state, void *in,
     memcpy(state->mainbuf, header_main.packet, header_main.bytes);
 
     state->oggtype = VCEDIT_IS_UNKNOWN;
-    int headerpackets = 0;
     if(vorbis_synthesis_headerin(state->vi, state->vc, &header_main) == 0)
     {
         state->oggtype = VCEDIT_IS_OGGVORBIS;
@@ -361,7 +362,6 @@ vcedit_open_callbacks(vcedit_state *state, void *in,
             break;
 #endif
     }
-    oggpack_buffer opb;
     i = 1;
     while(i<headerpackets)
     {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]