]> git.kaiwu.me - nginx.git/commitdiff
move condition declarations inside blocks where they are used
authorIgor Sysoev <igor@sysoev.ru>
Mon, 10 Dec 2007 12:09:51 +0000 (12:09 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Mon, 10 Dec 2007 12:09:51 +0000 (12:09 +0000)
15 files changed:
src/core/nginx.c
src/core/ngx_cycle.c
src/core/ngx_file.c
src/event/modules/ngx_select_module.c
src/event/ngx_event.c
src/http/modules/ngx_http_referer_module.c
src/http/modules/ngx_http_ssi_filter_module.c
src/http/ngx_http.c
src/http/ngx_http_core_module.c
src/http/ngx_http_request.c
src/mail/ngx_mail_handler.c
src/mail/ngx_mail_imap_handler.c
src/mail/ngx_mail_pop3_handler.c
src/mail/ngx_mail_smtp_handler.c
src/os/unix/ngx_process_cycle.c

index ae68605ef2e297ef72096f8c643d1f87f03b25dc..ee636825b0bcb7d35bfd6dbbc30f4b97dca23d50 100644 (file)
@@ -758,12 +758,6 @@ ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf)
 {
     ngx_core_conf_t  *ccf = conf;
 
-#if !(NGX_WIN32)
-    ngx_str_t       lock_file;
-    struct group   *grp;
-    struct passwd  *pwd;
-#endif
-
     ngx_conf_init_value(ccf->daemon, 1);
     ngx_conf_init_value(ccf->master, 1);
     ngx_conf_init_msec_value(ccf->timer_resolution, 0);
@@ -796,6 +790,8 @@ ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf)
 #if !(NGX_WIN32)
 
     if (ccf->user == (uid_t) NGX_CONF_UNSET_UINT && geteuid() == 0) {
+        struct group   *grp;
+        struct passwd  *pwd;
 
         ngx_set_errno(0);
         pwd = getpwnam(NGX_USER);
@@ -848,6 +844,9 @@ ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf)
         return NGX_CONF_ERROR;
     }
 
+    {
+    ngx_str_t  lock_file;
+
     lock_file = cycle->old_cycle->lock_file;
 
     if (lock_file.len) {
@@ -881,6 +880,7 @@ ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf)
                               ccf->lock_file.len),
                    ".accept", sizeof(".accept"));
     }
+    }
 
 #endif
 
index f900a2824b2aa152eb5bfaa21ffa556b665473ff..f0e86eb9426a03af34e0d6fda023c661367a77d4 100644 (file)
@@ -938,9 +938,6 @@ ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user)
     ngx_uint_t        i;
     ngx_list_part_t  *part;
     ngx_open_file_t  *file;
-#if !(NGX_WIN32)
-    ngx_file_info_t   fi;
-#endif
 
     part = &cycle->open_files.part;
     file = part->elts;
@@ -996,6 +993,7 @@ ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user)
         }
 #else
         if (user != (ngx_uid_t) NGX_CONF_UNSET_UINT) {
+            ngx_file_info_t  fi;
 
             if (ngx_file_info((const char *) file[i].name.data, &fi) == -1) {
                 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
index c945b558d2bde750cc9b37a7ea88cbb282c2dcf9..8edd3e14e00902f96d933af7b50d03b97474c117 100644 (file)
@@ -425,9 +425,6 @@ ngx_create_pathes(ngx_cycle_t *cycle, ngx_uid_t user)
     ngx_err_t         err;
     ngx_uint_t        i;
     ngx_path_t      **path;
-#if !(NGX_WIN32)
-    ngx_file_info_t   fi;
-#endif
 
     path = cycle->pathes.elts;
     for (i = 0; i < cycle->pathes.nelts; i++) {
@@ -447,6 +444,8 @@ ngx_create_pathes(ngx_cycle_t *cycle, ngx_uid_t user)
         }
 
 #if !(NGX_WIN32)
+        {
+        ngx_file_info_t   fi;
 
         if (ngx_file_info((const char *) path[i]->name.data, &fi) == -1) {
             ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
@@ -474,7 +473,7 @@ ngx_create_pathes(ngx_cycle_t *cycle, ngx_uid_t user)
                 return NGX_ERROR;
             }
         }
-
+        }
 #endif
     }
 
