diff options
author | Christian von Roques <roques@mti.ag> | 2011-08-08 16:33:05 +0200 |
---|---|---|
committer | Christian von Roques <roques@mti.ag> | 2011-09-06 20:06:45 +0200 |
commit | ef757a19bdab06e29dcc29de32ef7b8202f2e68d (patch) | |
tree | 5bc7e8ed5c3cbca7d7a4bfc37430d5af833aeee8 | |
parent | 22dae863060e0d66fa268f6d1cd4d6f084b850ab (diff) | |
download | otp-ef757a19bdab06e29dcc29de32ef7b8202f2e68d.tar.gz otp-ef757a19bdab06e29dcc29de32ef7b8202f2e68d.tar.bz2 otp-ef757a19bdab06e29dcc29de32ef7b8202f2e68d.zip |
Changes inspired by running cppcheck(1)
-rw-r--r-- | erts/emulator/sys/common/erl_poll.c | 2 | ||||
-rw-r--r-- | lib/erl_interface/src/legacy/erl_fix_alloc.c | 4 | ||||
-rw-r--r-- | lib/erl_interface/src/registry/reg_dump.c | 1 | ||||
-rw-r--r-- | lib/erl_interface/src/registry/reg_restore.c | 5 |
4 files changed, 9 insertions, 3 deletions
diff --git a/erts/emulator/sys/common/erl_poll.c b/erts/emulator/sys/common/erl_poll.c index f5c785d683..7278075f54 100644 --- a/erts/emulator/sys/common/erl_poll.c +++ b/erts/emulator/sys/common/erl_poll.c @@ -405,7 +405,7 @@ woke_up(ErtsPollSet ps) static ERTS_INLINE void wake_poller(ErtsPollSet ps, int interrupted) { - int wake; + int wake = 0; #ifdef ERTS_SMP erts_aint32_t wakeup_state; if (!interrupted) diff --git a/lib/erl_interface/src/legacy/erl_fix_alloc.c b/lib/erl_interface/src/legacy/erl_fix_alloc.c index 20f3024e41..ca09fc3b8b 100644 --- a/lib/erl_interface/src/legacy/erl_fix_alloc.c +++ b/lib/erl_interface/src/legacy/erl_fix_alloc.c @@ -109,6 +109,10 @@ void *erl_eterm_alloc (void) erl_eterm_state->freed--; } else if ((b = malloc(sizeof(*b))) == NULL) { erl_errno = ENOMEM; +#ifdef _REENTRANT + ei_mutex_unlock(erl_eterm_state->lock); +#endif /* _REENTRANT */ + return NULL; } erl_eterm_state->allocated++; b->free = 0; diff --git a/lib/erl_interface/src/registry/reg_dump.c b/lib/erl_interface/src/registry/reg_dump.c index 1e640fb506..d2854c10b5 100644 --- a/lib/erl_interface/src/registry/reg_dump.c +++ b/lib/erl_interface/src/registry/reg_dump.c @@ -215,6 +215,7 @@ static int mn_send_write(int fd, erlang_pid *mnesia, const char *key, ei_reg_obj else ei_encode_long(msgbuf,&index,(long)(obj->val.p)); /* just the pointer */ break; default: + if (dbuf) free(dbuf); return -1; } diff --git a/lib/erl_interface/src/registry/reg_restore.c b/lib/erl_interface/src/registry/reg_restore.c index 765c3f4314..7bc1c758af 100644 --- a/lib/erl_interface/src/registry/reg_restore.c +++ b/lib/erl_interface/src/registry/reg_restore.c @@ -303,6 +303,9 @@ int ei_reg_restore(int fd, ei_reg *reg, const char *mntab) if (mn_decode_insert(reg,msgbuf,&index,keybuf)) goto restore_failure; } + if (keybuf) free(keybuf); + if (dbuf) free(dbuf); + /* wait for unlink */ if (mn_unlink(fd)) return -1; @@ -310,8 +313,6 @@ int ei_reg_restore(int fd, ei_reg *reg, const char *mntab) ei_hash_foreach(reg->tab,clean_obj); /* success */ - if (keybuf) free(keybuf); - if (dbuf) free(dbuf); return 0; restore_failure: |