author | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Fri, 5 Aug 2016 11:17:32 +0000 (13:17 +0200) | ||
committer | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Fri, 5 Aug 2016 11:17:32 +0000 (13:17 +0200) |
Conflicts:
src/pyvalues.c
src/pyvalues.c
1 | 2 | |||
---|---|---|---|---|
src/daemon/plugin.c | patch | | diff1 | | diff2 | | blob | history |
src/network.c | patch | | diff1 | | diff2 | | blob | history |
src/pyvalues.c | patch | | diff1 | | diff2 | | blob | history |
diff --cc src/daemon/plugin.c
index 2ccc68c21ccc2d1fa566b602e0186085baae718a,1deabba3dde599a3c203258e1b26200519d6951c..1bee8cdd48693da128558e7579af53b37a370106
--- 1/src/daemon/plugin.c
--- 2/src/daemon/plugin.c
+++ b/src/daemon/plugin.c
return (0);
} /* int plugin_flush */
-void plugin_shutdown_all (void)
+int plugin_shutdown_all (void)
{
llentry_t *le;
+ int ret = 0; // Assume success.
- stop_read_threads ();
-
destroy_all_callbacks (&list_init);
+ stop_read_threads ();
+
pthread_mutex_lock (&read_lock);
llist_destroy (read_list);
read_list = NULL;
diff --cc src/network.c
index 1b560c4721750a2be34a221a2d9fd374dfe2a896,c6845eb9696198cc068e88686fb439e82bfc9df6..58ddb225fcd03854da5867096dac49cb6e4e503d
--- 1/src/network.c
--- 2/src/network.c
+++ b/src/network.c
have_init = 1;
#if HAVE_LIBGCRYPT
- network_init_gcrypt ();
+ if (network_init_gcrypt () < 0)
+ {
+ ERROR ("network plugin: Failed to initialize crypto library.");
+ return (-1);
+ }
#endif
- if (network_config_stats != 0)
+ if (network_config_stats)
plugin_register_read ("network", network_stats_read);
plugin_register_shutdown ("network", network_shutdown);
diff --cc src/pyvalues.c
index bd2088dc2e52c922b575aedf19c1e43bdce471ab,0ea81f8c986c6fcba479d85f3f0ec73ebed9f1aa..a7cb792357fcef570fe4f6d04902d26b4f17204e
--- 1/src/pyvalues.c
--- 2/src/pyvalues.c
+++ b/src/pyvalues.c
PyErr_Format(PyExc_TypeError, "meta must be a dict");
return NULL;
}
- size = (int) PySequence_Length(values);
+ size = (size_t) PySequence_Length(values);
if (size != ds->ds_num) {
- PyErr_Format(PyExc_RuntimeError, "type %s needs %d values, got %i", value_list.type, ds->ds_num, size);
+ PyErr_Format(PyExc_RuntimeError, "type %s needs %zu values, got %zu", value_list.type, ds->ds_num, size);
return NULL;
}
- value = malloc(size * sizeof(*value));
- for (i = 0; i < size; ++i) {
+ value = calloc(size, sizeof(*value));
+ for (size_t i = 0; i < size; ++i) {
PyObject *item, *num;
- item = PySequence_Fast_GET_ITEM(values, i); /* Borrowed reference. */
+ item = PySequence_Fast_GET_ITEM(values, (int) i); /* Borrowed reference. */
- if (ds->ds->type == DS_TYPE_COUNTER) {
+ switch (ds->ds[i].type) {
+ case DS_TYPE_COUNTER:
num = PyNumber_Long(item); /* New reference. */
if (num != NULL) {
value[i].counter = PyLong_AsUnsignedLongLong(num);
PyErr_Format(PyExc_TypeError, "values must be list or tuple");
return NULL;
}
- size = (int) PySequence_Length(values);
+ size = (size_t) PySequence_Length(values);
if (size != ds->ds_num) {
- PyErr_Format(PyExc_RuntimeError, "type %s needs %d values, got %i", value_list.type, ds->ds_num, size);
+ PyErr_Format(PyExc_RuntimeError, "type %s needs %zu values, got %zu", value_list.type, ds->ds_num, size);
return NULL;
}
- value = malloc(size * sizeof(*value));
- for (i = 0; i < size; ++i) {
+ value = calloc(size, sizeof(*value));
+ for (size_t i = 0; i < size; ++i) {
PyObject *item, *num;
item = PySequence_Fast_GET_ITEM(values, i); /* Borrowed reference. */
- if (ds->ds->type == DS_TYPE_COUNTER) {
+ switch (ds->ds[i].type) {
+ case DS_TYPE_COUNTER:
num = PyNumber_Long(item); /* New reference. */
if (num != NULL) {
value[i].counter = PyLong_AsUnsignedLongLong(num);