sleepy_penguin RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* [PATCH] fix 64-to-32-bit truncation warning
@ 2018-12-08 17:36 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2018-12-08 17:36 UTC (permalink / raw)
  To: sleepy-penguin; +Cc: Eric Wong

4GB thread-local-storage should be enough for anyone, right?
---
 ext/sleepy_penguin/init.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/ext/sleepy_penguin/init.c b/ext/sleepy_penguin/init.c
index 27aada4..76fa77a 100644
--- a/ext/sleepy_penguin/init.c
+++ b/ext/sleepy_penguin/init.c
@@ -101,15 +101,13 @@ static struct rb_sp_tlsbuf *alloc_tlsbuf(size_t size)
 	size_t bytes = size + sizeof(struct rb_sp_tlsbuf);
 	struct rb_sp_tlsbuf *buf;
 	void *ptr;
-	int err = posix_memalign(&ptr, rb_sp_l1_cache_line_size, bytes);
 
-	if (err) {
-		errno = err;
+	if (size >= UINT32_MAX ||
+	    posix_memalign(&ptr, rb_sp_l1_cache_line_size, bytes))
 		rb_memerror(); /* fatal */
-	}
 
 	buf = ptr;
-	buf->capa = size;
+	buf->capa = (uint32_t)size;
 
 	return buf;
 }
-- 
EW


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-12-08 17:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-08 17:36 [PATCH] fix 64-to-32-bit truncation warning Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/sleepy_penguin.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).