]> git.ipfire.org Git - collecty.git/commitdiff
python: Declare functions as static when possible
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Dec 2021 20:49:28 +0000 (20:49 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Dec 2021 20:49:28 +0000 (20:49 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_collecty/_collectymodule.h
src/_collecty/blockdev.c
src/_collecty/ping.c
src/_collecty/sensors.c

index bbbe8e23562858bb21232859f2925fd15ade5e3b..fbcaf51c93d6c8b960374316c43a32c9e7bd790c 100644 (file)
@@ -42,20 +42,6 @@ typedef struct {
 
 extern PyTypeObject BlockDeviceType;
 
-void BlockDevice_dealloc(BlockDevice* self);
-int BlockDevice_get_identity(BlockDevice* device);
-int BlockDevice_smart_is_available(BlockDevice* device);
-int BlockDevice_check_sleep_mode(BlockDevice* device);
-PyObject * BlockDevice_new(PyTypeObject* type, PyObject* args, PyObject* kwds);
-int BlockDevice_init(BlockDevice* self, PyObject* args, PyObject* kwds);
-PyObject* BlockDevice_get_path(PyObject* self);
-PyObject* BlockDevice_get_model(PyObject* self);
-PyObject* BlockDevice_get_serial(PyObject* self);
-PyObject* BlockDevice_is_smart_supported(PyObject* self);
-PyObject* BlockDevice_is_awake(PyObject* self);
-PyObject* BlockDevice_get_bad_sectors(PyObject* self);
-PyObject* BlockDevice_get_temperature(PyObject* self);
-
 /* ping */
 extern PyObject* PyExc_PingError;
 extern PyObject* PyExc_PingAddHostError;
@@ -79,19 +65,6 @@ typedef struct {
 
 extern PyTypeObject PingType;
 
-void Ping_dealloc(PingObject* self);
-void Ping_init_stats(PingObject* self);
-PyObject* Ping_new(PyTypeObject* type, PyObject* args, PyObject* kwds);
-int Ping_init(PingObject* self, PyObject* args, PyObject* kwds);
-double Ping_compute_average(PingObject* self);
-double Ping_compute_stddev(PingObject* self, double mean);
-PyObject* Ping_ping(PingObject* self, PyObject* args, PyObject* kwds);
-PyObject* Ping_get_packets_sent(PingObject* self);
-PyObject* Ping_get_packets_rcvd(PingObject* self);
-PyObject* Ping_get_average(PingObject* self);
-PyObject* Ping_get_stddev(PingObject* self);
-PyObject* Ping_get_loss(PingObject* self);
-
 /* sensors */
 typedef struct {
        PyObject_HEAD
@@ -101,20 +74,6 @@ typedef struct {
 
 extern PyTypeObject SensorType;
 
-void Sensor_dealloc(SensorObject* self);
-PyObject* Sensor_new(PyTypeObject* type, PyObject* args, PyObject* kwds);
-int Sensor_init(SensorObject* self, PyObject* args, PyObject* kwds);
-PyObject* Sensor_get_label(SensorObject* self);
-PyObject* Sensor_get_name(SensorObject* self);
-PyObject* Sensor_get_type(SensorObject* self);
-PyObject* Sensor_get_bus(SensorObject* self);
-PyObject* Sensor_return_value(SensorObject* sensor, sensors_subfeature_type subfeature_type);
-PyObject* Sensor_get_value(SensorObject* self);
-PyObject* Sensor_get_critical(SensorObject* self);
-PyObject* Sensor_get_maximum(SensorObject* self);
-PyObject* Sensor_get_minimum(SensorObject* self);
-PyObject* Sensor_get_high(SensorObject* self);
-
 PyObject* _collecty_sensors_init();
 PyObject* _collecty_sensors_cleanup();
 PyObject* _collecty_get_detected_sensors(PyObject* o, PyObject* args);
index 09d3994fe6f0d64a17d766987b1ca9d772bcbaa8..838d623a1265b0c3009d3e79470c23e283c7b096 100644 (file)
 
 #include "_collectymodule.h"
 
-static PyGetSetDef BlockDevice_getsetters[] = {
-       {"path", (getter)BlockDevice_get_path, NULL, NULL, NULL},
-       {"model", (getter)BlockDevice_get_model, NULL, NULL, NULL},
-       {"serial", (getter)BlockDevice_get_serial, NULL, NULL, NULL},
-};
-
-static PyMethodDef BlockDevice_methods[] = {
-       {"get_bad_sectors", (PyCFunction)BlockDevice_get_bad_sectors, METH_NOARGS, NULL},
-       {"get_temperature", (PyCFunction)BlockDevice_get_temperature, METH_NOARGS, NULL},
-       {"is_smart_supported", (PyCFunction)BlockDevice_is_smart_supported, METH_NOARGS, NULL},
-       {"is_awake", (PyCFunction)BlockDevice_is_awake, METH_NOARGS, NULL},
-       {NULL}
-};
-
-PyTypeObject BlockDeviceType = {
-       PyVarObject_HEAD_INIT(NULL, 0)
-       "_collecty.BlockDevice",            /*tp_name*/
-       sizeof(BlockDevice),                /*tp_basicsize*/
-       0,                                  /*tp_itemsize*/
-       (destructor)BlockDevice_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*/
-       "BlockDevice objects",              /* tp_doc */
-       0,                                          /* tp_traverse */
-       0,                                          /* tp_clear */
-       0,                                          /* tp_richcompare */
-       0,                                          /* tp_weaklistoffset */
-       0,                                          /* tp_iter */
-       0,                                          /* tp_iternext */
-       BlockDevice_methods,                /* tp_methods */
-       0,                                  /* tp_members */
-       BlockDevice_getsetters,             /* tp_getset */
-       0,                                  /* tp_base */
-       0,                                  /* tp_dict */
-       0,                                  /* tp_descr_get */
-       0,                                  /* tp_descr_set */
-       0,                                  /* tp_dictoffset */
-       (initproc)BlockDevice_init,         /* tp_init */
-       0,                                  /* tp_alloc */
-       BlockDevice_new,                    /* tp_new */
-};
-
-void BlockDevice_dealloc(BlockDevice* self) {
+static void BlockDevice_dealloc(BlockDevice* self) {
        if (self->disk)
                sk_disk_free(self->disk);
 
@@ -93,7 +38,7 @@ void BlockDevice_dealloc(BlockDevice* self) {
        Py_TYPE(self)->tp_free((PyObject*)self);
 }
 
-int BlockDevice_get_identity(BlockDevice* device) {
+static int BlockDevice_get_identity(BlockDevice* device) {
        int fd;
 
        if ((fd = open(device->path, O_RDONLY | O_NONBLOCK)) < 0) {
@@ -109,7 +54,7 @@ int BlockDevice_get_identity(BlockDevice* device) {
        return 0;
 }
 
-int BlockDevice_smart_is_available(BlockDevice* device) {
+static int BlockDevice_smart_is_available(BlockDevice* device) {
        SkBool available = FALSE;
 
        int r = sk_disk_smart_is_available(device->disk, &available);
@@ -122,7 +67,7 @@ int BlockDevice_smart_is_available(BlockDevice* device) {
        return 1;
 }
 
-int BlockDevice_check_sleep_mode(BlockDevice* device) {
+static int BlockDevice_check_sleep_mode(BlockDevice* device) {
        SkBool awake = FALSE;
 
        int r = sk_disk_check_sleep_mode(device->disk, &awake);
@@ -135,7 +80,7 @@ int BlockDevice_check_sleep_mode(BlockDevice* device) {
        return 1;
 }
 
-PyObject * BlockDevice_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
+static PyObject * BlockDevice_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
        BlockDevice* self = (BlockDevice*)type->tp_alloc(type, 0);
 
        if (self) {
@@ -148,7 +93,7 @@ PyObject * BlockDevice_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
        return (PyObject *)self;
 }
 
-int BlockDevice_init(BlockDevice* self, PyObject* args, PyObject* kwds) {
+static int BlockDevice_init(BlockDevice* self, PyObject* args, PyObject* kwds) {
        const char* path = NULL;
 
        if (!PyArg_ParseTuple(args, "s", &path))
@@ -185,7 +130,7 @@ int BlockDevice_init(BlockDevice* self, PyObject* args, PyObject* kwds) {
        return 0;
 }
 
-PyObject* BlockDevice_get_path(PyObject* self) {
+static PyObject* BlockDevice_get_path(PyObject* self) {
        BlockDevice* device = (BlockDevice*)self;
 
        return PyUnicode_FromString(device->path);
@@ -234,7 +179,7 @@ static void copy_string(char* d, const char* s, size_t n) {
        drop_spaces(d);
 }
 
-PyObject* BlockDevice_get_model(PyObject* self) {
+static PyObject* BlockDevice_get_model(PyObject* self) {
        BlockDevice* device = (BlockDevice*)self;
 
        char model[MODEL_SIZE + 1];
@@ -243,7 +188,7 @@ PyObject* BlockDevice_get_model(PyObject* self) {
        return PyUnicode_FromString(model);
 }
 
-PyObject* BlockDevice_get_serial(PyObject* self) {
+static PyObject* BlockDevice_get_serial(PyObject* self) {
        BlockDevice* device = (BlockDevice*)self;
 
        char serial[SERIAL_SIZE + 1];
@@ -252,7 +197,7 @@ PyObject* BlockDevice_get_serial(PyObject* self) {
        return PyUnicode_FromString(serial);
 }
 
-PyObject* BlockDevice_is_smart_supported(PyObject* self) {
+static PyObject* BlockDevice_is_smart_supported(PyObject* self) {
        BlockDevice* device = (BlockDevice*)self;
 
        if (BlockDevice_smart_is_available(device) == 0)
@@ -261,7 +206,7 @@ PyObject* BlockDevice_is_smart_supported(PyObject* self) {
        Py_RETURN_FALSE;
 }
 
-PyObject* BlockDevice_is_awake(PyObject* self) {
+static PyObject* BlockDevice_is_awake(PyObject* self) {
        BlockDevice* device = (BlockDevice*)self;
 
        if (BlockDevice_check_sleep_mode(device) == 0)
@@ -270,7 +215,7 @@ PyObject* BlockDevice_is_awake(PyObject* self) {
        Py_RETURN_FALSE;
 }
 
-PyObject* BlockDevice_get_bad_sectors(PyObject* self) {
+static PyObject* BlockDevice_get_bad_sectors(PyObject* self) {
        BlockDevice* device = (BlockDevice*)self;
 
        if (BlockDevice_smart_is_available(device)) {
@@ -286,7 +231,7 @@ PyObject* BlockDevice_get_bad_sectors(PyObject* self) {
        return PyLong_FromUnsignedLongLong((unsigned long long)bad_sectors);
 }
 
-PyObject* BlockDevice_get_temperature(PyObject* self) {
+static PyObject* BlockDevice_get_temperature(PyObject* self) {
        BlockDevice* device = (BlockDevice*)self;
 
        if (BlockDevice_smart_is_available(device)) {
@@ -308,3 +253,59 @@ PyObject* BlockDevice_get_temperature(PyObject* self) {
        // Convert the temperature to Kelvin
        return PyFloat_FromDouble((double)mkelvin / 1000.0);
 }
+
+static PyGetSetDef BlockDevice_getsetters[] = {
+       {"path", (getter)BlockDevice_get_path, NULL, NULL, NULL},
+       {"model", (getter)BlockDevice_get_model, NULL, NULL, NULL},
+       {"serial", (getter)BlockDevice_get_serial, NULL, NULL, NULL},
+       { NULL },
+};
+
+static PyMethodDef BlockDevice_methods[] = {
+       {"get_bad_sectors", (PyCFunction)BlockDevice_get_bad_sectors, METH_NOARGS, NULL},
+       {"get_temperature", (PyCFunction)BlockDevice_get_temperature, METH_NOARGS, NULL},
+       {"is_smart_supported", (PyCFunction)BlockDevice_is_smart_supported, METH_NOARGS, NULL},
+       {"is_awake", (PyCFunction)BlockDevice_is_awake, METH_NOARGS, NULL},
+       { NULL },
+};
+
+PyTypeObject BlockDeviceType = {
+       PyVarObject_HEAD_INIT(NULL, 0)
+       "_collecty.BlockDevice",            /*tp_name*/
+       sizeof(BlockDevice),                /*tp_basicsize*/
+       0,                                  /*tp_itemsize*/
+       (destructor)BlockDevice_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*/
+       "BlockDevice objects",              /* tp_doc */
+       0,                                          /* tp_traverse */
+       0,                                          /* tp_clear */
+       0,                                          /* tp_richcompare */
+       0,                                          /* tp_weaklistoffset */
+       0,                                          /* tp_iter */
+       0,                                          /* tp_iternext */
+       BlockDevice_methods,                /* tp_methods */
+       0,                                  /* tp_members */
+       BlockDevice_getsetters,             /* tp_getset */
+       0,                                  /* tp_base */
+       0,                                  /* tp_dict */
+       0,                                  /* tp_descr_get */
+       0,                                  /* tp_descr_set */
+       0,                                  /* tp_dictoffset */
+       (initproc)BlockDevice_init,         /* tp_init */
+       0,                                  /* tp_alloc */
+       BlockDevice_new,                    /* tp_new */
+};
index 1d66e2fb8de7da1b8e505bd63de660d54a46f57c..5a1ab9cc7d63c35edfc7aa3ec2539743339e60ab 100644 (file)
 
 #include "_collectymodule.h"
 
-static PyGetSetDef Ping_getsetters[] = {
-       {"average", (getter)Ping_get_average, NULL, NULL, NULL},
-       {"loss", (getter)Ping_get_loss, NULL, NULL, NULL},
-       {"stddev", (getter)Ping_get_stddev, NULL, NULL, NULL},
-       {"packets_sent", (getter)Ping_get_packets_sent, NULL, NULL, NULL},
-       {"packets_rcvd", (getter)Ping_get_packets_rcvd, NULL, NULL, NULL},
-       {NULL}
-};
-
-static PyMethodDef Ping_methods[] = {
-       {"ping", (PyCFunction)Ping_ping, METH_VARARGS|METH_KEYWORDS, NULL},
-       {NULL}
-};
-
-PyTypeObject PingType = {
-       PyVarObject_HEAD_INIT(NULL, 0)
-       "_collecty.Ping",                   /*tp_name*/
-       sizeof(PingObject),                 /*tp_basicsize*/
-       0,                                  /*tp_itemsize*/
-       (destructor)Ping_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*/
-       "Ping object",                      /* tp_doc */
-       0,                                          /* tp_traverse */
-       0,                                          /* tp_clear */
-       0,                                          /* tp_richcompare */
-       0,                                          /* tp_weaklistoffset */
-       0,                                          /* tp_iter */
-       0,                                          /* tp_iternext */
-       Ping_methods,                       /* tp_methods */
-       0,                                  /* tp_members */
-       Ping_getsetters,                    /* tp_getset */
-       0,                                  /* tp_base */
-       0,                                  /* tp_dict */
-       0,                                  /* tp_descr_get */
-       0,                                  /* tp_descr_set */
-       0,                                  /* tp_dictoffset */
-       (initproc)Ping_init,                /* tp_init */
-       0,                                  /* tp_alloc */
-       Ping_new,                           /* tp_new */
-};
-
-void Ping_dealloc(PingObject* self) {
+static void Ping_dealloc(PingObject* self) {
        if (self->ping)
                ping_destroy(self->ping);
 
        Py_TYPE(self)->tp_free((PyObject*)self);
 }
 
-void Ping_init_stats(PingObject* self) {
+static void Ping_init_stats(PingObject* self) {
        self->stats.history_index = 0;
        self->stats.history_size = 0;
        self->stats.packets_sent = 0;
@@ -97,7 +42,7 @@ void Ping_init_stats(PingObject* self) {
        self->stats.loss = 0.0;
 }
 
-PyObject* Ping_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
+static PyObject* Ping_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
        PingObject* self = (PingObject*)type->tp_alloc(type, 0);
 
        if (self) {
@@ -110,7 +55,7 @@ PyObject* Ping_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
        return (PyObject*)self;
 }
 
-int Ping_init(PingObject* self, PyObject* args, PyObject* kwds) {
+static int Ping_init(PingObject* self, PyObject* args, PyObject* kwds) {
        char* kwlist[] = {"host", "family", "timeout", "ttl", NULL};
        int family = PING_DEF_AF;
        double timeout = PING_DEFAULT_TIMEOUT;
@@ -170,7 +115,7 @@ int Ping_init(PingObject* self, PyObject* args, PyObject* kwds) {
        return 0;
 }
 
-double Ping_compute_average(PingObject* self) {
+static double Ping_compute_average(PingObject* self) {
        assert(self->stats.packets_rcvd > 0);
 
        double total_latency = 0.0;
@@ -183,7 +128,7 @@ double Ping_compute_average(PingObject* self) {
        return total_latency / self->stats.packets_rcvd;
 }
 
-double Ping_compute_stddev(PingObject* self, double mean) {
+static double Ping_compute_stddev(PingObject* self, double mean) {
        assert(self->stats.packets_rcvd > 0);
 
        double deviation = 0.0;
@@ -223,7 +168,7 @@ static double time_elapsed(struct timeval* t0) {
        return r;
 }
 
-PyObject* Ping_ping(PingObject* self, PyObject* args, PyObject* kwds) {
+static PyObject* Ping_ping(PingObject* self, PyObject* args, PyObject* kwds) {
        char* kwlist[] = {"count", "deadline", NULL};
        size_t count = PING_DEFAULT_COUNT;
        double deadline = 0;
@@ -303,22 +248,77 @@ PyObject* Ping_ping(PingObject* self, PyObject* args, PyObject* kwds) {
        Py_RETURN_NONE;
 }
 
-PyObject* Ping_get_packets_sent(PingObject* self) {
+static PyObject* Ping_get_packets_sent(PingObject* self) {
        return PyLong_FromUnsignedLong(self->stats.packets_sent);
 }
 
-PyObject* Ping_get_packets_rcvd(PingObject* self) {
+static PyObject* Ping_get_packets_rcvd(PingObject* self) {
        return PyLong_FromUnsignedLong(self->stats.packets_rcvd);
 }
 
-PyObject* Ping_get_average(PingObject* self) {
+static PyObject* Ping_get_average(PingObject* self) {
        return PyFloat_FromDouble(self->stats.average);
 }
 
-PyObject* Ping_get_stddev(PingObject* self) {
+static PyObject* Ping_get_stddev(PingObject* self) {
        return PyFloat_FromDouble(self->stats.stddev);
 }
 
-PyObject* Ping_get_loss(PingObject* self) {
+static PyObject* Ping_get_loss(PingObject* self) {
        return PyFloat_FromDouble(self->stats.loss);
 }
+
+static PyGetSetDef Ping_getsetters[] = {
+       {"average", (getter)Ping_get_average, NULL, NULL, NULL},
+       {"loss", (getter)Ping_get_loss, NULL, NULL, NULL},
+       {"stddev", (getter)Ping_get_stddev, NULL, NULL, NULL},
+       {"packets_sent", (getter)Ping_get_packets_sent, NULL, NULL, NULL},
+       {"packets_rcvd", (getter)Ping_get_packets_rcvd, NULL, NULL, NULL},
+       { NULL },
+};
+
+static PyMethodDef Ping_methods[] = {
+       {"ping", (PyCFunction)Ping_ping, METH_VARARGS|METH_KEYWORDS, NULL},
+       { NULL },
+};
+
+PyTypeObject PingType = {
+       PyVarObject_HEAD_INIT(NULL, 0)
+       "_collecty.Ping",                   /*tp_name*/
+       sizeof(PingObject),                 /*tp_basicsize*/
+       0,                                  /*tp_itemsize*/
+       (destructor)Ping_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*/
+       "Ping object",                      /* tp_doc */
+       0,                                          /* tp_traverse */
+       0,                                          /* tp_clear */
+       0,                                          /* tp_richcompare */
+       0,                                          /* tp_weaklistoffset */
+       0,                                          /* tp_iter */
+       0,                                          /* tp_iternext */
+       Ping_methods,                       /* tp_methods */
+       0,                                  /* tp_members */
+       Ping_getsetters,                    /* tp_getset */
+       0,                                  /* tp_base */
+       0,                                  /* tp_dict */
+       0,                                  /* tp_descr_get */
+       0,                                  /* tp_descr_set */
+       0,                                  /* tp_dictoffset */
+       (initproc)Ping_init,                /* tp_init */
+       0,                                  /* tp_alloc */
+       Ping_new,                           /* tp_new */
+};
index 5b154e1038004c9859d6d1fbad52f6a4a49e3293..0fb55d33da9223da002a3e0feca310f63fd9b6f4 100644 (file)
 
 #include "_collectymodule.h"
 
-static PyGetSetDef Sensor_getsetters[] = {
-       {"bus", (getter)Sensor_get_bus, NULL, NULL, NULL},
-       {"critical", (getter)Sensor_get_critical, NULL, NULL, NULL},
-       {"high", (getter)Sensor_get_high, NULL, NULL, NULL},
-       {"label", (getter)Sensor_get_label, NULL, NULL, NULL},
-       {"maximum", (getter)Sensor_get_maximum, NULL, NULL, NULL},
-       {"minumum", (getter)Sensor_get_minimum, NULL, NULL, NULL},
-       {"name", (getter)Sensor_get_name, NULL, NULL, NULL},
-       {"type", (getter)Sensor_get_type, NULL, NULL, NULL},
-       {"value", (getter)Sensor_get_value, NULL, NULL, NULL},
-       {NULL},
-};
-
-PyTypeObject SensorType = {
-       PyObject_HEAD_INIT(NULL)
-       "_collecty.Sensor",                 /*tp_name*/
-       sizeof(SensorObject),               /*tp_basicsize*/
-       0,                                  /*tp_itemsize*/
-       (destructor)Sensor_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*/
-       "Sensor objects",                   /* tp_doc */
-       0,                                  /* tp_traverse */
-       0,                                  /* tp_clear */
-       0,                                  /* tp_richcompare */
-       0,                                  /* tp_weaklistoffset */
-       0,                                  /* tp_iter */
-       0,                                  /* tp_iternext */
-       0,                                  /* tp_methods */
-       0,                                  /* tp_members */
-       Sensor_getsetters,                  /* tp_getset */
-       0,                                  /* tp_base */
-       0,                                  /* tp_dict */
-       0,                                  /* tp_descr_get */
-       0,                                  /* tp_descr_set */
-       0,                                  /* tp_dictoffset */
-       (initproc)Sensor_init,              /* tp_init */
-       0,                                  /* tp_alloc */
-       Sensor_new,                         /* tp_new */
-};
-
-void Sensor_dealloc(SensorObject* self) {
+static void Sensor_dealloc(SensorObject* self) {
        Py_TYPE(self)->tp_free((PyObject*)self);
 }
 
-PyObject* Sensor_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
+static PyObject* Sensor_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
        SensorObject* self = (SensorObject*)type->tp_alloc(type, 0);
 
        return (PyObject *)self;
 }
 
-int Sensor_init(SensorObject* self, PyObject* args, PyObject* kwds) {
+static int Sensor_init(SensorObject* self, PyObject* args, PyObject* kwds) {
        return 0;
 }
 
-PyObject* Sensor_get_label(SensorObject* self) {
+static PyObject* Sensor_get_label(SensorObject* self) {
        char* label = sensors_get_label(self->chip, self->feature);
 
        if (label) {
@@ -106,7 +52,7 @@ PyObject* Sensor_get_label(SensorObject* self) {
        Py_RETURN_NONE;
 }
 
-PyObject* Sensor_get_name(SensorObject* self) {
+static PyObject* Sensor_get_name(SensorObject* self) {
        char chip_name[512];
 
        int r = sensors_snprintf_chip_name(chip_name, sizeof(chip_name), self->chip);
@@ -118,7 +64,7 @@ PyObject* Sensor_get_name(SensorObject* self) {
        return PyUnicode_FromString(chip_name);
 }
 
-PyObject* Sensor_get_type(SensorObject* self) {
+static PyObject* Sensor_get_type(SensorObject* self) {
        const char* type = NULL;
 
        switch (self->feature->type) {
@@ -148,7 +94,7 @@ PyObject* Sensor_get_type(SensorObject* self) {
        Py_RETURN_NONE;
 }
 
-PyObject* Sensor_get_bus(SensorObject* self) {
+static PyObject* Sensor_get_bus(SensorObject* self) {
        const char* type = NULL;
 
        switch (self->chip->bus.type) {
@@ -202,7 +148,7 @@ static const sensors_subfeature* Sensor_get_subfeature(SensorObject* sensor, sen
        return subfeature;
 }
 
-PyObject* Sensor_return_value(SensorObject* sensor, sensors_subfeature_type subfeature_type) {
+static PyObject* Sensor_return_value(SensorObject* sensor, sensors_subfeature_type subfeature_type) {
        double value;
 
        const sensors_subfeature* subfeature = Sensor_get_subfeature(sensor, subfeature_type);
@@ -231,7 +177,7 @@ static PyObject* Sensor_no_value() {
        return NULL;
 }
 
-PyObject* Sensor_get_value(SensorObject* self) {
+static PyObject* Sensor_get_value(SensorObject* self) {
        sensors_subfeature_type subfeature_type;
 
        switch (self->feature->type) {
@@ -258,7 +204,7 @@ PyObject* Sensor_get_value(SensorObject* self) {
        return Sensor_return_value(self, subfeature_type);
 }
 
-PyObject* Sensor_get_critical(SensorObject* self) {
+static PyObject* Sensor_get_critical(SensorObject* self) {
        sensors_subfeature_type subfeature_type;
 
        switch (self->feature->type) {
@@ -281,7 +227,7 @@ PyObject* Sensor_get_critical(SensorObject* self) {
        return Sensor_return_value(self, subfeature_type);
 }
 
-PyObject* Sensor_get_maximum(SensorObject* self) {
+static PyObject* Sensor_get_maximum(SensorObject* self) {
        sensors_subfeature_type subfeature_type;
 
        switch (self->feature->type) {
@@ -308,7 +254,7 @@ PyObject* Sensor_get_maximum(SensorObject* self) {
        return Sensor_return_value(self, subfeature_type);
 }
 
-PyObject* Sensor_get_minimum(SensorObject* self) {
+static PyObject* Sensor_get_minimum(SensorObject* self) {
        sensors_subfeature_type subfeature_type;
 
        switch (self->feature->type) {
@@ -331,7 +277,7 @@ PyObject* Sensor_get_minimum(SensorObject* self) {
        return Sensor_return_value(self, subfeature_type);
 }
 
-PyObject* Sensor_get_high(SensorObject* self) {
+static PyObject* Sensor_get_high(SensorObject* self) {
        sensors_subfeature_type subfeature_type;
 
        switch (self->feature->type) {
@@ -425,3 +371,57 @@ PyObject* _collecty_get_detected_sensors(PyObject* o, PyObject* args) {
 
        return list;
 }
+
+static PyGetSetDef Sensor_getsetters[] = {
+       {"bus", (getter)Sensor_get_bus, NULL, NULL, NULL},
+       {"critical", (getter)Sensor_get_critical, NULL, NULL, NULL},
+       {"high", (getter)Sensor_get_high, NULL, NULL, NULL},
+       {"label", (getter)Sensor_get_label, NULL, NULL, NULL},
+       {"maximum", (getter)Sensor_get_maximum, NULL, NULL, NULL},
+       {"minumum", (getter)Sensor_get_minimum, NULL, NULL, NULL},
+       {"name", (getter)Sensor_get_name, NULL, NULL, NULL},
+       {"type", (getter)Sensor_get_type, NULL, NULL, NULL},
+       {"value", (getter)Sensor_get_value, NULL, NULL, NULL},
+       { NULL },
+};
+
+PyTypeObject SensorType = {
+       PyObject_HEAD_INIT(NULL)
+       "_collecty.Sensor",                 /*tp_name*/
+       sizeof(SensorObject),               /*tp_basicsize*/
+       0,                                  /*tp_itemsize*/
+       (destructor)Sensor_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*/
+       "Sensor objects",                   /* tp_doc */
+       0,                                  /* tp_traverse */
+       0,                                  /* tp_clear */
+       0,                                  /* tp_richcompare */
+       0,                                  /* tp_weaklistoffset */
+       0,                                  /* tp_iter */
+       0,                                  /* tp_iternext */
+       0,                                  /* tp_methods */
+       0,                                  /* tp_members */
+       Sensor_getsetters,                  /* tp_getset */
+       0,                                  /* tp_base */
+       0,                                  /* tp_dict */
+       0,                                  /* tp_descr_get */
+       0,                                  /* tp_descr_set */
+       0,                                  /* tp_dictoffset */
+       (initproc)Sensor_init,              /* tp_init */
+       0,                                  /* tp_alloc */
+       Sensor_new,                         /* tp_new */
+};