From 75919d6cae9d0992c7bfda986da5d18eac9c904c Mon Sep 17 00:00:00 2001
From: Andre Noll <maan@tuebingen.mpg.de>
Date: Tue, 20 Dec 2016 21:18:27 +0100
Subject: [PATCH] afh: Make sure we never return a negative chunk number.

With the old code this could happen if chunk zero is empty.
---
 afh_common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/afh_common.c b/afh_common.c
index f36c32e2..dfbf7513 100644
--- a/afh_common.c
+++ b/afh_common.c
@@ -295,8 +295,8 @@ int32_t afh_get_start_chunk(int32_t approx_chunk_num,
 
 	for (k = PARA_MAX(0, approx_chunk_num); k >= 0; k--)
 		if (get_chunk_len(k, afhi) > 0)
-			break;
-	return k;
+			return k;
+	return 0;
 }
 
 /**
-- 
2.39.5