summaryrefslogtreecommitdiff
path: root/src/python-systemd/id128.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-02-22 13:33:06 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-02-28 20:04:17 -0500
commit6a6633a16a510b40c6ad30cd0858699619384a44 (patch)
tree0fdf50a3cd3e478e7df9a5d30298fb4f2087a965 /src/python-systemd/id128.c
parentd426d8c8632ba0be408f8b6b56514b4598abab74 (diff)
python-systemd: check all errors and use automatic cleanup
__REALTIME_TIMESTAMP and __MONOTONIC_TIMESTAMP return ints. It doesn't make sense to convert to string, just to convert back to a number later on. Also try to follow systemd rules for indentation.
Diffstat (limited to 'src/python-systemd/id128.c')
-rw-r--r--src/python-systemd/id128.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/python-systemd/id128.c b/src/python-systemd/id128.c
index 42f247d108..a6711a5bd5 100644
--- a/src/python-systemd/id128.c
+++ b/src/python-systemd/id128.c
@@ -19,18 +19,13 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include <stdbool.h>
+
#include <Python.h>
#include <systemd/sd-messages.h>
-#define _cleanup_Py_DECREF_ __attribute__((cleanup(cleanup_Py_DECREFp)))
-
-static void cleanup_Py_DECREFp(PyObject **p) {
- if (!*p)
- return;
-
- Py_DECREF(*p);
-}
+#include "pyutil.h"
PyDoc_STRVAR(module__doc__,
"Python interface to the libsystemd-id128 library.\n\n"
@@ -127,7 +122,10 @@ PyMODINIT_FUNC initid128(void) {
if (m == NULL)
return;
+ /* a series of lines like 'add_id() ;' follow */
+#define JOINER ;
#include "id128-constants.h"
+#undef JOINER
}
#else
@@ -147,7 +145,14 @@ PyMODINIT_FUNC PyInit_id128(void) {
if (m == NULL)
return NULL;
+ if ( /* a series of lines like 'add_id() ||' follow */
+#define JOINER ||
#include "id128-constants.h"
+#undef JOINER
+ false) {
+ Py_DECREF(m);
+ return NULL;
+ }
return m;
}