[or-cvs] r8664: The otherwise regrettable MIPSpro C compiler warns about val (in tor/trunk: . src/common src/or)
nickm at seul.org
nickm at seul.org
Mon Oct 9 02:35:53 UTC 2006
Author: nickm
Date: 2006-10-08 22:35:51 -0400 (Sun, 08 Oct 2006)
New Revision: 8664
Modified:
tor/trunk/
tor/trunk/src/common/crypto.c
tor/trunk/src/common/torgzip.c
tor/trunk/src/common/torgzip.h
tor/trunk/src/or/config.c
tor/trunk/src/or/connection_edge.c
tor/trunk/src/or/directory.c
tor/trunk/src/or/dirserv.c
tor/trunk/src/or/rendcommon.c
tor/trunk/src/or/router.c
tor/trunk/src/or/routerparse.c
tor/trunk/src/or/test.c
Log:
r8957 at 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.
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r8957] on 96637b51-b116-0410-a10e-9941ebb49b64
Modified: tor/trunk/src/common/crypto.c
===================================================================
--- tor/trunk/src/common/crypto.c 2006-10-09 02:35:43 UTC (rev 8663)
+++ tor/trunk/src/common/crypto.c 2006-10-09 02:35:51 UTC (rev 8664)
@@ -879,12 +879,11 @@
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) {
Modified: tor/trunk/src/common/torgzip.c
===================================================================
--- tor/trunk/src/common/torgzip.c 2006-10-09 02:35:43 UTC (rev 8663)
+++ tor/trunk/src/common/torgzip.c 2006-10-09 02:35:51 UTC (rev 8664)
@@ -274,9 +274,9 @@
/** 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 @@
(ntohs(get_uint16(in)) % 31) == 0) {
return ZLIB_METHOD;
} else {
- return 0;
+ return UNKNOWN_METHOD;
}
}
Modified: tor/trunk/src/common/torgzip.h
===================================================================
--- tor/trunk/src/common/torgzip.h 2006-10-09 02:35:43 UTC (rev 8663)
+++ tor/trunk/src/common/torgzip.h 2006-10-09 02:35:51 UTC (rev 8664)
@@ -29,7 +29,7 @@
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
Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c 2006-10-09 02:35:43 UTC (rev 8663)
+++ tor/trunk/src/or/config.c 2006-10-09 02:35:51 UTC (rev 8664)
@@ -1555,13 +1555,11 @@
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 @@
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 @@
goto err;
}
- idx = 0;
if (is_legal_nickname(smartlist_get(items, 0))) {
nickname = smartlist_get(items, 0);
smartlist_del_keeporder(items, 0);
Modified: tor/trunk/src/or/connection_edge.c
===================================================================
--- tor/trunk/src/or/connection_edge.c 2006-10-09 02:35:43 UTC (rev 8663)
+++ tor/trunk/src/or/connection_edge.c 2006-10-09 02:35:51 UTC (rev 8664)
@@ -2311,7 +2311,8 @@
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 */
Modified: tor/trunk/src/or/directory.c
===================================================================
--- tor/trunk/src/or/directory.c 2006-10-09 02:35:43 UTC (rev 8663)
+++ tor/trunk/src/or/directory.c 2006-10-09 02:35:51 UTC (rev 8664)
@@ -1008,7 +1008,7 @@
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);
Modified: tor/trunk/src/or/dirserv.c
===================================================================
--- tor/trunk/src/or/dirserv.c 2006-10-09 02:35:43 UTC (rev 8663)
+++ tor/trunk/src/or/dirserv.c 2006-10-09 02:35:51 UTC (rev 8664)
@@ -226,7 +226,7 @@
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,
Modified: tor/trunk/src/or/rendcommon.c
===================================================================
--- tor/trunk/src/or/rendcommon.c 2006-10-09 02:35:43 UTC (rev 8663)
+++ tor/trunk/src/or/rendcommon.c 2006-10-09 02:35:51 UTC (rev 8664)
@@ -471,5 +471,7 @@
default:
tor_assert(0);
}
+
+ (void)r;
}
Modified: tor/trunk/src/or/router.c
===================================================================
--- tor/trunk/src/or/router.c 2006-10-09 02:35:43 UTC (rev 8663)
+++ tor/trunk/src/or/router.c 2006-10-09 02:35:51 UTC (rev 8664)
@@ -243,7 +243,6 @@
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 @@
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 @@
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 @@
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,
Modified: tor/trunk/src/or/routerparse.c
===================================================================
--- tor/trunk/src/or/routerparse.c 2006-10-09 02:35:43 UTC (rev 8663)
+++ tor/trunk/src/or/routerparse.c 2006-10-09 02:35:51 UTC (rev 8664)
@@ -110,7 +110,7 @@
/** 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 @@
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);
Modified: tor/trunk/src/or/test.c
===================================================================
--- tor/trunk/src/or/test.c 2006-10-09 02:35:43 UTC (rev 8663)
+++ tor/trunk/src/or/test.c 2006-10-09 02:35:51 UTC (rev 8664)
@@ -1174,6 +1174,7 @@
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);
}
More information about the tor-commits
mailing list