[gjs/wip/ptomato/mozjs31prep: 5/15] build: Avoid compiler warnings
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/ptomato/mozjs31prep: 5/15] build: Avoid compiler warnings
- Date: Mon, 19 Sep 2016 04:15:28 +0000 (UTC)
commit 50e91771f5b65e4263c029d35442595f25c0df46
Author: Philip Chimento <philip chimento gmail com>
Date: Sun Sep 18 19:52:10 2016 -0700
build: Avoid compiler warnings
This gets rid of one possible free() of an uninitialized variable;
renames some variables that shadowed local variables in outer blocks;
removes some unused variables; adds arguments to invocations of varargs
macros without any varargs, since this is disallowed; and puts extra
braces around initializers where the compiler complains about it.
https://bugzilla.gnome.org/show_bug.cgi?id=742249
gi/arg.cpp | 32 +++++++++++++++-----------------
gi/boxed.cpp | 6 +++---
gi/closure.cpp | 8 +++++---
gi/function.cpp | 12 ++++++------
gi/ns.cpp | 2 +-
gi/object.cpp | 1 -
gjs/coverage.cpp | 1 -
gjs/jsapi-util.cpp | 4 +---
modules/cairo-region.cpp | 24 ++++++++++++------------
9 files changed, 43 insertions(+), 47 deletions(-)
---
diff --git a/gi/arg.cpp b/gi/arg.cpp
index 72ac37a..93d6454 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -808,8 +808,8 @@ gjs_array_from_flat_gvalue_array(JSContext *context,
JSBool result = JS_TRUE;
for (i = 0; i < length; i ++) {
- GValue *value = &values[i];
- result = gjs_value_from_g_value(context, &elems[i], value);
+ GValue *gvalue = &values[i];
+ result = gjs_value_from_g_value(context, &elems[i], gvalue);
if (!result)
break;
}
@@ -1425,12 +1425,12 @@ gjs_value_to_g_argument(JSContext *context,
} else if (JSVAL_IS_OBJECT(value)) {
if (interface_type == GI_INFO_TYPE_STRUCT &&
g_struct_info_is_gtype_struct((GIStructInfo*)interface_info)) {
- GType gtype;
+ GType actual_gtype;
gpointer klass;
- gtype = gjs_gtype_get_actual_gtype(context, JSVAL_TO_OBJECT(value));
+ actual_gtype = gjs_gtype_get_actual_gtype(context, JSVAL_TO_OBJECT(value));
- if (gtype == G_TYPE_NONE) {
+ if (actual_gtype == G_TYPE_NONE) {
wrong = TRUE;
report_type_mismatch = TRUE;
break;
@@ -1442,10 +1442,10 @@ gjs_value_to_g_argument(JSContext *context,
the JS constructor is initialized.
*/
- if (g_type_is_a(gtype, G_TYPE_INTERFACE))
- klass = g_type_default_interface_peek(gtype);
+ if (g_type_is_a(actual_gtype, G_TYPE_INTERFACE))
+ klass = g_type_default_interface_peek(actual_gtype);
else
- klass = g_type_class_peek(gtype);
+ klass = g_type_class_peek(actual_gtype);
arg->v_pointer = klass;
} else if ((interface_type == GI_INFO_TYPE_STRUCT || interface_type == GI_INFO_TYPE_BOXED) &&
@@ -1745,7 +1745,6 @@ gjs_value_to_g_argument(JSContext *context,
param_info = g_type_info_get_param_type(type_info, 0);
element_type = g_type_info_get_tag(param_info);
- g_base_info_unref(param_info);
/* First, let's handle the case where we're passed an instance
* of our own byteArray class.
@@ -1780,7 +1779,6 @@ gjs_value_to_g_argument(JSContext *context,
if (array_type == GI_ARRAY_TYPE_C) {
arg->v_pointer = data;
} else if (array_type == GI_ARRAY_TYPE_ARRAY) {
- GITypeInfo *param_info = g_type_info_get_param_type(type_info, 0);
GArray *array = gjs_g_array_new_for_type(context, length, param_info);
if (!array)
@@ -1791,7 +1789,6 @@ gjs_value_to_g_argument(JSContext *context,
}
g_free(data);
- g_base_info_unref((GIBaseInfo*) param_info);
} else if (array_type == GI_ARRAY_TYPE_BYTE_ARRAY) {
GByteArray *byte_array = g_byte_array_sized_new(length);
@@ -1808,6 +1805,7 @@ gjs_value_to_g_argument(JSContext *context,
g_free(data);
}
+ g_base_info_unref((GIBaseInfo*) param_info);
break;
}
default:
@@ -3214,14 +3212,14 @@ gjs_g_arg_release_internal(JSContext *context,
guint i;
for (i = 0; i < array->len; i++) {
- GArgument arg;
+ GArgument arg_iter;
- arg.v_pointer = g_array_index (array, gpointer, i);
+ arg_iter.v_pointer = g_array_index (array, gpointer, i);
gjs_g_arg_release_internal(context,
transfer,
param_info,
element_type,
- &arg);
+ &arg_iter);
}
g_array_free (array, TRUE);
@@ -3250,13 +3248,13 @@ gjs_g_arg_release_internal(JSContext *context,
guint i;
for (i = 0; i < array->len; i++) {
- GArgument arg;
+ GArgument arg_iter;
- arg.v_pointer = g_ptr_array_index (array, i);
+ arg_iter.v_pointer = g_ptr_array_index (array, i);
gjs_g_argument_release(context,
transfer,
param_info,
- &arg);
+ &arg_iter);
}
}
diff --git a/gi/boxed.cpp b/gi/boxed.cpp
index 5de8fa8..bdc10ef 100644
--- a/gi/boxed.cpp
+++ b/gi/boxed.cpp
@@ -376,10 +376,10 @@ boxed_new(JSContext *context,
if (priv->zero_args_constructor >= 0) {
GIFunctionInfo *func_info = g_struct_info_get_method (priv->info, priv->zero_args_constructor);
- GIArgument rval;
+ GIArgument rval_arg;
GError *error = NULL;
- if (!g_function_info_invoke(func_info, NULL, 0, NULL, 0, &rval, &error)) {
+ if (!g_function_info_invoke(func_info, NULL, 0, NULL, 0, &rval_arg, &error)) {
gjs_throw(context, "Failed to invoke boxed constructor: %s", error->message);
g_clear_error(&error);
g_base_info_unref((GIBaseInfo*) func_info);
@@ -388,7 +388,7 @@ boxed_new(JSContext *context,
g_base_info_unref((GIBaseInfo*) func_info);
- priv->gboxed = rval.v_pointer;
+ priv->gboxed = rval_arg.v_pointer;
gjs_debug_lifecycle(GJS_DEBUG_GBOXED,
"JSObject created with boxed instance %p type %s",
diff --git a/gi/closure.cpp b/gi/closure.cpp
index 274f06f..61ed619 100644
--- a/gi/closure.cpp
+++ b/gi/closure.cpp
@@ -270,7 +270,7 @@ gjs_closure_invoke(GClosure *closure,
if (JS_IsExceptionPending(context)) {
gjs_debug_closure("Exception was pending before invoking callback??? "
- "Not expected");
+ "Not expected - closure %p", closure);
gjs_log_exception(context);
}
@@ -285,12 +285,14 @@ gjs_closure_invoke(GClosure *closure,
"have been thrown) closure %p callable %p",
closure, c->obj);
if (!gjs_log_exception(context))
- gjs_debug_closure("Closure invocation failed but no exception was set?");
+ gjs_debug_closure("Closure invocation failed but no exception was set?"
+ "closure %p", closure);
goto out;
}
if (gjs_log_exception(context)) {
- gjs_debug_closure("Closure invocation succeeded but an exception was set");
+ gjs_debug_closure("Closure invocation succeeded but an exception was set"
+ " - closure %p", closure);
}
out:
diff --git a/gi/function.cpp b/gi/function.cpp
index fd9929c..35456f7 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -561,12 +561,12 @@ gjs_fill_method_instance (JSContext *context,
} else if (type == GI_INFO_TYPE_STRUCT &&
g_struct_info_is_gtype_struct((GIStructInfo*) container)) {
/* And so do GType structures */
- GType gtype;
+ GType actual_gtype;
gpointer klass;
- gtype = gjs_gtype_get_actual_gtype(context, obj);
+ actual_gtype = gjs_gtype_get_actual_gtype(context, obj);
- if (gtype == G_TYPE_NONE) {
+ if (actual_gtype == G_TYPE_NONE) {
gjs_throw(context, "Invalid GType class passed for instance parameter");
return JS_FALSE;
}
@@ -577,10 +577,10 @@ gjs_fill_method_instance (JSContext *context,
the JS constructor is initialized.
*/
- if (g_type_is_a(gtype, G_TYPE_INTERFACE))
- klass = g_type_default_interface_peek(gtype);
+ if (g_type_is_a(actual_gtype, G_TYPE_INTERFACE))
+ klass = g_type_default_interface_peek(actual_gtype);
else
- klass = g_type_class_peek(gtype);
+ klass = g_type_class_peek(actual_gtype);
out_arg->v_pointer = klass;
} else {
diff --git a/gi/ns.cpp b/gi/ns.cpp
index 03e5f8f..5bda185 100644
--- a/gi/ns.cpp
+++ b/gi/ns.cpp
@@ -191,7 +191,7 @@ struct JSClass gjs_ns_class = {
};
JSPropertySpec gjs_ns_proto_props[] = {
- { "__name__", 0, GJS_MODULE_PROP_FLAGS | JSPROP_READONLY, (JSPropertyOp)get_name, NULL },
+ { "__name__", 0, GJS_MODULE_PROP_FLAGS | JSPROP_READONLY, { (JSPropertyOp)get_name, NULL } },
{ NULL }
};
diff --git a/gi/object.cpp b/gi/object.cpp
index 74121f8..fad6e77 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -2533,7 +2533,6 @@ gjs_override_property(JSContext *cx,
GParamSpec *pspec;
GParamSpec *new_pspec;
GType gtype;
- GTypeInterface *interface_type;
if (!gjs_parse_call_args(cx, "override_property", "so", args,
"name", &name,
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index ffefcfc..cbdb564 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -1756,7 +1756,6 @@ gjs_coverage_constructed(GObject *object)
JS_SetOptions(context, options_flags);
if (!bootstrap_coverage(coverage)) {
- JSContext *context = (JSContext *) gjs_context_get_native_context(priv->context);
JSAutoCompartment compartment(context, JS_GetGlobalObject(context));
gjs_log_exception(context);
}
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index 2ad4339..8adffee 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -38,8 +38,6 @@
#include <string.h>
#include <math.h>
-static GMutex gc_lock;
-
GQuark
gjs_util_error_quark (void)
{
@@ -400,7 +398,7 @@ gjs_log_object_props(JSContext *context,
while (!JSID_IS_VOID(prop_id)) {
jsval propval;
char *debugstr;
- char *name;
+ char *name = NULL;
if (!JS_GetPropertyById(context, obj, prop_id, &propval))
goto next;
diff --git a/modules/cairo-region.cpp b/modules/cairo-region.cpp
index dfe99d7..c46e406 100644
--- a/modules/cairo-region.cpp
+++ b/modules/cairo-region.cpp
@@ -209,18 +209,18 @@ JSPropertySpec gjs_cairo_region_proto_props[] = {
};
JSFunctionSpec gjs_cairo_region_proto_funcs[] = {
- { "union", (JSNative)union_func, 0, 0 },
- { "subtract", (JSNative)subtract_func, 0, 0 },
- { "intersect", (JSNative)intersect_func, 0, 0 },
- { "xor", (JSNative)xor_func, 0, 0 },
-
- { "unionRectangle", (JSNative)union_rectangle_func, 0, 0 },
- { "subtractRectangle", (JSNative)subtract_rectangle_func, 0, 0 },
- { "intersectRectangle", (JSNative)intersect_rectangle_func, 0, 0 },
- { "xorRectangle", (JSNative)xor_rectangle_func, 0, 0 },
-
- { "numRectangles", (JSNative)num_rectangles_func, 0, 0 },
- { "getRectangle", (JSNative)get_rectangle_func, 0, 0 },
+ { "union", { (JSNative)union_func, 0 }, 0 },
+ { "subtract", { (JSNative)subtract_func, 0 }, 0 },
+ { "intersect", { (JSNative)intersect_func, 0 }, 0 },
+ { "xor", { (JSNative)xor_func, 0 }, 0 },
+
+ { "unionRectangle", { (JSNative)union_rectangle_func, 0 }, 0 },
+ { "subtractRectangle", { (JSNative)subtract_rectangle_func, 0 }, 0 },
+ { "intersectRectangle", { (JSNative)intersect_rectangle_func, 0 }, 0 },
+ { "xorRectangle", { (JSNative)xor_rectangle_func, 0 }, 0 },
+
+ { "numRectangles", { (JSNative)num_rectangles_func, 0 }, 0 },
+ { "getRectangle", { (JSNative)get_rectangle_func, 0 }, 0 },
{ NULL }
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]