[PATCH] tests/qtest: fix discarded const qualifier warning

Matthew Penney posted 1 patch 2 weeks, 1 day ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260514191844.105888-1-matt@matthewpenney.net
Maintainers: Fabiano Rosas <farosas@suse.de>, Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
tests/qtest/libqtest.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] tests/qtest: fix discarded const qualifier warning
Posted by Matthew Penney 2 weeks, 1 day ago
Modern compilers warn that the result of strstr() may discard
const qualifiers when assigned to a non-const pointer.

Make 'found' a const char * to fix the warning.

Signed-off-by: Matthew Penney <matt@matthewpenney.net>
---
 tests/qtest/libqtest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index bf9284b9a1..b1e06ea364 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -2146,7 +2146,7 @@ bool mkimg(const char *file, const char *fmt, unsigned size_mb)
 bool qtest_verbose(const char *domain)
 {
     const char *log = getenv("QTEST_LOG");
-    char *found;
+    const char *found;
 
     assert(domain);
 
-- 
2.54.0
Re: [PATCH] tests/qtest: fix discarded const qualifier warning
Posted by Philippe Mathieu-Daudé 2 weeks ago
On 14/5/26 21:19, Matthew Penney wrote:
> Modern compilers warn that the result of strstr() may discard
> const qualifiers when assigned to a non-const pointer.
> 
> Make 'found' a const char * to fix the warning.
> 
> Signed-off-by: Matthew Penney <matt@matthewpenney.net>
> ---
>   tests/qtest/libqtest.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Re: [PATCH] tests/qtest: fix discarded const qualifier warning
Posted by Marc-André Lureau 2 weeks ago
Hi

On Thu, May 14, 2026 at 11:20 PM Matthew Penney <matt@matthewpenney.net> wrote:
>
> Modern compilers warn that the result of strstr() may discard
> const qualifiers when assigned to a non-const pointer.
>
> Make 'found' a const char * to fix the warning.
>
> Signed-off-by: Matthew Penney <matt@matthewpenney.net>

Fixes f606321be8 ("tests/qtest: Individual verbose switches")
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  tests/qtest/libqtest.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
> index bf9284b9a1..b1e06ea364 100644
> --- a/tests/qtest/libqtest.c
> +++ b/tests/qtest/libqtest.c
> @@ -2146,7 +2146,7 @@ bool mkimg(const char *file, const char *fmt, unsigned size_mb)
>  bool qtest_verbose(const char *domain)
>  {
>      const char *log = getenv("QTEST_LOG");
> -    char *found;
> +    const char *found;
>
>      assert(domain);
>
> --
> 2.54.0
>
>
>


-- 
Marc-André Lureau
Re: [PATCH] tests/qtest: fix discarded const qualifier warning
Posted by Thomas Huth 2 weeks, 1 day ago
On 14/05/2026 21.19, Matthew Penney wrote:
> Modern compilers warn that the result of strstr() may discard
> const qualifiers when assigned to a non-const pointer.
> 
> Make 'found' a const char * to fix the warning.
> 
> Signed-off-by: Matthew Penney <matt@matthewpenney.net>
> ---
>   tests/qtest/libqtest.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
> index bf9284b9a1..b1e06ea364 100644
> --- a/tests/qtest/libqtest.c
> +++ b/tests/qtest/libqtest.c
> @@ -2146,7 +2146,7 @@ bool mkimg(const char *file, const char *fmt, unsigned size_mb)
>   bool qtest_verbose(const char *domain)
>   {
>       const char *log = getenv("QTEST_LOG");
> -    char *found;
> +    const char *found;
>   
>       assert(domain);
Reviewed-by: Thomas Huth <thuth@redhat.com>
Tested-by: Thomas Huth <thuth@redhat.com>