From 6c66fd553b961fe07cdeca8c16537b126f68ccdd Mon Sep 17 00:00:00 2001 From: John Date: Thu, 12 Oct 2023 21:29:31 +0200 Subject: [PATCH] lint, docs, remove unused includes --- src/ebusd/main_args.cpp | 9 +-------- src/ebusd/mqttclient.cpp | 2 +- src/ebusd/mqttclient.h | 4 ++-- src/lib/knx/knx.cpp | 2 +- src/lib/knx/knxnet.h | 8 ++++---- src/lib/utils/arg.cpp | 16 ++++++++-------- 6 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/ebusd/main_args.cpp b/src/ebusd/main_args.cpp index 82d92141..be8a0da1 100755 --- a/src/ebusd/main_args.cpp +++ b/src/ebusd/main_args.cpp @@ -21,14 +21,7 @@ #endif #include "ebusd/main.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include #include "ebusd/datahandler.h" #include "lib/utils/log.h" #include "lib/utils/arg.h" diff --git a/src/ebusd/mqttclient.cpp b/src/ebusd/mqttclient.cpp index d752c3fb..2d9c127f 100644 --- a/src/ebusd/mqttclient.cpp +++ b/src/ebusd/mqttclient.cpp @@ -26,7 +26,7 @@ namespace ebusd { -// copydoc +// @copydoc MqttClient* MqttClient::create(mqtt_client_config_t config, MqttClientListener *listener) { return new MqttClientMosquitto(config, listener); } diff --git a/src/ebusd/mqttclient.h b/src/ebusd/mqttclient.h index febaa048..5309d31a 100755 --- a/src/ebusd/mqttclient.h +++ b/src/ebusd/mqttclient.h @@ -91,7 +91,7 @@ class MqttClient { * @param config the client configuration to use. * @param listener the client listener to use. */ - MqttClient(mqtt_client_config_t config, MqttClientListener *listener) + MqttClient(const mqtt_client_config_t config, MqttClientListener *listener) : m_config(config), m_listener(listener) {} /** @@ -146,7 +146,7 @@ class MqttClient { public: /** the client configuration to use. */ - mqtt_client_config_t m_config; + const mqtt_client_config_t m_config; /** the @a MqttClientListener instance. */ MqttClientListener* m_listener; diff --git a/src/lib/knx/knx.cpp b/src/lib/knx/knx.cpp index 6bd1f7d9..f47df2ec 100644 --- a/src/lib/knx/knx.cpp +++ b/src/lib/knx/knx.cpp @@ -88,7 +88,7 @@ knx_addr_t parseAddress(const string &str, bool isGroup, bool* error) { return 0; } -// copydoc +// @copydoc KnxConnection *KnxConnection::create(const char *url) { #ifdef HAVE_KNXD if (strchr(url, ':')) { diff --git a/src/lib/knx/knxnet.h b/src/lib/knx/knxnet.h index 16de8bf0..73ce156f 100644 --- a/src/lib/knx/knxnet.h +++ b/src/lib/knx/knxnet.h @@ -684,12 +684,12 @@ class KnxNetConnection : public KnxConnection { return nullptr; } - // copydoc + // @copydoc knx_addr_t getAddress() const override { return m_addr; } - // copydoc + // @copydoc void setAddress(knx_addr_t address) override { m_addr = address; // flush duplication check buffers @@ -697,12 +697,12 @@ class KnxNetConnection : public KnxConnection { m_lastSentFrames.reset(); } - // copydoc + // @copydoc bool isProgrammingMode() const override { return m_programmingMode; } - // copydoc + // @copydoc void setProgrammingMode(bool on) override { m_programmingMode = on; } diff --git a/src/lib/utils/arg.cpp b/src/lib/utils/arg.cpp index 86b81668..7653271f 100755 --- a/src/lib/utils/arg.cpp +++ b/src/lib/utils/arg.cpp @@ -60,9 +60,9 @@ void buildOpts(const argDef *argDefs, int &count, int &shortCharsCount, int &sho opt->flag = nullptr; opt->val = argDefIdx; if (isAlpha(arg->key)) { - shortChars[shortCharsCount] = (char)arg->key; + shortChars[shortCharsCount] = static_cast(arg->key); shortIndexes[shortCharsCount++] = count; - shortOpts[shortOptsCount++] = (char)arg->key; + shortOpts[shortOptsCount++] = static_cast(arg->key); if (arg->valueName) { shortOpts[shortOptsCount++] = ':'; if (arg->flags & af_optional) { @@ -100,9 +100,9 @@ int argParse(const argParseOpt *parseOpt, int argc, char **argv, int *argIndex) calcCounts(child->argDefs, count, shortCharsCount, shortOptsCount); } struct option *longOpts = (struct option*)calloc(count+1, sizeof(struct option)); // room for EOF - char *shortChars = (char*)calloc(shortCharsCount+1, sizeof(char)); // room for \0 - int *shortIndexes = (int*)calloc(shortCharsCount, sizeof(int)); - char *shortOpts = (char*)calloc(2+shortOptsCount+1, sizeof(char)); // room for +, :, and \0 + char *shortChars = reinterpret_cast(calloc(shortCharsCount+1, sizeof(char))); // room for \0 + int *shortIndexes = reinterpret_cast(calloc(shortCharsCount, sizeof(int))); + char *shortOpts = reinterpret_cast(calloc(2+shortOptsCount+1, sizeof(char))); // room for +, :, and \0 count = 0; shortCharsCount = 0; shortOptsCount = 0; @@ -144,7 +144,7 @@ int argParse(const argParseOpt *parseOpt, int argc, char **argv, int *argIndex) } if (isAlpha(c)) { // short name - int idx = (int)(strchr(shortChars, c) - shortChars); + int idx = static_cast(strchr(shortChars, c) - shortChars); if (idx >= 0 && idx < shortCharsCount) { longIdx = shortIndexes[idx]; } else { @@ -206,7 +206,7 @@ void wrap(const char* str, size_t pos, size_t indent) { while (*str && str < end) { if (!first) { if (indent) { - printf("%*c", (int)indent, ' '); + printf("%*c", static_cast(indent), ' '); } pos = indent; } @@ -299,7 +299,7 @@ void printArgs(const argDef *argDefs, size_t indent) { printf(" "); wrap(arg->help, taken+1, indent); } else { - printf("%*c", (int)(indent - taken), ' '); + printf("%*c", static_cast(indent - taken), ' '); wrap(arg->help, indent, indent); } }