bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 04/14] proc: turn count_up and store_pid into normal function


From: Samuel Thibault
Subject: Re: [PATCH 04/14] proc: turn count_up and store_pid into normal functions
Date: Sat, 9 Nov 2013 18:55:58 +0100
User-agent: Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30)

Justus Winter, le Fri 08 Nov 2013 21:24:12 +0100, a écrit :
> Previously count_up and store_pid were defined inside
> S_proc_getallpids. Move them out of that function and declare them
> static.
> 
> * proc/mgt.c: Turn count_up and store_pid into normal functions.
> ---
>  proc/mgt.c |   24 +++++++++++++++---------
>  1 file changed, 15 insertions(+), 9 deletions(-)
> 
> diff --git a/proc/mgt.c b/proc/mgt.c
> index d7ad296..4da2216 100644
> --- a/proc/mgt.c
> +++ b/proc/mgt.c
> @@ -514,6 +514,9 @@ S_proc_exception_raise (mach_port_t excport,
>  
>  }
>  
> +static void count_up (struct proc *, void *);
> +static void store_pid (struct proc *, void *);

Here as well: why not putting the functions definitions here instead of
forward declarations?

In this case, nesting the function is indeed not useful, except limiting
its visibility even more. I'd be OK with unnesting it.

>  /* Implement proc_getallpids as described in <hurd/process.defs>. */
>  kern_return_t
>  S_proc_getallpids (struct proc *p,
> @@ -523,15 +526,6 @@ S_proc_getallpids (struct proc *p,
>    int nprocs;
>    pid_t *loc;
>  
> -  void count_up (struct proc *p, void *counter)
> -    {
> -      ++*(int *)counter;
> -    }
> -  void store_pid (struct proc *p, void *loc)
> -    {
> -      *(*(pid_t **)loc)++ = p->p_pid;
> -    }
> -
>    /* No need to check P here; we don't use it. */
>  
>    add_tasks (0);
> @@ -553,6 +547,18 @@ S_proc_getallpids (struct proc *p,
>    *pidslen = nprocs;
>    return 0;
>  }
> +
> +void
> +count_up (struct proc *p, void *counter)
> +{
> +  ++*(int *)counter;
> +}
> +
> +void
> +store_pid (struct proc *p, void *loc)
> +{
> +  *(*(pid_t **)loc)++ = p->p_pid;
> +}
>  
>  /* Create a process for TASK, which is not otherwise known to us.
>     The PID/parentage/job-control fields are not yet filled in,
> -- 
> 1.7.10.4
> 
> 

-- 
Samuel
j'etais en train de nettoyer ma souris et le coup est parti...
 -+- s sur #ens-mim - et en plus c vrai... -+-



reply via email to

[Prev in Thread] Current Thread [Next in Thread]