summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-04-08 16:06:30 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-04-08 16:28:38 +0900
commitd8720eb7de9cd9d874b621f214c27022e17cc941 (patch)
treea0a448d47f614493d8a6bb9aabaca9a7cf9870e7
parent6163a4e1b33ed7df27d0c37e835ce04407857a16 (diff)
Suppress -Wshorten-64-to-32 warnings
-rw-r--r--ext/bigdecimal/bigdecimal.c10
-rw-r--r--ext/digest/digest.c6
-rw-r--r--ext/etc/etc.c4
-rw-r--r--ext/openssl/ossl_ssl.c2
-rw-r--r--ext/psych/psych.c6
-rw-r--r--ext/psych/psych_parser.c34
-rw-r--r--ext/strscan/strscan.c6
-rw-r--r--spec/ruby/optional/capi/ext/numeric_spec.c2
8 files changed, 35 insertions, 35 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 7ac883730db..ecd43fdc5c6 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -343,8 +343,8 @@ BigDecimal_prec(VALUE self)
VALUE obj;
GUARD_OBJ(p, GetVpValue(self, 1));
- obj = rb_assoc_new(INT2NUM(p->Prec*VpBaseFig()),
- INT2NUM(p->MaxPrec*VpBaseFig()));
+ obj = rb_assoc_new(SIZET2NUM(p->Prec*VpBaseFig()),
+ SIZET2NUM(p->MaxPrec*VpBaseFig()));
return obj;
}
@@ -2132,7 +2132,7 @@ BigDecimal_split(VALUE self)
rb_ary_push(obj, str);
rb_str_resize(str, strlen(psz1));
rb_ary_push(obj, INT2FIX(10));
- rb_ary_push(obj, INT2NUM(e));
+ rb_ary_push(obj, SSIZET2NUM(e));
return obj;
}
@@ -2145,7 +2145,7 @@ static VALUE
BigDecimal_exponent(VALUE self)
{
ssize_t e = VpExponent10(GetVpValue(self, 1));
- return INT2NUM(e);
+ return SSIZET2NUM(e);
}
/* Returns a string representation of self.
@@ -2765,7 +2765,7 @@ static VALUE
BigDecimal_limit(int argc, VALUE *argv, VALUE self)
{
VALUE nFig;
- VALUE nCur = INT2NUM(VpGetPrecLimit());
+ VALUE nCur = SIZET2NUM(VpGetPrecLimit());
if (rb_scan_args(argc, argv, "01", &nFig) == 1) {
int nf;
diff --git a/ext/digest/digest.c b/ext/digest/digest.c
index a59f880ac7e..cde0dfa0058 100644
--- a/ext/digest/digest.c
+++ b/ext/digest/digest.c
@@ -406,7 +406,7 @@ rb_digest_instance_digest_length(VALUE self)
/* never blindly assume that #digest() returns a string */
StringValue(digest);
- return INT2NUM(RSTRING_LEN(digest));
+ return LONG2NUM(RSTRING_LEN(digest));
}
/*
@@ -725,7 +725,7 @@ rb_digest_base_digest_length(VALUE self)
algo = get_digest_obj_metadata(self);
- return INT2NUM(algo->digest_len);
+ return SIZET2NUM(algo->digest_len);
}
/*
@@ -740,7 +740,7 @@ rb_digest_base_block_length(VALUE self)
algo = get_digest_obj_metadata(self);
- return INT2NUM(algo->block_len);
+ return SIZET2NUM(algo->block_len);
}
void
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index 3bad435a19c..d57c26555b8 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -142,7 +142,7 @@ setup_passwd(struct passwd *pwd)
safe_setup_filesystem_str(pwd->pw_dir),
safe_setup_filesystem_str(pwd->pw_shell),
#ifdef HAVE_STRUCT_PASSWD_PW_CHANGE
- INT2NUM(pwd->pw_change),
+ TIMET2NUM(pwd->pw_change),
#endif
#ifdef HAVE_STRUCT_PASSWD_PW_QUOTA
INT2NUM(pwd->pw_quota),
@@ -157,7 +157,7 @@ setup_passwd(struct passwd *pwd)
safe_setup_locale_str(pwd->pw_comment),
#endif
#ifdef HAVE_STRUCT_PASSWD_PW_EXPIRE
- INT2NUM(pwd->pw_expire),
+ TIMET2NUM(pwd->pw_expire),
#endif
0 /*dummy*/
);
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index 34bb636ead0..337ce5d64d8 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -2324,7 +2324,7 @@ ossl_ssl_get_verify_result(VALUE self)
GetSSL(self, ssl);
- return INT2NUM(SSL_get_verify_result(ssl));
+ return LONG2NUM(SSL_get_verify_result(ssl));
}
/*
diff --git a/ext/psych/psych.c b/ext/psych/psych.c
index 3bb59bfc118..0afd7318b5d 100644
--- a/ext/psych/psych.c
+++ b/ext/psych/psych.c
@@ -11,9 +11,9 @@ static VALUE libyaml_version(VALUE module)
yaml_get_version(&major, &minor, &patch);
- list[0] = INT2NUM((long)major);
- list[1] = INT2NUM((long)minor);
- list[2] = INT2NUM((long)patch);
+ list[0] = INT2NUM(major);
+ list[1] = INT2NUM(minor);
+ list[2] = INT2NUM(patch);
return rb_ary_new4((long)3, list);
}
diff --git a/ext/psych/psych_parser.c b/ext/psych/psych_parser.c
index fb1a917bb25..fd550b671a8 100644
--- a/ext/psych/psych_parser.c
+++ b/ext/psych/psych_parser.c
@@ -27,7 +27,7 @@ static ID id_event_location;
static int io_reader(void * data, unsigned char *buf, size_t size, size_t *read)
{
VALUE io = (VALUE)data;
- VALUE string = rb_funcall(io, id_read, 1, INT2NUM(size));
+ VALUE string = rb_funcall(io, id_read, 1, SIZET2NUM(size));
*read = 0;
@@ -89,9 +89,9 @@ static VALUE make_exception(yaml_parser_t * parser, VALUE path)
return rb_funcall(ePsychSyntaxError, rb_intern("new"), 6,
path,
- INT2NUM(line),
- INT2NUM(column),
- INT2NUM(parser->problem_offset),
+ SIZET2NUM(line),
+ SIZET2NUM(column),
+ SIZET2NUM(parser->problem_offset),
parser->problem ? rb_usascii_str_new2(parser->problem) : Qnil,
parser->context ? rb_usascii_str_new2(parser->context) : Qnil);
}
@@ -303,10 +303,10 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
rb_exc_raise(exception);
}
- start_line = INT2NUM((long)event.start_mark.line);
- start_column = INT2NUM((long)event.start_mark.column);
- end_line = INT2NUM((long)event.end_mark.line);
- end_column = INT2NUM((long)event.end_mark.column);
+ start_line = SIZET2NUM(event.start_mark.line);
+ start_column = SIZET2NUM(event.start_mark.column);
+ end_line = SIZET2NUM(event.end_mark.line);
+ end_column = SIZET2NUM(event.end_mark.column);
event_args[0] = handler;
event_args[1] = start_line;
@@ -321,7 +321,7 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
VALUE args[2];
args[0] = handler;
- args[1] = INT2NUM((long)event.data.stream_start.encoding);
+ args[1] = INT2NUM(event.data.stream_start.encoding);
rb_protect(protected_start_stream, (VALUE)args, &state);
}
break;
@@ -334,8 +334,8 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
VALUE version = event.data.document_start.version_directive ?
rb_ary_new3(
(long)2,
- INT2NUM((long)event.data.document_start.version_directive->major),
- INT2NUM((long)event.data.document_start.version_directive->minor)
+ INT2NUM(event.data.document_start.version_directive->major),
+ INT2NUM(event.data.document_start.version_directive->minor)
) : rb_ary_new();
if(event.data.document_start.tag_directives.start) {
@@ -418,7 +418,7 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
quoted_implicit =
event.data.scalar.quoted_implicit == 0 ? Qfalse : Qtrue;
- style = INT2NUM((long)event.data.scalar.style);
+ style = INT2NUM(event.data.scalar.style);
args[0] = handler;
args[1] = val;
@@ -450,7 +450,7 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
implicit =
event.data.sequence_start.implicit == 0 ? Qfalse : Qtrue;
- style = INT2NUM((long)event.data.sequence_start.style);
+ style = INT2NUM(event.data.sequence_start.style);
args[0] = handler;
args[1] = anchor;
@@ -483,7 +483,7 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
implicit =
event.data.mapping_start.implicit == 0 ? Qfalse : Qtrue;
- style = INT2NUM((long)event.data.mapping_start.style);
+ style = INT2NUM(event.data.mapping_start.style);
args[0] = handler;
args[1] = anchor;
@@ -527,9 +527,9 @@ static VALUE mark(VALUE self)
TypedData_Get_Struct(self, yaml_parser_t, &psych_parser_type, parser);
mark_klass = rb_const_get_at(cPsychParser, rb_intern("Mark"));
- args[0] = INT2NUM(parser->mark.index);
- args[1] = INT2NUM(parser->mark.line);
- args[2] = INT2NUM(parser->mark.column);
+ args[0] = SIZET2NUM(parser->mark.index);
+ args[1] = SIZET2NUM(parser->mark.line);
+ args[2] = SIZET2NUM(parser->mark.column);
return rb_class_new_instance(3, args, mark_klass);
}
diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c
index b6d17992c92..a484a470416 100644
--- a/ext/strscan/strscan.c
+++ b/ext/strscan/strscan.c
@@ -447,7 +447,7 @@ strscan_get_charpos(VALUE self)
GET_SCANNER(self, p);
- substr = rb_funcall(p->str, id_byteslice, 2, INT2FIX(0), INT2NUM(p->curr));
+ substr = rb_funcall(p->str, id_byteslice, 2, INT2FIX(0), LONG2NUM(p->curr));
return rb_str_length(substr);
}
@@ -473,7 +473,7 @@ strscan_set_pos(VALUE self, VALUE v)
if (i < 0) rb_raise(rb_eRangeError, "index out of range");
if (i > S_LEN(p)) rb_raise(rb_eRangeError, "index out of range");
p->curr = i;
- return INT2NUM(i);
+ return LONG2NUM(i);
}
static inline UChar *
@@ -1107,7 +1107,7 @@ strscan_matched_size(VALUE self)
GET_SCANNER(self, p);
if (! MATCHED_P(p)) return Qnil;
- return INT2NUM(p->regs.end[0] - p->regs.beg[0]);
+ return LONG2NUM(p->regs.end[0] - p->regs.beg[0]);
}
static int
diff --git a/spec/ruby/optional/capi/ext/numeric_spec.c b/spec/ruby/optional/capi/ext/numeric_spec.c
index 33f3a18c00a..d3639580a80 100644
--- a/spec/ruby/optional/capi/ext/numeric_spec.c
+++ b/spec/ruby/optional/capi/ext/numeric_spec.c
@@ -54,7 +54,7 @@ static VALUE numeric_spec_NUM2INT(VALUE self, VALUE num) {
}
static VALUE numeric_spec_INT2NUM(VALUE self, VALUE num) {
- return INT2NUM(NUM2LONG(num));
+ return INT2NUM(NUM2INT(num));
}
static VALUE numeric_spec_NUM2LONG(VALUE self, VALUE num) {