[PATCH v3 05/12] nxt_http_static_ctx_t: rename field 'index' to 'share_idx'

Alejandro Colomar alx.manpages at gmail.com
Sun Dec 19 01:30:23 UTC 2021


Having a configurable index filename will require adding an index
field to this structure.  The most natural name for that field is
'index', so the current index field should be renamed to allow for
that.  A sensible name is 'share_idx', since it's the index of the
shares array in 'nxt_http_static_conf_t'.

Instead of 'share_index' I opted for the shorter 'share_idx'.
Also, when 'index' allows an array of filenames in a following
commit, another similar variable 'index_idx' should be created,
and having a different prefix and suffix seems more readable than
for example 'index_index'.

Signed-off-by: Alejandro Colomar <alx.manpages at gmail.com>
Cc: Nginx Unit <unit at nginx.org>
Cc: "Valentin V. Bartenev" <vbart at nginx.com>
Cc: Zhidao HONG <z.hong at f5.com>
Cc: Igor Sysoev <igor at sysoev.ru>
Cc: Oisin Canty <o.canty at f5.com>
---
 src/nxt_http_static.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/nxt_http_static.c b/src/nxt_http_static.c
index 6b7cee7..663f896 100644
--- a/src/nxt_http_static.c
+++ b/src/nxt_http_static.c
@@ -33,7 +33,7 @@ typedef struct {
 #if (NXT_HAVE_OPENAT2)
     nxt_str_t                   chroot;
 #endif
-    uint32_t                    index;
+    uint32_t                    share_idx;
     uint8_t                     need_body;  /* 1 bit */
 } nxt_http_static_ctx_t;
 
@@ -218,7 +218,7 @@ nxt_http_static_iterate(nxt_task_t *task, nxt_http_request_t *r,
 
     conf = ctx->action->u.conf;
 
-    share = &conf->shares[ctx->index];
+    share = &conf->shares[ctx->share_idx];
 
 #if (NXT_DEBUG)
     nxt_str_t  shr;
@@ -245,7 +245,7 @@ nxt_http_static_iterate(nxt_task_t *task, nxt_http_request_t *r,
         nxt_var_raw(share->var, &ctx->share);
 
 #if (NXT_HAVE_OPENAT2)
-        if (conf->chroot != NULL && ctx->index == 0) {
+        if (conf->chroot != NULL && ctx->share_idx == 0) {
             nxt_var_raw(conf->chroot, &ctx->chroot);
         }
 #endif
@@ -262,7 +262,7 @@ nxt_http_static_iterate(nxt_task_t *task, nxt_http_request_t *r,
         nxt_var_query(task, r->var_query, share->var, &ctx->share);
 
 #if (NXT_HAVE_OPENAT2)
-        if (conf->chroot != NULL && ctx->index == 0) {
+        if (conf->chroot != NULL && ctx->share_idx == 0) {
             nxt_var_query(task, r->var_query, conf->chroot, &ctx->chroot);
         }
 #endif
@@ -357,7 +357,7 @@ nxt_http_static_send_ready(nxt_task_t *task, void *obj, void *data)
         nxt_uint_t               resolve;
         nxt_http_static_share_t  *share;
 
-        share = &conf->shares[ctx->index];
+        share = &conf->shares[ctx->share_idx];
 
         resolve = conf->resolve;
         chr = &ctx->chroot;
@@ -659,9 +659,9 @@ nxt_http_static_next(nxt_task_t *task, nxt_http_request_t *r,
     action = ctx->action;
     conf = action->u.conf;
 
-    ctx->index++;
+    ctx->share_idx++;
 
-    if (ctx->index < conf->nshares) {
+    if (ctx->share_idx < conf->nshares) {
         nxt_http_static_iterate(task, r, ctx);
         return;
     }
-- 
2.34.1



More information about the unit mailing list