From 67a93dbeab38026a7251670981032f882f596355 Mon Sep 17 00:00:00 2001 From: pablo2048 Date: Sat, 20 May 2023 12:47:13 +0200 Subject: [PATCH] Upravy z clang-tidy --- src/trace.cpp | 20 ++++++++++---------- src/trace.h | 15 ++++++--------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/trace.cpp b/src/trace.cpp index 814484b..0263eb7 100644 --- a/src/trace.cpp +++ b/src/trace.cpp @@ -5,9 +5,9 @@ #define MAX_LINE_LEN 50 struct TraceLine { - char _text[MAX_LINE_LEN + 1]; - uint32_t _time; - uint8_t _severity; + char _text[MAX_LINE_LEN + 1] = {0}; + uint32_t _time{}; + uint8_t _severity{}; TraceLine(uint8_t severity, const char *str, uint16_t len) { @@ -17,17 +17,17 @@ struct TraceLine { _severity = severity; } - TraceLine(void) {} + TraceLine() = default; }; static TraceLine _lines[MAX_TRACE_LINES]; static uint16_t _lines_index = 0; static uint16_t _lines_count = 0; static volatile int _modified = 0; -static AsyncWebSocket *_wss = NULL; // webovy soket pro trasovani +static AsyncWebSocket *_wss = nullptr; // webovy soket pro trasovani static Interval _tint(TRACE_CHECK_INTERVAL); // interval pro casovani stopare -static void (*message_cb)(const char *) = NULL; +static void (*message_cb)(const char *) = nullptr; static int modulo(int a, int b) { @@ -69,7 +69,7 @@ static void print(uint8_t severity, const char *buffer, int length) ++_modified; } -void trace_init(void) +void trace_init() { } @@ -136,7 +136,7 @@ void trace_dumpJSON(String &str) } } -void trace_clear(void) +void trace_clear() { _lines_index = 0; @@ -144,7 +144,7 @@ void trace_clear(void) _modified = 1; } -void trace_end(void) +void trace_end() { trace_clear(); @@ -255,7 +255,7 @@ void trace_forceupdate(void) void trace_poll() { - if (NULL != _wss) { + if (nullptr != _wss) { // je definovany webovy soket if (_modified) { // mame nejakou zmenu diff --git a/src/trace.h b/src/trace.h index 5922d5e..982c307 100644 --- a/src/trace.h +++ b/src/trace.h @@ -2,7 +2,7 @@ * @file trace.h * @author Pavel Brychta, http://www.xpablo.cz * - * Copyright (c) 2016-22 Pavel Brychta. All rights reserved. + * Copyright (c) 2016-23 Pavel Brychta. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,8 +19,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ -#ifndef _TRACE_H_ -#define _TRACE_H_ +#pragma once // Definice jednotlivych typu hlaseni do trasovani #define TRACE_ERROR 0 // chybova zprava = cervena @@ -39,7 +38,7 @@ /** * @brief Inicializace modulu */ -void trace_init(void); +void trace_init(); /** * @brief Ziskani vypisu v JSON formatu @@ -51,12 +50,12 @@ void trace_dumpJSON(String &str); /** * @brief Vyprazdneni stopovaciho bufferu */ -void trace_clear(void); +void trace_clear(); /** * @brief Ukonceni prace stopare - vyprazdni buffer */ -void trace_end(void); +void trace_end(); /** * @brief Ulozeni zpravy s obsahem z programove pameti (PROGMEM, F, ...) @@ -120,7 +119,7 @@ void trace_dump(uint8_t severity, const __FlashStringHelper *prefix, uint8_t *ad /** * @brief Vynuceni odeslani obsahu bufferu (napr. pri obnovovani spojeni) */ -void trace_forceupdate(void); +void trace_forceupdate(); #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) @@ -144,5 +143,3 @@ void trace_forceupdate(void); #define TRACE_POLL(a) ((void)0) #define TRACE_FORCEUPDATE(a) ((void)0) #endif // DONT_USE_TRACE - -#endif // _TRACE_H_