[pygobject] Fix warnings.



commit 0ee58113ecbea72784c52de928c041fc8fc88984
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Thu Dec 23 00:10:41 2010 +0100

    Fix warnings.

 gi/pygi-argument.c          |   16 +++++++---------
 gi/pygi-foreign-cairo.c     |   13 ++-----------
 gio/gfile.override          |    5 ++---
 glib/pyglib-python-compat.h |    3 +++
 glib/pyglib.c               |    2 +-
 glib/pygmainloop.c          |    3 ++-
 6 files changed, 17 insertions(+), 25 deletions(-)
---
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index 1479afd..ec0fd5f 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -397,7 +397,7 @@ check_number_release:
             }
 
             if (size != 1) {
-                PyErr_Format (PyExc_TypeError, "Must be a one character string, not %i characters",
+                PyErr_Format (PyExc_TypeError, "Must be a one character string, not %ld characters",
                               size);
                 retval = 0;
                 break;
@@ -721,8 +721,7 @@ _pygi_argument_from_object (PyObject   *object,
                 value = PyInt_AS_LONG (number);
             } else
 #endif
-            if (PyLong_Check (number))
-                value = PyLong_AsUnsignedLongLong (number);
+            value = PyLong_AsUnsignedLongLong (number);
 
             arg.v_uint64 = value;
 
@@ -743,10 +742,9 @@ _pygi_argument_from_object (PyObject   *object,
 #if PY_VERSION_HEX < 0x03000000
             if (PyInt_Check (number)) {
                 value = PyInt_AS_LONG (number);
-            } else 
-#endif 
-            if (PyLong_Check (number))
-                value = PyLong_AsLongLong (number);
+            } else
+#endif
+            value = PyLong_AsLongLong (number);
 
             arg.v_int64 = value;
 
@@ -1348,10 +1346,10 @@ _pygi_argument_to_object (GIArgument  *arg,
             if (arg->v_uint32 == 0) {
                 object = PYGLIB_PyUnicode_FromString ("");
             } else if (g_unichar_validate (arg->v_uint32)) {
-                gchar utf8[7];
+                gchar utf8[6];
                 gint bytes;
 
-                bytes = g_unichar_to_utf8 (arg->v_uint32, &utf8);
+                bytes = g_unichar_to_utf8 (arg->v_uint32, utf8);
                 object = PYGLIB_PyUnicode_FromStringAndSize ((char*)utf8, bytes);
             } else {
                 /* TODO: Convert the error to an exception. */
diff --git a/gi/pygi-foreign-cairo.c b/gi/pygi-foreign-cairo.c
index ada59bf..babe8b4 100644
--- a/gi/pygi-foreign-cairo.c
+++ b/gi/pygi-foreign-cairo.c
@@ -126,7 +126,7 @@ cairo_surface_release (GIBaseInfo *base_info,
     }                                   \
     if (l > INT_MAX || l < INT_MIN) {   \
         Py_DECREF(item);                \
-        PyErr_Format(PyExc_ValueError, "integer %l is out of range", l); \
+        PyErr_Format(PyExc_ValueError, "integer %ld is out of range", l); \
         goto err;                       \
     }                                   \
     i = (int)l;                         \
@@ -213,7 +213,7 @@ PYGLIB_MODULE_START(_gi_cairo, "_gi_cairo")
 {
     Pycairo_IMPORT;
     if (Pycairo_CAPI == NULL)
-        return 0;
+        return PYGLIB_MODULE_ERROR_RETURN;
 
     pygi_register_foreign_struct ("cairo",
                                   "Context",
@@ -226,14 +226,5 @@ PYGLIB_MODULE_START(_gi_cairo, "_gi_cairo")
                                   cairo_surface_to_arg,
                                   cairo_surface_from_arg,
                                   cairo_surface_release);
-
-#ifdef PycairoRectangleInt_FromRectangleInt
-     pygi_register_foreign_struct ("cairo",
-                                  "RectangleInt",
-                                  cairo_rectangle_int_to_arg,
-                                  cairo_rectangle_int_from_arg,
-                                  cairo_rectangle_int_release);
-#endif
-
 }
 PYGLIB_MODULE_END;
diff --git a/gio/gfile.override b/gio/gfile.override
index b50130c..1301963 100644
--- a/gio/gfile.override
+++ b/gio/gfile.override
@@ -840,7 +840,7 @@ _wrap_g_file_set_attribute(PyGObject *self, PyObject *args, PyObject *kwargs)
     static char *kwlist[] = { "attribute", "type", "value_p",
                               "flags", "cancellable", NULL };
     GFileQueryInfoFlags flags = G_FILE_QUERY_INFO_NONE;
-    int ret;
+    int ret = 0;
     GCancellable *cancellable = NULL;
     GError *error = NULL;
     char *attribute;
@@ -883,7 +883,7 @@ _wrap_g_file_set_attribute(PyGObject *self, PyObject *args, PyObject *kwargs)
 				       &error);
 	}
 	break;
-				       
+
     case G_FILE_ATTRIBUTE_TYPE_BYTE_STRING:
 	{
 	    char* s;
@@ -902,7 +902,6 @@ _wrap_g_file_set_attribute(PyGObject *self, PyObject *args, PyObject *kwargs)
 				       &error);
 	}
 	break;
-				       
 
     case G_FILE_ATTRIBUTE_TYPE_STRINGV:
 	{
diff --git a/glib/pyglib-python-compat.h b/glib/pyglib-python-compat.h
index 4a52231..8c1dd51 100644
--- a/glib/pyglib-python-compat.h
+++ b/glib/pyglib-python-compat.h
@@ -112,6 +112,8 @@ static int _pyglib_init_##modname(PyObject *module)
 
 /* Compilation on Python 2.x */
 #if PY_VERSION_HEX < 0x03000000
+#define PYGLIB_MODULE_ERROR_RETURN
+
 #define RO READONLY
 
 #define PYGLIB_PyBaseString_Check(ob) (PyString_Check(ob) || PyUnicode_Check(ob))
@@ -176,6 +178,7 @@ PyTypeObject symbol = {                                 \
 
 #else
 
+#define PYGLIB_MODULE_ERROR_RETURN 0
 
 #define PYGLIB_MODULE_START(symbol, modname)	        \
     static struct PyModuleDef _##symbol##module = {     \
diff --git a/glib/pyglib.c b/glib/pyglib.c
index c85a628..03f9e91 100644
--- a/glib/pyglib.c
+++ b/glib/pyglib.c
@@ -359,7 +359,7 @@ pyglib_gerror_exception_check(GError **error)
     }
 
     g_set_error(error, g_quark_from_string(PYGLIB_PyUnicode_AsString(py_domain)),
-                PYGLIB_PyLong_AsLong(py_code), PYGLIB_PyUnicode_AsString(py_message));
+                PYGLIB_PyLong_AsLong(py_code), "%s", PYGLIB_PyUnicode_AsString(py_message));
 
     Py_DECREF(py_message);
     Py_DECREF(py_code);
diff --git a/glib/pygmainloop.c b/glib/pygmainloop.c
index de74971..cdb94ae 100644
--- a/glib/pygmainloop.c
+++ b/glib/pygmainloop.c
@@ -158,8 +158,9 @@ pyg_signal_watch_check(GSource *source)
     PySignalWatchSource *real_source = (PySignalWatchSource *)source;
     GPollFD *poll_fd = &real_source->fd;
     unsigned char dummy;
+    gssize ret;
     if (poll_fd->revents & G_IO_IN)
-	read(poll_fd->fd, &dummy, 1);
+	ret = read(poll_fd->fd, &dummy, 1);
 #endif
 
     state = pyglib_gil_state_ensure();



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