Skip to content

Commit da39fa8

Browse files
committed
massive coding style fixes.
1 parent a243a96 commit da39fa8

4 files changed

+40
-47
lines changed

src/ngx_http_srcache_fetch.c

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,9 @@
1818

1919
static ngx_int_t ngx_http_srcache_fetch_subrequest(ngx_http_request_t *r,
2020
ngx_http_srcache_loc_conf_t *conf, ngx_http_srcache_ctx_t *ctx);
21-
2221
static ngx_int_t ngx_http_srcache_fetch_header_filter(ngx_http_request_t *r);
23-
2422
static ngx_int_t ngx_http_srcache_test_not_modified(ngx_http_request_t *r);
25-
2623
static ngx_int_t ngx_http_srcache_test_precondition(ngx_http_request_t *r);
27-
2824
static void ngx_http_srcache_post_read_body(ngx_http_request_t *r);
2925

3026

@@ -74,7 +70,7 @@ ngx_http_srcache_access_handler(ngx_http_request_t *r)
7470
/* register a ctx to give a chance to srcache_store to run */
7571

7672
ctx = ngx_pcalloc(r->pool,
77-
sizeof(ngx_http_srcache_filter_module));
73+
sizeof(ngx_http_srcache_filter_module));
7874

7975
if (ctx == NULL) {
8076
return NGX_HTTP_INTERNAL_SERVER_ERROR;
@@ -92,9 +88,9 @@ ngx_http_srcache_access_handler(ngx_http_request_t *r)
9288
}
9389

9490
if (conf->fetch_skip != NULL
95-
&& ngx_http_complex_value(r, conf->fetch_skip, &skip) == NGX_OK
96-
&& skip.len
97-
&& (skip.len != 1 || skip.data[0] != '0'))
91+
&& ngx_http_complex_value(r, conf->fetch_skip, &skip) == NGX_OK
92+
&& skip.len
93+
&& (skip.len != 1 || skip.data[0] != '0'))
9894
{
9995
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
10096
"srcache_fetch skipped due to the true value fed into "
@@ -178,7 +174,7 @@ ngx_http_srcache_access_handler(ngx_http_request_t *r)
178174

179175
if (!r->filter_finalize) {
180176
rc = ngx_http_srcache_next_body_filter(r,
181-
ctx->body_from_cache);
177+
ctx->body_from_cache);
182178

183179
if (rc == NGX_ERROR) {
184180
r->connection->error = 1;
@@ -237,7 +233,7 @@ ngx_http_srcache_access_handler(ngx_http_request_t *r)
237233
tmp = *cur_ph;
238234

239235
memmove(cur_ph, cur_ph + 1,
240-
(last_ph - cur_ph) * sizeof (ngx_http_phase_handler_t));
236+
(last_ph - cur_ph) * sizeof (ngx_http_phase_handler_t));
241237

242238
*last_ph = tmp;
243239

@@ -294,7 +290,7 @@ ngx_http_srcache_access_handler(ngx_http_request_t *r)
294290

295291
ngx_int_t
296292
ngx_http_srcache_fetch_post_subrequest(ngx_http_request_t *r, void *data,
297-
ngx_int_t rc)
293+
ngx_int_t rc)
298294
{
299295
ngx_http_srcache_ctx_t *ctx = data;
300296
ngx_http_srcache_ctx_t *pr_ctx;
@@ -325,8 +321,8 @@ ngx_http_srcache_fetch_post_subrequest(ngx_http_request_t *r, void *data,
325321
pr_ctx->from_cache = 0;
326322

327323
} else if (r->headers_out.status >= NGX_HTTP_SPECIAL_RESPONSE
328-
|| rc == NGX_ERROR
329-
|| rc >= NGX_HTTP_SPECIAL_RESPONSE)
324+
|| rc == NGX_ERROR
325+
|| rc >= NGX_HTTP_SPECIAL_RESPONSE)
330326
{
331327
dd("HERE");
332328
pr_ctx->from_cache = 0;
@@ -351,7 +347,7 @@ ngx_http_srcache_fetch_post_subrequest(ngx_http_request_t *r, void *data,
351347

352348
static ngx_int_t
353349
ngx_http_srcache_fetch_subrequest(ngx_http_request_t *r,
354-
ngx_http_srcache_loc_conf_t *conf, ngx_http_srcache_ctx_t *ctx)
350+
ngx_http_srcache_loc_conf_t *conf, ngx_http_srcache_ctx_t *ctx)
355351
{
356352
ngx_http_srcache_ctx_t *sr_ctx;
357353
ngx_http_post_subrequest_t *psr;
@@ -376,7 +372,7 @@ ngx_http_srcache_fetch_subrequest(ngx_http_request_t *r,
376372
parsed_sr->content_length_n = -1;
377373

378374
if (ngx_http_complex_value(r, &conf->fetch->location,
379-
&parsed_sr->location) != NGX_OK)
375+
&parsed_sr->location) != NGX_OK)
380376
{
381377
return NGX_HTTP_INTERNAL_SERVER_ERROR;
382378
}
@@ -421,13 +417,13 @@ ngx_http_srcache_fetch_subrequest(ngx_http_request_t *r,
421417
dd("firing the fetch subrequest");
422418

423419
dd("fetch location: %.*s", (int) parsed_sr->location.len,
424-
parsed_sr->location.data);
420+
parsed_sr->location.data);
425421

426422
dd("fetch args: %.*s", (int) parsed_sr->args.len,
427423
parsed_sr->args.data);
428424

429425
rc = ngx_http_subrequest(r, &parsed_sr->location, &parsed_sr->args,
430-
&sr, psr, flags);
426+
&sr, psr, flags);
431427

432428
if (rc != NGX_OK) {
433429
return NGX_ERROR;

src/ngx_http_srcache_filter_module.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ ngx_http_srcache_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
353353

354354
static char *
355355
ngx_http_srcache_conf_set_request(ngx_conf_t *cf, ngx_command_t *cmd,
356-
void *conf)
356+
void *conf)
357357
{
358358
char *p = conf;
359359

@@ -549,7 +549,7 @@ ngx_http_srcache_post_config(ngx_conf_t *cf)
549549

550550
static char *
551551
ngx_http_srcache_store_statuses(ngx_conf_t *cf, ngx_command_t *cmd,
552-
void *conf)
552+
void *conf)
553553
{
554554
ngx_http_srcache_loc_conf_t *slcf = conf;
555555

src/ngx_http_srcache_store.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ ngx_http_srcache_header_filter(ngx_http_request_t *r)
6868
dd("in fetch subrequest");
6969

7070
pr_ctx = ngx_http_get_module_ctx(r->parent,
71-
ngx_http_srcache_filter_module);
71+
ngx_http_srcache_filter_module);
7272

7373
if (pr_ctx == NULL) {
7474
dd("parent ctx is null");
@@ -270,7 +270,7 @@ ngx_http_srcache_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
270270

271271
if (ctx->ignore_body || ctx->in_store_subrequest/* || ctx->fetch_error */) {
272272
dd("ignore body: ignore body %d, in store sr %d",
273-
(int) ctx->ignore_body, (int) ctx->in_store_subrequest);
273+
(int) ctx->ignore_body, (int) ctx->in_store_subrequest);
274274
ngx_http_srcache_discard_bufs(r->pool, in);
275275
return NGX_OK;
276276
}
@@ -295,7 +295,7 @@ ngx_http_srcache_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
295295

296296
if (rc == NGX_AGAIN) {
297297
dd("AGAIN/OK: new pos %p, last %p",
298-
cl->buf->pos, cl->buf->last);
298+
cl->buf->pos, cl->buf->last);
299299

300300
continue;
301301
}
@@ -306,7 +306,7 @@ ngx_http_srcache_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
306306
ctx->ignore_body = 1;
307307
ngx_http_srcache_discard_bufs(r->pool, cl);
308308
pr_ctx = ngx_http_get_module_ctx(r->parent,
309-
ngx_http_srcache_filter_module);
309+
ngx_http_srcache_filter_module);
310310

