[sr-dev] git:master: app_python: fixed compilation errors and warnings.

Konstantin Mosesov ez at voipgroup.org.ua
Sat Feb 9 15:38:28 CET 2013


Module: sip-router
Branch: master
Commit: ae0183fe5af84ce986baa36b0e6a33f4e06f6803
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=ae0183fe5af84ce986baa36b0e6a33f4e06f6803

Author: Konstantin Mosesov <ez at voipgroup.org.ua>
Committer: Konstantin Mosesov <ez at voipgroup.org.ua>
Date:   Sat Feb  9 16:39:49 2013 +0200

app_python: fixed compilation errors and warnings.

---

 modules/app_python/mod_Core.c       |    2 +-
 modules/app_python/mod_Logger.c     |    2 +-
 modules/app_python/mod_Ranks.c      |    2 +-
 modules/app_python/mod_Router.c     |    3 ++-
 modules/app_python/python_mod.c     |    5 -----
 modules/app_python/python_support.c |   25 ++++++-------------------
 6 files changed, 11 insertions(+), 28 deletions(-)

diff --git a/modules/app_python/mod_Core.c b/modules/app_python/mod_Core.c
index 6e7f0e2..720049d 100644
--- a/modules/app_python/mod_Core.c
+++ b/modules/app_python/mod_Core.c
@@ -52,7 +52,7 @@ void init_mod_Core(void)
     core_module = Py_InitModule("Router.Core", CoreMethods);
     PyDict_SetItemString(main_module_dict, "Core", core_module);
 
-    Py_INCREF(&core_module);
+    Py_INCREF(core_module);
 
 #ifdef WITH_EXTRA_DEBUG
     LM_ERR("Module 'Router.Core' has been initialized\n");
diff --git a/modules/app_python/mod_Logger.c b/modules/app_python/mod_Logger.c
index 108c63b..8847b94 100644
--- a/modules/app_python/mod_Logger.c
+++ b/modules/app_python/mod_Logger.c
@@ -229,7 +229,7 @@ void init_mod_Logger(void)
     */
     PyModule_AddObject(logger_module, "DEFAULT_FACILITY", PyInt_FromLong((long)DEFAULT_FACILITY));
 
-    Py_INCREF(&logger_module);
+    Py_INCREF(logger_module);
 
 #ifdef WITH_EXTRA_DEBUG
     LM_ERR("Module 'Router.Logger' has been initialized\n");
diff --git a/modules/app_python/mod_Ranks.c b/modules/app_python/mod_Ranks.c
index db1428d..945e7a7 100644
--- a/modules/app_python/mod_Ranks.c
+++ b/modules/app_python/mod_Ranks.c
@@ -65,7 +65,7 @@ void init_mod_Ranks(void)
     PyModule_AddObject(ranks_module, "PROC_SIPRPC",		PyInt_FromLong((long)PROC_SIPRPC));
     PyModule_AddObject(ranks_module, "PROC_MIN",		PyInt_FromLong((long)PROC_MIN));
 
-    Py_INCREF(&ranks_module);
+    Py_INCREF(ranks_module);
 
 #ifdef WITH_EXTRA_DEBUG
     LM_ERR("Module 'Router.Ranks' has been initialized\n");
