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

Liu Yuan namei.unix at gmail.com
Tue Aug 7 13:21:10 CEST 2012


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

Could you explain what kind of problem the old code is?

-- 
thanks,
Yuan



More information about the sheepdog mailing list