Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
pgq committed Sep 20, 2017
1 parent 57d9b16 commit aaf6938
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion base/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion base/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#define MAXLINE 256

const static char *log_level_str[] = {
static const char *log_level_str[] = {
"[DEBUG]",
"[INFO] ",
"[WARN] ",
Expand Down
2 changes: 1 addition & 1 deletion base/palloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
11 changes: 10 additions & 1 deletion config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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, '{');
Expand All @@ -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, '{');
Expand All @@ -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);

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions event/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 4 additions & 4 deletions http/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions http/request.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -42,6 +42,7 @@ static const char *get_content_type(string *suffix);

int request_init(mem_pool *pool)
{
(void)pool;
return FCY_OK;
}

Expand Down Expand Up @@ -194,6 +195,7 @@ void request_headers_htop(request *r, buffer *b)

int request_read_chunked(request *r)
{
(void)r;
// TODO
return FCY_ERROR;
}
Expand Down

0 comments on commit aaf6938

Please sign in to comment.