Re: [commit] Tighten memory read/write methods

Mark Kettenis
2005-01-27T21:04:09Z

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