* Rusty Russell ([EMAIL PROTECTED]) wrote: > On Fri, 2007-08-24 at 12:26 -0400, Mathieu Desnoyers wrote: > > * Rusty Russell ([EMAIL PROTECTED]) wrote: > > > On Mon, 2007-08-20 at 16:27 -0400, Mathieu Desnoyers wrote: > > > > +{ > > > > + struct hlist_head *head; > > > > + struct hlist_node *node; > > > > + struct marker_entry *e; > > > > + size_t len = strlen(name) + 1; > > > > + u32 hash = jhash(name, len-1, 0); > > > > + > > > > + head = &marker_table[hash & ((1 << MARKER_HASH_BITS)-1)]; > > > > + hlist_for_each_entry(e, node, head, hlist) { > > > > + if (!strcmp(name, e->name)) > > > > + return e; > > > > + } > > > > + return NULL; > > > > +} > > > > > > OK, don't understand the strlen, len, len-1 dance here? > > > > > > > Let's say we have abc\0 for marker name as name input. > > > > len = 3 + 1 = 4 (including \0) > > hash is done only on the 3 first chars, excluding the \0 (therefore the > > len-1 there) > > > > Actually, it's like this only for a matter of consistency between > > add_marker and remove_marker, which are quite similar, but add_marker > > needs name_len to include the \0 value. It would be odd to change the > > logic between the two functions to one including the \0 and the other > > excluding it. > > Sure, but that doesn't really explain why the code does: > > size_t len = strlen(name) + 1; > u32 hash = jhash(name, len-1, 0); > > Rather than: > > u32 hash = jhash(name, strlen(name), 0); >
Yup, good point. Fixed. Thanks, Mathieu > > Thanks for the review, > > That's fine, just some light reading... > > Cheers, > Rusty. > > > -- Mathieu Desnoyers Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/