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

time casts

From
JWJason Wright <jason@thought.net>
Date
Jun 15, 2005, 15:30 UTC
Message-ID
<20050615153058.GD12393@thought.net>

In porting cogito/git 0.11.3 to OpenBSD, I ran into casts of time_t warnings for the printfs below. I think the warnings are harmless, but the patch below fixes 'em.

--Jason L. Wright

--- date.c.orig Wed Jun 15 11:21:00 2005 +++ date.c Wed Jun 15 11:21:30 2005

@@ -438,7 +438,8 @@ void parse_date(char *date, char *result
 		sign = '-';
 	}
 
-	snprintf(result, maxlen, "%lu %c%02d%02d", then, sign, offset/60, offset % 60);
+	snprintf(result, maxlen, "%lu %c%02d%02d", (unsigned long)then,
+	    sign, offset/60, offset % 60);
 }
 
 void datestamp(char *buf, int bufsize)
@@ -451,5 +452,6 @@ void datestamp(char *buf, int bufsize)
 	offset = my_mktime(localtime(&now)) - now;
 	offset /= 60;
 
-	snprintf(buf, bufsize, "%lu %+05d", now, offset/60*100 + offset%60);
+	snprintf(buf, bufsize, "%lu %+05d", (unsigned long)now,
+	    offset/60*100 + offset%60);
 }
--- tar-tree.c.orig	Wed Jun 15 11:24:07 2005
+++ tar-tree.c	Wed Jun 15 11:24:55 2005
@@ -318,7 +318,7 @@ static void write_header(const unsigned 
 	if (S_ISDIR(mode) || S_ISLNK(mode))
 		size = 0;
 	sprintf(&header[124], "%011lo", size);
-	sprintf(&header[136], "%011lo", archive_time);
+	sprintf(&header[136], "%011lo", (unsigned)archive_time);
 
 	header[156] = typeflag;
 
Message 1 of 1 in “time casts”
  1. Jason WrightJun 15, 2005

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.