mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
r8957@totoro: nickm | 2006-10-08 22:35:17 -0400
The otherwise regrettable MIPSpro C compiler warns about values set but never used, and about mixing enums and ints; these are good warnings, and so should be fixed. This removes some dead code and some potential bugs. Thanks to pnx. svn:r8664
This commit is contained in:
+1
-2
@@ -879,12 +879,11 @@ crypto_pk_private_hybrid_decrypt(crypto_pk_env_t *env,
|
||||
size_t fromlen,
|
||||
int padding, int warnOnFailure)
|
||||
{
|
||||
int overhead, outlen, r;
|
||||
int outlen, r;
|
||||
size_t pkeylen;
|
||||
crypto_cipher_env_t *cipher = NULL;
|
||||
char buf[PK_BYTES+1];
|
||||
|
||||
overhead = crypto_get_rsa_padding_overhead(crypto_get_rsa_padding(padding));
|
||||
pkeylen = crypto_pk_keysize(env);
|
||||
|
||||
if (fromlen <= pkeylen) {
|
||||
|
||||
@@ -274,9 +274,9 @@ tor_gzip_uncompress(char **out, size_t *out_len,
|
||||
|
||||
/** Try to tell whether the <b>in_len</b>-byte string in <b>in</b> is likely
|
||||
* to be compressed or not. If it is, return the likeliest compression method.
|
||||
* Otherwise, return 0.
|
||||
* Otherwise, return UNKNOWN_METHOD.
|
||||
*/
|
||||
int
|
||||
compress_method_t
|
||||
detect_compression_method(const char *in, size_t in_len)
|
||||
{
|
||||
if (in_len > 2 && !memcmp(in, "\x1f\x8b", 2)) {
|
||||
@@ -285,7 +285,7 @@ detect_compression_method(const char *in, size_t in_len)
|
||||
(ntohs(get_uint16(in)) % 31) == 0) {
|
||||
return ZLIB_METHOD;
|
||||
} else {
|
||||
return 0;
|
||||
return UNKNOWN_METHOD;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ tor_gzip_uncompress(char **out, size_t *out_len,
|
||||
|
||||
int is_gzip_supported(void);
|
||||
|
||||
int detect_compression_method(const char *in, size_t in_len);
|
||||
compress_method_t detect_compression_method(const char *in, size_t in_len);
|
||||
|
||||
typedef enum {
|
||||
TOR_ZLIB_OK, TOR_ZLIB_DONE, TOR_ZLIB_BUF_FULL, TOR_ZLIB_ERR
|
||||
|
||||
+1
-4
@@ -1555,13 +1555,11 @@ option_reset(config_format_t *fmt, or_options_t *options,
|
||||
config_var_t *var, int use_defaults)
|
||||
{
|
||||
config_line_t *c;
|
||||
void *lvalue;
|
||||
char *msg = NULL;
|
||||
CHECK(fmt, options);
|
||||
option_clear(fmt, options, var); /* clear it first */
|
||||
if (!use_defaults)
|
||||
return; /* all done */
|
||||
lvalue = STRUCT_VAR_P(options, var->var_offset);
|
||||
if (var->initvalue) {
|
||||
c = tor_malloc_zero(sizeof(config_line_t));
|
||||
c->key = tor_strdup(var->name);
|
||||
@@ -3247,7 +3245,7 @@ static int
|
||||
parse_dir_server_line(const char *line, int validate_only)
|
||||
{
|
||||
smartlist_t *items = NULL;
|
||||
int r, idx;
|
||||
int r;
|
||||
char *addrport=NULL, *address=NULL, *nickname=NULL, *fingerprint=NULL;
|
||||
uint16_t port;
|
||||
char digest[DIGEST_LEN];
|
||||
@@ -3262,7 +3260,6 @@ parse_dir_server_line(const char *line, int validate_only)
|
||||
goto err;
|
||||
}
|
||||
|
||||
idx = 0;
|
||||
if (is_legal_nickname(smartlist_get(items, 0))) {
|
||||
nickname = smartlist_get(items, 0);
|
||||
smartlist_del_keeporder(items, 0);
|
||||
|
||||
@@ -2311,7 +2311,8 @@ parse_extended_hostname(char *address)
|
||||
char query[REND_SERVICE_ID_LEN+1];
|
||||
|
||||
s = strrchr(address,'.');
|
||||
if (!s) return 0; /* no dot, thus normal */
|
||||
if (!s)
|
||||
return NORMAL_HOSTNAME; /* no dot, thus normal */
|
||||
if (!strcmp(s+1,"exit")) {
|
||||
*s = 0; /* nul-terminate it */
|
||||
return EXIT_HOSTNAME; /* .exit */
|
||||
|
||||
+1
-1
@@ -1008,7 +1008,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
||||
|
||||
if (conn->_base.purpose == DIR_PURPOSE_FETCH_NETWORKSTATUS) {
|
||||
smartlist_t *which = NULL;
|
||||
int source;
|
||||
networkstatus_source_t source;
|
||||
char *cp;
|
||||
log_info(LD_DIR,"Received networkstatus objects (size %d) from server "
|
||||
"'%s:%d'",(int) body_len, conn->_base.address, conn->_base.port);
|
||||
|
||||
+1
-1
@@ -226,7 +226,7 @@ dirserv_router_get_status(const routerinfo_t *router, const char **msg)
|
||||
|
||||
if (crypto_pk_get_fingerprint(router->identity_pkey, fingerprint, 0)) {
|
||||
log_warn(LD_BUG,"Error computing fingerprint");
|
||||
return -1;
|
||||
return FP_REJECT;
|
||||
}
|
||||
|
||||
return dirserv_get_status_impl(fingerprint, router->nickname,
|
||||
|
||||
@@ -471,5 +471,7 @@ rend_process_relay_cell(circuit_t *circ, int command, size_t length,
|
||||
default:
|
||||
tor_assert(0);
|
||||
}
|
||||
|
||||
(void)r;
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -243,7 +243,6 @@ init_keys(void)
|
||||
char fingerprint[FINGERPRINT_LEN+1];
|
||||
/*nickname<space>fp\n\0 */
|
||||
char fingerprint_line[MAX_NICKNAME_LEN+FINGERPRINT_LEN+3];
|
||||
char *cp;
|
||||
const char *mydesc, *datadir;
|
||||
crypto_pk_env_t *prkey;
|
||||
char digest[20];
|
||||
@@ -279,7 +278,6 @@ init_keys(void)
|
||||
if (check_private_dir(keydir, CPD_CREATE)) {
|
||||
return -1;
|
||||
}
|
||||
cp = keydir + strlen(keydir); /* End of string. */
|
||||
|
||||
/* 1. Read identity key. Make it if none is found. */
|
||||
tor_snprintf(keydir,sizeof(keydir),"%s/keys/identity.key",datadir);
|
||||
@@ -1093,7 +1091,7 @@ router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
|
||||
char *bandwidth_usage;
|
||||
char *family_line;
|
||||
#ifdef DEBUG_ROUTER_DUMP_ROUTER_TO_STRING
|
||||
char *s_tmp, *s_dup;
|
||||
char *s_dup;
|
||||
const char *cp;
|
||||
routerinfo_t *ri_tmp;
|
||||
#endif
|
||||
@@ -1263,7 +1261,7 @@ router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
|
||||
s[written+1] = 0;
|
||||
|
||||
#ifdef DEBUG_ROUTER_DUMP_ROUTER_TO_STRING
|
||||
cp = s_tmp = s_dup = tor_strdup(s);
|
||||
cp = s_dup = tor_strdup(s);
|
||||
ri_tmp = router_parse_entry_from_string(cp, NULL, 1);
|
||||
if (!ri_tmp) {
|
||||
log_err(LD_BUG,
|
||||
|
||||
@@ -110,7 +110,7 @@ typedef enum {
|
||||
|
||||
/** Table mapping keywords to token value and to argument rules. */
|
||||
static struct {
|
||||
const char *t; int v; arg_syntax s; obj_syntax os; int ws;
|
||||
const char *t; directory_keyword v; arg_syntax s; obj_syntax os; int ws;
|
||||
} token_table[] = {
|
||||
{ "accept", K_ACCEPT, ARGS, NO_OBJ, RTR },
|
||||
{ "directory-signature", K_DIRECTORY_SIGNATURE, ARGS, NEED_OBJ,
|
||||
@@ -265,15 +265,12 @@ router_append_dirobj_signature(char *buf, size_t buf_len, const char *digest,
|
||||
version_status_t
|
||||
tor_version_is_obsolete(const char *myversion, const char *versionlist)
|
||||
{
|
||||
const char *vl;
|
||||
tor_version_t mine, other;
|
||||
int found_newer = 0, found_older = 0, found_newer_in_series = 0,
|
||||
found_any_in_series = 0, r, same;
|
||||
version_status_t ret = VS_UNRECOMMENDED;
|
||||
smartlist_t *version_sl;
|
||||
|
||||
vl = versionlist;
|
||||
|
||||
log_debug(LD_CONFIG,"Checking whether version '%s' is in '%s'",
|
||||
myversion, versionlist);
|
||||
|
||||
|
||||
@@ -1174,6 +1174,7 @@ test_control_formats(void)
|
||||
sz = read_escaped_data(inp, strlen(inp), 1, &out);
|
||||
test_streq(out,
|
||||
".This is a test\nof the emergency \nbroadcast\n.system.\nZ.\n");
|
||||
test_eq(sz, strlen(out));
|
||||
|
||||
tor_free(out);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user