Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Dave Korn <dave.korn.cygwin@googlemail.com>
To: Paul Pluzhnikov <ppluzhnikov@google.com>
Cc: binutils@sourceware.org, Tom Tromey <tromey@redhat.com>,
	  gdb-patches ml <gdb-patches@sourceware.org>,
	 Dave Korn <dave.korn.cygwin@googlemail.com>
Subject: Re: How to get file descriptor from abfd?
Date: Wed, 10 Jun 2009 15:14:00 -0000	[thread overview]
Message-ID: <4A2FD0A7.2090408@gmail.com> (raw)
In-Reply-To: <8ac60eac0906080910x6497e1abg5c7aa9bdf863c5d5@mail.gmail.com>

Paul Pluzhnikov wrote:
> On Mon, Jun 1, 2009 at 10:54 PM, Paul Pluzhnikov<ppluzhnikov@google.com> wrote:
> 
>> Would attached patch be acceptable?
> 
> Ping?

  I can't approve this as it's outside my area.  I have verified that it
applies cleanly and builds without failures on i686-pc-cygwin (although that
doesn't support --enable-mmap currently for reasons I have yet to discover)
and have just a couple of minor formatting comments on the patch:

>  Index: bfdio.c
> ===================================================================
> RCS file: /cvs/src/src/bfd/bfdio.c,v
> retrieving revision 1.21
> diff -u -p -u -r1.21 bfdio.c
> --- bfdio.c	24 May 2009 11:47:27 -0000	1.21
> +++ bfdio.c	2 Jun 2009 05:30:15 -0000
> @@ -158,6 +158,8 @@ DESCRIPTION
>  .  int (*bclose) (struct bfd *abfd);
>  .  int (*bflush) (struct bfd *abfd);
>  .  int (*bstat) (struct bfd *abfd, struct stat *sb);
> +.  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.

> +static void *
> +cache_bmmap (struct bfd *abfd ATTRIBUTE_UNUSED,
> +	     void *addr ATTRIBUTE_UNUSED,
> +	     bfd_size_type len ATTRIBUTE_UNUSED,
> +	     int prot ATTRIBUTE_UNUSED,
> +	     int flags ATTRIBUTE_UNUSED,
> +	     file_ptr offset ATTRIBUTE_UNUSED)
> +{
> +  void *ret = (void *)-1;

  Gnu coding standards request a space between the cast and the -1.  This also
applies to several other casts throughout the patch.

> +
> +  if ((abfd->flags & BFD_IN_MEMORY) != 0)
> +    abort ();
> +#ifdef HAVE_MMAP
> +  else
> +    {
> +      FILE *f = bfd_cache_lookup (abfd, CACHE_NO_SEEK_ERROR);
> +      if (f == NULL)
> +	return ret;
> +
> +      ret = mmap (addr, len, prot, flags, fileno (f), offset);
> +      if (ret == (void *)-1)
> +	bfd_set_error (bfd_error_system_call);
> +    }
> +#endif
> +
> +  return ret;
> +

  Since abort() doesn't return, the else clause and extra level of nested
braces is superfluous here.  Straight-line code would be cleaner IMO.

  Anyway, that's minor stuff, as I said; the patch looks fundamentally sound
to me, but I can't OK it for you.

    cheers,
      DaveK


  reply	other threads:[~2009-06-10 15:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-31 17:56 Paul Pluzhnikov
2009-05-31 18:12 ` Dave Korn
2009-06-02  5:55   ` Paul Pluzhnikov
2009-06-08 16:10     ` Paul Pluzhnikov
2009-06-10 15:14       ` Dave Korn [this message]
2009-06-10 17:09         ` Paul Pluzhnikov
2009-06-10 23:59           ` Alan Modra
2009-06-11  0:42             ` Paul Pluzhnikov
2009-06-11  2:14           ` Dave Korn
2009-06-11  3:28           ` Dave Korn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A2FD0A7.2090408@gmail.com \
    --to=dave.korn.cygwin@googlemail.com \
    --cc=binutils@sourceware.org \
    --cc=gdb-patches@sourceware.org \
    --cc=ppluzhnikov@google.com \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox