This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [commit] Tighten memory read/write methods


   Date: Thu, 27 Jan 2005 15:11:19 -0500
   From: Andrew Cagney <cagney@gnu.org>

   Hello,

   This cleans up the {target_,}{read,write}_memory methods making the 
   buffer parameter a bfd_byte (instead of "is it signed?" char)

Just curious, but is that really an issue in these buffer-like
contexts?  I thought signed-ness is only an issue if there is an
(implcit) conversion to an integer type involved.  If there are such
issues, bfd_byte seems like the appropriate type to use (but please
read on), but otherwise I'd prefer using standard ISO C types.

Anyway, isn't it better to sidestep the issue entirely, and use 'void
*' in these contexts?  That's what we have been doing in the past I
think.  Most 'char *' stuff is only there because too many people
still remember K&R C.

Anyway, I think we shouldn't change these things haphazardly.  Can we
formulate a set of programming guidelines such that we can try to be a
bit more consistent.  My set of rules would be:

* Use const wherever possible.
* Use 'void *' wherever possible.
* Use 'char *' in context where you need to add an offset to a pointer.

Mark


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]