0
0
mirror of https://github.com/darkk/redsocks.git synced 2025-08-29 05:05:30 +00:00

Fix several compiler warnings.

This commit is contained in:
Leonid Evdokimov 2011-01-15 16:29:40 +02:00
parent 7099116ff1
commit 642c9a448f
5 changed files with 23 additions and 20 deletions

View File

@ -1,4 +1,4 @@
CFLAGS=-std=gnu99 -Wall -g -O0
CFLAGS=-std=gnu99 -Wall -g -O2
.PHONY: all
all: redsocks

4
base.c
View File

@ -296,8 +296,8 @@ static int base_fini();
static int base_init()
{
uid_t uid;
gid_t gid;
uid_t uid = -1;
gid_t gid = -1;
int devnull = -1;
if (!instance.configured) {

View File

@ -517,8 +517,9 @@ static void httpr_client_read_cb(struct bufferevent *buffev, void *_arg)
if (!httpr->has_host) {
char host[32]; // "Host: 123.456.789.012:34567"
strncpy(host, "Host: ", sizeof(host));
strncat(host, fmt_http_host(client->destaddr), sizeof(host));
int written_wo_null = snprintf(host, sizeof(host), "Host: %s",
fmt_http_host(client->destaddr));
assert(0 < written_wo_null && written_wo_null < sizeof(host));
if (httpr_append_header(client, host) < 0)
do_drop = 1;
}

View File

@ -304,8 +304,8 @@ void redsocks_drop_client(redsocks_client *client)
static void redsocks_shutdown(redsocks_client *client, struct bufferevent *buffev, int how)
{
short evhow;
char *strev, *strhow, *strevhow;
short evhow = 0;
char *strev, *strhow = NULL, *strevhow = NULL;
unsigned short *pevshut;
assert(how == SHUT_RD || how == SHUT_WR || how == SHUT_RDWR);
@ -328,6 +328,8 @@ static void redsocks_shutdown(redsocks_client *client, struct bufferevent *buffe
strevhow = "EV_READ|EV_WRITE";
}
assert(strhow && strevhow);
strev = buffev == client->client ? "client" : "relay";
pevshut = buffev == client->client ? &client->client_evshut : &client->relay_evshut;
@ -632,7 +634,7 @@ static void redsocks_debug_dump_instance(redsocks_instance *instance, time_t now
const char *s_client_evshut = redsocks_evshut_str(client->client_evshut);
const char *s_relay_evshut = redsocks_evshut_str(client->relay_evshut);
redsocks_log_error(client, LOG_DEBUG, "client: %i (%s)%s%s, relay: %i (%s)%s%s, age: %i sec, idle: %i sec.",
redsocks_log_error(client, LOG_DEBUG, "client: %i (%s)%s%s, relay: %i (%s)%s%s, age: %li sec, idle: %li sec.",
EVENT_FD(&client->client->ev_write),
redsocks_event_str(client->client->enabled),
s_client_evshut[0] ? " " : "", s_client_evshut,

View File

@ -401,7 +401,7 @@ static void redudp_relay_error(struct bufferevent *buffev, short what, void *_ar
static void redudp_timeout(int fd, short what, void *_arg)
{
redudp_client *client = _arg;
redudp_log_error(client, LOG_INFO, "Client timeout. First: %u, last_client: %u, last_relay: %u.",
redudp_log_error(client, LOG_INFO, "Client timeout. First: %li, last_client: %li, last_relay: %li.",
client->first_event, client->last_client_event, client->last_relay_event);
redudp_drop_client(client);
}
@ -585,17 +585,17 @@ static int redudp_onenter(parser_section *section)
for (parser_entry *entry = &section->entries[0]; entry->key; entry++)
entry->addr =
(strcmp(entry->key, "local_ip") == 0) ? &instance->config.bindaddr.sin_addr :
(strcmp(entry->key, "local_port") == 0) ? &instance->config.bindaddr.sin_port :
(strcmp(entry->key, "ip") == 0) ? &instance->config.relayaddr.sin_addr :
(strcmp(entry->key, "port") == 0) ? &instance->config.relayaddr.sin_port :
(strcmp(entry->key, "login") == 0) ? &instance->config.login :
(strcmp(entry->key, "password") == 0) ? &instance->config.password :
(strcmp(entry->key, "dest_ip") == 0) ? &instance->config.destaddr.sin_addr :
(strcmp(entry->key, "dest_port") == 0) ? &instance->config.destaddr.sin_port :
(strcmp(entry->key, "max_pktqueue") == 0) ? &instance->config.max_pktqueue :
(strcmp(entry->key, "udp_timeout") == 0) ? &instance->config.udp_timeout:
(strcmp(entry->key, "udp_timeout_stream") == 0) ? &instance->config.udp_timeout_stream :
(strcmp(entry->key, "local_ip") == 0) ? (void*)&instance->config.bindaddr.sin_addr :
(strcmp(entry->key, "local_port") == 0) ? (void*)&instance->config.bindaddr.sin_port :
(strcmp(entry->key, "ip") == 0) ? (void*)&instance->config.relayaddr.sin_addr :
(strcmp(entry->key, "port") == 0) ? (void*)&instance->config.relayaddr.sin_port :
(strcmp(entry->key, "login") == 0) ? (void*)&instance->config.login :
(strcmp(entry->key, "password") == 0) ? (void*)&instance->config.password :
(strcmp(entry->key, "dest_ip") == 0) ? (void*)&instance->config.destaddr.sin_addr :
(strcmp(entry->key, "dest_port") == 0) ? (void*)&instance->config.destaddr.sin_port :
(strcmp(entry->key, "max_pktqueue") == 0) ? (void*)&instance->config.max_pktqueue :
(strcmp(entry->key, "udp_timeout") == 0) ? (void*)&instance->config.udp_timeout:
(strcmp(entry->key, "udp_timeout_stream") == 0) ? (void*)&instance->config.udp_timeout_stream :
NULL;
section->data = instance;
return 0;