From 8e7edc6d1ebefa48ecc859cca69cc01e656bfbe9 Mon Sep 17 00:00:00 2001 From: john30 Date: Sun, 8 Jan 2017 16:38:30 +0100 Subject: [PATCH] fix for argp usage --- src/ebusd/datahandler.cpp | 8 ++++---- src/ebusd/mqtthandler.cpp | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/ebusd/datahandler.cpp b/src/ebusd/datahandler.cpp index 7d9c7950..a14fb2a1 100644 --- a/src/ebusd/datahandler.cpp +++ b/src/ebusd/datahandler.cpp @@ -31,7 +31,7 @@ using namespace std; static const struct argp_child g_last_argp_child = {NULL, 0, NULL, 0}; /** the list of @a argp_child structures. */ -static const struct argp_child* g_argp_children[ +static struct argp_child g_argp_children[ #ifdef HAVE_MQTT 1 #endif @@ -42,11 +42,11 @@ const struct argp_child* datahandler_getargs() { size_t count = 0; #ifdef HAVE_MQTT - g_argp_children[count++] = mqtthandler_getargs(); + g_argp_children[count++] = *mqtthandler_getargs(); #endif if (count>0) { - g_argp_children[count] = &g_last_argp_child; - return g_argp_children[0]; + g_argp_children[count] = g_last_argp_child; + return g_argp_children; } return NULL; } diff --git a/src/ebusd/mqtthandler.cpp b/src/ebusd/mqtthandler.cpp index 5aa6effb..e95938f3 100644 --- a/src/ebusd/mqtthandler.cpp +++ b/src/ebusd/mqtthandler.cpp @@ -69,7 +69,7 @@ static error_t mqtt_parse_opt(int key, char *arg, struct argp_state *state) return 0; } -static struct argp g_mqtt_argp = { g_mqtt_argp_options, mqtt_parse_opt, NULL, NULL, NULL, NULL, NULL }; +static const struct argp g_mqtt_argp = { g_mqtt_argp_options, mqtt_parse_opt, NULL, NULL, NULL, NULL, NULL }; static const struct argp_child g_mqtt_argp_child = {&g_mqtt_argp, 0, "", 1}; const struct argp_child* mqtthandler_getargs() @@ -151,6 +151,9 @@ MqttHandler::MqttHandler(BusHandler* busHandler, MessageMap* messages) logOtherError("mqtt", "malformed topic %s", g_topic); return; } + if (!enabled) { + return; + } if (m_topicCols.empty()) { if (m_topicStrs.empty()) { m_topicStrs.push_back("");