This is the mail archive of the gdb-patches@sourceware.org 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: [PATCH 1/9] Introduce target_fileio_fstat


Looks good with the nits below addressed.

On 03/20/2015 04:47 PM, Gary Benson wrote:

> --- a/gdb/inf-child.c
> +++ b/gdb/inf-child.c
> @@ -374,6 +374,22 @@ inf_child_fileio_pread (struct target_ops *self,
>    return ret;
>  }
>  
> +/* Get information about the file opened as FD and put it in SB.
> +   Return 0, or -1 if an error occurs (and set *TARGET_ERRNO).  */

Write something like "Implementation of to_fileio_fstat."
instead of duplicating the comment.

> +
> +static int
> +inf_child_fileio_fstat (struct target_ops *self, int fd,
> +			struct stat *sb, int *target_errno)
> +{

> index bb901b5..44ede10 100644
> --- a/gdb/target.c
> +++ b/gdb/target.c
> @@ -2848,6 +2848,27 @@ target_fileio_pread (int fd, gdb_byte *read_buf, int len,
>    return ret;
>  }
>  
> +/* Get information about the file opened as FD on the target
> +   and put it in SB.  Return 0, or -1 if an error occurs (and
> +   set *TARGET_ERRNO).  */

Write:

/* See target.h.  */

instead of duplicating the comment.

> +int
> +target_fileio_fstat (int fd, struct stat *sb, int *target_errno)
> +{
> +  fileio_fh_t *fh = fileio_fd_to_fh (fd);
> +  int ret = -1;
> +
> +  if (is_closed_fileio_fh (fh->fd))
> +    *target_errno = EBADF;
> +  else
> +    ret = fh->t->to_fileio_fstat (fh->t, fh->fd, sb, target_errno);
> +
> +  if (targetdebug)
> +    fprintf_unfiltered (gdb_stdlog,
> +			"target_fileio_fstat (%d) = %d (%d)\n",
> +			fd, ret, ret != -1 ? 0 : *target_errno);
> +  return ret;
> +}
> +
>  /* Close FD on the target.  Return 0, or -1 if an error occurs
>     (and set *TARGET_ERRNO).  */
>  int
> diff --git a/gdb/target.h b/gdb/target.h
> index c95e1a4..d2bd152 100644
> --- a/gdb/target.h
> +++ b/gdb/target.h
> @@ -846,6 +846,11 @@ struct target_ops
>  			    int fd, gdb_byte *read_buf, int len,
>  			    ULONGEST offset, int *target_errno);
>  
> +    /* Get information about the file opened as FD and put it in SB.
> +       Return 0, or -1 if an error occurs (and set *TARGET_ERRNO).  */

ITYM, "Return 0 on success, ..."

> +    int (*to_fileio_fstat) (struct target_ops *,
> +			    int fd, struct stat *sb, int *target_errno);
> +

> +/* Get information about the file opened as FD on the target
> +   and put it in SB.  Return 0, or -1 if an error occurs (and

Likewise.

> +   set *TARGET_ERRNO).  */
> +extern int target_fileio_fstat (int fd, struct stat *sb,
> +				int *target_errno);

Thanks,
Pedro Alves


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