We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4c3c9c3 commit ca1a093Copy full SHA for ca1a093
test/lint/lint-assertions.sh
@@ -0,0 +1,23 @@
1
+#!/usr/bin/env bash
2
+#
3
+# Copyright (c) 2018 The Bitcoin Core developers
4
+# Distributed under the MIT software license, see the accompanying
5
+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6
7
+# Check for assertions with obvious side effects.
8
+
9
+export LC_ALL=C
10
11
+EXIT_CODE=0
12
13
+# PRE31-C (SEI CERT C Coding Standard):
14
+# "Assertions should not contain assignments, increment, or decrement operators."
15
+OUTPUT=$(git grep -E '[^_]assert\(.*(\+\+|\-\-|[^=!<>]=[^=!<>]).*\);' -- "*.cpp" "*.h")
16
+if [[ ${OUTPUT} != "" ]]; then
17
+ echo "Assertions should not have side effects:"
18
+ echo
19
+ echo "${OUTPUT}"
20
+ EXIT_CODE=1
21
+fi
22
23
+exit ${EXIT_CODE}
0 commit comments