This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils 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: Better messages for discarde section


Hi Guys,

  Any objection to the following patch ?

  It changes the asprintf() and vasprintf() functions in libiberty to
  return -1 upon error, rather than 0.  This is in line with the
  equivalent versions in glibc and follows that stricture that the
  functions are supposed to behave like sprintf().

Cheers
        Nick

2003-06-03  Nick Clifton  <nickc@redhat.com>

	* asprintf.c: Change comment to note that -1 is returned upon
	error.
	* vasprintf.c: Likewise.
	(vasprintf): Return -1 upon error.
	* functions.texi: Document changes to asprintf and vasprintf.
          

Index: asprintf.c
===================================================================
RCS file: /cvs/src/src/libiberty/asprintf.c,v
retrieving revision 1.4
diff -c -3 -p -r1.4 asprintf.c
*** asprintf.c	17 Oct 2001 22:35:28 -0000	1.4
--- asprintf.c	3 Jun 2003 17:26:23 -0000
*************** pass a pointer to a pointer.  This funct
*** 37,43 ****
  the buffer needed, allocate memory with @code{malloc}, and store a
  pointer to the allocated memory in @code{*@var{resptr}}.  The value
  returned is the same as @code{sprintf} would return.  If memory could
! not be allocated, zero is returned and @code{NULL} is stored in
  @code{*@var{resptr}}.
  
  @end deftypefn
--- 37,43 ----
  the buffer needed, allocate memory with @code{malloc}, and store a
  pointer to the allocated memory in @code{*@var{resptr}}.  The value
  returned is the same as @code{sprintf} would return.  If memory could
! not be allocated, minus one is returned and @code{NULL} is stored in
  @code{*@var{resptr}}.
  
  @end deftypefn

Index: vasprintf.c
===================================================================
RCS file: /cvs/src/src/libiberty/vasprintf.c,v
retrieving revision 1.7
diff -c -3 -p -r1.7 vasprintf.c
*** vasprintf.c	20 Sep 2002 13:45:20 -0000	1.7
--- vasprintf.c	3 Jun 2003 17:26:24 -0000
*************** you pass a pointer to a pointer.  This f
*** 52,58 ****
  of the buffer needed, allocate memory with @code{malloc}, and store a
  pointer to the allocated memory in @code{*@var{resptr}}.  The value
  returned is the same as @code{vsprintf} would return.  If memory could
! not be allocated, zero is returned and @code{NULL} is stored in
  @code{*@var{resptr}}.
  
  @end deftypefn
--- 52,58 ----
  of the buffer needed, allocate memory with @code{malloc}, and store a
  pointer to the allocated memory in @code{*@var{resptr}}.  The value
  returned is the same as @code{vsprintf} would return.  If memory could
! not be allocated, minus one is returned and @code{NULL} is stored in
  @code{*@var{resptr}}.
  
  @end deftypefn
*************** int_vasprintf (result, format, args)
*** 142,148 ****
    if (*result != NULL)
      return vsprintf (*result, format, *args);
    else
!     return 0;
  }
  
  int
--- 142,148 ----
    if (*result != NULL)
      return vsprintf (*result, format, *args);
    else
!     return -1;
  }
  
  int

Index: functions.texi
===================================================================
RCS file: /cvs/src/src/libiberty/functions.texi,v
retrieving revision 1.13
diff -c -3 -p -r1.13 functions.texi
*** functions.texi	15 May 2003 19:08:25 -0000	1.13
--- functions.texi	3 Jun 2003 17:26:24 -0000
*************** pass a pointer to a pointer.  This funct
*** 29,35 ****
  the buffer needed, allocate memory with @code{malloc}, and store a
  pointer to the allocated memory in @code{*@var{resptr}}.  The value
  returned is the same as @code{sprintf} would return.  If memory could
! not be allocated, zero is returned and @code{NULL} is stored in
  @code{*@var{resptr}}.
  
  @end deftypefn
--- 29,35 ----
  the buffer needed, allocate memory with @code{malloc}, and store a
  pointer to the allocated memory in @code{*@var{resptr}}.  The value
  returned is the same as @code{sprintf} would return.  If memory could
! not be allocated, minus one is returned and @code{NULL} is stored in
  @code{*@var{resptr}}.
  
  @end deftypefn
*************** you pass a pointer to a pointer.  This f
*** 922,928 ****
  of the buffer needed, allocate memory with @code{malloc}, and store a
  pointer to the allocated memory in @code{*@var{resptr}}.  The value
  returned is the same as @code{vsprintf} would return.  If memory could
! not be allocated, zero is returned and @code{NULL} is stored in
  @code{*@var{resptr}}.
  
  @end deftypefn
--- 922,928 ----
  of the buffer needed, allocate memory with @code{malloc}, and store a
  pointer to the allocated memory in @code{*@var{resptr}}.  The value
  returned is the same as @code{vsprintf} would return.  If memory could
! not be allocated, minus one is returned and @code{NULL} is stored in
  @code{*@var{resptr}}.
  
  @end deftypefn

        


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