bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/8] Avoid hashing garbage for short keynames.


From: olafBuddenhagen
Subject: Re: [PATCH 2/8] Avoid hashing garbage for short keynames.
Date: Tue, 10 Aug 2010 00:50:25 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

Hi,

On Wed, Aug 04, 2010 at 04:20:00AM -0300, Diego Nieto Cid wrote:

> +static inline int
> +keyname_hash(char *keyname)
> +{
> +  char tmp[5] = {0, 0, 0, 0, 0};
> +  strncpy(tmp, keyname, 4);

Hm, why tmp[5]? The way I read the code, only 4 entries are used...

BTW, minor stylistic nitpick: I generally consider it clearer and more
robust to use sizeof in strncpy(), i.e.:

   strncpy(tmp, keyname, sizeof tmp)

But that's only matter of style -- so if you prefer your variant,
feel free to keep it like that :-)

(Also, I *think* the initialisation can be written as simply:

   int tmp[4] = {0}

I'm not entirely sure about this though...)

> +     return tmp[0] + (tmp[1] << 8) + (tmp[2] << 16) + (tmp[3] << 24);

Indenting is wrong here: should be same as the previous lines.

Otherwise, the patch looks fine :-)

-antrik-



reply via email to

[Prev in Thread] Current Thread [Next in Thread]