311311
if (pr_ctx == NULL) {
312312
return NGX_ERROR;
@@ -321,7 +321,7 @@ ngx_http_srcache_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
321321

322322
dd("OK: new pos %p, last %p", cl->buf->pos, cl->buf->last);
323323
dd("buf left: %.*s", (int) (cl->buf->last - cl->buf->pos),
324-
cl->buf->pos);
324+
cl->buf->pos);
325325

326326
ctx->parsing_cached_headers = 0;
327327

@@ -347,7 +347,7 @@ ngx_http_srcache_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
347347
dd("save the cached response body for parent");
348348

349349
pr_ctx = ngx_http_get_module_ctx(r->parent,
350-
ngx_http_srcache_filter_module);
350+
ngx_http_srcache_filter_module);
351351

352352
if (pr_ctx == NULL) {
353353
return NGX_ERROR;
@@ -467,7 +467,7 @@ ngx_http_srcache_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
467467

468468
static ngx_int_t
469469
ngx_http_srcache_store_subrequest(ngx_http_request_t *r,
470-
ngx_http_srcache_ctx_t *ctx)
470+
ngx_http_srcache_ctx_t *ctx)
471471
{
472472
ngx_http_srcache_ctx_t *sr_ctx;
473473
ngx_str_t args;
@@ -521,7 +521,7 @@ ngx_http_srcache_store_subrequest(ngx_http_request_t *r,
521521
parsed_sr->content_length_n = ctx->response_length;
522522

523523
if (ngx_http_complex_value(r, &conf->store->location,
524-
&parsed_sr->location) != NGX_OK)
524+
&parsed_sr->location) != NGX_OK)
525525
{
526526
return NGX_HTTP_INTERNAL_SERVER_ERROR;
527527
}
@@ -531,7 +531,7 @@ ngx_http_srcache_store_subrequest(ngx_http_request_t *r,
531531
}
532532

533533
if (ngx_http_complex_value(r, &conf->store->args, &parsed_sr->args)
534-
!= NGX_OK)
534+
!= NGX_OK)
535535
{
536536
return NGX_HTTP_INTERNAL_SERVER_ERROR;
537537
}
@@ -540,7 +540,8 @@ ngx_http_srcache_store_subrequest(ngx_http_request_t *r,
540540
args.len = 0;
541541

542542
if (ngx_http_parse_unsafe_uri(r, &parsed_sr->location, &args, &flags)
543-
!= NGX_OK) {
543+
!= NGX_OK)
544+
{
544545
return NGX_HTTP_INTERNAL_SERVER_ERROR;
545546
}
546547

@@ -554,7 +555,7 @@ ngx_http_srcache_store_subrequest(ngx_http_request_t *r,
554555
parsed_sr->location.data);
555556

556557
dd("store args: %.*s", (int) parsed_sr->args.len,
557-
parsed_sr->args.data);
558+
parsed_sr->args.data);
558559

559560
sr_ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_srcache_ctx_t));
560561

@@ -573,7 +574,7 @@ ngx_http_srcache_store_subrequest(ngx_http_request_t *r,
573574
psr->data = sr_ctx;
574575

575576
rc = ngx_http_subrequest(r, &parsed_sr->location, &parsed_sr->args,
576-
&sr, psr, flags);
577+
&sr, psr, flags);
577578

