From: Petri Lehtinen Date: Thu, 10 Mar 2011 19:28:44 +0000 (+0200) Subject: Fix a declaration after statement X-Git-Tag: v2.0.1~8 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=jansson.git;a=commitdiff_plain;h=11119601205b4276464e55a6518049a370560e60;hp=7f09f48e7e7bc98f54c41ad3204ed1d29f313b7b Fix a declaration after statement While at it, add -Wdeclaration-after-statement to AM_CFLAGS to catch these in the future. --- diff --git a/src/Makefile.am b/src/Makefile.am index ec9b099..4f2a58d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 diff --git a/src/error.c b/src/error.c index 074a68e..a7c8cbb 100644 --- a/src/error.c +++ b/src/error.c @@ -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 {