summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gi/gimodule.c48
-rw-r--r--gi/pygenum.c18
-rw-r--r--gi/pygflags.c12
-rw-r--r--gi/pygi-argument.c49
-rw-r--r--gi/pygi-array.c58
-rw-r--r--gi/pygi-cache.c12
-rw-r--r--gi/pygi-cache.h5
-rw-r--r--gi/pygi-closure.c8
-rw-r--r--gi/pygi-enum-marshal.c20
-rw-r--r--gi/pygi-info.c10
-rw-r--r--gi/pygi-invoke.c2
-rw-r--r--gi/pygi-list.c12
-rw-r--r--gi/pygi-marshal-cleanup.c8
-rw-r--r--gi/pygi-property.c4
-rw-r--r--gi/pygi-repository.c2
-rw-r--r--gi/pygi-source.c18
-rw-r--r--gi/pygi-type.c24
-rw-r--r--gi/pygi-util.c3
-rw-r--r--gi/pygi-value.c11
-rw-r--r--gi/pygobject-object.c10
-rw-r--r--gi/pygoptioncontext.c2
-rwxr-xr-xsetup.py2
-rw-r--r--tests/testhelpermodule.c4
23 files changed, 198 insertions, 144 deletions
diff --git a/gi/gimodule.c b/gi/gimodule.c
index 9c9a3ee2..957184ff 100644
--- a/gi/gimodule.c
+++ b/gi/gimodule.c
@@ -409,12 +409,13 @@ create_property (const gchar *prop_name,
static GParamSpec *
pyg_param_spec_from_object (PyObject *tuple)
{
- gint val_length;
+ Py_ssize_t val_length;
const gchar *prop_name;
GType prop_type;
const gchar *nick, *blurb;
PyObject *slice, *item, *py_prop_type;
GParamSpec *pspec;
+ gint intvalue;
val_length = PyTuple_Size(tuple);
if (val_length < 4) {
@@ -447,11 +448,14 @@ pyg_param_spec_from_object (PyObject *tuple)
return NULL;
}
+ if (!pygi_gint_from_py (item, &intvalue))
+ return NULL;
+
/* slice is the extra items in the tuple */
slice = PySequence_GetSlice(tuple, 4, val_length-1);
pspec = create_property(prop_name, prop_type,
nick, blurb, slice,
- PYGLIB_PyLong_AsLong(item));
+ intvalue);
return pspec;
}
@@ -551,7 +555,7 @@ add_properties (GObjectClass *klass, PyObject *properties)
GType prop_type;
const gchar *nick, *blurb;
GParamFlags flags;
- gint val_length;
+ Py_ssize_t val_length;
PyObject *slice, *item, *py_prop_type;
GParamSpec *pspec;
@@ -602,7 +606,10 @@ add_properties (GObjectClass *klass, PyObject *properties)
ret = FALSE;
break;
}
- flags = PYGLIB_PyLong_AsLong(item);
+ if (!pygi_gint_from_py (item, &flags)) {
+ ret = FALSE;
+ break;
+ }
/* slice is the extra items in the tuple */
slice = PySequence_GetSlice(value, 3, val_length-1);
@@ -714,6 +721,7 @@ create_signal (GType instance_type, const gchar *signal_name, PyObject *tuple)
PyObject *py_return_type, *py_param_types;
GType return_type;
guint n_params, i;
+ Py_ssize_t py_n_params;
GType *param_types;
guint signal_id;
GSignalAccumulator accumulator = NULL;
@@ -753,7 +761,15 @@ create_signal (GType instance_type, const gchar *signal_name, PyObject *tuple)
PyErr_SetString(PyExc_TypeError, buf);
return FALSE;
}
- n_params = PySequence_Length(py_param_types);
+ py_n_params = PySequence_Length(py_param_types);
+ if (py_n_params < 0)
+ return FALSE;
+ if (py_n_params > G_MAXUINT) {
+ PyErr_SetString(PyExc_TypeError, "too many params");
+ return FALSE;
+ }
+ n_params = (guint)py_n_params;
+
param_types = g_new(GType, n_params);
for (i = 0; i < n_params; i++) {
PyObject *item = PySequence_GetItem(py_param_types, i);
@@ -1222,8 +1238,8 @@ pyg_type_register(PyTypeObject *class, const char *type_name)
/* fill in missing values of GTypeInfo struct */
g_type_query(parent_type, &query);
- type_info.class_size = query.class_size;
- type_info.instance_size = query.instance_size;
+ type_info.class_size = (guint16)query.class_size;
+ type_info.instance_size = (guint16)query.instance_size;
/* create new typecode */
instance_type = g_type_register_static(parent_type, new_type_name,
@@ -1477,7 +1493,7 @@ _wrap_pyg_enum_register_new_gtype_and_add (PyObject *self,
enum_value = &g_enum_values[i];
enum_value->value_nick = g_strdup (name);
- enum_value->value = g_value_info_get_value (value_info);
+ enum_value->value = (gint)g_value_info_get_value (value_info);
if (c_identifier == NULL) {
enum_value->value_name = enum_value->value_nick;
@@ -1596,7 +1612,7 @@ _wrap_pyg_flags_register_new_gtype_and_add (PyObject *self,
flags_value = &g_flags_values[i];
flags_value->value_nick = g_strdup (name);
- flags_value->value = g_value_info_get_value (value_info);
+ flags_value->value = (guint)g_value_info_get_value (value_info);
if (c_identifier == NULL) {
flags_value->value_name = flags_value->value_nick;
@@ -2073,7 +2089,8 @@ pyg_signal_new(PyObject *self, PyObject *args)
PyObject *py_return_type, *py_param_types;
GType instance_type = 0;
- Py_ssize_t n_params, i;
+ Py_ssize_t py_n_params;
+ guint n_params, i;
GType *param_types;
guint signal_id;
@@ -2101,7 +2118,16 @@ pyg_signal_new(PyObject *self, PyObject *args)
"argument 5 must be a sequence of GType codes");
return NULL;
}
- n_params = PySequence_Length(py_param_types);
+
+ py_n_params = PySequence_Length(py_param_types);
+ if (py_n_params < 0)
+ return FALSE;
+ if (py_n_params > G_MAXUINT) {
+ PyErr_SetString(PyExc_TypeError, "too many params");
+ return FALSE;
+ }
+ n_params = (guint)py_n_params;
+
param_types = g_new(GType, n_params);
for (i = 0; i < n_params; i++) {
PyObject *item = PySequence_GetItem(py_param_types, i);
diff --git a/gi/pygenum.c b/gi/pygenum.c
index 0e7c1e31..69f1cd70 100644
--- a/gi/pygenum.c
+++ b/gi/pygenum.c
@@ -25,6 +25,7 @@
#include "pygi-type.h"
#include "pygi-util.h"
#include "pygi-type.h"
+#include "pygi-basictype.h"
#include "pygenum.h"
#include "pygboxed.h"
@@ -324,13 +325,17 @@ pyg_enum_get_value_name(PyGEnum *self, void *closure)
GEnumClass *enum_class;
GEnumValue *enum_value;
PyObject *retval;
+ gint intvalue;
+
+ if (!pygi_gint_from_py ((PyObject*) self, &intvalue))
+ return NULL;
enum_class = g_type_class_ref(self->gtype);
g_assert(G_IS_ENUM_CLASS(enum_class));
- enum_value = g_enum_get_value(enum_class, PYGLIB_PyLong_AS_LONG(self));
+ enum_value = g_enum_get_value(enum_class, intvalue);
- retval = PYGLIB_PyUnicode_FromString(enum_value->value_name);
+ retval = pygi_utf8_to_py (enum_value->value_name);
g_type_class_unref(enum_class);
return retval;
@@ -342,13 +347,18 @@ pyg_enum_get_value_nick(PyGEnum *self, void *closure)
GEnumClass *enum_class;
GEnumValue *enum_value;
PyObject *retval;
+ gint intvalue;
+
+ if (!pygi_gint_from_py ((PyObject*) self, &intvalue))
+ return NULL;
enum_class = g_type_class_ref(self->gtype);
g_assert(G_IS_ENUM_CLASS(enum_class));
- enum_value = g_enum_get_value(enum_class, PYGLIB_PyLong_AS_LONG(self));
+ enum_value = g_enum_get_value(enum_class, intvalue);
+
+ retval = pygi_utf8_to_py (enum_value->value_nick);
- retval = PYGLIB_PyUnicode_FromString(enum_value->value_nick);
g_type_class_unref(enum_class);
return retval;
diff --git a/gi/pygflags.c b/gi/pygflags.c
index d9f38175..01e8a55e 100644
--- a/gi/pygflags.c
+++ b/gi/pygflags.c
@@ -105,7 +105,7 @@ pyg_flags_repr(PyGFlags *self)
char *tmp, *retval, *module_str, *namespace;
PyObject *pyretval, *module;
- tmp = generate_repr(self->gtype, PYGLIB_PyLong_AsUnsignedLong(self));
+ tmp = generate_repr(self->gtype, (guint)PYGLIB_PyLong_AsUnsignedLong(self));
module = PyObject_GetAttrString ((PyObject *)self, "__module__");
if (module == NULL)
@@ -338,7 +338,7 @@ pyg_flags_and(PyGFlags *a, PyGFlags *b)
(PyObject*)b);
return pyg_flags_from_gtype(a->gtype,
- PYGLIB_PyLong_AsUnsignedLong(a) & PYGLIB_PyLong_AsUnsignedLong(b));
+ (guint)(PYGLIB_PyLong_AsUnsignedLong(a) & PYGLIB_PyLong_AsUnsignedLong(b)));
}
static PyObject *
@@ -348,7 +348,7 @@ pyg_flags_or(PyGFlags *a, PyGFlags *b)
return PYGLIB_PyLong_Type.tp_as_number->nb_or((PyObject*)a,
(PyObject*)b);
- return pyg_flags_from_gtype(a->gtype, PYGLIB_PyLong_AsUnsignedLong(a) | PYGLIB_PyLong_AsUnsignedLong(b));
+ return pyg_flags_from_gtype(a->gtype, (guint)(PYGLIB_PyLong_AsUnsignedLong(a) | PYGLIB_PyLong_AsUnsignedLong(b)));
}
static PyObject *
@@ -359,7 +359,7 @@ pyg_flags_xor(PyGFlags *a, PyGFlags *b)
(PyObject*)b);
return pyg_flags_from_gtype(a->gtype,
- PYGLIB_PyLong_AsUnsignedLong(a) ^ PYGLIB_PyLong_AsUnsignedLong(b));
+ (guint)(PYGLIB_PyLong_AsUnsignedLong(a) ^ PYGLIB_PyLong_AsUnsignedLong(b)));
}
@@ -382,7 +382,7 @@ pyg_flags_get_first_value_name(PyGFlags *self, void *closure)
flags_class = g_type_class_ref(self->gtype);
g_assert(G_IS_FLAGS_CLASS(flags_class));
- flags_value = g_flags_get_first_value(flags_class, PYGLIB_PyLong_AsUnsignedLong(self));
+ flags_value = g_flags_get_first_value(flags_class, (guint)PYGLIB_PyLong_AsUnsignedLong(self));
if (flags_value)
retval = PYGLIB_PyUnicode_FromString(flags_value->value_name);
else {
@@ -404,7 +404,7 @@ pyg_flags_get_first_value_nick(PyGFlags *self, void *closure)
flags_class = g_type_class_ref(self->gtype);
g_assert(G_IS_FLAGS_CLASS(flags_class));
- flags_value = g_flags_get_first_value(flags_class, PYGLIB_PyLong_AsUnsignedLong(self));
+ flags_value = g_flags_get_first_value(flags_class, (guint)PYGLIB_PyLong_AsUnsignedLong(self));
if (flags_value)
retval = PYGLIB_PyUnicode_FromString(flags_value->value_nick);
else {
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index be76930b..ae513f82 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -115,22 +115,22 @@ _pygi_hash_pointer_to_arg (GIArgument *arg,
switch (type_tag) {
case GI_TYPE_TAG_INT8:
- arg->v_int8 = GPOINTER_TO_INT (arg->v_pointer);
+ arg->v_int8 = (gint8)GPOINTER_TO_INT (arg->v_pointer);
break;
case GI_TYPE_TAG_INT16:
- arg->v_int16 = GPOINTER_TO_INT (arg->v_pointer);
+ arg->v_int16 = (gint16)GPOINTER_TO_INT (arg->v_pointer);
break;
case GI_TYPE_TAG_INT32:
- arg->v_int32 = GPOINTER_TO_INT (arg->v_pointer);
+ arg->v_int32 = (gint32)GPOINTER_TO_INT (arg->v_pointer);
break;
case GI_TYPE_TAG_UINT8:
- arg->v_uint8 = GPOINTER_TO_UINT (arg->v_pointer);
+ arg->v_uint8 = (guint8)GPOINTER_TO_UINT (arg->v_pointer);
break;
case GI_TYPE_TAG_UINT16:
- arg->v_uint16 = GPOINTER_TO_UINT (arg->v_pointer);
+ arg->v_uint16 = (guint16)GPOINTER_TO_UINT (arg->v_pointer);
break;
case GI_TYPE_TAG_UINT32:
- arg->v_uint32 = GPOINTER_TO_UINT (arg->v_pointer);
+ arg->v_uint32 = (guint32)GPOINTER_TO_UINT (arg->v_pointer);
break;
case GI_TYPE_TAG_GTYPE:
arg->v_size = GPOINTER_TO_SIZE (arg->v_pointer);
@@ -198,7 +198,7 @@ _pygi_argument_array_length_marshal (gsize length_arg_index,
GValue *values = (GValue *)user_data1;
GICallableInfo *callable_info = (GICallableInfo *)user_data2;
- g_callable_info_load_arg (callable_info, length_arg_index, &length_arg_info);
+ g_callable_info_load_arg (callable_info, (gint)length_arg_index, &length_arg_info);
g_arg_info_load_type (&length_arg_info, &length_type_info);
length_arg = _pygi_argument_from_g_value (&(values[length_arg_index]),
@@ -271,7 +271,7 @@ _pygi_argument_to_array (GIArgument *arg,
if (G_UNLIKELY (array_length_policy == NULL)) {
g_critical ("Unable to determine array length for %p",
arg->v_pointer);
- g_array = g_array_new (is_zero_terminated, FALSE, item_size);
+ g_array = g_array_new (is_zero_terminated, FALSE, (guint)item_size);
*out_free_array = TRUE;
return g_array;
}
@@ -288,11 +288,11 @@ _pygi_argument_to_array (GIArgument *arg,
g_assert (length >= 0);
- g_array = g_array_new (is_zero_terminated, FALSE, item_size);
+ g_array = g_array_new (is_zero_terminated, FALSE, (guint)item_size);
g_free (g_array->data);
g_array->data = arg->v_pointer;
- g_array->len = length;
+ g_array->len = (guint)length;
*out_free_array = TRUE;
break;
case GI_ARRAY_TYPE_ARRAY:
@@ -337,13 +337,13 @@ _pygi_argument_from_object (PyObject *object,
switch (type_tag) {
case GI_TYPE_TAG_ARRAY:
{
- Py_ssize_t length;
+ Py_ssize_t py_length;
+ guint length, i;
gboolean is_zero_terminated;
GITypeInfo *item_type_info;
gsize item_size;
GArray *array;
GITransfer item_transfer;
- Py_ssize_t i;
if (object == Py_None) {
arg.v_pointer = NULL;
@@ -360,11 +360,18 @@ _pygi_argument_from_object (PyObject *object,
break;
}
- length = PySequence_Length (object);
- if (length < 0) {
+ py_length = PySequence_Length (object);
+ if (py_length < 0) {
+ break;
+ }
+
+ if (py_length > G_MAXUINT) {
+ PyErr_SetString (PyExc_ValueError, "array too large");
break;
}
+ length = (guint)py_length;
+
is_zero_terminated = g_type_info_is_zero_terminated (type_info);
item_type_info = g_type_info_get_param_type (type_info, 0);
@@ -374,7 +381,7 @@ _pygi_argument_from_object (PyObject *object,
else
item_size = sizeof (GIArgument);
- array = g_array_sized_new (is_zero_terminated, FALSE, item_size, length);
+ array = g_array_sized_new (is_zero_terminated, FALSE, (guint)item_size, length);
if (array == NULL) {
g_base_info_unref ( (GIBaseInfo *) item_type_info);
PyErr_NoMemory();
@@ -418,7 +425,7 @@ array_item_error:
GI_TRANSFER_NOTHING, GI_DIRECTION_IN);
array = NULL;
- _PyGI_ERROR_PREFIX ("Item %zd: ", i);
+ _PyGI_ERROR_PREFIX ("Item %u: ", i);
break;
}
@@ -477,16 +484,8 @@ array_success:
case GI_INFO_TYPE_ENUM:
case GI_INFO_TYPE_FLAGS:
{
- PyObject *int_;
-
- int_ = PYGLIB_PyNumber_Long (object);
- if (int_ == NULL) {
+ if (!pygi_gint_from_py (object, &arg.v_int))
break;
- }
-
- arg.v_int = PYGLIB_PyLong_AsLong (int_);
-
- Py_DECREF (int_);
break;
}
diff --git a/gi/pygi-array.c b/gi/pygi-array.c
index e0b2d431..640a4085 100644
--- a/gi/pygi-array.c
+++ b/gi/pygi-array.c
@@ -47,7 +47,7 @@ gi_argument_from_py_ssize_t (GIArgument *arg_out,
case GI_TYPE_TAG_INT8:
if (size_in >= G_MININT8 && size_in <= G_MAXINT8) {
- arg_out->v_int8 = size_in;
+ arg_out->v_int8 = (gint8)size_in;
return TRUE;
} else {
goto overflow;
@@ -55,7 +55,7 @@ gi_argument_from_py_ssize_t (GIArgument *arg_out,
case GI_TYPE_TAG_UINT8:
if (size_in >= 0 && size_in <= G_MAXUINT8) {
- arg_out->v_uint8 = size_in;
+ arg_out->v_uint8 = (guint8)size_in;
return TRUE;
} else {
goto overflow;
@@ -63,7 +63,7 @@ gi_argument_from_py_ssize_t (GIArgument *arg_out,
case GI_TYPE_TAG_INT16:
if (size_in >= G_MININT16 && size_in <= G_MAXINT16) {
- arg_out->v_int16 = size_in;
+ arg_out->v_int16 = (gint16)size_in;
return TRUE;
} else {
goto overflow;
@@ -71,7 +71,7 @@ gi_argument_from_py_ssize_t (GIArgument *arg_out,
case GI_TYPE_TAG_UINT16:
if (size_in >= 0 && size_in <= G_MAXUINT16) {
- arg_out->v_uint16 = size_in;
+ arg_out->v_uint16 = (guint16)size_in;
return TRUE;
} else {
goto overflow;
@@ -80,7 +80,7 @@ gi_argument_from_py_ssize_t (GIArgument *arg_out,
/* Ranges assume two's complement */
case GI_TYPE_TAG_INT32:
if (size_in >= G_MININT32 && size_in <= G_MAXINT32) {
- arg_out->v_int32 = size_in;
+ arg_out->v_int32 = (gint32)size_in;
return TRUE;
} else {
goto overflow;
@@ -88,7 +88,7 @@ gi_argument_from_py_ssize_t (GIArgument *arg_out,
case GI_TYPE_TAG_UINT32:
if (size_in >= 0 && (gsize)size_in <= G_MAXUINT32) {
- arg_out->v_uint32 = size_in;
+ arg_out->v_uint32 = (guint32)size_in;
return TRUE;
} else {
goto overflow;
@@ -184,10 +184,11 @@ _pygi_marshal_from_py_array (PyGIInvokeState *state,
gpointer *cleanup_data)
{
PyGIMarshalFromPyFunc from_py_marshaller;
- int i = 0;
+ guint i = 0;
gsize success_count = 0;
- Py_ssize_t length;
- gssize item_size;
+ Py_ssize_t py_length;
+ guint length;
+ guint item_size;
gboolean is_ptr_array;
GArray *array_ = NULL;
PyGISequenceCache *sequence_cache = (PyGISequenceCache *)arg_cache;
@@ -206,19 +207,26 @@ _pygi_marshal_from_py_array (PyGIInvokeState *state,
return FALSE;
}
- length = PySequence_Length (py_arg);
- if (length < 0)
+ py_length = PySequence_Length (py_arg);
+ if (py_length < 0)
return FALSE;
+ if (py_length > G_MAXUINT) {
+ PyErr_SetString (PyExc_ValueError, "Sequence too large");
+ return FALSE;
+ }
+
+ length = (guint)py_length;
+
if (array_cache->fixed_size >= 0 &&
array_cache->fixed_size != length) {
- PyErr_Format (PyExc_ValueError, "Must contain %zd items, not %zd",
+ PyErr_Format (PyExc_ValueError, "Must contain %zd items, not %u",
array_cache->fixed_size, length);
return FALSE;
}
- item_size = array_cache->item_size;
+ item_size = (guint)array_cache->item_size;
is_ptr_array = (array_cache->array_type == GI_ARRAY_TYPE_PTR_ARRAY);
if (is_ptr_array) {
array_ = (GArray *)g_ptr_array_sized_new (length);
@@ -379,14 +387,14 @@ err:
g_ptr_array_free ( ( GPtrArray *)array_, TRUE);
else
g_array_free (array_, TRUE);
- _PyGI_ERROR_PREFIX ("Item %i: ", i);
+ _PyGI_ERROR_PREFIX ("Item %u: ", i);
return FALSE;
array_success:
if (array_cache->len_arg_index >= 0) {
/* we have an child arg to handle */
PyGIArgCache *child_cache =
- _pygi_callable_cache_get_arg (callable_cache, array_cache->len_arg_index);
+ _pygi_callable_cache_get_arg (callable_cache, (guint)array_cache->len_arg_index);
if (!gi_argument_from_py_ssize_t (&state->args[child_cache->c_arg_index].arg_value,
length,
@@ -513,7 +521,7 @@ _pygi_marshal_to_py_array (PyGIInvokeState *state,
PyObject *py_obj = NULL;
PyGISequenceCache *seq_cache = (PyGISequenceCache *)arg_cache;
PyGIArgGArray *array_cache = (PyGIArgGArray *)arg_cache;
- gsize processed_items = 0;
+ guint processed_items = 0;
/* GArrays make it easier to iterate over arrays
* with different element sizes but requires that
@@ -535,7 +543,7 @@ _pygi_marshal_to_py_array (PyGIInvokeState *state,
} else {
GIArgument *len_arg = &state->args[array_cache->len_arg_index].arg_value;
PyGIArgCache *sub_cache = _pygi_callable_cache_get_arg (callable_cache,
- array_cache->len_arg_index);
+ (guint)array_cache->len_arg_index);
if (!gi_argument_to_gsize (len_arg, &len, sub_cache->type_tag)) {
return NULL;
@@ -544,7 +552,7 @@ _pygi_marshal_to_py_array (PyGIInvokeState *state,
array_ = g_array_new (FALSE,
FALSE,
- array_cache->item_size);
+ (guint)array_cache->item_size);
if (array_ == NULL) {
PyErr_NoMemory ();
@@ -557,7 +565,7 @@ _pygi_marshal_to_py_array (PyGIInvokeState *state,
if (array_->data != NULL)
g_free (array_->data);
array_->data = arg->v_pointer;
- array_->len = len;
+ array_->len = (guint)len;
} else {
array_ = arg->v_pointer;
}
@@ -707,14 +715,14 @@ _wrap_c_array (PyGIInvokeState *state,
array_ = g_array_new (FALSE,
FALSE,
- array_cache->item_size);
+ (guint)array_cache->item_size);
if (array_ == NULL)
return NULL;
g_free (array_->data);
array_->data = data;
- array_->len = len;
+ array_->len = (guint)len;
return array_;
}
@@ -811,7 +819,7 @@ pygi_arg_garray_len_arg_setup (PyGIArgCache *arg_cache,
PyGIArgCache *child_cache = NULL;
child_cache = _pygi_callable_cache_get_arg (callable_cache,
- seq_cache->len_arg_index);
+ (guint)seq_cache->len_arg_index);
if (child_cache == NULL) {
child_cache = pygi_arg_cache_alloc ();
} else {
@@ -851,11 +859,11 @@ pygi_arg_garray_len_arg_setup (PyGIArgCache *arg_cache,
* indexes of arguments after the index argument.
*/
if (seq_cache->len_arg_index < arg_index && direction & PYGI_DIRECTION_FROM_PYTHON) {
- gssize i;
+ guint i;
(*py_arg_index) -= 1;
callable_cache->n_py_args -= 1;
- for (i = seq_cache->len_arg_index + 1;
+ for (i = (guint)seq_cache->len_arg_index + 1;
(gsize)i < _pygi_callable_cache_args_len (callable_cache); i++) {
PyGIArgCache *update_cache = _pygi_callable_cache_get_arg (callable_cache, i);
if (update_cache == NULL)
@@ -865,7 +873,7 @@ pygi_arg_garray_len_arg_setup (PyGIArgCache *arg_cache,
}
}
- _pygi_callable_cache_set_arg (callable_cache, seq_cache->len_arg_index, child_cache);
+ _pygi_callable_cache_set_arg (callable_cache, (guint)seq_cache->len_arg_index, child_cache);
return child_cache;
}
diff --git a/gi/pygi-cache.c b/gi/pygi-cache.c
index eec6d666..667ccf6e 100644
--- a/gi/pygi-cache.c
+++ b/gi/pygi-cache.c
@@ -464,8 +464,8 @@ static gboolean
_callable_cache_generate_args_cache_real (PyGICallableCache *callable_cache,
GICallableInfo *callable_info)
{
- gssize i;
- gssize arg_index;
+ gint i;
+ guint arg_index;
GITypeInfo *return_info;
GITransfer return_transfer;
PyGIArgCache *return_cache;
@@ -500,8 +500,8 @@ _callable_cache_generate_args_cache_real (PyGICallableCache *callable_cache,
callable_cache->user_data_index = -1;
- for (i = 0, arg_index = callable_cache->args_offset;
- (gsize)arg_index < _pygi_callable_cache_args_len (callable_cache);
+ for (i = 0, arg_index = (guint)callable_cache->args_offset;
+ arg_index < _pygi_callable_cache_args_len (callable_cache);
i++, arg_index++) {
PyGIArgCache *arg_cache = NULL;
GIArgInfo *arg_info;
@@ -609,7 +609,7 @@ _callable_cache_generate_args_cache_real (PyGICallableCache *callable_cache,
/* Reverse loop through all the arguments to setup arg_name_list/hash
* and find the number of required arguments */
- for (i=((gssize)_pygi_callable_cache_args_len (callable_cache))-1; i >= 0; i--) {
+ for (i=(_pygi_callable_cache_args_len (callable_cache))-1; i >= 0; i--) {
PyGIArgCache *arg_cache = _pygi_callable_cache_get_arg (callable_cache, i);
if (arg_cache->meta_type != PYGI_META_ARG_TYPE_CHILD &&
@@ -734,7 +734,7 @@ _callable_cache_init (PyGICallableCache *cache,
g_free (warning);
}
- n_args = cache->args_offset + g_callable_info_get_n_args (callable_info);
+ n_args = (gint)cache->args_offset + g_callable_info_get_n_args (callable_info);
if (n_args >= 0) {
cache->args_cache = g_ptr_array_new_full (n_args, (GDestroyNotify) pygi_arg_cache_free);
diff --git a/gi/pygi-cache.h b/gi/pygi-cache.h
index 574563b6..fc5a6162 100644
--- a/gi/pygi-cache.h
+++ b/gi/pygi-cache.h
@@ -316,7 +316,10 @@ pygi_vfunc_cache_new (GICallableInfo *info);
PyGIClosureCache *
pygi_closure_cache_new (GICallableInfo *info);
-#define _pygi_callable_cache_args_len(cache) ((cache)->args_cache)->len
+inline static guint
+_pygi_callable_cache_args_len (PyGICallableCache *cache) {
+ return ((cache)->args_cache)->len;
+}
inline static PyGIArgCache *
_pygi_callable_cache_get_arg (PyGICallableCache *cache, guint index) {
diff --git a/gi/pygi-closure.c b/gi/pygi-closure.c
index b219971f..21105fc2 100644
--- a/gi/pygi-closure.c
+++ b/gi/pygi-closure.c
@@ -709,7 +709,7 @@ _pygi_marshal_from_py_interface_callback (PyGIInvokeState *state,
callback_cache = (PyGICallbackCache *)arg_cache;
if (callback_cache->user_data_index > 0) {
- user_data_cache = _pygi_callable_cache_get_arg (callable_cache, callback_cache->user_data_index);
+ user_data_cache = _pygi_callable_cache_get_arg (callable_cache, (guint)callback_cache->user_data_index);
if (user_data_cache->py_arg_index < state->n_py_in_args) {
/* py_user_data is a borrowed reference. */
py_user_data = PyTuple_GetItem (state->py_in_args, user_data_cache->py_arg_index);
@@ -771,7 +771,7 @@ _pygi_marshal_from_py_interface_callback (PyGIInvokeState *state,
* later on in _pygi_destroy_notify_callback_closure.
*/
if (callback_cache->destroy_notify_index > 0) {
- destroy_cache = _pygi_callable_cache_get_arg (callable_cache, callback_cache->destroy_notify_index);
+ destroy_cache = _pygi_callable_cache_get_arg (callable_cache, (guint)callback_cache->destroy_notify_index);
}
if (destroy_cache) {
@@ -897,7 +897,7 @@ pygi_arg_callback_setup_from_info (PyGICallbackCache *arg_cache,
user_data_arg_cache->meta_type = PYGI_META_ARG_TYPE_CHILD_WITH_PYARG;
user_data_arg_cache->direction = direction;
user_data_arg_cache->has_default = TRUE; /* always allow user data with a NULL default. */
- _pygi_callable_cache_set_arg (callable_cache, arg_cache->user_data_index,
+ _pygi_callable_cache_set_arg (callable_cache, (guint)arg_cache->user_data_index,
user_data_arg_cache);
}
@@ -905,7 +905,7 @@ pygi_arg_callback_setup_from_info (PyGICallbackCache *arg_cache,
PyGIArgCache *destroy_arg_cache = pygi_arg_cache_alloc ();
destroy_arg_cache->meta_type = PYGI_META_ARG_TYPE_CHILD;
destroy_arg_cache->direction = direction;
- _pygi_callable_cache_set_arg (callable_cache, arg_cache->destroy_notify_index,
+ _pygi_callable_cache_set_arg (callable_cache, (guint)arg_cache->destroy_notify_index,
destroy_arg_cache);
}
diff --git a/gi/pygi-enum-marshal.c b/gi/pygi-enum-marshal.c
index 29e05fbe..950b33b7 100644
--- a/gi/pygi-enum-marshal.c
+++ b/gi/pygi-enum-marshal.c
@@ -34,28 +34,28 @@ gi_argument_from_c_long (GIArgument *arg_out,
{
switch (type_tag) {
case GI_TYPE_TAG_INT8:
- arg_out->v_int8 = c_long_in;
+ arg_out->v_int8 = (gint8)c_long_in;
return TRUE;
case GI_TYPE_TAG_UINT8:
- arg_out->v_uint8 = c_long_in;
+ arg_out->v_uint8 = (guint8)c_long_in;
return TRUE;
case GI_TYPE_TAG_INT16:
- arg_out->v_int16 = c_long_in;
+ arg_out->v_int16 = (gint16)c_long_in;
return TRUE;
case GI_TYPE_TAG_UINT16:
- arg_out->v_uint16 = c_long_in;
+ arg_out->v_uint16 = (guint16)c_long_in;
return TRUE;
case GI_TYPE_TAG_INT32:
- arg_out->v_int32 = c_long_in;
+ arg_out->v_int32 = (gint32)c_long_in;
return TRUE;
case GI_TYPE_TAG_UINT32:
- arg_out->v_uint32 = c_long_in;
+ arg_out->v_uint32 = (guint32)c_long_in;
return TRUE;
case GI_TYPE_TAG_INT64:
- arg_out->v_int64 = c_long_in;
+ arg_out->v_int64 = (gint64)c_long_in;
return TRUE;
case GI_TYPE_TAG_UINT64:
- arg_out->v_uint64 = c_long_in;
+ arg_out->v_uint64 = (guint64)c_long_in;
return TRUE;
default:
PyErr_Format (PyExc_TypeError,
@@ -244,7 +244,7 @@ _pygi_marshal_to_py_interface_enum (PyGIInvokeState *state,
if (iface_cache->g_type == G_TYPE_NONE) {
py_obj = PyObject_CallFunction (iface_cache->py_type, "l", c_long);
} else {
- py_obj = pyg_enum_from_gtype (iface_cache->g_type, c_long);
+ py_obj = pyg_enum_from_gtype (iface_cache->g_type, (gint)c_long);
}
g_base_info_unref (interface);
return py_obj;
@@ -293,7 +293,7 @@ _pygi_marshal_to_py_interface_flags (PyGIInvokeState *state,
Py_DECREF (py_args);
Py_DECREF (py_type);
} else {
- py_obj = pyg_flags_from_gtype (iface_cache->g_type, c_long);
+ py_obj = pyg_flags_from_gtype (iface_cache->g_type, (guint)c_long);
}
return py_obj;
diff --git a/gi/pygi-info.c b/gi/pygi-info.c
index d8ddcc77..d52be766 100644
--- a/gi/pygi-info.c
+++ b/gi/pygi-info.c
@@ -1323,8 +1323,8 @@ gboolean
pygi_g_struct_info_is_simple (GIStructInfo *struct_info)
{
gboolean is_simple;
- gsize n_field_infos;
- gsize i;
+ gint n_field_infos;
+ gint i;
is_simple = TRUE;
@@ -1771,13 +1771,13 @@ _struct_field_array_length_marshal (gsize length_index,
switch (g_base_info_get_type (container_info)) {
case GI_INFO_TYPE_UNION:
- array_len_field = g_union_info_get_field ((GIUnionInfo *)container_info, length_index);
+ array_len_field = g_union_info_get_field ((GIUnionInfo *)container_info, (gint)length_index);
break;
case GI_INFO_TYPE_STRUCT:
- array_len_field = g_struct_info_get_field ((GIStructInfo *)container_info, length_index);
+ array_len_field = g_struct_info_get_field ((GIStructInfo *)container_info, (gint)length_index);
break;
case GI_INFO_TYPE_OBJECT:
- array_len_field = g_object_info_get_field ((GIObjectInfo *)container_info, length_index);
+ array_len_field = g_object_info_get_field ((GIObjectInfo *)container_info, (gint)length_index);
break;
default:
/* Other types don't have fields. */
diff --git a/gi/pygi-invoke.c b/gi/pygi-invoke.c
index 286a043d..d5956c66 100644
--- a/gi/pygi-invoke.c
+++ b/gi/pygi-invoke.c
@@ -356,7 +356,7 @@ _caller_alloc (PyGIArgCache *arg_cache, GIArgument *arg)
} else if (arg_cache->type_tag == GI_TYPE_TAG_ARRAY) {
PyGIArgGArray *array_cache = (PyGIArgGArray *)arg_cache;
- arg->v_pointer = g_array_new (TRUE, TRUE, array_cache->item_size);
+ arg->v_pointer = g_array_new (TRUE, TRUE, (guint)array_cache->item_size);
} else {
return FALSE;
}
diff --git a/gi/pygi-list.c b/gi/pygi-list.c
index e8808fc2..b2986231 100644
--- a/gi/pygi-list.c
+++ b/gi/pygi-list.c
@@ -238,8 +238,8 @@ _pygi_marshal_to_py_glist (PyGIInvokeState *state,
gpointer *cleanup_data)
{
GList *list_;
- gsize length;
- gsize i;
+ guint length;
+ guint i;
GPtrArray *item_cleanups;
PyGIMarshalToPyFunc item_to_py_marshaller;
@@ -278,7 +278,7 @@ _pygi_marshal_to_py_glist (PyGIInvokeState *state,
if (py_item == NULL) {
Py_CLEAR (py_obj);
- _PyGI_ERROR_PREFIX ("Item %zu: ", i);
+ _PyGI_ERROR_PREFIX ("Item %u: ", i);
g_ptr_array_unref (item_cleanups);
return NULL;
}
@@ -297,8 +297,8 @@ _pygi_marshal_to_py_gslist (PyGIInvokeState *state,
gpointer *cleanup_data)
{
GSList *list_;
- gsize length;
- gsize i;
+ guint length;
+ guint i;
GPtrArray *item_cleanups;
PyGIMarshalToPyFunc item_to_py_marshaller;
@@ -336,7 +336,7 @@ _pygi_marshal_to_py_gslist (PyGIInvokeState *state,
g_ptr_array_index (item_cleanups, i) = item_cleanup_data;
if (py_item == NULL) {
Py_CLEAR (py_obj);
- _PyGI_ERROR_PREFIX ("Item %zu: ", i);
+ _PyGI_ERROR_PREFIX ("Item %u: ", i);
g_ptr_array_unref (item_cleanups);
return NULL;
}
diff --git a/gi/pygi-marshal-cleanup.c b/gi/pygi-marshal-cleanup.c
index 96bbad60..332b08be 100644
--- a/gi/pygi-marshal-cleanup.c
+++ b/gi/pygi-marshal-cleanup.c
@@ -92,14 +92,14 @@ void
pygi_marshal_cleanup_args_from_py_marshal_success (PyGIInvokeState *state,
PyGICallableCache *cache)
{
- gssize i;
+ guint i;
PyObject *error_type, *error_value, *error_traceback;
gboolean have_error = !!PyErr_Occurred ();
if (have_error)
PyErr_Fetch (&error_type, &error_value, &error_traceback);
- for (i = 0; (gsize)i < _pygi_callable_cache_args_len (cache); i++) {
+ for (i = 0; i < _pygi_callable_cache_args_len (cache); i++) {
PyGIArgCache *arg_cache = _pygi_callable_cache_get_arg (cache, i);
PyGIMarshalCleanupFunc cleanup_func = arg_cache->from_py_cleanup;
gpointer cleanup_data = state->args[i].arg_cleanup_data;
@@ -179,7 +179,7 @@ pygi_marshal_cleanup_args_from_py_parameter_fail (PyGIInvokeState *state,
PyGICallableCache *cache,
gssize failed_arg_index)
{
- gssize i;
+ guint i;
PyObject *error_type, *error_value, *error_traceback;
gboolean have_error = !!PyErr_Occurred ();
@@ -188,7 +188,7 @@ pygi_marshal_cleanup_args_from_py_parameter_fail (PyGIInvokeState *state,
state->failed = TRUE;
- for (i = 0; (gsize)i < _pygi_callable_cache_args_len (cache) && i <= failed_arg_index; i++) {
+ for (i = 0; i < _pygi_callable_cache_args_len (cache) && i <= failed_arg_index; i++) {
PyGIArgCache *arg_cache = _pygi_callable_cache_get_arg (cache, i);
PyGIMarshalCleanupFunc cleanup_func = arg_cache->from_py_cleanup;
gpointer cleanup_data = state->args[i].arg_cleanup_data;
diff --git a/gi/pygi-property.c b/gi/pygi-property.c
index 18d10136..b2f36c67 100644
--- a/gi/pygi-property.c
+++ b/gi/pygi-property.c
@@ -33,7 +33,7 @@ static GIPropertyInfo *
lookup_property_from_object_info (GIObjectInfo *info, const gchar *attr_name)
{
gssize n_infos;
- gssize i;
+ gint i;
n_infos = g_object_info_get_n_properties (info);
for (i = 0; i < n_infos; i++) {
@@ -57,7 +57,7 @@ lookup_property_from_interface_info (GIInterfaceInfo *info,
const gchar *attr_name)
{
gssize n_infos;
- gssize i;
+ gint i;
n_infos = g_interface_info_get_n_properties (info);
for (i = 0; i < n_infos; i++) {
diff --git a/gi/pygi-repository.c b/gi/pygi-repository.c
index 146f4e70..133f89c3 100644
--- a/gi/pygi-repository.c
+++ b/gi/pygi-repository.c
@@ -181,7 +181,7 @@ _wrap_g_irepository_get_infos (PyGIRepository *self,
const char *namespace_;
gssize n_infos;
PyObject *infos;
- gssize i;
+ gint i;
if (!PyArg_ParseTupleAndKeywords (args, kwargs, "s:Repository.get_infos",
kwlist, &namespace_)) {
diff --git a/gi/pygi-source.c b/gi/pygi-source.c
index d09849f0..b49b7d58 100644
--- a/gi/pygi-source.c
+++ b/gi/pygi-source.c
@@ -27,6 +27,7 @@
#include "pygi-info.h"
#include "pygi-boxed.h"
#include "pygi-type.h"
+#include "pygi-basictype.h"
#include "pygboxed.h"
#include "pygi-source.h"
@@ -65,13 +66,16 @@ pyg_source_prepare(GSource *source, gint *timeout)
goto bail;
}
- ret = PyObject_IsTrue(PyTuple_GET_ITEM(t, 0));
- *timeout = PYGLIB_PyLong_AsLong(PyTuple_GET_ITEM(t, 1));
+ if (!pygi_gboolean_from_py (PyTuple_GET_ITEM(t, 0), &ret)) {
+ ret = FALSE;
+ goto bail;
+ }
- if (*timeout == -1 && PyErr_Occurred()) {
- ret = FALSE;
- goto bail;
- }
+ if (!pygi_gint_from_py (PyTuple_GET_ITEM(t, 1), timeout))
+ {
+ ret = FALSE;
+ goto bail;
+ }
got_err = FALSE;
@@ -229,7 +233,7 @@ PyObject *
pyg_source_set_callback(PyGObject *self_module, PyObject *args)
{
PyObject *self, *first, *callback, *cbargs = NULL, *data;
- gint len;
+ Py_ssize_t len;
len = PyTuple_Size (args);
if (len < 2) {
diff --git a/gi/pygi-type.c b/gi/pygi-type.c
index 38c0780e..8c75c06f 100644
--- a/gi/pygi-type.c
+++ b/gi/pygi-type.c
@@ -595,8 +595,10 @@ pyg_enum_get_value(GType enum_type, PyObject *obj, gint *val)
*val = 0;
res = 0;
} else if (PYGLIB_PyLong_Check(obj)) {
- *val = PYGLIB_PyLong_AsLong(obj);
- res = 0;
+ if (!pygi_gint_from_py (obj, val))
+ res = -1;
+ else
+ res = 0;
if (PyObject_TypeCheck(obj, &PyGEnum_Type) && ((PyGEnum *) obj)->gtype != enum_type) {
g_warning("expected enumeration type %s, but got %s instead",
@@ -605,8 +607,10 @@ pyg_enum_get_value(GType enum_type, PyObject *obj, gint *val)
}
/* Dumb code duplication, but probably not worth it to have yet another macro. */
} else if (PyLong_Check(obj)) {
- *val = PyLong_AsLong(obj);
- res = 0;
+ if (!pygi_gint_from_py (obj, val))
+ res = -1;
+ else
+ res = 0;
if (PyObject_TypeCheck(obj, &PyGEnum_Type) && ((PyGEnum *) obj)->gtype != enum_type) {
g_warning("expected enumeration type %s, but got %s instead",
@@ -668,11 +672,11 @@ pyg_flags_get_value(GType flag_type, PyObject *obj, guint *val)
*val = 0;
res = 0;
} else if (PYGLIB_PyLong_Check(obj)) {
- *val = PYGLIB_PyLong_AsUnsignedLong(obj);
- res = 0;
+ if (pygi_guint_from_py (obj, val))
+ res = 0;
} else if (PyLong_Check(obj)) {
- *val = PyLong_AsLongLong(obj);
- res = 0;
+ if (pygi_guint_from_py (obj, val))
+ res = 0;
} else if (PYGLIB_PyUnicode_Check(obj)) {
GFlagsValue *info;
char *str = PYGLIB_PyUnicode_AsString(obj);
@@ -696,7 +700,7 @@ pyg_flags_get_value(GType flag_type, PyObject *obj, guint *val)
res = -1;
}
} else if (PyTuple_Check(obj)) {
- int i, len;
+ Py_ssize_t i, len;
len = PyTuple_Size(obj);
*val = 0;
@@ -993,7 +997,7 @@ pyg_signal_class_closure_marshal(GClosure *closure,
gchar *method_name, *tmp;
PyObject *method;
PyObject *params, *ret;
- guint i, len;
+ Py_ssize_t i, len;
state = PyGILState_Ensure();
diff --git a/gi/pygi-util.c b/gi/pygi-util.c
index 2b60694b..734d02fc 100644
--- a/gi/pygi-util.c
+++ b/gi/pygi-util.c
@@ -105,8 +105,7 @@ pyg_ptr_richcompare(void* a, void *b, int op)
const gchar *
pyg_constant_strip_prefix(const gchar *name, const gchar *strip_prefix)
{
- size_t prefix_len;
- guint i;
+ size_t prefix_len, i;
prefix_len = strlen(strip_prefix);
diff --git a/gi/pygi-value.c b/gi/pygi-value.c
index 9fc04143..7d1198d0 100644
--- a/gi/pygi-value.c
+++ b/gi/pygi-value.c
@@ -52,9 +52,9 @@ _pygi_argument_from_g_value(const GValue *value,
case GI_TYPE_TAG_INT16:
case GI_TYPE_TAG_INT32:
if (g_type_is_a (G_VALUE_TYPE (value), G_TYPE_LONG))
- arg.v_int = g_value_get_long (value);
+ arg.v_int32 = (gint32)g_value_get_long (value);
else
- arg.v_int = g_value_get_int (value);
+ arg.v_int32 = (gint32)g_value_get_int (value);
break;
case GI_TYPE_TAG_INT64:
if (g_type_is_a (G_VALUE_TYPE (value), G_TYPE_LONG))
@@ -68,9 +68,9 @@ _pygi_argument_from_g_value(const GValue *value,
case GI_TYPE_TAG_UINT16:
case GI_TYPE_TAG_UINT32:
if (g_type_is_a (G_VALUE_TYPE (value), G_TYPE_ULONG))
- arg.v_uint = g_value_get_ulong (value);
+ arg.v_uint32 = (guint32)g_value_get_ulong (value);
else
- arg.v_uint = g_value_get_uint (value);
+ arg.v_uint32 = (guint32)g_value_get_uint (value);
break;
case GI_TYPE_TAG_UINT64:
if (g_type_is_a (G_VALUE_TYPE (value), G_TYPE_ULONG))
@@ -245,9 +245,8 @@ static int
pyg_array_from_pyobject(GValue *value,
PyObject *obj)
{
- int len;
+ Py_ssize_t len, i;
GArray *array;
- int i;
len = PySequence_Length(obj);
if (len == -1) {
diff --git a/gi/pygobject-object.c b/gi/pygobject-object.c
index 64d1d451..caf41f64 100644
--- a/gi/pygobject-object.c
+++ b/gi/pygobject-object.c
@@ -896,8 +896,8 @@ pygobject_find_slot_for(PyTypeObject *type, PyObject *bases, int slot_offset,
#define TYPE_SLOT(type) (* (void **) (((char *) (type)) + slot_offset))
void *found_slot = NULL;
- int num_bases = PyTuple_Size(bases);
- int i;
+ Py_ssize_t num_bases = PyTuple_Size(bases);
+ Py_ssize_t i;
if (check_for_present && TYPE_SLOT(type) != NULL) {
/* We are requested to check if there is any custom slot value
@@ -1375,7 +1375,7 @@ pygobject_get_property (PyGObject *self, PyObject *args)
static PyObject *
pygobject_get_properties(PyGObject *self, PyObject *args)
{
- int len, i;
+ Py_ssize_t len, i;
PyObject *tuple;
if ((len = PyTuple_Size(args)) < 1) {
@@ -1710,7 +1710,7 @@ pygobject_connect(PyGObject *self, PyObject *args)
{
PyObject *first, *callback, *extra_args, *ret;
gchar *name;
- guint len;
+ Py_ssize_t len;
len = PyTuple_Size(args);
if (len < 2) {
@@ -2024,7 +2024,7 @@ pygobject_chain_from_overridden(PyGObject *self, PyObject *args)
static PyObject *
pygobject_weak_ref(PyGObject *self, PyObject *args)
{
- int len;
+ Py_ssize_t len;
PyObject *callback = NULL, *user_data = NULL;
PyObject *retval;
diff --git a/gi/pygoptioncontext.c b/gi/pygoptioncontext.c
index cf34aad2..d807e0a1 100644
--- a/gi/pygoptioncontext.c
+++ b/gi/pygoptioncontext.c
@@ -161,7 +161,7 @@ pyg_option_context_parse(PyGOptionContext *self,
original = g_strdupv(argv_content);
g_assert(argv_length <= G_MAXINT);
- argv_length_int = argv_length;
+ argv_length_int = (gint)argv_length;
Py_BEGIN_ALLOW_THREADS;
result = g_option_context_parse(self->context, &argv_length_int, &argv_content,
&error);
diff --git a/setup.py b/setup.py
index 52af46f2..1ef7b90a 100755
--- a/setup.py
+++ b/setup.py
@@ -799,6 +799,7 @@ def add_ext_compiler_flags(ext, compiler, _cache={}):
"-Wundef",
"-Wunused-but-set-variable",
"-Wwrite-strings",
+ "-Wconversion",
]
args += [
@@ -806,6 +807,7 @@ def add_ext_compiler_flags(ext, compiler, _cache={}):
"-Wno-missing-field-initializers",
"-Wno-unused-parameter",
"-Wno-discarded-qualifiers",
+ "-Wno-sign-conversion",
]
# silence clang for unused gcc CFLAGS added by Debian
diff --git a/tests/testhelpermodule.c b/tests/testhelpermodule.c
index 0975bc44..1c8f03ed 100644
--- a/tests/testhelpermodule.c
+++ b/tests/testhelpermodule.c
@@ -29,8 +29,8 @@ test_type_get_type(void)
type_info = (GTypeInfo *)g_new0(GTypeInfo, 1);
g_type_query(parent_type, &query);
- type_info->class_size = query.class_size;
- type_info->instance_size = query.instance_size;
+ type_info->class_size = (guint16)query.class_size;
+ type_info->instance_size = (guint16)query.instance_size;
gtype = g_type_register_static(parent_type,
"TestType", type_info, 0);