From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30260 invoked by alias); 3 May 2005 22:10:00 -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 30113 invoked from network); 3 May 2005 22:09:47 -0000 Received: from unknown (HELO sibelius.xs4all.nl) (82.92.89.47) by sourceware.org with SMTP; 3 May 2005 22:09:47 -0000 Received: from elgar.sibelius.xs4all.nl (root@elgar.sibelius.xs4all.nl [192.168.0.2]) by sibelius.xs4all.nl (8.13.0/8.13.0) with ESMTP id j43M6RW2013545; Wed, 4 May 2005 00:06:27 +0200 (CEST) Received: from elgar.sibelius.xs4all.nl (kettenis@localhost.sibelius.xs4all.nl [127.0.0.1]) by elgar.sibelius.xs4all.nl (8.13.4/8.13.3) with ESMTP id j43M6Q0I026474; Wed, 4 May 2005 00:06:26 +0200 (CEST) Received: (from kettenis@localhost) by elgar.sibelius.xs4all.nl (8.13.4/8.13.4/Submit) id j43M6QEN002791; Wed, 4 May 2005 00:06:26 +0200 (CEST) Date: Tue, 03 May 2005 22:10:00 -0000 Message-Id: <200505032206.j43M6QEN002791@elgar.sibelius.xs4all.nl> From: Mark Kettenis To: drow@false.org CC: gdb@sourceware.org, cagney@gnu.org, eliz@gnu.org In-reply-to: <20050503211646.GB8203@nevyn.them.org> (message from Daniel Jacobowitz on Tue, 3 May 2005 17:16:46 -0400) Subject: Re: A case for `void *' for pointers to arbitrary (byte) buffers References: <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> <20050503202352.GA6424@nevyn.them.org> <200505032113.j43LDOlL013376@elgar.sibelius.xs4all.nl> <20050503211646.GB8203@nevyn.them.org> X-SW-Source: 2005-05/txt/msg00046.txt.bz2 Date: Tue, 3 May 2005 17:16:46 -0400 From: Daniel Jacobowitz On Tue, May 03, 2005 at 11:13:24PM +0200, Mark Kettenis wrote: > Date: Tue, 3 May 2005 16:23:52 -0400 > From: Daniel Jacobowitz > > > 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. > > Ah, but these are supposed to be opaque blobs of memory. That's my point. This way we can only pass "opaque blobs of memory" to the interfaces that want opaque blobs. It's a question of categorization. For instance, this is a bug: long foo; target_read_memory (addr, &foo, 4); If the second argument is "void *", a C compiler won't complain about this. But for "uint8_t *", it will. Hmm, you have a point here... > If you want to use a standard type, play the necessary autoconf games > to acquire stdint.h. Use uint8_t *. > > That's an interesting suggestion. It might take a few iterations to > get that right though. I'm willing to do the work. OK great! I really like being able to use those (u)intN_t types, and especially (u)intptr_t. You can probably steal the autoconf checks from GNU coreutils. Those will have been pretty well tested I sppose. But the base sequence should something like: #ifdef HAVE_STDINT_H #include #else # ifdef HAVE_INTTYPES_H # include # else typedef unsigned char uint8_t; # endif #endif Mark