Skip to content

Commit

Permalink
Merge pull request #2 from byroot/undeclared-global-variable
Browse files Browse the repository at this point in the history
Use `rb_eArgError` directly.
  • Loading branch information
noteflakes authored Sep 9, 2024
2 parents 0e0a93d + 2a76936 commit b996100
Showing 1 changed file with 4 additions and 7 deletions.
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 @@ -152,15 +151,15 @@ static inline struct io_uring_sqe *get_sqe(IOURing_t *iour) {

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 @@ -302,13 +301,13 @@ VALUE IOURing_prep_cancel(VALUE self, VALUE spec) {
return prep_cancel_id(iour, 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(iour, NUM2UINT(id));

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

VALUE IOURing_prep_close(VALUE self, VALUE spec) {
Expand Down Expand Up @@ -727,8 +726,6 @@ void Init_IOURing(void) {
rb_define_method(cRing, "process_completions", IOURing_process_completions, -1);
rb_define_method(cRing, "process_completions_loop", IOURing_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

0 comments on commit b996100

Please sign in to comment.