Permalink
Browse files

* vm.c (backtrace_*): change type of lev and n from size_t to int.

  Also set type of rb_backtrace_t#backtrace_size to int.
  A patch from nobu.
* vm_eval.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent 5212b7f commit ec187ff8473f3c2091253496595b515ea59d2ec0 @ko1 ko1 committed May 26, 2012
Showing with 22 additions and 10 deletions.
  1. +8 −0 ChangeLog
  2. +12 −8 vm.c
  3. +2 −2 vm_eval.c
View
8 ChangeLog
@@ -1,3 +1,11 @@
+Sat May 26 17:05:45 2012 Koichi Sasada <ko1@atdot.net>
+
+ * vm.c (backtrace_*): change type of lev and n from size_t to int.
+ Also set type of rb_backtrace_t#backtrace_size to int.
+ A patch from nobu.
+
+ * vm_eval.c: ditto.
+
Sat May 26 16:26:30 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (realpath_rec): UNC prefix does not end with path separator,
View
20 vm.c
@@ -1026,7 +1026,7 @@ frame_info_to_str_m(VALUE self)
typedef struct rb_backtrace_struct {
rb_frame_info_t *backtrace;
rb_frame_info_t *backtrace_base;
- size_t backtrace_size;
+ int backtrace_size;
VALUE strary;
} rb_backtrace_t;
@@ -1198,9 +1198,13 @@ backtreace_collect(rb_backtrace_t *bt, int lev, int n, VALUE (*func)(rb_frame_in
VALUE btary;
int i;
+ if (UNLIKELY(lev < 0 || n < 0)) {
+ rb_bug("backtreace_collect: unreachable");
+ }
+
btary = rb_ary_new();
- for (i=0; i+lev<(int)bt->backtrace_size && i<n; i++) {
+ for (i=0; i+lev<bt->backtrace_size && i<n; i++) {
rb_frame_info_t *fi = &bt->backtrace[bt->backtrace_size - 1 - (lev+i)];
rb_ary_push(btary, func(fi, arg));
}
@@ -1230,10 +1234,10 @@ rb_backtrace_to_str_ary(VALUE self)
}
static VALUE
-backtrace_to_str_ary2(VALUE self, size_t lev, size_t n)
+backtrace_to_str_ary2(VALUE self, int lev, int n)
{
rb_backtrace_t *bt;
- size_t size;
+ int size;
GetCoreDataFromValue(self, rb_backtrace_t, bt);
size = bt->backtrace_size;
@@ -1261,10 +1265,10 @@ frame_info_create(rb_frame_info_t *srcfi, void *btobj)
}
static VALUE
-backtrace_to_frame_ary(VALUE self, size_t lev, size_t n)
+backtrace_to_frame_ary(VALUE self, int lev, int n)
{
rb_backtrace_t *bt;
- size_t size;
+ int size;
GetCoreDataFromValue(self, rb_backtrace_t, bt);
size = bt->backtrace_size;
@@ -1295,13 +1299,13 @@ backtrace_load_data(VALUE self, VALUE str)
}
static VALUE
-vm_backtrace_str_ary(rb_thread_t *th, size_t lev, size_t n)
+vm_backtrace_str_ary(rb_thread_t *th, int lev, int n)
{
return backtrace_to_str_ary2(backtrace_object(th), lev, n);
}
static VALUE
-vm_backtrace_frame_ary(rb_thread_t *th, size_t lev, size_t n)
+vm_backtrace_frame_ary(rb_thread_t *th, int lev, int n)
{
return backtrace_to_frame_ary(backtrace_object(th), lev, n);
}
View
4 vm_eval.c
@@ -20,8 +20,8 @@ static VALUE vm_exec(rb_thread_t *th);
static void vm_set_eval_stack(rb_thread_t * th, VALUE iseqval, const NODE *cref);
static int vm_collect_local_variables_in_heap(rb_thread_t *th, VALUE *dfp, VALUE ary);
-static VALUE vm_backtrace_str_ary(rb_thread_t *th, size_t lev, size_t n);
-static VALUE vm_backtrace_frame_ary(rb_thread_t *th, size_t lev, size_t n);
+static VALUE vm_backtrace_str_ary(rb_thread_t *th, int lev, int n);
+static VALUE vm_backtrace_frame_ary(rb_thread_t *th, int lev, int n);
static void vm_backtrace_print(FILE *fp);
typedef enum call_type {

0 comments on commit ec187ff

Please sign in to comment.