[pygobject] fix most warnings



commit 225f21117b6b3546989abe22538c784291e86b2a
Author: John (J5) Palmieri <johnp redhat com>
Date:   Fri Sep 16 12:26:10 2011 -0400

    fix most warnings
    
    * remove some unused vars
    * correctly cast vars
    * handle deprecated enums in switch statments by using default:
    * unused wanrings still remain in some places

 gi/pygi-argument.c        |    2 +-
 gi/pygi-cache.c           |    7 ++-----
 gi/pygi-info.c            |    6 ++++++
 gi/pygi-invoke.c          |    2 +-
 gi/pygi-marshal-from-py.c |   17 +++++++++--------
 gi/pygi-marshal-to-py.c   |    3 +--
 6 files changed, 20 insertions(+), 17 deletions(-)
---
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index 76ba6d9..4564f3d 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -1775,7 +1775,7 @@ _pygi_argument_to_object (GIArgument  *arg,
             break;
         }
         case GI_TYPE_TAG_ERROR:
-             if (pyglib_error_check (&arg->v_pointer)) {
+             if (pyglib_error_check ( (GError **) &arg->v_pointer)) {
                  PyObject *err_type;
                  PyObject *err_value;
                  PyObject *err_trace;
diff --git a/gi/pygi-cache.c b/gi/pygi-cache.c
index 659c424..41ca32c 100644
--- a/gi/pygi-cache.c
+++ b/gi/pygi-cache.c
@@ -150,7 +150,6 @@ _sequence_cache_new (GITypeInfo *type_info,
 {
     PyGISequenceCache *sc;
     GITypeInfo *item_type_info;
-    GITypeTag item_type_tag;
     GITransfer item_transfer;
 
     sc = g_slice_new0 (PyGISequenceCache);
@@ -243,6 +242,8 @@ _callback_cache_new (GIArgInfo *arg_info,
    PyGICallbackCache *cc;
 
    cc = g_slice_new0 (PyGICallbackCache);
+   ( (PyGIArgCache *)cc)->destroy_notify = (GDestroyNotify)_callback_cache_free_func;
+
    cc->user_data_index = g_arg_info_get_closure (arg_info);
    if (cc->user_data_index != -1)
        cc->user_data_index += child_offset;
@@ -736,8 +737,6 @@ _arg_cache_new_for_interface (GIInterfaceInfo *iface_info,
             (callable_cache->function_type == PYGI_FUNCTION_TYPE_METHOD ||
                  callable_cache->function_type == PYGI_FUNCTION_TYPE_VFUNC) ? 1: 0;
 
-    GI_IS_INTERFACE_INFO (iface_info);
-
     info_type = g_base_info_get_type ( (GIBaseInfo *)iface_info);
 
     /* Callbacks are special cased */
@@ -861,8 +860,6 @@ _arg_cache_new (GITypeInfo *type_info,
     gssize child_offset = 0;
     GITypeTag type_tag;
 
-    GI_IS_TYPE_INFO (type_info);
-
     type_tag = g_type_info_get_tag (type_info);
 
     if (callable_cache != NULL)
diff --git a/gi/pygi-info.c b/gi/pygi-info.c
index 30e1956..bf3af58 100644
--- a/gi/pygi-info.c
+++ b/gi/pygi-info.c
@@ -192,6 +192,9 @@ _pygi_info_new (GIBaseInfo *info)
         case GI_INFO_TYPE_UNRESOLVED:
             type = &PyGIUnresolvedInfo_Type;
             break;
+        default:
+            g_assert_not_reached();
+            break;
     }
 
     self = (PyGIBaseInfo *) type->tp_alloc (type, 0);
@@ -484,6 +487,7 @@ _pygi_g_type_info_size (GITypeInfo *type_info)
                 case GI_INFO_TYPE_ARG:
                 case GI_INFO_TYPE_TYPE:
                 case GI_INFO_TYPE_UNRESOLVED:
+                default:
                     g_assert_not_reached();
                     break;
             }
@@ -862,7 +866,9 @@ pygi_g_struct_info_is_simple (GIStructInfo *struct_info)
                     case GI_INFO_TYPE_ARG:
                     case GI_INFO_TYPE_TYPE:
                     case GI_INFO_TYPE_UNRESOLVED:
+                    default:
                         g_assert_not_reached();
+                        break;
                 }
 
                 g_base_info_unref (info);
diff --git a/gi/pygi-invoke.c b/gi/pygi-invoke.c
index f669c2e..0064fe5 100644
--- a/gi/pygi-invoke.c
+++ b/gi/pygi-invoke.c
@@ -472,7 +472,7 @@ _invoke_marshal_in_args (PyGIInvokeState *state, PyGICallableCache *cache)
         if (arg_cache->from_py_marshaller != NULL) {
             if (!arg_cache->allow_none && py_arg == Py_None) {
                 PyErr_Format (PyExc_TypeError,
-                              "Argument %i does not allow None as a value",
+                              "Argument %zd does not allow None as a value",
                               i);
 
                  pygi_marshal_cleanup_args_from_py_parameter_fail (state,
diff --git a/gi/pygi-marshal-from-py.c b/gi/pygi-marshal-from-py.c
index 6d41eb8..fa74a22 100644
--- a/gi/pygi-marshal-from-py.c
+++ b/gi/pygi-marshal-from-py.c
@@ -25,8 +25,6 @@
 
 #include <string.h>
 #include <time.h>
-
-#include <datetime.h>
 #include <pygobject.h>
 #include <pyglib-python-compat.h>
 
@@ -406,7 +404,7 @@ _pygi_marshal_from_py_uint64 (PyGIInvokeState   *state,
     if (PyInt_Check (py_long)) {
         long long_ = PyInt_AsLong (py_long);
         if (long_ < 0) {
-            PyErr_Format (PyExc_ValueError, "%ld not in range %d to %llu",
+            PyErr_Format (PyExc_ValueError, "%ld not in range %d to %lu",
                           long_, 0, G_MAXUINT64);
             return FALSE;
         }
@@ -444,7 +442,7 @@ _pygi_marshal_from_py_uint64 (PyGIInvokeState   *state,
 
         Py_DECREF (py_str);
 
-        PyErr_Format (PyExc_ValueError, "%s not in range %d to %llu",
+        PyErr_Format (PyExc_ValueError, "%s not in range %d to %lu",
                       long_str, 0, G_MAXUINT64);
 
         g_free (long_str);
@@ -452,7 +450,7 @@ _pygi_marshal_from_py_uint64 (PyGIInvokeState   *state,
     }
 
     if (ulong_ > G_MAXUINT64) {
-        PyErr_Format (PyExc_ValueError, "%llu not in range %d to %llu", ulong_, 0, G_MAXUINT64);
+        PyErr_Format (PyExc_ValueError, "%lu not in range %d to %lu", ulong_, 0, G_MAXUINT64);
         return FALSE;
     }
 
@@ -898,10 +896,11 @@ _pygi_marshal_from_py_glist (PyGIInvokeState   *state,
         list_ = g_list_append (list_, item.v_pointer);
         continue;
 err:
+        /* FIXME: clean up list
         if (sequence_cache->item_cache->from_py_cleanup != NULL) {
             PyGIMarshalCleanupFunc cleanup = sequence_cache->item_cache->from_py_cleanup;
         }
-
+        */
         g_list_free (list_);
         _PyGI_ERROR_PREFIX ("Item %i: ", i);
         return FALSE;
@@ -964,9 +963,11 @@ _pygi_marshal_from_py_gslist (PyGIInvokeState   *state,
         list_ = g_slist_append (list_, item.v_pointer);
         continue;
 err:
+        /* FIXME: Clean up list
         if (sequence_cache->item_cache->from_py_cleanup != NULL) {
             PyGIMarshalCleanupFunc cleanup = sequence_cache->item_cache->from_py_cleanup;
         }
+        */
 
         g_slist_free (list_);
         _PyGI_ERROR_PREFIX ("Item %i: ", i);
@@ -1316,13 +1317,13 @@ _pygi_marshal_from_py_interface_struct (PyGIInvokeState   *state,
         arg->v_pointer = value;
         return TRUE;
     } else if (iface_cache->is_foreign) {
-        gboolean success;
+        PyObject *success;
         success = pygi_struct_foreign_convert_to_g_argument (py_arg,
                                                              iface_cache->interface_info,
                                                              arg_cache->transfer,
                                                              arg);
 
-        return success;
+        return (success == Py_None);
     } else if (!PyObject_IsInstance (py_arg, iface_cache->py_type)) {
         PyErr_Format (PyExc_TypeError, "Expected %s, but got %s",
                       iface_cache->type_name,
diff --git a/gi/pygi-marshal-to-py.c b/gi/pygi-marshal-to-py.c
index cb62c49..48dfa08 100644
--- a/gi/pygi-marshal-to-py.c
+++ b/gi/pygi-marshal-to-py.c
@@ -26,7 +26,6 @@
 #include <string.h>
 #include <time.h>
 
-#include <datetime.h>
 #include <pygobject.h>
 #include <pyglib-python-compat.h>
 
@@ -276,7 +275,7 @@ _pygi_marshal_to_py_array (PyGIInvokeState   *state,
         if (seq_cache->fixed_size >= 0) {
             len = seq_cache->fixed_size;
         } else if (seq_cache->is_zero_terminated) {
-            len = g_strv_length (arg->v_string);
+            len = g_strv_length ((gchar **)arg->v_pointer);
         } else {
             GIArgument *len_arg = state->args[seq_cache->len_arg_index];
             len = len_arg->v_long;



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