mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
c51cec606d
## Issue being fixed or feature implemented Current implementation relies either on asserts or sometimes checks then returning a special value; In the case of asserts (or no assert where we use the value without checks) it'd be better to make it explicit to function caller that the ptr must be not_null; otherwise gsl::not_null will call terminate. See https://github.com/microsoft/GSL/blob/main/docs/headers.md#user-content-H-pointers-not_null and https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rf-nullptr I'm interested in a conceptual review; specifically on if this is beneficial over just converting these ptrs to be a reference? ## What was done? *Partial* implementation on using gsl::not_null in dash code ## How Has This Been Tested? Building ## Breaking Changes None ## Checklist: _Go over all the following points, and put an `x` in all the boxes that apply._ - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ --------- Signed-off-by: pasta <pasta@dashboost.org> Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
31 lines
1.1 KiB
Bash
Executable File
31 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Copyright (c) 2018 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
#
|
|
# Check include guards.
|
|
|
|
export LC_ALL=C
|
|
HEADER_ID_PREFIX="BITCOIN_"
|
|
HEADER_ID_SUFFIX="_H"
|
|
|
|
REGEXP_EXCLUDE_FILES_WITH_PREFIX="src/(crypto/ctaes/|dashbls/|immer/|leveldb/|crc32c/|secp256k1/|test/fuzz/FuzzedDataProvider.h|tinyformat.h|bench/nanobench.h|univalue/|ctpl_stl.h|bls/|crypto/sph|gsl)"
|
|
|
|
EXIT_CODE=0
|
|
for HEADER_FILE in $(git ls-files -- "*.h" | grep -vE "^${REGEXP_EXCLUDE_FILES_WITH_PREFIX}")
|
|
do
|
|
HEADER_ID_BASE=$(cut -f2- -d/ <<< "${HEADER_FILE}" | sed "s/\.h$//g" | tr / _ | tr "[:lower:]" "[:upper:]" | tr - _)
|
|
HEADER_ID="${HEADER_ID_PREFIX}${HEADER_ID_BASE}${HEADER_ID_SUFFIX}"
|
|
if [[ $(grep -cE "^#(ifndef|define) ${HEADER_ID}" "${HEADER_FILE}") != 2 ]]; then
|
|
echo "${HEADER_FILE} seems to be missing the expected include guard:"
|
|
echo " #ifndef ${HEADER_ID}"
|
|
echo " #define ${HEADER_ID}"
|
|
echo " ..."
|
|
echo " #endif // ${HEADER_ID}"
|
|
echo
|
|
EXIT_CODE=1
|
|
fi
|
|
done
|
|
exit ${EXIT_CODE}
|