Use NGX_MAX_PATH_LEVEL where appropriate.

The macro was unused since 0.7.44.
This commit is contained in:
Ruslan Ermilov 2016-07-06 13:22:29 +03:00
parent 5c4ca2ac80
commit 6810b9f148
3 changed files with 16 additions and 17 deletions

View File

@ -225,7 +225,7 @@ ngx_create_hashed_filename(ngx_path_t *path, u_char *file, size_t len)
file[path->name.len + path->len] = '/';
for (n = 0; n < 3; n++) {
for (n = 0; n < NGX_MAX_PATH_LEVEL; n++) {
level = path->level[n];
if (level == 0) {
@ -249,7 +249,7 @@ ngx_create_path(ngx_file_t *file, ngx_path_t *path)
pos = path->name.len;
for (i = 0; i < 3; i++) {
for (i = 0; i < NGX_MAX_PATH_LEVEL; i++) {
if (path->level[i] == 0) {
break;
}
@ -399,6 +399,8 @@ char *
ngx_conf_merge_path_value(ngx_conf_t *cf, ngx_path_t **path, ngx_path_t *prev,
ngx_path_init_t *init)
{
ngx_uint_t i;
if (*path) {
return NGX_CONF_OK;
}
@ -419,13 +421,10 @@ ngx_conf_merge_path_value(ngx_conf_t *cf, ngx_path_t **path, ngx_path_t *prev,
return NGX_CONF_ERROR;
}
(*path)->level[0] = init->level[0];
(*path)->level[1] = init->level[1];
(*path)->level[2] = init->level[2];
(*path)->len = init->level[0] + (init->level[0] ? 1 : 0)
+ init->level[1] + (init->level[1] ? 1 : 0)
+ init->level[2] + (init->level[2] ? 1 : 0);
for (i = 0; i < NGX_MAX_PATH_LEVEL; i++) {
(*path)->level[i] = init->level[i];
(*path)->len += init->level[i] + (init->level[i] ? 1 : 0);
}
if (ngx_add_path(cf, path) != NGX_OK) {
return NGX_CONF_ERROR;
@ -518,7 +517,7 @@ ngx_add_path(ngx_conf_t *cf, ngx_path_t **slot)
return NGX_ERROR;
}
for (n = 0; n < 3; n++) {
for (n = 0; n < NGX_MAX_PATH_LEVEL; n++) {
if (p[i]->level[n] != path->level[n]) {
if (path->conf_file == NULL) {
if (p[i]->conf_file == NULL) {

View File

@ -49,7 +49,7 @@ typedef void (*ngx_path_loader_pt) (void *data);
typedef struct {
ngx_str_t name;
size_t len;
size_t level[3];
size_t level[NGX_MAX_PATH_LEVEL];
ngx_path_manager_pt manager;
ngx_path_loader_pt loader;
@ -62,7 +62,7 @@ typedef struct {
typedef struct {
ngx_str_t name;
size_t level[3];
size_t level[NGX_MAX_PATH_LEVEL];
} ngx_path_init_t;

View File

@ -101,7 +101,7 @@ ngx_http_file_cache_init(ngx_shm_zone_t *shm_zone, void *data)
return NGX_ERROR;
}
for (n = 0; n < 3; n++) {
for (n = 0; n < NGX_MAX_PATH_LEVEL; n++) {
if (cache->path->level[n] != ocache->path->level[n]) {
ngx_log_error(NGX_LOG_EMERG, shm_zone->shm.log, 0,
"cache \"%V\" had previously different levels",
@ -2257,7 +2257,7 @@ ngx_http_file_cache_set_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
p = value[i].data + 7;
last = value[i].data + value[i].len;
for (n = 0; n < 3 && p < last; n++) {
for (n = 0; n < NGX_MAX_PATH_LEVEL && p < last; n++) {
if (*p > '0' && *p < '3') {
@ -2268,7 +2268,7 @@ ngx_http_file_cache_set_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
break;
}
if (*p++ == ':' && n < 2 && p != last) {
if (*p++ == ':' && n < NGX_MAX_PATH_LEVEL - 1 && p < last) {
continue;
}
@ -2278,7 +2278,7 @@ ngx_http_file_cache_set_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
goto invalid_levels;
}
if (cache->path->len < 10 + 3) {
if (cache->path->len < 10 + NGX_MAX_PATH_LEVEL) {
continue;
}
@ -2450,7 +2450,7 @@ ngx_http_file_cache_set_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_memcpy(p, "/temp", sizeof("/temp"));
ngx_memcpy(&cache->temp_path->level, &cache->path->level,
3 * sizeof(size_t));
NGX_MAX_PATH_LEVEL * sizeof(size_t));
cache->temp_path->len = cache->path->len;
cache->temp_path->conf_file = cf->conf_file->file.name.data;