* [PATCH 1/1] Fix unsigned time_t comparison
@ 2013-02-25 21:51 Mike Gorchak
2013-02-25 22:10 ` Junio C Hamano
2013-02-25 22:27 ` Junio C Hamano
0 siblings, 2 replies; 3+ messages in thread
From: Mike Gorchak @ 2013-02-25 21:51 UTC (permalink / raw)
To: git
Do not compare time_t (less comparison) with -1. If time_t
is unsigned this leads to always true comparison.
Signed-off-by: Mike Gorchak <mike.gorchak.qnx@gmail.com>
---
date.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/date.c b/date.c
index 57331ed..1ac28e5 100644
--- a/date.c
+++ b/date.c
@@ -383,7 +383,7 @@ static int is_date(int year, int month, int day,
struct tm *now_tm, time_t now,
* sense to specify timestamp way into the future. Make
* sure it is not later than ten days from now...
*/
- if (now + 10*24*3600 < specified)
+ if ((specified != -1) && (now + 10*24*3600 < specified))
return 0;
tm->tm_mon = r->tm_mon;
tm->tm_mday = r->tm_mday;
--
1.8.2-rc0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] Fix unsigned time_t comparison
2013-02-25 21:51 [PATCH 1/1] Fix unsigned time_t comparison Mike Gorchak
@ 2013-02-25 22:10 ` Junio C Hamano
2013-02-25 22:27 ` Junio C Hamano
1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2013-02-25 22:10 UTC (permalink / raw)
To: Mike Gorchak; +Cc: git
Mike Gorchak <mike.gorchak.qnx@gmail.com> writes:
> Do not compare time_t (less comparison) with -1. If time_t
> is unsigned this leads to always true comparison.
>
> Signed-off-by: Mike Gorchak <mike.gorchak.qnx@gmail.com>
> ---
> date.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/date.c b/date.c
> index 57331ed..1ac28e5 100644
> --- a/date.c
> +++ b/date.c
> @@ -383,7 +383,7 @@ static int is_date(int year, int month, int day,
> struct tm *now_tm, time_t now,
> * sense to specify timestamp way into the future. Make
> * sure it is not later than ten days from now...
> */
> - if (now + 10*24*3600 < specified)
> + if ((specified != -1) && (now + 10*24*3600 < specified))
> return 0;
> tm->tm_mon = r->tm_mon;
> tm->tm_mday = r->tm_mday;
This is good enough band-aid for now (as it won't change the
semantics for anybody), but I suspect in the longer term we would
want to pick a different mechanims to signal errors, so that we can
specify timestamp that is before 1970.
Thanks, will queue.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] Fix unsigned time_t comparison
2013-02-25 21:51 [PATCH 1/1] Fix unsigned time_t comparison Mike Gorchak
2013-02-25 22:10 ` Junio C Hamano
@ 2013-02-25 22:27 ` Junio C Hamano
1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2013-02-25 22:27 UTC (permalink / raw)
To: Mike Gorchak; +Cc: git
Mike Gorchak <mike.gorchak.qnx@gmail.com> writes:
> Do not compare time_t (less comparison) with -1. If time_t
> is unsigned this leads to always true comparison.
>
> Signed-off-by: Mike Gorchak <mike.gorchak.qnx@gmail.com>
> ---
> date.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/date.c b/date.c
> index 57331ed..1ac28e5 100644
> --- a/date.c
> +++ b/date.c
> @@ -383,7 +383,7 @@ static int is_date(int year, int month, int day,
> struct tm *now_tm, time_t now,
Line-wrapped. Will manually fix while applying.
Thanks.
> * sense to specify timestamp way into the future. Make
> * sure it is not later than ten days from now...
> */
> - if (now + 10*24*3600 < specified)
> + if ((specified != -1) && (now + 10*24*3600 < specified))
> return 0;
> tm->tm_mon = r->tm_mon;
> tm->tm_mday = r->tm_mday;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-02-25 22:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-25 21:51 [PATCH 1/1] Fix unsigned time_t comparison Mike Gorchak
2013-02-25 22:10 ` Junio C Hamano
2013-02-25 22:27 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox