Code

python plugin: Cast pointer to `void *' to work around strict aliasing problems.
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Tue, 8 Dec 2009 10:53:10 +0000 (11:53 +0100)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Tue, 8 Dec 2009 10:53:10 +0000 (11:53 +0100)
python.c: In function `cpy_write_callback':
python.c:349: warning: dereferencing type-punned pointer will break strict-aliasing rules
python.c: In function `cpy_notification_callback':
python.c:368: warning: dereferencing type-punned pointer will break strict-aliasing rules
python.c: In function `cpy_oconfig_to_pyconfig':
python.c:842: warning: dereferencing type-punned pointer will break strict-aliasing rules
python.c: In function `cpy_config':
python.c:887: warning: dereferencing type-punned pointer will break strict-aliasing rules
python.c:888: warning: dereferencing type-punned pointer will break strict-aliasing rules
python.c:889: warning: dereferencing type-punned pointer will break strict-aliasing rules

src/python.c

index ae853c38e8be412d05092fdf49914d397765b66f..8491649b5090807440c79d7b5a36ff41f3e37cd8 100644 (file)
@@ -346,7 +346,7 @@ static int cpy_write_callback(const data_set_t *ds, const value_list_t *value_li
                                CPY_RETURN_FROM_THREADS 0;
                        }
                }
-               v = PyObject_CallFunction((PyObject *) &ValuesType, "sOssssdi", value_list->type, list,
+               v = PyObject_CallFunction((void *) &ValuesType, "sOssssdi", value_list->type, list,
                                value_list->plugin_instance, value_list->type_instance, value_list->plugin,
                                value_list->host, (double) value_list->time, value_list->interval);
                Py_DECREF(list);
@@ -365,7 +365,7 @@ static int cpy_notification_callback(const notification_t *notification, user_da
        PyObject *ret, *n;
 
        CPY_LOCK_THREADS
-               n = PyObject_CallFunction((PyObject *) &NotificationType, "ssssssdi", notification->type, notification->message,
+               n = PyObject_CallFunction((void *) &NotificationType, "ssssssdi", notification->type, notification->message,
                                notification->plugin_instance, notification->type_instance, notification->plugin,
                                notification->host, (double) notification->time, notification->severity);
                ret = PyObject_CallFunctionObjArgs(c->callback, n, c->data, (void *) 0); /* New reference. */
@@ -839,7 +839,7 @@ static PyObject *cpy_oconfig_to_pyconfig(oconfig_item_t *ci, PyObject *parent) {
                }
        }
        
-       item = PyObject_CallFunction((PyObject *) &ConfigType, "sONO", ci->key, parent, values, Py_None);
+       item = PyObject_CallFunction((void *) &ConfigType, "sONO", ci->key, parent, values, Py_None);
        if (item == NULL)
                return NULL;
        children = PyTuple_New(ci->children_num); /* New reference. */
@@ -884,9 +884,9 @@ static int cpy_config(oconfig_item_t *ci) {
                return 1;
        }
        module = Py_InitModule("collectd", cpy_methods); /* Borrowed reference. */
-       PyModule_AddObject(module, "Config", (PyObject *) &ConfigType); /* Steals a reference. */
-       PyModule_AddObject(module, "Values", (PyObject *) &ValuesType); /* Steals a reference. */
-       PyModule_AddObject(module, "Notification", (PyObject *) &NotificationType); /* Steals a reference. */
+       PyModule_AddObject(module, "Config", (void *) &ConfigType); /* Steals a reference. */
+       PyModule_AddObject(module, "Values", (void *) &ValuesType); /* Steals a reference. */
+       PyModule_AddObject(module, "Notification", (void *) &NotificationType); /* Steals a reference. */
        PyModule_AddIntConstant(module, "LOG_DEBUG", LOG_DEBUG);
        PyModule_AddIntConstant(module, "LOG_INFO", LOG_INFO);
        PyModule_AddIntConstant(module, "LOG_NOTICE", LOG_NOTICE);