diff --git a/modules/app_python/mod_Router.c b/modules/app_python/mod_Router.c
index 8ec7366..6d1e488 100644
--- a/modules/app_python/mod_Router.c
+++ b/modules/app_python/mod_Router.c
@@ -51,7 +51,8 @@ void init_mod_Router(void)
 {
     main_module = Py_InitModule("Router", RouterMethods);
     main_module_dict = PyModule_GetDict(main_module);
-    Py_INCREF(&main_module);
+
+    Py_INCREF(main_module);
 
 #ifdef WITH_EXTRA_DEBUG
     LM_ERR("Module 'Router' has been initialized\n");
diff --git a/modules/app_python/python_mod.c b/modules/app_python/python_mod.c
index d297102..1f6e30e 100644
--- a/modules/app_python/python_mod.c
+++ b/modules/app_python/python_mod.c
@@ -287,7 +287,6 @@ static int child_init(int rank)
 	    PyErr_Format(PyExc_AttributeError, "'module' instance has no class name");
 	python_handle_exception("child_init");
 	Py_DECREF(format_exc_obj);
-	Py_XDECREF(classname);
 	PyThreadState_Swap(NULL);
 	PyEval_ReleaseLock();
 	return -1;
@@ -309,7 +308,6 @@ static int child_init(int rank)
 	    PyErr_Format(PyExc_AttributeError, "class object '%s' has is not callable attribute '%s'", !classname ? "None" : classname, mod_init_fname.s);
 	python_handle_exception("child_init");
 	Py_DECREF(format_exc_obj);
-	Py_XDECREF(classname);
 	Py_XDECREF(pFunc);
         PyThreadState_Swap(NULL);
         PyEval_ReleaseLock();
@@ -320,7 +318,6 @@ static int child_init(int rank)
     if (pArgs == NULL) {
 	python_handle_exception("child_init");
 	Py_DECREF(format_exc_obj);
-	Py_XDECREF(classname);
         Py_DECREF(pFunc);
         PyThreadState_Swap(NULL);
         PyEval_ReleaseLock();
@@ -370,7 +367,6 @@ static int child_init(int rank)
 	python_handle_exception("child_init");
 	Py_DECREF(format_exc_obj);
 	Py_XDECREF(pResult);
-	Py_XDECREF(classname);
 	PyThreadState_Swap(NULL);
 	PyEval_ReleaseLock();
 	return -1;
@@ -379,7 +375,6 @@ static int child_init(int rank)
 
     rval = PyInt_AsLong(pResult);
     Py_DECREF(pResult);
-    Py_XDECREF(classname);
     PyThreadState_Swap(NULL);
     PyEval_ReleaseLock();
 
diff --git a/modules/app_python/python_support.c b/modules/app_python/python_support.c
index fc529a4..81ef7f1 100644
--- a/modules/app_python/python_support.c
+++ b/modules/app_python/python_support.c
@@ -83,7 +83,7 @@ void python_handle_exception(const char *fmt, ...)
     buf = (char *)pkg_realloc(NULL, buflen * sizeof(char *));
     if (!buf)
     {
-	LM_ERR("python_handle_exception(): Can't allocate memory (%lu bytes), pkg_realloc() has failed. Not enough memory.\n", buflen * sizeof(char *));
+	LM_ERR("python_handle_exception(): Can't allocate memory (%lu bytes), pkg_realloc() has failed. Not enough memory.\n", (unsigned long)(buflen * sizeof(char *)));
 	return;
     }
     memset(buf, 0, sizeof(char *));
@@ -115,7 +115,7 @@ void python_handle_exception(const char *fmt, ...)
 	buf = (char *)pkg_realloc(buf, buflen * sizeof(char *));
 	if (!buf)
 	{
-	    LM_ERR("python_handle_exception(): Can't allocate memory (%li bytes), pkg_realloc() has failed. Not enough memory.\n", buflen * sizeof(char *));
+	    LM_ERR("python_handle_exception(): Can't allocate memory (%lu bytes), pkg_realloc() has failed. Not enough memory.\n", (unsigned long)(buflen * sizeof(char *)));
 	    Py_DECREF(line);
 	    Py_DECREF(pResult);
 	    return;
@@ -174,7 +174,7 @@ char *make_message(const char *fmt, ...)
     p = (char *)pkg_realloc(NULL, size * sizeof(char *));
     if (!p)
     {
-	LM_ERR("make_message(): Can't allocate memory (%li bytes), pkg_malloc() has failed: Not enough memory.\n", size * sizeof(char *));
+	LM_ERR("make_message(): Can't allocate memory (%lu bytes), pkg_malloc() has failed: Not enough memory.\n", (unsigned long)(size * sizeof(char *)));
 	return NULL;
     }
     memset(p, 0, size * sizeof(char *));
@@ -196,7 +196,7 @@ char *make_message(const char *fmt, ...)
 	np = (char *)pkg_realloc(p, size * sizeof(char *));
         if (!np)
 	{
-	    LM_ERR("make_message(): Can't allocate memory (%li bytes), pkg_realloc() has failed: Not enough memory.\n", size * sizeof(char *));
+	    LM_ERR("make_message(): Can't allocate memory (%lu bytes), pkg_realloc() has failed: Not enough memory.\n", (unsigned long)size * sizeof(char *));
 	    if (p)
     		pkg_free(p);
     	    return NULL;
@@ -223,13 +223,7 @@ char *get_class_name(PyObject *y)
     name = PyString_AsString(p);
     Py_XDECREF(p);
 
-    if (name == NULL)
-    {
-	Py_XDECREF(name);
-	return NULL;
-    }
-    else
-	return name;
+    return name;
 }
 
 
@@ -256,12 +250,5 @@ char *get_instance_class_name(PyObject *y)
     Py_XDECREF(p);
     Py_XDECREF(n);
 
-    if (name == NULL)
-    {
-	Py_XDECREF(name);
-	return NULL;
-    }
-    else
-	return name;
+    return name;
 }
-




More information about the sr-dev mailing list