mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 05:03:43 +01:00
Use a stricter set of warnings; make them all pass.
svn:r2645
This commit is contained in:
parent
85c79ffbc7
commit
ad4dc74482
@ -5,8 +5,6 @@ AM_CONFIG_HEADER(orconfig.h)
|
||||
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
CFLAGS="$CFLAGS -Wall -g -O2"
|
||||
|
||||
if test -f /etc/redhat-release; then
|
||||
CFLAGS="$CFLAGS -I/usr/kerberos/include"
|
||||
fi
|
||||
@ -233,6 +231,13 @@ AC_SUBST(BINDIR)
|
||||
LOCALSTATEDIR=`eval echo $localstatedir`
|
||||
AC_SUBST(LOCALSTATEDIR)
|
||||
|
||||
# Set CFLAGS _after_ all the above checks, since our warnings are stricter
|
||||
# than autoconf's macros like.
|
||||
CFLAGS="$CFLAGS -Wall -W -Wno-unused-parameter -Wfloat-equal -Wdeclaration-after-statement -Wundef -Wendif-labels -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -g -O2"
|
||||
|
||||
# Add these in when you feel like fun.
|
||||
# -Wbad-function-cast -Werror
|
||||
|
||||
echo "confdir: $CONFDIR"
|
||||
|
||||
AC_OUTPUT(Makefile contrib/tor.sh contrib/torify contrib/Makefile src/config/torrc.sample doc/tor.1 src/Makefile doc/Makefile doc/design-paper/Makefile src/config/Makefile src/common/Makefile src/or/Makefile src/win32/Makefile src/tools/Makefile)
|
||||
|
@ -93,6 +93,13 @@ struct crypto_dh_env_t {
|
||||
DH *dh;
|
||||
};
|
||||
|
||||
/* Prototypes for functions only used by tortls.c */
|
||||
crypto_pk_env_t *_crypto_new_pk_env_rsa(RSA *rsa);
|
||||
RSA *_crypto_pk_env_get_rsa(crypto_pk_env_t *env);
|
||||
EVP_PKEY *_crypto_pk_env_get_evp_pkey(crypto_pk_env_t *env, int private);
|
||||
DH *_crypto_dh_env_get_dh(crypto_dh_env_t *dh);
|
||||
|
||||
|
||||
/** Return the number of bytes added by padding method <b>padding</b>.
|
||||
*/
|
||||
static INLINE int
|
||||
|
@ -26,12 +26,6 @@
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#if _MSC_VER > 1300
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#elif defined(_MSC_VER)
|
||||
#include <winsock.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -108,7 +108,7 @@ extern int have_failed;
|
||||
|
||||
#define test_memeq(expr1, expr2, len) \
|
||||
STMT_BEGIN \
|
||||
void *v1=(expr1), *v2=(expr2); \
|
||||
const void *v1=(expr1), *v2=(expr2); \
|
||||
if(!memcmp(v1,v2,(len))) { printf("."); fflush(stdout); } else { \
|
||||
have_failed = 1; \
|
||||
printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n", \
|
||||
|
@ -83,6 +83,7 @@ static int connection_finished_flushing(connection_t *conn);
|
||||
static int connection_finished_connecting(connection_t *conn);
|
||||
static int connection_read_to_buf(connection_t *conn);
|
||||
static int connection_process_inbuf(connection_t *conn);
|
||||
static int connection_bucket_read_limit(connection_t *conn);
|
||||
|
||||
/**************************************************************/
|
||||
|
||||
@ -642,7 +643,7 @@ int retry_all_listeners(int force) {
|
||||
extern int global_read_bucket, global_write_bucket;
|
||||
|
||||
/** How many bytes at most can we read onto this connection? */
|
||||
int connection_bucket_read_limit(connection_t *conn) {
|
||||
static int connection_bucket_read_limit(connection_t *conn) {
|
||||
int at_most;
|
||||
|
||||
/* do a rudimentary round-robin so one circuit can't hog a connection */
|
||||
|
@ -24,6 +24,8 @@ static int list_server_status(char **running_routers_out,
|
||||
char **router_status_out);
|
||||
static void directory_remove_unrecognized(void);
|
||||
static int dirserv_regenerate_directory(void);
|
||||
/* Should be static; exposed for testing */
|
||||
void add_fingerprint_to_dir(const char *nickname, const char *fp);
|
||||
|
||||
/************** Fingerprint handling code ************/
|
||||
|
||||
|
@ -1019,7 +1019,7 @@ static int network_init(void)
|
||||
|
||||
/** Called by exit() as we shut down the process.
|
||||
*/
|
||||
void exit_function(void)
|
||||
static void exit_function(void)
|
||||
{
|
||||
/* XXX if we ever daemonize, this gets called immediately */
|
||||
#ifdef MS_WINDOWS
|
||||
@ -1096,7 +1096,7 @@ void tor_cleanup(void) {
|
||||
}
|
||||
|
||||
/** Read/create keys as needed, and echo our fingerprint to stdout. */
|
||||
void do_list_fingerprint(void)
|
||||
static void do_list_fingerprint(void)
|
||||
{
|
||||
char buf[FINGERPRINT_LEN+1];
|
||||
crypto_pk_env_t *k;
|
||||
|
@ -1038,13 +1038,6 @@ circuit_t *circuit_launch_by_identity(uint8_t purpose, const char *exit_digest);
|
||||
void circuit_reset_failure_count(int timeout);
|
||||
int connection_ap_handshake_attach_circuit(connection_t *conn);
|
||||
|
||||
int circuit_init_cpath_crypto(crypt_path_t *cpath, char *key_data,int reverse);
|
||||
int circuit_finish_handshake(circuit_t *circ, char *reply);
|
||||
int circuit_truncated(circuit_t *circ, crypt_path_t *layer);
|
||||
|
||||
void assert_cpath_layer_ok(const crypt_path_t *c);
|
||||
void assert_circuit_ok(const circuit_t *c);
|
||||
|
||||
/********************************* command.c ***************************/
|
||||
|
||||
void command_process_cell(cell_t *cell, connection_t *conn);
|
||||
@ -1271,6 +1264,8 @@ int proxy_mode(void);
|
||||
void handle_signals(int is_parent);
|
||||
void tor_cleanup(void);
|
||||
|
||||
int tor_main(int argc, char *argv[]);
|
||||
|
||||
/********************************* onion.c ***************************/
|
||||
|
||||
int onion_pending_add(circuit_t *circ);
|
||||
|
@ -30,9 +30,6 @@ circuit_resume_edge_reading_helper(connection_t *conn,
|
||||
crypt_path_t *layer_hint);
|
||||
static int
|
||||
circuit_consider_stop_edge_reading(circuit_t *circ, crypt_path_t *layer_hint);
|
||||
void connection_edge_consider_sending_sendme(connection_t *conn);
|
||||
|
||||
|
||||
|
||||
/** Stats: how many relay cells have originated at this hop, or have
|
||||
* been relayed onward (not recognized at this hop)?
|
||||
|
@ -737,7 +737,8 @@ void router_mark_as_down(const char *digest) {
|
||||
* will either be inserted into the routerlist or freed. Returns 0 if the
|
||||
* router was added; -1 if it was not.
|
||||
*/
|
||||
int router_add_to_routerlist(routerinfo_t *router) {
|
||||
static int
|
||||
router_add_to_routerlist(routerinfo_t *router) {
|
||||
int i;
|
||||
routerinfo_t *r;
|
||||
char id_digest[DIGEST_LEN];
|
||||
|
@ -139,6 +139,8 @@ static int check_directory_signature(const char *digest,
|
||||
crypto_pk_env_t *pkey,
|
||||
crypto_pk_env_t *declared_key);
|
||||
static crypto_pk_env_t *find_dir_signing_key(const char *str);
|
||||
/* static */ int is_obsolete_version(const char *myversion,
|
||||
const char *versionlist);
|
||||
|
||||
/** Set <b>digest</b> to the SHA-1 digest of the hash of the directory in
|
||||
* <b>s</b>. Return 0 on success, nonzero on failure.
|
||||
|
@ -23,27 +23,11 @@ int have_failed = 0;
|
||||
/* These functions are file-local, but are exposed so we can test. */
|
||||
void add_fingerprint_to_dir(const char *nickname, const char *fp);
|
||||
void get_platform_str(char *platform, size_t len);
|
||||
|
||||
void
|
||||
dump_hex(char *s, size_t len)
|
||||
{
|
||||
static const char TABLE[] = "0123456789ABCDEF";
|
||||
unsigned char *d = s;
|
||||
size_t i;
|
||||
int j, nyb;
|
||||
for(i=0;i<len;++i) {
|
||||
for (j=1;j>=0;--j) {
|
||||
nyb = (((int) d[i]) >> (j*4)) & 0x0f;
|
||||
tor_assert(0 <= nyb);
|
||||
tor_assert(nyb <= 15);
|
||||
putchar(TABLE[nyb]);
|
||||
}
|
||||
}
|
||||
}
|
||||
int is_obsolete_version(const char *myversion, const char *start);
|
||||
|
||||
static char temp_dir[256];
|
||||
|
||||
void
|
||||
static void
|
||||
setup_directory(void)
|
||||
{
|
||||
static int is_setup = 0;
|
||||
@ -64,7 +48,7 @@ setup_directory(void)
|
||||
is_setup = 1;
|
||||
}
|
||||
|
||||
const char *
|
||||
static const char *
|
||||
get_fname(const char *name)
|
||||
{
|
||||
static char buf[1024];
|
||||
@ -73,7 +57,7 @@ get_fname(const char *name)
|
||||
return buf;
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
remove_directory(void)
|
||||
{
|
||||
DIR *dirp;
|
||||
@ -97,7 +81,7 @@ remove_directory(void)
|
||||
rmdir(temp_dir);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
test_buffers(void) {
|
||||
#define MAX_BUF_SIZE 1024*1024
|
||||
char str[256];
|
||||
@ -223,7 +207,7 @@ test_buffers(void) {
|
||||
buf_free(buf);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
test_crypto_dh(void)
|
||||
{
|
||||
crypto_dh_env_t *dh1, *dh2;
|
||||
@ -258,7 +242,7 @@ test_crypto_dh(void)
|
||||
crypto_dh_free(dh2);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
test_crypto(void)
|
||||
{
|
||||
crypto_cipher_env_t *env1, *env2;
|
||||
@ -494,7 +478,7 @@ test_crypto(void)
|
||||
free(data3);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
test_util(void) {
|
||||
struct timeval start, end;
|
||||
struct tm a_time;
|
||||
@ -694,7 +678,7 @@ test_util(void) {
|
||||
smartlist_free(sl);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
test_gzip(void)
|
||||
{
|
||||
char *buf1, *buf2=NULL, *buf3=NULL;
|
||||
@ -729,7 +713,8 @@ test_gzip(void)
|
||||
tor_free(buf1);
|
||||
}
|
||||
|
||||
static void* _squareAndRemoveK4(const char *key, void*val, void *data)
|
||||
static void *
|
||||
_squareAndRemoveK4(const char *key, void*val, void *data)
|
||||
{
|
||||
int *ip = (int*)data;
|
||||
intptr_t v;
|
||||
@ -741,7 +726,8 @@ static void* _squareAndRemoveK4(const char *key, void*val, void *data)
|
||||
return (void*)(v*v);
|
||||
}
|
||||
|
||||
void test_strmap(void)
|
||||
static void
|
||||
test_strmap(void)
|
||||
{
|
||||
strmap_t *map;
|
||||
strmap_iter_t *iter;
|
||||
@ -815,7 +801,8 @@ void test_strmap(void)
|
||||
strmap_free(map,NULL);
|
||||
}
|
||||
|
||||
void test_onion(void)
|
||||
static void
|
||||
test_onion(void)
|
||||
{
|
||||
#if 0
|
||||
char **names;
|
||||
@ -833,7 +820,7 @@ void test_onion(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
test_onion_handshake(void)
|
||||
{
|
||||
/* client-side */
|
||||
@ -876,10 +863,8 @@ test_onion_handshake(void)
|
||||
crypto_free_pk_env(pk);
|
||||
}
|
||||
|
||||
/* from routerparse.c */
|
||||
int is_obsolete_version(const char *myversion, const char *start);
|
||||
|
||||
void
|
||||
static void
|
||||
test_dir_format(void)
|
||||
{
|
||||
char buf[8192], buf2[8192];
|
||||
@ -925,7 +910,7 @@ test_dir_format(void)
|
||||
get_platform_str(platform, sizeof(platform));
|
||||
memset(&r1,0,sizeof(r1));
|
||||
memset(&r2,0,sizeof(r2));
|
||||
r1.address = "testaddr1.foo.bar";
|
||||
r1.address = tor_strdup("testaddr1.foo.bar");
|
||||
r1.addr = 0xc0a80001u; /* 192.168.0.1 */
|
||||
r1.published_on = 0;
|
||||
r1.or_port = 9000;
|
||||
@ -937,7 +922,7 @@ test_dir_format(void)
|
||||
r1.bandwidthburst = 5000;
|
||||
r1.bandwidthcapacity = 10000;
|
||||
r1.exit_policy = NULL;
|
||||
r1.nickname = "Magri";
|
||||
r1.nickname = tor_strdup("Magri");
|
||||
r1.platform = tor_strdup(platform);
|
||||
|
||||
ex1.policy_type = EXIT_POLICY_ACCEPT;
|
||||
@ -951,7 +936,7 @@ test_dir_format(void)
|
||||
ex2.msk = 0xFF000000u;
|
||||
ex2.prt_min = ex2.prt_max = 24;
|
||||
ex2.next = NULL;
|
||||
r2.address = "tor.tor.tor";
|
||||
r2.address = tor_strdup("tor.tor.tor");
|
||||
r2.addr = 0x0a030201u; /* 10.3.2.1 */
|
||||
r2.platform = tor_strdup(platform);
|
||||
r2.published_on = 5;
|
||||
@ -962,7 +947,7 @@ test_dir_format(void)
|
||||
r2.identity_pkey = pk1;
|
||||
r2.bandwidthrate = r2.bandwidthburst = r2.bandwidthcapacity = 3000;
|
||||
r2.exit_policy = &ex1;
|
||||
r2.nickname = "Fred";
|
||||
r2.nickname = tor_strdup("Fred");
|
||||
|
||||
bw_lines = rep_hist_get_bandwidth_lines();
|
||||
test_assert(bw_lines);
|
||||
@ -1062,7 +1047,7 @@ test_dir_format(void)
|
||||
test_assert(router_dump_router_to_string(buf, 2048, &r2, pk1)>0);
|
||||
cp = buf;
|
||||
test_eq(dirserv_add_descriptor((const char**)&cp), 1);
|
||||
options.Nickname = "DirServer";
|
||||
options.Nickname = tor_strdup("DirServer");
|
||||
test_assert(!dirserv_dump_directory_to_string(buf,8192,pk3));
|
||||
cp = buf;
|
||||
test_assert(!router_parse_routerlist_from_directory(buf, &dir1, pk3, 1));
|
||||
@ -1128,7 +1113,8 @@ test_dir_format(void)
|
||||
|
||||
}
|
||||
|
||||
void test_rend_fns(void)
|
||||
static void
|
||||
test_rend_fns(void)
|
||||
{
|
||||
char address1[] = "fooaddress.onion";
|
||||
char address2[] = "aaaaaaaaaaaaaaaa.onion";
|
||||
@ -1182,7 +1168,7 @@ main(int c, char**v){
|
||||
atexit(remove_directory);
|
||||
|
||||
// puts("========================== Buffers =========================");
|
||||
// test_buffers();
|
||||
if (0) test_buffers();
|
||||
puts("\n========================== Crypto ==========================");
|
||||
// add_stream_log(LOG_DEBUG, LOG_ERR, "<stdout>", stdout);
|
||||
test_crypto();
|
||||
|
@ -44,9 +44,10 @@
|
||||
do { log_fn(LOG_ERR, "Error while %s: %s", act, \
|
||||
tor_socket_strerror(tor_socket_errno(_s))); } while(0)
|
||||
|
||||
int build_socks4a_resolve_request(char **out,
|
||||
const char *username,
|
||||
const char *hostname)
|
||||
static int
|
||||
build_socks4a_resolve_request(char **out,
|
||||
const char *username,
|
||||
const char *hostname)
|
||||
{
|
||||
size_t len;
|
||||
tor_assert(out);
|
||||
@ -65,8 +66,9 @@ int build_socks4a_resolve_request(char **out,
|
||||
return len;
|
||||
}
|
||||
|
||||
int parse_socks4a_resolve_response(const char *response, size_t len,
|
||||
uint32_t *addr_out)
|
||||
static int
|
||||
parse_socks4a_resolve_response(const char *response, size_t len,
|
||||
uint32_t *addr_out)
|
||||
{
|
||||
uint8_t status;
|
||||
tor_assert(response);
|
||||
@ -86,8 +88,9 @@ int parse_socks4a_resolve_response(const char *response, size_t len,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int do_resolve(const char *hostname, uint32_t sockshost, uint16_t socksport,
|
||||
uint32_t *result_addr)
|
||||
static int
|
||||
do_resolve(const char *hostname, uint32_t sockshost, uint16_t socksport,
|
||||
uint32_t *result_addr)
|
||||
{
|
||||
int s;
|
||||
struct sockaddr_in socksaddr;
|
||||
@ -149,7 +152,8 @@ int do_resolve(const char *hostname, uint32_t sockshost, uint16_t socksport,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void usage(void)
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
puts("Syntax: tor-resolve [-v] hostname [sockshost:socksport]");
|
||||
exit(1);
|
||||
|
Loading…
Reference in New Issue
Block a user