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

ruby-changes:39007

From: nobu <ko1@a...>
Date: Wed, 1 Jul 2015 17:18:14 +0900 (JST)
Subject: [ruby-changes:39007] nobu:r51088 (trunk): method.h: update argument checks

nobu	2015-07-01 17:18:03 +0900 (Wed, 01 Jul 2015)

  New Revision: 51088

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

  Log:
    method.h: update argument checks
    
    * method.h (METHOD_ENTRY_VISI_SET, METHOD_ENTRY_BASIC_SET),
      (METHOD_ENTRY_SAFE_SET, METHOD_ENTRY_FLAGS_SET): get rid of
      negative arguments, and safe leve is restricted to 1 now.

  Modified files:
    trunk/method.h
Index: method.h
===================================================================
--- method.h	(revision 51087)
+++ method.h	(revision 51088)
@@ -60,27 +60,27 @@ typedef struct rb_method_entry_struct { https://github.com/ruby/ruby/blob/trunk/method.h#L60
 static inline void
 METHOD_ENTRY_VISI_SET(rb_method_entry_t *me, rb_method_visibility_t visi)
 {
-    VM_ASSERT(visi <= 3);
+    VM_ASSERT(visi >= 0 && visi <= 3);
     me->flags = (me->flags & ~(IMEMO_FL_USER0 | IMEMO_FL_USER1)) | (visi << IMEMO_FL_USHIFT+0);
 }
 static inline void
-METHOD_ENTRY_BASIC_SET(rb_method_entry_t *me, int basic)
+METHOD_ENTRY_BASIC_SET(rb_method_entry_t *me, unsigned int basic)
 {
     VM_ASSERT(basic <= 1);
     me->flags = (me->flags & ~(IMEMO_FL_USER2                 )) | (basic << IMEMO_FL_USHIFT+2);
 }
 static inline void
-METHOD_ENTRY_SAFE_SET(rb_method_entry_t *me, int safe)
+METHOD_ENTRY_SAFE_SET(rb_method_entry_t *me, unsigned int safe)
 {
-    VM_ASSERT(safe <= 3);
+    VM_ASSERT(safe <= 1);
     me->flags = (me->flags & ~(IMEMO_FL_USER3 | IMEMO_FL_USER4)) | (safe << IMEMO_FL_USHIFT+3);
 }
 static inline void
-METHOD_ENTRY_FLAGS_SET(rb_method_entry_t *me, rb_method_visibility_t visi, int basic, int safe)
+METHOD_ENTRY_FLAGS_SET(rb_method_entry_t *me, rb_method_visibility_t visi, unsigned int basic, unsigned int safe)
 {
-    VM_ASSERT(visi <= 3);
+    VM_ASSERT(visi >= 0 && visi <= 3);
     VM_ASSERT(basic <= 1);
-    VM_ASSERT(safe <= 3);
+    VM_ASSERT(safe <= 1);
     me->flags =
       (me->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2|IMEMO_FL_USER3|IMEMO_FL_USER4)) |
 	((visi << IMEMO_FL_USHIFT+0) | (basic << (IMEMO_FL_USHIFT+2)) | (safe << IMEMO_FL_USHIFT+3));

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

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