Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions .github/workflows/CI-unixish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

strategy:
matrix:
os: [ubuntu-22.04, macos-13]
os: [ubuntu-22.04, macos-13, macos-15]
fail-fast: false # Prefer quick result

runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:

strategy:
matrix:
os: [ubuntu-22.04, macos-13]
os: [ubuntu-22.04, macos-13, macos-15]
fail-fast: false # Prefer quick result

runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -155,7 +155,7 @@ jobs:

strategy:
matrix:
os: [ubuntu-22.04, macos-13]
os: [ubuntu-22.04, macos-13, macos-15]
fail-fast: false # Prefer quick result

runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -189,7 +189,7 @@ jobs:

strategy:
matrix:
os: [ubuntu-22.04, macos-13]
os: [ubuntu-22.04, macos-13, macos-15]
fail-fast: false # Prefer quick result

runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -223,7 +223,7 @@ jobs:

strategy:
matrix:
os: [ubuntu-22.04, macos-13]
os: [ubuntu-22.04, macos-13, macos-15]
fail-fast: false # Prefer quick result

runs-on: ${{ matrix.os }}
Expand All @@ -247,7 +247,7 @@ jobs:

strategy:
matrix:
os: [ubuntu-22.04, macos-13]
os: [ubuntu-22.04, macos-13, macos-15]
include:
- xdist_n: auto
# FIXME: test_color_tty fails with xdist
Expand Down Expand Up @@ -284,16 +284,30 @@ jobs:
if: contains(matrix.os, 'macos')
run: |
# pcre was removed from runner images in November 2022
brew install coreutils python3 pcre gnu-sed
brew install coreutils pcre gnu-sed

- name: Install missing Python packages
- name: Install missing Python packages on ubuntu
if: contains(matrix.os, 'ubuntu')
run: |
python3 -m pip install pip --upgrade
python3 -m pip install pytest
python3 -m pip install pytest-timeout
python3 -m pip install pytest-xdist
python3 -m pip install psutil

# we need to use -break-system-packages --user because the common approaches do not work.
# using pip works but it appears to install the packages into a different Python installation so they are not found later on.
# using python3 -m pip without the additional flags fails since the packages are being managed by a different tool (brew) and that lacks some of the packages.
# using pipx also does not work.
- name: Install missing Python packages on macos
if: contains(matrix.os, 'macos')
run: |
python3 -m pip install --break-system-packages --user pip --upgrade
python3 -m pip install --break-system-packages --user pytest
python3 -m pip install --break-system-packages --user pytest-timeout
python3 -m pip install --break-system-packages --user pytest-xdist
python3 -m pip install --break-system-packages --user psutil

- name: Build cppcheck
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scriptcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ jobs:
dmake:
strategy:
matrix:
os: [ubuntu-22.04, macos-13, windows-2025]
os: [ubuntu-22.04, macos-13, macos-15, windows-2025]
fail-fast: false

runs-on: ${{ matrix.os }}
Expand Down
12 changes: 11 additions & 1 deletion test/cfg/gnu.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ int deallocuse_backtrace(int size) {
return numEntries;
}

#if !defined(__APPLE__)
void leakReturnValNotUsed_get_current_dir_name(void)
{
// cppcheck-suppress leakReturnValNotUsed
Expand Down Expand Up @@ -114,7 +115,6 @@ int nullPointer_gethostbyname_r(const char* name, struct hostent* ret, const cha
return gethostbyname_r(name, ret, buf, buflen, result, h_errnop);
}


int nullPointer_gethostbyaddr_r(const void* addr, socklen_t len, int type, struct hostent* ret, const char* buf, size_t buflen, struct hostent** result, const int* h_errnop)
{
// cppcheck-suppress nullPointer
Expand All @@ -129,6 +129,7 @@ int nullPointer_gethostbyaddr_r(const void* addr, socklen_t len, int type, struc
(void) gethostbyaddr_r(addr, len, type, ret, buf, buflen, result, NULL);
return gethostbyaddr_r(addr, len, type, ret, buf, buflen, result, h_errnop);
}
#endif

int nullPointer_getopt_long(int argc, char **argv, const char *optstring,
const struct option *longopts, int *longindex)
Expand All @@ -154,6 +155,7 @@ int nullPointer_getopt_long_only(int argc, char* const* argv, const char* optstr
return getopt_long_only(argc, argv, optstring, longopts, longindex);
}

#if !defined(__APPLE__)
int nullPointer_getservent_r(struct servent *restrict result_buf, const char *restrict buf, size_t buflen, struct servent **restrict result)
{
// cppcheck-suppress nullPointer
Expand All @@ -173,6 +175,7 @@ void *bufferAccessOutOfBounds_memrchr(const void *s, int c, size_t n)
(void)memrchr(buf,c,43);
return memrchr(s,c,n);
}
#endif

void knownConditionTrueFalse_ffsl(long i)
{
Expand All @@ -192,6 +195,7 @@ void knownConditionTrueFalse_ffsll(long long i)
if (ffsll(i) == 0) {}
}

#if !defined(__APPLE__)
int nullPointer_semtimedop(int semid, struct sembuf *sops, size_t nsops, const struct timespec *timeout)
{
(void) semtimedop(semid, sops, nsops, NULL); // If the timeout argument is NULL, then semtimedop() behaves exactly like semop().
Expand Down Expand Up @@ -227,8 +231,10 @@ int uninitvar_getpw(uid_t uid, char *buf)
// cppcheck-suppress uninitvar
return getpw(someUid, buf);
}
#endif

// Declaration necessary because there is no specific / portable header.
// https://www.eyrie.org/~eagle/software/rra-c-util/xmalloc.html
extern void *xcalloc(size_t nmemb, size_t size);
extern void *xmalloc(size_t size);
extern void *xrealloc(void *block, size_t newsize);
Expand Down Expand Up @@ -294,8 +300,10 @@ void valid_code(int argInt1, va_list valist_arg, const int * parg)

if (__builtin_expect(argInt1, 0)) {}
if (__builtin_expect_with_probability(argInt1 + 1, 2, 0.5)) {}
#ifdef __GLIBC__
if (__glibc_unlikely(argInt1 != 0)) {}
if (__glibc_likely(parg != NULL)) {}
#endif
const void *ax1 = __builtin_assume_aligned(parg, 16);
printf("%p", ax1);
const void *ax2 = __builtin_assume_aligned(parg, 32, 8);
Expand Down Expand Up @@ -489,6 +497,7 @@ void bufferAccessOutOfBounds()
free(pAlloc2);
}

#if !defined(__APPLE__)
void leakReturnValNotUsed()
{
// cppcheck-suppress [unreadVariable, constVariablePointer]
Expand All @@ -508,6 +517,7 @@ void leakReturnValNotUsed()
if (42 == __builtin_expect(42, 0))
return;
}
#endif

#if !defined(__CYGWIN__) && !defined(__APPLE__)
int nullPointer_epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)
Expand Down
2 changes: 2 additions & 0 deletions test/cfg/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ int nullPointer_getpwnam_r(const char *name, struct passwd *pwd, char *buffer, s
return getpwnam_r(name, pwd, buffer, bufsize, result);
}

