This is the mail archive of the 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: How to get file descriptor from abfd?

On Wed, Jun 10, 2009 at 8:26 AM, Dave
Korn<> wrote:

>> +. void (*bmmap) (struct bfd *abfd, void *addr, bfd_size_type len,
>> +.                int prot, int flags, file_ptr offset);
> The return type here should be void*, not plain void.

Thanks, fixed.

>> + void *ret = (void *)-1;
> Gnu coding standards request a space between the cast and the -1.

Fixed in all the places I could find.

>> + if ((abfd->flags & BFD_IN_MEMORY) != 0)
>> +   abort ();
>> +#ifdef HAVE_MMAP
>> +  else
>> +    {
>> +      FILE *f = bfd_cache_lookup (abfd, CACHE_NO_SEEK_ERROR);
> Since abort() doesn't return, the else clause and extra level of nested
> braces is superfluous here.

The braces introduce a new scope for 'FILE *f'.
If I move the declaration to the top of function, then it fails to build
when !HAVE_MMAP:

  cc1: warnings being treated as errors
  ../../src/bfd/cache.c: In function 'cache_bmmap':
  ../../src/bfd/cache.c:404: warning: unused variable 'f'

I left this "as is".

Corrected patch attached.

Paul Pluzhnikov

Attachment: bfd-mmap-patch-20090610.txt
Description: Text document

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