diff --git a/base/buffer.c b/base/buffer.c index aecf87b..9f622a0 100644 --- a/base/buffer.c +++ b/base/buffer.c @@ -152,7 +152,7 @@ ssize_t buffer_read_fd(buffer *b, int fd, int *saved_errno) if (n == -1) { *saved_errno = errno; } - else if (n <= writable) { + else if (n <= (int)writable) { b->write_index += n; } else { diff --git a/base/log.c b/base/log.c index 9d0919d..1345dcf 100644 --- a/base/log.c +++ b/base/log.c @@ -8,7 +8,7 @@ #define MAXLINE 256 -const static char *log_level_str[] = { +static const char *log_level_str[] = { "[DEBUG]", "[INFO] ", "[WARN] ", diff --git a/base/palloc.c b/base/palloc.c index e3b1429..07dead2 100644 --- a/base/palloc.c +++ b/base/palloc.c @@ -50,7 +50,7 @@ void *palloc(mem_pool *pool, size_t size) /* 对齐指针 */ last = align_ptr(p->last, MEM_POOL_ALIGNMENT); - if (p->end - last >= size) { + if ((size_t)(p->end - last) >= size) { p->last = last + size; return last; } diff --git a/config.c b/config.c index d8ae62f..5095228 100644 --- a/config.c +++ b/config.c @@ -147,6 +147,8 @@ void config(const char *path) static const char *config_main(const char *s, void *d) { + (void)d; + conf_block *b = conf_main_block; s = first_not_space(s); @@ -169,6 +171,8 @@ static const char *config_main(const char *s, void *d) static const char *config_events(const char *s, void *d) { + (void)d; + conf_block *b = conf_events_block; s = expect(s, '{'); @@ -192,6 +196,8 @@ static const char *config_events(const char *s, void *d) static const char *config_server(const char *s, void *d) { + (void)d; + conf_block *b = conf_server_block; s = expect(s, '{'); @@ -215,6 +221,8 @@ static const char *config_server(const char *s, void *d) static const char *config_location(const char *s, void *d) { + (void)d; + conf_block *b = conf_location_block; location *loc = array_alloc(locations); @@ -327,7 +335,7 @@ static const char *config_str_brace(const char *s, void *d) static const char *config_log_level(const char *s, void *d) { - const static char *level_str[] = { + static const char *level_str[] = { "debug", "info", "warn", @@ -450,6 +458,7 @@ static const char *config_index(const char *s, void *d) static const char *config_comment(const char *s, void *d) { + (void)d; while (*s != '\0' && *s != '\n') ++s; return s; diff --git a/event/connection.c b/event/connection.c index 8ccd098..cb2937a 100644 --- a/event/connection.c +++ b/event/connection.c @@ -201,6 +201,8 @@ int conn_read(connection *conn, buffer *in) int conn_read_chunked(connection *conn, buffer *in) { + (void)conn; + (void)in; return FCY_ERROR; } diff --git a/http/http.c b/http/http.c index 8a23617..9686357 100644 --- a/http/http.c +++ b/http/http.c @@ -199,11 +199,11 @@ static void read_request_body(event *ev) /* content-length */ if (rqst->has_content_length_header) { readable = buffer_readable_bytes(body_in); - if (readable >= rqst->content_length) { + if (readable >= (size_t)rqst->content_length) { goto done; } CONN_READ(conn, body_in, close_connection(conn)); - if (buffer_readable_bytes(body_in) < rqst->content_length) { + if (buffer_readable_bytes(body_in) < (size_t)rqst->content_length) { return; } } @@ -215,7 +215,7 @@ static void read_request_body(event *ev) /* 整个http请求解析和读取完毕 */ done: readable = buffer_readable_bytes(body_in); - if (readable > rqst->content_length) { + if (readable > (size_t)rqst->content_length) { LOG_WARN("%s read extra request body", conn_str(conn)); /* trunc */ buffer_unwrite(body_in, readable - rqst->content_length); @@ -479,7 +479,7 @@ static void upstream_read_response_body(event *ev) } if (upstm->has_content_length_header) { - if (buffer_readable_bytes(b) < upstm->content_length) { + if (buffer_readable_bytes(b) < (size_t)upstm->content_length) { return; } else { diff --git a/http/request.c b/http/request.c index 4a91166..43890ac 100644 --- a/http/request.c +++ b/http/request.c @@ -10,13 +10,13 @@ #include "connection.h" #include "request.h" -const static char *suffix_str[] = { +static const char *suffix_str[] = { "html", "txt", "xml", "asp", "css", "gif", "ico", "png", "jpg", "js", "pdf", NULL, }; -const static char *content_type_str[] = { +static const char *content_type_str[] = { "text/html; charset=utf-8", "text/plain; charset=utf-8", "text/xml", @@ -42,6 +42,7 @@ static const char *get_content_type(string *suffix); int request_init(mem_pool *pool) { + (void)pool; return FCY_OK; } @@ -194,6 +195,7 @@ void request_headers_htop(request *r, buffer *b) int request_read_chunked(request *r) { + (void)r; // TODO return FCY_ERROR; }