aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/nginx.c2
-rw-r--r--src/core/ngx_alloc.c27
-rw-r--r--src/core/ngx_conf_file.c7
-rw-r--r--src/core/ngx_connection.h4
-rw-r--r--src/core/ngx_file.c11
-rw-r--r--src/core/ngx_file.h4
-rw-r--r--src/core/ngx_garbage_collector.c3
-rw-r--r--src/core/ngx_hunk.c2
-rw-r--r--src/core/ngx_hunk.h2
-rw-r--r--src/core/ngx_output_chain.c14
-rw-r--r--src/core/ngx_parse.c8
11 files changed, 49 insertions, 35 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c
index ca056bd18..26db6f8b7 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -230,7 +230,7 @@ ngx_log_debug(log, "REOPEN: %d:%d:%s" _ fd _ file[i].fd _ file[i].name.data);
cycle = ngx_init_cycle(cycle, cycle->log);
if (cycle == NULL) {
- cycle = (ngx_cycle_t*) ngx_cycle;
+ cycle = (ngx_cycle_t *) ngx_cycle;
continue;
}
diff --git a/src/core/ngx_alloc.c b/src/core/ngx_alloc.c
index 32aa25c7e..dff05936e 100644
--- a/src/core/ngx_alloc.c
+++ b/src/core/ngx_alloc.c
@@ -5,10 +5,9 @@
void *ngx_alloc(size_t size, ngx_log_t *log)
{
- void *p;
+ void *p;
- p = malloc(size);
- if (p == NULL) {
+ if (!(p = malloc(size))) {
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
"malloc() %d bytes failed", size);
}
@@ -23,7 +22,7 @@ void *ngx_alloc(size_t size, ngx_log_t *log)
void *ngx_calloc(size_t size, ngx_log_t *log)
{
- void *p;
+ void *p;
p = ngx_alloc(size, log);
if (p) {
@@ -36,9 +35,11 @@ void *ngx_calloc(size_t size, ngx_log_t *log)
ngx_pool_t *ngx_create_pool(size_t size, ngx_log_t *log)
{
- ngx_pool_t *p;
+ ngx_pool_t *p;
- ngx_test_null(p, ngx_alloc(size, log), NULL);
+ if (!(p = ngx_alloc(size, log))) {
+ return NULL;
+ }
p->last = (char *) p + sizeof(ngx_pool_t);
p->end = (char *) p + size;
@@ -115,7 +116,10 @@ void *ngx_palloc(ngx_pool_t *pool, size_t size)
/* alloc a new pool block */
- ngx_test_null(n, ngx_create_pool(p->end - (char *) p, p->log), NULL);
+ if (!(n = ngx_create_pool((size_t) (p->end - (char *) p), p->log))) {
+ return NULL;
+ }
+
p->next = n;
m = n->last;
n->last += size;
@@ -143,11 +147,16 @@ void *ngx_palloc(ngx_pool_t *pool, size_t size)
}
if (large == NULL) {
- ngx_test_null(large, ngx_palloc(pool, sizeof(ngx_pool_large_t)), NULL);
+ if (!(large = ngx_palloc(pool, sizeof(ngx_pool_large_t)))) {
+ return NULL;
+ }
+
large->next = NULL;
}
- ngx_test_null(p, ngx_alloc(size, pool->log), NULL);
+ if (!(p = ngx_alloc(size, pool->log))) {
+ return NULL;
+ }
if (pool->large == NULL) {
pool->large = large;
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c
index 5ea364bce..fd30216f5 100644
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -315,12 +315,12 @@ ngx_log_debug(cf->log, "TOKEN START");
}
if (h->pos - start) {
- ngx_memcpy(h->start, start, h->pos - start);
+ ngx_memcpy(h->start, start, (size_t) (h->pos - start));
}
n = ngx_read_file(&cf->conf_file->file,
h->start + (h->pos - start),
- h->end - (h->start + (h->pos - start)),
+ (size_t) (h->end - (h->start + (h->pos - start))),
cf->conf_file->file.offset);
if (n == NGX_ERROR) {
@@ -462,7 +462,8 @@ ngx_log_debug(cf->log, "%d:%d:%d:%d:%d '%c'" _
if (found) {
ngx_test_null(word, ngx_push_array(cf->args), NGX_ERROR);
ngx_test_null(word->data,
- ngx_palloc(cf->pool, h->pos - start + 1),
+ ngx_palloc(cf->pool,
+ (size_t) (h->pos - start + 1)),
NGX_ERROR);
for (dst = word->data, src = start, len = 0;
diff --git a/src/core/ngx_connection.h b/src/core/ngx_connection.h
index da6f37a01..9312fba60 100644
--- a/src/core/ngx_connection.h
+++ b/src/core/ngx_connection.h
@@ -28,8 +28,8 @@ typedef struct {
ngx_log_t *log;
int backlog;
- int pool_size;
- int post_accept_buffer_size; /* should be here because
+ size_t pool_size;
+ size_t post_accept_buffer_size; /* should be here because
of the AcceptEx() preread */
time_t post_accept_timeout; /* should be here because
of the deferred accept */
diff --git a/src/core/ngx_file.c b/src/core/ngx_file.c
index ee4c653db..4ae537894 100644
--- a/src/core/ngx_file.c
+++ b/src/core/ngx_file.c
@@ -105,7 +105,8 @@ ngx_log_debug(file->log, "temp fd: %d" _ file->fd);
void ngx_create_hashed_filename(ngx_file_t *file, ngx_path_t *path)
{
- int i, name, pos, level;
+ int i, name, pos;
+ size_t level;
name = file->name.len;
pos = path->name.len + 1;
@@ -192,7 +193,7 @@ char *ngx_conf_set_path_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
char *p = conf;
- int i, n;
+ int i, n, level;
ngx_str_t *value;
ngx_path_t *path, **pp;
@@ -219,12 +220,12 @@ char *ngx_conf_set_path_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
path->len = 0;
for (i = 0, n = 2; n < cf->args->nelts; i++, n++) {
- path->level[i] = ngx_atoi(value[n].data, value[n].len);
- if (path->level[i] == NGX_ERROR || path->level[i] == 0) {
+ level = ngx_atoi(value[n].data, value[n].len);
+ if (level == NGX_ERROR || level == 0) {
return "invalid value";
}
- path->len += path->level[i] + 1;
+ path->len += path->level[i] + level + 1;
}
while (i < 3) {
diff --git a/src/core/ngx_file.h b/src/core/ngx_file.h
index b1e5fb855..9042c61d5 100644
--- a/src/core/ngx_file.h
+++ b/src/core/ngx_file.h
@@ -27,8 +27,8 @@ struct ngx_file_s {
struct ngx_path_s {
ngx_str_t name;
- int len;
- int level[3];
+ u_int len;
+ u_int level[3];
ngx_gc_handler_pt gc_handler;
};
diff --git a/src/core/ngx_garbage_collector.c b/src/core/ngx_garbage_collector.c
index e673acd5a..f60fae927 100644
--- a/src/core/ngx_garbage_collector.c
+++ b/src/core/ngx_garbage_collector.c
@@ -70,8 +70,9 @@ void stub_init(ngx_cycle_t *cycle)
static int ngx_collect_garbage(ngx_gc_t *ctx, ngx_str_t *dname, int level)
{
- int rc, len;
+ int rc;
char *last;
+ size_t len;
ngx_err_t err;
ngx_str_t fname, buf;
ngx_dir_t dir;
diff --git a/src/core/ngx_hunk.c b/src/core/ngx_hunk.c
index de57a5d02..2785c39d4 100644
--- a/src/core/ngx_hunk.c
+++ b/src/core/ngx_hunk.c
@@ -3,7 +3,7 @@
#include <ngx_core.h>
-ngx_hunk_t *ngx_create_temp_hunk(ngx_pool_t *pool, int size)
+ngx_hunk_t *ngx_create_temp_hunk(ngx_pool_t *pool, size_t size)
{
ngx_hunk_t *h;
diff --git a/src/core/ngx_hunk.h b/src/core/ngx_hunk.h
index 2c6664b60..7dc0f0c85 100644
--- a/src/core/ngx_hunk.h
+++ b/src/core/ngx_hunk.h
@@ -124,7 +124,7 @@ typedef struct {
(size_t) (h->file_last - h->file_pos))
-ngx_hunk_t *ngx_create_temp_hunk(ngx_pool_t *pool, int size);
+ngx_hunk_t *ngx_create_temp_hunk(ngx_pool_t *pool, size_t size);
#define ngx_alloc_hunk(pool) ngx_palloc(pool, sizeof(ngx_hunk_t))
#define ngx_calloc_hunk(pool) ngx_pcalloc(pool, sizeof(ngx_hunk_t))
diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c
index f196937ef..46deab446 100644
--- a/src/core/ngx_output_chain.c
+++ b/src/core/ngx_output_chain.c
@@ -10,14 +10,13 @@
ngx_inline static int ngx_output_chain_need_to_copy(ngx_output_chain_ctx_t *ctx,
ngx_hunk_t *hunk);
static int ngx_output_chain_copy_hunk(ngx_hunk_t *dst, ngx_hunk_t *src,
- int sendfile);
+ u_int sendfile);
int ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
{
int rc, last;
- size_t hsize;
- ssize_t size;
+ size_t size, hsize;
ngx_chain_t *cl, *out, **last_out;
/*
@@ -191,13 +190,14 @@ ngx_inline static int ngx_output_chain_need_to_copy(ngx_output_chain_ctx_t *ctx,
static int ngx_output_chain_copy_hunk(ngx_hunk_t *dst, ngx_hunk_t *src,
- int sendfile)
+ u_int sendfile)
{
- ssize_t n, size;
+ size_t size;
+ ssize_t n;
size = ngx_hunk_size(src);
- if (size > (dst->end - dst->pos)) {
+ if (size > (size_t) (dst->end - dst->pos)) {
size = dst->end - dst->pos;
}
@@ -233,7 +233,7 @@ ngx_log_debug(src->file->log, "READ: %qd:%qd %X:%X %X:%X" _
}
#endif
- if (n != size) {
+ if ((size_t) n != size) {
ngx_log_error(NGX_LOG_ALERT, src->file->log, 0,
ngx_read_file_n " reads only %d of %d from file",
n, size);
diff --git a/src/core/ngx_parse.c b/src/core/ngx_parse.c
index 213b2f6ec..6a1f54bb2 100644
--- a/src/core/ngx_parse.c
+++ b/src/core/ngx_parse.c
@@ -5,8 +5,9 @@
int ngx_parse_size(ngx_str_t *line)
{
- int len, scale, size;
- char last;
+ int scale, size;
+ char last;
+ size_t len;
len = line->len;
last = line->data[len - 1];
@@ -41,8 +42,9 @@ int ngx_parse_size(ngx_str_t *line)
int ngx_parse_time(ngx_str_t *line, int sec)
{
- int value, total, len, scale;
+ int value, total, scale;
u_int max, i;
+ size_t len;
char *start, last;
enum {
st_start = 0,