From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 129026 invoked by alias); 27 Oct 2015 16:02:01 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 128311 invoked by uid 89); 27 Oct 2015 16:02:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 27 Oct 2015 16:01:57 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id E52FB33A8A8; Tue, 27 Oct 2015 16:01:55 +0000 (UTC) Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9RG1sgM012306; Tue, 27 Oct 2015 12:01:54 -0400 From: Pedro Alves To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH] Make host_address_to_string/gdb_print_host_address cast parameter to 'void *' Date: Tue, 27 Oct 2015 21:28:00 -0000 Message-Id: <1445961713-28986-1-git-send-email-palves@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SW-Source: 2015-10/txt/msg00632.txt.bz2 Fixes a set of errors like: ../../src/gdb/symfile-debug.c: In function ‘int debug_qf_map_symtabs_matching_filename(objfile*, const char*, const char*, int (*)(symtab*, void*), void*)’: ../../src/gdb/symfile-debug.c:137:39: error: invalid conversion from ‘int (*)(symtab*, void*)’ to ‘const void*’ [-fpermissive] host_address_to_string (callback), ^ Note this has to work with data and function pointers. In C++11 we may perhaps do something a bit safer, but we're not there yet, and I don't think it really matters. For now just always do a simple C-style cast in host_address_to_string itself. No point in adding a void * cast to each and every caller. gdb/ChangeLog: 2015-10-27 Pedro Alves * common/print-utils.c (host_address_to_string): Undef. * common/print-utils.h (host_address_to_string): Add a wrapper macro around the host_address_to_string function. * utils.c (): * utils.c (gdb_print_host_address): Undef. * utils.h (gdb_print_host_address): Add a wrapper macro around the host_address_to_string function. --- gdb/common/print-utils.c | 2 ++ gdb/common/print-utils.h | 4 ++++ gdb/utils.c | 2 ++ gdb/utils.h | 4 ++++ 4 files changed, 12 insertions(+) diff --git a/gdb/common/print-utils.c b/gdb/common/print-utils.c index 1c1a5c1..bd62503 100644 --- a/gdb/common/print-utils.c +++ b/gdb/common/print-utils.c @@ -315,6 +315,8 @@ core_addr_to_string_nz (const CORE_ADDR addr) /* See print-utils.h. */ +#undef host_address_to_string + const char * host_address_to_string (const void *addr) { diff --git a/gdb/common/print-utils.h b/gdb/common/print-utils.h index 8d16966..abeb003 100644 --- a/gdb/common/print-utils.h +++ b/gdb/common/print-utils.h @@ -67,4 +67,8 @@ extern const char *core_addr_to_string_nz (const CORE_ADDR addr); extern const char *host_address_to_string (const void *addr); +/* Wrapper that avoids adding a pointless cast to all callers. */ +#define host_address_to_string(ADDR) \ + host_address_to_string ((const void *) (ADDR)) + #endif /* COMMON_CELLS_H */ diff --git a/gdb/utils.c b/gdb/utils.c index afeff12..101e438 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1103,6 +1103,8 @@ print_spaces (int n, struct ui_file *file) /* Print a host address. */ +#undef gdb_print_host_address + void gdb_print_host_address (const void *addr, struct ui_file *stream) { diff --git a/gdb/utils.h b/gdb/utils.h index 995a1cf..a226744 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -248,6 +248,10 @@ extern int filtered_printing_initialized (void); /* Display the host ADDR on STREAM formatted as ``0x%x''. */ extern void gdb_print_host_address (const void *addr, struct ui_file *stream); +/* Wrapper that avoids adding a pointless cast to all callers. */ +#define gdb_print_host_address(ADDR, STREAM) \ + gdb_print_host_address ((const void *) ADDR, STREAM) + /* Convert CORE_ADDR to string in platform-specific manner. This is usually formatted similar to 0x%lx. */ extern const char *paddress (struct gdbarch *gdbarch, CORE_ADDR addr); -- 1.9.3