From bc7b9984d33908d6a5e6bf417e1778a9d994984a Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Mon, 22 Aug 2016 13:46:36 +0300 Subject: [PATCH 1/5] mdbx: fix copyright timestamps. 1 of 2 for https://github.com/ReOpen/libmdbx/issues/3 Change-Id: I7a0b820e092e7b0064ae22341bebcd015e37b7c7 --- COPYRIGHT | 2 +- intro.doc | 2 +- lmdb.h | 4 ++-- mdb.c | 2 +- mdb_copy.1 | 2 +- mdb_copy.c | 2 +- mdb_dump.1 | 2 +- mdb_dump.c | 2 +- mdb_load.c | 2 +- mdb_stat.1 | 2 +- mdb_stat.c | 2 +- midl.c | 2 +- midl.h | 2 +- mtest0.c | 2 +- mtest2.c | 2 +- mtest3.c | 2 +- mtest4.c | 2 +- mtest5.c | 2 +- mtest6.c | 2 +- sample-bdb.txt | 2 +- sample-mdb.txt | 2 +- 21 files changed, 22 insertions(+), 22 deletions(-) diff --git a/COPYRIGHT b/COPYRIGHT index 842d1677..1ebd52b2 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -18,7 +18,7 @@ along with this program. If not, see . --- -Copyright 2011-2014 Howard Chu, Symas Corp. +Copyright 2011-2016 Howard Chu, Symas Corp. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/intro.doc b/intro.doc index aeaeb21d..cfe6976e 100644 --- a/intro.doc +++ b/intro.doc @@ -19,7 +19,7 @@ * * --- * - * Copyright 2015-2014 Howard Chu, Symas Corp. + * Copyright 2015 Howard Chu, Symas Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/lmdb.h b/lmdb.h index 4a3d57e7..fb9c6467 100644 --- a/lmdb.h +++ b/lmdb.h @@ -120,7 +120,7 @@ * Howard Chu, Symas Corp. All rights reserved. * * @copyright 2015,2016 Leonid Yuriev . - * 2011-2014 Howard Chu, Symas Corp. All rights reserved. + * 2011-2016 Howard Chu, Symas Corp. All rights reserved. * * --- * @@ -146,7 +146,7 @@ * @par Derived From: * This code is derived from LMDB engine written by Howard Chu, Symas Corporation. * - * Copyright 2011-2014 Howard Chu, Symas Corp. All rights reserved. + * Copyright 2011-2016 Howard Chu, Symas Corp. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted only as authorized by the OpenLDAP diff --git a/mdb.c b/mdb.c index f37b2ba1..c9d4d359 100644 --- a/mdb.c +++ b/mdb.c @@ -26,7 +26,7 @@ * * --- * - * Copyright 2011-2014 Howard Chu, Symas Corp. + * Copyright 2011-2016 Howard Chu, Symas Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/mdb_copy.1 b/mdb_copy.1 index 2cadb3ac..73a05012 100644 --- a/mdb_copy.1 +++ b/mdb_copy.1 @@ -18,7 +18,7 @@ .\" .\" --- .\" -.\" Copyright 2012-2014 Howard Chu, Symas Corp. All Rights Reserved. +.\" Copyright 2012-2016 Howard Chu, Symas Corp. All Rights Reserved. .\" Copying restrictions apply. See COPYRIGHT/LICENSE. .TH MDB_COPY 1 "2014/06/20" "LMDB 0.9.14" .SH NAME diff --git a/mdb_copy.c b/mdb_copy.c index f2db960e..5023b05d 100644 --- a/mdb_copy.c +++ b/mdb_copy.c @@ -21,7 +21,7 @@ * * --- * - * Copyright 2012-2014 Howard Chu, Symas Corp. + * Copyright 2012-2016 Howard Chu, Symas Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/mdb_dump.1 b/mdb_dump.1 index ead2d92a..0d23c15b 100644 --- a/mdb_dump.1 +++ b/mdb_dump.1 @@ -18,7 +18,7 @@ .\" .\" --- .\" -.\" Copyright 2014 Howard Chu, Symas Corp. All Rights Reserved. +.\" Copyright 2014-2016 Howard Chu, Symas Corp. All Rights Reserved. .\" Copying restrictions apply. See COPYRIGHT/LICENSE. .TH MDB_DUMP 1 "2014/06/20" "LMDB 0.9.14" .SH NAME diff --git a/mdb_dump.c b/mdb_dump.c index b5f3af6c..ce721bdf 100644 --- a/mdb_dump.c +++ b/mdb_dump.c @@ -21,7 +21,7 @@ * * --- * - * Copyright 2011-2014 Howard Chu, Symas Corp. + * Copyright 2011-2016 Howard Chu, Symas Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/mdb_load.c b/mdb_load.c index 2d89a501..a1d2755d 100644 --- a/mdb_load.c +++ b/mdb_load.c @@ -21,7 +21,7 @@ * * --- * - * Copyright 2011-2014 Howard Chu, Symas Corp. + * Copyright 2011-2016 Howard Chu, Symas Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/mdb_stat.1 b/mdb_stat.1 index f2739bb4..aa1d3348 100644 --- a/mdb_stat.1 +++ b/mdb_stat.1 @@ -18,7 +18,7 @@ .\" .\" --- .\" -.\" Copyright 2012-2014 Howard Chu, Symas Corp. All Rights Reserved. +.\" Copyright 2012-2016 Howard Chu, Symas Corp. All Rights Reserved. .\" Copying restrictions apply. See COPYRIGHT/LICENSE. .TH MDB_STAT 1 "2014/06/20" "LMDB 0.9.14" .SH NAME diff --git a/mdb_stat.c b/mdb_stat.c index ab523467..03565ed4 100644 --- a/mdb_stat.c +++ b/mdb_stat.c @@ -21,7 +21,7 @@ * * --- * - * Copyright 2011-2014 Howard Chu, Symas Corp. + * Copyright 2011-2016 Howard Chu, Symas Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/midl.c b/midl.c index 9dcad71a..bfe22715 100644 --- a/midl.c +++ b/midl.c @@ -22,7 +22,7 @@ * * --- * - * Copyright 2000-2014 The OpenLDAP Foundation. + * Copyright 2000-2016 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/midl.h b/midl.h index 2d6f2753..360b068d 100644 --- a/midl.h +++ b/midl.h @@ -30,7 +30,7 @@ * * --- * - * Copyright 2000-2014 The OpenLDAP Foundation. + * Copyright 2000-2016 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/mtest0.c b/mtest0.c index 9b86cc0c..330c72e8 100644 --- a/mtest0.c +++ b/mtest0.c @@ -20,7 +20,7 @@ * along with this program. If not, see . * * - * Copyright 2011-2014 Howard Chu, Symas Corp. + * Copyright 2011-2016 Howard Chu, Symas Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/mtest2.c b/mtest2.c index f9860c66..b2c76459 100644 --- a/mtest2.c +++ b/mtest2.c @@ -21,7 +21,7 @@ * * --- * - * Copyright 2011-2014 Howard Chu, Symas Corp. + * Copyright 2011-2016 Howard Chu, Symas Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/mtest3.c b/mtest3.c index b1d30ca3..7272b2dc 100644 --- a/mtest3.c +++ b/mtest3.c @@ -21,7 +21,7 @@ * * --- * - * Copyright 2011-2014 Howard Chu, Symas Corp. + * Copyright 2011-2016 Howard Chu, Symas Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/mtest4.c b/mtest4.c index 5cec46b7..48ed0eab 100644 --- a/mtest4.c +++ b/mtest4.c @@ -21,7 +21,7 @@ * * --- * - * Copyright 2011-2014 Howard Chu, Symas Corp. + * Copyright 2011-2016 Howard Chu, Symas Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/mtest5.c b/mtest5.c index 31c92f01..1540ba02 100644 --- a/mtest5.c +++ b/mtest5.c @@ -21,7 +21,7 @@ * * --- * - * Copyright 2011-2014 Howard Chu, Symas Corp. + * Copyright 2011-2016 Howard Chu, Symas Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/mtest6.c b/mtest6.c index b150f1c4..d5672888 100644 --- a/mtest6.c +++ b/mtest6.c @@ -21,7 +21,7 @@ * * --- * - * Copyright 2011-2014 Howard Chu, Symas Corp. + * Copyright 2011-2016 Howard Chu, Symas Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sample-bdb.txt b/sample-bdb.txt index 165585b9..d01cc29b 100644 --- a/sample-bdb.txt +++ b/sample-bdb.txt @@ -24,7 +24,7 @@ * * --- * - * Copyright 2012-2014 Howard Chu, Symas Corp. + * Copyright 2012-2016 Howard Chu, Symas Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sample-mdb.txt b/sample-mdb.txt index 7ad5769d..6b0eda10 100644 --- a/sample-mdb.txt +++ b/sample-mdb.txt @@ -24,7 +24,7 @@ * * --- * - * Copyright 2012-2014 Howard Chu, Symas Corp. + * Copyright 2012-2016 Howard Chu, Symas Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without From ae92d0d6718fae4ec3dad237697fad709b3229c7 Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Mon, 22 Aug 2016 14:39:45 +0300 Subject: [PATCH 2/5] mdbx: fixes issues detected by PVS-Studio. See http://www.viva64.com/en/b/0422/ This is Partial for https://github.com/ReOpen/ReOpenLDAP/issues/107 Change-Id: Ic47d3cb1ff88ca0807bdd692a1e01487c70b264c --- mdb.c | 31 +++++++++++++++++-------------- mdb_dump.c | 2 +- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/mdb.c b/mdb.c index c9d4d359..4caa8c5f 100644 --- a/mdb.c +++ b/mdb.c @@ -1222,11 +1222,12 @@ mdb_strerror(int err) static txnid_t mdbx_oomkick(MDB_env *env, txnid_t oldest); #endif /* MDBX_MODE_ENABLED */ +static void mdb_debug_log(int type, const char *function, int line, const char *fmt, ...) + __attribute__((format(gnu_printf, 4, 5))); + #if MDB_DEBUG static txnid_t mdb_debug_edge; - static void mdb_debug_log(int type, const char *function, int line, - const char *fmt, ...); static void __cold mdb_assert_fail(MDB_env *env, const char *msg, const char *func, int line) @@ -1263,8 +1264,7 @@ static txnid_t mdbx_oomkick(MDB_env *env, txnid_t oldest); #endif /* MDB_DEBUG */ static void __cold -mdb_debug_log(int type, const char *function, int line, - const char *fmt, ...) +mdb_debug_log(int type, const char *function, int line, const char *fmt, ...) { va_list args; @@ -1272,8 +1272,12 @@ mdb_debug_log(int type, const char *function, int line, if (mdb_debug_logger) mdb_debug_logger(type, function, line, fmt, args); else { - if (function && line) - fprintf(stderr, "%s:%u ", function, line); + if (function && line > 0) + fprintf(stderr, "%s:%d ", function, line); + else if (function) + fprintf(stderr, "%s: ", function); + else if (line > 0) + fprintf(stderr, "%d: ", line); vfprintf(stderr, fmt, args); } va_end(args); @@ -1344,7 +1348,6 @@ char * mdb_dkey(MDB_val *key, char *buf) { char *ptr = buf; - unsigned char *c = key->mv_data; unsigned i; if (!key) @@ -1358,7 +1361,7 @@ mdb_dkey(MDB_val *key, char *buf) #if 1 buf[0] = '\0'; for (i=0; imv_size; i++) - ptr += sprintf(ptr, "%02x", *c++); + ptr += sprintf(ptr, "%02x", ((unsigned char*) key->mv_data)[i]); #else sprintf(buf, "%.*s", key->mv_size, key->mv_data); #endif @@ -1405,14 +1408,14 @@ mdb_page_list(MDB_page *mp) } nkeys = NUMKEYS(mp); - mdb_print("%s %zu numkeys %d%s\n", type, pgno, nkeys, state); + mdb_print("%s %zu numkeys %u%s\n", type, pgno, nkeys, state); for (i=0; imp_leaf2_ksize; key.mv_data = LEAF2KEY(mp, i, nsize); total += nsize; - mdb_print("key %d: nsize %d, %s\n", i, nsize, DKEY(&key)); + mdb_print("key %u: nsize %u, %s\n", i, nsize, DKEY(&key)); continue; } node = NODEPTR(mp, i); @@ -1420,7 +1423,7 @@ mdb_page_list(MDB_page *mp) key.mv_data = node->mn_data; nsize = NODESIZE + key.mv_size; if (IS_BRANCH(mp)) { - mdb_print("key %d: page %zu, %s\n", i, NODEPGNO(node), DKEY(&key)); + mdb_print("key %u: page %zu, %s\n", i, NODEPGNO(node), DKEY(&key)); total += nsize; } else { if (F_ISSET(node->mn_flags, F_BIGDATA)) @@ -1429,12 +1432,12 @@ mdb_page_list(MDB_page *mp) nsize += NODEDSZ(node); total += nsize; nsize += sizeof(indx_t); - mdb_print("key %d: nsize %d, %s%s\n", + mdb_print("key %u: nsize %u, %s%s\n", i, nsize, DKEY(&key), mdb_leafnode_type(node)); } total = EVEN(total); } - mdb_print("Total: header %d + contents %d + unused %d\n", + mdb_print("Total: header %u + contents %u + unused %u\n", IS_LEAF2(mp) ? PAGEHDRSZ : PAGEBASE + mp->mp_lower, total, SIZELEFT(mp)); } @@ -5651,7 +5654,7 @@ mdb_ovpage_free(MDB_cursor *mc, MDB_page *mp) MDB_ID pn = pg << 1; int rc; - mdb_debug("free ov page %zu (%d)", pg, ovpages); + mdb_debug("free ov page %zu (%u)", pg, ovpages); /* If the page is dirty or on the spill list we just acquired it, * so we should give it back to our current free list, if any. * Otherwise put it onto the list of pages we freed in this txn. diff --git a/mdb_dump.c b/mdb_dump.c index ce721bdf..3b67e3b4 100644 --- a/mdb_dump.c +++ b/mdb_dump.c @@ -147,7 +147,7 @@ static int dumpit(MDB_txn *txn, MDB_dbi dbi, char *name) rc = mdb_cursor_open(txn, dbi, &mc); if (rc) return rc; - while ((rc = mdb_cursor_get(mc, &key, &data, MDB_NEXT) == MDB_SUCCESS)) { + while ((rc = mdb_cursor_get(mc, &key, &data, MDB_NEXT)) == MDB_SUCCESS) { if (gotsig) { rc = EINTR; break; From 4b373b233d62ad9ac13a694f3a31b9b1bc4f0298 Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Tue, 23 Aug 2016 14:56:06 +0300 Subject: [PATCH 3/5] mdbx: minor cleanup mdbx_setup_debug(). Change-Id: I1d246420431518c1e6253fbdc2e6beeedbd8c4b6 --- mdbx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mdbx.c b/mdbx.c index 7281147f..fae09fbd 100644 --- a/mdbx.c +++ b/mdbx.c @@ -49,12 +49,11 @@ mdbx_setup_debug(int flags, MDBX_debug_func* logger, long edge_txn) { mdb_runtime_flags = flags; if (logger != (MDBX_debug_func*) MDBX_DBG_DNT) mdb_debug_logger = logger; + if (edge_txn != (long) MDBX_DBG_DNT) { #if MDB_DEBUG - if (edge_txn != (long) MDBX_DBG_DNT) mdb_debug_edge = edge_txn; -#else - (void) edge_txn; #endif + } return ret; } From fed33a943e61b5e3fc66580a50bba5f84cab6130 Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Tue, 23 Aug 2016 15:00:58 +0300 Subject: [PATCH 4/5] mdbx: adds Makefile deps from mdbx.c Fix commit 9407621eba08ff339b21de75b8d229788370e7d8 Change-Id: I16dd4e2d6b3343f0827d7af13a93193ffc22c426 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4bc4c810..9016fba9 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,7 @@ TESTS := mtest0 mtest1 mtest2 mtest3 mtest4 mtest5 mtest6 wbench \ yota_test1 yota_test2 SRC_LMDB := mdb.c midl.c lmdb.h midl.h reopen.h barriers.h -SRC_MDBX := $(SRC_LMDB) mdbx.h +SRC_MDBX := $(SRC_LMDB) mdbx.c mdbx.h .PHONY: mdbx lmdb all install clean check tests coverage From a92c4a9c17692cbcd62589f0008dfc1fa81d214d Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Tue, 23 Aug 2016 15:13:32 +0300 Subject: [PATCH 5/5] mdbx: adds LICENSE note. More for https://github.com/ReOpen/libmdbx/issues/3 Change-Id: I3606bb7011e705f149b26a610cbd33741c11da25 --- LICENSE | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/LICENSE b/LICENSE index 210c8aa8..62bf0465 100644 --- a/LICENSE +++ b/LICENSE @@ -1,3 +1,9 @@ +Note: This project pending for dual licensing. We assume to resolve +issues related to OpenLDAP Public License and then provide dual +licensing under OpenLDAP and AGPL. Sign the CLA before contributing. + +*********************************************************************** + GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007