Skip to content

Commit 1b95970

Browse files
committed
style: fixed minor coding style issues found by ngx-releng.
1 parent 20ed155 commit 1b95970

15 files changed

+145
-114
lines changed

src/ngx_postgres_ddebug.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636

3737
# if (NGX_HAVE_VARIADIC_MACROS)
3838

39-
# define dd(...) fprintf(stderr, "postgres *** %s: ", __func__); \
40-
fprintf(stderr, __VA_ARGS__); \
39+
# define dd(...) fprintf(stderr, "postgres *** %s: ", __func__); \
40+
fprintf(stderr, __VA_ARGS__); \
4141
fprintf(stderr, " *** %s line %d.\n", __FILE__, __LINE__)
4242

4343
# else

src/ngx_postgres_handler.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ ngx_postgres_handler(ngx_http_request_t *r)
8888
return rc;
8989
}
9090

91-
#if defined(nginx_version) \
92-
&& (((nginx_version >= 7063) && (nginx_version < 8000)) \
91+
#if defined(nginx_version) \
92+
&& (((nginx_version >= 7063) && (nginx_version < 8000)) \
9393
|| (nginx_version >= 8007))
9494

9595
if (ngx_http_upstream_create(r) != NGX_OK) {

src/ngx_postgres_handler.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,18 @@
3333
#include <ngx_http.h>
3434

3535

36-
ngx_int_t ngx_postgres_handler(ngx_http_request_t *);
37-
void ngx_postgres_wev_handler(ngx_http_request_t *,
38-
ngx_http_upstream_t *);
39-
void ngx_postgres_rev_handler(ngx_http_request_t *,
40-
ngx_http_upstream_t *);
41-
ngx_int_t ngx_postgres_create_request(ngx_http_request_t *);
42-
ngx_int_t ngx_postgres_reinit_request(ngx_http_request_t *);
43-
void ngx_postgres_abort_request(ngx_http_request_t *);
44-
void ngx_postgres_finalize_request(ngx_http_request_t *, ngx_int_t);
45-
ngx_int_t ngx_postgres_process_header(ngx_http_request_t *);
46-
ngx_int_t ngx_postgres_input_filter_init(void *);
47-
ngx_int_t ngx_postgres_input_filter(void *, ssize_t);
36+
ngx_int_t ngx_postgres_handler(ngx_http_request_t *);
37+
void ngx_postgres_wev_handler(ngx_http_request_t *,
38+
ngx_http_upstream_t *);
39+
void ngx_postgres_rev_handler(ngx_http_request_t *,
40+
ngx_http_upstream_t *);
41+
ngx_int_t ngx_postgres_create_request(ngx_http_request_t *);
42+
ngx_int_t ngx_postgres_reinit_request(ngx_http_request_t *);
43+
void ngx_postgres_abort_request(ngx_http_request_t *);
44+
void ngx_postgres_finalize_request(ngx_http_request_t *, ngx_int_t);
45+
ngx_int_t ngx_postgres_process_header(ngx_http_request_t *);
46+
ngx_int_t ngx_postgres_input_filter_init(void *);
47+
ngx_int_t ngx_postgres_input_filter(void *, ssize_t);
48+
4849

4950
#endif /* _NGX_POSTGRES_HANDLER_H_ */

src/ngx_postgres_keepalive.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,20 @@ typedef struct {
4747
} ngx_postgres_keepalive_cache_t;
4848

4949

50-
ngx_int_t ngx_postgres_keepalive_init(ngx_pool_t *,
51-
ngx_postgres_upstream_srv_conf_t *);
50+
ngx_int_t ngx_postgres_keepalive_init(ngx_pool_t *,
51+
ngx_postgres_upstream_srv_conf_t *);
5252
ngx_int_t ngx_postgres_keepalive_get_peer_single(ngx_peer_connection_t *,
53-
ngx_postgres_upstream_peer_data_t *,
54-
ngx_postgres_upstream_srv_conf_t *);
53+
ngx_postgres_upstream_peer_data_t *,
54+
ngx_postgres_upstream_srv_conf_t *);
5555
ngx_int_t ngx_postgres_keepalive_get_peer_multi(ngx_peer_connection_t *,
56-
ngx_postgres_upstream_peer_data_t *,
57-
ngx_postgres_upstream_srv_conf_t *);
58-
void ngx_postgres_keepalive_free_peer(ngx_peer_connection_t *,
59-
ngx_postgres_upstream_peer_data_t *,
60-
ngx_postgres_upstream_srv_conf_t *, ngx_uint_t);
61-
void ngx_postgres_keepalive_dummy_handler(ngx_event_t *);
62-
void ngx_postgres_keepalive_close_handler(ngx_event_t *);
63-
void ngx_postgres_keepalive_cleanup(void *);
56+
ngx_postgres_upstream_peer_data_t *,
57+
ngx_postgres_upstream_srv_conf_t *);
58+
void ngx_postgres_keepalive_free_peer(ngx_peer_connection_t *,
59+
ngx_postgres_upstream_peer_data_t *,
60+
ngx_postgres_upstream_srv_conf_t *, ngx_uint_t);
61+
void ngx_postgres_keepalive_dummy_handler(ngx_event_t *);
62+
void ngx_postgres_keepalive_close_handler(ngx_event_t *);
63+
void ngx_postgres_keepalive_cleanup(void *);
64+
6465

