From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 384 invoked by alias); 28 Mar 2013 21:41:30 -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 346 invoked by uid 89); 28 Mar 2013 21:41:19 -0000 X-Spam-SWARE-Status: No, score=-8.3 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 28 Mar 2013 21:41:17 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2SLfCH6013393 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 28 Mar 2013 17:41:12 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r2SLfA4I000961; Thu, 28 Mar 2013 17:41:11 -0400 Message-ID: <5154B8F6.4000804@redhat.com> Date: Fri, 29 Mar 2013 00:29:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130311 Thunderbird/17.0.4 MIME-Version: 1.0 To: Aleksandar Ristovski CC: Jan Kratochvil , "gdb-patches@sourceware.org" Subject: Re: [patch 4/6] Prepare linux_find_memory_regions_full & co. for move References: <51278984.3070208@qnx.com> <20130310210820.GE21130@host2.jankratochvil.net> <514C56CB.4070207@qnx.com> <20130326165242.GA12291@host2.jankratochvil.net> <515353C4.2050203@qnx.com> <20130328202805.GB9375@host2.jankratochvil.net> <5154AE75.4050103@qnx.com> In-Reply-To: <5154AE75.4050103@qnx.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-03/txt/msg01081.txt.bz2 On 03/28/2013 08:56 PM, Aleksandar Ristovski wrote: >>> >>> +static char * >>> +read_stralloc (const char *filename, read_stralloc_func_ftype *func) >>> { >>> - gdb_byte *buffer; >>> - char *bufstr; >>> + char *buffer; >> >> Why you make this change? That is unrelated to this patchset, it is a recent >> modification by Pedro. > > > [AR] I apologize to Pedro - the code as I put it seems more natural, a few less lines and such. But I can remove it, it is not essential. Please don't revert that. > fad14e531 (Pedro Alves 2013-03-11 12:22:16 +0000 3546) gdb_byte *buffer; > fad14e531 (Pedro Alves 2013-03-11 12:22:16 +0000 3547) char *bufstr; $ git show fad14e531 commit fad14e531b1fa96211beac28557d7fb5d42a8b80 Author: Pedro Alves Date: Mon Mar 11 12:22:16 2013 +0000 Avoid invalid pointer to pointer conversions. Casts between 'char **' <-> 'unsigned char **' and 'char **' <-> const char **' are actually invalid: http://gcc.gnu.org/ml/gcc-help/2013-03/msg00118.html In a nutshell, char (and variants) can alias anything, but pointers to chars get no special treatment (cf. C99/N1256, 6.5/7). Turns out older gcc's actually warn/complain on these constructs, though newer one's don't: http://sourceware.org/ml/gdb-patches/2013-03/msg00429.html http://sourceware.org/ml/gdb-patches/2013-03/msg00430.html This patch fixes the cases I added last week. It also fixes one other preexisting case in charset.c, though it seems even older gccs don't complain of char * <-> const char * aliasing. Tested on x86_64 Fedora 17. gdb/ 2013-03-11 Pedro Alves * charset.c (convert_between_encodings): Don't cast between different pointer to pointer types. Instead, make the 'inp' local be of the type iconv expects. (wchar_iterate): Don't cast between different pointer to pointer types. Instead, use new pointer local of the type iconv expects. * target.c (target_read_stralloc, target_fileio_read_stralloc): Add new local of type char pointer, and use it to get a char/string view of the byte buffer, instead of casting between pointer to pointer types. -- Pedro Alves