mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
compile.c: ignore the result of COMPILE by marking with NO_CHECK
to suppress many warnings of Coverity Scan
This commit is contained in:
parent
0eafa1dce8
commit
4b345f9d4b
1 changed files with 18 additions and 17 deletions
35
compile.c
35
compile.c
|
@ -442,6 +442,7 @@ do { \
|
|||
#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)
|
|||
}
|
||||
|
||||
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,
|
|||
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
|
|||
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,
|
|||
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
|
|||
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
|
|||
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,
|
|||
|
||||
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,
|
|||
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)
|
|||
}
|
||||
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,
|
|||
}
|
||||
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,
|
|||
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)
|
|||
|
||||
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,
|
|||
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,
|
|||
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,
|
|||
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
|
|||
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);
|
||||
|
|
Loading…
Add table
Reference in a new issue