aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-05-16 00:37:34 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2018-07-10 23:41:14 +0200
commitc8d0593d6495e87603806ada76a399500cdc2831 (patch)
treed0d9dc88a43ab30a3712a7946d21baea837bebfb /src
parent4f40dc104633e44d3b021fafb1057b7669616926 (diff)
Fix memory leak and avoid compile warning
Change-Id: Ib0bcba9daad456f63c0ea704e1fa87f44b6acc98 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src')
-rw-r--r--src/harvester.c10
-rw-r--r--src/plugins/influxdb-reader.c5
-rw-r--r--src/plugins/influxdb-writer.c6
-rw-r--r--src/plugins/influxdb.c6
4 files changed, 12 insertions, 15 deletions
diff --git a/src/harvester.c b/src/harvester.c
index 30ba486..1d4d9a6 100644
--- a/src/harvester.c
+++ b/src/harvester.c
@@ -48,9 +48,9 @@ void afv_write(struct afb_req req)
*metric = NULL;
if(wrap_json_unpack(req_args, "{s?s,s?o,so!}",
- "host", &host,
- "port", &portJ,
- "metric", &metric) || ! metric)
+ "host", &host,
+ "port", &portJ,
+ "metric", &metric) || ! metric)
afb_req_fail(req, "Failed", "Error processing arguments. Miss metric\
JSON object or malformed");
else {
@@ -82,10 +82,10 @@ int init()
case INFLUX:
tsdb_write = influxdb_write;
write_curl_cb = influxdb_write_curl_cb;
- if(influxdb_reader(&r_args) != 0) {
+ /*if(influxdb_reader(&r_args) != 0) {
AFB_ERROR("Problem initiating reader timer. Abort");
return ERROR;
- }
+ }*/
break;
default:
AFB_ERROR("No Time Series Database found. Abort");
diff --git a/src/plugins/influxdb-reader.c b/src/plugins/influxdb-reader.c
index b6bef25..a1fa3a0 100644
--- a/src/plugins/influxdb-reader.c
+++ b/src/plugins/influxdb-reader.c
@@ -91,7 +91,6 @@ static void unpack_metric_from_db(void *ml, json_object *metricJ)
wrap_json_array_for_all(columnsJ, fill_key, m_list);
wrap_json_array_for_all(valuesJ, fill_n_send_values, m_list);
-
}
static json_object *unpack_series(json_object *seriesJ)
@@ -176,7 +175,7 @@ static CURL *make_curl_query_get(const char *url)
args[0] = "epoch";
args[1] = "ns";
args[2] = "q";
- strncat(query, "SELECT * FROM /^.*$/", strlen("SELECT * FROM /^.*$/"));
+ strcat(query, "SELECT * FROM /^.*$/");
args[4] = NULL;
length_now = asprintf(&now, "%lu", get_ts());
@@ -192,7 +191,7 @@ static CURL *make_curl_query_get(const char *url)
AFB_ERROR("Error writing last_db_read file: %s\n", strerror( errno ));
}
else {
- strncat(query, " WHERE time >= ", strlen(" WHERE time >= "));
+ strcat(query, " WHERE time >= ");
strncat(query, last_ts, strlen(last_ts));
close(fd_last_read);
fd_last_read = openat(rootdir_fd, "last_db_read", O_TRUNC | O_RDWR);
diff --git a/src/plugins/influxdb-writer.c b/src/plugins/influxdb-writer.c
index fdb1a2a..c21f4fd 100644
--- a/src/plugins/influxdb-writer.c
+++ b/src/plugins/influxdb-writer.c
@@ -132,15 +132,13 @@ CURL *make_curl_write_post(const char *url, json_object *metricsJ)
}
}
- post_data[i] = NULL;
-
/* Check that we just do not broke the for loop before trying preparing CURL
request object */
curl = i == lpd ?
curl_wrap_prepare_post_unescaped(url, NULL, "\n", (const char * const*)post_data) : NULL;
free(serie);
- /*for(i = 0; i < lpd; i++)
- free(post_data[i]);*/
+ for(i = 0; i < lpd; i++)
+ free(post_data[i]);
free(post_data);
return curl;
diff --git a/src/plugins/influxdb.c b/src/plugins/influxdb.c
index 27161ab..a98bd2b 100644
--- a/src/plugins/influxdb.c
+++ b/src/plugins/influxdb.c
@@ -41,11 +41,11 @@ size_t make_url(char *url, size_t l_url, const char *host, const char *port, con
port = port ? port : DEFAULT_DBPORT;
strncat(url, host, strlen(host));
- strncat(url, ":", 1);
+ strcat(url, ":");
strncat(url, port, strlen(port));
- strncat(url, "/", 1);
+ strcat(url, "/");
strncat(url, endpoint, strlen(endpoint));
- strncat(url, "?db="DEFAULT_DB, strlen("?db="DEFAULT_DB));
+ strcat(url, "?db="DEFAULT_DB);
return strlen(url);
}