Skip to content

Commit d1f292f

Browse files
authored
Updates for uncrustify 0.78. (#454)
Shorten some unnecessary macros, and add INDENT-OFF around the logging macros. Signed-off-by: Chris Lalancette <[email protected]>
1 parent 24431ba commit d1f292f

File tree

4 files changed

+24
-40
lines changed

4 files changed

+24
-40
lines changed

include/rcutils/stdatomic_helper/win32/stdatomic.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@
9191
*/
9292

9393
#define ATOMIC_VAR_INIT(value) {.__val = (value)}
94-
#define atomic_init(obj, value) do { \
95-
(obj)->__val = (value); \
96-
} while (0)
94+
#define atomic_init(obj, value) do {(obj)->__val = (value);} while (0)
9795

9896
/*
9997
* Clang and recent GCC both provide predefined macros for the memory

resource/logging_macros.h.em

+21-17
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#ifndef RCUTILS__LOGGING_MACROS_H_
2020
#define RCUTILS__LOGGING_MACROS_H_
2121

22+
// *INDENT-OFF*
23+
2224
#include "rcutils/logging.h"
2325

2426
#include <stdio.h>
@@ -108,7 +110,7 @@ extern "C"
108110
* A macro finalizing the `once` condition.
109111
*/
110112
#define RCUTILS_LOG_CONDITION_ONCE_AFTER } \
111-
}
113+
}
112114
///@@}
113115

114116
/** @@name Macros for the `expression` condition which ignores the log calls
@@ -169,7 +171,7 @@ typedef bool (* RclLogFilter)();
169171
* A macro finalizing the `skipfirst` condition.
170172
*/
171173
#define RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER } \
172-
}
174+
}
173175
///@@}
174176
175177
/** @@name Macros for the `throttle` condition which ignores log calls if the
@@ -181,28 +183,28 @@ typedef bool (* RclLogFilter)();
181183
* A macro initializing and checking the `throttle` condition.
182184
*/
183185
#define RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(get_time_point_value, duration) { \
184-
static rcutils_duration_value_t __rcutils_logging_duration = RCUTILS_MS_TO_NS(RCUTILS_CAST_DURATION(duration)); \
185-
static rcutils_time_point_value_t __rcutils_logging_last_logged = 0; \
186-
rcutils_time_point_value_t __rcutils_logging_now = 0; \
187-
bool __rcutils_logging_condition = true; \
188-
if (get_time_point_value(&__rcutils_logging_now) != RCUTILS_RET_OK) { \
189-
rcutils_log( \
190-
&__rcutils_logging_location, RCUTILS_LOG_SEVERITY_ERROR, "", \
191-
"%s() at %s:%d getting current steady time failed\n", \
192-
__func__, __FILE__, __LINE__); \
193-
} else { \
194-
__rcutils_logging_condition = __rcutils_logging_now >= __rcutils_logging_last_logged + __rcutils_logging_duration; \
195-
} \
186+
static rcutils_duration_value_t __rcutils_logging_duration = RCUTILS_MS_TO_NS(RCUTILS_CAST_DURATION(duration)); \
187+
static rcutils_time_point_value_t __rcutils_logging_last_logged = 0; \
188+
rcutils_time_point_value_t __rcutils_logging_now = 0; \
189+
bool __rcutils_logging_condition = true; \
190+
if (get_time_point_value(&__rcutils_logging_now) != RCUTILS_RET_OK) { \
191+
rcutils_log( \
192+
&__rcutils_logging_location, RCUTILS_LOG_SEVERITY_ERROR, "", \
193+
"%s() at %s:%d getting current steady time failed\n", \
194+
__func__, __FILE__, __LINE__); \
195+
} else { \
196+
__rcutils_logging_condition = __rcutils_logging_now >= __rcutils_logging_last_logged + __rcutils_logging_duration; \
197+
} \
196198
\
197-
if (RCUTILS_LIKELY(__rcutils_logging_condition)) { \
198-
__rcutils_logging_last_logged = __rcutils_logging_now;
199+
if (RCUTILS_LIKELY(__rcutils_logging_condition)) { \
200+
__rcutils_logging_last_logged = __rcutils_logging_now;
199201

200202
/**
201203
* \def RCUTILS_LOG_CONDITION_THROTTLE_AFTER
202204
* A macro finalizing the `throttle` condition.
203205
*/
204206
#define RCUTILS_LOG_CONDITION_THROTTLE_AFTER } \
205-
}
207+
}
206208
///@@}
207209
208210
@{
@@ -257,6 +259,8 @@ from rcutils.logging import severities
257259
#endif
258260
///@@}
259261

262+
// *INDENT-ON*
263+
260264
@[end for]@
261265
#ifdef __cplusplus
262266
}

test/test_find.cpp

+1-12
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,7 @@
1818

1919
#include "rcutils/find.h"
2020

21-
#define ENABLE_LOGGING 1
22-
23-
#if ENABLE_LOGGING
24-
#define LOG(expected, actual) do { \
25-
printf("Expected: %zu Actual: %zu\n", expected, actual); \
26-
} while (0)
27-
#else
28-
#define LOG(X, arg) do { \
29-
(void)(X); \
30-
(void)(arg); \
31-
} while (0)
32-
#endif
21+
#define LOG(expected, actual) printf("Expected: %zu Actual: %zu\n", expected, actual);
3322

3423
size_t test_find(const char * str, char delimiter, size_t expected_pos)
3524
{

test/test_split.cpp

+1-8
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,7 @@
2020
#include "rcutils/split.h"
2121
#include "rcutils/types/string_array.h"
2222

23-
#define ENABLE_LOGGING 1
24-
25-
#if ENABLE_LOGGING
26-
#define LOG(expected, actual) { \
27-
printf("Expected: %s Actual: %s\n", expected, actual);}
28-
#else
29-
#define LOG(X, arg) {}
30-
#endif
23+
#define LOG(expected, actual) printf("Expected: %s Actual: %s\n", expected, actual);
3124

3225
rcutils_string_array_t test_split(const char * str, char delimiter, size_t expected_token_size)
3326
{

0 commit comments

Comments
 (0)