db->db = dbopen(db->filename, O_RDWR, 0600, DB_BTREE, &db->btinfo);
if (db->db != NULL)
goto open_ok;
- switch (errno) {
-#ifdef EFTYPE
- case EFTYPE:
-#endif
- case EINVAL:
+ if (IS_EFTYPE(errno)) {
db->db = dbopen(db->filename, O_RDWR, 0600, DB_HASH, &db->info);
if (db->db != NULL)
goto open_ok;
- default:
+ } else {
(void) osa_adb_release_lock(db);
if (errno == EINVAL)
return OSA_ADB_BAD_DB;
goto done;
/* If that was wrong, retry with the other type. */
- switch (errno) {
-#ifdef EFTYPE
- case EFTYPE:
-#endif
- case EINVAL:
+ if (IS_EFTYPE(errno)) {
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;
- break;
}
/* Don't try unlocked iteration with a hash database. */
#include "adb_err.h"
#include <com_err.h>
+/* DB2 uses EFTYPE to indicate a database file of the wrong format, and falls
+ * back to EINVAL if the platform does not define EFTYPE. */
+#ifdef EFTYPE
+#define IS_EFTYPE(e) ((e) == EFTYPE || (e) == EINVAL)
+#else
+#define IS_EFTYPE(e) ((e) == EINVAL)
+#endif
+
typedef long osa_adb_ret_t;
#define OSA_ADB_POLICY_DB_MAGIC 0x12345A00