[pygobject] Fix various compiler warnings for 32bit builds
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Fix various compiler warnings for 32bit builds
- Date: Fri, 24 Mar 2017 07:55:58 +0000 (UTC)
commit 5399bb785e625c36025d6bc1e5cf2b5519759d0d
Author: Christoph Reiter <creiter src gnome org>
Date: Wed Mar 22 19:24:22 2017 +0100
Fix various compiler warnings for 32bit builds
Due to the switch to AX_COMPILER_FLAGS which adds some more
warning flags. I didn't notice these as they only get triggered
on 32bit builds. Tested with gcc 6.3 and clang 3.9.
https://bugzilla.gnome.org/show_bug.cgi?id=780409
gi/gimodule.c | 1 +
gi/pygboxed.c | 1 +
gi/pygenum.c | 2 +-
gi/pygi-argument.c | 2 ++
gi/pygi-array.c | 4 ++--
gi/pygi-cache.c | 6 +++---
gi/pygi-closure.c | 4 ++--
gi/pygi-foreign-cairo.c | 2 +-
gi/pygi-invoke.c | 8 ++++----
gi/pygi-marshal-cleanup.c | 4 ++--
gi/pygi-signal-closure.h | 1 +
gi/pygi-util.h | 1 +
gi/pygi-value.h | 2 +-
gi/pygobject-object.c | 4 ++--
gi/pygtype.h | 2 +-
15 files changed, 25 insertions(+), 19 deletions(-)
---
diff --git a/gi/gimodule.c b/gi/gimodule.c
index 50a3e05..65e10e4 100644
--- a/gi/gimodule.c
+++ b/gi/gimodule.c
@@ -21,6 +21,7 @@
* USA
*/
+#include <Python.h>
#include <glib-object.h>
#include "config.h"
diff --git a/gi/pygboxed.c b/gi/pygboxed.c
index d168a9e..6bf2376 100644
--- a/gi/pygboxed.c
+++ b/gi/pygboxed.c
@@ -22,6 +22,7 @@
# include <config.h>
#endif
+#include <Python.h>
#include <glib-object.h>
#include <pyglib.h>
diff --git a/gi/pygenum.c b/gi/pygenum.c
index 522e2ef..6897d53 100644
--- a/gi/pygenum.c
+++ b/gi/pygenum.c
@@ -165,7 +165,7 @@ pyg_enum_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
* values might not have been that good", but we need to keep
* backward compatibility.
*/
- if (!PyDict_Check(values) || PyDict_Size(values) > eclass->n_values) {
+ if (!PyDict_Check(values) || (gsize)PyDict_Size(values) > eclass->n_values) {
PyErr_SetString(PyExc_TypeError, "__enum_values__ badly formed");
Py_DECREF(values);
g_type_class_unref(eclass);
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index a24318b..e6f9346 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -19,6 +19,8 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
+#include <Python.h>
+
#include <string.h>
#include <time.h>
diff --git a/gi/pygi-array.c b/gi/pygi-array.c
index 6c8279d..8dfab12 100644
--- a/gi/pygi-array.c
+++ b/gi/pygi-array.c
@@ -87,7 +87,7 @@ gi_argument_from_py_ssize_t (GIArgument *arg_out,
}
case GI_TYPE_TAG_UINT32:
- if (size_in >= 0 && size_in <= G_MAXUINT32) {
+ if (size_in >= 0 && (gsize)size_in <= G_MAXUINT32) {
arg_out->v_uint32 = size_in;
return TRUE;
} else {
@@ -832,7 +832,7 @@ pygi_arg_garray_len_arg_setup (PyGIArgCache *arg_cache,
callable_cache->n_py_args -= 1;
for (i = seq_cache->len_arg_index + 1;
- i < _pygi_callable_cache_args_len (callable_cache); i++) {
+ (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)
break;
diff --git a/gi/pygi-cache.c b/gi/pygi-cache.c
index a106742..82a6182 100644
--- a/gi/pygi-cache.c
+++ b/gi/pygi-cache.c
@@ -501,7 +501,7 @@ _callable_cache_generate_args_cache_real (PyGICallableCache *callable_cache,
callable_cache->user_data_index = -1;
for (i = 0, arg_index = callable_cache->args_offset;
- arg_index < _pygi_callable_cache_args_len (callable_cache);
+ (gsize)arg_index < _pygi_callable_cache_args_len (callable_cache);
i++, arg_index++) {
PyGIArgCache *arg_cache = NULL;
GIArgInfo *arg_info;
@@ -1143,7 +1143,7 @@ pygi_closure_cache_new (GICallableInfo *info)
*
* See: https://bugzilla.gnome.org/show_bug.cgi?id=652115
*/
- for (i = 0; i < _pygi_callable_cache_args_len (callable_cache); i++) {
+ for (i = 0; (gsize)i < _pygi_callable_cache_args_len (callable_cache); i++) {
PyGIArgCache *arg_cache;
PyGIArgGArray *garray_cache;
PyGIArgCache *len_arg_cache;
@@ -1166,7 +1166,7 @@ pygi_closure_cache_new (GICallableInfo *info)
* do not recognize user_data/data arguments correctly.
*/
if (callable_cache->user_data_index == -1) {
- for (i = 0; i < _pygi_callable_cache_args_len (callable_cache); i++) {
+ for (i = 0; (gsize)i < _pygi_callable_cache_args_len (callable_cache); i++) {
PyGIArgCache *arg_cache;
arg_cache = g_ptr_array_index (callable_cache->args_cache, i);
diff --git a/gi/pygi-closure.c b/gi/pygi-closure.c
index 21a0464..1cc2ec0 100644
--- a/gi/pygi-closure.c
+++ b/gi/pygi-closure.c
@@ -345,7 +345,7 @@ _pygi_closure_convert_arguments (PyGIInvokeState *state,
gssize n_in_args = 0;
gssize i;
- for (i = 0; i < _pygi_callable_cache_args_len (cache); i++) {
+ for (i = 0; (gsize)i < _pygi_callable_cache_args_len (cache); i++) {
PyGIArgCache *arg_cache;
arg_cache = g_ptr_array_index (cache->args_cache, i);
@@ -447,7 +447,7 @@ _pygi_closure_set_out_arguments (PyGIInvokeState *state,
i_py_retval++;
}
- for (i = 0; i < _pygi_callable_cache_args_len (cache); i++) {
+ for (i = 0; (gsize)i < _pygi_callable_cache_args_len (cache); i++) {
PyGIArgCache *arg_cache = g_ptr_array_index (cache->args_cache, i);
if (arg_cache->direction & PYGI_DIRECTION_FROM_PYTHON) {
diff --git a/gi/pygi-foreign-cairo.c b/gi/pygi-foreign-cairo.c
index 3ad3a99..ad1d5c0 100644
--- a/gi/pygi-foreign-cairo.c
+++ b/gi/pygi-foreign-cairo.c
@@ -21,8 +21,8 @@
* IN THE SOFTWARE.
*/
-#include <cairo.h>
#include <Python.h>
+#include <cairo.h>
#if PY_VERSION_HEX < 0x03000000
#include <pycairo.h>
diff --git a/gi/pygi-invoke.c b/gi/pygi-invoke.c
index 2c6a186..fd9e474 100644
--- a/gi/pygi-invoke.c
+++ b/gi/pygi-invoke.c
@@ -89,7 +89,7 @@ _py_args_combine_and_check_length (PyGICallableCache *cache,
{
PyObject *combined_py_args = NULL;
Py_ssize_t n_py_args, n_py_kwargs, i;
- guint n_expected_args = cache->n_py_args;
+ gssize n_expected_args = cache->n_py_args;
GSList *l;
n_py_args = PyTuple_GET_SIZE (py_args);
@@ -107,7 +107,7 @@ _py_args_combine_and_check_length (PyGICallableCache *cache,
if (cache->user_data_varargs_index < 0 && n_expected_args < n_py_args) {
char *full_name = pygi_callable_cache_get_full_name (cache);
PyErr_Format (PyExc_TypeError,
- "%.200s() takes exactly %d %sargument%s (%zd given)",
+ "%.200s() takes exactly %zd %sargument%s (%zd given)",
full_name,
n_expected_args,
n_py_kwargs > 0 ? "non-keyword " : "",
@@ -194,7 +194,7 @@ _py_args_combine_and_check_length (PyGICallableCache *cache,
} else {
char *full_name = pygi_callable_cache_get_full_name (cache);
PyErr_Format (PyExc_TypeError,
- "%.200s() takes exactly %d %sargument%s (%zd given)",
+ "%.200s() takes exactly %zd %sargument%s (%zd given)",
full_name,
n_expected_args,
n_py_kwargs > 0 ? "non-keyword " : "",
@@ -414,7 +414,7 @@ _invoke_marshal_in_args (PyGIInvokeState *state, PyGIFunctionCache *function_cac
return FALSE;
}
- for (i = 0; i < _pygi_callable_cache_args_len (cache); i++) {
+ for (i = 0; (gsize)i < _pygi_callable_cache_args_len (cache); i++) {
GIArgument *c_arg = &state->args[i].arg_value;
PyGIArgCache *arg_cache = g_ptr_array_index (cache->args_cache, i);
PyObject *py_arg = NULL;
diff --git a/gi/pygi-marshal-cleanup.c b/gi/pygi-marshal-cleanup.c
index b4d04bc..906be58 100644
--- a/gi/pygi-marshal-cleanup.c
+++ b/gi/pygi-marshal-cleanup.c
@@ -94,7 +94,7 @@ pygi_marshal_cleanup_args_from_py_marshal_success (PyGIInvokeState *state,
{
gssize i;
- for (i = 0; i < _pygi_callable_cache_args_len (cache); i++) {
+ for (i = 0; (gsize)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;
@@ -164,7 +164,7 @@ pygi_marshal_cleanup_args_from_py_parameter_fail (PyGIInvokeState *state,
state->failed = TRUE;
- for (i = 0; i < _pygi_callable_cache_args_len (cache) && i <= failed_arg_index; i++) {
+ for (i = 0; (gsize)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-signal-closure.h b/gi/pygi-signal-closure.h
index 92e1870..9ba8d6d 100644
--- a/gi/pygi-signal-closure.h
+++ b/gi/pygi-signal-closure.h
@@ -24,6 +24,7 @@
#ifndef __PYGI_SIGNAL_CLOSURE_H__
#define __PYGI_SIGNAL_CLOSURE_H__
+#include <Python.h>
#include <girepository.h>
#include "pygobject-internal.h"
diff --git a/gi/pygi-util.h b/gi/pygi-util.h
index c7a6ca7..c7bc1d5 100644
--- a/gi/pygi-util.h
+++ b/gi/pygi-util.h
@@ -1,6 +1,7 @@
#ifndef __PYGI_UTIL_H__
#define __PYGI_UTIL_H__
+#include <Python.h>
#include <glib.h>
#include "pygobject-internal.h"
#include <pyglib-python-compat.h>
diff --git a/gi/pygi-value.h b/gi/pygi-value.h
index ce2e902..5b2eac1 100644
--- a/gi/pygi-value.h
+++ b/gi/pygi-value.h
@@ -18,9 +18,9 @@
#ifndef __PYGI_VALUE_H__
#define __PYGI_VALUE_H__
+#include <Python.h>
#include <glib-object.h>
#include <girepository.h>
-#include <Python.h>
G_BEGIN_DECLS
diff --git a/gi/pygobject-object.c b/gi/pygobject-object.c
index 25731b2..1c97594 100644
--- a/gi/pygobject-object.c
+++ b/gi/pygobject-object.c
@@ -1837,7 +1837,7 @@ pygobject_emit(PyGObject *self, PyObject *args)
return NULL;
}
g_signal_query(signal_id, &query);
- if (len != query.n_params + 1) {
+ if ((gsize)len != query.n_params + 1) {
gchar buf[128];
g_snprintf(buf, sizeof(buf),
@@ -1922,7 +1922,7 @@ pygobject_chain_from_overridden(PyGObject *self, PyObject *args)
return NULL;
}
g_signal_query(signal_id, &query);
- if (len != query.n_params) {
+ if (len < 0 || (gsize)len != query.n_params) {
gchar buf[128];
g_snprintf(buf, sizeof(buf),
diff --git a/gi/pygtype.h b/gi/pygtype.h
index 82c2523..7caf77c 100644
--- a/gi/pygtype.h
+++ b/gi/pygtype.h
@@ -21,8 +21,8 @@
#ifndef __PYGOBJECT_TYPE_H__
#define __PYGOBJECT_TYPE_H__
-#include <glib-object.h>
#include <Python.h>
+#include <glib-object.h>
#include "pygobject-internal.h"
#define PYGOBJECT_REGISTER_GTYPE(d, type, name, gtype) \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]