[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r10199: Fix warnings from -Wunsafe-loop-optimizations, which inciden (in tor/trunk: . src/common src/or)
- To: or-cvs@xxxxxxxxxxxxx
- Subject: [or-cvs] r10199: Fix warnings from -Wunsafe-loop-optimizations, which inciden (in tor/trunk: . src/common src/or)
- From: nickm@xxxxxxxx
- Date: Wed, 16 May 2007 18:15:56 -0400 (EDT)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Wed, 16 May 2007 18:16:26 -0400
- Reply-to: or-dev@xxxxxxxxxxxxx
- Sender: owner-or-cvs@xxxxxxxxxxxxx
Author: nickm
Date: 2007-05-16 18:15:48 -0400 (Wed, 16 May 2007)
New Revision: 10199
Modified:
tor/trunk/
tor/trunk/src/common/crypto.c
tor/trunk/src/or/relay.c
Log:
r12769@catbus: nickm | 2007-05-16 17:32:01 -0400
Fix warnings from -Wunsafe-loop-optimizations, which incidentally turned up a logic bug in connection_or_flush_from_first_active_circuit that would overcount the number of cells flushed.
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r12769] on 8246c3cf-6607-4228-993b-4d95d33730f1
Modified: tor/trunk/src/common/crypto.c
===================================================================
--- tor/trunk/src/common/crypto.c 2007-05-16 22:15:14 UTC (rev 10198)
+++ tor/trunk/src/common/crypto.c 2007-05-16 22:15:48 UTC (rev 10199)
@@ -1494,14 +1494,12 @@
tor_assert(key_out_len <= DIGEST_LEN*256);
memcpy(tmp, key_in, key_in_len);
- for (cp = key_out, i=0; key_out_len; ++i, cp += DIGEST_LEN) {
+ for (cp = key_out, i=0; key_out_len >= DIGEST_LEN;
+ ++i, cp += DIGEST_LEN, key_out_len -= DIGEST_LEN) {
tmp[key_in_len] = i;
if (crypto_digest(digest, tmp, key_in_len+1))
goto err;
memcpy(cp, digest, MIN(DIGEST_LEN, key_out_len));
- if (key_out_len < DIGEST_LEN)
- break;
- key_out_len -= DIGEST_LEN;
}
memset(tmp, 0, key_in_len+1);
tor_free(tmp);
Modified: tor/trunk/src/or/relay.c
===================================================================
--- tor/trunk/src/or/relay.c 2007-05-16 22:15:14 UTC (rev 10198)
+++ tor/trunk/src/or/relay.c 2007-05-16 22:15:48 UTC (rev 10199)
@@ -1807,7 +1807,7 @@
}
tor_assert(*next_circ_on_conn_p(circ,conn));
- for (n_flushed = 0; n_flushed < max && queue->head; ++n_flushed) {
+ for (n_flushed = 0; n_flushed < max && queue->head; ) {
packed_cell_t *cell = cell_queue_pop(queue);
tor_assert(*next_circ_on_conn_p(circ,conn));