From 2904cdca2d230155139680729bc11b033b4b4d93 Mon Sep 17 00:00:00 2001 From: Richard Nyberg Date: Thu, 21 Jul 2005 15:06:13 +0000 Subject: [PATCH] Add tests for correctness. --- btpd/peer.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/btpd/peer.c b/btpd/peer.c index f40e3c1..8aecd0b 100644 --- a/btpd/peer.c +++ b/btpd/peer.c @@ -125,6 +125,7 @@ peer_choke(struct peer *p) void peer_want(struct peer *p, uint32_t index) { + assert(p->nwant < p->npieces); p->nwant++; if (p->nwant == 1) { p->flags |= PF_I_WANT; @@ -135,6 +136,7 @@ peer_want(struct peer *p, uint32_t index) void peer_unwant(struct peer *p, uint32_t index) { + assert(p->nwant > 0); p->nwant--; if (p->nwant == 0) { p->flags &= ~PF_I_WANT;