Skip to content

Commit 52c728a

Browse files
committed
Use propper type for mach_port_t default param
- enable compilation warnings as errors for CI to catch such issues in the future; - fix Mingw strict compilation warnings;
1 parent 2aeb068 commit 52c728a

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

.github/workflows/builds.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: GitHub Builds
22

33
on: [push, pull_request]
44

5+
env:
6+
NIX_COMPILE_FLAGS: -Wall -Wextra -pedantic -Werror
7+
MSVC_COMPILE_FLAGS: /W4 /WX
8+
59
jobs:
610
macos-automake:
711

@@ -36,8 +40,8 @@ jobs:
3640
- name: Configure CMake
3741
run: |
3842
rm -rf build install
39-
cmake -B build/shared -S hidapisrc -DCMAKE_INSTALL_PREFIX=install/shared
40-
cmake -B build/framework -S hidapisrc -DCMAKE_INSTALL_PREFIX=install/framework -DCMAKE_FRAMEWORK=ON
43+
cmake -B build/shared -S hidapisrc -DCMAKE_INSTALL_PREFIX=install/shared "-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}"
44+
cmake -B build/framework -S hidapisrc -DCMAKE_INSTALL_PREFIX=install/framework -DCMAKE_FRAMEWORK=ON "-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}"
4145
- name: Build CMake Shared
4246
working-directory: build/shared
4347
run: make install
@@ -70,8 +74,8 @@ jobs:
7074
- name: Configure CMake
7175
run: |
7276
rm -rf build install
73-
cmake -B build/shared -S hidapisrc -DCMAKE_INSTALL_PREFIX=install/shared
74-
cmake -B build/static -S hidapisrc -DCMAKE_INSTALL_PREFIX=install/static -DBUILD_SHARED_LIBS=FALSE
77+
cmake -B build/shared -S hidapisrc -DCMAKE_INSTALL_PREFIX=install/shared "-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}"
78+
cmake -B build/static -S hidapisrc -DCMAKE_INSTALL_PREFIX=install/static -DBUILD_SHARED_LIBS=FALSE "-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}"
7579
- name: Build CMake Shared
7680
working-directory: build/shared
7781
run: make install
@@ -103,7 +107,7 @@ jobs:
103107
shell: cmd
104108
run: |
105109
RMDIR /Q /S build install
106-
cmake -B build -S hidapisrc -DCMAKE_INSTALL_PREFIX=install
110+
cmake -B build -S hidapisrc -DCMAKE_INSTALL_PREFIX=install "-DCMAKE_C_FLAGS=%MSVC_COMPILE_FLAGS%"
107111
- name: Build CMake
108112
working-directory: build
109113
run: cmake --build . --target install
@@ -126,7 +130,7 @@ jobs:
126130
run: |
127131
RMDIR /Q /S build install
128132
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
129-
cmake -G"NMake Makefiles" -B build -S hidapisrc -DCMAKE_INSTALL_PREFIX=install
133+
cmake -G"NMake Makefiles" -B build -S hidapisrc -DCMAKE_INSTALL_PREFIX=install "-DCMAKE_C_FLAGS=%MSVC_COMPILE_FLAGS%"
130134
- name: Build CMake
131135
working-directory: build
132136
shell: cmd
@@ -151,7 +155,7 @@ jobs:
151155
shell: cmd
152156
run: |
153157
RMDIR /Q /S build install
154-
cmake -G"MinGW Makefiles" -B build -S hidapisrc -DCMAKE_INSTALL_PREFIX=install
158+
cmake -G"MinGW Makefiles" -B build -S hidapisrc -DCMAKE_INSTALL_PREFIX=install "-DCMAKE_C_FLAGS=%NIX_COMPILE_FLAGS%"
155159
- name: Build CMake
156160
working-directory: build
157161
run: cmake --build . --target install

mac/hid.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,12 +790,12 @@ static io_registry_entry_t hid_open_service_registry_from_path(const char *path)
790790
char *endptr;
791791
uint64_t entry_id = strtoull(path + 10, &endptr, 10);
792792
if (*endptr == '\0') {
793-
return IOServiceGetMatchingService(NULL, IORegistryEntryIDMatching(entry_id));
793+
return IOServiceGetMatchingService((mach_port_t) 0, IORegistryEntryIDMatching(entry_id));
794794
}
795795
}
796796
else {
797797
/* Fallback to older format of the path */
798-
return IORegistryEntryFromPath(NULL, path);
798+
return IORegistryEntryFromPath((mach_port_t) 0, path);
799799
}
800800

