File 0404-erts-Add-asserts-to-suppress-false-positives-found-b.patch of Package erlang
From 0b1820ed8789929547ee5ca04ac651bb415205a8 Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Thu, 25 Jun 2020 11:40:28 +0200
Subject: [PATCH 04/34] erts: Add asserts to suppress false positives found by
clang sa
---
erts/emulator/beam/beam_bif_load.c | 6 +-
erts/emulator/beam/beam_bp.c | 7 ++-
erts/emulator/beam/beam_debug.c | 6 +-
erts/emulator/beam/bif.c | 2 +-
erts/emulator/beam/dist.c | 2 +
erts/emulator/beam/erl_async.c | 1 +
erts/emulator/beam/erl_bif_re.c | 3 +-
erts/emulator/beam/erl_bif_unique.c | 1 +
erts/emulator/beam/erl_db.c | 1 +
erts/emulator/beam/erl_db_catree.c | 6 ++
erts/emulator/beam/erl_db_tree.c | 4 ++
erts/emulator/beam/erl_db_util.c | 22 +++----
erts/emulator/beam/erl_gc.c | 3 +-
erts/emulator/beam/erl_lock_check.c | 15 +++--
erts/emulator/beam/erl_lock_check.h | 5 +-
erts/emulator/beam/erl_map.c | 6 ++
erts/emulator/beam/erl_message.h | 4 +-
erts/emulator/beam/erl_msacc.h | 66 ++++++++++-----------
erts/emulator/beam/erl_process.c | 1 +
erts/emulator/beam/erl_process_lock.c | 4 +-
erts/emulator/beam/erl_trace.c | 2 +
erts/emulator/beam/external.c | 10 +++-
erts/emulator/beam/global.h | 2 +-
erts/emulator/beam/io.c | 1 +
erts/emulator/drivers/common/inet_drv.c | 10 +++-
erts/emulator/drivers/unix/ttsl_drv.c | 1 +
erts/emulator/sys/common/erl_check_io.c | 4 +-
erts/emulator/sys/common/erl_mmap.c | 6 +-
erts/emulator/sys/common/erl_poll.c | 10 ++--
erts/emulator/sys/unix/sys.c | 2 +-
erts/epmd/src/epmd_int.h | 6 ++
erts/epmd/src/epmd_srv.c | 1 +
erts/etc/common/heart.c | 4 +-
erts/etc/common/inet_gethost.c | 25 +++++++-
erts/include/internal/ethread.h | 18 +++---
erts/lib_src/common/ethr_aux.c | 4 +-
erts/lib_src/common/ethr_mutex.c | 2 +-
erts/lib_src/yielding_c_fun/ycf_yield_fun.c | 2 +-
38 files changed, 174 insertions(+), 101 deletions(-)
diff --git a/erts/emulator/beam/beam_bif_load.c b/erts/emulator/beam/beam_bif_load.c
index 02da37cff6..14db75063d 100644
--- a/erts/emulator/beam/beam_bif_load.c
+++ b/erts/emulator/beam/beam_bif_load.c
@@ -77,13 +77,11 @@ init_purge_state(void)
erts_export_put(am_erts_code_purger, am_pending_purge_lambda, 3);
purge_state.sprocs = &purge_state.def_sprocs[0];
- purge_state.sp_size = sizeof(purge_state.def_sprocs);
- purge_state.sp_size /= sizeof(purge_state.def_sprocs[0]);
+ purge_state.sp_size = sizeof(purge_state.def_sprocs) / sizeof(purge_state.def_sprocs[0]);
purge_state.sp_ix = 0;
purge_state.funs = &purge_state.def_funs[0];
- purge_state.fe_size = sizeof(purge_state.def_funs);
- purge_state.fe_size /= sizeof(purge_state.def_funs[0]);
+ purge_state.fe_size = sizeof(purge_state.def_funs) / sizeof(purge_state.def_funs[0]);
purge_state.fe_ix = 0;
purge_state.saved_old.code_hdr = 0;
diff --git a/erts/emulator/beam/beam_bp.c b/erts/emulator/beam/beam_bp.c
index 2ec0b2a901..2142830ae8 100644
--- a/erts/emulator/beam/beam_bp.c
+++ b/erts/emulator/beam/beam_bp.c
@@ -718,7 +718,7 @@ erts_generic_breakpoint(Process* c_p, ErtsCodeInfo *info, Eterm* reg)
new_tracer = do_call_trace(c_p, info, reg, 1, bp->meta_ms, old_tracer);
if (!ERTS_TRACER_COMPARE(new_tracer, old_tracer)) {
- if (old_tracer == erts_atomic_cmpxchg_acqb(
+ if ((erts_aint_t)old_tracer == erts_atomic_cmpxchg_acqb(
&bp->meta_tracer->tracer,
(erts_aint_t)new_tracer,
(erts_aint_t)old_tracer)) {
@@ -1129,6 +1129,8 @@ static void bp_hash_rehash(bp_time_hash_t *hash, Uint n) {
Uint ix;
Uint hval;
+ ASSERT(n > 0);
+
item = (bp_data_time_item_t *)Alloc(size);
sys_memzero(item, size);
@@ -1136,6 +1138,7 @@ static void bp_hash_rehash(bp_time_hash_t *hash, Uint n) {
item[ix].pid = NIL;
}
+
/* rehash, old hash -> new hash */
for( ix = 0; ix < hash->n; ix++) {
@@ -1395,7 +1398,7 @@ set_function_break(ErtsCodeInfo *ci, Binary *match_spec, Uint break_flags,
bp->count = bcp;
} else if (break_flags & ERTS_BPF_TIME_TRACE) {
BpDataTime* bdt;
- int i;
+ Uint i;
ASSERT((bp->flags & ERTS_BPF_TIME_TRACE) == 0);
bdt = Alloc(sizeof(BpDataTime));
diff --git a/erts/emulator/beam/beam_debug.c b/erts/emulator/beam/beam_debug.c
index d1ad71e7ac..b790aeaff8 100644
--- a/erts/emulator/beam/beam_debug.c
+++ b/erts/emulator/beam/beam_debug.c
@@ -458,7 +458,7 @@ print_op(fmtfn_t to, void *to_arg, int op, int size, BeamInstr* addr)
* Copy all arguments to a local buffer for the unpacking.
*/
- ASSERT(size <= sizeof(args)/sizeof(args[0]));
+ ASSERT(size > 0 && size <= sizeof(args)/sizeof(args[0]));
ap = args;
for (i = 0; i < size; i++) {
*ap++ = addr[i];
@@ -553,14 +553,14 @@ print_op(fmtfn_t to, void *to_arg, int op, int size, BeamInstr* addr)
break;
case 'S': /* Register */
{
- Uint reg_type = (*ap & 1) ? 'y' : 'x';
+ Uint reg_type = (ap[0] & 1) ? 'y' : 'x';
Uint n = ap[0] / sizeof(Eterm);
erts_print(to, to_arg, "%c(%d)", reg_type, n);
ap++;
break;
}
case 's': /* Any source (tagged constant or register) */
- tag = loader_tag(*ap);
+ tag = loader_tag(ap[0]);
if (tag == LOADER_X_REG) {
erts_print(to, to_arg, "x(%d)", loader_x_reg_index(*ap));
ap++;
diff --git a/erts/emulator/beam/bif.c b/erts/emulator/beam/bif.c
index 41c7768111..c19ff6250c 100644
--- a/erts/emulator/beam/bif.c
+++ b/erts/emulator/beam/bif.c
@@ -1591,7 +1591,7 @@ static Eterm process_flag_aux(Process *c_p, int *redsp, Eterm flag, Eterm val)
if (i == 0)
scb = NULL;
else {
- Uint sz = sizeof(*scb) + (i-1) * sizeof(scb->ct[0]);
+ Uint sz = sizeof(*scb) + (i-1) * sizeof(*scb->ct);
scb = erts_alloc(ERTS_ALC_T_CALLS_BUF, sz);
scb->len = i;
scb->cur = 0;
diff --git a/erts/emulator/beam/dist.c b/erts/emulator/beam/dist.c
index 077a288f72..30dffa13ee 100644
--- a/erts/emulator/beam/dist.c
+++ b/erts/emulator/beam/dist.c
@@ -2847,6 +2847,8 @@ erts_dsig_prepare(ErtsDSigSendContext *ctx,
*/
int res;
+ ASSERT(no_trap || proc);
+
if (!erts_is_alive)
return ERTS_DSIG_PREP_NOT_ALIVE;
if (!dep) {
diff --git a/erts/emulator/beam/erl_async.c b/erts/emulator/beam/erl_async.c
index ec116cb9f5..0f33459fa4 100644
--- a/erts/emulator/beam/erl_async.c
+++ b/erts/emulator/beam/erl_async.c
@@ -137,6 +137,7 @@ static void *async_main(void *);
static ERTS_INLINE ErtsAsyncQ *
async_q(int i)
{
+ ASSERT(async != NULL);
return &async->queue[i].aq;
}
diff --git a/erts/emulator/beam/erl_bif_re.c b/erts/emulator/beam/erl_bif_re.c
index 3c2cc2e6d5..b03595c2c2 100644
--- a/erts/emulator/beam/erl_bif_re.c
+++ b/erts/emulator/beam/erl_bif_re.c
@@ -1042,6 +1042,7 @@ build_capture(Eterm capture_spec[CAPSPEC_SIZE], const pcre *code)
(tmpbsiz = ap->len + 1));
}
}
+ ASSERT(tmpb != NULL);
sys_memcpy(tmpb,ap->name,ap->len);
tmpb[ap->len] = '\0';
} else {
@@ -1059,7 +1060,7 @@ build_capture(Eterm capture_spec[CAPSPEC_SIZE], const pcre *code)
(tmpbsiz = slen + 1));
}
}
-
+ ASSERT(tmpb != NULL);
buffres = erts_iolist_to_buf(val, tmpb, slen);
ASSERT(buffres >= 0); (void)buffres;
tmpb[slen] = '\0';
diff --git a/erts/emulator/beam/erl_bif_unique.c b/erts/emulator/beam/erl_bif_unique.c
index 90820124f0..58aba0369b 100644
--- a/erts/emulator/beam/erl_bif_unique.c
+++ b/erts/emulator/beam/erl_bif_unique.c
@@ -813,6 +813,7 @@ bld_unique_integer_term(Eterm **hpp, Uint *szp,
else {
int hix;
Eterm *hp = *hpp;
+ ASSERT(hp != NULL);
tmp_hp = big_val(tmp);
for (hix = 0; hix < hsz; hix++)
hp[hix] = tmp_hp[hix];
diff --git a/erts/emulator/beam/erl_db.c b/erts/emulator/beam/erl_db.c
index c80d987471..28e5a805bd 100644
--- a/erts/emulator/beam/erl_db.c
+++ b/erts/emulator/beam/erl_db.c
@@ -1512,6 +1512,7 @@ typedef struct {
static ERTS_INLINE BIF_RETTYPE
ets_cret_to_return_value(Process* p, int cret)
{
+ ASSERT(p || cret == DB_ERROR_NONE_FALSE || cret == DB_ERROR_NONE);
switch (cret) {
case DB_ERROR_NONE_FALSE:
BIF_RET(am_false);
diff --git a/erts/emulator/beam/erl_db_catree.c b/erts/emulator/beam/erl_db_catree.c
index 2e09c241dd..b5033abc68 100644
--- a/erts/emulator/beam/erl_db_catree.c
+++ b/erts/emulator/beam/erl_db_catree.c
@@ -370,6 +370,7 @@ TreeDbTerm* insert_TreeDbTerm(DbTableCATree *tb,
p->balance = 0;
(*this) = p1;
} else { /* Double RR rotation */
+ ASSERT(p1->right);
p2 = p1->right;
p1->right = p2->left;
p2->left = p1;
@@ -400,6 +401,7 @@ TreeDbTerm* insert_TreeDbTerm(DbTableCATree *tb,
p->balance = 0;
(*this) = p1;
} else { /* Double RL rotation */
+ ASSERT(p1->left);
p2 = p1->left;
p1->left = p2->right;
p2->right = p1;
@@ -465,8 +467,10 @@ static ERTS_INLINE int compute_tree_hight(TreeDbTerm * root)
int hight_so_far = 1;
while (current_node->left != NULL || current_node->right != NULL) {
if (current_node->balance == -1) {
+ ASSERT(current_node->left != NULL);
current_node = current_node->left;
} else {
+ ASSERT(current_node->right != NULL);
current_node = current_node->right;
}
hight_so_far = hight_so_far + 1;
@@ -628,6 +632,7 @@ static TreeDbTerm* join_trees(TreeDbTerm *left_root_param,
p->balance = 0;
(*this) = p1;
} else { /* Double RR rotation */
+ ASSERT(p1->right);
p2 = p1->right;
p1->right = p2->left;
p2->left = p1;
@@ -658,6 +663,7 @@ static TreeDbTerm* join_trees(TreeDbTerm *left_root_param,
p->balance = 0;
(*this) = p1;
} else { /* Double RL rotation */
+ ASSERT(p1->left);
p2 = p1->left;
p1->left = p2->right;
p2->right = p1;
diff --git a/erts/emulator/beam/erl_db_tree.c b/erts/emulator/beam/erl_db_tree.c
index 68afae1a7d..a439b974a7 100644
--- a/erts/emulator/beam/erl_db_tree.c
+++ b/erts/emulator/beam/erl_db_tree.c
@@ -757,6 +757,7 @@ int db_put_dbterm_tree_common(DbTableCommon *tb,
p->balance = 0;
(*this) = p1;
} else { /* Double RR rotation */
+ ASSERT(p1->right);
p2 = p1->right;
p1->right = p2->left;
p2->left = p1;
@@ -787,6 +788,7 @@ int db_put_dbterm_tree_common(DbTableCommon *tb,
p->balance = 0;
(*this) = p1;
} else { /* Double RL rotation */
+ ASSERT(p1->left);
p2 = p1->left;
p1->left = p2->right;
p2->right = p1;
@@ -878,6 +880,7 @@ int db_put_tree_common(DbTableCommon *tb, TreeDbTerm **root, Eterm obj,
p->balance = 0;
(*this) = p1;
} else { /* Double RR rotation */
+ ASSERT(p1->right);
p2 = p1->right;
p1->right = p2->left;
p2->left = p1;
@@ -908,6 +911,7 @@ int db_put_tree_common(DbTableCommon *tb, TreeDbTerm **root, Eterm obj,
p->balance = 0;
(*this) = p1;
} else { /* Double RL rotation */
+ ASSERT(p1->left);
p2 = p1->left;
p1->left = p2->right;
p2->right = p1;
diff --git a/erts/emulator/beam/erl_db_util.c b/erts/emulator/beam/erl_db_util.c
index 1919436334..6cb123d55e 100644
--- a/erts/emulator/beam/erl_db_util.c
+++ b/erts/emulator/beam/erl_db_util.c
@@ -143,8 +143,6 @@ do { \
} while (0)
-#define TermWords(t) (((t) / (sizeof(UWord)/sizeof(Eterm))) + !!((t) % (sizeof(UWord)/sizeof(Eterm))))
-
#define add_dmc_err(EINFO, STR, VAR, TERM, SEV) \
vadd_dmc_err(EINFO, SEV, VAR, STR, TERM)
@@ -2226,7 +2224,7 @@ restart:
FAIL();
if (sys_memcmp(float_val(*ep) + 1, pc, sizeof(double)))
FAIL();
- pc += TermWords(2);
+ pc += FLOAT_SIZE_OBJECT;
++ep;
break;
case matchEqRef: {
@@ -2237,7 +2235,7 @@ restart:
FAIL();
}
i = thing_arityval(*epc);
- pc += TermWords(i+1);
+ pc += i+1;
++ep;
break;
}
@@ -2250,7 +2248,7 @@ restart:
if (*tp != *epc)
FAIL();
i = BIG_ARITY(epc);
- pc += TermWords(i+1);
+ pc += i+1;
while(i--) {
if (*++tp != *++epc) {
FAIL();
@@ -5323,8 +5321,10 @@ static Eterm match_spec_test(Process *p, Eterm against, Eterm spec, int trace)
if (trace) {
if (n)
arr = erts_alloc(ERTS_ALC_T_DB_TMP, sizeof(Eterm) * n);
- else
+ else {
+ ASSERT(!is_list(against));
arr = NULL;
+ }
l = against;
n = 0;
while (is_list(l)) {
@@ -5540,13 +5540,13 @@ void db_match_dis(Binary *bp)
if (is_ordinary_ref_thing(t)) {
ErtsORefThing *rt = (ErtsORefThing *) t;
num = rt->num;
- t += TermWords(ERTS_REF_THING_SIZE);
+ t += ERTS_REF_THING_SIZE;
}
else {
ErtsMRefThing *mrt = (ErtsMRefThing *) t;
ASSERT(is_magic_ref_thing(t));
num = mrt->mb->refn;
- t += TermWords(ERTS_MAGIC_REF_THING_SIZE);
+ t += ERTS_MAGIC_REF_THING_SIZE;
}
erts_printf("EqRef\t(%d) {", (int) ERTS_REF_NUMBERS);
@@ -5575,7 +5575,7 @@ void db_match_dis(Binary *bp)
n = thing_arityval(*t);
{
Eterm *et = (Eterm *) t;
- t += TermWords(n+1);
+ t += n+1;
erts_printf("EqBig\t(%d) {", (int) n);
first = 1;
++n;
@@ -5599,7 +5599,7 @@ void db_match_dis(Binary *bp)
{
double num;
sys_memcpy(&num,t,sizeof(double));
- t += TermWords(2);
+ t += FLOAT_SIZE_OBJECT;
erts_printf("EqFloat\t%f\n", num);
}
break;
diff --git a/erts/emulator/beam/erl_gc.c b/erts/emulator/beam/erl_gc.c
index b9ae4c4161..7cdb532f75 100644
--- a/erts/emulator/beam/erl_gc.c
+++ b/erts/emulator/beam/erl_gc.c
@@ -2867,10 +2867,11 @@ sweep_off_heap(Process *p, int fullsweep)
while (ptr) {
if (IS_MOVED_BOXED(ptr->thing_word)) {
ASSERT(!ErtsInArea(ptr, oheap, oheap_sz));
- if (is_external_header(((struct erl_off_heap_header*) boxed_val(ptr->thing_word))->thing_word))
+ if (is_external_header(((struct erl_off_heap_header*) boxed_val(ptr->thing_word))->thing_word)) {
erts_node_bookkeep(((ExternalThing*)ptr)->node,
make_boxed(&ptr->thing_word),
ERL_NODE_DEC, __FILE__, __LINE__);
+ }
*prev = ptr = (struct erl_off_heap_header*) boxed_val(ptr->thing_word);
ASSERT(!IS_MOVED_BOXED(ptr->thing_word));
switch (ptr->thing_word) {
diff --git a/erts/emulator/beam/erl_lock_check.c b/erts/emulator/beam/erl_lock_check.c
index 6613707e3f..a35bfe7a20 100644
--- a/erts/emulator/beam/erl_lock_check.c
+++ b/erts/emulator/beam/erl_lock_check.c
@@ -178,7 +178,7 @@ static erts_lc_lock_order_t erts_lock_order[] = {
&& \
((LCK_FLG) & ERTS_LOCK_FLAGS_MASK_TYPE) != ERTS_LOCK_FLAGS_TYPE_SPINLOCK)
-static __decl_noreturn void __noreturn lc_abort(void);
+static __decl_noreturn void __noreturn lc_abort(void);
static const char *rw_op_str(erts_lock_options_t options)
{
@@ -548,7 +548,7 @@ type_order_violation(char *op, lc_thread_t *thr,
lc_abort();
}
-static void
+static void __noreturn
lock_mismatch(lc_thread_t *thr, int exact,
int failed_have, erts_lc_lock_t *have, int have_len,
int failed_have_not, erts_lc_lock_t *have_not, int have_not_len)
@@ -649,7 +649,7 @@ thread_exit_handler(void)
}
}
-static __decl_noreturn void
+static __decl_noreturn void __noreturn
lc_abort(void)
{
#ifdef __WIN32__
@@ -689,7 +689,6 @@ erts_lc_assert_failed(const char *file, int line, const char *assertion)
file, line, assertion);
print_curr_locks(get_my_locked_locks());
lc_abort();
- return 0;
}
void erts_lc_fail(char *fmt, ...)
@@ -1279,11 +1278,11 @@ void erts_lc_might_unlock_flg(erts_lc_lock_t *lck, erts_lock_options_t options)
ll = thr->required.first;
if (find_lock(&ll, lck))
unlock_of_required_lock(thr, lck);
- }
- ll = thr->locked.first;
- if (!find_lock(&ll, lck))
- unlock_of_not_locked(thr, lck);
+ ll = thr->locked.first;
+ if (!find_lock(&ll, lck))
+ unlock_of_not_locked(thr, lck);
+ }
}
int
diff --git a/erts/emulator/beam/erl_lock_check.h b/erts/emulator/beam/erl_lock_check.h
index b5b141bff6..92f056bee1 100644
--- a/erts/emulator/beam/erl_lock_check.h
+++ b/erts/emulator/beam/erl_lock_check.h
@@ -80,8 +80,8 @@ void erts_lc_might_unlock(erts_lc_lock_t *lck);
void erts_lc_init_lock(erts_lc_lock_t *lck, char *name, erts_lock_flags_t flags);
void erts_lc_init_lock_x(erts_lc_lock_t *lck, char *name, erts_lock_flags_t flags, Eterm extra);
void erts_lc_destroy_lock(erts_lc_lock_t *lck);
-void erts_lc_fail(char *fmt, ...);
-int erts_lc_assert_failed(char *file, int line, char *assertion);
+__decl_noreturn void __noreturn erts_lc_fail(char *fmt, ...);
+__decl_noreturn int erts_lc_assert_failed(char *file, int line, char *assertion);
void erts_lc_set_thread_name(char *thread_name);
void erts_lc_pll(void);
diff --git a/erts/emulator/beam/erl_map.c b/erts/emulator/beam/erl_map.c
index e1650b9356..d82a4acfdf 100644
--- a/erts/emulator/beam/erl_map.c
+++ b/erts/emulator/beam/erl_map.c
@@ -919,6 +919,8 @@ static Eterm hashmap_from_chunked_array(ErtsHeapFactory *factory, hxnode_t *hxns
*hp++ = MAP_HEADER_HAMT_NODE_BITMAP(hdr);
*hp++ = res; sz--;
+ ASSERT(ESTACK_COUNT(stack) > sz);
+
while (sz--) { *hp++ = ESTACK_POP(stack); }
res = make_hashmap(nhp);
hdr = ESTACK_POP(stack);
@@ -1304,6 +1306,7 @@ recurse:
if (sp->nodeA == sp->nodeB) {
res = sp->nodeA;
ctx->size -= is_list(sp->nodeB) ? 1 : hashmap_subtree_size(sp->nodeB);
+ ASSERT(is_value(res));
}
else {
if (is_list(sp->nodeA)) { /* A is LEAF */
@@ -1319,6 +1322,7 @@ recurse:
+ Don't spend time comparing big values.
- Might waste some heap space for internal
nodes that could otherwise be reused. */
+ ASSERT(is_value(res));
goto merge_nodes;
}
}
@@ -2518,6 +2522,8 @@ unroll:
return make_flatmap(mp);
}
+ ASSERT(!ESTACK_ISEMPTY(stack));
+
hp = HAlloc(p, size);
hp_end = hp + size;
res = THE_NON_VALUE;
diff --git a/erts/emulator/beam/erl_message.h b/erts/emulator/beam/erl_message.h
index 82d666923b..c63a1241d8 100644
--- a/erts/emulator/beam/erl_message.h
+++ b/erts/emulator/beam/erl_message.h
@@ -581,8 +581,8 @@ Uint erts_mbuf_size(Process *p);
#define ERTS_FOREACH_SIG_PRIVQS(PROC, MVAR, CODE) \
do { \
int i__; \
- ErtsMessage *msgs__[] = {(PROC)->sig_qs.first, \
- (PROC)->sig_qs.cont}; \
+ ErtsMessage *msgs__[2] = {(PROC)->sig_qs.first, \
+ (PROC)->sig_qs.cont}; \
for (i__ = 0; i__ < sizeof(msgs__)/sizeof(msgs__[0]); i__++) { \
ErtsMessage *MVAR; \
for (MVAR = msgs__[i__]; MVAR; MVAR = MVAR->next) { \
diff --git a/erts/emulator/beam/erl_msacc.h b/erts/emulator/beam/erl_msacc.h
index b2b5be49e2..d348e05c84 100644
--- a/erts/emulator/beam/erl_msacc.h
+++ b/erts/emulator/beam/erl_msacc.h
@@ -370,47 +370,47 @@ void erts_msacc_set_state_m__(ErtsMsAcc *msacc, Uint new_state, int increment) {
#else
#define ERTS_MSACC_IS_ENABLED() 0
-#define erts_msacc_early_init()
-#define erts_msacc_init()
-#define erts_msacc_init_thread(type, id, liberty)
-#define ERTS_MSACC_PUSH_STATE()
-#define ERTS_MSACC_PUSH_STATE_CACHED()
-#define ERTS_MSACC_POP_STATE()
-#define ERTS_MSACC_SET_STATE(state)
-#define ERTS_MSACC_SET_STATE_CACHED(state)
-#define ERTS_MSACC_PUSH_AND_SET_STATE(state)
-#define ERTS_MSACC_PUSH_AND_SET_STATE_CACHED(state)
-#define ERTS_MSACC_UPDATE_CACHE()
-#define ERTS_MSACC_IS_ENABLED_CACHED()
-#define ERTS_MSACC_DECLARE_CACHE()
-#define ERTS_MSACC_PUSH_STATE_M()
-#define ERTS_MSACC_PUSH_STATE_CACHED_M()
-#define ERTS_MSACC_SET_STATE_CACHED_M(state)
-#define ERTS_MSACC_POP_STATE_M()
-#define ERTS_MSACC_PUSH_AND_SET_STATE_M(state)
-#define ERTS_MSACC_SET_BIF_STATE_CACHED_X(Mod,Addr)
+#define erts_msacc_early_init() do {} while(0)
+#define erts_msacc_init() do {} while(0)
+#define erts_msacc_init_thread(type, id, liberty) do {} while(0)
+#define ERTS_MSACC_PUSH_STATE() do {} while(0)
+#define ERTS_MSACC_PUSH_STATE_CACHED() do {} while(0)
+#define ERTS_MSACC_POP_STATE() do {} while(0)
+#define ERTS_MSACC_SET_STATE(state) do {} while(0)
+#define ERTS_MSACC_SET_STATE_CACHED(state) do {} while(0)
+#define ERTS_MSACC_PUSH_AND_SET_STATE(state) do {} while(0)
+#define ERTS_MSACC_PUSH_AND_SET_STATE_CACHED(state) do {} while(0)
+#define ERTS_MSACC_UPDATE_CACHE() do {} while(0)
+#define ERTS_MSACC_IS_ENABLED_CACHED() do {} while(0)
+#define ERTS_MSACC_DECLARE_CACHE()
+#define ERTS_MSACC_PUSH_STATE_M() do {} while(0)
+#define ERTS_MSACC_PUSH_STATE_CACHED_M() do {} while(0)
+#define ERTS_MSACC_SET_STATE_CACHED_M(state) do {} while(0)
+#define ERTS_MSACC_POP_STATE_M() do {} while(0)
+#define ERTS_MSACC_PUSH_AND_SET_STATE_M(state) do {} while(0)
+#define ERTS_MSACC_SET_BIF_STATE_CACHED_X(Mod,Addr) do {} while(0)
#endif /* ERTS_ENABLE_MSACC */
#ifndef ERTS_MSACC_EXTENDED_STATES
-#define ERTS_MSACC_PUSH_STATE_X()
-#define ERTS_MSACC_POP_STATE_X()
-#define ERTS_MSACC_SET_STATE_X(state)
-#define ERTS_MSACC_SET_STATE_M_X(state)
-#define ERTS_MSACC_SET_STATE_CACHED_X(state)
-#define ERTS_MSACC_PUSH_AND_SET_STATE_X(state)
-#define ERTS_MSACC_PUSH_AND_SET_STATE_CACHED_X(state)
-#define ERTS_MSACC_UPDATE_CACHE_X()
+#define ERTS_MSACC_PUSH_STATE_X() do {} while(0)
+#define ERTS_MSACC_POP_STATE_X() do {} while(0)
+#define ERTS_MSACC_SET_STATE_X(state) do {} while(0)
+#define ERTS_MSACC_SET_STATE_M_X(state) do {} while(0)
+#define ERTS_MSACC_SET_STATE_CACHED_X(state) do {} while(0)
+#define ERTS_MSACC_PUSH_AND_SET_STATE_X(state) do {} while(0)
+#define ERTS_MSACC_PUSH_AND_SET_STATE_CACHED_X(state) do {} while(0)
+#define ERTS_MSACC_UPDATE_CACHE_X() do {} while(0)
#define ERTS_MSACC_IS_ENABLED_CACHED_X() 0
#define ERTS_MSACC_DECLARE_CACHE_X()
-#define ERTS_MSACC_PUSH_STATE_M_X()
-#define ERTS_MSACC_PUSH_STATE_CACHED_M_X()
+#define ERTS_MSACC_PUSH_STATE_M_X() do {} while(0)
+#define ERTS_MSACC_PUSH_STATE_CACHED_M_X() do {} while(0)
#define ERTS_MSACC_SET_STATE_CACHED_M_X(state)
-#define ERTS_MSACC_POP_STATE_M_X()
-#define ERTS_MSACC_PUSH_AND_SET_STATE_M_X(state)
-#define ERTS_MSACC_PUSH_AND_SET_STATE_CACHED_M_X(state)
-#define ERTS_MSACC_SET_BIF_STATE_CACHED_X(Mod,Addr)
+#define ERTS_MSACC_POP_STATE_M_X() do {} while(0)
+#define ERTS_MSACC_PUSH_AND_SET_STATE_M_X(state) do {} while(0)
+#define ERTS_MSACC_PUSH_AND_SET_STATE_CACHED_M_X(state) do {} while(0)
+#define ERTS_MSACC_SET_BIF_STATE_CACHED_X(Mod,Addr) do {} while(0)
#else
diff --git a/erts/emulator/beam/erl_process.c b/erts/emulator/beam/erl_process.c
index afb9fa1f55..99f1becec2 100644
--- a/erts/emulator/beam/erl_process.c
+++ b/erts/emulator/beam/erl_process.c
@@ -5283,6 +5283,7 @@ change_no_used_runqs(int used)
{
ErtsMigrationPaths *new_mpaths, *old_mpaths;
int qix;
+ ASSERT(used > 0);
erts_mtx_lock(&balance_info.update_mtx);
set_no_used_runqs(used);
diff --git a/erts/emulator/beam/erl_process_lock.c b/erts/emulator/beam/erl_process_lock.c
index 04fb81eb35..2e422f6f68 100644
--- a/erts/emulator/beam/erl_process_lock.c
+++ b/erts/emulator/beam/erl_process_lock.c
@@ -307,10 +307,10 @@ transfer_locks(Process *p,
& (lock << ERTS_PROC_LOCK_WAITER_SHIFT));
transferred++;
wtr = dequeue_waiter(&p->lock, lock_no);
- ERTS_LC_ASSERT(wtr);
+ ASSERT(wtr != NULL);
if (!p->lock.queue[lock_no])
unset_waiter |= lock;
- ERTS_LC_ASSERT(wtr->uflgs & lock);
+ ASSERT(wtr->uflgs & lock);
wtr->uflgs &= ~lock;
if (wtr->uflgs)
try_aquire(&p->lock, wtr);
diff --git a/erts/emulator/beam/erl_trace.c b/erts/emulator/beam/erl_trace.c
index c1a1aba1f3..904013a8f5 100644
--- a/erts/emulator/beam/erl_trace.c
+++ b/erts/emulator/beam/erl_trace.c
@@ -2861,6 +2861,8 @@ is_tracer_enabled(Process* c_p, ErtsProcLocks c_p_locks,
enum ErtsTracerOpt topt, Eterm tag) {
Eterm nif_result;
+ ASSERT(t_p);
+
#if defined(ERTS_ENABLE_LOCK_CHECK)
if (c_p)
ERTS_LC_ASSERT(erts_proc_lc_my_proc_locks(c_p) == c_p_locks
diff --git a/erts/emulator/beam/external.c b/erts/emulator/beam/external.c
index f66ac8c28f..7d1f8e2857 100644
--- a/erts/emulator/beam/external.c
+++ b/erts/emulator/beam/external.c
@@ -3059,6 +3059,9 @@ enc_term_int(TTBEncodeContext* ctx, ErtsAtomCacheMap *acmp, Eterm obj, byte* ep,
}
}
+ /* If pending connect there must be a context and an iov within that context */
+ ASSERT(!(dflags & DFLAG_PENDING_CONNECT) || (ctx && ctx->iov));
+
goto L_jump_start;
outer_loop:
@@ -3577,7 +3581,6 @@ enc_term_int(TTBEncodeContext* ctx, ErtsAtomCacheMap *acmp, Eterm obj, byte* ep,
case EXPORT_DEF:
{
Export* exp = *((Export **) (export_val(obj) + 1));
- ASSERT(!(dflags & DFLAG_PENDING_CONNECT) || (ctx && ctx->iov));
if (dflags & DFLAG_PENDING_CONNECT)
hopefull_export(ctx, &ep, exp, dflags, off_heap);
else if ((dflags & DFLAG_EXPORT_PTR_TAG) != 0) {
@@ -4978,6 +4981,9 @@ encode_size_struct_int(TTBSizeContext* ctx, ErtsAtomCacheMap *acmp, Eterm obj,
}
}
+ /* If pending connect there must be a context and an iov within that context */
+ ASSERT(!(dflags & DFLAG_PENDING_CONNECT) || ctx);
+
#define LIST_TAIL_OP ((0 << _TAG_PRIMARY_SIZE) | TAG_PRIMARY_HEADER)
#define PATCH_FUN_SIZE_OP ((1 << _TAG_PRIMARY_SIZE) | TAG_PRIMARY_HEADER)
#define TERM_ARRAY_OP(N) (((N+1) << _TAG_PRIMARY_SIZE) | TAG_PRIMARY_HEADER)
diff --git a/erts/emulator/beam/global.h b/erts/emulator/beam/global.h
index a76c61424a..133e1cfa51 100644
--- a/erts/emulator/beam/global.h
+++ b/erts/emulator/beam/global.h
@@ -464,7 +464,7 @@ do { \
#define ESTACK_COUNT(s) ((s).sp - (s).start)
#define ESTACK_ISEMPTY(s) ((s).sp == (s).start)
-#define ESTACK_POP(s) (*(--(s).sp))
+#define ESTACK_POP(s) (ASSERT(!ESTACK_ISEMPTY(s)),(*(--(s).sp)))
/*
diff --git a/erts/emulator/beam/io.c b/erts/emulator/beam/io.c
index 7d71e3d0ff..1468e35449 100644
--- a/erts/emulator/beam/io.c
+++ b/erts/emulator/beam/io.c
@@ -3063,6 +3063,7 @@ static void resize_linebuf(LineBuf **b)
*/
static int flush_linebuf(LineBufContext *bp)
{
+ ASSERT(*bp->b != NULL);
bp->retlen = (*bp->b)->ovlen;
switch(LINEBUF_STATE(*bp)){
case LINEBUF_CR_INSIDE:
diff --git a/erts/emulator/drivers/common/inet_drv.c b/erts/emulator/drivers/common/inet_drv.c
index 3334152738..967958e9ff 100644
--- a/erts/emulator/drivers/common/inet_drv.c
+++ b/erts/emulator/drivers/common/inet_drv.c
@@ -5348,13 +5348,17 @@ static int call_getifaddrs(inet_descriptor* desc_p, struct ifaddrs **ifa_pp)
* over the getifaddrs() call
*/
current_ns = open("/proc/self/ns/net", O_RDONLY);
- if (current_ns == INVALID_SOCKET)
- return sock_errno();
+ if (current_ns == INVALID_SOCKET) {
+ save_errno = sock_errno();
+ ASSERT(save_errno != 0);
+ return save_errno;
+ }
new_ns = open(desc_p->netns, O_RDONLY);
if (new_ns == INVALID_SOCKET) {
save_errno = sock_errno();
while (close(current_ns) == INVALID_SOCKET &&
sock_errno() == EINTR);
+ ASSERT(save_errno != 0);
return save_errno;
}
if (setns(new_ns, CLONE_NEWNET) != 0) {
@@ -5363,6 +5367,7 @@ static int call_getifaddrs(inet_descriptor* desc_p, struct ifaddrs **ifa_pp)
sock_errno() == EINTR);
while (close(current_ns) == INVALID_SOCKET &&
sock_errno() == EINTR);
+ ASSERT(save_errno != 0);
return save_errno;
}
else {
@@ -5387,6 +5392,7 @@ static int call_getifaddrs(inet_descriptor* desc_p, struct ifaddrs **ifa_pp)
if (result >= 0) {
/* We got a result but have to waste it */
save_errno = sock_errno();
+ ASSERT(save_errno != 0);
freeifaddrs(*ifa_pp);
}
}
diff --git a/erts/emulator/drivers/unix/ttsl_drv.c b/erts/emulator/drivers/unix/ttsl_drv.c
index 05bec288d4..fec38df024 100644
--- a/erts/emulator/drivers/unix/ttsl_drv.c
+++ b/erts/emulator/drivers/unix/ttsl_drv.c
@@ -609,6 +609,7 @@ static void octal_or_hex_format(Uint ch, byte *buf, int *pos)
'A','B','C','D','E','F'};
int num = octal_or_hex_positions(ch);
if (num != 3) {
+ ASSERT(num > 3);
buf[(*pos)++] = 'x';
buf[(*pos)++] = '{';
num -= 3;
diff --git a/erts/emulator/sys/common/erl_check_io.c b/erts/emulator/sys/common/erl_check_io.c
index e9091ec771..9d6be82445 100644
--- a/erts/emulator/sys/common/erl_check_io.c
+++ b/erts/emulator/sys/common/erl_check_io.c
@@ -2623,7 +2623,7 @@ static int erts_debug_print_checkio_state(erts_dsprintf_buf_t *dsbufp,
if (state->type == ERTS_EV_TYPE_DRV_SEL) {
erts_dsprintf(dsbufp, "driver_select ");
-
+ ASSERT(state->driver.select != NULL);
#ifdef ERTS_SYS_CONTINOUS_FD_NUMBERS
if (internal) {
erts_dsprintf(dsbufp, "internal ");
@@ -2698,6 +2698,7 @@ static int erts_debug_print_checkio_state(erts_dsprintf_buf_t *dsbufp,
}
else if (state->type == ERTS_EV_TYPE_NIF) {
ErtsResource* r;
+ ASSERT(state->driver.nif != NULL);
erts_dsprintf(dsbufp, "enif_select ");
#ifdef ERTS_SYS_CONTINOUS_FD_NUMBERS
@@ -2823,6 +2824,7 @@ erts_check_io_debug(ErtsCheckIoDebugInfo *ciodip)
null_des.driver.nif = NULL;
null_des.driver.stop.drv_ptr = NULL;
null_des.events = 0;
+ null_des.active_events = 0;
null_des.type = ERTS_EV_TYPE_NONE;
null_des.flags = 0;
diff --git a/erts/emulator/sys/common/erl_mmap.c b/erts/emulator/sys/common/erl_mmap.c
index bb09590b1b..890adbb7cb 100644
--- a/erts/emulator/sys/common/erl_mmap.c
+++ b/erts/emulator/sys/common/erl_mmap.c
@@ -1835,7 +1835,7 @@ void *
erts_mremap(ErtsMemMapper* mm,
Uint32 flags, void *ptr, UWord old_size, UWord *sizep)
{
- void *new_ptr;
+ void *new_ptr = NULL;
Uint32 superaligned;
UWord asize;
@@ -1895,9 +1895,9 @@ erts_mremap(ErtsMemMapper* mm,
}
#endif
#ifdef ERTS_HAVE_OS_MREMAP
- if (superaligned)
+ if (superaligned) {
return remap_move(mm, flags, new_ptr, old_size, sizep);
- else {
+ } else {
new_ptr = os_mremap(ptr, old_size, asize, 0);
if (!new_ptr)
return NULL;
diff --git a/erts/emulator/sys/common/erl_poll.c b/erts/emulator/sys/common/erl_poll.c
index 9f0c82dc4b..d2c808a5a9 100644
--- a/erts/emulator/sys/common/erl_poll.c
+++ b/erts/emulator/sys/common/erl_poll.c
@@ -219,12 +219,12 @@ int ERTS_SELECT(int nfds, ERTS_fd_set *readfds, ERTS_fd_set *writefds,
#else
-#define ERTS_POLLSET_SET_HAVE_UPDATE_REQUESTS(PS)
-#define ERTS_POLLSET_UNSET_HAVE_UPDATE_REQUESTS(PS)
+#define ERTS_POLLSET_SET_HAVE_UPDATE_REQUESTS(PS) do {} while(0)
+#define ERTS_POLLSET_UNSET_HAVE_UPDATE_REQUESTS(PS) do {} while(0)
#define ERTS_POLLSET_HAVE_UPDATE_REQUESTS(PS) 0
-#define ERTS_POLLSET_LOCK(PS)
-#define ERTS_POLLSET_UNLOCK(PS)
+#define ERTS_POLLSET_LOCK(PS) do {} while(0)
+#define ERTS_POLLSET_UNLOCK(PS) do {} while(0)
#endif
@@ -1154,6 +1154,8 @@ static int update_pollset(ErtsPollSet *ps, ErtsPollResFd pr[], int fd)
int last_pix;
if (reset) {
+ /* pr is only null during poll initialization and then no reset should happen */
+ ASSERT(pr != NULL);
/* When a fd has been reset, we tell the caller of erts_poll_wait
this by setting the fd as ERTS_POLL_EV_NONE */
ERTS_POLL_RES_SET_FD(&pr[res], fd);
diff --git a/erts/emulator/sys/unix/sys.c b/erts/emulator/sys/unix/sys.c
index 4fc10cc4f3..7ddfed7d25 100644
--- a/erts/emulator/sys/unix/sys.c
+++ b/erts/emulator/sys/unix/sys.c
@@ -924,7 +924,7 @@ void sys_preload_end(Preload* p)
*/
int sys_get_key(int fd) {
int c, ret;
- unsigned char rbuf[64];
+ unsigned char rbuf[64] = {0};
fd_set fds;
fflush(stdout); /* Flush query ??? */
diff --git a/erts/epmd/src/epmd_int.h b/erts/epmd/src/epmd_int.h
index f5d17aff55..e09dd0ac95 100644
--- a/erts/epmd/src/epmd_int.h
+++ b/erts/epmd/src/epmd_int.h
@@ -97,6 +97,12 @@
# include <systemd/sd-daemon.h>
#endif /* HAVE_SYSTEMD_DAEMON */
+#ifdef DEBUG
+#define ASSERT(Cnd) do { if (!(Cnd)) { abort(); } } while(0)
+#else
+#define ASSERT(Cnd)
+#endif
+
#if defined(HAVE_IN6) && defined(AF_INET6) && defined(HAVE_INET_PTON)
# define EPMD6
#endif
diff --git a/erts/epmd/src/epmd_srv.c b/erts/epmd/src/epmd_srv.c
index ad264585c6..f8fbc45cd2 100644
--- a/erts/epmd/src/epmd_srv.c
+++ b/erts/epmd/src/epmd_srv.c
@@ -1434,6 +1434,7 @@ static Node *node_reg2(EpmdVars *g,
(g->debug && (g->nodes.unreg_count > DEBUG_MAX_UNREG_COUNT)))
{
/* MAX_UNREG_COUNT > 1 so no need to check unreg_tail */
+ ASSERT(g->nodes.unreg != NULL);
node = g->nodes.unreg; /* Take first == oldest */
g->nodes.unreg = node->next; /* Link out */
g->nodes.unreg_count--;
diff --git a/erts/etc/common/heart.c b/erts/etc/common/heart.c
index 215c152008..db4e2cfd24 100644
--- a/erts/etc/common/heart.c
+++ b/erts/etc/common/heart.c
@@ -283,8 +283,8 @@ free_env_val(char *value)
*/
static void get_arguments(int argc, char** argv) {
int i = 1;
- int h;
- unsigned long p;
+ int h = -1;
+ unsigned long p = 0;
while (i < argc) {
switch (argv[i][0]) {
diff --git a/erts/etc/common/inet_gethost.c b/erts/etc/common/inet_gethost.c
index 12012a056e..3814cc3387 100644
--- a/erts/etc/common/inet_gethost.c
+++ b/erts/etc/common/inet_gethost.c
@@ -117,6 +117,17 @@
#endif /* !WIN32 */
+#if defined(__GNUC__)
+# define PROTO_NORETURN__ void __attribute__((noreturn))
+# define IMPL_NORETURN__ void
+#elif defined(__WIN32__) && defined(_MSC_VER)
+# define PROTO_NORETURN__ __declspec(noreturn) void
+# define IMPL_NORETURN__ __declspec(noreturn) void
+#else
+# define PROTO_NORETURN__ void
+# define IMPL_NORETURN__ void
+#endif
+
#define PACKET_BYTES 4
#ifdef WIN32
#define READ_PACKET_BYTES(X,Y,Z) read_int32((X),(Y),(Z))
@@ -298,6 +309,12 @@ static HANDLE debug_console_allocated = INVALID_HANDLE_VALUE;
#define REALLOC(Old, Size) my_realloc((Old), (Size))
#define FREE(Ptr) free(Ptr)
+#ifdef DEBUG
+#define ASSERT(Cnd) do { if (!(Cnd)) { abort(); } } while(0)
+#else
+#define ASSERT(Cnd)
+#endif
+
#ifdef WIN32
#define WAKEUP_WINSOCK() do { \
char dummy_buff[100]; \
@@ -309,7 +326,7 @@ static HANDLE debug_console_allocated = INVALID_HANDLE_VALUE;
static char *format_address(int siz, AddrByte *addr);
static void debugf(char *format, ...);
static void warning(char *format, ...);
-static void fatal(char *format, ...);
+static PROTO_NORETURN__ fatal(char *format, ...);
static void *my_malloc(size_t size);
static void *my_realloc(void *old, size_t size);
static int get_int32(AddrByte *buff);
@@ -1721,6 +1738,7 @@ static int worker_loop(void)
req = REALLOC(req, (req_size = this_size));
}
}
+ ASSERT(req != NULL);
if (read_exact(0, req, (size_t) this_size) != this_size) {
DEBUGF(1,("Worker got EOF while reading data, exiting."));
exit(0);
@@ -2120,6 +2138,7 @@ static size_t build_reply(SerialType serial, struct hostent *he,
(*preply_size = need));
}
}
+ ASSERT(*preply != NULL);
ptr = *preply;
PUT_PACKET_BYTES(ptr,need - PACKET_BYTES);
ptr += PACKET_BYTES;
@@ -2179,7 +2198,7 @@ static size_t build_reply_ai(SerialType serial, int addrlen,
(*preply_size = need));
}
}
-
+ ASSERT(*preply != NULL);
ptr = *preply;
PUT_PACKET_BYTES(ptr,need - PACKET_BYTES);
ptr += PACKET_BYTES;
@@ -2592,7 +2611,7 @@ static void warning(char *format, ...)
va_end(ap);
}
-static void fatal(char *format, ...)
+static IMPL_NORETURN__ fatal(char *format, ...)
{
char buff[2048];
char *ptr;
diff --git a/erts/include/internal/ethread.h b/erts/include/internal/ethread.h
index 83c66f381d..23f9517244 100644
--- a/erts/include/internal/ethread.h
+++ b/erts/include/internal/ethread.h
@@ -83,14 +83,6 @@
# endif
#endif
-int ethr_assert_failed(const char *file, int line, const char *func, char *a);
-#ifdef ETHR_DEBUG
-#define ETHR_ASSERT(A) \
- ((void) ((A) ? 1 : ethr_assert_failed(__FILE__, __LINE__, __func__, #A)))
-#else
-#define ETHR_ASSERT(A) ((void) 1)
-#endif
-
#if defined(__GNUC__)
# define ETHR_PROTO_NORETURN__ void __attribute__((noreturn))
# define ETHR_IMPL_NORETURN__ void
@@ -102,6 +94,16 @@ int ethr_assert_failed(const char *file, int line, const char *func, char *a);
# define ETHR_IMPL_NORETURN__ void
#endif
+ETHR_PROTO_NORETURN__
+ethr_assert_failed(const char *file, int line, const char *func, char *a);
+#ifdef ETHR_DEBUG
+#define ETHR_ASSERT(A) \
+ ((void) ((A) ? 1 : ethr_assert_failed(__FILE__, __LINE__, __func__, #A)))
+#else
+#define ETHR_ASSERT(A) ((void) 1)
+#endif
+
+
#if defined(ETHR_PTHREADS)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* The pthread implementation *
diff --git a/erts/lib_src/common/ethr_aux.c b/erts/lib_src/common/ethr_aux.c
index c24f262e9c..ea860fa568 100644
--- a/erts/lib_src/common/ethr_aux.c
+++ b/erts/lib_src/common/ethr_aux.c
@@ -751,9 +751,9 @@ ETHR_IMPL_NORETURN__ ethr_fatal_error__(const char *file,
ethr_abort__();
}
-int ethr_assert_failed(const char *file, int line, const char *func, char *a)
+ETHR_IMPL_NORETURN__
+ethr_assert_failed(const char *file, int line, const char *func, char *a)
{
fprintf(stderr, "%s:%d: %s(): Assertion failed: %s\n", file, line, func, a);
ethr_abort__();
- return 0;
}
diff --git a/erts/lib_src/common/ethr_mutex.c b/erts/lib_src/common/ethr_mutex.c
index 7be83b9117..acc7cb2da2 100644
--- a/erts/lib_src/common/ethr_mutex.c
+++ b/erts/lib_src/common/ethr_mutex.c
@@ -1058,7 +1058,7 @@ ethr_cond_signal(ethr_cond *cnd)
ethr_ts_event *tse;
ETHR_ASSERT(!ethr_not_inited__);
- ETHR_ASSERT(cnd);
+ ETHR_ASSERT(cnd != NULL);
ETHR_ASSERT(cnd->initialized == ETHR_COND_INITIALIZED);
ETHR_MTX_HARD_DEBUG_FENCE_CHK(cnd);
diff --git a/erts/lib_src/yielding_c_fun/ycf_yield_fun.c b/erts/lib_src/yielding_c_fun/ycf_yield_fun.c
index a597df87c0..9fedac2b79 100644
--- a/erts/lib_src/yielding_c_fun/ycf_yield_fun.c
+++ b/erts/lib_src/yielding_c_fun/ycf_yield_fun.c
@@ -135,7 +135,7 @@ ycf_node* mk_yield_code(ycf_node* f_node,
ycf_symbol_list ret_type = ycf_node_get_return_type(f_node);
ret_code =
ycf_string_new(" {\n"
- " static %s const ycf_unused_ret_value;\n"
+ " static %s const ycf_unused_ret_value = 0;\n"
" return ycf_unused_ret_value;\n"
" }\n",
ycf_symbol_list_to_str(&ret_type));
--
2.26.2