lkml.org 
[lkml]   [2013]   [Dec]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] pid: change task_struct::pid to read-only
    Richard, Peter,

    sorry I deleted your emails by accident, so I am replying to my email.

    Sure, ASSIGN_CONST() looks "dangerous". Still to me it is safer than
    "(pid_t*)&(tsk->pid)" done by hand. And yes, it is visible to grep.

    But the main point, it is much more readable. Just look at the change
    below,

    On 12/17, Oleg Nesterov wrote:
    >
    > > > if (!thread_group_leader(tsk)) {
    > > > struct task_struct *leader = tsk->group_leader;
    > > > + /* tast_struct::pid is const pid_t, hence the ugly cast */
    > > > + pid_t *pid_p = (pid_t*)&(tsk->pid);
    > > >
    > > > sig->notify_count = -1; /* for exit_notify() */
    > > > for (;;) {
    > > > @@ -950,7 +952,7 @@ static int de_thread(struct task_struct *tsk)
    > > > * Note: The old leader also uses this pid until release_task
    > > > * is called. Odd but simple and correct.
    > > > */
    > > > - tsk->pid = leader->pid;
    > > > + *pid_p = leader->pid;

    Isn't it ugly to add the temporary? And this temporary is the pointer.
    ASSIGN_CONST(task->pid, leader->pid) is self-documenting and clear.

    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.

    Oleg.



    \
     
     \ /
      Last update: 2013-12-20 20:21    [W:8.142 / U:0.164 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site