X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fperl.c;h=d2a00bfde5ec316e2482bbf7deb1148a7a13dac2;hb=1b10ab706f8b70ce2f086e59a54cc09d671ad989;hp=f58e02ab4ae9077b4e73b012da340275fce29a6e;hpb=01d23e3f5daf016d03f82d92a76be2fe3decdca4;p=collectd.git diff --git a/src/perl.c b/src/perl.c index f58e02ab..d2a00bfd 100644 --- a/src/perl.c +++ b/src/perl.c @@ -38,9 +38,7 @@ #undef DONT_POISON_SPRINTF_YET -#if HAVE_STDBOOL_H #include -#endif #include #include @@ -426,8 +424,6 @@ static int hv2value_list(pTHX_ HV *hash, value_list_t *vl) { if (NULL != (tmp = hv_fetch(hash, "host", 4, 0))) sstrncpy(vl->host, SvPV_nolen(*tmp), sizeof(vl->host)); - else - sstrncpy(vl->host, hostname_g, sizeof(vl->host)); if (NULL != (tmp = hv_fetch(hash, "plugin", 6, 0))) sstrncpy(vl->plugin, SvPV_nolen(*tmp), sizeof(vl->plugin)); @@ -496,7 +492,8 @@ static int av2data_set(pTHX_ AV *array, char *name, data_set_t *ds) { * meta => [ { name => , value => }, ... ] * } */ -static int av2notification_meta(pTHX_ AV *array, notification_meta_t **ret_meta) { +static int av2notification_meta(pTHX_ AV *array, + notification_meta_t **ret_meta) { notification_meta_t *tail = NULL; int len = av_len(array); @@ -883,12 +880,12 @@ static int oconfig_item2hv(pTHX_ oconfig_item_t *ci, HV *hash) { static char *get_module_name(char *buf, size_t buf_len, const char *module) { int status = 0; if (base_name[0] == '\0') - status = ssnprintf(buf, buf_len, "%s", module); + status = snprintf(buf, buf_len, "%s", module); else - status = ssnprintf(buf, buf_len, "%s::%s", base_name, module); + status = snprintf(buf, buf_len, "%s::%s", base_name, module); if ((status < 0) || ((unsigned int)status >= buf_len)) - return (NULL); - return (buf); + return NULL; + return buf; } /* char *get_module_name */ /* @@ -1627,18 +1624,19 @@ static void _plugin_register_generic_userdata(pTHX, int type, ret = plugin_register_flush("perl", perl_flush, /* user_data = */ NULL); } - if (0 == ret) + if (0 == ret) { ret = plugin_register_flush(pluginname, perl_flush, &userdata); + } else { + free(userdata.data); + } } else { ret = -1; } if (0 == ret) XSRETURN_YES; - else { - free(userdata.data); + else XSRETURN_EMPTY; - } } /* static void _plugin_register_generic_userdata ( ... ) */ /* @@ -2499,7 +2497,7 @@ static int perl_config_loadplugin(pTHX_ oconfig_item_t *ci) { if (NULL == get_module_name(module_name, sizeof(module_name), value)) { log_err("Invalid module name %s", value); - return (1); + return 1; } if (0 != init_pi(perl_argc, perl_argv)) @@ -2725,5 +2723,3 @@ void module_register(void) { plugin_register_complex_config("perl", perl_config); return; } /* void module_register (void) */ - -/* vim: set sw=4 ts=4 tw=78 noexpandtab : */