[Drbd-dev] [PATCH] drbd: Fix test of unsigned in _drbd_fault_random()

Roel Kluin roel.kluin at gmail.com
Tue Dec 15 22:55:44 CET 2009


rsp->count is unsigned so the test does not work.

Signed-off-by: Roel Kluin <roel.kluin at gmail.com>
---
Found using coccinelle: http://coccinelle.lip6.fr/

diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index 157d1e4..c2594c1 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -3623,7 +3623,7 @@ _drbd_fault_random(struct fault_random_state *rsp)
 {
 	long refresh;
 
-	if (--rsp->count < 0) {
+	if (!rsp->count--) {
 		get_random_bytes(&refresh, sizeof(refresh));
 		rsp->state += refresh;
 		rsp->count = FAULT_RANDOM_REFRESH;


More information about the drbd-dev mailing list