All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wright <jason@thought.net>
To: git@vger.kernel.org
Subject: time casts
Date: Wed, 15 Jun 2005 11:30:59 -0400	[thread overview]
Message-ID: <20050615153058.GD12393@thought.net> (raw)

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;
 

                 reply	other threads:[~2005-06-15 15:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050615153058.GD12393@thought.net \
    --to=jason@thought.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.