Skip to content

Commit a46cd14

Browse files
Merge pull request #5706 from craigcomstock/2025-03-06-static-check-fixes
2025 03 06 static check fixes
2 parents f081c22 + d180e6b commit a46cd14

File tree

5 files changed

+23
-13
lines changed

5 files changed

+23
-13
lines changed

.github/workflows/job-static-check.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,7 @@ jobs:
3838
- name: Prepare Environment
3939
run: |
4040
sudo apt-get update && \
41-
sudo apt-get install -y dpkg-dev debhelper g++ libncurses6 pkg-config \
42-
build-essential libpam0g-dev fakeroot gcc make autoconf buildah \
43-
liblmdb-dev libacl1-dev libcurl4-openssl-dev libyaml-dev libxml2-dev \
44-
libssl-dev libpcre2-dev librsync-dev
45-
46-
- name: Run Autogen
47-
run: NO_CONFIGURE=1 PROJECT=community ./buildscripts/build-scripts/autogen
41+
sudo apt-get install -y buildah
4842
4943
- name: Run The Test
5044
working-directory: ./core

cf-check/dump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ static void print_struct_persistent_class(
224224
/* Make a copy to ensure proper alignment. We cannot just copy data to a
225225
* local PersistentClassInfo variable because it contains a
226226
* variable-length string at the end (see the struct definition). */
227-
PersistentClassInfo *class_info = malloc(value.mv_size);
227+
PersistentClassInfo *class_info = xmalloc(value.mv_size);
228228
memcpy(class_info, value.mv_data, value.mv_size);
229229
const unsigned int expires = class_info->expires;
230230
const PersistentClassPolicy policy = class_info->policy;

libpromises/locks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static CfLockStack *LOCK_STACK = NULL;
8484

8585
static void PushLock(char *lock, char *last)
8686
{
87-
CfLockStack *new_lock = malloc(sizeof(CfLockStack));
87+
CfLockStack *new_lock = xmalloc(sizeof(CfLockStack));
8888
strlcpy(new_lock->lock, lock, CF_BUFSIZE);
8989
strlcpy(new_lock->last, last, CF_BUFSIZE);
9090

tests/static-check/run_checks.sh

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,34 @@ set -x
55
n_procs="$(getconf _NPROCESSORS_ONLN)"
66

77
function check_with_gcc() {
8+
# previous runs may have cached configuration based on a different CC
89
rm -f config.cache
910
make clean
10-
./configure -C --enable-debug CC=gcc
11+
# here --config-cache enables lots of checks in subdir libntech to re-use checks made in core
12+
./configure --config-cache --enable-debug CC=gcc
1113
local gcc_exceptions="-Wno-sign-compare -Wno-enum-int-mismatch"
1214
make -j -l${n_procs} --keep-going CFLAGS="-Werror -Wall -Wextra $gcc_exceptions"
1315
}
1416

1517
function check_with_clang() {
18+
# previous runs may have cached configuration based on a different CC
1619
rm -f config.cache
1720
make clean
18-
./configure -C --enable-debug CC=clang
21+
# here --config-cache enables lots of checks in subdir libntech to re-use checks made in core
22+
./configure --config-cache --enable-debug CC=clang
1923
make -j -l${n_procs} --keep-going CFLAGS="-Werror -Wall -Wextra -Wno-sign-compare"
2024
}
2125

2226
function check_with_cppcheck() {
27+
# previous runs may have cached configuration based on a different CC
2328
rm -f config.cache
2429
make clean
30+
# here --config-cache enables lots of checks in subdir libntech to re-use checks made in core
31+
./configure --config-cache --enable-debug
2532
make -C libpromises/ bootstrap.inc # needed by libpromises/bootstrap.c
26-
./configure -C --enable-debug
33+
34+
# print out cppcheck version for comparisons over time in case of regressions due to newer versions
35+
cppcheck --version
2736

2837
# cppcheck options:
2938
# -I -- include paths
@@ -43,6 +52,13 @@ cd "$(dirname $0)"/../../
4352

4453
failure=0
4554
failures=""
55+
56+
# in jenkins the workdir is already autogen'd
57+
# in github it is not, so do that work here
58+
if [ ! -f configure ]; then
59+
./autogen.sh --enable-debug
60+
fi
61+
4662
check_with_gcc || { failures="${failures}FAIL: GCC check failed\n"; failure=1; }
4763
check_with_clang || { failures="${failures}FAIL: Clang check failed\n"; failure=1; }
4864
check_with_cppcheck || { failures="${failures}FAIL: cppcheck failed\n"; failure=1; }

0 commit comments

Comments
 (0)