From 0c8283f7596812bb6ad7c80580044961ae939eb6 Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 20 May 2026 22:41:57 -0500 Subject: [PATCH 1/4] Fix potential memory leak in parse_uevent_info --- linux/hid.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux/hid.c b/linux/hid.c index 148e48848..203163e11 100644 --- a/linux/hid.c +++ b/linux/hid.c @@ -616,10 +616,12 @@ static int parse_uevent_info(const char *uevent, unsigned *bus_type, } } else if (strcmp(key, "HID_NAME") == 0) { /* The caller has to free the product name */ + free(*product_name_utf8); *product_name_utf8 = strdup(value); found_name = 1; } else if (strcmp(key, "HID_UNIQ") == 0) { /* The caller has to free the serial number */ + free(*serial_number_utf8); *serial_number_utf8 = strdup(value); found_serial = 1; } From 5a886b7a4f66a59448ee4adcdd0ffdbe05a0c99c Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 20 May 2026 22:42:27 -0500 Subject: [PATCH 2/4] Remaining IWYU cleanups --- hidtest/test.c | 1 - libusb/hid.c | 4 +--- linux/hid.c | 10 ++++++---- mac/hid.c | 3 +++ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/hidtest/test.c b/hidtest/test.c index eb01d88e0..56fb779ff 100644 --- a/hidtest/test.c +++ b/hidtest/test.c @@ -19,7 +19,6 @@ #include #include #include - #include // Headers needed for sleeping. diff --git a/libusb/hid.c b/libusb/hid.c index d2ceef5d3..553a3bf8b 100644 --- a/libusb/hid.c +++ b/libusb/hid.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -33,9 +34,6 @@ /* Unix */ #include #include -#include -#include -#include #include #include diff --git a/linux/hid.c b/linux/hid.c index 203163e11..247e10295 100644 --- a/linux/hid.c +++ b/linux/hid.c @@ -26,24 +26,26 @@ #include #include #include - /* Unix */ #include -#include #include #include -#include #include #include +#include +#include +#include +#include /* Linux */ #include -#include #include #include #include "hidapi.h" +struct udev_device; + #ifdef HIDAPI_ALLOW_BUILD_WORKAROUND_KERNEL_2_6_39 /* This definitions first appeared in Linux Kernel 2.6.39 in linux/hidraw.h. hidapi doesn't support kernels older than that, diff --git a/mac/hid.c b/mac/hid.c index a91bc1902..b596421c3 100644 --- a/mac/hid.c +++ b/mac/hid.c @@ -29,12 +29,15 @@ #include #include #include +#include +#include #include #include #include #include #include #include +#include #include "hidapi_darwin.h" From 69b102b7c71364e72964cdabb3c229c8976ffa47 Mon Sep 17 00:00:00 2001 From: Jacob Hartzer Date: Sat, 13 Jun 2026 21:28:20 -0500 Subject: [PATCH 3/4] Restore space for visual separation of system headers lib --- hidtest/test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hidtest/test.c b/hidtest/test.c index 56fb779ff..eb01d88e0 100644 --- a/hidtest/test.c +++ b/hidtest/test.c @@ -19,6 +19,7 @@ #include #include #include + #include // Headers needed for sleeping. From ec29007b996587481fea73133ea340072599a689 Mon Sep 17 00:00:00 2001 From: Jacob Hartzer Date: Sat, 13 Jun 2026 22:47:57 -0500 Subject: [PATCH 4/4] Use `vswhere.exe` to find VS install --- .github/workflows/builds.yml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 8f61dc3f0..9904ea6cc 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -193,6 +193,12 @@ jobs: choco install ninja pip3 install meson refreshenv + - name: Find Visual Studio installation + shell: cmd + run: | + for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath`) do ( + echo VCVARS_PATH=%%i\VC\Auxiliary\Build\vcvars64.bat>> %GITHUB_ENV% + ) - name: Configure CMake MSVC shell: cmd run: | @@ -235,13 +241,13 @@ jobs: - name: Configure CMake NMake MSVC shell: cmd run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" + call "%VCVARS_PATH%" cmake -G"NMake Makefiles" -B build\nmake -S hidapisrc -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHIDAPI_WITH_TESTS=ON -DHIDAPI_BUILD_PP_DATA_DUMP=ON -DHIDAPI_ENABLE_ASAN=ON -DCMAKE_INSTALL_PREFIX=install\nmake -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=%MSVC_COMPILE_FLAGS%" - name: Build CMake NMake MSVC working-directory: build\nmake shell: cmd run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" + call "%VCVARS_PATH%" nmake install - name: Check artifacts CMake NMake MSVC uses: andstor/file-existence-action@v2 @@ -254,7 +260,7 @@ jobs: - name: Check CMake NMake MSVC Export Package shell: cmd run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" + call "%VCVARS_PATH%" cmake ^ -G"NMake Makefiles" ^ -B build\nmake_test ^ @@ -271,13 +277,13 @@ jobs: - name: Configure CMake NMake ClangCL shell: cmd run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" + call "%VCVARS_PATH%" cmake -G"NMake Makefiles" -B build\clang_cl -S hidapisrc -D CMAKE_C_COMPILER=clang-cl -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHIDAPI_WITH_TESTS=ON -DHIDAPI_BUILD_PP_DATA_DUMP=ON -DHIDAPI_ENABLE_ASAN=OFF -DCMAKE_INSTALL_PREFIX=install\clang_cl -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=%MSVC_COMPILE_FLAGS%" - name: Build CMake NMake ClangCL working-directory: build\clang_cl shell: cmd run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" + call "%VCVARS_PATH%" nmake install - name: Check artifacts CMake NMake ClangCL uses: andstor/file-existence-action@v2 @@ -290,7 +296,7 @@ jobs: - name: Check CMake NMake ClangCL Export Package shell: cmd run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" + call "%VCVARS_PATH%" cmake ^ -G"NMake Makefiles" ^ -B build\clang_cl_test ^ @@ -340,7 +346,7 @@ jobs: - name: Check Meson build shell: cmd run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" + call "%VCVARS_PATH%" meson setup build_meson hidapisrc cd build_meson ninja