From fc6e92b9d0b13246974b205b0d6e7b4785e5c2cc Mon Sep 17 00:00:00 2001 From: vianney Date: Fri, 14 Jun 2024 11:02:15 +0200 Subject: [PATCH] Run clippy on windows in CI (#485) * Run clippy on windows in CI * Fix win32 clippy error * Revert clippy rust_version check * Fix clippy error on windows --- .github/workflows/lint.yml | 9 ++++++--- profiling-ffi/src/lib.rs | 2 +- spawn_worker/src/win32.rs | 3 +-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 21d580fdd..2829f74c5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,13 +15,14 @@ jobs: run: rustup update nightly && rustup default nightly && rustup component add rustfmt - run: cargo fmt --all -- --check clippy: - name: "clippy #${{ matrix.rust_version }}" + name: "clippy #${{ matrix.platform }} ${{ matrix.rust_version }}" + runs-on: ${{ matrix.platform }} strategy: fail-fast: false matrix: # Ignore nightly for now, it fails too often rust_version: ["1.71.1", "stable"] - runs-on: ubuntu-latest + platform: [windows-latest, ubuntu-latest] steps: - name: Checkout sources uses: actions/checkout@v4 @@ -31,7 +32,9 @@ jobs: rust_version: ${{ matrix.rust_version }} - name: Install ${{ matrix.version }} toolchain and clippy run: rustup install ${{ matrix.rust_version }} && rustup default ${{ matrix.rust_version }} && rustup component add clippy - - run: cargo clippy --all-targets --all-features -- -D warnings $([ ${{ matrix.rust_version }} = 1.71.1 ] && echo -Aunknown-lints) + - name: Run clippy on ${{ matrix.platform }} ${{ matrix.rust_version }} + shell: bash + run: cargo clippy --all-targets --all-features -- -D warnings $([ ${{ matrix.rust_version }} = 1.71.1 ] && echo -Aunknown-lints) licensecheck: runs-on: ubuntu-latest name: "Presence of licence headers" diff --git a/profiling-ffi/src/lib.rs b/profiling-ffi/src/lib.rs index 20e68186f..9f5c260c2 100644 --- a/profiling-ffi/src/lib.rs +++ b/profiling-ffi/src/lib.rs @@ -1,7 +1,7 @@ // Copyright 2021-Present Datadog, Inc. https://www.datadoghq.com/ // SPDX-License-Identifier: Apache-2.0 -#[cfg(feature = "symbolizer")] +#[cfg(all(feature = "symbolizer", not(target_os = "windows")))] pub use symbolizer_ffi::*; use std::fmt::Debug; diff --git a/spawn_worker/src/win32.rs b/spawn_worker/src/win32.rs index ecda74ca9..5152ee1f4 100644 --- a/spawn_worker/src/win32.rs +++ b/spawn_worker/src/win32.rs @@ -416,8 +416,7 @@ pub fn recv_passed_handle() -> Option { } fn get_module_file_name(h: HMODULE) -> anyhow::Result { - let mut buf = Vec::new(); - buf.resize(2000, 0); + let mut buf = vec![0; 2000]; loop { let read: usize = unsafe { GetModuleFileNameW(h, &mut buf) } as usize; if read == 0 {