{"thread":{"id":"33012","subject":"[PATCH 1/1] Fix unsigned time_t comparison","startedAt":"2013-02-25T21:51:16Z","lastAt":"2013-02-25T22:27:54Z","messageCount":3,"participants":["Mike Gorchak","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"210297","messageId":"CAHXAxrMZODO07_dPep-yKgrzD1228iSMGUXX06xkKDmoZF4+qA@mail.gmail.com","threadId":"33012","inReplyTo":null,"subject":"[PATCH 1/1] Fix unsigned time_t comparison","fromName":"Mike Gorchak","fromEmail":"mike.gorchak.qnx@gmail.com","sentAt":"2013-02-25T21:51:16Z","receivedAt":"2013-02-25T21:51:16Z","isPatch":true,"sender":{"key":"mike.gorchak.qnx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1337711?v=4"},"body":"Do not compare time_t (less comparison) with -1. If time_t\nis unsigned this leads to always true comparison.\n\nSigned-off-by: Mike Gorchak <mike.gorchak.qnx@gmail.com>\n---\n date.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/date.c b/date.c\nindex 57331ed..1ac28e5 100644\n--- a/date.c\n+++ b/date.c\n@@ -383,7 +383,7 @@ static int is_date(int year, int month, int day,\nstruct tm *now_tm, time_t now,\n \t\t * sense to specify timestamp way into the future.  Make\n \t\t * sure it is not later than ten days from now...\n \t\t */\n-\t\tif (now + 10*24*3600 < specified)\n+\t\tif ((specified != -1) && (now + 10*24*3600 < specified))\n \t\t\treturn 0;\n \t\ttm->tm_mon = r->tm_mon;\n \t\ttm->tm_mday = r->tm_mday;\n-- \n1.8.2-rc0\n"},{"id":"210301","messageId":"7vvc9gnixb.fsf@alter.siamese.dyndns.org","threadId":"33012","inReplyTo":"CAHXAxrMZODO07_dPep-yKgrzD1228iSMGUXX06xkKDmoZF4+qA@mail.gmail.com","subject":"Re: [PATCH 1/1] Fix unsigned time_t comparison","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-02-25T22:10:56Z","receivedAt":"2013-02-25T22:10:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Mike Gorchak <mike.gorchak.qnx@gmail.com> writes:\n\n> Do not compare time_t (less comparison) with -1. If time_t\n> is unsigned this leads to always true comparison.\n>\n> Signed-off-by: Mike Gorchak <mike.gorchak.qnx@gmail.com>\n> ---\n>  date.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/date.c b/date.c\n> index 57331ed..1ac28e5 100644\n> --- a/date.c\n> +++ b/date.c\n> @@ -383,7 +383,7 @@ static int is_date(int year, int month, int day,\n> struct tm *now_tm, time_t now,\n>  \t\t * sense to specify timestamp way into the future.  Make\n>  \t\t * sure it is not later than ten days from now...\n>  \t\t */\n> -\t\tif (now + 10*24*3600 < specified)\n> +\t\tif ((specified != -1) && (now + 10*24*3600 < specified))\n>  \t\t\treturn 0;\n>  \t\ttm->tm_mon = r->tm_mon;\n>  \t\ttm->tm_mday = r->tm_mday;\n\nThis is good enough band-aid for now (as it won't change the\nsemantics for anybody), but I suspect in the longer term we would\nwant to pick a different mechanims to signal errors, so that we can\nspecify timestamp that is before 1970.\n\nThanks, will queue.\n"},{"id":"210302","messageId":"7vmwusni51.fsf@alter.siamese.dyndns.org","threadId":"33012","inReplyTo":"CAHXAxrMZODO07_dPep-yKgrzD1228iSMGUXX06xkKDmoZF4+qA@mail.gmail.com","subject":"Re: [PATCH 1/1] Fix unsigned time_t comparison","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-02-25T22:27:54Z","receivedAt":"2013-02-25T22:27:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Mike Gorchak <mike.gorchak.qnx@gmail.com> writes:\n\n> Do not compare time_t (less comparison) with -1. If time_t\n> is unsigned this leads to always true comparison.\n>\n> Signed-off-by: Mike Gorchak <mike.gorchak.qnx@gmail.com>\n> ---\n>  date.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/date.c b/date.c\n> index 57331ed..1ac28e5 100644\n> --- a/date.c\n> +++ b/date.c\n> @@ -383,7 +383,7 @@ static int is_date(int year, int month, int day,\n> struct tm *now_tm, time_t now,\n\nLine-wrapped.  Will manually fix while applying.\n\nThanks.\n\n>  \t\t * sense to specify timestamp way into the future.  Make\n>  \t\t * sure it is not later than ten days from now...\n>  \t\t */\n> -\t\tif (now + 10*24*3600 < specified)\n> +\t\tif ((specified != -1) && (now + 10*24*3600 < specified))\n>  \t\t\treturn 0;\n>  \t\ttm->tm_mon = r->tm_mon;\n>  \t\ttm->tm_mday = r->tm_mday;\n"}]}