mirror of
https://github.com/curl/curl.git
synced 2026-07-25 02:37:18 +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
18
.github/workflows/linux.yml
vendored
18
.github/workflows/linux.yml
vendored
|
|
@ -37,6 +37,7 @@ permissions: {}
|
|||
|
||||
env:
|
||||
MAKEFLAGS: -j 5
|
||||
CURL_CLANG_TIDYFLAGS: '-checks=-clang-analyzer-security.insecureAPI.strcpy,-clang-analyzer-optin.performance.Padding,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-clang-analyzer-valist.Uninitialized'
|
||||
# unhandled
|
||||
bearssl-version: 0.6
|
||||
# renovate: datasource=github-tags depName=libressl-portable/portable versioning=semver registryUrl=https://github.com
|
||||
|
|
@ -210,6 +211,12 @@ jobs:
|
|||
- name: '!ssl !http !smtp !imap'
|
||||
configure: --without-ssl --enable-debug --disable-http --disable-smtp --disable-imap --disable-unity
|
||||
|
||||
- name: clang-tidy
|
||||
install_packages: clang-tidy libssl-dev libssh2-1-dev
|
||||
install_steps: skipall
|
||||
configure: --with-openssl --with-libssh2
|
||||
make-custom-target: tidy
|
||||
|
||||
- name: scanbuild
|
||||
install_packages: clang-tools clang libssl-dev libssh2-1-dev
|
||||
install_steps: skipall
|
||||
|
|
@ -287,7 +294,8 @@ jobs:
|
|||
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y --no-install-suggests --no-install-recommends \
|
||||
libtool autoconf automake pkgconf ninja-build stunnel4 \
|
||||
libtool autoconf automake pkgconf ninja-build \
|
||||
${{ matrix.build.install_steps != 'skipall' && matrix.build.install_steps != 'skiprun' && 'stunnel4' || '' }} \
|
||||
libpsl-dev libbrotli-dev libzstd-dev \
|
||||
${{ matrix.build.install_packages }}
|
||||
python3 -m venv $HOME/venv
|
||||
|
|
@ -595,7 +603,7 @@ jobs:
|
|||
if [ -n '${{ matrix.build.generate }}' ]; then
|
||||
${{ matrix.build.make-prefix }} cmake --build . --verbose
|
||||
else
|
||||
${{ matrix.build.make-prefix }} make V=1
|
||||
${{ matrix.build.make-prefix }} make V=1 ${{ matrix.build.make-custom-target }}
|
||||
fi
|
||||
|
||||
- name: 'single-use function check'
|
||||
|
|
@ -609,8 +617,9 @@ jobs:
|
|||
fi
|
||||
./scripts/singleuse.pl --unit ${libcurla}
|
||||
|
||||
- run: ./src/curl -V
|
||||
name: 'check curl -V output'
|
||||
- name: 'check curl -V output'
|
||||
if: ${{ matrix.build.make-custom-target != 'tidy' }}
|
||||
run: ./src/curl -V
|
||||
|
||||
- run: cmake --install . --prefix $HOME/curl --strip
|
||||
if: ${{ matrix.build.generate }}
|
||||
|
|
@ -671,6 +680,7 @@ jobs:
|
|||
fi
|
||||
|
||||
- name: 'build examples'
|
||||
if: ${{ matrix.build.make-custom-target != 'tidy' }}
|
||||
run: |
|
||||
if [ -n '${{ matrix.build.generate }}' ]; then
|
||||
${{ matrix.build.make-prefix }} cmake --build . --verbose --target curl-examples
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue