From: Eric Wong <e@80x24.org>
To: clogger-public@bogomips.org
Cc: Eric Wong <e@80x24.org>
Subject: [PATCH] fix -Wshorten-64-to-32 warnings on 64-bit
Date: Wed, 14 Jan 2015 02:34:08 +0000 [thread overview]
Message-ID: <1421202848-16880-1-git-send-email-e@80x24.org> (raw)
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
reply other threads:[~2015-01-14 2:34 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
List information: https://yhbt.net/clogger/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1421202848-16880-1-git-send-email-e@80x24.org \
--to=e@80x24.org \
--cc=clogger-public@bogomips.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.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/clogger.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).