From: Edward Lu Date: Thu, 23 Jul 2015 19:20:09 +0000 (+0000) Subject: c89-ify http2 X-Git-Tag: 2.5.0-alpha~2991 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=546bf924b3c3b053c03c1e7675a02918ae6eefbc;p=thirdparty%2Fapache%2Fhttpd.git c89-ify http2 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1692432 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/http2/h2_alpn.c b/modules/http2/h2_alpn.c index 6a76f7fbda8..bb71e718854 100644 --- a/modules/http2/h2_alpn.c +++ b/modules/http2/h2_alpn.c @@ -143,7 +143,8 @@ void h2_alpn_register_hooks(void) static int h2_util_array_index(apr_array_header_t *array, const char *s) { - for (int i = 0; i < array->nelts; i++) { + int i; + for (i = 0; i < array->nelts; i++) { const char *p = APR_ARRAY_IDX(array, i, const char*); if (!strcmp(p, s)) { return i; @@ -155,6 +156,7 @@ static int h2_util_array_index(apr_array_header_t *array, const char *s) static int h2_npn_advertise(conn_rec *c, apr_array_header_t *protos) { h2_config *cfg; + apr_size_t i; check_sni_host(c); cfg = h2_config_get(c); @@ -162,7 +164,7 @@ static int h2_npn_advertise(conn_rec *c, apr_array_header_t *protos) return DECLINED; } - for (apr_size_t i = 0; i < h2_alpn_protos_len; ++i) { + for (i = 0; i < h2_alpn_protos_len; ++i) { const char *proto = h2_alpn_protos[i]; ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, c, "NPN proposing %s from client selection", proto); @@ -176,6 +178,7 @@ static int h2_negotiated(conn_rec *c, const char *via, apr_size_t proto_name_len) { h2_ctx *ctx = h2_ctx_get(c); + apr_size_t i; if (h2_ctx_is_task(ctx) ) { return DECLINED; @@ -197,7 +200,7 @@ static int h2_negotiated(conn_rec *c, const char *via, apr_pstrndup(c->pool, proto_name, proto_name_len)); } - for (apr_size_t i = 0; i < h2_alpn_protos_len; ++i) { + for (i = 0; i < h2_alpn_protos_len; ++i) { const char *proto = h2_alpn_protos[i]; if (proto_name_len == strlen(proto) && strncmp(proto, proto_name, proto_name_len) == 0) { @@ -222,6 +225,7 @@ static int h2_alpn_propose(conn_rec *c, apr_array_header_t *protos) { h2_config *cfg; + apr_size_t i; check_sni_host(c); cfg = h2_config_get(c); @@ -234,7 +238,7 @@ static int h2_alpn_propose(conn_rec *c, ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, c, "ALPN propose for config %s", cfg->name); /* */ - for (apr_size_t i = 0; i < h2_alpn_protos_len; ++i) { + for (i = 0; i < h2_alpn_protos_len; ++i) { const char *proto = h2_alpn_protos[i]; if (h2_util_array_index(client_protos, proto) >= 0) { ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, c, diff --git a/modules/http2/h2_alt_svc.c b/modules/http2/h2_alt_svc.c index b80bc54ee5f..2eaab12791f 100644 --- a/modules/http2/h2_alt_svc.c +++ b/modules/http2/h2_alt_svc.c @@ -73,6 +73,7 @@ static int h2_alt_svc_request_handler(request_rec *r) { h2_ctx *ctx = h2_ctx_rget(r); h2_config *cfg; + int i; if (h2_ctx_is_active(ctx) || h2_ctx_is_task(ctx)) { return DECLINED; @@ -98,7 +99,7 @@ static int h2_alt_svc_request_handler(request_rec *r) "h2_alt_svc: announce %s for %s:%d", (secure? "secure" : "insecure"), r->hostname, (int)r->server->port); - for (int i = 0; i < cfg->alt_svcs->nelts; ++i) { + for (i = 0; i < cfg->alt_svcs->nelts; ++i) { h2_alt_svc *as = h2_alt_svc_IDX(cfg->alt_svcs, i); const char *ahost = as->host; if (ahost && !apr_strnatcasecmp(ahost, r->hostname)) { diff --git a/modules/http2/h2_conn.c b/modules/http2/h2_conn.c index fc75704e9e0..2f98090b9d3 100644 --- a/modules/http2/h2_conn.c +++ b/modules/http2/h2_conn.c @@ -48,8 +48,9 @@ static int checked; static void check_modules() { + int i; if (!checked) { - for (int i = 0; ap_loaded_modules[i]; ++i) { + for (i = 0; ap_loaded_modules[i]; ++i) { module *m = ap_loaded_modules[i]; if (!strcmp("event.c", m->name)) { mpm_type = H2_MPM_EVENT; @@ -81,6 +82,7 @@ apr_status_t h2_conn_child_init(apr_pool_t *pool, server_rec *s) int max_threads_per_child = 0; int threads_limit = 0; int idle_secs = 0; + int i; ap_mpm_query(AP_MPMQ_MAX_THREADS, &max_threads_per_child); ap_mpm_query(AP_MPMQ_HARD_LIMIT_THREADS, &threads_limit); @@ -95,7 +97,7 @@ apr_status_t h2_conn_child_init(apr_pool_t *pool, server_rec *s) } } - for (int i = 0; ap_loaded_modules[i]; ++i) { + for (i = 0; ap_loaded_modules[i]; ++i) { module *m = ap_loaded_modules[i]; if (!strcmp("event.c", m->name)) { mpm_type = H2_MPM_EVENT; diff --git a/modules/http2/h2_conn_io.c b/modules/http2/h2_conn_io.c index 55e48119aaf..f876a1f95a4 100644 --- a/modules/http2/h2_conn_io.c +++ b/modules/http2/h2_conn_io.c @@ -188,8 +188,9 @@ static apr_status_t bucketeer_buffer(h2_conn_io *io) { apr_size_t remaining = io->buflen; int bcount = (int)(remaining / io->max_write_size); apr_bucket *b; + int i; - for (int i = 0; i < bcount; ++i) { + for (i = 0; i < bcount; ++i) { b = apr_bucket_transient_create(data, io->max_write_size, io->output->bucket_alloc); APR_BRIGADE_INSERT_TAIL(io->output, b); diff --git a/modules/http2/h2_io_set.c b/modules/http2/h2_io_set.c index c80ede4acb3..049e6d78942 100644 --- a/modules/http2/h2_io_set.c +++ b/modules/http2/h2_io_set.c @@ -47,7 +47,8 @@ h2_io_set *h2_io_set_create(apr_pool_t *pool) void h2_io_set_destroy(h2_io_set *sp) { - for (int i = 0; i < sp->list->nelts; ++i) { + int i; + for (i = 0; i < sp->list->nelts; ++i) { h2_io *io = h2_io_IDX(sp->list, i); h2_io_destroy(io); } @@ -76,7 +77,8 @@ h2_io *h2_io_set_get(h2_io_set *sp, int stream_id) h2_io *h2_io_set_get_highest_prio(h2_io_set *set) { h2_io *highest = NULL; - for (int i = 0; i < set->list->nelts; ++i) { + int i; + for (i = 0; i < set->list->nelts; ++i) { h2_io *io = h2_io_IDX(set->list, i); if (!highest /*|| io-prio even higher */ ) { highest = io; @@ -114,7 +116,8 @@ apr_status_t h2_io_set_add(h2_io_set *sp, h2_io *io) h2_io *h2_io_set_remove(h2_io_set *sp, h2_io *io) { - for (int i = 0; i < sp->list->nelts; ++i) { + int i; + for (i = 0; i < sp->list->nelts; ++i) { h2_io *e = h2_io_IDX(sp->list, i); if (e == io) { int n; @@ -135,7 +138,8 @@ h2_io *h2_io_set_remove(h2_io_set *sp, h2_io *io) void h2_io_set_destroy_all(h2_io_set *sp) { - for (int i = 0; i < sp->list->nelts; ++i) { + int i; + for (i = 0; i < sp->list->nelts; ++i) { h2_io *io = h2_io_IDX(sp->list, i); h2_io_destroy(io); } @@ -156,7 +160,8 @@ int h2_io_set_is_empty(h2_io_set *sp) void h2_io_set_iter(h2_io_set *sp, h2_io_set_iter_fn *iter, void *ctx) { - for (int i = 0; i < sp->list->nelts; ++i) { + int i; + for (i = 0; i < sp->list->nelts; ++i) { h2_io *s = h2_io_IDX(sp->list, i); if (!iter(ctx, s)) { break; diff --git a/modules/http2/h2_response.c b/modules/http2/h2_response.c index fc2107cc39d..b902e5d555e 100644 --- a/modules/http2/h2_response.c +++ b/modules/http2/h2_response.c @@ -46,6 +46,7 @@ h2_response *h2_response_create(int stream_id, { apr_table_t *header; h2_response *response = apr_pcalloc(pool, sizeof(h2_response)); + int i; if (response == NULL) { return NULL; } @@ -55,7 +56,7 @@ h2_response *h2_response_create(int stream_id, if (hlines) { header = apr_table_make(pool, hlines->nelts); - for (int i = 0; i < hlines->nelts; ++i) { + for (i = 0; i < hlines->nelts; ++i) { char *hline = ((char **)hlines->elts)[i]; char *sep = strchr(hline, ':'); if (!sep) { diff --git a/modules/http2/h2_stream_set.c b/modules/http2/h2_stream_set.c index 762b507ea0b..d4022c4ac4a 100644 --- a/modules/http2/h2_stream_set.c +++ b/modules/http2/h2_stream_set.c @@ -103,7 +103,8 @@ apr_status_t h2_stream_set_add(h2_stream_set *sp, h2_stream *stream) h2_stream *h2_stream_set_remove(h2_stream_set *sp, h2_stream *stream) { - for (int i = 0; i < sp->list->nelts; ++i) { + int i; + for (i = 0; i < sp->list->nelts; ++i) { h2_stream *s = H2_STREAM_IDX(sp->list, i); if (s == stream) { int n; @@ -137,7 +138,8 @@ h2_stream *h2_stream_set_find(h2_stream_set *sp, h2_stream_set_match_fn match, void *ctx) { h2_stream *s = NULL; - for (int i = 0; !s && i < sp->list->nelts; ++i) { + int i; + for (i = 0; !s && i < sp->list->nelts; ++i) { s = match(ctx, H2_STREAM_IDX(sp->list, i)); } return s; @@ -146,7 +148,8 @@ h2_stream *h2_stream_set_find(h2_stream_set *sp, void h2_stream_set_iter(h2_stream_set *sp, h2_stream_set_iter_fn *iter, void *ctx) { - for (int i = 0; i < sp->list->nelts; ++i) { + int i; + for (i = 0; i < sp->list->nelts; ++i) { h2_stream *s = H2_STREAM_IDX(sp->list, i); if (!iter(ctx, s)) { break; diff --git a/modules/http2/h2_util.c b/modules/http2/h2_util.c index e735996bc6c..65fe4496596 100644 --- a/modules/http2/h2_util.c +++ b/modules/http2/h2_util.c @@ -64,7 +64,8 @@ size_t h2_util_header_print(char *buffer, size_t maxlen, char *h2_strlwr(char *s) { - for (char *p = s; *p; ++p) { + char *p; + for (p = s; *p; ++p) { if (*p >= 'A' && *p <= 'Z') { *p += 'a' - 'A'; } @@ -75,7 +76,8 @@ char *h2_strlwr(char *s) void h2_util_camel_case_header(char *s, size_t len) { size_t start = 1; - for (size_t i = 0; i < len; ++i) { + size_t i; + for (i = 0; i < len; ++i) { if (start) { if (s[i] >= 'a' && s[i] <= 'z') { s[i] -= 'a' - 'A'; @@ -156,12 +158,13 @@ apr_size_t h2_util_base64url_decode(unsigned char **decoded, const char *encoded int h2_util_contains_token(apr_pool_t *pool, const char *s, const char *token) { + char *c; if (s) { if (!apr_strnatcasecmp(s, token)) { /* the simple life */ return 1; } - for (char *c = ap_get_token(pool, &s, 0); c && *c; + for (c = ap_get_token(pool, &s, 0); c && *c; c = *s? ap_get_token(pool, &s, 0) : NULL) { if (!apr_strnatcasecmp(c, token)) { /* seeing the token? */ return 1; @@ -180,10 +183,12 @@ int h2_util_contains_token(apr_pool_t *pool, const char *s, const char *token) const char *h2_util_first_token_match(apr_pool_t *pool, const char *s, const char *tokens[], apr_size_t len) { + char *c; + apr_size_t i; if (s && *s) { - for (char *c = ap_get_token(pool, &s, 0); c && *c; + for (c = ap_get_token(pool, &s, 0); c && *c; c = *s? ap_get_token(pool, &s, 0) : NULL) { - for (apr_size_t i = 0; i < len; ++i) { + for (i = 0; i < len; ++i) { if (!apr_strnatcasecmp(c, tokens[i])) { return tokens[i]; }