index 1e704c2f69f6426a2b6b91c55e67e776fdcad99b..19215a79c93fd59a7e0c190ddca659eb09a26f58 100644 (file)
@@ -254,9 +254,6 @@ ngx_select_process_events(ngx_cycle_t *cycle, ngx_msec_t timer,
     ngx_event_t        *ev, **queue;
     ngx_connection_t   *c;
     struct timeval      tv, *tp;
-#if !(NGX_WIN32)
-    ngx_uint_t          level;
-#endif
 
 #if !(NGX_WIN32)
 
@@ -348,6 +345,8 @@ ngx_select_process_events(ngx_cycle_t *cycle, ngx_msec_t timer,
 #else
 
     if (err) {
+        ngx_uint_t  level;
+
         if (err == NGX_EINTR) {
 
             if (ngx_event_timer_alarm) {
index 7a856d409a6b674728a8cdce43dc85d1f2915368..d347107428ee3c7594ff73318db0e8bac1d45a18 100644 (file)
@@ -428,13 +428,9 @@ ngx_event_module_init(ngx_cycle_t *cycle)
     void              ***cf;
     u_char              *shared;
     size_t               size, cl;
-    ngx_event_conf_t    *ecf;
-    ngx_core_conf_t     *ccf;
     ngx_shm_t            shm;
-#if !(NGX_WIN32)
-    ngx_int_t            limit;
-    struct rlimit        rlmt;
-#endif
+    ngx_core_conf_t     *ccf;
+    ngx_event_conf_t    *ecf;
 
     cf = ngx_get_conf(cycle->conf_ctx, ngx_events_module);
 
@@ -456,6 +452,9 @@ ngx_event_module_init(ngx_cycle_t *cycle)
     ngx_timer_resolution = ccf->timer_resolution;
 
 #if !(NGX_WIN32)
+    {
+    ngx_int_t      limit;
+    struct rlimit  rlmt;
 
     if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) {
         ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
@@ -475,7 +474,7 @@ ngx_event_module_init(ngx_cycle_t *cycle)
                           ecf->connections, limit);
         }
     }
-
+    }
 #endif /* !(NGX_WIN32) */
 
 
@@ -573,13 +572,6 @@ ngx_event_process_init(ngx_cycle_t *cycle)
     ngx_core_conf_t     *ccf;
     ngx_event_conf_t    *ecf;
     ngx_event_module_t  *module;
-#if (NGX_WIN32)
-    ngx_iocp_conf_t     *iocpcf;
-#else
-    struct rlimit        rlmt;
-    struct sigaction     sa;
-    struct itimerval     itv;
-#endif
 
     ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
     ecf = ngx_event_get_conf(cycle->conf_ctx, ngx_event_core_module);
@@ -625,6 +617,8 @@ ngx_event_process_init(ngx_cycle_t *cycle)
 #if !(NGX_WIN32)
 
     if (ngx_timer_resolution && !(ngx_event_flags & NGX_USE_TIMER_EVENT)) {
+        struct sigaction  sa;
+        struct itimerval  itv;
 
         ngx_memzero(&sa, sizeof(struct sigaction));
         sa.sa_handler = ngx_timer_signal_handler;
@@ -648,6 +642,7 @@ ngx_event_process_init(ngx_cycle_t *cycle)
     }
 
     if (ngx_event_flags & NGX_USE_FD_EVENT) {
+        struct rlimit  rlmt;
 
         if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) {
             ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
@@ -774,6 +769,8 @@ ngx_event_process_init(ngx_cycle_t *cycle)
 #if (NGX_WIN32)
 
         if (ngx_event_flags & NGX_USE_IOCP_EVENT) {
+            ngx_iocp_conf_t  *iocpcf;
+
             rev->handler = ngx_event_acceptex;
 
             if (ngx_add_event(rev, 0, NGX_IOCP_ACCEPT) == NGX_ERROR) {
index d5e8d6482705c4e041e2f4b9596b29bbf35ebba0..0076e947241651a3ca1fc47023eca9f04606c3a7 100644 (file)
@@ -106,11 +106,6 @@ ngx_http_referer_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
     ngx_uint_t                 i, key;
     ngx_http_referer_conf_t   *rlcf;
     u_char                     buf[256];
-#if (NGX_PCRE)
-    ngx_int_t                  n;
-    ngx_str_t                  referer;
-    ngx_http_referer_regex_t  *regex;
-#endif
 
     rlcf = ngx_http_get_module_loc_conf(r, ngx_http_referer_module);
 
@@ -173,6 +168,9 @@ ngx_http_referer_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
 #if (NGX_PCRE)
 
     if (rlcf->regex) {
+        ngx_int_t                  n;
+        ngx_str_t                  referer;
+        ngx_http_referer_regex_t  *regex;
 
         referer.len = len - 7;
         referer.data = ref;
index ae72ee3796a27273614ffc509498254c738fabee..5e17cb59f669410c6b2190ba02d467c458a24aef 100644 (file)
@@ -2373,11 +2373,6 @@ ngx_http_ssi_if(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx,
     ngx_str_t    *expr, left, right;
     ngx_int_t     rc;
     ngx_uint_t    negative, noregex, flags;
-#if (NGX_PCRE)
-    ngx_str_t     err;
-    ngx_regex_t  *regex;
-    u_char        errstr[NGX_MAX_CONF_ERRSTR];
-#endif
 
     if (ctx->command.len == 2) {
         if (ctx->conditional) {
@@ -2511,6 +2506,10 @@ ngx_http_ssi_if(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx,
 
     } else {
 #if (NGX_PCRE)
+        ngx_str_t     err;
+        ngx_regex_t  *regex;
+        u_char        errstr[NGX_MAX_CONF_ERRSTR];
+
         err.len = NGX_MAX_CONF_ERRSTR;
         err.data = errstr;
 
index 59b43d05444aca3da8e44cf08edd101f10480999..e3583a4f8311155b1b0dd7ffe10524fd5a652d28 100644 (file)
@@ -101,9 +101,6 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 #if (NGX_PCRE)
     ngx_uint_t                   regex;
 #endif
-#if (NGX_WIN32)
-    ngx_iocp_conf_t             *iocpcf;
-#endif
 
     /* the main http context */
 
@@ -821,10 +818,14 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
             ls->log.handler = ngx_accept_log_error;
 
 #if (NGX_WIN32)
+            {
+            ngx_iocp_conf_t  *iocpcf;
+
             iocpcf = ngx_event_get_conf(cf->cycle->conf_ctx, ngx_iocp_module);
             if (iocpcf->acceptex_read) {
                 ls->post_accept_buffer_size = cscf->client_header_buffer_size;
             }
+            }
 #endif
 
             ls->backlog = in_addr[a].listen_conf->backlog;
index b882f1c2fc637b6641b4ecbd6105eccf138b0f75..dbfa91ac6047a3fbdd985e8f3ca49c8de2077793 100644 (file)
@@ -1803,10 +1803,6 @@ ngx_http_core_location(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
     ngx_http_conf_ctx_t       *ctx, *pctx;
     ngx_http_core_srv_conf_t  *cscf;
     ngx_http_core_loc_conf_t  *clcf, *pclcf, **clcfp;
-#if (NGX_PCRE)
-    ngx_str_t                  err;
-    u_char                     errstr[NGX_MAX_CONF_ERRSTR];
-#endif
 
     ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t));
     if (ctx == NULL) {
@@ -1861,6 +1857,9 @@ ngx_http_core_location(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
                        && value[1].data[1] == '*'))
         {
 #if (NGX_PCRE)
+            ngx_str_t  err;
+            u_char     errstr[NGX_MAX_CONF_ERRSTR];
+
             err.len = NGX_MAX_CONF_ERRSTR;
             err.data = errstr;
 
@@ -2803,10 +2802,6 @@ ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
     ngx_str_t               *value, name;
     ngx_uint_t               i;
     ngx_http_server_name_t  *sn;
-#if (NGX_PCRE)
-    ngx_str_t                err;
-    u_char                   errstr[NGX_MAX_CONF_ERRSTR];
-#endif
 
     value = cf->args->elts;
 
@@ -2882,6 +2877,10 @@ ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
         }
 
 #if (NGX_PCRE)
+        {
+        ngx_str_t  err;
+        u_char     errstr[NGX_MAX_CONF_ERRSTR];
+
         err.len = NGX_MAX_CONF_ERRSTR;
         err.data = errstr;
 
@@ -2898,7 +2897,7 @@ ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 
         sn->name.len = value[i].len;
         sn->name.data = value[i].data;
-
+        }
 #else
         ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                            "the using of the regex \"%V\" "
index 3d06f964f02f32d47fe3b54f0c1d80032c815a34..51ec46ce75baccd98e48754af67e90077c60d17d 100644 (file)
@@ -232,9 +232,6 @@ ngx_http_init_request(ngx_event_t *rev)
     ngx_http_core_srv_conf_t   *cscf;
     ngx_http_core_loc_conf_t   *clcf;
     ngx_http_core_main_conf_t  *cmcf;
-#if (NGX_HTTP_SSL)
-    ngx_http_ssl_srv_conf_t    *sscf;
-#endif
 
 #if (NGX_STAT_STUB)
     ngx_atomic_fetch_add(ngx_stat_reading, -1);
@@ -354,6 +351,9 @@ ngx_http_init_request(ngx_event_t *rev)
 
 #if (NGX_HTTP_SSL)
 
+    {
+    ngx_http_ssl_srv_conf_t  *sscf;
+
     sscf = ngx_http_get_module_srv_conf(r, ngx_http_ssl_module);
     if (sscf->enable) {
 
@@ -370,6 +370,7 @@ ngx_http_init_request(ngx_event_t *rev)
 
         r->main_filter_need_in_memory = 1;
     }
+    }
 
 #endif
 
@@ -1398,11 +1399,7 @@ ngx_http_process_request_header(ngx_http_request_t *r)
 static void
 ngx_http_process_request(ngx_http_request_t *r)
 {
-    ngx_connection_t         *c;
-#if (NGX_HTTP_SSL)
-    long                      rc;
-    ngx_http_ssl_srv_conf_t  *sscf;
-#endif
+    ngx_connection_t  *c;
 
     c = r->connection;
 
@@ -1416,6 +1413,9 @@ ngx_http_process_request(ngx_http_request_t *r)
 #if (NGX_HTTP_SSL)
 
     if (c->ssl) {
+        long                      rc;
+        ngx_http_ssl_srv_conf_t  *sscf;
+
         sscf = ngx_http_get_module_srv_conf(r, ngx_http_ssl_module);
 
         if (sscf->verify) {
@@ -1469,12 +1469,6 @@ ngx_http_find_virtual_server(ngx_http_request_t *r, u_char *host, size_t len,
 {
     ngx_http_core_loc_conf_t  *clcf;
     ngx_http_core_srv_conf_t  *cscf;
-#if (NGX_PCRE)
-    ngx_int_t                  n;
-    ngx_uint_t                 i;
-    ngx_str_t                  name;
-    ngx_http_server_name_t    *sn;
-#endif
 
     cscf = ngx_hash_find_combined(&r->virtual_names->names, hash, host, len);
 
@@ -1485,6 +1479,10 @@ ngx_http_find_virtual_server(ngx_http_request_t *r, u_char *host, size_t len,
 #if (NGX_PCRE)
 
     if (r->virtual_names->nregex) {
+        ngx_int_t                n;
+        ngx_uint_t               i;
+        ngx_str_t                name;
+        ngx_http_server_name_t  *sn;
 
         name.len = len;
         name.data = host;
index e4985d3d24e86eed0b0f78cb7041997037f0200d..0cb67a237c8ac0a1746a22055fe1bfc60623384b 100644 (file)
@@ -29,10 +29,6 @@ ngx_mail_init_connection(ngx_connection_t *c)
     ngx_mail_in_port_t   *imip;
     ngx_mail_in_addr_t   *imia;
     ngx_mail_session_t   *s;
-#if (NGX_MAIL_SSL)
-    ngx_mail_ssl_conf_t  *sslcf;
-#endif
-
 
     /* find the server configuration for the address:port */
 
@@ -116,6 +112,8 @@ ngx_mail_init_connection(ngx_connection_t *c)
     c->log_error = NGX_ERROR_INFO;
 
 #if (NGX_MAIL_SSL)
+    {
+    ngx_mail_ssl_conf_t  *sslcf;
 
     sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module);
 
@@ -123,7 +121,7 @@ ngx_mail_init_connection(ngx_connection_t *c)
         ngx_mail_ssl_init_connection(&sslcf->ssl, c);
         return;
     }
-
+    }
 #endif
 
     ngx_mail_init_session(c);
index 949e96e2e75168bd1cdfde6f4d2868242fd2b6ba..62ba17da846535a2e1d20b17dd3f7b0a937e0d1e 100644 (file)
@@ -302,7 +302,7 @@ ngx_mail_imap_auth_state(ngx_event_t *rev)
 static ngx_int_t
 ngx_mail_imap_login(ngx_mail_session_t *s, ngx_connection_t *c)
 {
-    ngx_str_t            *arg;
+    ngx_str_t  *arg;
 
 #if (NGX_MAIL_SSL)
     if (ngx_mail_starttls_only(s, c)) {
@@ -410,15 +410,14 @@ static ngx_int_t
 ngx_mail_imap_capability(ngx_mail_session_t *s, ngx_connection_t *c)
 {
     ngx_mail_imap_srv_conf_t  *iscf;
-#if (NGX_MAIL_SSL)
-    ngx_mail_ssl_conf_t       *sslcf;
-#endif
 
     iscf = ngx_mail_get_module_srv_conf(s, ngx_mail_imap_module);
 
 #if (NGX_MAIL_SSL)
 
     if (c->ssl == NULL) {
+        ngx_mail_ssl_conf_t  *sslcf;
+
         sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module);
 
         if (sslcf->starttls == NGX_MAIL_STARTTLS_ON) {
index 966345a5a72e2be926355205b48863ff175b7f30..c486fbebd5556ca1a16b867e8c9487a4da838930 100644 (file)
@@ -283,7 +283,7 @@ ngx_mail_pop3_auth_state(ngx_event_t *rev)
 static ngx_int_t
 ngx_mail_pop3_user(ngx_mail_session_t *s, ngx_connection_t *c)
 {
-    ngx_str_t            *arg;
+    ngx_str_t  *arg;
 
 #if (NGX_MAIL_SSL)
     if (ngx_mail_starttls_only(s, c)) {
@@ -344,15 +344,14 @@ static ngx_int_t
 ngx_mail_pop3_capa(ngx_mail_session_t *s, ngx_connection_t *c, ngx_int_t stls)
 {
     ngx_mail_pop3_srv_conf_t  *pscf;
-#if (NGX_MAIL_SSL)
-    ngx_mail_ssl_conf_t       *sslcf;
-#endif
 
     pscf = ngx_mail_get_module_srv_conf(s, ngx_mail_pop3_module);
 
 #if (NGX_MAIL_SSL)
 
     if (stls && c->ssl == NULL) {
+        ngx_mail_ssl_conf_t  *sslcf;
+
         sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module);
 
         if (sslcf->starttls == NGX_MAIL_STARTTLS_ON) {
index 96cb762ed7f61f470ebe9962ecede500b5af6240..84722f4ee948569ae9df0c4d0b80ca23c2cb26d5 100644 (file)
@@ -319,9 +319,6 @@ ngx_mail_smtp_helo(ngx_mail_session_t *s, ngx_connection_t *c)
 {
     ngx_str_t                 *arg;
     ngx_mail_smtp_srv_conf_t  *sscf;
-#if (NGX_MAIL_SSL)
-    ngx_mail_ssl_conf_t       *sslcf;
-#endif
 
     if (s->args.nelts != 1) {
         s->out.len = sizeof(smtp_invalid_argument) - 1;
@@ -352,6 +349,8 @@ ngx_mail_smtp_helo(ngx_mail_session_t *s, ngx_connection_t *c)
 #if (NGX_MAIL_SSL)
 
         if (c->ssl == NULL) {
+            ngx_mail_ssl_conf_t  *sslcf;
+
             sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module);
 
             if (sslcf->starttls == NGX_MAIL_STARTTLS_ON) {
index 631597ef45f19f2e850746b695d59ff98181bb1f..aa95e81d93659a4301cecf1d73d50172012e5c26 100644 (file)
@@ -687,17 +687,16 @@ ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
 {
     ngx_uint_t         i;
     ngx_connection_t  *c;
-#if (NGX_THREADS)
-    ngx_int_t          n;
-    ngx_err_t          err;
-    ngx_core_conf_t   *ccf;
-#endif
 
     ngx_worker_process_init(cycle, 1);
 
     ngx_setproctitle("worker process");
 
 #if (NGX_THREADS)
+    {
+    ngx_int_t         n;
+    ngx_err_t         err;
+    ngx_core_conf_t  *ccf;
 
     ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
 
@@ -736,7 +735,7 @@ ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
             }
         }
     }
-
+    }
 #endif
 
     for ( ;; ) {