diff options
author | mmcc <mmcc@cvs.openbsd.org> | 2015-12-28 22:08:19 +0000 |
---|---|---|
committer | mmcc <mmcc@cvs.openbsd.org> | 2015-12-28 22:08:19 +0000 |
commit | 2b7e45a9f71e83195c6a0adf68237584f51e58a7 (patch) | |
tree | 8318880361e05bcfcbf5d545011888bf0e7d43e3 /lib/libc/db | |
parent | ca0f93cf7f05b71a14ee9ed66e06416c9ff657ba (diff) |
Remove NULL-checks before free() and a few related dead assignments.
ok and valuable input from millert@
Diffstat (limited to 'lib/libc/db')
-rw-r--r-- | lib/libc/db/btree/bt_open.c | 5 | ||||
-rw-r--r-- | lib/libc/db/hash/hash.c | 11 | ||||
-rw-r--r-- | lib/libc/db/hash/hash_bigkey.c | 8 |
3 files changed, 9 insertions, 15 deletions
diff --git a/lib/libc/db/btree/bt_open.c b/lib/libc/db/btree/bt_open.c index b6a715cc7ef..f8ea301f1b8 100644 --- a/lib/libc/db/btree/bt_open.c +++ b/lib/libc/db/btree/bt_open.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bt_open.c,v 1.18 2014/09/15 06:12:19 guenther Exp $ */ +/* $OpenBSD: bt_open.c,v 1.19 2015/12/28 22:08:18 mmcc Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -318,8 +318,7 @@ eftype: errno = EFTYPE; err: saved_errno = errno; if (t) { - if (t->bt_dbp) - free(t->bt_dbp); + free(t->bt_dbp); if (t->bt_fd != -1) (void)close(t->bt_fd); free(t); diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c index 7578e507da4..5b1c2980362 100644 --- a/lib/libc/db/hash/hash.c +++ b/lib/libc/db/hash/hash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hash.c,v 1.27 2015/11/01 03:45:28 guenther Exp $ */ +/* $OpenBSD: hash.c,v 1.28 2015/12/28 22:08:18 mmcc Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -407,12 +407,9 @@ hdestroy(HTAB *hashp) save_errno = errno; /* Free Bigmaps */ for (i = 0; i < hashp->nmaps; i++) - if (hashp->mapp[i]) - free(hashp->mapp[i]); - if (hashp->tmp_key) - free(hashp->tmp_key); - if (hashp->tmp_buf) - free(hashp->tmp_buf); + free(hashp->mapp[i]); + free(hashp->tmp_key); + free(hashp->tmp_buf); if (hashp->fp != -1) (void)close(hashp->fp); diff --git a/lib/libc/db/hash/hash_bigkey.c b/lib/libc/db/hash/hash_bigkey.c index 18682cc1b28..c98165432ba 100644 --- a/lib/libc/db/hash/hash_bigkey.c +++ b/lib/libc/db/hash/hash_bigkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hash_bigkey.c,v 1.18 2015/01/16 16:48:51 deraadt Exp $ */ +/* $OpenBSD: hash_bigkey.c,v 1.19 2015/12/28 22:08:18 mmcc Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -452,8 +452,7 @@ collect_data(HTAB *hashp, BUFHEAD *bufp, int len, int set) if (bp[2] == FULL_KEY_DATA) { /* End of Data */ totlen = len + mylen; - if (hashp->tmp_buf) - free(hashp->tmp_buf); + free(hashp->tmp_buf); if ((hashp->tmp_buf = (char *)malloc(totlen)) == NULL) return (-1); if (set) { @@ -518,8 +517,7 @@ collect_key(HTAB *hashp, BUFHEAD *bufp, int len, DBT *val, int set) save_addr = bufp->addr; totlen = len + mylen; if (bp[2] == FULL_KEY || bp[2] == FULL_KEY_DATA) { /* End of Key. */ - if (hashp->tmp_key != NULL) - free(hashp->tmp_key); + free(hashp->tmp_key); if ((hashp->tmp_key = (char *)malloc(totlen)) == NULL) return (-1); if (__big_return(hashp, bufp, 1, val, set)) |