* [PATCH] fixup -Wshorten-64-to-32 warnings
@ 2015-01-10 11:14 6% Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2015-01-10 11:14 UTC (permalink / raw)
To: kgio-public; +Cc: Eric Wong
These are emitted by clang on a Ubuntu Trusty amd64 system.
clang version 3.5-1ubuntu1 (trunk) (based on LLVM 3.5)
---
ext/kgio/poll.c | 2 +-
ext/kgio/writev.c | 50 +++++++++++++++++++++++++++++++-------------------
2 files changed, 32 insertions(+), 20 deletions(-)
diff --git a/ext/kgio/poll.c b/ext/kgio/poll.c
index 41bebf6..1f931e7 100644
--- a/ext/kgio/poll.c
+++ b/ext/kgio/poll.c
@@ -160,7 +160,7 @@ retry:
}
if (nr == 0) return Qnil;
- return poll_result(nr, a);
+ return poll_result((int)nr, a);
}
/*
diff --git a/ext/kgio/writev.c b/ext/kgio/writev.c
index aafc6d8..9a8030a 100644
--- a/ext/kgio/writev.c
+++ b/ext/kgio/writev.c
@@ -56,22 +56,22 @@ struct my_iovec {
* turns x/512 into x>>9 */
#define WRITEV_IMPL_THRESHOLD 512
-static unsigned int iov_max = 1024; /* this could be overriden in init */
+static int iov_max = 1024; /* this could be overriden in init */
struct wrv_args {
VALUE io;
VALUE buf;
VALUE vec_buf; /* FIXME: this requires RSTRING_MODIFY for rbx */
struct iovec *vec;
- unsigned long iov_cnt;
+ int iov_cnt;
size_t batch_len;
int something_written;
int fd;
};
-static ssize_t custom_writev(int fd, const struct iovec *vec, unsigned int iov_cnt, size_t total_len)
+static ssize_t custom_writev(int fd, const struct iovec *vec, int iov_cnt, size_t total_len)
{
- unsigned int i;
+ int i;
ssize_t result;
char *buf, *curbuf;
const struct iovec *curvec = vec;
@@ -113,12 +113,25 @@ static void prepare_writev(struct wrv_args *a, VALUE io, VALUE ary)
a->vec = NULL;
}
+#ifndef RARRAY_LENINT
+static inline int rarray_int(VALUE val)
+{
+ long num = RARRAY_LEN(val);
+
+ if ((long)(int)num != num)
+ rb_raise(rb_eRangeError, "%ld cannot to be an int", num);
+
+ return (int)num;
+}
+#define RARRAY_LENINT(n) rarray_int(n)
+#endif
+
static void fill_iovec(struct wrv_args *a)
{
- unsigned long i;
+ int i;
struct iovec *curvec;
- a->iov_cnt = RARRAY_LEN(a->buf);
+ a->iov_cnt = RARRAY_LENINT(a->buf);
a->batch_len = 0;
if (a->iov_cnt == 0) return;
if (a->iov_cnt > iov_max) a->iov_cnt = iov_max;
@@ -150,18 +163,18 @@ static void fill_iovec(struct wrv_args *a)
}
}
-static long trim_writev_buffer(struct wrv_args *a, long n)
+static long trim_writev_buffer(struct wrv_args *a, ssize_t n)
{
long i;
long ary_len = RARRAY_LEN(a->buf);
- if (n == (long)a->batch_len) {
+ if (n == (ssize_t)a->batch_len) {
i = a->iov_cnt;
n = 0;
} else {
for (i = 0; n && i < ary_len; i++) {
VALUE entry = rb_ary_entry(a->buf, i);
- n -= RSTRING_LEN(entry);
+ n -= (ssize_t)RSTRING_LEN(entry);
if (n < 0) break;
}
}
@@ -187,7 +200,8 @@ static long trim_writev_buffer(struct wrv_args *a, long n)
return RARRAY_LEN(a->buf);
}
-static int writev_check(struct wrv_args *a, long n, const char *msg, int io_wait)
+static long
+writev_check(struct wrv_args *a, ssize_t n, const char *msg, int io_wait)
{
if (n >= 0) {
if (n > 0) a->something_written = 1;
@@ -214,7 +228,7 @@ static int writev_check(struct wrv_args *a, long n, const char *msg, int io_wait
static VALUE my_writev(VALUE io, VALUE ary, int io_wait)
{
struct wrv_args a;
- long n;
+ ssize_t n;
prepare_writev(&a, io, ary);
set_nonblocking(a.fd);
@@ -224,15 +238,13 @@ static VALUE my_writev(VALUE io, VALUE ary, int io_wait)
if (a.iov_cnt == 0)
n = 0;
else if (a.iov_cnt == 1)
- n = (long)write(a.fd, a.vec[0].iov_base,
- a.vec[0].iov_len);
+ n = write(a.fd, a.vec[0].iov_base, a.vec[0].iov_len);
/* for big strings use library function */
else if (USE_WRITEV &&
- ((a.batch_len / WRITEV_IMPL_THRESHOLD) > a.iov_cnt))
- n = (long)writev(a.fd, a.vec, a.iov_cnt);
+ ((long)(a.batch_len/WRITEV_IMPL_THRESHOLD) > a.iov_cnt))
+ n = writev(a.fd, a.vec, a.iov_cnt);
else
- n = (long)custom_writev(a.fd, a.vec, a.iov_cnt,
- a.batch_len);
+ n = custom_writev(a.fd, a.vec, a.iov_cnt, a.batch_len);
} while (writev_check(&a, n, "writev", io_wait) != 0);
rb_str_resize(a.vec_buf, 0);
@@ -303,9 +315,9 @@ static VALUE s_trywritev(VALUE mod, VALUE io, VALUE ary)
void init_kgio_writev(void)
{
#ifdef IOV_MAX
- unsigned int sys_iov_max = IOV_MAX;
+ int sys_iov_max = IOV_MAX;
#else
- unsigned int sys_iov_max = sysconf(_SC_IOV_MAX);
+ int sys_iov_max = (int)sysconf(_SC_IOV_MAX);
#endif
VALUE mPipeMethods, mSocketMethods;
--
EW
^ permalink raw reply related [relevance 6%]
* [PATCH] kgio 2.9.3 - minor cleanups and fixes
@ 2015-01-12 8:50 7% Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2015-01-12 8:50 UTC (permalink / raw)
To: kgio-public
Most notably there's a new RB_GC_GUARD to fix an occasional segfault at
load time for Ruby 1.8 users thanks to Petr Novodvorskiy for reporting
the issue.
There's been a new mailing list for a few months now at:
kgio-public@bogomips.org
No subscription is required, but if you wish to subscribe
(existing librelist subscribers must resubscribe)
kgio-public+subscribe@bogomips.org
There's also a bunch of code cleanups and packaging
cleanups. Our website is faster now thanks to olddoc:
http://bogomips.org/kgio/
shortlog:
test/lib_read_write: fix trywritev blocking test
new mailing list info: kgio-public@bogomips.org
relax license to allow LGPLv2.1 or later
gemspec: modernize for more recent rubygems
doc: switch to olddoc
remove references to rubyforge and ancient Rubies
TODO: updates for the future of kgio
tryopen: add RB_GC_GUARD for Ruby 1.8
LICENSE: prefer URL to FSF address
cleanup packaging harder
fixup -Wshorten-64-to-32 warnings
cleanup: avoid shadowing rb_str_subseq
cleanup: avoid shadowing rb_ary_subseq
pkg.mk: synchronize with my other projects
gemspec: remove invalid rdoc_options
gemspec: use SPDX license abbreviation
---
GIT-VERSION-GEN | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 5cd7851..d0fbba7 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -1,7 +1,7 @@
#!/bin/sh
GVF=GIT-VERSION-FILE
-DEF_VER=v2.9.2
+DEF_VER=v2.9.3
LF='
'
--
EW
^ permalink raw reply related [relevance 7%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2015-01-10 11:14 6% [PATCH] fixup -Wshorten-64-to-32 warnings Eric Wong
2015-01-12 8:50 7% [PATCH] kgio 2.9.3 - minor cleanups and fixes Eric Wong
Code repositories for project(s) associated with this public inbox
https://yhbt.net/kgio.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).