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

ruby-changes:56553

From: Yusuke <ko1@a...>
Date: Mon, 15 Jul 2019 15:01:05 +0900 (JST)
Subject: [ruby-changes:56553] Yusuke Endoh: 4b345f9d4b (master): compile.c: ignore the result of COMPILE by marking with NO_CHECK

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

From 4b345f9d4bbff2cfc9895155fb0e8f90d1cac816 Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Mon, 15 Jul 2019 14:42:22 +0900
Subject: compile.c: ignore the result of COMPILE by marking with NO_CHECK

to suppress many warnings of Coverity Scan

diff --git a/compile.c b/compile.c
index ddb0815..a7b49c8 100644
--- a/compile.c
+++ b/compile.c
@@ -442,6 +442,7 @@ do { \ https://github.com/ruby/ruby/blob/trunk/compile.c#L442
 #define COMPILE_NG 0
 
 #define CHECK(sub) if (!(sub)) {BEFORE_RETURN;return COMPILE_NG;}
+#define NO_CHECK(sub) (void)(sub)
 #define BEFORE_RETURN
 
 /* leave name uninitialized so that compiler warn if INIT_ANCHOR is
@@ -638,7 +639,7 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node) https://github.com/ruby/ruby/blob/trunk/compile.c#L639
     }
 
     if (node == 0) {
-	COMPILE(ret, "nil", node);
+	NO_CHECK(COMPILE(ret, "nil", node));
 	iseq_set_local_table(iseq, 0);
     }
     /* assume node is T_NODE */
@@ -1575,7 +1576,7 @@ iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, https://github.com/ruby/ruby/blob/trunk/compile.c#L1576
 		dv = Qfalse;
 		break;
 	      default:
-		COMPILE_POPPED(optargs, "kwarg", node); /* nd_type(node) == NODE_KW_ARG */
+		NO_CHECK(COMPILE_POPPED(optargs, "kwarg", node)); /* nd_type(node) == NODE_KW_ARG */
 		dv = complex_mark;
 	    }
 
@@ -1712,7 +1713,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, const NODE *cons https://github.com/ruby/ruby/blob/trunk/compile.c#L1713
 	    COMPILE_POPPED(optargs, "init arguments (m)", args->pre_init);
 	}
 	if (args->post_init) { /* p_init */
-	    COMPILE_POPPED(optargs, "init arguments (p)", args->post_init);
+	    NO_CHECK(COMPILE_POPPED(optargs, "init arguments (p)", args->post_init));
 	}
 
 	if (body->type == ISEQ_TYPE_BLOCK) {
@@ -3832,7 +3833,7 @@ compile_keyword_arg(rb_iseq_t *iseq, LINK_ANCHOR *const ret, https://github.com/ruby/ruby/blob/trunk/compile.c#L3833
 		const NODE *key_node = node->nd_head;
 		const NODE *val_node = node->nd_next->nd_head;
 		keywords[i] = key_node->nd_lit;
-		COMPILE(ret, "keyword values", val_node);
+		NO_CHECK(COMPILE(ret, "keyword values", val_node));
 	    }
 	    assert(i == len);
 	    return TRUE;
@@ -3858,7 +3859,7 @@ compile_args(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node_roo https://github.com/ruby/ruby/blob/trunk/compile.c#L3859
             len--;
         }
         else {
-            COMPILE_(ret, "array element", node->nd_head, FALSE);
+            NO_CHECK(COMPILE_(ret, "array element", node->nd_head, FALSE));
         }
     }
 
@@ -4055,7 +4056,7 @@ compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node_ro https://github.com/ruby/ruby/blob/trunk/compile.c#L4056
 				if (i > 0 || !first) ADD_INSN(ret, line, swap);
 				else ADD_INSN1(ret, line, newhash, INT2FIX(0));
 			    }
-			    COMPILE(ret, "keyword splat", kw);
+			    NO_CHECK(COMPILE(ret, "keyword splat", kw));
 			    if (popped) {
 				ADD_INSN(ret, line, pop);
 			    }
