summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Chimento <philip.chimento@gmail.com>2019-12-11 12:34:19 -0800
committerPhilip Chimento <philip.chimento@gmail.com>2019-12-16 15:26:29 -0500
commitb2c8c2877e001a00579e2fa4dfd8be47f4169ba2 (patch)
treeccd9b85c9a6a745a997893dc7176157b460a4baf
parentadf8f133f80b7d59a416d92cef0d0ddc57da78f0 (diff)
scripts: Always enable core checkers
I was told by a Clang static analyzer developer that running the analyzer without the core checkers enabled is not supported, and I've seen that it can lead to crashes. For this we need to make a few changes to the test programs. In gvariant-iter we need to avoid tripping a warning from a core checker, and in gerror-api we can remove two tests for cases that a core checker already detects. See https://bugs.llvm.org/show_bug.cgi?id=42816
-rwxr-xr-xscripts/tartan8
-rw-r--r--tests/gerror-api.c20
-rw-r--r--tests/gvariant-iter.c8
3 files changed, 14 insertions, 22 deletions
diff --git a/scripts/tartan b/scripts/tartan
index d5e40b6..3dcf012 100755
--- a/scripts/tartan
+++ b/scripts/tartan
@@ -130,11 +130,15 @@ if [ "$include_plugin_flags" = "1" ] &&
include_plugin_flags=0
fi
-# The -analyzer-checker argument loads all 'tartan.*' static checkers.
+# The -analyzer-checker arguments load all 'tartan.*' and 'core.*' static
+# checkers.
# The -add-plugin argument loads the tartan AST frontend plugin.
+# FIXME: in Clang 10.x, add '-analyzer-config silence-checker=core' in order to
+# only print Tartan warnings.
add_plugin=( "-load" "$plugin_path" \
"-add-plugin" "$plugin_name" \
- "-analyzer-checker" "$plugin_name" )
+ "-analyzer-checker" "$plugin_name" \
+ "-analyzer-checker" "core" )
if [ "$escape_plugin_flags" = "1" ]; then
_add_plugin=()
diff --git a/tests/gerror-api.c b/tests/gerror-api.c
index 6d03b1a..442bf9b 100644
--- a/tests/gerror-api.c
+++ b/tests/gerror-api.c
@@ -55,16 +55,6 @@
}
/*
- * warning: Using uninitialized GError
- * g_error_free (some_error);
- * ^~~~~~~~~~~~~~~~~~~~~~~~~
- */
-{
- GError *some_error; // uninitialised
- g_error_free (some_error);
-}
-
-/*
* warning: Freeing non-set GError
* g_error_free (some_error);
* ^~~~~~~~~~~~~~~~~~~~~~~~~
@@ -390,16 +380,6 @@
}
/*
- * warning: Freeing non-set GError
- * g_propagate_error (error, sub_error);
- * ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- */
-{
- GError *sub_error = NULL;
- g_propagate_error (error, sub_error);
-}
-
-/*
* warning: Freeing already-freed GError
* g_propagate_error (error, sub_error);
* ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/tests/gvariant-iter.c b/tests/gvariant-iter.c
index 37865ff..ff36db7 100644
--- a/tests/gvariant-iter.c
+++ b/tests/gvariant-iter.c
@@ -9,10 +9,12 @@
GVariant *value;
gchar *key;
+ dictionary = g_variant_new_array ((const GVariantType *) "{sv}", NULL, 0);
g_variant_iter_init (&iter, dictionary);
while (g_variant_iter_loop (&iter, "{sv}", &key, &value)) {
/* Something */
}
+ g_variant_unref (dictionary);
}
/*
@@ -26,10 +28,12 @@
gchar *not_a_value;
gchar *key;
+ dictionary = g_variant_new_array ((const GVariantType *) "{sv}", NULL, 0);
g_variant_iter_init (&iter, dictionary);
while (g_variant_iter_loop (&iter, "{sv}", &key, &not_a_value)) {
/* Something */
}
+ g_variant_unref (dictionary);
}
/*
@@ -41,6 +45,7 @@
GVariant *value;
gchar *key;
+ dictionary = g_variant_new_array ((const GVariantType *) "{sv}", NULL, 0);
g_variant_iter_init (&iter, dictionary);
while (g_variant_iter_next (&iter, "{sv}", &key, &value)) {
/* Something */
@@ -48,6 +53,7 @@
g_variant_unref (value);
g_free (key);
}
+ g_variant_unref (dictionary);
}
/*
@@ -61,6 +67,7 @@
gchar *not_a_value;
gchar *key;
+ dictionary = g_variant_new_array ((const GVariantType *) "{sv}", NULL, 0);
g_variant_iter_init (&iter, dictionary);
while (g_variant_iter_next (&iter, "{sv}", &key, &not_a_value)) {
/* Something */
@@ -68,4 +75,5 @@
g_free (not_a_value);
g_free (key);
}
+ g_variant_unref (dictionary);
}