At Tue, 07 Aug 2012 19:21:10 +0800,
Liu Yuan wrote:
> 
> 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?

If the first byte of entry->raw.sha1 is zero, strlen(entry->raw.sha1)
returns zero.  What this function wants to do is to check
entry->raw.sha1 is filled with zero, isn't it?

Thanks,

Kazutaka
-- 
sheepdog mailing list
[email protected]
http://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to