Skip to content

Commit a9e9b0d

Browse files
author
Marco Magdy
committed
Fix clang-tidy benign warnings
Made the variables 3 characters or more. Disabled the parameters easily swappable warning because there isn't an easy way to fix that in C++ without introducing another library or a lot of boilerplate code. The code is small enough to not warrant introducing solutions to avoid that warnings.
1 parent e3e9e09 commit a9e9b0d

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

.clang-tidy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
Checks:
3-
'clang-diagnostic-*,clang-analyzer-*,performance-*,readability-*,modernize-*,bugprone-*,misc-*,-modernize-use-trailing-return-type'
3+
'clang-diagnostic-*,clang-analyzer-*,performance-*,readability-*,modernize-*,bugprone-*,misc-*,
4+
-modernize-use-trailing-return-type,-bugprone-easily-swappable-parameters'
45
WarningsAsErrors: '*'
56
HeaderFilterRegex: 'include/aws/.*\.h$'
67
FormatStyle: 'none'

src/logging.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
namespace aws {
2323
namespace logging {
2424

25-
static inline char const* get_prefix(verbosity v)
25+
static inline char const* get_prefix(verbosity verbosity)
2626
{
27-
switch (v) {
27+
switch (verbosity) {
2828
case verbosity::error:
2929
return "[ERROR]";
3030
case verbosity::info:
@@ -37,28 +37,28 @@ static inline char const* get_prefix(verbosity v)
3737
}
3838

3939
LAMBDA_RUNTIME_API
40-
void log(verbosity v, char const* tag, char const* msg, va_list args)
40+
void log(verbosity verbosity, char const* tag, char const* msg, va_list args)
4141
{
4242
va_list copy;
4343
va_copy(copy, args);
44-
const int sz = vsnprintf(nullptr, 0, msg, args) + 1;
45-
if (sz < 0) {
44+
const int msg_size = vsnprintf(nullptr, 0, msg, args) + 1;
45+
if (msg_size < 0) {
4646
puts("error occurred during log formatting!\n");
4747
va_end(copy);
4848
return;
4949
}
5050
constexpr int max_stack_buffer_size = 512;
5151
std::array<char, max_stack_buffer_size> buf;
5252
char* out = buf.data();
53-
if (sz >= max_stack_buffer_size) {
54-
out = new char[sz];
53+
if (msg_size >= max_stack_buffer_size) {
54+
out = new char[msg_size];
5555
}
5656

57-
vsnprintf(out, sz, msg, copy);
57+
vsnprintf(out, msg_size, msg, copy);
5858
va_end(copy);
59-
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
59+
auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(
6060
std::chrono::high_resolution_clock::now().time_since_epoch());
61-
printf("%s [%lld] %s %s\n", get_prefix(v), static_cast<long long>(ms.count()), tag, out);
61+
printf("%s [%lld] %s %s\n", get_prefix(verbosity), static_cast<long long>(millis.count()), tag, out);
6262
// stdout is not line-buffered when redirected (for example to a file or to another process) so we must flush it
6363
// manually.
6464
fflush(stdout);

0 commit comments

Comments
 (0)