lkml.org 
[lkml]   [2005]   [Dec]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[patch 11/21] Create and use timespec_valid macro

    - add timespec_valid(ts) [returns false if the timespec is denorm]

    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

    include/linux/time.h | 6 ++++++
    kernel/posix-timers.c | 5 ++---
    2 files changed, 8 insertions(+), 3 deletions(-)

    Index: linux-2.6.15-rc5/include/linux/time.h
    ===================================================================
    --- linux-2.6.15-rc5.orig/include/linux/time.h
    +++ linux-2.6.15-rc5/include/linux/time.h
    @@ -44,6 +44,12 @@ extern unsigned long mktime(const unsign

    extern void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec);

    +/*
    + * Returns true if the timespec is norm, false if denorm:
    + */
    +#define timespec_valid(ts) \
    + (((ts)->tv_sec >= 0) && (((unsigned) (ts)->tv_nsec) < NSEC_PER_SEC))
    +
    extern struct timespec xtime;
    extern struct timespec wall_to_monotonic;
    extern seqlock_t xtime_lock;
    Index: linux-2.6.15-rc5/kernel/posix-timers.c
    ===================================================================
    --- linux-2.6.15-rc5.orig/kernel/posix-timers.c
    +++ linux-2.6.15-rc5/kernel/posix-timers.c
    @@ -712,8 +712,7 @@ out:
    */
    static int good_timespec(const struct timespec *ts)
    {
    - if ((!ts) || (ts->tv_sec < 0) ||
    - ((unsigned) ts->tv_nsec >= NSEC_PER_SEC))
    + if ((!ts) || !timespec_valid(ts))
    return 0;
    return 1;
    }
    @@ -1406,7 +1405,7 @@ sys_clock_nanosleep(const clockid_t whic
    if (copy_from_user(&t, rqtp, sizeof (struct timespec)))
    return -EFAULT;

    - if ((unsigned) t.tv_nsec >= NSEC_PER_SEC || t.tv_sec < 0)
    + if (!timespec_valid(&t))
    return -EINVAL;

    /*
    --

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-12-06 01:42    [W:0.021 / U:2.620 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site