From 51d566ba6e657ece9769e03dbdaa7bd64c3f45f5 Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Thu, 24 May 2018 12:58:12 +0100 Subject: [PATCH 1/2] test_paths: Reindent to avoid tripping -Wmisleading-indentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes: glib/tests/testglib.c: In function ‘test_paths’: glib/tests/testglib.c:955:3: error: this ‘if’ clause does not guard... [-Werror=misleading-indentation] if (g_test_verbose ()) ^~ glib/tests/testglib.c:958:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ { ^ https://bugzilla.gnome.org/show_bug.cgi?id=796385 --- tests/testglib.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/testglib.c b/tests/testglib.c index ca9153a13..f29bbc664 100644 --- a/tests/testglib.c +++ b/tests/testglib.c @@ -955,18 +955,18 @@ test_paths (void) if (g_test_verbose ()) g_printerr ("checking g_canonicalize_filename() supports NULL..."); - { - const gchar *relative_path = "./"; - gchar *canonical_path = g_canonicalize_filename (relative_path, NULL); - gchar *cwd = g_get_current_dir (); - if (g_strcmp0 (canonical_path, cwd) != 0) - { - g_error ("\nfailed for \"%s\"==\"%s\" (returned: \"%s\")\n", - relative_path, cwd, canonical_path); - } - g_free (cwd); - g_free (canonical_path); - } + { + const gchar *relative_path = "./"; + gchar *canonical_path = g_canonicalize_filename (relative_path, NULL); + gchar *cwd = g_get_current_dir (); + if (g_strcmp0 (canonical_path, cwd) != 0) + { + g_error ("\nfailed for \"%s\"==\"%s\" (returned: \"%s\")\n", + relative_path, cwd, canonical_path); + } + g_free (cwd); + g_free (canonical_path); + } if (g_test_verbose ()) g_printerr ("ok\n"); From 61b2f5c8e11aa5ae38138f352334f389f2b1d058 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 30 May 2018 10:12:01 +0100 Subject: [PATCH 2/2] build: Always enable -Wmisleading-indentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Try and ensure that people don’t push code with misleading indentation in future. This should give fairly few false positives. Signed-off-by: Philip Withnall --- configure.ac | 2 +- meson.build | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index ab67bda3f..be48c9a19 100644 --- a/configure.ac +++ b/configure.ac @@ -3508,7 +3508,7 @@ AC_ARG_ENABLE(compile-warnings, enable_compile_warnings=yes) AS_IF([test "x$enable_compile_warnings" != xno], [ CC_CHECK_FLAGS_APPEND([GLIB_WARN_CFLAGS], [CFLAGS], [\ - -Wall -Wstrict-prototypes -Wduplicated-branches \ + -Wall -Wstrict-prototypes -Wduplicated-branches -Wmisleading-indentation \ -Werror=declaration-after-statement \ -Werror=missing-prototypes -Werror=implicit-function-declaration \ -Werror=pointer-arith -Werror=init-self -Werror=format-security \ diff --git a/meson.build b/meson.build index 49cc9c3bd..6eb67cff2 100644 --- a/meson.build +++ b/meson.build @@ -331,6 +331,7 @@ if cc.get_id() == 'gcc' or cc.get_id() == 'clang' test_c_args = [ '-Wall', '-Wduplicated-branches', + '-Wmisleading-indentation', '-Wstrict-prototypes', '-Wunused', '-Werror=declaration-after-statement',