]> git.ipfire.org Git - thirdparty/pciutils.git/commit
windows: Do not cast FARPROC to LPVOID and then to some function pointer
authorPali Rohár <pali@kernel.org>
Thu, 21 Nov 2024 22:51:26 +0000 (23:51 +0100)
committerMartin Mares <mj@ucw.cz>
Sun, 8 Jun 2025 15:19:58 +0000 (17:19 +0200)
commit39147c1081aff7445c105673fc5729c547d1d5b1
tree17923eeee5b986fc99091e1ef81e93c565c341a6
parentfef7acc713c4a5b13dd06381f511ff58ecb031f0
windows: Do not cast FARPROC to LPVOID and then to some function pointer

FARPROC is function pointer type intptr_t(__stdcall*)() and LPVOID is data
pointer type void*. Casting from function pointer to data pointer and back
is undefined in C, and moreover in all cases it is not needed. In all cases
it is just needed to cast FARPROC function pointer type to some specific
function pointer type, and casting via intermediate LPVOID was there just
to mute compiler warnings about casting between two incompatible function
pointer types. To mute that compiler warning, do casting via intermediate
generic function pointer type void(*)(void) which is preferred according to
gcc documentation and does not throw any compiler warnings neither by gcc,
nor by msvc compilers.
lib/win32-helpers.c