Revision: 7648 https://osdn.net/projects/ttssh2/scm/svn/commits/7648 Author: zmatsuo Date: 2019-05-06 22:41:50 +0900 (Mon, 06 May 2019) Log Message: ----------- ttxsshのlogprintf()とlogprintf_hexdump()の引数チェックを強化 可変引数関数にattributeを追加 Modified Paths: -------------- trunk/CMakeLists.txt trunk/ttssh2/ttxssh/ttxssh.c trunk/ttssh2/ttxssh/ttxssh.h -------------- next part -------------- Modified: trunk/CMakeLists.txt =================================================================== --- trunk/CMakeLists.txt 2019-05-06 13:41:41 UTC (rev 7647) +++ trunk/CMakeLists.txt 2019-05-06 13:41:50 UTC (rev 7648) @@ -4,7 +4,7 @@ project(teraterm_all) option(ENABLE_TTXSAMPLES "TTXSamples" ON) -option(USE_UNICODE_API "unicode" OFF) +option(MORE_WARNING "stronger warning" OFF) set_property(GLOBAL PROPERTY USE_FOLDERS ON) @@ -25,8 +25,19 @@ string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}) string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_DEPRECATE /W3") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D_CRT_SECURE_NO_DEPRECATE /W3") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_DEPRECATE") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D_CRT_SECURE_NO_DEPRECATE") + if (MORE_WARNING) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4") + if(${MSVC_VERSION} GREATER_EQUAL 1910) # Visual Studio 2017以上の時 + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /analyze") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /analyze") + endif() + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3") + endif() set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GF /Gy") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /GF /Gy") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") Modified: trunk/ttssh2/ttxssh/ttxssh.c =================================================================== --- trunk/ttssh2/ttxssh/ttxssh.c 2019-05-06 13:41:41 UTC (rev 7647) +++ trunk/ttssh2/ttxssh/ttxssh.c 2019-05-06 13:41:50 UTC (rev 7648) @@ -977,7 +977,11 @@ } } -void logprintf(int level, char *fmt, ...) +#if defined(_MSC_VER) +void logprintf(int level, _Printf_format_string_ const char *fmt, ...) +#else +void logprintf(int level, const char *fmt, ...) +#endif { char buff[4096]; va_list params; @@ -1031,7 +1035,11 @@ //strncat_s(buf, buflen, "\n", _TRUNCATE); } -void logprintf_hexdump(int level, char *data, int len, char *fmt, ...) +#if defined(_MSC_VER) +void logprintf_hexdump(int level, const char *data, int len, _Printf_format_string_ const char *fmt, ...) +#else +void logprintf_hexdump(int level, const char *data, int len, const char *fmt, ...) +#endif { char buff[4096]; va_list params; Modified: trunk/ttssh2/ttxssh/ttxssh.h =================================================================== --- trunk/ttssh2/ttxssh/ttxssh.h 2019-05-06 13:41:41 UTC (rev 7647) +++ trunk/ttssh2/ttxssh/ttxssh.h 2019-05-06 13:41:50 UTC (rev 7648) @@ -90,6 +90,11 @@ #include "tttypes.h" #include "ttplugin.h" +#if defined(_MSC_VER) && _MSC_VER < 1910 +// 2017\x96\xA2\x96\x9E\x82̂Ƃ\xAB\x82͖\xB3\x8C\xF8\x82Ƃ\xB7\x82\xE9 +#define _Printf_format_string_ +#endif + HANDLE hInst; /* Instance handle of TTXSSH.DLL */ #define ID_SSHSCPMENU 52110 @@ -356,8 +361,16 @@ void notify_nonfatal_error(PTInstVar pvar, char *msg); void notify_fatal_error(PTInstVar pvar, char *msg, BOOL send_disconnect); void logputs(int level, char *msg); -void logprintf(int level, char *fmt, ...); -void logprintf_hexdump(int level, char *data, int len, char *fmt, ...); +#if defined(_MSC_VER) +void logprintf(int level, _Printf_format_string_ const char *fmt, ...); +void logprintf_hexdump(int level, const char *data, int len, _Printf_format_string_ const char *fmt, ...); +#elif defined(__GNUC__) +void logprintf(int level, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); +void logprintf_hexdump(int level, const char *data, int len, const char *fmt, ...) __attribute__ ((format (printf, 4, 5))); +#else +void logprintf(int level, const char *fmt, ...); +void logprintf_hexdump(int level, const char *data, int len, const char *fmt, ...); +#endif void get_teraterm_dir_relative_name(char *buf, int bufsize, char *basename); int copy_teraterm_dir_relative_path(char *dest, int destsize, char *basename);