rv = (* handle->db->get)( handle->db, &versionKey, &versionData, 0 );
ret = (* handle->db->get)( handle->db, &versionKey, &versionData, 0 );
SECKEY_OpenKeyDB(PRBool readOnly, SECKEYDBNameFunc namecb, void *cbarg){    SECKEYKeyDBHandle *handle;    DBT versionKey;    DBT versionData;    int rv;    int openflags;    char *dbname = NULL;    PRBool updated = PR_FALSE;        handle = (SECKEYKeyDBHandle *)PORT_ZAlloc (sizeof(SECKEYKeyDBHandle));    if (handle == NULL) {	PORT_SetError (SEC_ERROR_NO_MEMORY);	return NULL;    }    versionKey.data = VERSION_STRING;    versionKey.size = sizeof(VERSION_STRING)-1;        if ( readOnly ) {	openflags = O_RDONLY;    } else {	openflags = O_RDWR;    }    dbname = (*namecb)(cbarg, PRIVATE_KEY_DB_FILE_VERSION);    if ( dbname == NULL ) {	goto loser;    }        handle->db = dbopen( dbname, openflags, 0600, DB_HASH, 0 );    /* check for correct version number */    if (handle->db != NULL) {	/* lookup version string in database */	rv = (* handle->db->get)( handle->db, &versionKey, &versionData, 0 );	/* error accessing the database */	if ( rv < 0 ) {	    goto loser;	}	if ( rv == 1 ) {	    /* no version number record, reset the database */	    (* handle->db->close)( handle->db );	    handle->db = NULL;	    goto newdb;	    	}		handle->version = *( (unsigned char *)versionData.data);	    	if (handle->version != PRIVATE_KEY_DB_FILE_VERSION ) {	    /* bogus version number record, reset the database */	    (* handle->db->close)( handle->db );	    handle->db = NULL;	    goto newdb;	}    }newdb:	    /* if first open fails, try to create a new DB */    if ( handle->db == NULL ) {	if ( readOnly ) {	    goto loser;	}		handle->db = dbopen( dbname,			     O_RDWR | O_CREAT | O_TRUNC, 0600, DB_HASH, 0 );        PORT_Free( dbname );        dbname = NULL;	/* if create fails then we lose */	if ( handle->db == NULL ) {	    goto loser;	}	rv = makeGlobalVersion(handle);	if ( rv != SECSuccess ) {	    goto loser;	}	/*	 * try to update from v2 db	 */	dbname = (*namecb)(cbarg, 2);	if ( dbname != NULL ) {	    handle->updatedb = dbopen( dbname, O_RDONLY, 0600, DB_HASH, 0 );	    if ( handle->updatedb ) {		/*		 * Try to update the db using a null password.  If the db		 * doesn't have a password, then this will work.  If it does		 * have a password, then this will fail and we will do the		 * update later		 */		rv = SECKEY_UpdateKeyDBPass1(handle);		if ( rv == SECSuccess ) {		    updated = PR_TRUE;		}	    }	                PORT_Free( dbname );            dbname = NULL;	}	/* we are using the old salt if we updated from an old db */	if ( ! updated ) {	    rv = makeGlobalSalt(handle);	    if ( rv != SECSuccess ) {		goto loser;	    }	}		/* sync the database */	rv = (* handle->db->sync)(handle->db, 0);	if ( rv ) {	    goto loser;	}    }    handle->global_salt = GetKeyDBGlobalSalt(handle);    if ( dbname )        PORT_Free( dbname );    return handle;loser:    if ( dbname )        PORT_Free( dbname );    PORT_SetError(SEC_ERROR_BAD_DATABASE);    if ( handle->db ) {	(* handle->db->close)(handle->db);    }    if ( handle->updatedb ) {	(* handle->updatedb->close)(handle->updatedb);    }    PORT_Free(handle);    return NULL;}