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

ruby-changes:62033

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

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

From b5eeb3453e7c3047ce3e4f39e8ae89af4fafb16f 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: Wed, 17 Jun 2020 14:28:54 +0900
Subject: trap_handler: 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/signal.c b/signal.c
index 5361b8c..d479ca9 100644
--- a/signal.c
+++ b/signal.c
@@ -1209,6 +1209,14 @@ trap_handler(VALUE *cmd, int sig) https://github.com/ruby/ruby/blob/trunk/signal.c#L1209
 	    *cmd = command;
 	    RSTRING_GETMEM(command, cptr, len);
 	    switch (len) {
+              sig_ign:
+                func = SIG_IGN;
+                *cmd = Qtrue;
+                break;
+              sig_dfl:
+                func = default_handler(sig);
+                *cmd = 0;
+                break;
 	      case 0:
                 goto sig_ign;
 		break;
@@ -1223,14 +1231,10 @@ trap_handler(VALUE *cmd, int sig) https://github.com/ruby/ruby/blob/trunk/signal.c#L1231
                 break;
 	      case 7:
 		if (memcmp(cptr, "SIG_IGN", 7) == 0) {
-sig_ign:
-                    func = SIG_IGN;
-                    *cmd = Qtrue;
+                    goto sig_ign;
 		}
 		else if (memcmp(cptr, "SIG_DFL", 7) == 0) {
-sig_dfl:
-                    func = default_handler(sig);
-                    *cmd = 0;
+                    goto sig_dfl;
 		}
 		else if (memcmp(cptr, "DEFAULT", 7) == 0) {
                     goto sig_dfl;
-- 
cgit v0.10.2


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

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