801801
return MACH_PORT_NULL;

windows/hidapi_cfgmgr32.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ typedef CONFIGRET(__stdcall* CM_Get_Device_Interface_List_SizeW_)(PULONG pulLen,
5454
typedef CONFIGRET(__stdcall* CM_Get_Device_Interface_ListW_)(LPGUID InterfaceClassGuid, DEVINSTID_W pDeviceID, PZZWSTR Buffer, ULONG BufferLen, ULONG ulFlags);
5555

5656
// from devpkey.h
57-
static DEVPROPKEY DEVPKEY_NAME = { { 0xb725f130, 0x47ef, 0x101a, 0xa5, 0xf1, 0x02, 0x60, 0x8c, 0x9e, 0xeb, 0xac }, 10 }; // DEVPROP_TYPE_STRING
58-
static DEVPROPKEY DEVPKEY_Device_InstanceId = { { 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57 }, 256 }; // DEVPROP_TYPE_STRING
59-
static DEVPROPKEY DEVPKEY_Device_HardwareIds = { { 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0}, 3 }; // DEVPROP_TYPE_STRING_LIST
60-
static DEVPROPKEY DEVPKEY_Device_CompatibleIds = { { 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0}, 4 }; // DEVPROP_TYPE_STRING_LIST
61-
static DEVPROPKEY DEVPKEY_Device_ContainerId = { { 0x8c7ed206, 0x3f8a, 0x4827, 0xb3, 0xab, 0xae, 0x9e, 0x1f, 0xae, 0xfc, 0x6c}, 2 }; // DEVPROP_TYPE_GUID
57+
static DEVPROPKEY DEVPKEY_NAME = { { 0xb725f130, 0x47ef, 0x101a, {0xa5, 0xf1, 0x02, 0x60, 0x8c, 0x9e, 0xeb, 0xac} }, 10 }; // DEVPROP_TYPE_STRING
58+
static DEVPROPKEY DEVPKEY_Device_InstanceId = { { 0x78c34fc8, 0x104a, 0x4aca, {0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57} }, 256 }; // DEVPROP_TYPE_STRING
59+
static DEVPROPKEY DEVPKEY_Device_HardwareIds = { { 0xa45c254e, 0xdf1c, 0x4efd, {0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0} }, 3 }; // DEVPROP_TYPE_STRING_LIST
60+
static DEVPROPKEY DEVPKEY_Device_CompatibleIds = { { 0xa45c254e, 0xdf1c, 0x4efd, {0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0} }, 4 }; // DEVPROP_TYPE_STRING_LIST
61+
static DEVPROPKEY DEVPKEY_Device_ContainerId = { { 0x8c7ed206, 0x3f8a, 0x4827, {0xb3, 0xab, 0xae, 0x9e, 0x1f, 0xae, 0xfc, 0x6c} }, 2 }; // DEVPROP_TYPE_GUID
6262

6363
// from propkey.h
64-
static PROPERTYKEY PKEY_DeviceInterface_Bluetooth_DeviceAddress = { { 0x2bd67d8b, 0x8beb, 0x48d5, 0x87, 0xe0, 0x6c, 0xda, 0x34, 0x28, 0x04, 0x0a }, 1 }; // DEVPROP_TYPE_STRING
65-
static PROPERTYKEY PKEY_DeviceInterface_Bluetooth_Manufacturer = { { 0x2bd67d8b, 0x8beb, 0x48d5, 0x87, 0xe0, 0x6c, 0xda, 0x34, 0x28, 0x04, 0x0a }, 4 }; // DEVPROP_TYPE_STRING
64+
static PROPERTYKEY PKEY_DeviceInterface_Bluetooth_DeviceAddress = { { 0x2bd67d8b, 0x8beb, 0x48d5, {0x87, 0xe0, 0x6c, 0xda, 0x34, 0x28, 0x04, 0x0a} }, 1 }; // DEVPROP_TYPE_STRING
65+
static PROPERTYKEY PKEY_DeviceInterface_Bluetooth_Manufacturer = { { 0x2bd67d8b, 0x8beb, 0x48d5, {0x87, 0xe0, 0x6c, 0xda, 0x34, 0x28, 0x04, 0x0a} }, 4 }; // DEVPROP_TYPE_STRING
6666

6767
#endif
6868

0 commit comments

Comments
 (0)