#if !defined(__APPLE__)
int nullPointer_fgetpwent_r(FILE *restrict stream, const struct passwd *restrict pwbuf, char *restrict buf, size_t buflen, struct passwd **restrict pwbufp)
{
// cppcheck-suppress nullPointer
Expand All @@ -248,6 +249,7 @@ int nullPointer_getpwent_r(const struct passwd *restrict pwbuf, char *restrict b
(void) getpwent_r(pwbuf, buf, buflen, NULL);
return getpwent_r(pwbuf, buf, buflen, pwbufp);
}
#endif

int nullPointer_getgrgid_r(gid_t gid, struct group *restrict grp, char *restrict buf, size_t buflen, struct group **restrict result)
{
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ CPPCHECK_OPT=(
CXX=g++
CXX_OPT=("-fsyntax-only" "-w" "-std=c++2a")
CC=gcc
CC_OPT=("-fsyntax-only" "-w" "-Wno-implicit-function-declaration" "-std=c11") # TODO: remove -Wno-implicit-function-declaration when warnings are fixed on MacOS
CC_OPT=("-fsyntax-only" "-w" "-std=c11")

function get_pkg_config_cflags {
# TODO: get rid of the error enabling/disabling?
Expand Down
8 changes: 7 additions & 1 deletion test/signal/test-signalhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import os
import sys
import pytest
import platform

from packaging.version import Version

def __lookup_cppcheck_exe(exe_name):
# path the script is located in
Expand Down Expand Up @@ -64,7 +67,10 @@ def test_segv():
assert stderr == ''
lines = stdout.splitlines()
if sys.platform == "darwin":
assert lines[0] == 'Internal error: cppcheck received signal SIGSEGV - SEGV_MAPERR (at 0x0).'
if Version(platform.mac_ver()[0]) >= Version('14'):
assert lines[0] == 'Internal error: cppcheck received signal SIGSEGV - SEGV_ACCERR (at 0x0).'
else:
assert lines[0] == 'Internal error: cppcheck received signal SIGSEGV - SEGV_MAPERR (at 0x0).'
else:
assert lines[0] == 'Internal error: cppcheck received signal SIGSEGV - SEGV_MAPERR (reading at 0x0).'
# no stacktrace on macOS
Expand Down
3 changes: 2 additions & 1 deletion test/testmathlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,8 @@ class TestMathLib : public TestFixture {

ASSERT_THROW_INTERNAL_EQUALS(MathLib::toDoubleNumber("invalid"), INTERNAL, "Internal Error. MathLib::toDoubleNumber: conversion failed: invalid");

#if defined(_LIBCPP_VERSION) && (defined(__APPLE__) && defined(__MACH__))
// AppleClang before 18 reports a different error
#if (defined(__APPLE__) && defined(__MACH__)) && (defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION < 180000))
ASSERT_THROW_INTERNAL_EQUALS(MathLib::toDoubleNumber("1invalid"), INTERNAL, "Internal Error. MathLib::toDoubleNumber: conversion failed: 1invalid");
ASSERT_THROW_INTERNAL_EQUALS(MathLib::toDoubleNumber("1.1invalid"), INTERNAL, "Internal Error. MathLib::toDoubleNumber: conversion failed: 1.1invalid");
#else
Expand Down