projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Explain the need for _GNU_SOURCE
[collectd.git]
/
src
/
openldap.c
diff --git
a/src/openldap.c
b/src/openldap.c
index
dc93334
..
e100aee
100644
(file)
--- a/
src/openldap.c
+++ b/
src/openldap.c
@@
-27,9
+27,14
@@
**/
#include "collectd.h"
**/
#include "collectd.h"
+
#include "common.h"
#include "plugin.h"
#include "common.h"
#include "plugin.h"
-#include "configfile.h"
+
+#if defined(__APPLE__)
+#pragma clang diagnostic push
+#pragma clang diagnostic warning "-Wdeprecated-declarations"
+#endif
#include <lber.h>
#include <ldap.h>
#include <lber.h>
#include <ldap.h>
@@
-164,11
+169,7
@@
static void cldap_submit_value (const char *type, const char *type_instance, /*
vl.values = &value;
vl.values_len = 1;
vl.values = &value;
vl.values_len = 1;
- if ((st->host == NULL)
- || (strcmp ("", st->host) == 0)
- || (strcmp ("localhost", st->host) == 0))
- sstrncpy (vl.host, hostname_g, sizeof (vl.host));
- else
+ if ((st->host != NULL) && (strcmp ("localhost", st->host) != 0))
sstrncpy (vl.host, st->host, sizeof (vl.host));
sstrncpy (vl.plugin, "openldap", sizeof (vl.plugin));
sstrncpy (vl.host, st->host, sizeof (vl.host));
sstrncpy (vl.plugin, "openldap", sizeof (vl.plugin));
@@
-187,23
+188,19
@@
static void cldap_submit_value (const char *type, const char *type_instance, /*
static void cldap_submit_derive (const char *type, const char *type_instance, /* {{{ */
derive_t d, cldap_t *st)
{
static void cldap_submit_derive (const char *type, const char *type_instance, /* {{{ */
derive_t d, cldap_t *st)
{
- value_t v;
- v.derive = d;
- cldap_submit_value (type, type_instance, v, st);
+ cldap_submit_value (type, type_instance, (value_t) { .derive = d }, st);
} /* }}} void cldap_submit_derive */
static void cldap_submit_gauge (const char *type, const char *type_instance, /* {{{ */
gauge_t g, cldap_t *st)
{
} /* }}} void cldap_submit_derive */
static void cldap_submit_gauge (const char *type, const char *type_instance, /* {{{ */
gauge_t g, cldap_t *st)
{
- value_t v;
- v.gauge = g;
- cldap_submit_value (type, type_instance, v, st);
+ cldap_submit_value (type, type_instance, (value_t) { .gauge = g }, st);
} /* }}} void cldap_submit_gauge */
static int cldap_read_host (user_data_t *ud) /* {{{ */
{
cldap_t *st;
} /* }}} void cldap_submit_gauge */
static int cldap_read_host (user_data_t *ud) /* {{{ */
{
cldap_t *st;
- LDAPMessage *
e, *
result;
+ LDAPMessage *result;
char *dn;
int rc;
int status;
char *dn;
int rc;
int status;
@@
-244,7
+241,7
@@
static int cldap_read_host (user_data_t *ud) /* {{{ */
return (-1);
}
return (-1);
}
- for (e = ldap_first_entry (st->ld, result); e != NULL;
+ for (
LDAPMessage *
e = ldap_first_entry (st->ld, result); e != NULL;
e = ldap_next_entry (st->ld, e))
{
if ((dn = ldap_get_dn (st->ld, e)) != NULL)
e = ldap_next_entry (st->ld, e))
{
if ((dn = ldap_get_dn (st->ld, e)) != NULL)
@@
-553,16
+550,14
@@
static int cldap_read_host (user_data_t *ud) /* {{{ */
static int cldap_config_add (oconfig_item_t *ci) /* {{{ */
{
cldap_t *st;
static int cldap_config_add (oconfig_item_t *ci) /* {{{ */
{
cldap_t *st;
- int i;
int status;
int status;
- st =
malloc (
sizeof (*st));
+ st =
calloc (1,
sizeof (*st));
if (st == NULL)
{
if (st == NULL)
{
- ERROR ("openldap plugin:
m
alloc failed.");
+ ERROR ("openldap plugin:
c
alloc failed.");
return (-1);
}
return (-1);
}
- memset (st, 0, sizeof (*st));
status = cf_util_get_string (ci, &st->name);
if (status != 0)
status = cf_util_get_string (ci, &st->name);
if (status != 0)
@@
-572,11
+567,11
@@
static int cldap_config_add (oconfig_item_t *ci) /* {{{ */
}
st->starttls = 0;
}
st->starttls = 0;
- st->timeout = (long)
(CDTIME_T_TO_MS(plugin_get_interval()) / 1000
);
+ st->timeout = (long)
CDTIME_T_TO_TIME_T(plugin_get_interval()
);
st->verifyhost = 1;
st->version = LDAP_VERSION3;
st->verifyhost = 1;
st->version = LDAP_VERSION3;
- for (i = 0; i < ci->children_num; i++)
+ for (i
nt i
= 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;
{
oconfig_item_t *child = ci->children + i;
@@
-620,9
+615,8
@@
static int cldap_config_add (oconfig_item_t *ci) /* {{{ */
if ((status == 0) && (st->url != NULL))
{
LDAPURLDesc *ludpp;
if ((status == 0) && (st->url != NULL))
{
LDAPURLDesc *ludpp;
- int rc;
- if (
(rc = ldap_url_parse (st->url, &ludpp)
) != 0)
+ if (
ldap_url_parse (st->url, &ludpp
) != 0)
{
ERROR ("openldap plugin: Instance `%s': "
"Invalid URL: `%s'",
{
ERROR ("openldap plugin: Instance `%s': "
"Invalid URL: `%s'",
@@
-650,27
+644,24
@@
static int cldap_config_add (oconfig_item_t *ci) /* {{{ */
}
else
{
}
else
{
- user_data_t ud;
- char callback_name[3*DATA_MAX_NAME_LEN];
+ char callback_name[3*DATA_MAX_NAME_LEN] = { 0 };
databases = temp;
databases[databases_num] = st;
databases_num++;
databases = temp;
databases[databases_num] = st;
databases_num++;
- memset (&ud, 0, sizeof (ud));
- ud.data = st;
-
- memset (callback_name, 0, sizeof (callback_name));
ssnprintf (callback_name, sizeof (callback_name),
"openldap/%s/%s",
(st->host != NULL) ? st->host : hostname_g,
ssnprintf (callback_name, sizeof (callback_name),
"openldap/%s/%s",
(st->host != NULL) ? st->host : hostname_g,
- (st->name != NULL) ? st->name : "default")
,
+ (st->name != NULL) ? st->name : "default")
;
status = plugin_register_complex_read (/* group = */ NULL,
/* name = */ callback_name,
/* callback = */ cldap_read_host,
/* interval = */ 0,
status = plugin_register_complex_read (/* group = */ NULL,
/* name = */ callback_name,
/* callback = */ cldap_read_host,
/* interval = */ 0,
- /* user_data = */ &ud);
+ &(user_data_t) {
+ .data = st,
+ });
}
}
}
}
@@
-685,10
+676,9
@@
static int cldap_config_add (oconfig_item_t *ci) /* {{{ */
static int cldap_config (oconfig_item_t *ci) /* {{{ */
{
static int cldap_config (oconfig_item_t *ci) /* {{{ */
{
- int i;
int status = 0;
int status = 0;
- for (i = 0; i < ci->children_num; i++)
+ for (i
nt i
= 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;
{
oconfig_item_t *child = ci->children + i;
@@
-718,9
+708,7
@@
static int cldap_init (void) /* {{{ */
static int cldap_shutdown (void) /* {{{ */
{
static int cldap_shutdown (void) /* {{{ */
{
- size_t i;
-
- for (i = 0; i < databases_num; i++)
+ for (size_t i = 0; i < databases_num; i++)
if (databases[i]->ld != NULL)
ldap_unbind_ext_s (databases[i]->ld, NULL, NULL);
sfree (databases);
if (databases[i]->ld != NULL)
ldap_unbind_ext_s (databases[i]->ld, NULL, NULL);
sfree (databases);
@@
-735,3
+723,7
@@
void module_register (void) /* {{{ */
plugin_register_init ("openldap", cldap_init);
plugin_register_shutdown ("openldap", cldap_shutdown);
} /* }}} void module_register */
plugin_register_init ("openldap", cldap_init);
plugin_register_shutdown ("openldap", cldap_shutdown);
} /* }}} void module_register */
+
+#if defined(__APPLE__)
+#pragma clang diagnostic pop
+#endif