Skip to content

Commit b488d21

Browse files
author
Stefan Fritsch
committed
Various code cleanup to avoid compiler, cppcheck, or clang warnings:
modules/debugging/mod_firehose.c: Make some internal functions static (to do: logs_cleanup() is unused) modules/filters/mod_charset_lite.c: Remove dead assignments modules/filters/mod_include.c: likewise modules/metadata/mod_usertrack.c: likewise modules/proxy/mod_proxy_ftp.c: likewise modules/ssl/ssl_engine_pphrase.c: likewise modules/proxy/mod_proxy_balancer.c: likewise; Remove NULL check that can never happen modules/proxy/proxy_util.c: Axe NULL-check that can never happen and if it would, it would just mask another bug os/unix/unixd.c: likewise modules/http/http_filters.c: Remove sub-condition that is always true modules/lua/mod_lua.c: Add default cases to switch statements modules/generators/mod_autoindex.c: Unsigned value can never be < 0 server/util_expr_eval.c: Fix compiler warnings with VC and on OS2 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1220493 13f79535-47bb-0310-9956-ffa450edef68
1 parent 25c3f9a commit b488d21

13 files changed

Lines changed: 22 additions & 25 deletions

File tree

modules/debugging/mod_firehose.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,21 +104,21 @@ typedef struct firehose_ctx_t
104104
#define BODY_LEN (PIPE_BUF - HEADER_LEN - 2)
105105
#define HEADER_FMT "%" APR_UINT64_T_HEX_FMT " %" APR_UINT64_T_HEX_FMT " %c %s %" APR_UINT64_T_HEX_FMT CRLF
106106

107-
apr_status_t logs_cleanup(void *dummy)
107+
static apr_status_t logs_cleanup(void *dummy)
108108
{
109109
apr_file_t *file = (apr_file_t *) dummy;
110110
apr_file_close(file);
111111
return APR_SUCCESS;
112112
}
113113

114-
apr_status_t filter_output_cleanup(void *dummy)
114+
static apr_status_t filter_output_cleanup(void *dummy)
115115
{
116116
ap_filter_t *f = (ap_filter_t *) dummy;
117117
ap_remove_output_filter(f);
118118
return APR_SUCCESS;
119119
}
120120

