ubik: calloc ubik_dbase 63/13363/3
authorAndrew Deason <adeason@sinenomine.net>
Mon, 15 Oct 2018 21:10:59 +0000 (16:10 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 26 Oct 2018 14:21:52 +0000 (10:21 -0400)
Instead of using malloc and initializing various fields to 0, allocate
our ubik_dbase using calloc, to more easily ensure all fields are
initialized.

Change-Id: I5c2f345a82a2eb73d53ffc3e1b0fa408af6a8311
Reviewed-on: https://gerrit.openafs.org/13363
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/ubik/ubik.c

index a1aee0c..f93a1bc 100644 (file)
@@ -406,11 +406,8 @@ ubik_ServerInitCommon(afs_uint32 myHost, short myPort,
 
     initialize_U_error_table();
 
-    tdb = malloc(sizeof(struct ubik_dbase));
+    tdb = calloc(1, sizeof(*tdb));
     tdb->pathName = strdup(pathName);
-    tdb->activeTrans = (struct ubik_trans *)0;
-    memset(&tdb->version, 0, sizeof(struct ubik_version));
-    memset(&tdb->cachedVersion, 0, sizeof(struct ubik_version));
 #ifdef AFS_PTHREAD_ENV
     opr_mutex_init(&tdb->versionLock);
     opr_mutex_init(&beacon_globals.beacon_lock);
@@ -421,7 +418,6 @@ ubik_ServerInitCommon(afs_uint32 myHost, short myPort,
     Lock_Init(&tdb->versionLock);
 #endif
     Lock_Init(&tdb->cache_lock);
-    tdb->flags = 0;
     tdb->read = uphys_read;
     tdb->write = uphys_write;
     tdb->truncate = uphys_truncate;
@@ -432,8 +428,6 @@ ubik_ServerInitCommon(afs_uint32 myHost, short myPort,
     tdb->setlabel = uphys_setlabel;
     tdb->getnfiles = uphys_getnfiles;
     tdb->buffered_append = uphys_buf_append;
-    tdb->readers = 0;
-    tdb->tidCounter = tdb->writeTidCounter = 0;
     *dbase = tdb;
     ubik_dbase = tdb;          /* for now, only one db per server; can fix later when we have names for the other dbases */