[前][次][番号順一覧][スレッド一覧]

ruby-changes:62023

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:07:49 +0900 (JST)
Subject: [ruby-changes:62023] 9298631316 (master): check_exec_redirect_fd: do not goto into a branch

https://git.ruby-lang.org/ruby.git/commit/?id=9298631316

From 92986313161c36157187ed7078fc4909bbf9bc04 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?=
 <shyouhei@r...>
Date: Tue, 16 Jun 2020 12:27:33 +0900
Subject: check_exec_redirect_fd: do not goto into a branch

I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.

diff --git a/process.c b/process.c
index 5e47a51..054c303 100644
--- a/process.c
+++ b/process.c
@@ -1886,8 +1886,7 @@ check_exec_redirect_fd(VALUE v, int iskey) https://github.com/ruby/ruby/blob/trunk/process.c#L1886
         fd = fptr->fd;
     }
     else {
-      wrong:
-        rb_raise(rb_eArgError, "wrong exec redirect");
+        goto wrong;
     }
     if (fd < 0) {
         rb_raise(rb_eArgError, "negative file descriptor");
@@ -1898,6 +1897,9 @@ check_exec_redirect_fd(VALUE v, int iskey) https://github.com/ruby/ruby/blob/trunk/process.c#L1897
     }
 #endif
     return INT2FIX(fd);
+
+  wrong:
+    rb_raise(rb_eArgError, "wrong exec redirect");
 }
 
 static VALUE
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]