From 21c886534f8927fdc0fb5f8647394f3e0e0874b8 Mon Sep 17 00:00:00 2001 From: Pierce Lopez Date: Sun, 9 Jun 2019 10:52:08 -0400 Subject: [PATCH 1/3] build: add --disable-werror option to configure to omit -Werror compiler option --- configure.ac | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 272ea6a..798fd5b 100644 --- a/configure.ac +++ b/configure.ac @@ -165,7 +165,12 @@ AS_IF([test "x$enable_Bsymbolic" = "xcheck"], AS_IF([test "x$enable_Bsymbolic" = "xyes"], [JSON_BSYMBOLIC_LDFLAGS=-Wl[,]-Bsymbolic-functions]) AC_SUBST(JSON_BSYMBOLIC_LDFLAGS) -AX_APPEND_COMPILE_FLAGS([-Wall -Werror -Wcast-qual -Wno-error=deprecated-declarations]) +AC_ARG_ENABLE([werror], + AS_HELP_STRING([--disable-werror], [avoid treating compiler warnings as fatal errors])) + +AS_IF([test "x$enable_werror" != "xno"], [AX_APPEND_COMPILE_FLAGS([-Werror])]) + +AX_APPEND_COMPILE_FLAGS([-Wall -Wcast-qual -Wno-error=deprecated-declarations]) AX_APPEND_COMPILE_FLAGS([-Wextra -Wwrite-string -Wno-unused-parameter]) AX_APPEND_COMPILE_FLAGS([-D_GNU_SOURCE]) From 44605744dcd562dfb290e8aa3dd6c5b2becb1ed0 Mon Sep 17 00:00:00 2001 From: Pierce Lopez Date: Sun, 9 Jun 2019 10:55:50 -0400 Subject: [PATCH 2/3] build: fix compiler option -Wwrite-strings was typod as -Wwrite-string --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 798fd5b..120797e 100644 --- a/configure.ac +++ b/configure.ac @@ -171,7 +171,7 @@ AC_ARG_ENABLE([werror], AS_IF([test "x$enable_werror" != "xno"], [AX_APPEND_COMPILE_FLAGS([-Werror])]) AX_APPEND_COMPILE_FLAGS([-Wall -Wcast-qual -Wno-error=deprecated-declarations]) -AX_APPEND_COMPILE_FLAGS([-Wextra -Wwrite-string -Wno-unused-parameter]) +AX_APPEND_COMPILE_FLAGS([-Wextra -Wwrite-strings -Wno-unused-parameter]) AX_APPEND_COMPILE_FLAGS([-D_GNU_SOURCE]) AC_LANG_PUSH([C]) From 634900d2704e3ad78cd508cb28c4cc970801cf25 Mon Sep 17 00:00:00 2001 From: Pierce Lopez Date: Sun, 9 Jun 2019 12:10:14 -0400 Subject: [PATCH 3/3] tests: appease -Wwrite-strings --- tests/test_deep_copy.c | 3 ++- tests/test_double_serializer.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/test_deep_copy.c b/tests/test_deep_copy.c index 7a6e63f..63f882b 100644 --- a/tests/test_deep_copy.c +++ b/tests/test_deep_copy.c @@ -186,7 +186,8 @@ int main(int argc, char **argv) printf("\nTesting deep_copy with a custom serializer set\n"); json_object *with_serializer = json_object_new_string("notemitted"); - json_object_set_serializer(with_serializer, my_custom_serializer, "dummy userdata", NULL); + char udata[] = "dummy userdata"; + json_object_set_serializer(with_serializer, my_custom_serializer, udata, NULL); json_object_object_add(src1, "with_serializer", with_serializer); dst1 = NULL; /* With a custom serializer in use, a custom shallow_copy function must also be used */ diff --git a/tests/test_double_serializer.c b/tests/test_double_serializer.c index 21612c8..bb1b8a2 100644 --- a/tests/test_double_serializer.c +++ b/tests/test_double_serializer.c @@ -11,16 +11,17 @@ int main() { struct json_object *obj = json_object_new_double(0.5); + char udata[] = "test"; printf("Test default serializer:\n"); printf("obj.to_string(standard)=%s\n", json_object_to_json_string(obj)); printf("Test default serializer with custom userdata:\n"); - obj->_userdata = "test"; + obj->_userdata = udata; printf("obj.to_string(userdata)=%s\n", json_object_to_json_string(obj)); printf("Test explicit serializer with custom userdata:\n"); - json_object_set_serializer(obj, json_object_double_to_json_string, "test", NULL); + json_object_set_serializer(obj, json_object_double_to_json_string, udata, NULL); printf("obj.to_string(custom)=%s\n", json_object_to_json_string(obj)); printf("Test reset serializer:\n");