lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 25 Mar 2008 11:29:43 +0000
From:	Ian Abbott <abbotti@....co.uk>
To:	Rob Landley <rob@...dley.net>
Cc:	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Corrections to Documentation/rbtree.txt

On 20/03/08 18:39, Rob Landley wrote:
> On Thursday 20 March 2008 10:29:57 Ian Abbott wrote:
>> From: Ian Abbott <abbotti@....co.uk>
>>
>> The description of the rb_entry() macro in Documentation/rbtree.txt seems
>> incorrect. This patch improves it (hopefully).  Also I changed the example
>> code to call the previous 'my_search()' example instead of an undefined
>> 'mysearch()'.
> 
> I have no objection to the patch (and the my_search thing seems like an 
> obvious typo), but is there a reason to prefer rb_entry() rather than 
> container_of()?  If so, the rationale might be a good thing to add to the 
> documentation...

I forgot to mention this in my earlier post, but while we're on the
subject, it might be worth renaming the 'node' variable in the
'my_search()' and iteration examples to avoid confusion in the use of
the rb_entry() (or container_of() macro), for example in 'my_search()',
instead of:

	struct rb_node *node = root->rb_node;

	while (node) {
		struct mytype *data = rb_entry(node, struct mytype, node);

I think this is clearer:

	struct rb_node *pn = root->rb_node;

	while (pn) {
		struct mytype *data = rb_entry(pn, struct mytype, node);

(I used rb_entry instead of container_of in the above.  Also, there are
probably better, longer variable names than 'pn', e.g. 'rbn' or 'rbnode'
or 'pnode'.)

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@....co.uk>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