X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Famqp.c;h=fc69e936554a6418b7be9d05784c7bba798a2a13;hb=354f9991530248e45207d236eb74c1cc3d5238ef;hp=97359cfd394facc2fa81669385c3bedecd019d98;hpb=979b0fa58b2de639ff79209eff12ec17ff593483;p=collectd.git diff --git a/src/amqp.c b/src/amqp.c index 97359cfd..fc69e936 100644 --- a/src/amqp.c +++ b/src/amqp.c @@ -199,11 +199,11 @@ static char *camqp_strerror (camqp_config_t *conf, /* {{{ */ switch (r.reply_type) { case AMQP_RESPONSE_NORMAL: - sstrncpy (buffer, "Success", sizeof (buffer)); + sstrncpy (buffer, "Success", buffer_size); break; case AMQP_RESPONSE_NONE: - sstrncpy (buffer, "Missing RPC reply type", sizeof (buffer)); + sstrncpy (buffer, "Missing RPC reply type", buffer_size); break; case AMQP_RESPONSE_LIBRARY_EXCEPTION: @@ -215,7 +215,7 @@ static char *camqp_strerror (camqp_config_t *conf, /* {{{ */ return (sstrerror (r.library_error, buffer, buffer_size)); #endif else - sstrncpy (buffer, "End of stream", sizeof (buffer)); + sstrncpy (buffer, "End of stream", buffer_size); break; case AMQP_RESPONSE_SERVER_EXCEPTION: @@ -716,7 +716,7 @@ static void *camqp_subscribe_thread (void *user_data) /* {{{ */ continue; } - status = camqp_read_header (conf); + camqp_read_header (conf); amqp_maybe_release_buffers (conf->connection); } /* while (subscriber_threads_running) */ @@ -736,7 +736,7 @@ static int camqp_subscribe_init (camqp_config_t *conf) /* {{{ */ if (tmp == NULL) { ERROR ("amqp plugin: realloc failed."); - camqp_config_free (conf); + sfree (subscriber_threads); return (ENOMEM); } subscriber_threads = tmp; @@ -750,7 +750,6 @@ static int camqp_subscribe_init (camqp_config_t *conf) /* {{{ */ char errbuf[1024]; ERROR ("amqp plugin: pthread_create failed: %s", sstrerror (status, errbuf, sizeof (errbuf))); - camqp_config_free (conf); return (status); } @@ -925,15 +924,14 @@ static int camqp_config_connection (oconfig_item_t *ci, /* {{{ */ int status; int i; - conf = malloc (sizeof (*conf)); + conf = calloc (1, sizeof (*conf)); if (conf == NULL) { - ERROR ("amqp plugin: malloc failed."); + ERROR ("amqp plugin: calloc failed."); return (ENOMEM); } /* Initialize "conf" {{{ */ - memset (conf, 0, sizeof (*conf)); conf->publish = publish; conf->name = NULL; conf->format = CAMQP_FORMAT_COMMAND;