From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alan Modra To: binutils@sources.redhat.com Cc: gdb-patches@sources.redhat.com Subject: bfd_read and bfd_write Date: Tue, 04 Sep 2001 22:20:00 -0000 Message-id: <20010905145037.K13524@bubble.sa.bigpond.net.au> X-SW-Source: 2001-09/msg00006.html I have a (rather large) patch to clean up a few things in bfd that I'd like to apply in the next day or so, but first thought I'd better give people fair warning and a chance to object. One of the changes I've made is to bfd_read, and similarly bfd_write. bfd_size_type -bfd_read (ptr, size, nitems, abfd) +bfd_read (ptr, size, abfd) PTR ptr; bfd_size_type size; - bfd_size_type nitems; bfd *abfd; Why the change? Well, in having both "size" and "nitems", you'd expect bfd_read to behave like fread, but it doesn't. bfd_read returns "size * nitems" on success, whereas fread returns "nitems". Additionally, many places in bfd swap the "size" and "nitems" args, and technically we should always have size == 1 since we are operating on files of bytes. This doesn't really matter as bfd_read does the multiplication and passes size == 1 down to fread, but we're breaking the fread abstraction. This change will of course break gdb, for which I have patches, and any uncontributed ports. Comments/flames? Alan