6566
#endif /* _NGX_POSTGRES_KEEPALIVE_H_ */

src/ngx_postgres_module.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -174,21 +174,21 @@ ngx_module_t ngx_postgres_module = {
174174
};
175175

176176
ngx_conf_bitmask_t ngx_postgres_http_methods[] = {
177-
{ ngx_string("GET"), NGX_HTTP_GET },
178-
{ ngx_string("HEAD"), NGX_HTTP_HEAD },
179-
{ ngx_string("POST"), NGX_HTTP_POST },
180-
{ ngx_string("PUT"), NGX_HTTP_PUT },
181-
{ ngx_string("DELETE"), NGX_HTTP_DELETE },
182-
{ ngx_string("MKCOL"), NGX_HTTP_MKCOL },
183-
{ ngx_string("COPY"), NGX_HTTP_COPY },
184-
{ ngx_string("MOVE"), NGX_HTTP_MOVE },
185-
{ ngx_string("OPTIONS"), NGX_HTTP_OPTIONS },
186-
{ ngx_string("PROPFIND"), NGX_HTTP_PROPFIND },
187-
{ ngx_string("PROPPATCH"), NGX_HTTP_PROPPATCH },
188-
{ ngx_string("LOCK"), NGX_HTTP_LOCK },
189-
{ ngx_string("UNLOCK"), NGX_HTTP_UNLOCK },
177+
{ ngx_string("GET"), NGX_HTTP_GET },
178+
{ ngx_string("HEAD"), NGX_HTTP_HEAD },
179+
{ ngx_string("POST"), NGX_HTTP_POST },
180+
{ ngx_string("PUT"), NGX_HTTP_PUT },
181+
{ ngx_string("DELETE"), NGX_HTTP_DELETE },
182+
{ ngx_string("MKCOL"), NGX_HTTP_MKCOL },
183+
{ ngx_string("COPY"), NGX_HTTP_COPY },
184+
{ ngx_string("MOVE"), NGX_HTTP_MOVE },
185+
{ ngx_string("OPTIONS"), NGX_HTTP_OPTIONS },
186+
{ ngx_string("PROPFIND"), NGX_HTTP_PROPFIND },
187+
{ ngx_string("PROPPATCH"), NGX_HTTP_PROPPATCH },
188+
{ ngx_string("LOCK"), NGX_HTTP_LOCK },
189+
{ ngx_string("UNLOCK"), NGX_HTTP_UNLOCK },
190190
#if defined(nginx_version) && (nginx_version >= 8041)
191-
{ ngx_string("PATCH"), NGX_HTTP_PATCH },
191+
{ ngx_string("PATCH"), NGX_HTTP_PATCH },
192192
#endif
193193
{ ngx_null_string, 0 }
194194
};
@@ -448,23 +448,23 @@ ngx_postgres_conf_server(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
448448
for (i = 2; i < cf->args->nelts; i++) {
449449

450450
if (ngx_strncmp(value[i].data, "dbname=", sizeof("dbname=") - 1)
451-
== 0)
451+
== 0)
452452
{
453453
pgs->dbname.len = value[i].len - (sizeof("dbname=") - 1);
454454
pgs->dbname.data = &value[i].data[sizeof("dbname=") - 1];
455455
continue;
456456
}
457457

458458
if (ngx_strncmp(value[i].data, "user=", sizeof("user=") - 1)
459-
== 0)
459+
== 0)
460460
{
461461
pgs->user.len = value[i].len - (sizeof("user=") - 1);
462462
pgs->user.data = &value[i].data[sizeof("user=") - 1];
463463
continue;
464464
}
465465

