[sheepdog] [PATCH] farm: fix comparison of empty sha1

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Tue Aug 7 13:11:34 CEST 2012


Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 sheep/farm/trunk.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/sheep/farm/trunk.c b/sheep/farm/trunk.c
index cd1fd20..8a53f9f 100644
--- a/sheep/farm/trunk.c
+++ b/sheep/farm/trunk.c
@@ -169,7 +169,9 @@ out:
 
 static inline int trunk_entry_no_sha1(struct trunk_entry_incore *entry)
 {
-	return !strlen((char *)entry->raw.sha1);
+	unsigned char empty[SHA1_LEN] = {0};
+
+	return memcmp(entry->raw.sha1, empty, SHA1_LEN) == 0;
 }
 
 static inline void put_entry(struct trunk_entry_incore *entry)
-- 
1.7.2.5




More information about the sheepdog mailing list