Fix verbose compiler warnings, including one in routerlist.c that would have been an actual error. Normalize whitespace. Enforce convention that "address" is a hostname and "addr" is an IPv4 address.

svn:r5190
This commit is contained in:
Nick Mathewson 2005-10-05 02:06:36 +00:00
parent 0924094042
commit 8434595584
7 changed files with 26 additions and 26 deletions

View File

@ -518,7 +518,7 @@ CFLAGS="$CFLAGS -Wall -g -O2"
# released versions. (Some relevant gcc versions can't handle these.) # 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 -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"
# Add these in when you feel like fun. # Add these in when you feel like fun.
#CFLAGS="$CFLAGS -Wbad-function-cast -Werror -Wdeclaration-after-statement -Wold-style-definitions" #CFLAGS="$CFLAGS -Wbad-function-cast -Werror -Wdeclaration-after-statement -Wold-style-definition"
echo "confdir: $CONFDIR" echo "confdir: $CONFDIR"

View File

@ -499,16 +499,16 @@ addressmap_virtaddress_ent_free(void *_ent)
/** Free storage held by a virtaddress_entry_t* entry in <b>ent</b> */ /** Free storage held by a virtaddress_entry_t* entry in <b>ent</b> */
static void static void
addressmap_virtaddress_remove(const char *addr, addressmap_entry_t *ent) addressmap_virtaddress_remove(const char *address, addressmap_entry_t *ent)
{ {
if (ent && ent->new_address && address_is_in_virtual_range(ent->new_address)) { if (ent && ent->new_address && address_is_in_virtual_range(ent->new_address)) {
virtaddress_entry_t *ve = virtaddress_entry_t *ve =
strmap_get(virtaddress_reversemap, ent->new_address); strmap_get(virtaddress_reversemap, ent->new_address);
/*log_fn(LOG_NOTICE,"remove reverse mapping for %s",ent->new_address);*/ /*log_fn(LOG_NOTICE,"remove reverse mapping for %s",ent->new_address);*/
if (ve) { if (ve) {
if (!strcmp(addr, ve->ipv4_address)) if (!strcmp(address, ve->ipv4_address))
tor_free(ve->ipv4_address); tor_free(ve->ipv4_address);
if (!strcmp(addr, ve->hostname_address)) if (!strcmp(address, ve->hostname_address))
tor_free(ve->hostname_address); tor_free(ve->hostname_address);
if (!ve->ipv4_address && !ve->hostname_address) { if (!ve->ipv4_address && !ve->hostname_address) {
tor_free(ve); tor_free(ve);
@ -520,9 +520,9 @@ addressmap_virtaddress_remove(const char *addr, addressmap_entry_t *ent)
/* DOCDOC */ /* DOCDOC */
static void static void
addressmap_ent_remove(const char *addr, addressmap_entry_t *ent) addressmap_ent_remove(const char *address, addressmap_entry_t *ent)
{ {
addressmap_virtaddress_remove(addr, ent); addressmap_virtaddress_remove(address, ent);
addressmap_ent_free(ent); addressmap_ent_free(ent);
} }
@ -735,15 +735,15 @@ client_dns_set_addressmap(const char *address, uint32_t val, const char *exitnam
* client_dns_get_unused_address. * client_dns_get_unused_address.
**/ **/
int int
address_is_in_virtual_range(const char *addr) address_is_in_virtual_range(const char *address)
{ {
struct in_addr in; struct in_addr in;
tor_assert(addr); tor_assert(address);
if (!strcasecmpend(addr, ".virtual")) { if (!strcasecmpend(address, ".virtual")) {
return 1; return 1;
} else if (tor_inet_aton(addr, &in)) { } else if (tor_inet_aton(address, &in)) {
uint32_t a = ntohl(in.s_addr); uint32_t addr = ntohl(in.s_addr);
if (a >= MIN_UNUSED_IPV4 && a <= MAX_UNUSED_IPV4) if (addr >= MIN_UNUSED_IPV4 && addr <= MAX_UNUSED_IPV4)
return 1; return 1;
} }
return 0; return 0;

View File

@ -1120,20 +1120,20 @@ handle_control_mapaddress(connection_t *conn, uint32_t len, const char *body)
} else if (!is_plausible_address(to)) { } else if (!is_plausible_address(to)) {
log_fn(LOG_WARN,"Skipping invalid argument '%s' in MapAddress msg",to); log_fn(LOG_WARN,"Skipping invalid argument '%s' in MapAddress msg",to);
} else if (!strcmp(from, ".") || !strcmp(from, "0.0.0.0")) { } else if (!strcmp(from, ".") || !strcmp(from, "0.0.0.0")) {
const char *addr = addressmap_register_virtual_address( const char *address = addressmap_register_virtual_address(
!strcmp(from,".") ? RESOLVED_TYPE_HOSTNAME : RESOLVED_TYPE_IPV4, !strcmp(from,".") ? RESOLVED_TYPE_HOSTNAME : RESOLVED_TYPE_IPV4,
tor_strdup(to)); tor_strdup(to));
if (!addr) { if (!address) {
log_fn(LOG_WARN, log_fn(LOG_WARN,
"Unable to allocate address for '%s' in MapAddress msg", "Unable to allocate address for '%s' in MapAddress msg",
safe_str(line)); safe_str(line));
} else { } else {
size_t anslen = strlen(addr)+strlen(to)+8; size_t anslen = strlen(address)+strlen(to)+8;
char *ans = tor_malloc(anslen); char *ans = tor_malloc(anslen);
if (v0) if (v0)
tor_snprintf(ans, anslen, "%s %s", addr, to); tor_snprintf(ans, anslen, "%s %s", address, to);
else else
tor_snprintf(ans, anslen, "250-%s=%s", addr, to); tor_snprintf(ans, anslen, "250-%s=%s", address, to);
smartlist_add(reply, ans); smartlist_add(reply, ans);
} }
} else { } else {
@ -1677,7 +1677,6 @@ handle_control_attachstream(connection_t *conn, uint32_t len,
return 0; return 0;
} }
/** Callled when we get a POSTDESCRIPTORT message. Try to learn the provided /** Callled when we get a POSTDESCRIPTORT message. Try to learn the provided
* descriptor, and report succcess or failure. */ * descriptor, and report succcess or failure. */
static int static int

View File

@ -1983,3 +1983,4 @@ tor_main(int argc, char *argv[])
tor_cleanup(); tor_cleanup();
return -1; return -1;
} }

View File

@ -2140,7 +2140,7 @@ int router_exit_policy_all_routers_reject(uint32_t addr, uint16_t port,
int router_exit_policy_rejects_all(routerinfo_t *router); int router_exit_policy_rejects_all(routerinfo_t *router);
void add_trusted_dir_server(const char *nickname, void add_trusted_dir_server(const char *nickname,
const char *addr, uint16_t port, const char *address, uint16_t port,
const char *digest, int supports_v1); const char *digest, int supports_v1);
void clear_trusted_dir_servers(void); void clear_trusted_dir_servers(void);
networkstatus_t *networkstatus_get_by_digest(const char *digest); networkstatus_t *networkstatus_get_by_digest(const char *digest);

View File

@ -18,7 +18,7 @@ static circuit_t *find_intro_circuit(routerinfo_t *router, const char *pk_digest
typedef struct rend_service_port_config_t { typedef struct rend_service_port_config_t {
uint16_t virtual_port; uint16_t virtual_port;
uint16_t real_port; uint16_t real_port;
uint32_t real_address; uint32_t real_addr;
} rend_service_port_config_t; } rend_service_port_config_t;
/** Try to maintain this many intro points per service if possible. */ /** Try to maintain this many intro points per service if possible. */
@ -128,7 +128,7 @@ add_service(rend_service_t *service)
for (i = 0; i < smartlist_len(service->ports); ++i) { for (i = 0; i < smartlist_len(service->ports); ++i) {
char addrbuf[INET_NTOA_BUF_LEN]; char addrbuf[INET_NTOA_BUF_LEN];
p = smartlist_get(service->ports, i); p = smartlist_get(service->ports, i);
addr.s_addr = htonl(p->real_address); addr.s_addr = htonl(p->real_addr);
tor_inet_ntoa(&addr, addrbuf, sizeof(addrbuf)); tor_inet_ntoa(&addr, addrbuf, sizeof(addrbuf));
log_fn(LOG_DEBUG,"Service maps port %d to %s:%d", log_fn(LOG_DEBUG,"Service maps port %d to %s:%d",
p->virtual_port, addrbuf, p->real_port); p->virtual_port, addrbuf, p->real_port);
@ -191,7 +191,7 @@ parse_port_config(const char *string)
result = tor_malloc(sizeof(rend_service_port_config_t)); result = tor_malloc(sizeof(rend_service_port_config_t));
result->virtual_port = virtport; result->virtual_port = virtport;
result->real_port = realport; result->real_port = realport;
result->real_address = addr; result->real_addr = addr;
err: err:
SMARTLIST_FOREACH(sl, char *, c, tor_free(c)); SMARTLIST_FOREACH(sl, char *, c, tor_free(c));
smartlist_free(sl); smartlist_free(sl);
@ -1094,7 +1094,7 @@ rend_service_set_connection_addr_port(connection_t *conn, circuit_t *circ)
for (i = 0; i < smartlist_len(service->ports); ++i) { for (i = 0; i < smartlist_len(service->ports); ++i) {
p = smartlist_get(service->ports, i); p = smartlist_get(service->ports, i);
if (conn->port == p->virtual_port) { if (conn->port == p->virtual_port) {
conn->addr = p->real_address; conn->addr = p->real_addr;
conn->port = p->real_port; conn->port = p->real_port;
return 0; return 0;
} }

View File

@ -1317,8 +1317,8 @@ int
router_load_single_router(const char *s, const char **msg) router_load_single_router(const char *s, const char **msg)
{ {
routerinfo_t *ri; routerinfo_t *ri;
tor_assert(msg);
smartlist_t *lst; smartlist_t *lst;
tor_assert(msg);
*msg = NULL; *msg = NULL;
if (!(ri = router_parse_entry_from_string(s, NULL))) { if (!(ri = router_parse_entry_from_string(s, NULL))) {
@ -2406,8 +2406,8 @@ routerstatus_list_update_from_networkstatus(time_t now)
const char *d = strmap_get_lc(name_map, the_name); const char *d = strmap_get_lc(name_map, the_name);
if (d && d != conflict) if (d && d != conflict)
rs_out->status.is_named = 1; rs_out->status.is_named = 1;
if (smartlist_string_isin(warned_conflicts, rs->nickname)) if (smartlist_string_isin(warned_conflicts, rs_out->status.nickname))
smartlist_string_remove(warned_conflicts, rs->nickname); smartlist_string_remove(warned_conflicts, rs_out->status.nickname);
} }
if (rs_out->status.is_named) if (rs_out->status.is_named)
strlcpy(rs_out->status.nickname, the_name, sizeof(rs_out->status.nickname)); strlcpy(rs_out->status.nickname, the_name, sizeof(rs_out->status.nickname));