[gjs] Various bugs and issues caught by the Clang static analyzer



commit b3fa00a4236d08e1ce61754615ca9a920480b6a9
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri Jul 13 16:46:46 2012 -0400

    Various bugs and issues caught by the Clang static analyzer
    
    https://bugzilla.gnome.org/show_bug.cgi?id=679897

 gi/arg.c      |    5 +++++
 gi/function.c |    2 +-
 gi/object.c   |    6 ++++--
 util/log.c    |    4 +++-
 4 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/gi/arg.c b/gi/arg.c
index 25f1808..3f82d9c 100644
--- a/gi/arg.c
+++ b/gi/arg.c
@@ -251,6 +251,7 @@ type_needs_out_release(GITypeInfo *type_info,
         case GI_INFO_TYPE_ENUM:
         case GI_INFO_TYPE_FLAGS:
             needs_release = FALSE;
+            break;
 
         default:
             needs_release = TRUE;
@@ -1937,6 +1938,8 @@ gjs_array_from_carray_internal (JSContext  *context,
     GITypeTag element_type;
     guint i;
 
+    result = JS_FALSE;
+
     element_type = g_type_info_get_tag(param_info);
 
     if (is_gvalue_flat_array(param_info, element_type))
@@ -2124,6 +2127,8 @@ gjs_array_from_zero_terminated_c_array (JSContext  *context,
     GITypeTag element_type;
     guint i;
 
+    result = JS_FALSE;
+
     element_type = g_type_info_get_tag(param_info);
 
     /* Special case array(guint8) */
diff --git a/gi/function.c b/gi/function.c
index 1f8ac3d..a4209d2 100644
--- a/gi/function.c
+++ b/gi/function.c
@@ -282,6 +282,7 @@ gjs_callback_closure(ffi_cif *cif,
     }
 
     if (trampoline->is_vfunc) {
+        g_assert(n_args > 0);
         this_object = JSVAL_TO_OBJECT(jsargs[0]);
         jsargs++;
         n_jsargs--;
@@ -665,7 +666,6 @@ gjs_invoke_c_function(JSContext      *context,
 
     failed = FALSE;
     c_arg_pos = 0; /* index into in_arg_cvalues, etc */
-    gi_arg_pos = 0; /* index into function->info arguments */
     js_arg_pos = 0; /* index into argv */
 
     if (is_method) {
diff --git a/gi/object.c b/gi/object.c
index 9942ee2..d9cfb68 100644
--- a/gi/object.c
+++ b/gi/object.c
@@ -1392,11 +1392,13 @@ emit_func(JSContext *context,
 
     if (signal_query.return_type != G_TYPE_NONE) {
         if (!gjs_value_from_g_value(context,
-                                       &retval,
-                                       &rvalue))
+                                    &retval,
+                                    &rvalue))
             failed = TRUE;
 
         g_value_unset(&rvalue);
+    } else {
+        retval = JSVAL_VOID;
     }
 
     for (i = 0; i < (signal_query.n_params + 1); ++i) {
diff --git a/util/log.c b/util/log.c
index e52daf5..64971a0 100644
--- a/util/log.c
+++ b/util/log.c
@@ -184,7 +184,6 @@ gjs_debug(GjsDebugTopic topic,
         return;
 
     error = FALSE;
-    prefix = "???";
     switch (topic) {
     case GJS_DEBUG_STRACE_TIMESTAMP:
         /* return early if strace timestamps are disabled, avoiding
@@ -280,6 +279,9 @@ gjs_debug(GjsDebugTopic topic,
     case GJS_DEBUG_GERROR:
         prefix = "JS G ERR";
         break;
+    default:
+        prefix = "???";
+        break;
     }
 
     if (!is_allowed_prefix(prefix))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]