Fix compiler warnings using gcc 4.6.

This commit is contained in:
Jan Vidar Krey 2011-11-28 16:30:35 +01:00
parent 3b4a199673
commit bad4512a37
7 changed files with 44 additions and 34 deletions

View File

@ -26,12 +26,10 @@
static int check_cmd_bool(const char* cmd, struct linked_list* list, char* line, int line_count) static int check_cmd_bool(const char* cmd, struct linked_list* list, char* line, int line_count)
{ {
char* data; char* data;
char* data_extra;
if (!strncmp(line, cmd, strlen(cmd))) if (!strncmp(line, cmd, strlen(cmd)))
{ {
data = &line[strlen(cmd)]; data = &line[strlen(cmd)];
data_extra = 0;
data[0] = '\0'; data[0] = '\0';
data++; data++;

View File

@ -119,7 +119,7 @@ struct hub_info
#endif #endif
#ifdef SSL_SUPPORT #ifdef SSL_SUPPORT
SSL_METHOD* ssl_method; const SSL_METHOD* ssl_method;
SSL_CTX* ssl_ctx; SSL_CTX* ssl_ctx;
#endif /* SSL_SUPPORT */ #endif /* SSL_SUPPORT */
}; };

View File

@ -70,7 +70,6 @@ static int handle_openssl_error(struct net_connection* con, int ret)
con->ssl_state = tls_st_error; con->ssl_state = tls_st_error;
return -1; return -1;
} }
return -1; return -1;
} }

View File

@ -1,6 +1,6 @@
/* /*
* uhub - A tiny ADC p2p connection hub * uhub - A tiny ADC p2p connection hub
* Copyright (C) 2007-2009, Jan Vidar Krey * Copyright (C) 2007-2011, Jan Vidar Krey
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -75,33 +75,32 @@ static void event_callback(struct net_connection* con, int events, void *arg)
{ {
struct ADC_client* client = (struct ADC_client*) net_con_get_ptr(con); struct ADC_client* client = (struct ADC_client*) net_con_get_ptr(con);
if (events == NET_EVENT_TIMEOUT) switch (client->state)
{ {
if (client->state == ps_conn) case ps_conn:
{ if (events == NET_EVENT_TIMEOUT)
client->callback(client, ADC_CLIENT_DISCONNECTED, 0); {
} client->callback(client, ADC_CLIENT_DISCONNECTED, 0);
return; return;
} }
if (events & NET_EVENT_READ) if (events & NET_EVENT_WRITE)
{ ADC_client_connect(client, 0);
if (ADC_client_recv(client) == -1) break;
{
ADC_client_on_disconnected(client);
}
}
if (events & NET_EVENT_WRITE) default:
{ if (events & NET_EVENT_READ)
if (client->state == ps_conn) {
{ if (ADC_client_recv(client) == -1)
ADC_client_connect(client, 0); {
} ADC_client_on_disconnected(client);
else }
{ }
/* FIXME: Call send again */
} if (events & NET_EVENT_WRITE)
{
/* FIXME: Call send again */
}
} }
} }
@ -380,6 +379,14 @@ int ADC_client_connect(struct ADC_client* client, const char* address)
int ret = net_connect(net_con_get_sd(client->con), (struct sockaddr*) &client->addr, sizeof(struct sockaddr_in)); int ret = net_connect(net_con_get_sd(client->con), (struct sockaddr*) &client->addr, sizeof(struct sockaddr_in));
if (ret == 0 || (ret == -1 && net_error() == EISCONN)) if (ret == 0 || (ret == -1 && net_error() == EISCONN))
{ {
#ifdef SSL_SUPPORT
if (ssl_enabled)
{
}
else
#endif
ADC_client_on_connected(client); ADC_client_on_connected(client);
} }
else if (ret == -1 && (net_error() == EALREADY || net_error() == EINPROGRESS || net_error() == EWOULDBLOCK || net_error() == EINTR)) else if (ret == -1 && (net_error() == EALREADY || net_error() == EINPROGRESS || net_error() == EWOULDBLOCK || net_error() == EINTR))
@ -446,9 +453,9 @@ static int ADC_client_parse_address(struct ADC_client* client, const char* arg)
/* Check for ADC or ADCS */ /* Check for ADC or ADCS */
if (!strncmp(arg, "adc://", 6)) if (!strncmp(arg, "adc://", 6))
ssl = 0; client->ssl_enabled = 0;
else if (!strncmp(arg, "adcs://", 7)) else if (!strncmp(arg, "adcs://", 7))
ssl = 1; client->ssl_enabled = 1;
else else
return 0; return 0;

View File

@ -1,6 +1,6 @@
/* /*
* uhub - A tiny ADC p2p connection hub * uhub - A tiny ADC p2p connection hub
* Copyright (C) 2007-2010, Jan Vidar Krey * Copyright (C) 2007-2011, Jan Vidar Krey
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -115,6 +115,11 @@ struct ADC_client
char* hub_address; char* hub_address;
char* nick; char* nick;
char* desc; char* desc;
int ssl_enabled;
#ifdef SSL_SUPPORT
SSL_METHOD* ssl_method;
SSL_CTX* ssl_ctx;
#endif /* SSL_SUPPORT */
}; };
int ADC_client_create(struct ADC_client* client, const char* nickname, const char* description); int ADC_client_create(struct ADC_client* client, const char* nickname, const char* description);

View File

@ -328,9 +328,8 @@ void runloop(size_t clients)
ADC_client_connect(c, cfg_uri); ADC_client_connect(c, cfg_uri);
} }
while (running) while (net_backend_process())
{ {
net_backend_process();
} }
for (n = 0; n < clients; n++) for (n = 0; n < clients; n++)

View File

@ -1,4 +1,6 @@
#if !defined(_MSC_VER)
#include "revision.h" #include "revision.h"
#endif
#ifndef PRODUCT #ifndef PRODUCT
#define PRODUCT "uhub" #define PRODUCT "uhub"