git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/1] Fix unsigned time_t comparison

From
Mike Gorchak <mike.gorchak.qnx@gmail.com>
Date
Feb 25, 2013, 21:51 UTC
Message-ID
<CAHXAxrMZODO07_dPep-yKgrzD1228iSMGUXX06xkKDmoZF4+qA@mail.gmail.com>

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
Next: Junio C Hamano
Message 1 of 3 in “Fix unsigned time_t comparison”
  1. 1/1 Fix unsigned time_t comparisonMike Gorchak, Feb 25, 2013
  2. Junio C HamanoFeb 25, 2013
  3. Junio C HamanoFeb 25, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.