[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140123192403.GA5823@madcap2.tricolour.ca>
Date: Thu, 23 Jan 2014 14:24:03 -0500
From: Richard Guy Briggs <rgb@...hat.com>
To: Oleg Nesterov <oleg@...hat.com>
Cc: akpm@...ux-foundation.org, Peter Zijlstra <peterz@...radead.org>,
linux-audit@...hat.com, linux-kernel@...r.kernel.org,
Eric Paris <eparis@...hat.com>
Subject: Re: [PATCH] pid: change task_struct::pid to read-only
On 13/12/22, Oleg Nesterov wrote:
> On 12/20, Peter Zijlstra wrote:
> >
> > On Fri, Dec 20, 2013 at 08:01:57PM +0100, Oleg Nesterov wrote:
> > > The only problem is that
> > >
> > > #define ASSIGN_CONST(l, r) (*(typeof(r) *)&(l) = (r))
> > >
> > > obviously can't work in this case ;) We need something more clever.
> >
> > Hmm indeed, C++ has both the const_cast<>() thingy and the template
> > system is powerful enough to actually implement const_cast<>() inside
> > the language.
>
> So, how about
>
> #define CONST_CAST(type, lval) \
> (*({ \
> (void)((type *)0 == &(lval)); \
> (type *)&(lval); \
> })) \
>
> de_thread/copy_process can do
>
> CONST_CAST(pid_t, tsk->pid) = leader->pid;
>
> and if "type" is wrong we have a warning.
Cool. This works very nicely. Thanks for the ideas Oleg!
> Oleg.
- RGB
--
Richard Guy Briggs <rbriggs@...hat.com>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat
Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545
--
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