chiark / gitweb /
systemd-python: fix gcc warning
[elogind.git] / src / python-systemd / _reader.c
index 6ac2f204911f676907c1adc4698fa8020661e9d3..a678f69318055c94b14179aa3f13a7771d5b1a21 100644 (file)
@@ -908,9 +908,9 @@ static PyObject* Reader_get_catalog(Reader *self, PyObject *args)
 
         r = sd_journal_get_data(self->j, "MESSAGE_ID", &mid, &mid_len);
         if (r == 0) {
-            const int l = sizeof("MESSAGE_ID");
+            const size_t l = sizeof("MESSAGE_ID");
             assert(mid_len > l);
-            PyErr_Format(PyExc_KeyError, "%.*s", (int) mid_len - l,
+            PyErr_Format(PyExc_KeyError, "%.*s", (int) (mid_len - l),
                          (const char*) mid + l);
         } else if (r == -ENOENT)
             PyErr_SetString(PyExc_IndexError, "no MESSAGE_ID field");
@@ -1046,48 +1046,20 @@ static PyMethodDef Reader_methods[] = {
 
 static PyTypeObject ReaderType = {
     PyVarObject_HEAD_INIT(NULL, 0)
-    "_reader._Reader",                        /*tp_name*/
-    sizeof(Reader),                           /*tp_basicsize*/
-    0,                                        /*tp_itemsize*/
-    (destructor)Reader_dealloc,               /*tp_dealloc*/
-    0,                                        /*tp_print*/
-    0,                                        /*tp_getattr*/
-    0,                                        /*tp_setattr*/
-    0,                                        /*tp_compare*/
-    0,                                        /*tp_repr*/
-    0,                                        /*tp_as_number*/
-    0,                                        /*tp_as_sequence*/
-    0,                                        /*tp_as_mapping*/
-    0,                                        /*tp_hash */
-    0,                                        /*tp_call*/
-    0,                                        /*tp_str*/
-    0,                                        /*tp_getattro*/
-    0,                                        /*tp_setattro*/
-    0,                                        /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    Reader__doc__,                            /* tp_doc */
-    0,                                        /* tp_traverse */
-    0,                                        /* tp_clear */
-    0,                                        /* tp_richcompare */
-    0,                                        /* tp_weaklistoffset */
-    0,                                        /* tp_iter */
-    0,                                        /* tp_iternext */
-    Reader_methods,                           /* tp_methods */
-    0,                                        /* tp_members */
-    Reader_getsetters,                        /* tp_getset */
-    0,                                        /* tp_base */
-    0,                                        /* tp_dict */
-    0,                                        /* tp_descr_get */
-    0,                                        /* tp_descr_set */
-    0,                                        /* tp_dictoffset */
-    (initproc) Reader_init,                   /* tp_init */
-    0,                                        /* tp_alloc */
-    PyType_GenericNew,                        /* tp_new */
+    .tp_name = "_reader._Reader",
+    .tp_basicsize = sizeof(Reader),
+    .tp_dealloc = (destructor) Reader_dealloc,
+    .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+    .tp_doc = Reader__doc__,
+    .tp_methods = Reader_methods,
+    .tp_getset = Reader_getsetters,
+    .tp_init = (initproc) Reader_init,
+    .tp_new = PyType_GenericNew,
 };
 
 static PyMethodDef methods[] = {
         { "_get_catalog", get_catalog, METH_VARARGS, get_catalog__doc__},
-        { NULL, NULL, 0, NULL }        /* Sentinel */
+        {} /* Sentinel */
 };
 
 #if PY_MAJOR_VERSION >= 3
@@ -1097,7 +1069,6 @@ static PyModuleDef module = {
     module__doc__,
     -1,
     methods,
-    NULL, NULL, NULL, NULL
 };
 #endif