On Thursday 21 May 2015 10:24:50 Baolin Wang wrote:
> > >
> > >  SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
> > >                 const struct timespec __user *, tp)
> > >  {
> > > +#ifdef CONFIG_64BIT
> > > +       struct timespec64 new_tp;
> > > +#else
> > >         struct timespec new_tp;
> > > +       struct timespec64 new_tp64;
> > > +#endif
> > >
> > >         if (copy_from_user(&new_tp, tp, sizeof (*tp)))
> > >                 return -EFAULT;
> > >
> > > +#ifdef CONFIG_64BIT
> > >         return __clock_settime(which_clock, &new_tp);
> > > +#else
> > > +       new_tp64 = timespec_to_timespec64(new_tp);
> > > +       return __clock_settime(which_clock, &new_tp64);
> > > +#endif
> > >  }
> >
> > Please just have two clock_settime functions wrapped by the ifdef
> > conditional. You should always try to avoid ifdefs inside of
> > functions.
> >
> 
> Thanks for your comments. I'll fix that to make it look easily.

I think it's best to do it the way I have in my patch series:
keep one __clock_settime() function that takes a timespec64
argument, but introduce a get_timespec64() function that
copies a __user timespec to a kernel timespec64. By copying
the two members individually with get_user(), you can avoid
the difference between 32-bit and 64-bit platforms.

        Arnd
_______________________________________________
Y2038 mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/y2038

Reply via email to