From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-2.9 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: clogger-public@bogomips.org Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 7F9571F4E1; Wed, 14 Jan 2015 02:34:13 +0000 (UTC) From: Eric Wong To: clogger-public@bogomips.org Cc: Eric Wong Subject: [PATCH] fix -Wshorten-64-to-32 warnings on 64-bit Date: Wed, 14 Jan 2015 02:34:08 +0000 Message-Id: <1421202848-16880-1-git-send-email-e@80x24.org> X-Mailer: git-send-email 2.2.1.269.g12c6725 List-Id: 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