From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11303 invoked by alias); 3 May 2005 20:23:57 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 11288 invoked from network); 3 May 2005 20:23:53 -0000 Received: from unknown (HELO nevyn.them.org) (66.93.172.17) by sourceware.org with SMTP; 3 May 2005 20:23:53 -0000 Received: from drow by nevyn.them.org with local (Exim 4.50 #1 (Debian)) id 1DT3vs-0001hw-Mj; Tue, 03 May 2005 16:23:52 -0400 Date: Tue, 03 May 2005 20:23:00 -0000 From: Daniel Jacobowitz To: Mark Kettenis Cc: gdb@sourceware.org, cagney@gnu.org, eliz@gnu.org Subject: Re: A case for `void *' for pointers to arbitrary (byte) buffers Message-ID: <20050503202352.GA6424@nevyn.them.org> Mail-Followup-To: Mark Kettenis , gdb@sourceware.org, cagney@gnu.org, eliz@gnu.org References: <42710E90.3030300@gnu.org> <200504281919.j3SJJKF1011501@elgar.sibelius.xs4all.nl> <42715EE8.5070704@gnu.org> <01c54c8a$Blat.v2.4$ffbe8140@zahav.net.il> <42753958.70109@gnu.org> <01c54e92$Blat.v2.4$5cf24460@zahav.net.il> <42755FD4.8000009@gnu.org> <01c54f4a$Blat.v2.4$a9fc8500@zahav.net.il> <42778DE6.1080106@gnu.org> <200505032013.j43KD1dD005239@elgar.sibelius.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200505032013.j43KD1dD005239@elgar.sibelius.xs4all.nl> User-Agent: Mutt/1.5.8i X-SW-Source: 2005-05/txt/msg00037.txt.bz2 On Tue, May 03, 2005 at 10:13:01PM +0200, Mark Kettenis wrote: > Do we need a `bfd_byte *' or `gdb_byte *'? > ------------------------------------------ > > We might. Many implementations will need to cast to some sort of byte > type to do arithmetic or look at individual bytes. As we have seen, > using can be `char *' is problematic. In most (problematic) cases we > really mean `unsigned char', only a few will warrant `signed char'. > And `bfd_byte *' is a nice abbreviation. Personally I'm perfectly > happy with writing `unsigned char'. IMHO it has the benefit that it > is perfectly clear that this type is unsigned, even to someone who has > never been exposed to the GDB codebase. I think that using gdb_byte has a consistency advantage over typing "unsigned char" everywhere. We will know that we are dealing with opaque blobs of (usually) target memory, but retain the ability to do arithmetic on them. > Why not use `xxx_byte *' instead of `void *'? > --------------------------------------------- > > * It's nonstandard. Why do we need a nonstandard type if a perfectly > god standard type is available? > > * It doesn't really solve the issue. It only propagates the problem > one level up or down. Since `xxx_byte *' is nothing but a typedef > for `unsigned char *', someone calling a functions with `xxx_byte *' > as one of its arguments with a `char *' argument will suffer from > the warning that raised this entire issue; `void *' breaks the chain > immediately. I think that's a bad thing! For the same reason that we use -Werror: where possible, we can let GCC enforce consistency within our source base. Use of gdb_byte (as unsigned char) buys you the advantage that any other pointer type won't silently convert to it. If you want to use a standard type, play the necessary autoconf games to acquire stdint.h. Use uint8_t *. -- Daniel Jacobowitz CodeSourcery, LLC