Skip to content

Commit

Permalink
all: fix ctype misuse
Browse files Browse the repository at this point in the history
Signed-off-by: hexian000 <[email protected]>
  • Loading branch information
hexian000 committed Dec 31, 2023
1 parent 15abd17 commit 92eeffb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions contrib/csnippets/net/addr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* This code is licensed under MIT license (see LICENSE for details) */

#include "addr.h"

#include <stddef.h>
#include <string.h>

Expand Down
12 changes: 7 additions & 5 deletions contrib/csnippets/net/url.c
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 5 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 92eeffb

Please sign in to comment.