121-
apr_status_t filter_input_cleanup(void *dummy)
121+
static apr_status_t filter_input_cleanup(void *dummy)
122122
{
123123
ap_filter_t *f = (ap_filter_t *) dummy;
124124
ap_remove_input_filter(f);
@@ -128,7 +128,7 @@ apr_status_t filter_input_cleanup(void *dummy)
128128
/**
129129
* Add the terminating empty fragment to indicate end-of-connection.
130130
*/
131-
apr_status_t pumpit_cleanup(void *dummy)
131+
static apr_status_t pumpit_cleanup(void *dummy)
132132
{
133133
firehose_ctx_t *ctx = (firehose_ctx_t *) dummy;
134134
apr_status_t rv;

modules/filters/mod_charset_lite.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -864,11 +864,9 @@ static apr_status_t xlate_out_filter(ap_filter_t *f, apr_bucket_brigade *bb)
864864
consumed_bucket = NULL;
865865
}
866866
if (dptr == APR_BRIGADE_SENTINEL(bb)) {
867-
done = 1;
868867
break;
869868
}
870869
if (APR_BUCKET_IS_EOS(dptr)) {
871-
done = 1;
872870
cur_len = -1; /* XXX yuck, but that tells us to send
873871
* eos down; when we minimize our bb construction
874872
* we'll fix this crap */
@@ -894,7 +892,6 @@ static apr_status_t xlate_out_filter(ap_filter_t *f, apr_bucket_brigade *bb)
894892
}
895893
rv = apr_bucket_read(dptr, &cur_str, &cur_len, APR_BLOCK_READ);
896894
if (rv != APR_SUCCESS) {
897-
done = 1;
898895
ctx->ees = EES_BUCKET_READ;
899896
break;
900897
}

modules/filters/mod_include.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3809,7 +3809,6 @@ static int includes_setup(ap_filter_t *f)
38093809
static apr_status_t includes_filter(ap_filter_t *f, apr_bucket_brigade *b)
38103810
{
38113811
request_rec *r = f->r;
3812-
include_ctx_t *ctx = f->ctx;
38133812
request_rec *parent;
38143813
include_dir_config *conf = ap_get_module_config(r->per_dir_config,
38153814
&include_module);
@@ -3827,6 +3826,7 @@ static apr_status_t includes_filter(ap_filter_t *f, apr_bucket_brigade *b)
38273826

38283827
if (!f->ctx) {
38293828
struct ssi_internal_ctx *intern;
3829+
include_ctx_t *ctx;
38303830

38313831
/* create context for this filter */
38323832
f->ctx = ctx = apr_palloc(r->pool, sizeof(*ctx));

modules/generators/mod_autoindex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ static char *find_title(request_rec *r)
12091209
}
12101210
n = sizeof(char) * (MAX_STRING_LEN - 1);
12111211
apr_file_read(thefile, titlebuf, &n);
1212-
if (n <= 0) {
1212+
if (n == 0) {
12131213
apr_file_close(thefile);
12141214
return NULL;
12151215
}

modules/http/http_filters.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ static long get_chunk_size(char *b)
631631
chunkbits -= 4;
632632
++b;
633633
}
634-
if (apr_isxdigit(*b) && (chunkbits <= 0)) {
634+
if (apr_isxdigit(*b)) {
635635
/* overflow */
636636
return -1;
637637
}

modules/lua/mod_lua.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ static int lua_handler(request_rec *r)
131131
pool = apr_thread_pool_get(r->connection->current_thread);
132132
break;
133133
#endif
134+
default:
135+
ap_assert(0);
134136
}
135137

136138
L = ap_lua_get_lua_state(pool,
@@ -225,6 +227,8 @@ static int lua_request_rec_hook_harness(request_rec *r, const char *name, int ap
225227
pool = apr_thread_pool_get(r->connection->current_thread);
226228
break;
227229
#endif
230+
default:
231+
ap_assert(0);
228232
}
229233

230234
L = ap_lua_get_lua_state(pool, spec);

modules/metadata/mod_usertrack.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,6 @@ static const char *set_cookie_exp(cmd_parms *parms, void *dummy,
326326
if (!word[0])
327327
return "bad expires code, missing <type>";
328328

329-
factor = 0;
330329
if (!strncasecmp(word, "years", 1))
331330
factor = 60 * 60 * 24 * 365;
332331
else if (!strncasecmp(word, "months", 2))

modules/proxy/mod_proxy_balancer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static proxy_worker *find_route_worker(proxy_balancer *balancer,
217217
if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(worker) : PROXY_WORKER_IS_STANDBY(worker)) )
218218
continue;
219219
if (*(worker->s->route) && strcmp(worker->s->route, route) == 0) {
220-
if (worker && PROXY_WORKER_IS_USABLE(worker)) {
220+
if (PROXY_WORKER_IS_USABLE(worker)) {
221221
return worker;
222222
} else {
223223
/*
@@ -693,7 +693,7 @@ static int balancer_post_config(apr_pool_t *pconf, apr_pool_t *plog,
693693
{
694694
apr_status_t rv;
695695
void *sconf = s->module_config;
696-
proxy_server_conf *conf = (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
696+
proxy_server_conf *conf;
697697
ap_slotmem_instance_t *new = NULL;
698698
apr_time_t tstamp;
699699

modules/proxy/mod_proxy_ftp.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,7 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
13271327
break;
13281328
*strp = '\0';
13291329

1330-
len = decodeenc(path); /* Note! This decodes a %2f -> "/" */
1330+
decodeenc(path); /* Note! This decodes a %2f -> "/" */
13311331

13321332
if (strchr(path, '/')) { /* are there now any '/' characters? */
13331333
return ftp_proxyerror(r, backend, HTTP_BAD_REQUEST,
@@ -2050,7 +2050,7 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
20502050
}
20512051

20522052
/* Retrieve the final response for the RETR or LIST commands */
2053-
rc = proxy_ftp_command(NULL, r, origin, bb, &ftpmessage);
2053+
proxy_ftp_command(NULL, r, origin, bb, &ftpmessage);
20542054
apr_brigade_cleanup(bb);
20552055

20562056
/*
@@ -2061,8 +2061,7 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
20612061
*/
20622062

20632063
/* finish */
2064-
rc = proxy_ftp_command("QUIT" CRLF,
2065-
r, origin, bb, &ftpmessage);
2064+
proxy_ftp_command("QUIT" CRLF, r, origin, bb, &ftpmessage);
20662065
/* responses: 221, 500 */
20672066
/* 221 Service closing control connection. */
20682067
/* 500 Syntax error, command unrecognized. */

modules/proxy/proxy_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ PROXY_DECLARE(int) ap_proxy_checkproxyblock(request_rec *r, proxy_server_conf *c
768768
ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
769769
"checking remote machine [%s] against [%s]",
770770
uri_addr->hostname, npent[j].name);
771-
if ((npent[j].name && ap_strstr_c(uri_addr->hostname, npent[j].name))
771+
if (ap_strstr_c(uri_addr->hostname, npent[j].name)
772772
|| npent[j].name[0] == '*') {
773773
ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, APLOGNO(00916)
774774
"connect to remote machine %s blocked: name %s "

0 commit comments

Comments
 (0)