466466
if (ngx_strncmp(value[i].data, "password=", sizeof("password=") - 1)
467-
== 0)
467+
== 0)
468468
{
469469
pgs->password.len = value[i].len - (sizeof("password=") - 1);
470470
pgs->password.data = &value[i].data[sizeof("password=") - 1];
@@ -511,7 +511,7 @@ ngx_postgres_conf_keepalive(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
511511
for (i = 1; i < cf->args->nelts; i++) {
512512

513513
if (ngx_strncmp(value[i].data, "max=", sizeof("max=") - 1)
514-
== 0)
514+
== 0)
515515
{
516516
value[i].len = value[i].len - (sizeof("max=") - 1);
517517
value[i].data = &value[i].data[sizeof("max=") - 1];
@@ -533,7 +533,7 @@ ngx_postgres_conf_keepalive(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
533533
}
534534

535535
if (ngx_strncmp(value[i].data, "mode=", sizeof("mode=") - 1)
536-
== 0)
536+
== 0)
537537
{
538538
value[i].len = value[i].len - (sizeof("mode=") - 1);
539539
value[i].data = &value[i].data[sizeof("mode=") - 1];
@@ -562,7 +562,7 @@ ngx_postgres_conf_keepalive(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
562562
}
563563

564564
if (ngx_strncmp(value[i].data, "overflow=", sizeof("overflow=") - 1)
565-
== 0)
565+
== 0)
566566
{
567567
value[i].len = value[i].len - (sizeof("overflow=") - 1);
568568
value[i].data = &value[i].data[sizeof("overflow=") - 1];

src/ngx_postgres_module.h

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,41 +43,48 @@ typedef struct {
4343
ngx_uint_t empty;
4444
} ngx_postgres_escape_t;
4545

46+
4647
typedef struct {
4748
ngx_uint_t key;
4849
ngx_str_t sv;
4950
ngx_http_complex_value_t *cv;
5051
} ngx_postgres_mixed_t;
5152

53+
5254
typedef struct {
5355
ngx_uint_t key;
5456
ngx_int_t status;
5557
} ngx_postgres_rewrite_t;
5658

59+
5760
typedef struct {
5861
ngx_int_t row;
5962
ngx_int_t column;
6063
u_char *col_name;
6164
ngx_uint_t required;
6265
} ngx_postgres_value_t;
6366

67+
6468
typedef struct {
6569
ngx_uint_t idx;
6670
ngx_http_variable_t *var;
6771
ngx_postgres_value_t value;
6872
} ngx_postgres_variable_t;
6973

74+
7075
typedef struct {
7176
ngx_uint_t methods_set;
7277
ngx_array_t *methods; /* method-specific */
7378
ngx_postgres_mixed_t *def; /* default */
7479
} ngx_postgres_query_conf_t;
7580

76-
typedef struct ngx_postgres_rewrite_conf_s ngx_postgres_rewrite_conf_t;
81+
82+
typedef struct ngx_postgres_rewrite_conf_s ngx_postgres_rewrite_conf_t;
7783

7884
typedef ngx_int_t (*ngx_postgres_rewrite_handler_pt)
7985
(ngx_http_request_t *, ngx_postgres_rewrite_conf_t *);
8086

87+
8188
struct ngx_postgres_rewrite_conf_s {
8289
/* condition */
8390
ngx_uint_t key;
@@ -88,21 +95,25 @@ struct ngx_postgres_rewrite_conf_s {
8895
ngx_postgres_rewrite_t *def; /* default */
8996
};
9097

98+
9199
typedef struct {
92100
ngx_str_t name;
93101
ngx_uint_t key;
94102
ngx_postgres_rewrite_handler_pt handler;
95103
} ngx_postgres_rewrite_enum_t;
96104

105+
97106
typedef ngx_int_t (*ngx_postgres_output_handler_pt)
98107
(ngx_http_request_t *, PGresult *);
99108

109+
100110
typedef struct {
101111
ngx_str_t name;
102112
unsigned binary:1;
103113
ngx_postgres_output_handler_pt handler;
104114
} ngx_postgres_output_enum_t;
105115

116+
106117
typedef struct {
107118
#if defined(nginx_version) && (nginx_version >= 8022)
108119
ngx_addr_t *addrs;
@@ -116,6 +127,7 @@ typedef struct {
116127
ngx_str_t password;
117128
} ngx_postgres_upstream_server_t;
118129

130+
119131
typedef struct {
120132
struct sockaddr *sockaddr;
121133
socklen_t socklen;
@@ -127,13 +139,15 @@ typedef struct {
127139
ngx_str_t password;
128140
} ngx_postgres_upstream_peer_t;
129141

142+
130143
typedef struct {
131144
ngx_uint_t single;
132145
ngx_uint_t number;
133146
ngx_str_t *name;
134147
ngx_postgres_upstream_peer_t peer[1];
135148
} ngx_postgres_upstream_peers_t;
136149

150+
137151
typedef struct {
138152
ngx_postgres_upstream_peers_t *peers;
139153
ngx_uint_t current;
@@ -148,6 +162,7 @@ typedef struct {
148162
ngx_uint_t reject;
149163
} ngx_postgres_upstream_srv_conf_t;
150164

165+
151166
typedef struct {
152167
/* upstream */
153168
ngx_http_upstream_conf_t upstream;
@@ -163,6 +178,7 @@ typedef struct {
163178
ngx_array_t *variables;
164179
} ngx_postgres_loc_conf_t;
165180

181+
166182
typedef struct {
167183
ngx_chain_t *response;
168184
ngx_int_t var_cols;
@@ -174,20 +190,21 @@ typedef struct {
174190
} ngx_postgres_ctx_t;
175191

176192

177-
ngx_int_t ngx_postgres_add_variables(ngx_conf_t *);
178-
void *ngx_postgres_create_upstream_srv_conf(ngx_conf_t *);
179-
void *ngx_postgres_create_loc_conf(ngx_conf_t *);
180-
char *ngx_postgres_merge_loc_conf(ngx_conf_t *, void *, void *);
181-
char *ngx_postgres_conf_server(ngx_conf_t *, ngx_command_t *, void *);
182-
char *ngx_postgres_conf_keepalive(ngx_conf_t *, ngx_command_t *, void *);
183-
char *ngx_postgres_conf_pass(ngx_conf_t *, ngx_command_t *, void *);
184-
char *ngx_postgres_conf_query(ngx_conf_t *, ngx_command_t *, void *);
185-
char *ngx_postgres_conf_rewrite(ngx_conf_t *, ngx_command_t *, void *);
186-
char *ngx_postgres_conf_output(ngx_conf_t *, ngx_command_t *, void *);
187-
char *ngx_postgres_conf_set(ngx_conf_t *, ngx_command_t *, void *);
188-
char *ngx_postgres_conf_escape(ngx_conf_t *, ngx_command_t *, void *);
189-
190-
ngx_http_upstream_srv_conf_t *ngx_postgres_find_upstream(ngx_http_request_t *,
191-
ngx_url_t *);
193+
ngx_int_t ngx_postgres_add_variables(ngx_conf_t *);
194+
void *ngx_postgres_create_upstream_srv_conf(ngx_conf_t *);
195+
void *ngx_postgres_create_loc_conf(ngx_conf_t *);
196+
char *ngx_postgres_merge_loc_conf(ngx_conf_t *, void *, void *);
197+
char *ngx_postgres_conf_server(ngx_conf_t *, ngx_command_t *, void *);
198+
char *ngx_postgres_conf_keepalive(ngx_conf_t *, ngx_command_t *, void *);
199+
char *ngx_postgres_conf_pass(ngx_conf_t *, ngx_command_t *, void *);
200+
char *ngx_postgres_conf_query(ngx_conf_t *, ngx_command_t *, void *);
201+
char *ngx_postgres_conf_rewrite(ngx_conf_t *, ngx_command_t *, void *);
202+
char *ngx_postgres_conf_output(ngx_conf_t *, ngx_command_t *, void *);
203+
char *ngx_postgres_conf_set(ngx_conf_t *, ngx_command_t *, void *);
204+
char *ngx_postgres_conf_escape(ngx_conf_t *, ngx_command_t *, void *);
205+
206+
ngx_http_upstream_srv_conf_t *ngx_postgres_find_upstream(ngx_http_request_t *,
207+
ngx_url_t *);
208+
192209

193210
#endif /* _NGX_POSTGRES_MODULE_H_ */

src/ngx_postgres_output.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,19 @@
3737
#include "resty_dbd_stream.h"
3838

3939

40-
ngx_int_t ngx_postgres_output_value(ngx_http_request_t *, PGresult *);
41-
ngx_int_t ngx_postgres_output_text(ngx_http_request_t *, PGresult *);
42-
ngx_int_t ngx_postgres_output_rds(ngx_http_request_t *, PGresult *);
43-
ngx_chain_t *ngx_postgres_render_rds_header(ngx_http_request_t *,
44-
ngx_pool_t *, PGresult *, ngx_int_t, ngx_int_t);
40+
ngx_int_t ngx_postgres_output_value(ngx_http_request_t *, PGresult *);
41+
ngx_int_t ngx_postgres_output_text(ngx_http_request_t *, PGresult *);
42+
ngx_int_t ngx_postgres_output_rds(ngx_http_request_t *, PGresult *);
43+
ngx_chain_t *ngx_postgres_render_rds_header(ngx_http_request_t *,
44+
ngx_pool_t *, PGresult *, ngx_int_t, ngx_int_t);
4545
ngx_chain_t *ngx_postgres_render_rds_columns(ngx_http_request_t *,
46-
ngx_pool_t *, PGresult *, ngx_int_t);
46+
ngx_pool_t *, PGresult *, ngx_int_t);
4747
ngx_chain_t *ngx_postgres_render_rds_row(ngx_http_request_t *, ngx_pool_t *,
48-
PGresult *, ngx_int_t, ngx_int_t, ngx_int_t);
48+
PGresult *, ngx_int_t, ngx_int_t, ngx_int_t);
4949
ngx_chain_t *ngx_postgres_render_rds_row_terminator(ngx_http_request_t *,
50-
ngx_pool_t *);
51-
ngx_int_t ngx_postgres_output_chain(ngx_http_request_t *, ngx_chain_t *);
52-
rds_col_type_t ngx_postgres_rds_col_type(Oid);
50+
ngx_pool_t *);
51+
ngx_int_t ngx_postgres_output_chain(ngx_http_request_t *, ngx_chain_t *);
52+
rds_col_type_t ngx_postgres_rds_col_type(Oid);
53+
5354

5455
#endif /* _NGX_POSTGRES_OUTPUT_H_ */

src/ngx_postgres_processor.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ ngx_postgres_upstream_connect(ngx_http_request_t *r, ngx_connection_t *pgxc,
145145
"postgres: re-polling while connecting, rc:%d",
146146
(int) pgrc);
147147

148-
if (pgrc == PGRES_POLLING_READING || pgrc == PGRES_POLLING_WRITING)
148+
if (pgrc == PGRES_POLLING_READING
149+
|| pgrc == PGRES_POLLING_WRITING)
149150
{
150151
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pgxc->log, 0,
151152
"postgres: busy while connecting, rc:%d",

src/ngx_postgres_rewrite.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@
3333
#include "ngx_postgres_module.h"
3434

3535

36-
ngx_int_t ngx_postgres_rewrite(ngx_http_request_t *,
37-
ngx_postgres_rewrite_conf_t *);
38-
ngx_int_t ngx_postgres_rewrite_changes(ngx_http_request_t *,
39-
ngx_postgres_rewrite_conf_t *);
36+
ngx_int_t ngx_postgres_rewrite(ngx_http_request_t *,
37+
ngx_postgres_rewrite_conf_t *);
38+
ngx_int_t ngx_postgres_rewrite_changes(ngx_http_request_t *,
39+
ngx_postgres_rewrite_conf_t *);
4040
ngx_int_t ngx_postgres_rewrite_rows(ngx_http_request_t *,
41-
ngx_postgres_rewrite_conf_t *);
41+
ngx_postgres_rewrite_conf_t *);
42+
4243

4344
#endif /* _NGX_POSTGRES_REWRITE_H_ */

0 commit comments

Comments
 (0)