mirror of
https://github.com/apache/httpd.git
synced 2025-08-08 15:02:10 +03:00
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. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1769192 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -826,8 +826,7 @@ static void fixup_vary(request_rec *r)
|
|||||||
* its comma-separated fieldname values, and then add them to varies
|
* its comma-separated fieldname values, and then add them to varies
|
||||||
* if not already present in the array.
|
* if not already present in the array.
|
||||||
*/
|
*/
|
||||||
apr_table_do((int (*)(void *, const char *, const char *))uniq_field_values,
|
apr_table_do(uniq_field_values, varies, r->headers_out, "Vary", NULL);
|
||||||
(void *) varies, r->headers_out, "Vary", NULL);
|
|
||||||
|
|
||||||
/* If we found any, replace old Vary fields with unique-ified value */
|
/* If we found any, replace old Vary fields with unique-ified value */
|
||||||
|
|
||||||
|
@@ -103,8 +103,7 @@ static void fix_vary(request_rec *r)
|
|||||||
* its comma-separated fieldname values, and then add them to varies
|
* its comma-separated fieldname values, and then add them to varies
|
||||||
* if not already present in the array.
|
* if not already present in the array.
|
||||||
*/
|
*/
|
||||||
apr_table_do((int (*)(void *, const char *, const char *))uniq_field_values,
|
apr_table_do(uniq_field_values, varies, r->headers_out, "Vary", NULL);
|
||||||
(void *) varies, r->headers_out, "Vary", NULL);
|
|
||||||
|
|
||||||
/* If we found any, replace old Vary fields with unique-ified value */
|
/* If we found any, replace old Vary fields with unique-ified value */
|
||||||
|
|
||||||
@@ -275,8 +274,7 @@ static h2_headers *create_response(h2_task *task, request_rec *r)
|
|||||||
|
|
||||||
set_basic_http_header(headers, r, r->pool);
|
set_basic_http_header(headers, r, r->pool);
|
||||||
if (r->status == HTTP_NOT_MODIFIED) {
|
if (r->status == HTTP_NOT_MODIFIED) {
|
||||||
apr_table_do((int (*)(void *, const char *, const char *)) copy_header,
|
apr_table_do(copy_header, headers, r->headers_out,
|
||||||
(void *) headers, r->headers_out,
|
|
||||||
"ETag",
|
"ETag",
|
||||||
"Content-Location",
|
"Content-Location",
|
||||||
"Expires",
|
"Expires",
|
||||||
@@ -290,8 +288,7 @@ static h2_headers *create_response(h2_task *task, request_rec *r)
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
apr_table_do((int (*)(void *, const char *, const char *)) copy_header,
|
apr_table_do(copy_header, headers, r->headers_out, NULL);
|
||||||
(void *) headers, r->headers_out, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return h2_headers_rcreate(r, r->status, headers, r->pool);
|
return h2_headers_rcreate(r, r->status, headers, r->pool);
|
||||||
|
@@ -666,13 +666,15 @@ static const char *process_regexp(header_entry *hdr, const char *value,
|
|||||||
return ret;
|
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
|
/* If the input header (key) matches the regex, echo it intact to
|
||||||
* r->headers_out.
|
* r->headers_out.
|
||||||
*/
|
*/
|
||||||
if (!ap_regexec(v->hdr->regex, key, 0, NULL, 0)) {
|
if (!ap_regexec(ed->hdr->regex, key, 0, NULL, 0)) {
|
||||||
apr_table_add(v->r->headers_out, key, val);
|
apr_table_add(ed->r->headers_out, key, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@@ -808,8 +810,7 @@ static int do_headers_fixup(request_rec *r, apr_table_t *headers,
|
|||||||
case hdr_echo:
|
case hdr_echo:
|
||||||
v.r = r;
|
v.r = r;
|
||||||
v.hdr = hdr;
|
v.hdr = hdr;
|
||||||
apr_table_do((int (*) (void *, const char *, const char *))
|
apr_table_do(echo_header, &v, r->headers_in, NULL);
|
||||||
echo_header, (void *) &v, r->headers_in, NULL);
|
|
||||||
break;
|
break;
|
||||||
case hdr_edit:
|
case hdr_edit:
|
||||||
case hdr_edit_r:
|
case hdr_edit_r:
|
||||||
|
@@ -311,15 +311,16 @@ static apr_status_t ap_session_set(request_rec * r, session_rec * z,
|
|||||||
return APR_SUCCESS;
|
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;
|
*count += strlen(key) * 3 + strlen(val) * 3 + 1;
|
||||||
return 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);
|
int length = strlen(slider);
|
||||||
slider += length;
|
slider += length;
|
||||||
if (length) {
|
if (length) {
|
||||||
@@ -356,11 +357,9 @@ static apr_status_t session_identity_encode(request_rec * r, session_rec * z)
|
|||||||
char *expiry = apr_psprintf(z->pool, "%" APR_INT64_T_FMT, z->expiry);
|
char *expiry = apr_psprintf(z->pool, "%" APR_INT64_T_FMT, z->expiry);
|
||||||
apr_table_setn(z->entries, SESSION_EXPIRY, expiry);
|
apr_table_setn(z->entries, SESSION_EXPIRY, expiry);
|
||||||
}
|
}
|
||||||
apr_table_do((int (*) (void *, const char *, const char *))
|
apr_table_do(identity_count, &length, z->entries, NULL);
|
||||||
identity_count, &length, z->entries, NULL);
|
|
||||||
buffer = apr_pcalloc(r->pool, length + 1);
|
buffer = apr_pcalloc(r->pool, length + 1);
|
||||||
apr_table_do((int (*) (void *, const char *, const char *))
|
apr_table_do(identity_concat, buffer, z->entries, NULL);
|
||||||
identity_concat, buffer, z->entries, NULL);
|
|
||||||
z->encoded = buffer;
|
z->encoded = buffer;
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
|
@@ -174,8 +174,9 @@ AP_DECLARE(apr_status_t) ap_cookie_remove2(request_rec * r, const char *name2, c
|
|||||||
* $path or other attributes following our cookie if present. If we end
|
* $path or other attributes following our cookie if present. If we end
|
||||||
* up with an empty cookie, remove the whole header.
|
* 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 *last1, *last2;
|
||||||
char *cookie = apr_pstrdup(v->r->pool, val);
|
char *cookie = apr_pstrdup(v->r->pool, val);
|
||||||
const char *name = apr_pstrcat(v->r->pool, v->name ? v->name : "", "=", NULL);
|
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(request_rec * r, const char *name, const
|
|||||||
v.duplicated = 0;
|
v.duplicated = 0;
|
||||||
v.name = name;
|
v.name = name;
|
||||||
|
|
||||||
apr_table_do((int (*) (void *, const char *, const char *))
|
apr_table_do(extract_cookie_line, &v, r->headers_in,
|
||||||
extract_cookie_line, (void *) &v, r->headers_in,
|
|
||||||
"Cookie", "Cookie2", NULL);
|
"Cookie", "Cookie2", NULL);
|
||||||
if (v.duplicated) {
|
if (v.duplicated) {
|
||||||
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00011) LOG_PREFIX
|
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00011) LOG_PREFIX
|
||||||
|
Reference in New Issue
Block a user