aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2017-10-01 15:19:10 +0900
committerKazuki Yamaguchi <k@rhe.jp>2017-10-06 08:47:40 +0000
commita75a9999ee603b3d5322f46a6c40dc9c22023bb9 (patch)
tree9d5efcc0d4265c34500070cae3fcebec3c7355bd
parent7ca6ca4e96a93f9c23fc54320f5ff8e4ff044c8f (diff)
downloadruby-a75a9999ee603b3d5322f46a6c40dc9c22023bb9.tar.gz
gdbm, dbm, sdbm: remove unnecessary conditions
The dfree and dsize callback functions are never called with NULL.
-rw-r--r--ext/dbm/dbm.c15
-rw-r--r--ext/gdbm/gdbm.c15
-rw-r--r--ext/sdbm/init.c8
3 files changed, 15 insertions, 23 deletions
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c
index 1f69f68..4ac6898 100644
--- a/ext/dbm/dbm.c
+++ b/ext/dbm/dbm.c
@@ -59,21 +59,18 @@ static void
free_dbm(void *ptr)
{
struct dbmdata *dbmp = ptr;
- if (dbmp) {
- if (dbmp->di_dbm) dbm_close(dbmp->di_dbm);
- xfree(dbmp);
- }
+ if (dbmp->di_dbm)
+ dbm_close(dbmp->di_dbm);
+ xfree(dbmp);
}
static size_t
memsize_dbm(const void *ptr)
{
- size_t size = 0;
const struct dbmdata *dbmp = ptr;
- if (dbmp) {
- size += sizeof(*dbmp);
- if (dbmp->di_dbm) size += DBM_SIZEOF_DBM;
- }
+ size_t size = sizeof(*dbmp);
+ if (dbmp->di_dbm)
+ size += DBM_SIZEOF_DBM;
return size;
}
diff --git a/ext/gdbm/gdbm.c b/ext/gdbm/gdbm.c
index 2aa9010..85e2b33 100644
--- a/ext/gdbm/gdbm.c
+++ b/ext/gdbm/gdbm.c
@@ -114,21 +114,18 @@ static void
free_dbm(void *ptr)
{
struct dbmdata *dbmp = ptr;
- if (dbmp) {
- if (dbmp->di_dbm) gdbm_close(dbmp->di_dbm);
- xfree(dbmp);
- }
+ if (dbmp->di_dbm)
+ gdbm_close(dbmp->di_dbm);
+ xfree(dbmp);
}
static size_t
memsize_dbm(const void *ptr)
{
- size_t size = 0;
const struct dbmdata *dbmp = ptr;
- if (dbmp) {
- size += sizeof(*dbmp);
- if (dbmp->di_dbm) size += DBM_SIZEOF_DBM;
- }
+ size_t size = sizeof(*dbmp);
+ if (dbmp->di_dbm)
+ size += DBM_SIZEOF_DBM;
return size;
}
diff --git a/ext/sdbm/init.c b/ext/sdbm/init.c
index de99b07..f28eeb2 100644
--- a/ext/sdbm/init.c
+++ b/ext/sdbm/init.c
@@ -99,12 +99,10 @@ free_sdbm(void *ptr)
static size_t
memsize_dbm(const void *ptr)
{
- size_t size = 0;
const struct dbmdata *dbmp = ptr;
- if (dbmp) {
- size += sizeof(*dbmp);
- if (dbmp->di_dbm) size += sizeof(DBM);
- }
+ size_t size = sizeof(*dbmp);
+ if (dbmp->di_dbm)
+ size += sizeof(DBM);
return size;
}