[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-
- Re: [PATCH 1/8] Update the parser to work with current XKB files., (continued)
- Re: [PATCH 1/8] Update the parser to work with current XKB files., olafBuddenhagen, 2010/08/11
- Re: [PATCH 1/8] Update the parser to work, Diego Nieto Cid, 2010/08/11
- [PATCH 1/5] Add type to $$ in mid-rules., Diego Nieto Cid, 2010/08/11
- [PATCH 2/5] Lexer support for keycodes with +/- symbols and arbitrary level numbers., Diego Nieto Cid, 2010/08/11
- [PATCH 3/5] Skip to main file's default section when needed., Diego Nieto Cid, 2010/08/11
- [PATCH 4/5] Update key type assigment routine., Diego Nieto Cid, 2010/08/11
- [PATCH 5/5] Recreate xkb/keymap/hurd from xkeyboard-config-1.8's xfree86 keymap., Diego Nieto Cid, 2010/08/11
[PATCH 4/8] Remove glue code and use mig to regenerate it., Diego Nieto Cid, 2010/08/04
[PATCH 3/8] Rule vmod returns an int with the vmod's bit on., Diego Nieto Cid, 2010/08/04
[PATCH 2/8] Avoid hashing garbage for short keynames., Diego Nieto Cid, 2010/08/04
- Re: [PATCH 2/8] Avoid hashing garbage for short keynames.,
olafBuddenhagen <=
[PATCH 5/8] Update code borrowed from console-client., Diego Nieto Cid, 2010/08/04
[PATCH 6/8] Add missing functions to input_driver_test., Diego Nieto Cid, 2010/08/04
[PATCH 7/8] Argument's default values are set independently., Diego Nieto Cid, 2010/08/04
[PATCH 8/8] Use vfprintf in debug_printf and write to stderr., Diego Nieto Cid, 2010/08/04