Subject: Re: code in kern_proc.c
To: None <tech-kern@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: tech-kern
Date: 12/22/2003 17:50:41
In article <006501c3c8ae$56799860$3964a8c0@ianzag>,
Ian Zagorskih <ianzag@megasignal.com> wrote:
>
>Hey all,
>
>Just a cut from /sys/kern/kern_proc.c
>
>--- cut ---
>/*
> * Locate a process by number
> */
>struct proc *
>pfind(pid)
>    pid_t pid;
>{
>    struct proc *p;
>
>    proclist_lock_read();
>    for (p = PIDHASH(pid)->lh_first; p != 0; p = p->p_hash.le_next)
>        if (p->p_pid == pid)
>            goto out;
>out:
>    proclist_unlock_read();
>    return (p);
>}
>
>--- cut ---
>
>I'm wondering if this "goto out" is really required here ? I.e. isn't code
>like:
>
>for (p = PIDHASH(pid)->lh_first; p != 0; p = p->p_hash.le_next)
>    if (p->p_pid == pid) break;
>
>..does the same ? I'm not complaining about "goto is bad || good" just
>wondering if i'm missing something and this goto really does smth that break
>cannot :)

Yes it does the same, and should be preferred in this case. OTOH, we don't
have such code anymore in kern_proc.c

christos