From cded7ea68256553cb51a298bf7db87ee03f8c886 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 20 Feb 2015 07:07:36 -0600 Subject: [PATCH] Fix some time value changes; mostly changing greater than 1000000000 to greater than or equal to 1000000000. From Juha Niskanen --- arch/arm/src/stm32/stm32_i2c.c | 4 ++-- arch/arm/src/stm32/stm32_i2c_alt.c | 4 ++-- arch/arm/src/stm32/stm32f30xxx_i2c.c | 4 ++-- arch/arm/src/tiva/tiva_i2c.c | 4 ++-- fs/vfs/fs_poll.c | 2 +- net/arp/arp_notify.c | 2 +- net/icmpv6/icmpv6_notify.c | 2 +- net/icmpv6/icmpv6_rnotify.c | 2 +- sched/mqueue/mq_timedreceive.c | 2 +- sched/mqueue/mq_timedsend.c | 2 +- sched/semaphore/sem_timedwait.c | 6 +++--- 11 files changed, 17 insertions(+), 17 deletions(-) diff --git a/arch/arm/src/stm32/stm32_i2c.c b/arch/arm/src/stm32/stm32_i2c.c index fdf94ed787..ce150fd3ae 100644 --- a/arch/arm/src/stm32/stm32_i2c.c +++ b/arch/arm/src/stm32/stm32_i2c.c @@ -638,7 +638,7 @@ static inline int stm32_i2c_sem_waitdone(FAR struct stm32_i2c_priv_s *priv) #ifdef CONFIG_STM32_I2C_DYNTIMEO abstime.tv_nsec += 1000 * stm32_i2c_tousecs(priv->msgc, priv->msgv); - if (abstime.tv_nsec > 1000 * 1000 * 1000) + if (abstime.tv_nsec >= 1000 * 1000 * 1000) { abstime.tv_sec++; abstime.tv_nsec -= 1000 * 1000 * 1000; @@ -646,7 +646,7 @@ static inline int stm32_i2c_sem_waitdone(FAR struct stm32_i2c_priv_s *priv) #elif CONFIG_STM32_I2CTIMEOMS > 0 abstime.tv_nsec += CONFIG_STM32_I2CTIMEOMS * 1000 * 1000; - if (abstime.tv_nsec > 1000 * 1000 * 1000) + if (abstime.tv_nsec >= 1000 * 1000 * 1000) { abstime.tv_sec++; abstime.tv_nsec -= 1000 * 1000 * 1000; diff --git a/arch/arm/src/stm32/stm32_i2c_alt.c b/arch/arm/src/stm32/stm32_i2c_alt.c index b1107aafe9..592fb32909 100755 --- a/arch/arm/src/stm32/stm32_i2c_alt.c +++ b/arch/arm/src/stm32/stm32_i2c_alt.c @@ -646,7 +646,7 @@ static int stm32_i2c_sem_waitdone(FAR struct stm32_i2c_priv_s *priv) #ifdef CONFIG_STM32_I2C_DYNTIMEO abstime.tv_nsec += 1000 * stm32_i2c_tousecs(priv->msgc, priv->msgv); - if (abstime.tv_nsec > 1000 * 1000 * 1000) + if (abstime.tv_nsec >= 1000 * 1000 * 1000) { abstime.tv_sec++; abstime.tv_nsec -= 1000 * 1000 * 1000; @@ -654,7 +654,7 @@ static int stm32_i2c_sem_waitdone(FAR struct stm32_i2c_priv_s *priv) #elif CONFIG_STM32_I2CTIMEOMS > 0 abstime.tv_nsec += CONFIG_STM32_I2CTIMEOMS * 1000 * 1000; - if (abstime.tv_nsec > 1000 * 1000 * 1000) + if (abstime.tv_nsec >= 1000 * 1000 * 1000) { abstime.tv_sec++; abstime.tv_nsec -= 1000 * 1000 * 1000; diff --git a/arch/arm/src/stm32/stm32f30xxx_i2c.c b/arch/arm/src/stm32/stm32f30xxx_i2c.c index 8118133c01..d9c29c7226 100644 --- a/arch/arm/src/stm32/stm32f30xxx_i2c.c +++ b/arch/arm/src/stm32/stm32f30xxx_i2c.c @@ -673,7 +673,7 @@ static inline int stm32_i2c_sem_waitdone(FAR struct stm32_i2c_priv_s *priv) #ifdef CONFIG_STM32_I2C_DYNTIMEO abstime.tv_nsec += 1000 * stm32_i2c_tousecs(priv->msgc, priv->msgv); - if (abstime.tv_nsec > 1000 * 1000 * 1000) + if (abstime.tv_nsec >= 1000 * 1000 * 1000) { abstime.tv_sec++; abstime.tv_nsec -= 1000 * 1000 * 1000; @@ -681,7 +681,7 @@ static inline int stm32_i2c_sem_waitdone(FAR struct stm32_i2c_priv_s *priv) #elif CONFIG_STM32_I2CTIMEOMS > 0 abstime.tv_nsec += CONFIG_STM32_I2CTIMEOMS * 1000 * 1000; - if (abstime.tv_nsec > 1000 * 1000 * 1000) + if (abstime.tv_nsec >= 1000 * 1000 * 1000) { abstime.tv_sec++; abstime.tv_nsec -= 1000 * 1000 * 1000; diff --git a/arch/arm/src/tiva/tiva_i2c.c b/arch/arm/src/tiva/tiva_i2c.c index fa6f05eb1d..9124993c0b 100644 --- a/arch/arm/src/tiva/tiva_i2c.c +++ b/arch/arm/src/tiva/tiva_i2c.c @@ -812,7 +812,7 @@ static inline int tiva_i2c_sem_waitdone(struct tiva_i2c_priv_s *priv) #ifdef CONFIG_TIVA_I2C_DYNTIMEO abstime.tv_nsec += 1000 * tiva_i2c_tousecs(priv->msgc, priv->msgv); - if (abstime.tv_nsec > 1000 * 1000 * 1000) + if (abstime.tv_nsec >= 1000 * 1000 * 1000) { abstime.tv_sec++; abstime.tv_nsec -= 1000 * 1000 * 1000; @@ -820,7 +820,7 @@ static inline int tiva_i2c_sem_waitdone(struct tiva_i2c_priv_s *priv) #elif CONFIG_TIVA_I2C_TIMEOMS > 0 abstime.tv_nsec += CONFIG_TIVA_I2C_TIMEOMS * 1000 * 1000; - if (abstime.tv_nsec > 1000 * 1000 * 1000) + if (abstime.tv_nsec >= 1000 * 1000 * 1000) { abstime.tv_sec++; abstime.tv_nsec -= 1000 * 1000 * 1000; diff --git a/fs/vfs/fs_poll.c b/fs/vfs/fs_poll.c index d968defb62..a471f655fb 100644 --- a/fs/vfs/fs_poll.c +++ b/fs/vfs/fs_poll.c @@ -327,7 +327,7 @@ int poll(FAR struct pollfd *fds, nfds_t nfds, int timeout) abstime.tv_sec += sec; abstime.tv_nsec += nsec; - if (abstime.tv_nsec > NSEC_PER_SEC) + if (abstime.tv_nsec >= NSEC_PER_SEC) { abstime.tv_sec++; abstime.tv_nsec -= NSEC_PER_SEC; diff --git a/net/arp/arp_notify.c b/net/arp/arp_notify.c index d2f4c06890..4326d23c17 100644 --- a/net/arp/arp_notify.c +++ b/net/arp/arp_notify.c @@ -187,7 +187,7 @@ int arp_wait(FAR struct arp_notify_s *notify, FAR struct timespec *timeout) abstime.tv_sec += timeout->tv_sec; abstime.tv_nsec += timeout->tv_nsec; - if (abstime.tv_nsec > 1000000000) + if (abstime.tv_nsec >= 1000000000) { abstime.tv_sec++; abstime.tv_nsec -= 1000000000; diff --git a/net/icmpv6/icmpv6_notify.c b/net/icmpv6/icmpv6_notify.c index 6c324d32df..2302b3b2a3 100644 --- a/net/icmpv6/icmpv6_notify.c +++ b/net/icmpv6/icmpv6_notify.c @@ -191,7 +191,7 @@ int icmpv6_wait(FAR struct icmpv6_notify_s *notify, abstime.tv_sec += timeout->tv_sec; abstime.tv_nsec += timeout->tv_nsec; - if (abstime.tv_nsec > 1000000000) + if (abstime.tv_nsec >= 1000000000) { abstime.tv_sec++; abstime.tv_nsec -= 1000000000; diff --git a/net/icmpv6/icmpv6_rnotify.c b/net/icmpv6/icmpv6_rnotify.c index 174c8c16a5..9a17677197 100644 --- a/net/icmpv6/icmpv6_rnotify.c +++ b/net/icmpv6/icmpv6_rnotify.c @@ -287,7 +287,7 @@ int icmpv6_rwait(FAR struct icmpv6_rnotify_s *notify, abstime.tv_sec += timeout->tv_sec; abstime.tv_nsec += timeout->tv_nsec; - if (abstime.tv_nsec > 1000000000) + if (abstime.tv_nsec >= 1000000000) { abstime.tv_sec++; abstime.tv_nsec -= 1000000000; diff --git a/sched/mqueue/mq_timedreceive.c b/sched/mqueue/mq_timedreceive.c index ef9f0b6a5a..858d9a3bf4 100644 --- a/sched/mqueue/mq_timedreceive.c +++ b/sched/mqueue/mq_timedreceive.c @@ -198,7 +198,7 @@ ssize_t mq_timedreceive(mqd_t mqdes, FAR char *msg, size_t msglen, return ERROR; } - if (!abstime || abstime->tv_sec < 0 || abstime->tv_nsec > 1000000000) + if (!abstime || abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) { set_errno(EINVAL); return ERROR; diff --git a/sched/mqueue/mq_timedsend.c b/sched/mqueue/mq_timedsend.c index a5aa11c840..e144956491 100644 --- a/sched/mqueue/mq_timedsend.c +++ b/sched/mqueue/mq_timedsend.c @@ -200,7 +200,7 @@ int mq_timedsend(mqd_t mqdes, FAR const char *msg, size_t msglen, int prio, return ERROR; } - if (!abstime || abstime->tv_sec < 0 || abstime->tv_nsec > 1000000000) + if (!abstime || abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) { set_errno(EINVAL); return ERROR; diff --git a/sched/semaphore/sem_timedwait.c b/sched/semaphore/sem_timedwait.c index 1ac69e68bf..b7d8507286 100644 --- a/sched/semaphore/sem_timedwait.c +++ b/sched/semaphore/sem_timedwait.c @@ -147,7 +147,7 @@ static void sem_timeout(int argc, uint32_t pid) * abstime - The absolute time to wait until a timeout is declared. * * Return Value: - * One success, the length of the selected message in bytes.is + * One success, the length of the selected message in bytes is * returned. On failure, -1 (ERROR) is returned and the errno * is set appropriately: * @@ -198,7 +198,7 @@ int sem_timedwait(FAR sem_t *sem, FAR const struct timespec *abstime) /* We will disable interrupts until we have completed the semaphore * wait. We need to do this (as opposed to just disabling pre-emption) - * because there could be interrupt handlers that are asynchronoulsy + * because there could be interrupt handlers that are asynchronously * posting semaphores and to prevent race conditions with watchdog * timeout. This is not too bad because interrupts will be re- * enabled while we are blocked waiting for the semaphore. @@ -223,7 +223,7 @@ int sem_timedwait(FAR sem_t *sem, FAR const struct timespec *abstime) * with a valid timeout. */ - if (abstime->tv_sec < 0 || abstime->tv_nsec > 1000000000) + if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) { err = EINVAL; goto errout_disabled;