Skip to content

Commit

Permalink
fix [-Wunused-parameter] warnings
Browse files Browse the repository at this point in the history
they appear when using `Wextra` flag

```
lib/DnAppLogger/src/DnApp/Logger/Endpoint/NullLogger.h:14:34: warning: unused parameter 'level' [-Wunused-parameter]
        auto log(const LOG_LEVEL level, const char* const message) -> void override {
                                 ^
lib/DnAppLogger/src/DnApp/Logger/Endpoint/NullLogger.h:14:59: warning: unused parameter 'message' [-Wunused-parameter]
        auto log(const LOG_LEVEL level, const char* const message) -> void override {
                                                          ^
lib/DnAppArduino/src/DnApp/Arduino/Logger/Endpoint/WithArduinoStringNullLogger.h:15:34: warning: unused parameter 'level' [-Wunused-parameter]
        auto log(const LOG_LEVEL level, const char* const message) -> void override {
                                 ^
lib/DnAppArduino/src/DnApp/Arduino/Logger/Endpoint/WithArduinoStringNullLogger.h:15:59: warning: unused parameter 'message' [-Wunused-parameter]
        auto log(const LOG_LEVEL level, const char* const message) -> void override {
                                                          ^
```
  • Loading branch information
MacDada committed Apr 30, 2023
1 parent 2c6f95a commit 81b11bb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,5 +262,13 @@ Code style, conventions, decisions
* `// todo:[2137] Description of what is to be done`
– the number is for easier grep,
when the same kind of issue appears in multiple places.
* `static_cast` to `void` when function arguments are not being used.
I know of 3 possible solutions:
* A.) `static_cast<void>(unusedParameter);`
– the preferred C++ way, that we're doing,
* B.) `(void) unusedParameter;`
– the "old" C–style casting, but `A.)` is more precise,
* C.) remove `unusedParameter` var from the function arguments
– but keeping the name better explains what it represents.

---
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ namespace DnApp::Arduino::Logger::Endpoint {
using WithArduinoStringLogger::log;

auto log(const LOG_LEVEL level, const char* const message) -> void override {
// fix `[-Wunused-parameter]` warnings:
static_cast<void>(level);
static_cast<void>(message);

// do nothing
};
};
Expand Down
4 changes: 4 additions & 0 deletions lib/DnAppLogger/src/DnApp/Logger/Endpoint/NullLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ namespace DnApp::Logger::Endpoint {
using Logger::log;

auto log(const LOG_LEVEL level, const char* const message) -> void override {
// fix `[-Wunused-parameter]` warnings:
static_cast<void>(level);
static_cast<void>(message);

// do nothing
};
};
Expand Down

0 comments on commit 81b11bb

Please sign in to comment.