From 3eb2ec5cc10ddfdfc65cf99e8e26fdf87cb40468 Mon Sep 17 00:00:00 2001 From: Alexander Shabalin Date: Tue, 12 Jan 2021 13:22:13 +0300 Subject: [PATCH] Use clang format attribute (#4624) --- kotlin-native/runtime/src/main/cpp/KAssert.h | 4 ++-- kotlin-native/runtime/src/main/cpp/Porting.h | 8 ++++---- kotlin-native/runtime/src/main/cpp/StdCppStubs.cpp | 2 +- kotlin-native/runtime/src/main/cpp/Worker.cpp | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/kotlin-native/runtime/src/main/cpp/KAssert.h b/kotlin-native/runtime/src/main/cpp/KAssert.h index a7c9e789892..80e1edf0df0 100644 --- a/kotlin-native/runtime/src/main/cpp/KAssert.h +++ b/kotlin-native/runtime/src/main/cpp/KAssert.h @@ -32,7 +32,7 @@ #define CURRENT_SOURCE_LOCATION nullptr #endif -RUNTIME_NORETURN void RuntimeAssertFailed(const char* location, const char* message, ...); +RUNTIME_NORETURN void RuntimeAssertFailed(const char* location, const char* format, ...) __attribute__((format(printf, 2, 3))); namespace internal { @@ -42,7 +42,7 @@ inline RUNTIME_NORETURN void TODOImpl(const char* location) { // TODO: Support format string when `RuntimeAssertFailed` supports it. inline RUNTIME_NORETURN void TODOImpl(const char* location, const char* message) { - RuntimeAssertFailed(location, message); + RuntimeAssertFailed(location, "%s", message); } } // namespace internal diff --git a/kotlin-native/runtime/src/main/cpp/Porting.h b/kotlin-native/runtime/src/main/cpp/Porting.h index 1085e1fb789..68a2eff78fd 100644 --- a/kotlin-native/runtime/src/main/cpp/Porting.h +++ b/kotlin-native/runtime/src/main/cpp/Porting.h @@ -27,8 +27,8 @@ namespace konan { // Console operations. void consoleInit(); -void consolePrintf(const char* format, ...); -void consoleErrorf(const char* format, ...); +void consolePrintf(const char* format, ...) __attribute__((format(printf, 1, 2))); +void consoleErrorf(const char* format, ...) __attribute__((format(printf, 1, 2))); void consoleWriteUtf8(const void* utf8, uint32_t sizeBytes); void consoleErrorUtf8(const void* utf8, uint32_t sizeBytes); // Negative return value denotes that read wasn't successful. @@ -46,8 +46,8 @@ void onThreadExit(void (*destructor)(void*), void* destructorParameter); // memcpy/memmove/memcmp are not here intentionally, as frequently implemented/optimized // by C compiler. void* memmem(const void *big, size_t bigLen, const void *little, size_t littleLen); -int snprintf(char* buffer, size_t size, const char* format, ...); -int vsnprintf(char* buffer, size_t size, const char* format, va_list args); +int snprintf(char* buffer, size_t size, const char* format, ...) __attribute__((format(printf, 3, 4))); +int vsnprintf(char* buffer, size_t size, const char* format, va_list args) __attribute__((format(printf, 3, 0))); size_t strnlen(const char* buffer, size_t maxSize); diff --git a/kotlin-native/runtime/src/main/cpp/StdCppStubs.cpp b/kotlin-native/runtime/src/main/cpp/StdCppStubs.cpp index 1269305dcd8..a0f9ac2ae0f 100644 --- a/kotlin-native/runtime/src/main/cpp/StdCppStubs.cpp +++ b/kotlin-native/runtime/src/main/cpp/StdCppStubs.cpp @@ -32,7 +32,7 @@ RUNTIME_USED RUNTIME_WEAK extern "C" char* Konan_cxa_demangle( namespace std { RUNTIME_WEAK void __throw_length_error(const char* __s __attribute__((unused))) { - RuntimeAssert(false, __s); + RuntimeCheck(false, "%s", __s); } } // namespace std diff --git a/kotlin-native/runtime/src/main/cpp/Worker.cpp b/kotlin-native/runtime/src/main/cpp/Worker.cpp index 2f9175f7dd0..9c3a76f05a5 100644 --- a/kotlin-native/runtime/src/main/cpp/Worker.cpp +++ b/kotlin-native/runtime/src/main/cpp/Worker.cpp @@ -511,7 +511,7 @@ class State { if (remainingNativeWorkers != 0) { konan::consoleErrorf( - "Unfinished workers detected, %lu workers leaked!\n" + "Unfinished workers detected, %zu workers leaked!\n" "Use `Platform.isMemoryLeakCheckerActive = false` to avoid this check.\n", remainingNativeWorkers); konan::consoleFlush();