Re: [patch V2 02/38] posix-cpu-timers: Use common permission check in posix_cpu_clock_get()

From: Frederic Weisbecker
Date: Wed Aug 21 2019 - 19:40:30 EST


On Wed, Aug 21, 2019 at 09:08:49PM +0200, Thomas Gleixner wrote:
> Replace the next slightly different copy of permission checks. That also
> removes the necessarity to check the return value of the sample functions
> because the clock id is already validated.
>
> Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> ---
> kernel/time/posix-cpu-timers.c | 61 ++++++++++-------------------------------
> 1 file changed, 16 insertions(+), 45 deletions(-)
>
> --- a/kernel/time/posix-cpu-timers.c
> +++ b/kernel/time/posix-cpu-timers.c
> @@ -289,53 +289,24 @@ static int cpu_clock_sample_group(const
> return 0;
> }
>
> -static int posix_cpu_clock_get_task(struct task_struct *tsk,
> - const clockid_t which_clock,
> - struct timespec64 *tp)
> +static int posix_cpu_clock_get(const clockid_t clock, struct timespec64 *tp)
> {
> - int err = -EINVAL;
> - u64 rtn;
> + const clockid_t clkid = CPUCLOCK_WHICH(clock);

So I guess you later remove the CPUCLOCK_WHICH() from cpu_clock_sample*()
and turn them to void.

Reviewed-by: Frederic Weisbecker <frederic@xxxxxxxxxx>