578579
if (rc != NGX_OK) {
579580
return NGX_ERROR;
@@ -593,7 +594,7 @@ ngx_http_srcache_store_subrequest(ngx_http_request_t *r,
593594

594595
static ngx_int_t
595596
ngx_http_srcache_store_post_subrequest(ngx_http_request_t *r, void *data,
596-
ngx_int_t rc)
597+
ngx_int_t rc)
597598
{
598599
return NGX_OK;
599600
}

src/ngx_http_srcache_util.c

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ ngx_http_srcache_adjust_subrequest(ngx_http_request_t *sr,
288288
sr->request_body = body;
289289

290290
rc = ngx_http_srcache_set_content_length_header(sr,
291-
parsed_sr->content_length_n);
291+
parsed_sr->content_length_n);
292292

293293
if (rc != NGX_OK) {
294294
return NGX_HTTP_INTERNAL_SERVER_ERROR;
@@ -1035,7 +1035,7 @@ ngx_http_srcache_store_response_header(ngx_http_request_t *r,
10351035
&& r->headers_out.last_modified_time != -1)
10361036
{
10371037
b->last = ngx_cpymem(b->last, "Last-Modified: ",
1038-
sizeof("Last-Modified: ") - 1);
1038+
sizeof("Last-Modified: ") - 1);
10391039

10401040
b->last = ngx_cpymem(b->last, buf, sizeof(buf));
10411041

@@ -1044,7 +1044,7 @@ ngx_http_srcache_store_response_header(ngx_http_request_t *r,
10441044

10451045
if (r->allow_ranges) {
10461046
b->last = ngx_cpymem(b->last, "X-SRCache-Allow-Ranges: 1\r\n",
1047-
sizeof("X-SRCache-Allow-Ranges: 1\r\n") - 1);
1047+
sizeof("X-SRCache-Allow-Ranges: 1\r\n") - 1);
10481048
}
10491049

10501050
part = &r->headers_out.headers.part;
@@ -1067,14 +1067,14 @@ ngx_http_srcache_store_response_header(ngx_http_request_t *r,
10671067
}
10681068

10691069
dd("header hash: %lu, hash lc: %lu", (unsigned long) header[i].hash,
1070-
(unsigned long) ngx_hash_key_lc(header[i].key.data,
1071-
header[i].key.len));
1070+
(unsigned long) ngx_hash_key_lc(header[i].key.data,
1071+
header[i].key.len));
10721072

10731073
if (ngx_hash_find(&conf->hide_headers_hash, header[i].hash,
10741074
header[i].lowcase_key, header[i].key.len))
10751075
{
10761076
dd("skipped header key: %.*s", (int) header[i].key.len,
1077-
header[i].key.data);
1077+
header[i].key.data);
10781078
continue;
10791079
}
10801080

@@ -1133,8 +1133,7 @@ ngx_http_srcache_hide_headers_hash(ngx_conf_t *cf,
11331133
{
11341134
conf->hide_headers_hash = prev->hide_headers_hash;
11351135

1136-
if (conf->hide_headers_hash.buckets)
1137-
{
1136+
if (conf->hide_headers_hash.buckets) {
11381137
return NGX_OK;
11391138
}
11401139

@@ -1198,16 +1197,15 @@ ngx_http_srcache_hide_headers_hash(ngx_conf_t *cf,
11981197

11991198
if (h[i].len == sizeof("Last-Modified") - 1
12001199
&& ngx_strncasecmp(h[i].data, (u_char *) "Last-Modified",
1201-
sizeof("Last-Modified") - 1)
1200+
sizeof("Last-Modified") - 1)
12021201
== 0)
12031202
{
12041203
conf->hide_last_modified = 1;
12051204
}
12061205

12071206
if (h[i].len == sizeof("Content-Type") - 1
12081207
&& ngx_strncasecmp(h[i].data, (u_char *) "Content-Type",
1209-
sizeof("Content-Type") - 1)
1210-
== 0)
1208+
sizeof("Content-Type") - 1) == 0)
12111209
{
12121210
conf->hide_content_type = 1;
12131211
}
@@ -1235,16 +1233,14 @@ ngx_http_srcache_hide_headers_hash(ngx_conf_t *cf,
12351233

12361234
if (h[i].len == sizeof("Content-Type") - 1
12371235
&& ngx_strncasecmp(h[i].data, (u_char *) "Content-Type",
1238-
sizeof("Content-Type") - 1)
1239-
== 0)
1236+
sizeof("Content-Type") - 1) == 0)
12401237
{
12411238
conf->hide_content_type = 0;
12421239
}
12431240

12441241
if (h[i].len == sizeof("Last-Modified") - 1
12451242
&& ngx_strncasecmp(h[i].data, (u_char *) "Last-Modified",
1246-
sizeof("Last-Modified") - 1)
1247-
== 0)
1243+
sizeof("Last-Modified") - 1) == 0)
12481244
{
12491245
conf->hide_last_modified = 0;
12501246
}

0 commit comments

Comments
 (0)