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

Liu Yuan namei.unix at gmail.com
Wed Aug 8 08:33:07 CEST 2012


On 08/07/2012 07:11 PM, MORITA Kazutaka wrote:
> 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)
> 

Applied, thanks.

Yuan



More information about the sheepdog mailing list