From aa83632ffe80a7af09ba781eed7c31ba17311fa9 Mon Sep 17 00:00:00 2001 From: William Woodall Date: Tue, 15 Dec 2015 18:50:34 -0800 Subject: [PATCH] fixup comments on #endif statements --- rcl/src/rcl/common.c | 6 +++--- rcl/src/rcl/time.c | 6 +++--- rcl/src/rcl/time_unix.c | 26 +++++++++++++------------- rcl/src/rcl/time_win32.c | 3 --- rcl/test/memory_tools.cpp | 2 +- rcl/test/memory_tools_common.cpp | 4 ++-- rcl/test/rcl/test_allocator.cpp | 4 ++-- 7 files changed, 24 insertions(+), 27 deletions(-) diff --git a/rcl/src/rcl/common.c b/rcl/src/rcl/common.c index 5cec065..ab9f523 100644 --- a/rcl/src/rcl/common.c +++ b/rcl/src/rcl/common.c @@ -24,7 +24,7 @@ extern "C" #if defined(WIN32) #define WINDOWS_ENV_BUFFER_SIZE 2048 static char __env_buffer[WINDOWS_ENV_BUFFER_SIZE]; -#endif +#endif // defined(WIN32) rcl_ret_t rcl_impl_getenv(const char * env_name, const char ** env_value) @@ -37,7 +37,7 @@ rcl_impl_getenv(const char * env_name, const char ** env_value) if (*env_value == NULL) { *env_value = ""; } -#else +#else // !defined(WIN32) size_t required_size; errno_t ret = getenv_s(&required_size, __env_buffer, sizeof(__env_buffer), env_name); if (ret != 0) { @@ -46,7 +46,7 @@ rcl_impl_getenv(const char * env_name, const char ** env_value) } __env_buffer[WINDOWS_ENV_BUFFER_SIZE - 1] = '\0'; *env_value = __env_buffer; -#endif +#endif // !defined(WIN32) return RCL_RET_OK; } diff --git a/rcl/src/rcl/time.c b/rcl/src/rcl/time.c index ab08eda..7226b2c 100644 --- a/rcl/src/rcl/time.c +++ b/rcl/src/rcl/time.c @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef WIN32 +#if defined(WIN32) #include "./time_win32.c" -#else +#else // defined(WIN32) #include "./time_unix.c" -#endif +#endif // defined(WIN32) diff --git a/rcl/src/rcl/time_unix.c b/rcl/src/rcl/time_unix.c index 7cd438d..765742c 100644 --- a/rcl/src/rcl/time_unix.c +++ b/rcl/src/rcl/time_unix.c @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef WIN32 +#if defined(WIN32) #error time_unix.c is not intended to be used with win32 based systems -#endif +#endif // defined(WIN32) #if __cplusplus extern "C" @@ -26,7 +26,7 @@ extern "C" #if defined(__MACH__) #include #include -#endif +#endif // defined(__MACH__) #include #include #include @@ -37,10 +37,10 @@ extern "C" #if !defined(__MACH__) // Assume clock_get_time is available on OS X. // This id an appropriate check for clock_gettime() according to: // http://man7.org/linux/man-pages/man2/clock_gettime.2.html -#if (!defined(_POSIX_TIMERS) || !_POSIX_TIMERS) +#if !defined(_POSIX_TIMERS) || !_POSIX_TIMERS #error no monotonic clock function available -#endif -#endif +#endif // !defined(_POSIX_TIMERS) || !_POSIX_TIMERS +#endif // !defined(__MACH__) #define __WOULD_BE_NEGATIVE(seconds, subseconds) (seconds < 0 || (subseconds < 0 && seconds == 0)) @@ -58,10 +58,10 @@ rcl_system_time_point_now(rcl_system_time_point_t * now) mach_port_deallocate(mach_task_self(), cclock); timespec_now.tv_sec = mts.tv_sec; timespec_now.tv_nsec = mts.tv_nsec; -#else +#else // defined(__MACH__) // Otherwise use clock_gettime. clock_gettime(CLOCK_REALTIME, ×pec_now); -#endif // if defined(__MACH__) +#endif // defined(__MACH__) if (__WOULD_BE_NEGATIVE(timespec_now.tv_sec, timespec_now.tv_nsec)) { RCL_SET_ERROR_MSG("unexpected negative time"); return RCL_RET_ERROR; @@ -85,14 +85,14 @@ rcl_steady_time_point_now(rcl_steady_time_point_t * now) mach_port_deallocate(mach_task_self(), cclock); timespec_now.tv_sec = mts.tv_sec; timespec_now.tv_nsec = mts.tv_nsec; -#else +#else // defined(__MACH__) // Otherwise use clock_gettime. -#ifdef CLOCK_MONOTONIC_RAW +#if defined(CLOCK_MONOTONIC_RAW) clock_gettime(CLOCK_MONOTONIC_RAW, ×pec_now); -#else +#else // defined(CLOCK_MONOTONIC_RAW) clock_gettime(CLOCK_MONOTONIC, ×pec_now); -#endif // CLOCK_MONOTONIC_RAW -#endif // if defined(__MACH__) +#endif // defined(CLOCK_MONOTONIC_RAW) +#endif // defined(__MACH__) if (__WOULD_BE_NEGATIVE(timespec_now.tv_sec, timespec_now.tv_nsec)) { RCL_SET_ERROR_MSG("unexpected negative time"); return RCL_RET_ERROR; diff --git a/rcl/src/rcl/time_win32.c b/rcl/src/rcl/time_win32.c index debdaf4..987ac68 100644 --- a/rcl/src/rcl/time_win32.c +++ b/rcl/src/rcl/time_win32.c @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef WIN32 #ifndef WIN32 #error time_win32.c is only intended to be used with win32 based systems #endif @@ -68,5 +67,3 @@ rcl_steady_time_point_now(rcl_steady_time_point_t * now) #if __cplusplus } #endif - -#endif diff --git a/rcl/test/memory_tools.cpp b/rcl/test/memory_tools.cpp index e87c67e..b95338f 100644 --- a/rcl/test/memory_tools.cpp +++ b/rcl/test/memory_tools.cpp @@ -138,4 +138,4 @@ void set_on_unepexcted_free_callback(UnexpectedCallbackType callback) {} void memory_checking_thread_init() {} -#endif // !defined(WIN32) +#endif // if defined(__linux__) elif defined(__APPLE__) elif defined(WIN32) else ... diff --git a/rcl/test/memory_tools_common.cpp b/rcl/test/memory_tools_common.cpp index c05e4e3..03a2772 100644 --- a/rcl/test/memory_tools_common.cpp +++ b/rcl/test/memory_tools_common.cpp @@ -20,9 +20,9 @@ #if defined(__APPLE__) #include #define MALLOC_PRINTF malloc_printf -#else +#else // defined(__APPLE__) #define MALLOC_PRINTF printf -#endif +#endif // defined(__APPLE__) #include "./memory_tools.hpp" #include "./scope_exit.hpp" diff --git a/rcl/test/rcl/test_allocator.cpp b/rcl/test/rcl/test_allocator.cpp index 5bb65b6..ecf1bd6 100644 --- a/rcl/test/rcl/test_allocator.cpp +++ b/rcl/test/rcl/test_allocator.cpp @@ -49,10 +49,10 @@ public: /* Tests the default allocator. */ TEST_F(TestAllocatorFixture, test_default_allocator_normal) { -#ifdef WIN32 +#if defined(WIN32) printf("Allocator tests disabled on Windows.\n"); return; -#endif +#endif // defined(WIN32) ASSERT_NO_MALLOC( rcl_allocator_t allocator = rcl_get_default_allocator(); )