[前][次][番号順一覧][スレッド一覧]

ruby-changes:42932

From: nobu <ko1@a...>
Date: Sun, 15 May 2016 12:03:55 +0900 (JST)
Subject: [ruby-changes:42932] nobu:r55006 (trunk): random.c: suppress a warning

nobu	2016-05-15 12:03:45 +0900 (Sun, 15 May 2016)

  New Revision: 55006

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55006

  Log:
    random.c: suppress a warning
    
    * random.c (random_ulong_limited): suppress a shift count warning
      when unsigned long is 32bits.

  Modified files:
    trunk/random.c
Index: random.c
===================================================================
--- random.c	(revision 55005)
+++ random.c	(revision 55006)
@@ -991,7 +991,11 @@ random_ulong_limited(VALUE obj, rb_rando https://github.com/ruby/ruby/blob/trunk/random.c#L991
 	const int w = sizeof(limit) * CHAR_BIT - nlz_long(limit);
 	const int n = w > 32 ? sizeof(unsigned long) : sizeof(uint32_t);
 	const unsigned long mask = ~(~0UL << w);
-	const unsigned long full = ~(~0UL << n * CHAR_BIT);
+	const unsigned long full =
+#if SIZEOF_LONG == 4
+	    (size_t)n >= sizeof(unsigned long) ? ~0UL :
+#endif
+	    ~(~0UL << n * CHAR_BIT);
 	unsigned long val, bits = 0, rest = 0;
 	do {
 	    if (mask & ~rest) {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]