Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use rb_eArgError directly. #2

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions ext/iou/ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

VALUE mIOU;
VALUE cRing;
VALUE cArgumentError;

VALUE SYM_accept;
VALUE SYM_block;
Expand Down Expand Up @@ -151,15 +150,15 @@ static inline struct io_uring_sqe *get_sqe(IOU_t *iou) {

static inline void get_required_kwargs(VALUE spec, VALUE *values, int argc, ...) {
if (TYPE(spec) != T_HASH)
rb_raise(cArgumentError, "Expected keyword arguments");
rb_raise(rb_eArgError, "Expected keyword arguments");

va_list ptr;
va_start(ptr, argc);
for (int i = 0; i < argc; i++) {
VALUE k = va_arg(ptr, VALUE);
VALUE v = rb_hash_aref(spec, k);
if (NIL_P(v))
rb_raise(cArgumentError, "Missing %"PRIsVALUE" value", k);
rb_raise(rb_eArgError, "Missing %"PRIsVALUE" value", k);
values[i] = v;
}
va_end(ptr);
Expand Down Expand Up @@ -294,13 +293,13 @@ VALUE IOU_prep_cancel(VALUE self, VALUE spec) {
return prep_cancel_id(iou, NUM2UINT(spec));

if (TYPE(spec) != T_HASH)
rb_raise(cArgumentError, "Expected operation id or keyword arguments");
rb_raise(rb_eArgError, "Expected operation id or keyword arguments");

VALUE id = rb_hash_aref(spec, SYM_id);
if (!NIL_P(id))
return prep_cancel_id(iou, NUM2UINT(id));

rb_raise(cArgumentError, "Missing operation id");
rb_raise(rb_eArgError, "Missing operation id");
}

VALUE IOU_prep_close(VALUE self, VALUE spec) {
Expand Down Expand Up @@ -719,8 +718,6 @@ void Init_IOU(void) {
rb_define_method(cRing, "process_completions", IOU_process_completions, -1);
rb_define_method(cRing, "process_completions_loop", IOU_process_completions_loop, 0);

cArgumentError = rb_const_get(rb_cObject, rb_intern("ArgumentError"));

SYM_accept = MAKE_SYM("accept");
SYM_block = MAKE_SYM("block");
SYM_buffer = MAKE_SYM("buffer");
Expand Down