svn rev #24508: trunk/src/plugins/kdb/db2/
ghudson@MIT.EDU
ghudson at MIT.EDU
Wed Nov 3 13:32:11 EDT 2010
http://src.mit.edu/fisheye/changelog/krb5/?cs=24508
Commit By: ghudson
Log Message:
Simplify kdb_db2's open_db() a little further, avoiding a suspicious
switch fallthrough.
Changed Files:
U trunk/src/plugins/kdb/db2/kdb_db2.c
Modified: trunk/src/plugins/kdb/db2/kdb_db2.c
===================================================================
--- trunk/src/plugins/kdb/db2/kdb_db2.c 2010-11-03 16:43:49 UTC (rev 24507)
+++ trunk/src/plugins/kdb/db2/kdb_db2.c 2010-11-03 17:32:11 UTC (rev 24508)
@@ -309,13 +309,14 @@
hashi.lorder = 0;
hashi.nelem = 1;
+ /* Try our best guess at the database type. */
db = dbopen(fname, flags, mode,
dbc->hashfirst ? DB_HASH : DB_BTREE,
dbc->hashfirst ? (void *) &hashi : (void *) &bti);
- if (db != NULL) {
- free(fname);
- return db;
- }
+ if (db != NULL)
+ goto done;
+
+ /* If that was wrong, retry with the other type. */
switch (errno) {
#ifdef EFTYPE
case EFTYPE:
@@ -324,12 +325,15 @@
db = dbopen(fname, flags, mode,
dbc->hashfirst ? DB_BTREE : DB_HASH,
dbc->hashfirst ? (void *) &bti : (void *) &hashi);
+ /* If that worked, update our guess for next time. */
if (db != NULL)
dbc->hashfirst = !dbc->hashfirst;
- default:
- free(fname);
- return db;
+ break;
}
+
+done:
+ free(fname);
+ return db;
}
/* Initialize the lock file and policy database fields of the DB2 context
More information about the cvs-krb5
mailing list