From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id C870A1F544 for ; Sun, 11 Jun 2023 21:33:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yhbt.net; s=selector1; t=1686519208; bh=jLq8OoABGpHRSKxL2DISsAlwlEwMttcjZSprDxiZ6dg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=34vflGFmKYb6OtLmKuyGTIjFpQCiSXd2i6pVqwlUNE+GkpY8pcgwnWqxEd0JdK4H3 y0X0z7heD+Rv+7ltnOiJPiP8HyeFQsymSp+o2OpzgJ5gkduCppepA2egpHYk5eHKm1 m0o8TDBiPrCg0BQSP0TPnfmCU+WWRyw2H5ZDwjuY= From: Eric Wong To: raindrops-public@yhbt.net Subject: [PATCH 2/4] my_fileno: use rb_io_check_closed for Ruby <3.1 Date: Sun, 11 Jun 2023 21:33:26 +0000 Message-Id: <20230611213328.379546-3-bofh@yhbt.net> In-Reply-To: <20230611213328.379546-1-bofh@yhbt.net> References: <20230611213328.379546-1-bofh@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This is less code and hopefully smaller binaries. `rb_io_check_closed' has been in Ruby since the pre-CVS of decades ago, and it doesn't matter if it's removed or not in the future since Ruby 3.1+ doesn't see this code path and calls `rb_io_descriptor' directly. --- ext/raindrops/my_fileno.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ext/raindrops/my_fileno.h b/ext/raindrops/my_fileno.h index 646f31b..3a0100f 100644 --- a/ext/raindrops/my_fileno.h +++ b/ext/raindrops/my_fileno.h @@ -9,9 +9,8 @@ static int my_fileno(VALUE io) rb_io_t *fptr; GetOpenFile(io, fptr); + rb_io_check_closed(fptr); - if (fptr->fd < 0) - rb_raise(rb_eIOError, "closed stream"); return fptr->fd; } #endif /* Ruby <3.1 !HAVE_RB_IO_DESCRIPTOR */