@@ -4280,10 +4281,10 @@ compile_massign_opt(rb_iseq_t *iseq, LINK_ANCHOR *const ret, https://github.com/ruby/ruby/blob/trunk/compile.c#L4281
 
     while (rhsn) {
 	if (llen <= rlen) {
-	    COMPILE_POPPED(ret, "masgn val (popped)", rhsn->nd_head);
+	    NO_CHECK(COMPILE_POPPED(ret, "masgn val (popped)", rhsn->nd_head));
 	}
 	else {
-	    COMPILE(ret, "masgn val", rhsn->nd_head);
+	    NO_CHECK(COMPILE(ret, "masgn val", rhsn->nd_head));
 	}
 	rhsn = rhsn->nd_next;
 	rlen++;
@@ -4331,7 +4332,7 @@ compile_massign(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, https://github.com/ruby/ruby/blob/trunk/compile.c#L4332
 	    lhsn = lhsn->nd_next;
 	}
 
-	COMPILE(ret, "normal masgn rhs", rhsn);
+	NO_CHECK(COMPILE(ret, "normal masgn rhs", rhsn));
 
 	if (!popped) {
 	    ADD_INSN(ret, nd_line(node), dup);
@@ -4432,7 +4433,7 @@ compile_cpath(LINK_ANCHOR *const ret, rb_iseq_t *iseq, const NODE *cpath) https://github.com/ruby/ruby/blob/trunk/compile.c#L4433
     }
     else if (cpath->nd_head) {
 	/* Bar::Foo */
-	COMPILE(ret, "nd_else->nd_head", cpath->nd_head);
+	NO_CHECK(COMPILE(ret, "nd_else->nd_head", cpath->nd_head));
 	return VM_DEFINECLASS_FLAG_SCOPED;
     }
     else {
@@ -4529,7 +4530,7 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, https://github.com/ruby/ruby/blob/trunk/compile.c#L4530
 	}
 	defined_expr0(iseq, ret, node->nd_head, lfinish, Qfalse);
         ADD_INSNL(ret, line, branchunless, lfinish[1]);
-	COMPILE(ret, "defined/colon2#nd_head", node->nd_head);
+	NO_CHECK(COMPILE(ret, "defined/colon2#nd_head", node->nd_head));
 
         ADD_INSN3(ret, line, defined,
 		  (rb_is_const_id(node->nd_mid) ?
@@ -4564,7 +4565,7 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, https://github.com/ruby/ruby/blob/trunk/compile.c#L4565
 	if (explicit_receiver) {
 	    defined_expr0(iseq, ret, node->nd_recv, lfinish, Qfalse);
             ADD_INSNL(ret, line, branchunless, lfinish[1]);
-	    COMPILE(ret, "defined/recv", node->nd_recv);
+	    NO_CHECK(COMPILE(ret, "defined/recv", node->nd_recv));
             ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_METHOD),
 		      ID2SYM(node->nd_mid), needstr);
 	}
@@ -4752,7 +4753,7 @@ add_ensure_iseq(LINK_ANCHOR *const ret, rb_iseq_t *iseq, int is_return) https://github.com/ruby/ruby/blob/trunk/compile.c#L4753
 
 	    ISEQ_COMPILE_DATA(iseq)->ensure_node_stack = enlp->prev;
 	    ADD_LABEL(ensure_part, lstart);
-	    COMPILE_POPPED(ensure_part, "ensure part", enlp->ensure_node);
+	    NO_CHECK(COMPILE_POPPED(ensure_part, "ensure part", enlp->ensure_node));
 	    ADD_LABEL(ensure_part, lend);
 	    ADD_SEQ(ensure, ensure_part);
 	}
@@ -4790,7 +4791,7 @@ setup_args_core(rb_iseq_t *iseq, LINK_ANCHOR *const args, const NODE *argn, https://github.com/ruby/ruby/blob/trunk/compile.c#L4791
     if (argn) {
         switch (nd_type(argn)) {
           case NODE_SPLAT: {
-            COMPILE(args, "args (splat)", argn->nd_head);
+            NO_CHECK(COMPILE(args, "args (splat)", argn->nd_head));
             ADD_INSN1(args, nd_line(argn), splatarray, dup_rest ? Qtrue : Qfalse);
             if (flag) *flag |= VM_CALL_ARGS_SPLAT;
             return INT2FIX(1);
@@ -4799,7 +4800,7 @@ setup_args_core(rb_iseq_t *iseq, LINK_ANCHOR *const args, const NODE *argn, https://github.com/ruby/ruby/blob/trunk/compile.c#L4800
           case NODE_ARGSPUSH: {
             int next_is_array = (nd_type(argn->nd_head) == NODE_ARRAY);
             VALUE argc = setup_args_core(iseq, args, argn->nd_head, 1, NULL, NULL);
-            COMPILE(args, "args (cat: splat)", argn->nd_body);
+            NO_CHECK(COMPILE(args, "args (cat: splat)", argn->nd_body));
             if (flag) {
                 *flag |= VM_CALL_ARGS_SPLAT;
                 /* This is a dirty hack.  It traverses the AST twice.
@@ -4844,7 +4845,7 @@ setup_args(rb_iseq_t *iseq, LINK_ANCHOR *const args, const NODE *argn, https://github.com/ruby/ruby/blob/trunk/compile.c#L4845
     if (argn && nd_type(argn) == NODE_BLOCK_PASS) {
         DECL_ANCHOR(arg_block);
         INIT_ANCHOR(arg_block);
-        COMPILE(arg_block, "block", argn->nd_body);
+        NO_CHECK(COMPILE(arg_block, "block", argn->nd_body));
 
         *flag |= VM_CALL_ARGS_BLOCKARG;
         ret = setup_args_core(iseq, args, argn->nd_head, 0, flag, keywords);
@@ -4901,7 +4902,7 @@ compile_named_capture_assign(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE https://github.com/ruby/ruby/blob/trunk/compile.c#L4902
 	    ADD_INSN(ret, line, dup);
 	}
 	last = ret->last;
-	COMPILE_POPPED(ret, "capture", vars->nd_head);
+	NO_CHECK(COMPILE_POPPED(ret, "capture", vars->nd_head));
 	last = last->next; /* putobject :var */
 	cap = new_insn_send(iseq, line, idAREF, INT2FIX(1),
 			    NULL, INT2FIX(0), NULL);
-- 
cgit v0.10.2


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

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