mirror of
https://github.com/curl/curl.git
synced 2026-07-30 07:48:02 +03:00
clang-tidy: add to CI, add cmake support, fix fallouts
build: - autotools: fix to build generated sources for the `tidy` target. - autotools: allow passing custom clang-tidy options via `CURL_CLANG_TIDYFLAGS` env. - cmake: add `CURL_CLANG_TIDY` option to configure for `clang-tidy`. Also add: - `CLANG_TIDY` variable to customize the `clang-tidy` tool. - `CURL_CLANG_TIDYFLAGS` to pass custom options to `clang-tidy`. - apply `--enable-werror` and `-DCURL_WERROR=ON` to `clang-tidy`. CI/GHA: - add clang-tidy job for Linux, using autotools and clang-tidy v18. This one needs to disable `clang-analyzer-valist.Uninitialized` to avoid false positives: https://github.com/llvm/llvm-project/issues/40656 Duration: 5.5 minutes - add clang-tidy job for macOS, using cmake and clang-tidy v19. This one also covers tests and examples, and doesn't hit the false positives seen with llvm v18 and earlier. Duration: 4.5 minutes - Linux/macOS: skip installing test dependencies when not building or running tests. fix fallouts reported by `clang-tidy`: - lib: - cf-h2-proxy: unused assignment in non-debug builds. - cf-socket: silence warning. FIXME: https://github.com/curl/curl/pull/15825#issuecomment-2561867769 - ftp: NULL passed to `strncmp()`. - http2: NULL-ptr deref. - mprintf: silence warning. - src/tool_writeout: NULL passed to `fputs()`. - examples: - invalid file pointers. - missing `fclose()`. - tests: - http/clients/hx-download: memory leaks on error. - http/clients/hx-download: memory leak on repeat `-r` option. - server: double `fclose()`. https://www.man7.org/linux/man-pages/man3/fclose.3.html - server: invalid file pointer/handle. - server/getpart: unused assignments. - server/mqttd: leak on failed `realloc()`. - server/tftpd: NULL passed to `strcmp()`. Closes #15825
This commit is contained in:
parent
421e592db2
commit
fabfa8e402
27 changed files with 134 additions and 68 deletions
12
.github/workflows/macos.yml
vendored
12
.github/workflows/macos.yml
vendored
|
|
@ -131,6 +131,10 @@ jobs:
|
|||
- name: 'OpenSSL gsasl rtmp AppleIDN'
|
||||
install: gsasl rtmpdump
|
||||
generate: -DOPENSSL_ROOT_DIR=$(brew --prefix openssl) -DCURL_USE_GSASL=ON -DUSE_LIBRTMP=ON -DUSE_APPLE_IDN=ON
|
||||
- name: 'OpenSSL AppleIDN clang-tidy +examples'
|
||||
install: llvm
|
||||
generate: -DOPENSSL_ROOT_DIR=$(brew --prefix openssl) -DUSE_APPLE_IDN=ON -DCURL_CLANG_TIDY=ON -DCLANG_TIDY=$(brew --prefix llvm)/bin/clang-tidy
|
||||
clang-tidy: true
|
||||
- name: 'OpenSSL +static libssh +examples'
|
||||
install: libssh
|
||||
generate: -DOPENSSL_ROOT_DIR=$(brew --prefix openssl) -DBUILD_STATIC_LIBS=ON -DCURL_USE_LIBSSH2=OFF -DCURL_USE_LIBSSH=ON
|
||||
|
|
@ -161,6 +165,8 @@ jobs:
|
|||
- { compiler: llvm@15, build: { macos-version-min: '10.15' } }
|
||||
- { compiler: llvm@15, build: { torture: true } }
|
||||
- { compiler: gcc-12, build: { torture: true } }
|
||||
- { compiler: llvm@15, build: { clang-tidy: true } }
|
||||
- { compiler: gcc-12, build: { clang-tidy: true } }
|
||||
# opt out jobs from combinations that have the compiler set manually
|
||||
- { compiler: llvm@15, build: { compiler: 'clang' } }
|
||||
- { compiler: llvm@15, build: { compiler: 'gcc-12' } }
|
||||
|
|
@ -176,7 +182,9 @@ jobs:
|
|||
# https://github.com/curl/curl/runs/4095721123?check_suite_focus=true
|
||||
run: |
|
||||
echo ${{ matrix.build.generate && 'ninja' || 'automake libtool' }} \
|
||||
pkgconf libpsl libssh2 nghttp2 stunnel ${{ matrix.build.install }} | xargs -Ix -n1 echo brew '"x"' > /tmp/Brewfile
|
||||
pkgconf libpsl libssh2 \
|
||||
${{ !matrix.build.clang-tidy && 'nghttp2 stunnel' || '' }} \
|
||||
${{ matrix.build.install }} | xargs -Ix -n1 echo brew '"x"' > /tmp/Brewfile
|
||||
while [[ $? == 0 ]]; do for i in 1 2 3; do brew update && brew bundle install --no-lock --file /tmp/Brewfile && break 2 || { echo Error: wait to try again; sleep 10; } done; false Too many retries; done
|
||||
|
||||
- name: 'brew unlink openssl'
|
||||
|
|
@ -281,12 +289,14 @@ jobs:
|
|||
fi
|
||||
|
||||
- name: 'install test prereqs'
|
||||
if: ${{ !matrix.build.clang-tidy }}
|
||||
run: |
|
||||
python3 -m venv $HOME/venv
|
||||
source $HOME/venv/bin/activate
|
||||
python3 -m pip install -r tests/requirements.txt
|
||||
|
||||
- name: 'run tests'
|
||||
if: ${{ !matrix.build.clang-tidy }}
|
||||
timeout-minutes: ${{ matrix.build.torture && 20 || 10 }}
|
||||
run: |
|
||||
export TFLAGS='-j20 ${{ matrix.build.tflags }}'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue