diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-17 08:50:01 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-17 08:50:01 +0000 |
commit | 1efb3c31b731e99627bbc0da13dfd3463bb67c67 (patch) | |
tree | f6258144a4e2509c34fac5fcda8291547951b4dc /time.c | |
parent | 0f67a3bb3171c98770c7a5de8559636d2551a3b8 (diff) |
* Avoid undefined behaviors found by gcc -fsanitize=undefined.
gcc (Debian 4.9.1-16) 4.9.1
* include/ruby/ruby.h (INT2FIX): Avoid undefined behavior.
* node.h (nd_set_line): Ditto.
* pack.c (encodes): Ditto.
(pack_unpack): Ditto.
* regint.h (BIT_STATUS_AT): Ditto.
(BS_BIT): Ditto.
* time.c (time_mdump): Ditto.
(time_mload): Ditto.
* vm_core.h (VM_FRAME_MAGIC_MASK): Ditto.
* vm_trace.c (recalc_add_ruby_vm_event_flags): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r-- | time.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -4653,7 +4653,7 @@ time_mdump(VALUE time) (vtm.mon-1) << 10 | /* 4 */ vtm.mday << 5 | /* 5 */ vtm.hour; /* 5 */ - s = vtm.min << 26 | /* 6 */ + s = (unsigned long)vtm.min << 26 | /* 6 */ vtm.sec << 20 | /* 6 */ usec; /* 20 */ @@ -4766,10 +4766,10 @@ time_mload(VALUE time, VALUE str) p = s = 0; for (i=0; i<4; i++) { - p |= buf[i]<<(8*i); + p |= (unsigned long)buf[i]<<(8*i); } for (i=4; i<8; i++) { - s |= buf[i]<<(8*(i-4)); + s |= (unsigned long)buf[i]<<(8*(i-4)); } if ((p & (1UL<<31)) == 0) { |