Skip to contentSkip to conversation

qga/commands-win32: Fix problem with redundant protype declaration

PATCH In review Thomas Huth 3 participants 4 messages Sep 15, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qga/commands-win32: Fix problem with redundant protype declaration

When compiling QEMU with MSYS2 on Windows, there is currently the following error:

../qga/commands-win32.c:62:24: error: redundant redeclaration of
'CM_Get_DevNode_PropertyW' [-Werror=redundant-decls]
62 | CMAPI CONFIGRET WINAPI CM_Get_DevNode_PropertyW(

      |                        ^~~~~~~~~~~~~~~~~~~~~~~~

In file included from ../qga/commands-win32.c:26:
C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/cfgmgr32.h:840:26: note:
previous declaration of 'CM_Get_DevNode_PropertyW' was here
840 | CMAPI CONFIGRET WINAPI CM_Get_DevNode_PropertyW(DEVINST dnDevInst,
const DEVPROPKEY *PropertyKey, DEVPROPTYPE *PropertyType, PBYTE PropertyBuffer, PULONG PropertyBufferSize, ULONG ulFlags);

Seems like this protype is sometimes available in the cfgmgr32.h header, and sometimes not. Let's silence the compiler warning here to let the build pass with -Werror, too.

---
I can take this through my "testing" tree together with some other MSYS2 patches if there are no objections.

 qga/commands-win32.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
qga/commands-win32.c +4 -1
index 48d8bbe649..0c3c05484f 100644
@@ -57,8 +57,10 @@ DEFINE_DEVPROPKEY(qga_DEVPKEY_Device_DriverDate, 0xa8b865dd, 0x2e3d,
 DEFINE_DEVPROPKEY(qga_DEVPKEY_Device_DriverVersion, 0xa8b865dd, 0x2e3d,
     0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 3);
     /* DEVPROP_TYPE_STRING */
-/* The following shoud be in cfgmgr32.h, but it isn't */
+/* The CM_Get_DevNode_PropertyW prototype is only sometimes in cfgmgr32.h */
 #ifndef CM_Get_DevNode_Property
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wredundant-decls"
 CMAPI CONFIGRET WINAPI CM_Get_DevNode_PropertyW(
     DEVINST          dnDevInst,
     CONST DEVPROPKEY * PropertyKey,
@@ -68,6 +70,7 @@ CMAPI CONFIGRET WINAPI CM_Get_DevNode_PropertyW(
     ULONG            ulFlags
 );
 #define CM_Get_DevNode_Property CM_Get_DevNode_PropertyW
+#pragma GCC diagnostic pop
 #endif
 
 #ifndef SHTDN_REASON_FLAG_PLANNED
Signature · 1 line
2.18.2
#1 lore raw

Cc'ing Marc-André

Quoted 14 lines · Thomas Huth

When compiling QEMU with MSYS2 on Windows, there is currently the following error:

../qga/commands-win32.c:62:24: error: redundant redeclaration of
'CM_Get_DevNode_PropertyW' [-Werror=redundant-decls]
62 | CMAPI CONFIGRET WINAPI CM_Get_DevNode_PropertyW(

      |                        ^~~~~~~~~~~~~~~~~~~~~~~~

In file included from ../qga/commands-win32.c:26:
C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/cfgmgr32.h:840:26: note:
previous declaration of 'CM_Get_DevNode_PropertyW' was here
840 | CMAPI CONFIGRET WINAPI CM_Get_DevNode_PropertyW(DEVINST dnDevInst,
const DEVPROPKEY *PropertyKey, DEVPROPTYPE *PropertyType, PBYTE PropertyBuffer, PULONG PropertyBufferSize, ULONG ulFlags);

Quoted 2 lines

Seems like this protype is sometimes available in the cfgmgr32.h header, and sometimes not.

This prototype is declared Since Windows Vista, but per commit 4ac80866476 ("qga: drop < Vista compatibility") it should be always true... So I'm confused.

Maybe we should build with:

QEMU_BUILD_BUG_ON(_WIN32_WINNT < 0x0600); /* Vista */

Commit 56cdca1d7a6 ("build-sys: build with Vista API by default") defines it if missing... Maybe that's where this problem comes from? (On too old includes we force them as Vista).

Quoted 36 lines

Let's silence the compiler warning here
to let the build pass with -Werror, too.

---
I can take this through my "testing" tree together with some other MSYS2 patches if there are no objections.

 qga/commands-win32.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
qga/commands-win32.c +4 -1
index 48d8bbe649..0c3c05484f 100644
@@ -57,8 +57,10 @@ DEFINE_DEVPROPKEY(qga_DEVPKEY_Device_DriverDate, 0xa8b865dd, 0x2e3d,
 DEFINE_DEVPROPKEY(qga_DEVPKEY_Device_DriverVersion, 0xa8b865dd, 0x2e3d,
     0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 3);
     /* DEVPROP_TYPE_STRING */
-/* The following shoud be in cfgmgr32.h, but it isn't */
+/* The CM_Get_DevNode_PropertyW prototype is only sometimes in cfgmgr32.h */
 #ifndef CM_Get_DevNode_Property
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wredundant-decls"
 CMAPI CONFIGRET WINAPI CM_Get_DevNode_PropertyW(
     DEVINST          dnDevInst,
     CONST DEVPROPKEY * PropertyKey,
@@ -68,6 +70,7 @@ CMAPI CONFIGRET WINAPI CM_Get_DevNode_PropertyW(
     ULONG            ulFlags
 );
 #define CM_Get_DevNode_Property CM_Get_DevNode_PropertyW
+#pragma GCC diagnostic pop
 #endif
 
 #ifndef SHTDN_REASON_FLAG_PLANNED
#2 lore raw

Hi

Quoted 27 lines · Philippe Mathieu-Daudé

Cc'ing Marc-André

Quoted 9 lines · Thomas Huth

When compiling QEMU with MSYS2 on Windows, there is currently the following error:

../qga/commands-win32.c:62:24: error: redundant redeclaration of
'CM_Get_DevNode_PropertyW' [-Werror=redundant-decls]
62 | CMAPI CONFIGRET WINAPI CM_Get_DevNode_PropertyW(

      |                        ^~~~~~~~~~~~~~~~~~~~~~~~

In file included from ../qga/commands-win32.c:26:
C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/cfgmgr32.h:840:26:

note:

Quoted 2 lines

previous declaration of 'CM_Get_DevNode_PropertyW' was here
840 | CMAPI CONFIGRET WINAPI CM_Get_DevNode_PropertyW(DEVINST

dnDevInst,

Quoted 1 line

const DEVPROPKEY *PropertyKey, DEVPROPTYPE *PropertyType, PBYTE

PropertyBuffer,

Quoted 4 lines
   PULONG PropertyBufferSize, ULONG ulFlags);

Seems like this protype is sometimes available in the cfgmgr32.h header, and sometimes not.

This prototype is declared Since Windows Vista, but per commit 4ac80866476 ("qga: drop < Vista compatibility") it should be always true... So I'm confused.

Quoted 9 lines

Maybe we should build with:

QEMU_BUILD_BUG_ON(_WIN32_WINNT < 0x0600); /* Vista */

Commit 56cdca1d7a6 ("build-sys: build with Vista API by default") defines it if missing... Maybe that's where this problem comes from? (On too old includes we force them as Vista).

It doesn't have much to do with _WIN32_WINNT version, I think

The prototype was quite recently added in mingw-headers by Tomáš:
commit 5ace9333fa948dd4ce73bd262aaf0df39a0cf6ef

Author: Tomáš Golembiovský <[email protected]>
Date:   Fri Oct 18 11:22:22 2019 +0200

include/cfgmgr32.h: add CM_Get_DevNode_PropertyW

It should be fine to silence the warning as proposed here.

Quoted 42 lines

Let's silence the compiler warning here

qga/commands-win32.c DEFINE_DEVPROPKEY(qga_DEVPKEY_Device_DriverDate,

Quoted 15 lines

to let the build pass with -Werror, too.

---
I can take this through my "testing" tree together with some other MSYS2 patches if there are no objections.

 qga/commands-win32.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
qga/commands-win32.c +0 -0
index 48d8bbe649..0c3c05484f 100644
@@ -57,8 +57,10 @@ DEFINE_DEVPROPKEY(qga_DEVPKEY_Device_DriverDate,

0xa8b865dd, 0x2e3d,

qga/commands-win32.c DEFINE_DEVPROPKEY(qga_DEVPKEY_Device_DriverDate, 0xa8b865dd, 0x2e3d,

Quoted 5 lines
qga/commands-win32.c +1 -1
 DEFINE_DEVPROPKEY(qga_DEVPKEY_Device_DriverVersion, 0xa8b865dd, 0x2e3d,
     0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 3);
     /* DEVPROP_TYPE_STRING */
-/* The following shoud be in cfgmgr32.h, but it isn't */
+/* The CM_Get_DevNode_PropertyW prototype is only sometimes in

cfgmgr32.h */

Quoted 15 lines
qga/commands-win32.c +3 -0
 #ifndef CM_Get_DevNode_Property
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wredundant-decls"
 CMAPI CONFIGRET WINAPI CM_Get_DevNode_PropertyW(
     DEVINST          dnDevInst,
     CONST DEVPROPKEY * PropertyKey,
@@ -68,6 +70,7 @@ CMAPI CONFIGRET WINAPI CM_Get_DevNode_PropertyW(
     ULONG            ulFlags
 );
 #define CM_Get_DevNode_Property CM_Get_DevNode_PropertyW
+#pragma GCC diagnostic pop
 #endif
 
 #ifndef SHTDN_REASON_FLAG_PLANNED
Signature · 1 line
Marc-André Lureau
Reviewed-by on v1 1/1
#3 lore raw
In reply to Thomas Huth

Hi

Quoted 16 lines · Thomas Huth

When compiling QEMU with MSYS2 on Windows, there is currently the following error:

../qga/commands-win32.c:62:24: error: redundant redeclaration of
'CM_Get_DevNode_PropertyW' [-Werror=redundant-decls]
62 | CMAPI CONFIGRET WINAPI CM_Get_DevNode_PropertyW(

      |                        ^~~~~~~~~~~~~~~~~~~~~~~~

In file included from ../qga/commands-win32.c:26:
C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/cfgmgr32.h:840:26: note:
previous declaration of 'CM_Get_DevNode_PropertyW' was here
840 | CMAPI CONFIGRET WINAPI CM_Get_DevNode_PropertyW(DEVINST
dnDevInst,
const DEVPROPKEY *PropertyKey, DEVPROPTYPE *PropertyType, PBYTE
PropertyBuffer,
PULONG PropertyBufferSize, ULONG ulFlags);

Quoted 6 lines

Seems like this protype is sometimes available in the cfgmgr32.h header, and sometimes not. Let's silence the compiler warning here to let the build pass with -Werror, too.

---

Quoted 37 lines

I can take this through my "testing" tree together with some other MSYS2 patches if there are no objections.

 qga/commands-win32.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
qga/commands-win32.c +3 -1
index 48d8bbe649..0c3c05484f 100644
@@ -57,8 +57,10 @@ DEFINE_DEVPROPKEY(qga_DEVPKEY_Device_DriverDate,
 0xa8b865dd, 0x2e3d,
 DEFINE_DEVPROPKEY(qga_DEVPKEY_Device_DriverVersion, 0xa8b865dd, 0x2e3d,
     0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 3);
     /* DEVPROP_TYPE_STRING */
-/* The following shoud be in cfgmgr32.h, but it isn't */
+/* The CM_Get_DevNode_PropertyW prototype is only sometimes in cfgmgr32.h
 */
 #ifndef CM_Get_DevNode_Property
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wredundant-decls"
 CMAPI CONFIGRET WINAPI CM_Get_DevNode_PropertyW(

DEVINST dnDevInst,
CONST DEVPROPKEY * PropertyKey,

qga/commands-win32.c +1 -1
@@ -68,6 +70,7 @@ CMAPI CONFIGRET WINAPI CM_Get_DevNode_PropertyW(
     ULONG            ulFlags
 );
 #define CM_Get_DevNode_Property CM_Get_DevNode_PropertyW
+#pragma GCC diagnostic pop
 #endif
 
 #ifndef SHTDN_REASON_FLAG_PLANNED
--

2.18.2

Signature · 1 line
Marc-André Lureau