summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2017-10-25 18:32:44 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-10-24 19:24:50 +0900
commit7459a32af3e89ea9990efb4d76bfdc869e480ffe (patch)
tree3faf1fdeabfed9a3d05106fa493e24dfcbbbbe12
parente5c2bf55d0c5b71227284a577301b3c48894032e (diff)
downloadruby-7459a32af3e89ea9990efb4d76bfdc869e480ffe.tar.gz
suppress warnings for probable NULL dererefences
-rw-r--r--compile.c1
-rw-r--r--encoding.c5
-rw-r--r--vm.c1
-rw-r--r--vm_core.h2
4 files changed, 8 insertions, 1 deletions
diff --git a/compile.c b/compile.c
index 055d4e85f5..62a047be78 100644
--- a/compile.c
+++ b/compile.c
@@ -4774,6 +4774,7 @@ compile_massign_lhs(rb_iseq_t *iseq, LINK_ANCHOR *const pre, LINK_ANCHOR *const
LINK_ELEMENT *insn_element = LAST_ELEMENT(pre);
iobj = (INSN *)get_prev_insn((INSN *)insn_element); /* send insn */
+ ASSUME(iobj);
ELEM_REMOVE(LAST_ELEMENT(pre));
ELEM_REMOVE((LINK_ELEMENT *)iobj);
pre->last = iobj->link.prev;
diff --git a/encoding.c b/encoding.c
index 2fb1c42047..2737108379 100644
--- a/encoding.c
+++ b/encoding.c
@@ -496,6 +496,7 @@ set_base_encoding(struct enc_table *enc_table, int index, rb_encoding *base)
{
rb_encoding *enc = enc_table->list[index].enc;
+ ASSUME(enc);
enc_table->list[index].base = base;
if (ENC_DUMMY_P(base)) ENC_SET_DUMMY((rb_raw_encoding *)enc);
return enc;
@@ -758,7 +759,9 @@ rb_encdb_alias(const char *alias, const char *orig)
void
rb_encdb_set_unicode(int index)
{
- ((rb_raw_encoding *)rb_enc_from_index(index))->flags |= ONIGENC_FLAG_UNICODE;
+ rb_raw_encoding *enc = (rb_raw_encoding *)rb_enc_from_index(index);
+ ASSUME(enc);
+ enc->flags |= ONIGENC_FLAG_UNICODE;
}
static void
diff --git a/vm.c b/vm.c
index 2f6a244eee..a18b2140d3 100644
--- a/vm.c
+++ b/vm.c
@@ -1653,6 +1653,7 @@ rb_vm_cref_replace_with_duplicated_cref(void)
const rb_execution_context_t *ec = GET_EC();
const rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(ec, ec->cfp);
rb_cref_t *cref = vm_cref_replace_with_duplicated_cref(cfp->ep);
+ ASSUME(cref);
return cref;
}
diff --git a/vm_core.h b/vm_core.h
index 8519da8f9e..76d0025613 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -1367,6 +1367,7 @@ vm_assert_env(VALUE obj)
}
#endif
+RBIMPL_ATTR_NONNULL((1))
static inline VALUE
VM_ENV_ENVVAL(const VALUE *ep)
{
@@ -1376,6 +1377,7 @@ VM_ENV_ENVVAL(const VALUE *ep)
return envval;
}
+RBIMPL_ATTR_NONNULL((1))
static inline const rb_env_t *
VM_ENV_ENVVAL_PTR(const VALUE *ep)
{