[Qemu-devel] [PATCH] slirp: fix compilation errors with DEBUG set

Laurent Vivier posted 1 patch 7 years ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20170327084612.8998-1-laurent@vivier.eu
Test checkpatch passed
Test docker passed
Test s390x passed
slirp/slirp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[Qemu-devel] [PATCH] slirp: fix compilation errors with DEBUG set
Posted by Laurent Vivier 7 years ago
slirp/slirp.c: In function 'get_dns_addr_resolv_conf':
slirp/slirp.c:202:29: error: initialization discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
                 char *res = inet_ntop(af, tmp_addr, s, sizeof(s));
                             ^~~~~~~~~
slirp/slirp.c:204:25: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
                     res = "(string conversion error)";

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 slirp/slirp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/slirp/slirp.c b/slirp/slirp.c
index 60539de..5a94b06 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -198,7 +198,7 @@ static int get_dns_addr_resolv_conf(int af, void *pdns_addr, void *cached_addr,
 #ifdef DEBUG
             else {
                 char s[INET6_ADDRSTRLEN];
-                char *res = inet_ntop(af, tmp_addr, s, sizeof(s));
+                const char *res = inet_ntop(af, tmp_addr, s, sizeof(s));
                 if (!res) {
                     res = "(string conversion error)";
                 }
-- 
2.9.3


Re: [Qemu-devel] [PATCH] slirp: fix compilation errors with DEBUG set
Posted by Philippe Mathieu-Daudé 7 years ago
On 03/27/2017 05:46 AM, Laurent Vivier wrote:
> slirp/slirp.c: In function 'get_dns_addr_resolv_conf':
> slirp/slirp.c:202:29: error: initialization discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
>                  char *res = inet_ntop(af, tmp_addr, s, sizeof(s));
>                              ^~~~~~~~~
> slirp/slirp.c:204:25: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
>                      res = "(string conversion error)";
>
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>

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

> ---
>  slirp/slirp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/slirp/slirp.c b/slirp/slirp.c
> index 60539de..5a94b06 100644
> --- a/slirp/slirp.c
> +++ b/slirp/slirp.c
> @@ -198,7 +198,7 @@ static int get_dns_addr_resolv_conf(int af, void *pdns_addr, void *cached_addr,
>  #ifdef DEBUG
>              else {
>                  char s[INET6_ADDRSTRLEN];
> -                char *res = inet_ntop(af, tmp_addr, s, sizeof(s));
> +                const char *res = inet_ntop(af, tmp_addr, s, sizeof(s));
>                  if (!res) {
>                      res = "(string conversion error)";
>                  }
>