diff --git a/contrib/csnippets/net/addr.c b/contrib/csnippets/net/addr.c index aef1a1f..d1dbe57 100644 --- a/contrib/csnippets/net/addr.c +++ b/contrib/csnippets/net/addr.c @@ -2,6 +2,7 @@ * This code is licensed under MIT license (see LICENSE for details) */ #include "addr.h" + #include #include diff --git a/contrib/csnippets/net/url.c b/contrib/csnippets/net/url.c index d7255aa..d203044 100644 --- a/contrib/csnippets/net/url.c +++ b/contrib/csnippets/net/url.c @@ -18,7 +18,7 @@ static void hex(char *p, uint8_t c) static int unhex(char c) { - if (isdigit(c)) { + if (isdigit((unsigned char)c)) { return c - '0'; } if ('A' <= c && c <= 'F') { @@ -84,7 +84,7 @@ escape(char *buf, size_t buf_size, const char *str, const char *allowed_symbols, { const size_t cap = buf_size; for (const char *p = str; *p != '\0'; ++p) { - const char ch = *p; + const unsigned char ch = *p; if (islower(ch) || isupper(ch) || isdigit(ch) || strchr(allowed_symbols, ch) != NULL) { APPENDCH(ch); @@ -274,7 +274,7 @@ bool url_unescape_query(char *str) static inline char *strlower(char *s) { for (char *p = s; *p != '\0'; ++p) { - *s = (char)tolower(*s); + *s = (unsigned char)tolower((unsigned char)*s); } return s; } @@ -308,8 +308,10 @@ bool url_parse(char *raw, struct url *restrict url) /* parse scheme */ for (char *p = raw; *p != '\0'; ++p) { /* RFC 2396: Section 3.1 */ - if (isupper(*p) || islower(*p)) { - } else if (isdigit(*p) || *p == '+' || *p == '-' || *p == '.') { + if (isupper((unsigned char)*p) || islower((unsigned char)*p)) { + } else if ( + isdigit((unsigned char)*p) || *p == '+' || *p == '-' || + *p == '.') { if (p == raw) { break; } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4b05061..3df1be2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -33,7 +33,11 @@ endif() target_compile_options(kcptun-libev PRIVATE "-include${CMAKE_CURRENT_BINARY_DIR}/config.h") # be strict with original sources -target_compile_options(kcptun-libev PRIVATE -pedantic -Wall -Wextra -Werror) +target_compile_options(kcptun-libev PRIVATE -pedantic -Wall -Wextra) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux") + target_compile_options(kcptun-libev PRIVATE -Werror) +endif() + target_link_libraries(kcptun-libev PRIVATE kcp json bloom csnippets) # find libev