[Cluster-devel] [PATCH 03/19] libgfs2: Fix an impossible loop condition in gfs2_rgrp_read

Andrew Price anprice at redhat.com
Tue Sep 2 12:07:20 UTC 2014


Correct a loop which expects an unsigned int to become negative.

Signed-off-by: Andrew Price <anprice at redhat.com>
---
 gfs2/libgfs2/rgrp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gfs2/libgfs2/rgrp.c b/gfs2/libgfs2/rgrp.c
index e929846..56b73ae 100644
--- a/gfs2/libgfs2/rgrp.c
+++ b/gfs2/libgfs2/rgrp.c
@@ -131,10 +131,10 @@ uint64_t gfs2_rgrp_read(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
 		bi->bi_bh = bhs[x];
 		if (gfs2_check_meta(bi->bi_bh, mtype)) {
 			unsigned err = x;
-			for (; x >= 0; x--) {
+			do {
 				brelse(rgd->bits[x].bi_bh);
 				rgd->bits[x].bi_bh = NULL;
-			}
+			} while (x-- != 0);
 			free(bhs);
 			return rgd->ri.ri_addr + err;
 		}
-- 
1.9.3




More information about the Cluster-devel mailing list