Fixed wrong usages of `mrb_raisef()`; ref #4043

`mrb_raisef()` only takes `%S` specifier. If you don't have extra
arguments, use `mrb_raise()`.
parent 70600c3b
......@@ -47,7 +47,7 @@ istruct_test_test_receive(mrb_state *mrb, mrb_value self)
mrb_get_args(mrb, "o", &object);
if (mrb_obj_class(mrb, object) != mrb_class_get(mrb, "InlineStructTest"))
{
mrb_raisef(mrb, E_TYPE_ERROR, "Expected InlineStructTest");
mrb_raise(mrb, E_TYPE_ERROR, "Expected InlineStructTest");
}
return mrb_bool_value(((char*)mrb_istruct_ptr(object))[0] == 's');
}
......
......@@ -510,7 +510,7 @@ utf8_to_uv(mrb_state *mrb, const char *p, long *lenp)
}
if (n > *lenp) {
mrb_raisef(mrb, E_ARGUMENT_ERROR, "malformed UTF-8 character (expected %S bytes, given %S bytes)",
mrb_fixnum_value(n), mrb_fixnum_value(*lenp));
mrb_fixnum_value(n), mrb_fixnum_value(*lenp));
}
*lenp = n--;
if (n != 0) {
......@@ -1055,7 +1055,7 @@ alias:
while (tmpl->idx < tlen && isdigit(tptr[tmpl->idx])) {
count = count * 10 + (tptr[tmpl->idx++] - '0');
if (count < 0) {
mrb_raisef(mrb, E_RUNTIME_ERROR, "too big template length");
mrb_raise(mrb, E_RUNTIME_ERROR, "too big template length");
}
}
continue; /* special case */
......
......@@ -203,8 +203,8 @@ mrb_addrinfo_getnameinfo(mrb_state *mrb, mrb_value self)
mrb_raise(mrb, E_SOCKET_ERROR, "invalid sockaddr");
}
error = getnameinfo((struct sockaddr *)RSTRING_PTR(sastr), (socklen_t)RSTRING_LEN(sastr), RSTRING_PTR(host), NI_MAXHOST, RSTRING_PTR(serv), NI_MAXSERV, (int)flags);
if (error != 0) {
mrb_raisef(mrb, E_SOCKET_ERROR, "getnameinfo: %s", gai_strerror(error));
if (error) {
mrb_raisef(mrb, E_SOCKET_ERROR, "getnameinfo: %S", mrb_str_new_cstr(mrb, gai_strerror(error)));
}
ary = mrb_ary_new_capa(mrb, 2);
mrb_str_resize(mrb, host, strlen(RSTRING_PTR(host)));
......@@ -469,12 +469,12 @@ mrb_basicsocket_setsockopt(mrb_state *mrb, mrb_value self)
}
} else if (argc == 1) {
if (strcmp(mrb_obj_classname(mrb, so), "Socket::Option") != 0)
mrb_raisef(mrb, E_ARGUMENT_ERROR, "not an instance of Socket::Option");
mrb_raise(mrb, E_ARGUMENT_ERROR, "not an instance of Socket::Option");
level = mrb_fixnum(mrb_funcall(mrb, so, "level", 0));
optname = mrb_fixnum(mrb_funcall(mrb, so, "optname", 0));
optval = mrb_funcall(mrb, so, "data", 0);
} else {
mrb_raisef(mrb, E_ARGUMENT_ERROR, "wrong number of arguments (%d for 3)", argc);
mrb_raisef(mrb, E_ARGUMENT_ERROR, "wrong number of arguments (%S for 3)", mrb_fixnum_value(argc));
}
s = socket_fd(mrb, self);
......@@ -682,7 +682,7 @@ mrb_socket_sockaddr_family(mrb_state *mrb, mrb_value klass)
mrb_get_args(mrb, "S", &str);
if ((size_t)RSTRING_LEN(str) < offsetof(struct sockaddr, sa_family) + sizeof(sa->sa_family)) {
mrb_raisef(mrb, E_SOCKET_ERROR, "invalid sockaddr (too short)");
mrb_raise(mrb, E_SOCKET_ERROR, "invalid sockaddr (too short)");
}
sa = (const struct sockaddr *)RSTRING_PTR(str);
return mrb_fixnum_value(sa->sa_family);
......@@ -700,7 +700,7 @@ mrb_socket_sockaddr_un(mrb_state *mrb, mrb_value klass)
mrb_get_args(mrb, "S", &path);
if ((size_t)RSTRING_LEN(path) > sizeof(sunp->sun_path) - 1) {
mrb_raisef(mrb, E_ARGUMENT_ERROR, "too long unix socket path (max: %ubytes)", (unsigned int)sizeof(sunp->sun_path) - 1);
mrb_raisef(mrb, E_ARGUMENT_ERROR, "too long unix socket path (max: %S bytes)", mrb_fixnum_value(sizeof(sunp->sun_path) - 1));
}
s = mrb_str_buf_new(mrb, sizeof(struct sockaddr_un));
sunp = (struct sockaddr_un *)RSTRING_PTR(s);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment