[PATCH-for-7.0] qga/vss-win32: fix compilation with clang++

Helge Konetzka posted 1 patch 2 years, 1 month ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/240b4ac6-7f74-e959-ae81-73dbe3fa904e@zapateado.de
Maintainers: Konstantin Kostiuk <kkostiuk@redhat.com>, Michael Roth <michael.roth@amd.com>
There is a newer version of this series
qga/vss-win32/install.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH-for-7.0] qga/vss-win32: fix compilation with clang++
Posted by Helge Konetzka 2 years, 1 month ago
Compiling with clang++ of msys2 toolchain clang64 leads to an error
on initializing 'char*' variable nul with a 'const char*' value

Signed-off-by: Helge Konetzka <hk@zapateado.de>
---
Compiling with clang++ of msys2 toolchain clang64 leads to

[1445/1747] Compiling C++ object qga/vss-win32/qga-vss.dll.p/install.cpp.obj
FAILED: qga/vss-win32/qga-vss.dll.p/install.cpp.obj
...
qga/vss-win32/install.cpp:49:24: error: cannot initialize a variable of 
type 'char *' with an rvalue of type 'const char *'
     char *msg = NULL, *nul = strchr(text, '(');
                        ^     ~~~~~~~~~~~~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.
make: *** [Makefile:163: run-ninja] Error 1
==> ERROR: A failure occurred in build().
     Aborting...
---
  qga/vss-win32/install.cpp | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/qga/vss-win32/install.cpp b/qga/vss-win32/install.cpp
index 8076efe3cb..b57508fbe0 100644
--- a/qga/vss-win32/install.cpp
+++ b/qga/vss-win32/install.cpp
@@ -46,7 +46,8 @@ void errmsg(DWORD err, const char *text)
       * If text doesn't contains '(', negative precision is given, which is
       * treated as though it were missing.
       */
-    char *msg = NULL, *nul = strchr(text, '(');
+    char *msg = NULL;
+    const char *nul = strchr(text, '(');
      int len = nul ? nul - text : -1;

      FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
-- 
2.30.2
Re: [PATCH-for-7.0] qga/vss-win32: fix compilation with clang++
Posted by Marc-André Lureau 2 years, 1 month ago
On Wed, Mar 16, 2022 at 4:41 PM Helge Konetzka <hk@zapateado.de> wrote:

> Compiling with clang++ of msys2 toolchain clang64 leads to an error
> on initializing 'char*' variable nul with a 'const char*' value
>
> Signed-off-by: Helge Konetzka <hk@zapateado.de>
>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
> Compiling with clang++ of msys2 toolchain clang64 leads to
>
> [1445/1747] Compiling C++ object
> qga/vss-win32/qga-vss.dll.p/install.cpp.obj
> FAILED: qga/vss-win32/qga-vss.dll.p/install.cpp.obj
> ...
> qga/vss-win32/install.cpp:49:24: error: cannot initialize a variable of
> type 'char *' with an rvalue of type 'const char *'
>      char *msg = NULL, *nul = strchr(text, '(');
>                         ^     ~~~~~~~~~~~~~~~~~
> 1 error generated.
> ninja: build stopped: subcommand failed.
> make: *** [Makefile:163: run-ninja] Error 1
> ==> ERROR: A failure occurred in build().
>      Aborting...
> ---
>   qga/vss-win32/install.cpp | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/qga/vss-win32/install.cpp b/qga/vss-win32/install.cpp
> index 8076efe3cb..b57508fbe0 100644
> --- a/qga/vss-win32/install.cpp
> +++ b/qga/vss-win32/install.cpp
> @@ -46,7 +46,8 @@ void errmsg(DWORD err, const char *text)
>        * If text doesn't contains '(', negative precision is given, which
> is
>        * treated as though it were missing.
>        */
> -    char *msg = NULL, *nul = strchr(text, '(');
> +    char *msg = NULL;
> +    const char *nul = strchr(text, '(');
>       int len = nul ? nul - text : -1;
>
>       FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
> --
> 2.30.2
>
>
>

-- 
Marc-André Lureau
Re: [PATCH-for-7.0] qga/vss-win32: fix compilation with clang++
Posted by Philippe Mathieu-Daudé 2 years, 1 month ago
On 16/3/22 13:31, Helge Konetzka wrote:
> Compiling with clang++ of msys2 toolchain clang64 leads to an error
> on initializing 'char*' variable nul with a 'const char*' value

Can you include the error message in the description? I.e.:

'''
This fixes:

  qga/vss-win32/install.cpp:49:24: error: cannot initialize a variable of
  type 'char *' with an rvalue of type 'const char *'
       char *msg = NULL, *nul = strchr(text, '(');
                          ^     ~~~~~~~~~~~~~~~~~
'''

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> Signed-off-by: Helge Konetzka <hk@zapateado.de>
> ---
> Compiling with clang++ of msys2 toolchain clang64 leads to
> 
> [1445/1747] Compiling C++ object 
> qga/vss-win32/qga-vss.dll.p/install.cpp.obj
> FAILED: qga/vss-win32/qga-vss.dll.p/install.cpp.obj
> ...
> qga/vss-win32/install.cpp:49:24: error: cannot initialize a variable of 
> type 'char *' with an rvalue of type 'const char *'
>      char *msg = NULL, *nul = strchr(text, '(');
>                         ^     ~~~~~~~~~~~~~~~~~
> 1 error generated.
> ninja: build stopped: subcommand failed.
> make: *** [Makefile:163: run-ninja] Error 1
> ==> ERROR: A failure occurred in build().
>      Aborting...
> ---
>   qga/vss-win32/install.cpp | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/qga/vss-win32/install.cpp b/qga/vss-win32/install.cpp
> index 8076efe3cb..b57508fbe0 100644
> --- a/qga/vss-win32/install.cpp
> +++ b/qga/vss-win32/install.cpp
> @@ -46,7 +46,8 @@ void errmsg(DWORD err, const char *text)
>        * If text doesn't contains '(', negative precision is given, 
> which is
>        * treated as though it were missing.
>        */
> -    char *msg = NULL, *nul = strchr(text, '(');
> +    char *msg = NULL;
> +    const char *nul = strchr(text, '(');
>       int len = nul ? nul - text : -1;
> 
>       FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |