mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
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:
parent
0924094042
commit
8434595584
@ -518,7 +518,7 @@ CFLAGS="$CFLAGS -Wall -g -O2"
|
||||
# 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"
|
||||
# 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"
|
||||
|
||||
|
@ -499,16 +499,16 @@ addressmap_virtaddress_ent_free(void *_ent)
|
||||
|
||||
/** Free storage held by a virtaddress_entry_t* entry in <b>ent</b> */
|
||||
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)) {
|
||||
virtaddress_entry_t *ve =
|
||||
strmap_get(virtaddress_reversemap, ent->new_address);
|
||||
/*log_fn(LOG_NOTICE,"remove reverse mapping for %s",ent->new_address);*/
|
||||
if (ve) {
|
||||
if (!strcmp(addr, ve->ipv4_address))
|
||||
if (!strcmp(address, 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);
|
||||
if (!ve->ipv4_address && !ve->hostname_address) {
|
||||
tor_free(ve);
|
||||
@ -520,9 +520,9 @@ addressmap_virtaddress_remove(const char *addr, addressmap_entry_t *ent)
|
||||
|
||||
/* DOCDOC */
|
||||
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);
|
||||
}
|
||||
|
||||
@ -735,15 +735,15 @@ client_dns_set_addressmap(const char *address, uint32_t val, const char *exitnam
|
||||
* client_dns_get_unused_address.
|
||||
**/
|
||||
int
|
||||
address_is_in_virtual_range(const char *addr)
|
||||
address_is_in_virtual_range(const char *address)
|
||||
{
|
||||
struct in_addr in;
|
||||
tor_assert(addr);
|
||||
if (!strcasecmpend(addr, ".virtual")) {
|
||||
tor_assert(address);
|
||||
if (!strcasecmpend(address, ".virtual")) {
|
||||
return 1;
|
||||
} else if (tor_inet_aton(addr, &in)) {
|
||||
uint32_t a = ntohl(in.s_addr);
|
||||
if (a >= MIN_UNUSED_IPV4 && a <= MAX_UNUSED_IPV4)
|
||||
} else if (tor_inet_aton(address, &in)) {
|
||||
uint32_t addr = ntohl(in.s_addr);
|
||||
if (addr >= MIN_UNUSED_IPV4 && addr <= MAX_UNUSED_IPV4)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -1120,20 +1120,20 @@ handle_control_mapaddress(connection_t *conn, uint32_t len, const char *body)
|
||||
} else if (!is_plausible_address(to)) {
|
||||
log_fn(LOG_WARN,"Skipping invalid argument '%s' in MapAddress msg",to);
|
||||
} 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,
|
||||
tor_strdup(to));
|
||||
if (!addr) {
|
||||
if (!address) {
|
||||
log_fn(LOG_WARN,
|
||||
"Unable to allocate address for '%s' in MapAddress msg",
|
||||
safe_str(line));
|
||||
} else {
|
||||
size_t anslen = strlen(addr)+strlen(to)+8;
|
||||
size_t anslen = strlen(address)+strlen(to)+8;
|
||||
char *ans = tor_malloc(anslen);
|
||||
if (v0)
|
||||
tor_snprintf(ans, anslen, "%s %s", addr, to);
|
||||
tor_snprintf(ans, anslen, "%s %s", address, to);
|
||||
else
|
||||
tor_snprintf(ans, anslen, "250-%s=%s", addr, to);
|
||||
tor_snprintf(ans, anslen, "250-%s=%s", address, to);
|
||||
smartlist_add(reply, ans);
|
||||
}
|
||||
} else {
|
||||
@ -1677,7 +1677,6 @@ handle_control_attachstream(connection_t *conn, uint32_t len,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/** Callled when we get a POSTDESCRIPTORT message. Try to learn the provided
|
||||
* descriptor, and report succcess or failure. */
|
||||
static int
|
||||
|
@ -1983,3 +1983,4 @@ tor_main(int argc, char *argv[])
|
||||
tor_cleanup();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
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);
|
||||
void clear_trusted_dir_servers(void);
|
||||
networkstatus_t *networkstatus_get_by_digest(const char *digest);
|
||||
|
@ -18,7 +18,7 @@ static circuit_t *find_intro_circuit(routerinfo_t *router, const char *pk_digest
|
||||
typedef struct rend_service_port_config_t {
|
||||
uint16_t virtual_port;
|
||||
uint16_t real_port;
|
||||
uint32_t real_address;
|
||||
uint32_t real_addr;
|
||||
} rend_service_port_config_t;
|
||||
|
||||
/** 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) {
|
||||
char addrbuf[INET_NTOA_BUF_LEN];
|
||||
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));
|
||||
log_fn(LOG_DEBUG,"Service maps port %d to %s:%d",
|
||||
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->virtual_port = virtport;
|
||||
result->real_port = realport;
|
||||
result->real_address = addr;
|
||||
result->real_addr = addr;
|
||||
err:
|
||||
SMARTLIST_FOREACH(sl, char *, c, tor_free(c));
|
||||
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) {
|
||||
p = smartlist_get(service->ports, i);
|
||||
if (conn->port == p->virtual_port) {
|
||||
conn->addr = p->real_address;
|
||||
conn->addr = p->real_addr;
|
||||
conn->port = p->real_port;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1317,8 +1317,8 @@ int
|
||||
router_load_single_router(const char *s, const char **msg)
|
||||
{
|
||||
routerinfo_t *ri;
|
||||
tor_assert(msg);
|
||||
smartlist_t *lst;
|
||||
tor_assert(msg);
|
||||
*msg = 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);
|
||||
if (d && d != conflict)
|
||||
rs_out->status.is_named = 1;
|
||||
if (smartlist_string_isin(warned_conflicts, rs->nickname))
|
||||
smartlist_string_remove(warned_conflicts, rs->nickname);
|
||||
if (smartlist_string_isin(warned_conflicts, rs_out->status.nickname))
|
||||
smartlist_string_remove(warned_conflicts, rs_out->status.nickname);
|
||||
}
|
||||
if (rs_out->status.is_named)
|
||||
strlcpy(rs_out->status.nickname, the_name, sizeof(rs_out->status.nickname));
|
||||
|
Loading…
Reference in New Issue
Block a user