From bc8051c4b469f776fdb507ae53119fe62fee9015 Mon Sep 17 00:00:00 2001 From: David Declerck Date: Fri, 19 Jul 2024 17:05:10 +0200 Subject: [PATCH] Adjust flmdb.c adjustments --- libcob/flmdb.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libcob/flmdb.c b/libcob/flmdb.c index e55c3001c..1c626db3d 100644 --- a/libcob/flmdb.c +++ b/libcob/flmdb.c @@ -319,13 +319,12 @@ db_suppresskey (cob_file *f, int idx) { unsigned char ch_sprs; int i,len; - struct indexed_file *p; + struct indexed_file *p = p = f->file;; if (!f->keys[idx].tf_suppress) { return 0; } ch_sprs = f->keys[idx].char_suppress & 0xFF; - p = f->file; len = db_savekey(f, p->suppkey, f->record->data, idx); for (i = 0; i < len; i++) { if (p->suppkey[i] != ch_sprs) @@ -1163,13 +1162,12 @@ lmdb_start (cob_file_api *a, cob_file *f, const int cond, cob_field *key) static int lmdb_read (cob_file_api *a, cob_file *f, cob_field *key, const int read_opts) { - struct indexed_file *p; + struct indexed_file *p = f->file; int ret; int db_opts; int test_lock = 0; COB_UNUSED (a); - p = f->file; db_opts = read_opts; if ((ret = lmdb_start_internal (f, COB_EQ, key, db_opts, test_lock)) != COB_STATUS_00_SUCCESS) { @@ -1209,8 +1207,9 @@ lmdb_read_next (cob_file_api *a, cob_file *f, const int read_opts) if (f->open_mode != COB_OPEN_I_O || (f->lock_mode & COB_FILE_EXCLUSIVE)) { db_opts &= ~COB_READ_LOCK; - } else if ((f->lock_mode & COB_LOCK_AUTOMATIC) && - !(db_opts & COB_READ_NO_LOCK)) { + } else + if ((f->lock_mode & COB_LOCK_AUTOMATIC) && + !(db_opts & COB_READ_NO_LOCK)) { db_opts |= COB_READ_LOCK; } unlock_record (f); @@ -1290,6 +1289,7 @@ lmdb_read_next (cob_file_api *a, cob_file *f, const int read_opts) #if 0 /* TODO: Come back and implement locking. */ if (db_env != NULL && !file_changed) { + ret = 0; if (!(db_opts & COB_READ_IGNORE_LOCK)) { ret = test_record_lock (f, p->key.mv_data, p->key.mv_size); if (ret) { @@ -1299,7 +1299,7 @@ lmdb_read_next (cob_file_api *a, cob_file *f, const int read_opts) } return COB_STATUS_51_RECORD_LOCKED; } - } + } else if (db_opts & COB_READ_LOCK) { ret = lock_record (f, p->key.mv_data, p->key.mv_size); if (ret) { @@ -1413,6 +1413,7 @@ lmdb_read_next (cob_file_api *a, cob_file *f, const int read_opts) #if 0 /* TODO: Come back and implement locking */ if (db_env != NULL) { + ret = 0; if (!(db_opts & COB_READ_IGNORE_LOCK)) { ret = test_record_lock (f, p->key.mv_data, p->key.mv_size); if (ret) { @@ -1424,7 +1425,7 @@ lmdb_read_next (cob_file_api *a, cob_file *f, const int read_opts) } return COB_STATUS_51_RECORD_LOCKED; } - } + } else if (db_opts & COB_READ_LOCK) { ret = lock_record (f, p->key.mv_data, p->key.mv_size); if (ret) { @@ -1473,7 +1474,7 @@ lmdb_read_next (cob_file_api *a, cob_file *f, const int read_opts) static int lmdb_write (cob_file_api *a, cob_file *f, const int opt) { - struct indexed_file *p; + struct indexed_file *p = p = f->file;; int rc = 0; unsigned int cs = COB_STATUS_00_SUCCESS; @@ -1481,7 +1482,6 @@ lmdb_write (cob_file_api *a, cob_file *f, const int opt) if (f->flag_nonexistent) { return COB_STATUS_48_OUTPUT_DENIED; } - p = f->file; /* Check record key */ db_setkey (f, 0);