clogger RubyGem user+dev discussion/patches/pulls/bugs/help
 help / Atom feed
* [PATCH] fix -Wshorten-64-to-32 warnings on 64-bit
@ 2015-01-14  2:34 Eric Wong
  0 siblings, 0 replies; 1+ messages in thread
From: Eric Wong @ 2015-01-14  2:34 UTC (permalink / raw)
  To: clogger-public; +Cc: Eric Wong

There's a related constification of a string format pointer
in there.

Tested on clang version 3.5-1ubuntu1 on x86-64
---
 ext/clogger_ext/clogger.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/ext/clogger_ext/clogger.c b/ext/clogger_ext/clogger.c
index 3db9235..aa7bdde 100644
--- a/ext/clogger_ext/clogger.c
+++ b/ext/clogger_ext/clogger.c
@@ -363,9 +363,9 @@ static void append_ts(struct clogger *c, VALUE op, struct timespec *ts)
 {
 	char buf[sizeof(".000000") + ((sizeof(ts->tv_sec) * 8) / 3)];
 	int nr;
-	char *fmt = RSTRING_PTR(rb_ary_entry(op, 1));
+	const char *fmt = RSTRING_PTR(rb_ary_entry(op, 1));
 	int ndiv = NUM2INT(rb_ary_entry(op, 2));
-	int usec = ts->tv_nsec / 1000;
+	int usec = (int)(ts->tv_nsec / 1000);
 
 	nr = snprintf(buf, sizeof(buf), fmt,
 		      (int)ts->tv_sec, (int)(usec / ndiv));
@@ -443,7 +443,7 @@ static void append_request_length(struct clogger *c)
 	}
 }
 
-static long local_gmtoffset(struct tm *tm)
+static int local_gmtoffset(struct tm *tm)
 {
 	time_t t = time(NULL);
 
@@ -455,7 +455,7 @@ static long local_gmtoffset(struct tm *tm)
  * HAVE_ST_TM_GMTOFF is defined ourselves.
  */
 #if defined(HAVE_STRUCT_TM_TM_GMTOFF) || defined(HAVE_ST_TM_GMTOFF)
-	return tm->tm_gmtoff / 60;
+	return (int)tm->tm_gmtoff / 60;
 #else
 	return -(tm->tm_isdst ? timezone - 3600 : timezone) / 60;
 #endif
@@ -466,7 +466,7 @@ static void append_time_iso8601(struct clogger *c)
 	char buf[sizeof("1970-01-01T00:00:00+00:00")];
 	struct tm tm;
 	int nr;
-	long gmtoff = local_gmtoffset(&tm);
+	int gmtoff = local_gmtoffset(&tm);
 
 	nr = snprintf(buf, sizeof(buf),
 	              "%4d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d",
@@ -487,7 +487,7 @@ static void append_time_local(struct clogger *c)
 	char buf[sizeof("01/Jan/1970:00:00:00 +0000")];
 	struct tm tm;
 	int nr;
-	long gmtoff = local_gmtoffset(&tm);
+	int gmtoff = local_gmtoffset(&tm);
 
 	nr = snprintf(buf, sizeof(buf),
 	              "%02d/%s/%d:%02d:%02d:%02d %c%02d%02d",
-- 
EW


^ permalink raw reply	[flat|nested] 1+ messages in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-14  2:34 [PATCH] fix -Wshorten-64-to-32 warnings on 64-bit Eric Wong

clogger RubyGem user+dev discussion/patches/pulls/bugs/help

Archives are clonable:
	git clone --mirror https://bogomips.org/clogger-public
	git clone --mirror http://ou63pmih66umazou.onion/clogger-public

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.clogger
	nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.clogger

 note: .onion URLs require Tor: https://www.torproject.org/
       or Tor2web: https://www.tor2web.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox