X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fwrite_kafka.c;h=e881593b65161e20af6b697dd122ca2e402829c0;hb=5eb1fef6de7e0c8fb99e3d85063d96d7cc785f9b;hp=37b3e14f25ef821aea4b93332007b26173473253;hpb=01e2d29ebc5dec07daab935da3fcee5bb9c7d620;p=collectd.git diff --git a/src/write_kafka.c b/src/write_kafka.c index 37b3e14f..e881593b 100644 --- a/src/write_kafka.c +++ b/src/write_kafka.c @@ -36,7 +36,6 @@ #include #include -#include #include #include @@ -202,6 +201,8 @@ static int kafka_write(const data_set_t *ds, /* {{{ */ key = ctx->key; if (key != NULL) keylen = strlen (key); + else + keylen = 0; rd_kafka_produce(ctx->topic, RD_KAFKA_PARTITION_UA, RD_KAFKA_MSG_F_COPY, buffer, blen, @@ -252,6 +253,7 @@ static void kafka_config_topic(rd_kafka_conf_t *conf, oconfig_item_t *ci) /* {{{ tctx->escape_char = '.'; tctx->store_rates = 1; tctx->format = KAFKA_FORMAT_JSON; + tctx->key = NULL; if ((tctx->kafka_conf = rd_kafka_conf_dup(conf)) == NULL) { sfree(tctx); @@ -315,6 +317,7 @@ static void kafka_config_topic(rd_kafka_conf_t *conf, oconfig_item_t *ci) /* {{{ } else if (strcasecmp ("Key", child->key) == 0) { cf_util_get_string (child, &tctx->key); + assert (tctx->key != NULL); } else if (strcasecmp ("Format", child->key) == 0) { status = cf_util_get_string(child, &key); if (status != 0)