You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jc...@apache.org on 2016/11/10 20:53:21 UTC
svn commit: r1769192 - in /httpd/httpd/trunk: modules/http/http_filters.c
modules/http2/h2_from_h1.c modules/metadata/mod_headers.c
modules/session/mod_session.c server/util_cookies.c
Author: jchampion
Date: Thu Nov 10 20:53:21 2016
New Revision: 1769192
URL: http://svn.apache.org/viewvc?rev=1769192&view=rev
Log:
Remove unnecessary apr_table_do() function casts
Function casts can cause hard-to-debug corruption issues if a
declaration is accidentally changed to be incompatible. Luckily, most of
the function casts for apr_table_do() calls are unnecessary. Remove
them, and adjust the signatures for helpers that weren't taking void* as
the first argument.
The remaining helper that requires a cast is http_filter.c's
form_header_field(), which is probably where many of these casts were
copy-pasted from. I have left it as-is: it has other direct callers
besides apr_table_do(), and it's already documented with warnings not to
change the function signature.
Modified:
httpd/httpd/trunk/modules/http/http_filters.c
httpd/httpd/trunk/modules/http2/h2_from_h1.c
httpd/httpd/trunk/modules/metadata/mod_headers.c
httpd/httpd/trunk/modules/session/mod_session.c
httpd/httpd/trunk/server/util_cookies.c
Modified: httpd/httpd/trunk/modules/http/http_filters.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http/http_filters.c?rev=1769192&r1=1769191&r2=1769192&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http/http_filters.c (original)
+++ httpd/httpd/trunk/modules/http/http_filters.c Thu Nov 10 20:53:21 2016
@@ -826,8 +826,7 @@ static void fixup_vary(request_rec *r)
* its comma-separated fieldname values, and then add them to varies
* if not already present in the array.
*/
- apr_table_do((int (*)(void *, const char *, const char *))uniq_field_values,
- (void *) varies, r->headers_out, "Vary", NULL);
+ apr_table_do(uniq_field_values, varies, r->headers_out, "Vary", NULL);
/* If we found any, replace old Vary fields with unique-ified value */
Modified: httpd/httpd/trunk/modules/http2/h2_from_h1.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_from_h1.c?rev=1769192&r1=1769191&r2=1769192&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_from_h1.c (original)
+++ httpd/httpd/trunk/modules/http2/h2_from_h1.c Thu Nov 10 20:53:21 2016
@@ -103,8 +103,7 @@ static void fix_vary(request_rec *r)
* its comma-separated fieldname values, and then add them to varies
* if not already present in the array.
*/
- apr_table_do((int (*)(void *, const char *, const char *))uniq_field_values,
- (void *) varies, r->headers_out, "Vary", NULL);
+ apr_table_do(uniq_field_values, varies, r->headers_out, "Vary", NULL);
/* If we found any, replace old Vary fields with unique-ified value */
@@ -275,8 +274,7 @@ static h2_headers *create_response(h2_ta
set_basic_http_header(headers, r, r->pool);
if (r->status == HTTP_NOT_MODIFIED) {
- apr_table_do((int (*)(void *, const char *, const char *)) copy_header,
- (void *) headers, r->headers_out,
+ apr_table_do(copy_header, headers, r->headers_out,
"ETag",
"Content-Location",
"Expires",
@@ -290,8 +288,7 @@ static h2_headers *create_response(h2_ta
NULL);
}
else {
- apr_table_do((int (*)(void *, const char *, const char *)) copy_header,
- (void *) headers, r->headers_out, NULL);
+ apr_table_do(copy_header, headers, r->headers_out, NULL);
}
return h2_headers_rcreate(r, r->status, headers, r->pool);
Modified: httpd/httpd/trunk/modules/metadata/mod_headers.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/metadata/mod_headers.c?rev=1769192&r1=1769191&r2=1769192&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/metadata/mod_headers.c (original)
+++ httpd/httpd/trunk/modules/metadata/mod_headers.c Thu Nov 10 20:53:21 2016
@@ -666,13 +666,15 @@ static const char *process_regexp(header
return ret;
}
-static int echo_header(echo_do *v, const char *key, const char *val)
+static int echo_header(void *v, const char *key, const char *val)
{
+ edit_do *ed = v;
+
/* If the input header (key) matches the regex, echo it intact to
* r->headers_out.
*/
- if (!ap_regexec(v->hdr->regex, key, 0, NULL, 0)) {
- apr_table_add(v->r->headers_out, key, val);
+ if (!ap_regexec(ed->hdr->regex, key, 0, NULL, 0)) {
+ apr_table_add(ed->r->headers_out, key, val);
}
return 1;
@@ -808,8 +810,7 @@ static int do_headers_fixup(request_rec
case hdr_echo:
v.r = r;
v.hdr = hdr;
- apr_table_do((int (*) (void *, const char *, const char *))
- echo_header, (void *) &v, r->headers_in, NULL);
+ apr_table_do(echo_header, &v, r->headers_in, NULL);
break;
case hdr_edit:
case hdr_edit_r:
Modified: httpd/httpd/trunk/modules/session/mod_session.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/session/mod_session.c?rev=1769192&r1=1769191&r2=1769192&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/session/mod_session.c (original)
+++ httpd/httpd/trunk/modules/session/mod_session.c Thu Nov 10 20:53:21 2016
@@ -311,15 +311,16 @@ static apr_status_t ap_session_set(reque
return APR_SUCCESS;
}
-static int identity_count(int *count, const char *key, const char *val)
+static int identity_count(void *v, const char *key, const char *val)
{
+ int *count = v;
*count += strlen(key) * 3 + strlen(val) * 3 + 1;
return 1;
}
-static int identity_concat(char *buffer, const char *key, const char *val)
+static int identity_concat(void *v, const char *key, const char *val)
{
- char *slider = buffer;
+ char *slider = v;
int length = strlen(slider);
slider += length;
if (length) {
@@ -356,11 +357,9 @@ static apr_status_t session_identity_enc
char *expiry = apr_psprintf(z->pool, "%" APR_INT64_T_FMT, z->expiry);
apr_table_setn(z->entries, SESSION_EXPIRY, expiry);
}
- apr_table_do((int (*) (void *, const char *, const char *))
- identity_count, &length, z->entries, NULL);
+ apr_table_do(identity_count, &length, z->entries, NULL);
buffer = apr_pcalloc(r->pool, length + 1);
- apr_table_do((int (*) (void *, const char *, const char *))
- identity_concat, buffer, z->entries, NULL);
+ apr_table_do(identity_concat, buffer, z->entries, NULL);
z->encoded = buffer;
return OK;
Modified: httpd/httpd/trunk/server/util_cookies.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util_cookies.c?rev=1769192&r1=1769191&r2=1769192&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util_cookies.c (original)
+++ httpd/httpd/trunk/server/util_cookies.c Thu Nov 10 20:53:21 2016
@@ -174,8 +174,9 @@ AP_DECLARE(apr_status_t) ap_cookie_remov
* $path or other attributes following our cookie if present. If we end
* up with an empty cookie, remove the whole header.
*/
-static int extract_cookie_line(ap_cookie_do * v, const char *key, const char *val)
+static int extract_cookie_line(void *varg, const char *key, const char *val)
{
+ ap_cookie_do *v = varg;
char *last1, *last2;
char *cookie = apr_pstrdup(v->r->pool, val);
const char *name = apr_pstrcat(v->r->pool, v->name ? v->name : "", "=", NULL);
@@ -252,8 +253,7 @@ AP_DECLARE(apr_status_t) ap_cookie_read(
v.duplicated = 0;
v.name = name;
- apr_table_do((int (*) (void *, const char *, const char *))
- extract_cookie_line, (void *) &v, r->headers_in,
+ apr_table_do(extract_cookie_line, &v, r->headers_in,
"Cookie", "Cookie2", NULL);
if (v.duplicated) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00011) LOG_PREFIX