Add a new warning to our "warn a lot" list: unused parameters. This means we have to explicitly "use" unuseds, but it can catch bugs. (It caught two coding mistakes so far.)

svn:r6532
This commit is contained in:
Nick Mathewson 2006-06-04 22:42:13 +00:00
parent c4647545a0
commit 853e2d99b6
19 changed files with 66 additions and 10 deletions

View File

@ -604,7 +604,7 @@ else
fi
# Add some more warnings which we use in the cvs version but not in the
# released versions. (Some relevant gcc versions can't handle these.)
#CFLAGS="$CFLAGS -W -Wno-unused-parameter -Wfloat-equal -Wundef -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2 -Winit-self -Wwrite-strings -Waggregate-return -Wmissing-declarations -Wmissing-field-initializers -Wredundant-decls -Winline"
#CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2 -Winit-self -Wwrite-strings -Waggregate-return -Wmissing-declarations -Wmissing-field-initializers -Wredundant-decls -Winline"
# Add these in when you feel like fun.
#CFLAGS="$CFLAGS -Wbad-function-cast -Werror -Wdeclaration-after-statement -Wold-style-definition"

View File

@ -160,6 +160,7 @@ void
tor_munmap_file(const char *memory, size_t size)
{
char *mem = (char*) memory;
(void)size;
tor_free(mem);
}
#endif

View File

