Fix a declaration after statement
authorPetri Lehtinen <petri@digip.org>
Thu, 10 Mar 2011 19:28:44 +0000 (21:28 +0200)
committerPetri Lehtinen <petri@digip.org>
Thu, 10 Mar 2011 19:28:53 +0000 (21:28 +0200)
While at it, add -Wdeclaration-after-statement to AM_CFLAGS to catch
these in the future.

src/Makefile.am
src/error.c

index ec9b099..4f2a58d 100644 (file)
@@ -21,5 +21,5 @@ libjansson_la_LDFLAGS = \
 
 if GCC
 # These flags are gcc specific
-AM_CFLAGS = -Wall -Wextra -Werror
+AM_CFLAGS = -Wall -Wextra -Wdeclaration-after-statement -Werror
 endif
index 074a68e..a7c8cbb 100644 (file)
@@ -18,10 +18,12 @@ void jsonp_error_init(json_error_t *error, const char *source)
 
 void jsonp_error_set_source(json_error_t *error, const char *source)
 {
+    size_t length;
+
     if(!error || !source)
         return;
 
-    size_t length = strlen(source);
+    length = strlen(source);
     if(length < JSON_ERROR_SOURCE_LENGTH)
         strcpy(error->source, source);
     else {