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:	Thu, 12 Apr 2012 06:28:50 +0200
From:	Oleg Nesterov <oleg@...hat.com>
To:	Linus Torvalds <torvalds@...ux-foundation.org>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	David Howells <dhowells@...hat.com>,
	David Smith <dsmith@...hat.com>,
	"Frank Ch. Eigler" <fche@...hat.com>,
	Larry Woodman <lwoodman@...hat.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Tejun Heo <tj@...nel.org>, linux-kernel@...r.kernel.org
Subject: Re: hlist_for_each_entry && pos (Was: task_work_queue)

On 04/11, Linus Torvalds wrote:
>
> On Wed, Apr 11, 2012 at 9:00 PM, Oleg Nesterov <oleg@...hat.com> wrote:
> >
> > This reminds me.
> >
> > hlist_for_each_entry_*() do not need "pos", it can be
> >
> >        #define hlist_for_each_entry(pos, head, member)                                 \
> >                for (pos = (void*)(head)->first;                 �	\
> >                pos && ({ pos = hlist_entry((void*)pos, typeof(*pos), member); 1; });   \
> >                pos = (void*)(pos)->member.next)
>
> Ugh. I'm not sure that is any better, with the extra casts to hide the
> fact that you use the wrong type pointers for it.
>
> Are there any code generation improvements?

Not sure, I'll check...

> Because quite frankly, if there aren't, I think the code churn just
> isn't worth it - especially with how ugly the macro is.

Ah, personally I think that "how ugly the macro" doesn't matter.
What does matter (imho again), it simplifies the usage.

> This is one of those things where the C99 features would actually be
> nice: one of the few features from C++ that I actually liked is the
> ability to declare the induction variable. So
>
>   #define hlist_for_each_entry(pos, head, member) \
>     for (void *__pos = (head)->first; \

Agreed. But,

	error: 'for' loop initial declaration used outside C99 mode

we should change CFLAGS, I guess. BTW, personally I'd like very much
to use "for (type var; ...")" if this was allowed.

> That said, "pretty macro" isn't very high
> on the list of things to worry about. Not nearly as high as the pain
> changing the interface would cause for things that *should* be trivial
> (like backporting patches etc).

Yes, agreed, that was the question.

> So I'd really want to see some more tangible advantage.

OK, I'll check the code generation just in case.

Oleg.

--
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