Add __attribute__((format)) to trace and c99_snprintf, fix two mismatches

This commit is contained in:
Ryan Prichard 2016-01-16 00:03:27 -06:00
parent a532a7ce3b
commit f6c6f0558e
4 changed files with 18 additions and 2 deletions

View File

@ -201,7 +201,7 @@ bool NamedPipe::connectToServer(const std::wstring &name)
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL);
trace("connection to [%ls], handle == 0x%x", name.c_str(), handle);
trace("connection to [%ls], handle == %p", name.c_str(), handle);
if (handle == INVALID_HANDLE_VALUE)
return false;
m_handle = handle;

View File

@ -107,7 +107,8 @@ static void translateException(winpty_error_ptr_t *&err) {
} catch (...) {
ret = const_cast<winpty_error_ptr_t>(&kUncaughtException);
}
trace("libwinpty error: code=%d msg='%ls'", ret->code, ret->msg);
trace("libwinpty error: code=%u msg='%ls'",
static_cast<unsigned>(ret->code), ret->msg);
if (err != nullptr) {
*err = ret;
} else {

View File

@ -23,6 +23,13 @@
bool isTracingEnabled();
bool hasDebugFlag(const char *flag);
#if defined(__CYGWIN__) || defined(__MSYS__)
void trace(const char *format, ...) __attribute__((format(printf, 1, 2)));
#elif defined(__GNUC__)
void trace(const char *format, ...) __attribute__((format(ms_printf, 1, 2)));
#else
void trace(const char *format, ...);
#endif
#endif // DEBUGCLIENT_H

View File

@ -73,6 +73,14 @@ static inline int c99_vsnprintf(
#endif /* _MSC_VER */
#if defined(__CYGWIN__) || defined(__MSYS__)
static inline int c99_snprintf(char* str, size_t size, const char* format, ...)
__attribute__((format(printf, 3, 4)));
#elif defined(__GNUC__)
static inline int c99_snprintf(char* str, size_t size, const char* format, ...)
__attribute__((format(ms_printf, 3, 4)));
#endif
static inline int c99_snprintf(
char* str,
size_t size,