Skip to content

Commit d873ff9

Browse files
committed
refactor: cleanups post unsubtree'ing univalue
Mostly changes to remove src/univalue exceptions from the various linters, and the required code changes to make them happy. As well as minor doc changes.
1 parent e2aa704 commit d873ff9

22 files changed

+32
-56
lines changed

Diff for: .gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ src/obj
4444
share/setup.nsi
4545
share/qt/Info.plist
4646

47-
src/univalue/gen
48-
4947
src/qt/*.moc
5048
src/qt/moc_*.cpp
5149
src/qt/forms/ui_*.h

Diff for: Makefile.am

-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ LCOV_FILTER_PATTERN = \
174174
-p "src/leveldb/" \
175175
-p "src/crc32c/" \
176176
-p "src/bench/" \
177-
-p "src/univalue" \
178177
-p "src/crypto/ctaes" \
179178
-p "src/minisketch" \
180179
-p "src/secp256k1" \

Diff for: ci/lint/06_script.sh

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export COMMIT_RANGE
1818
test/lint/git-subtree-check.sh src/crypto/ctaes
1919
test/lint/git-subtree-check.sh src/secp256k1
2020
test/lint/git-subtree-check.sh src/minisketch
21-
test/lint/git-subtree-check.sh src/univalue
2221
test/lint/git-subtree-check.sh src/leveldb
2322
test/lint/git-subtree-check.sh src/crc32c
2423
test/lint/check-doc.py

Diff for: contrib/devtools/copyright_header.py

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"src/leveldb/",
3636
"src/minisketch",
3737
"src/secp256k1/",
38-
"src/univalue/",
3938
"src/crc32c/",
4039
]
4140

Diff for: doc/developer-notes.md

-4
Original file line numberDiff line numberDiff line change
@@ -1158,10 +1158,6 @@ Current subtrees include:
11581158
- src/crypto/ctaes
11591159
- Upstream at https://github.com/bitcoin-core/ctaes ; maintained by Core contributors.
11601160

1161-
- src/univalue
1162-
- Subtree at https://github.com/bitcoin-core/univalue-subtree ; maintained by Core contributors.
1163-
- Deviates from upstream https://github.com/jgarzik/univalue.
1164-
11651161
- src/minisketch
11661162
- Upstream at https://github.com/sipa/minisketch ; maintained by Core contributors.
11671163

Diff for: src/univalue/include/univalue.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or https://opensource.org/licenses/mit-license.php.
55

6-
#ifndef __UNIVALUE_H__
7-
#define __UNIVALUE_H__
6+
#ifndef BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_H
7+
#define BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_H
88

99
#include <charconv>
1010
#include <cstdint>
@@ -194,4 +194,4 @@ extern const UniValue NullUniValue;
194194

195195
const UniValue& find_value( const UniValue& obj, const std::string& name);
196196

197-
#endif // __UNIVALUE_H__
197+
#endif // BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_H

Diff for: src/univalue/lib/univalue_escapes.h renamed to src/univalue/include/univalue_escapes.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
// Automatically generated file. Do not modify.
2-
#ifndef BITCOIN_UNIVALUE_UNIVALUE_ESCAPES_H
3-
#define BITCOIN_UNIVALUE_UNIVALUE_ESCAPES_H
1+
#ifndef BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_ESCAPES_H
2+
#define BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_ESCAPES_H
43
static const char *escapes[256] = {
54
"\\u0000",
65
"\\u0001",
@@ -259,4 +258,4 @@ static const char *escapes[256] = {
259258
nullptr,
260259
nullptr,
261260
};
262-
#endif // BITCOIN_UNIVALUE_UNIVALUE_ESCAPES_H
261+
#endif // BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_ESCAPES_H

Diff for: src/univalue/lib/univalue_utffilter.h renamed to src/univalue/include/univalue_utffilter.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Copyright 2016 Wladimir J. van der Laan
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or https://opensource.org/licenses/mit-license.php.
4-
#ifndef UNIVALUE_UTFFILTER_H
5-
#define UNIVALUE_UTFFILTER_H
4+
#ifndef BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_UTFFILTER_H
5+
#define BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_UTFFILTER_H
66

77
#include <string>
88

@@ -116,4 +116,4 @@ class JSONUTF8StringFilter
116116
}
117117
};
118118

119-
#endif
119+
#endif // BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_UTFFILTER_H

Diff for: src/univalue/lib/univalue_read.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// file COPYING or https://opensource.org/licenses/mit-license.php.
44

55
#include <univalue.h>
6-
#include "univalue_utffilter.h"
6+
#include <univalue_utffilter.h>
77

88
#include <cstdio>
99
#include <cstdint>

Diff for: src/univalue/lib/univalue_write.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// file COPYING or https://opensource.org/licenses/mit-license.php.
44

55
#include <univalue.h>
6-
#include "univalue_escapes.h"
6+
#include <univalue_escapes.h>
77

88
#include <memory>
99
#include <string>

Diff for: src/univalue/sources.mk

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ UNIVALUE_INCLUDE_DIR_INT = %reldir%/include
1212

1313
UNIVALUE_DIST_HEADERS_INT =
1414
UNIVALUE_DIST_HEADERS_INT += %reldir%/include/univalue.h
15-
16-
UNIVALUE_LIB_HEADERS_INT =
17-
UNIVALUE_LIB_HEADERS_INT += %reldir%/lib/univalue_utffilter.h
18-
UNIVALUE_LIB_HEADERS_INT += %reldir%/lib/univalue_escapes.h
15+
UNIVALUE_DIST_HEADERS_INT += %reldir%/include/univalue_utffilter.h
16+
UNIVALUE_DIST_HEADERS_INT += %reldir%/include/univalue_escapes.h
1917

2018
UNIVALUE_LIB_SOURCES_INT =
2119
UNIVALUE_LIB_SOURCES_INT += %reldir%/lib/univalue.cpp

Diff for: src/univalue/test/unitester.cpp

+13-21
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,7 @@
1212
#error JSON_TEST_SRC must point to test source directory
1313
#endif
1414

15-
#ifndef ARRAY_SIZE
16-
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
17-
#endif
18-
1915
std::string srcdir(JSON_TEST_SRC);
20-
static bool test_failed = false;
21-
22-
#define d_assert(expr) { if (!(expr)) { test_failed = true; fprintf(stderr, "%s failed\n", filename.c_str()); } }
23-
#define f_assert(expr) { if (!(expr)) { test_failed = true; fprintf(stderr, "%s failed\n", __func__); } }
2416

2517
static std::string rtrim(std::string s)
2618
{
@@ -41,9 +33,9 @@ static void runtest(std::string filename, const std::string& jdata)
4133
bool testResult = val.read(jdata);
4234

4335
if (wantPass) {
44-
d_assert(testResult == true);
36+
assert(testResult == true);
4537
} else {
46-
d_assert(testResult == false);
38+
assert(testResult == false);
4739
}
4840

4941
if (wantRoundTrip) {
@@ -141,30 +133,30 @@ void unescape_unicode_test()
141133
bool testResult;
142134
// Escaped ASCII (quote)
143135
testResult = val.read("[\"\\u0022\"]");
144-
f_assert(testResult);
145-
f_assert(val[0].get_str() == "\"");
136+
assert(testResult);
137+
assert(val[0].get_str() == "\"");
146138
// Escaped Basic Plane character, two-byte UTF-8
147139
testResult = val.read("[\"\\u0191\"]");
148-
f_assert(testResult);
149-
f_assert(val[0].get_str() == "\xc6\x91");
140+
assert(testResult);
141+
assert(val[0].get_str() == "\xc6\x91");
150142
// Escaped Basic Plane character, three-byte UTF-8
151143
testResult = val.read("[\"\\u2191\"]");
152-
f_assert(testResult);
153-
f_assert(val[0].get_str() == "\xe2\x86\x91");
144+
assert(testResult);
145+
assert(val[0].get_str() == "\xe2\x86\x91");
154146
// Escaped Supplementary Plane character U+1d161
155147
testResult = val.read("[\"\\ud834\\udd61\"]");
156-
f_assert(testResult);
157-
f_assert(val[0].get_str() == "\xf0\x9d\x85\xa1");
148+
assert(testResult);
149+
assert(val[0].get_str() == "\xf0\x9d\x85\xa1");
158150
}
159151

160152
int main (int argc, char *argv[])
161153
{
162-
for (unsigned int fidx = 0; fidx < ARRAY_SIZE(filenames); fidx++) {
163-
runtest_file(filenames[fidx]);
154+
for (const auto& f: filenames) {
155+
runtest_file(f);
164156
}
165157

166158
unescape_unicode_test();
167159

168-
return test_failed ? 1 : 0;
160+
return 0;
169161
}
170162

Diff for: test/lint/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ To do a full check with `-r`, make sure that you have fetched the upstream repos
2828
maintained:
2929
* for `src/secp256k1`: https://github.com/bitcoin-core/secp256k1.git (branch master)
3030
* for `src/leveldb`: https://github.com/bitcoin-core/leveldb-subtree.git (branch bitcoin-fork)
31-
* for `src/univalue`: https://github.com/bitcoin-core/univalue-subtree.git (branch master)
3231
* for `src/crypto/ctaes`: https://github.com/bitcoin-core/ctaes.git (branch master)
3332
* for `src/crc32c`: https://github.com/bitcoin-core/crc32c-subtree.git (branch bitcoin-fork)
3433
* for `src/minisketch`: https://github.com/sipa/minisketch.git (branch master)

Diff for: test/lint/lint-files.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
ALLOWED_FILENAME_REGEXP = "^[a-zA-Z0-9/_.@][a-zA-Z0-9/_.@-]*$"
2222
ALLOWED_SOURCE_FILENAME_REGEXP = "^[a-z0-9_./-]+$"
2323
ALLOWED_SOURCE_FILENAME_EXCEPTION_REGEXP = (
24-
"^src/(secp256k1/|minisketch/|univalue/|test/fuzz/FuzzedDataProvider.h)"
24+
"^src/(secp256k1/|minisketch/|test/fuzz/FuzzedDataProvider.h)"
2525
)
2626
ALLOWED_PERMISSION_NON_EXECUTABLES = 0o644
2727
ALLOWED_PERMISSION_EXECUTABLES = 0o755

Diff for: test/lint/lint-format-strings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def main():
7777

7878
matching_files_filtered = []
7979
for matching_file in matching_files:
80-
if not re.search('^src/(leveldb|secp256k1|minisketch|tinyformat|univalue|test/fuzz/strprintf.cpp)', matching_file):
80+
if not re.search('^src/(leveldb|secp256k1|minisketch|tinyformat|test/fuzz/strprintf.cpp)', matching_file):
8181
matching_files_filtered.append(matching_file)
8282
matching_files_filtered.sort()
8383

Diff for: test/lint/lint-include-guards.py

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
'src/crc32c',
2323
'src/secp256k1',
2424
'src/minisketch',
25-
'src/univalue',
2625
'src/tinyformat.h',
2726
'src/bench/nanobench.h',
2827
'src/test/fuzz/FuzzedDataProvider.h']

Diff for: test/lint/lint-includes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"src/crc32c/",
2020
"src/secp256k1/",
2121
"src/minisketch/",
22-
"src/univalue/"]
22+
]
2323

2424
EXPECTED_BOOST_INCLUDES = ["boost/algorithm/string/replace.hpp",
2525
"boost/date_time/posix_time/posix_time.hpp",

Diff for: test/lint/lint-locale-dependence.py

-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
"src/secp256k1/",
6161
"src/minisketch/",
6262
"src/tinyformat.h",
63-
"src/univalue/"
6463
]
6564

6665
LOCALE_DEPENDENT_FUNCTIONS = [

Diff for: test/lint/lint-shell-locale.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def main():
4141
exit_code = 0
4242
shell_files = get_shell_files_list()
4343
for file_path in shell_files:
44-
if re.search('src/(secp256k1|minisketch|univalue)/', file_path):
44+
if re.search('src/(secp256k1|minisketch)/', file_path):
4545
continue
4646

4747
with open(file_path, 'r', encoding='utf-8') as file_obj:

Diff for: test/lint/lint-shell.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def main():
6868
]
6969
files = get_files(files_cmd)
7070
# remove everything that doesn't match this regex
71-
reg = re.compile(r'src/[leveldb,secp256k1,minisketch,univalue]')
71+
reg = re.compile(r'src/[leveldb,secp256k1,minisketch]')
7272
files[:] = [file for file in files if not reg.match(file)]
7373

7474
# build the `shellcheck` command

Diff for: test/lint/lint-spelling.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from subprocess import check_output, STDOUT, CalledProcessError
1313

1414
IGNORE_WORDS_FILE = 'test/lint/spelling.ignore-words.txt'
15-
FILES_ARGS = ['git', 'ls-files', '--', ":(exclude)build-aux/m4/", ":(exclude)contrib/seeds/*.txt", ":(exclude)depends/", ":(exclude)doc/release-notes/", ":(exclude)src/leveldb/", ":(exclude)src/crc32c/", ":(exclude)src/qt/locale/", ":(exclude)src/qt/*.qrc", ":(exclude)src/secp256k1/", ":(exclude)src/minisketch/", ":(exclude)src/univalue/", ":(exclude)contrib/builder-keys/keys.txt", ":(exclude)contrib/guix/patches"]
15+
FILES_ARGS = ['git', 'ls-files', '--', ":(exclude)build-aux/m4/", ":(exclude)contrib/seeds/*.txt", ":(exclude)depends/", ":(exclude)doc/release-notes/", ":(exclude)src/leveldb/", ":(exclude)src/crc32c/", ":(exclude)src/qt/locale/", ":(exclude)src/qt/*.qrc", ":(exclude)src/secp256k1/", ":(exclude)src/minisketch/", ":(exclude)contrib/builder-keys/keys.txt", ":(exclude)contrib/guix/patches"]
1616

1717

1818
def check_codespell_install():

Diff for: test/lint/lint-whitespace.py

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"src/crc32c/",
2323
"src/secp256k1/",
2424
"src/minisketch/",
25-
"src/univalue/",
2625
"doc/release-notes/",
2726
"src/qt/locale"]
2827

0 commit comments

Comments
 (0)