@ -1802,6 +1802,8 @@ secret_to_key(char *key_out, size_t key_out_len, const char *secret,
static void
_openssl_locking_cb(int mode, int n, const char *file, int line)
{
(void)file;
(void)line;
if (!_openssl_mutexes)
/* This is not a really good fix for the
* "release-freed-lock-from-separate-thread-on-shutdown" problem, but

View File

@ -950,6 +950,8 @@ clean_name_for_stat(char *name)
return;
name[len-1]='\0';
}
#else
(void)name;
#endif
}

View File

@ -1508,6 +1508,7 @@ choose_good_entry_server(uint8_t purpose, cpath_build_state_t *state)
routerinfo_t *r, *choice;
smartlist_t *excluded;
or_options_t *options = get_options();
(void)purpose; /* not used yet. */
if (state && options->UseEntryGuards) {
return choose_random_entry(state);

View File

@ -605,6 +605,10 @@ circuit_testing_failed(circuit_t *circ, int at_last_hop)
log_info(LD_GENERAL,
"Our testing circuit (to see if your ORPort is reachable) "
"has failed. I'll try again later.");
/* These aren't used yet. */
(void)circ;
(void)at_last_hop;
}
/** The circuit <b>circ</b> has just become open. Take the next

View File

@ -1489,6 +1489,7 @@ static void
option_clear(config_format_t *fmt, or_options_t *options, config_var_t *var)
{
void *lvalue = STRUCT_VAR_P(options, var->var_offset);
(void)fmt; /* unused */
switch (var->type) {
case CONFIG_TYPE_STRING:
tor_free(*(char**)lvalue);
@ -3601,6 +3602,10 @@ static int
or_state_validate(or_state_t *old_state, or_state_t *state,
int from_setconf, char **msg)
{
/* We don't use these; only options do. Still, we need to match that
* signature. */
(void) from_setconf;
(void) old_state;
if (entry_guards_parse_state(state, 0, msg)<0) {
return -1;
}

View File

@ -1107,6 +1107,9 @@ connection_bucket_refill(struct timeval *now)
connection_t *conn;
connection_t **carray;
or_options_t *options = get_options();
/* Not used, but it should be! We might have rolled over more than one
* second! XXXX */
(void) now;
/* refill the global buckets */
if (global_read_bucket < (int)options->BandwidthBurst) {
@ -2018,6 +2021,7 @@ connection_reached_eof(connection_t *conn)
void
assert_connection_ok(connection_t *conn, time_t now)
{
(void) now; /* XXXX unused. */
tor_assert(conn);
tor_assert(conn->magic == CONNECTION_MAGIC);
tor_assert(conn->type >= _CONN_TYPE_MIN);

View File

@ -790,6 +790,7 @@ handle_control_getconf(connection_t *conn, uint32_t body_len, const char *body)
int v0 = STATE_IS_V0(conn->state);
questions = smartlist_create();
(void) body_len; /* body is null-terminated; so we can ignore len. */
if (v0) {
smartlist_split_string(questions, body, "\n",
SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
@ -1077,6 +1078,8 @@ static int
handle_control_saveconf(connection_t *conn, uint32_t len,
const char *body)
{
(void) len;
(void) body;
if (options_save_current()<0) {
if (STATE_IS_V0(conn->state))
send_control0_error(conn, ERR_INTERNAL,
@ -1157,6 +1160,8 @@ handle_control_mapaddress(connection_t *conn, uint32_t len, const char *body)
char *r;
size_t sz;
int v0 = STATE_IS_V0(conn->state);
(void) len; /* body is null-terminated, so it's safe to ignore the length. */
lines = smartlist_create();
elts = smartlist_create();
reply = smartlist_create();
@ -1542,6 +1547,7 @@ handle_control_getinfo(connection_t *conn, uint32_t len, const char *body)
char *msg = NULL, *ans = NULL;
size_t msg_len;
int v0 = STATE_IS_V0(conn->state);
(void) len; /* body is null-terminated, so it's safe to ignore the length. */
questions = smartlist_create();
if (v0)
@ -1803,6 +1809,7 @@ handle_control_setpurpose(connection_t *conn, int for_circuits,
routerinfo_t *ri = NULL;
uint8_t new_purpose;
smartlist_t *args = smartlist_create();
(void) len; /* body is null-terminated, so it's safe to ignore the length. */
smartlist_split_string(args, body, " ",
SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
if (smartlist_len(args)<2) {
@ -2779,6 +2786,7 @@ void
control_event_logmsg(int severity, unsigned int domain, const char *msg)
{
int oldlog, event;
(void) domain;
if (disable_log_messages)
return;

View File

@ -324,6 +324,8 @@ connection_dir_download_routerdesc_failed(connection_t *conn)
/* Try again. No need to increment the failure count for routerdescs, since
* it's not their fault.*/
/* update_router_descriptor_downloads(time(NULL)); */
(void) conn;
/* XXXX Why did the above get commented out? -NM */
}
/** Helper for directory_initiate_command_(router|trusted_dir): send the
@ -1331,7 +1333,8 @@ directory_dump_request_log(void)
static void
note_request(const char *key, size_t bytes)
{
return;
(void)key;
(void)bytes;
}
char *
@ -1355,6 +1358,9 @@ directory_handle_command_get(connection_t *conn, char *headers,
char *url = NULL;
char tmp[8192];
char date[RFC1123_TIME_LEN+1];
/* We ignore the body of a GET request. */
(void)body;
(void)body_len;
log_debug(LD_DIRSERV,"Received GET command.");

View File

@ -1633,6 +1633,7 @@ dirserv_orconn_tls_done(const char *address,
tor_assert(address);
tor_assert(digest_rcvd);
tor_assert(nickname_rcvd);
(void) as_advertised; // XXXX This should really be implemented. -NM
// XXXXNM We should really have a better solution here than dropping
// XXXXNM whole routers; otherwise, they come back way too easily.

View File

@ -1057,18 +1057,21 @@ dnsworkers_rotate(void)
int
connection_dns_finished_flushing(connection_t *conn)
{
(void)conn;
tor_assert(0);
return 0;
}
int
connection_dns_process_inbuf(connection_t *conn)
{
(void)conn;
tor_assert(0);
return 0;
}
int
connection_dns_reached_eof(connection_t *conn)
{
(void)conn;
tor_assert(0);
return 0;
}

View File

@ -397,6 +397,8 @@ static void
conn_read_callback(int fd, short event, void *_conn)
{
connection_t *conn = _conn;
(void)fd;
(void)event;
log_debug(LD_NET,"socket %d wants to read.",conn->s);
@ -427,6 +429,8 @@ static void
conn_write_callback(int fd, short events, void *_conn)
{
connection_t *conn = _conn;
(void)fd;
(void)events;
LOG_FN_CONN(conn, (LOG_DEBUG, LD_NET, "socket %d wants to write.",conn->s));
@ -534,6 +538,7 @@ void
directory_all_unreachable(time_t now)
{
connection_t *conn;
(void)now;
stats_n_seconds_working=0; /* reset it */
@ -828,7 +833,7 @@ run_scheduled_events(time_t now)
}
mark_my_descriptor_dirty_if_older_than(
now - FORCE_REGENERATE_DESCRIPTOR_INTERVAL);
consider_publishable_server(now, 0);
consider_publishable_server(0);
/* also, check religiously for reachability, if it's within the first
* 20 minutes of our uptime. */
if (server_mode(options) &&
@ -925,6 +930,9 @@ second_elapsed_callback(int fd, short event, void *args)
size_t bytes_read;
int seconds_elapsed;
or_options_t *options = get_options();
(void)fd;
(void)event;
(void)args;
if (!timeout_event) {
timeout_event = tor_malloc_zero(sizeof(struct event));
evtimer_set(timeout_event, second_elapsed_callback, NULL);
@ -1227,6 +1235,8 @@ static void
signal_callback(int fd, short events, void *arg)
{
uintptr_t sig = (uintptr_t)arg;
(void)fd;
(void)events;
switch (sig)
{
case SIGTERM:

View File

@ -2227,7 +2227,7 @@ void consider_testing_reachability(void);
void router_orport_found_reachable(void);
void router_dirport_found_reachable(void);
void server_has_changed_ip(void);
void consider_publishable_server(time_t now, int force);
void consider_publishable_server(int force);
int authdir_mode(or_options_t *options);
int clique_mode(or_options_t *options);

View File

@ -654,6 +654,7 @@ connection_edge_process_end_not_open(
struct in_addr in;
routerinfo_t *exitrouter;
int reason = *(cell->payload+RELAY_HEADER_SIZE);
(void) layer_hint; /* unused */
if (rh->length > 0 && edge_reason_is_retriable(reason) &&
conn->type == CONN_TYPE_AP) {

View File

@ -183,6 +183,7 @@ rend_client_introduction_acked(circuit_t *circ,
const char *request, size_t request_len)
{
circuit_t *rendcirc;
(void) request; // XXXX Use this.
if (circ->purpose != CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT) {
log_warn(LD_PROTOCOL,
@ -342,6 +343,8 @@ int
rend_client_rendezvous_acked(circuit_t *circ, const char *request,
size_t request_len)
{
(void) request;
(void) request_len;
/* we just got an ack for our establish-rendezvous. switch purposes. */
if (circ->purpose != CIRCUIT_PURPOSE_C_ESTABLISH_REND) {
log_warn(LD_PROTOCOL,"Got a rendezvous ack when we weren't expecting one. "

View File

@ -769,6 +769,8 @@ rend_service_intro_established(circuit_t *circuit, const char *request,
size_t request_len)
{
rend_service_t *service;
(void) request;
(void) request_len;
if (circuit->purpose != CIRCUIT_PURPOSE_S_ESTABLISH_INTRO) {
log_warn(LD_PROTOCOL,

View File

@ -480,7 +480,7 @@ router_orport_found_reachable(void)
" Publishing server descriptor." : "");
can_reach_or_port = 1;
mark_my_descriptor_dirty();
consider_publishable_server(time(NULL), 1);
consider_publishable_server(1);
}
}
@ -569,7 +569,7 @@ proxy_mode(or_options_t *options)
* - We have the AuthoritativeDirectory option set.
*/
static int
decide_if_publishable_server(time_t now)
decide_if_publishable_server(void)
{
or_options_t *options = get_options();
@ -593,7 +593,7 @@ decide_if_publishable_server(time_t now)
* determine what IP address and ports to test.
*/
void
consider_publishable_server(time_t now, int force)
consider_publishable_server(int force)
{
int rebuilt;
@ -601,7 +601,7 @@ consider_publishable_server(time_t now, int force)
return;
rebuilt = router_rebuild_descriptor(0);
if (decide_if_publishable_server(now)) {
if (decide_if_publishable_server()) {
set_server_advertised(1);
if (rebuilt == 0)
router_upload_dir_desc_to_dirservers(force);
@ -951,6 +951,7 @@ check_descriptor_ipaddress_changed(time_t now)
{
uint32_t prev, cur;
or_options_t *options = get_options();
(void) now;
if (!desc_routerinfo)
return;

View File

@ -2528,9 +2528,9 @@ update_networkstatus_downloads(time_t now)
{
or_options_t *options = get_options();
if (options->DirPort)
update_networkstatus_cache_downloads(time(NULL));
update_networkstatus_cache_downloads(now);
else
update_networkstatus_client_downloads(time(NULL));
update_networkstatus_client_downloads(now);
}
/** Return 1 if all running sufficiently-stable routers will reject
@ -2685,6 +2685,7 @@ compute_recommended_versions(time_t now, int client)
smartlist_t *combined, *recommended;
int n_versioning;
char *result;
(void) now; /* right now, we consider *all* ors. */
if (!networkstatus_list)
return tor_strdup("<none>");
@ -3508,6 +3509,7 @@ update_router_descriptor_cache_downloads(time_t now)
int i, j, n;
int n_download;
or_options_t *options = get_options();
(void) now;
if (!options->DirPort) {
log_warn(LD_BUG, "Called update_router_descriptor_cache_downloads() "