Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* RFA: callfuncs.c and callfwmall.c
@ 2001-11-02  0:29 Jackie Smith Cashion
  2001-11-12 17:07 ` Fernando Nasser
  0 siblings, 1 reply; 3+ messages in thread
From: Jackie Smith Cashion @ 2001-11-02  0:29 UTC (permalink / raw)
  To: GDB Patches

The functions "char *t_structs_a" in gdb/testsuite/callfuncs.c and
callfwmall.c erroneously return a pointer to a local variable. Please
consider the following change.

2001-11-12  Jackie Smith Cashion  <jsmith@redhat.com>

	* gdb.base/callfuncs.c (t_structs_a): Do not return a pointer
	to a local (non-static) variable. Copy tstruct.a to a static buffer
	and return a pointer to that buffer.
	* gdb.base/callfwmall.c (t_structs_a): Ditto.

Index: callfuncs.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/callfuncs.c,v
retrieving revision 1.3
diff -c -3 -p -r1.3 callfuncs.c
*** callfuncs.c	2001/11/08 19:08:34	1.3
--- callfuncs.c	2001/11/13 00:36:29
*************** int    t_structs_i (struct struct1 tstru
*** 133,139 ****
  long   t_structs_l (struct struct1 tstruct) { return (tstruct.l); }
  float  t_structs_f (struct struct1 tstruct) { return (tstruct.f); }
  double t_structs_d (struct struct1 tstruct) { return (tstruct.d); }
! char  *t_structs_a (struct struct1 tstruct) { return (tstruct.a); }
  #else
  char   t_structs_c (tstruct) struct struct1 tstruct; { return
(tstruct.c); }
  short  t_structs_s (tstruct) struct struct1 tstruct; { return
(tstruct.s); }
--- 133,144 ----
  long   t_structs_l (struct struct1 tstruct) { return (tstruct.l); }
  float  t_structs_f (struct struct1 tstruct) { return (tstruct.f); }
  double t_structs_d (struct struct1 tstruct) { return (tstruct.d); }
! char  *t_structs_a (struct struct1 tstruct)
! {
!   static char buf[8];
!   strcpy (buf, tstruct.a);
!   return buf;
! }
  #else
  char   t_structs_c (tstruct) struct struct1 tstruct; { return
(tstruct.c); }
  short  t_structs_s (tstruct) struct struct1 tstruct; { return
(tstruct.s); }
*************** int    t_structs_i (tstruct) struct stru
*** 141,147 ****
  long   t_structs_l (tstruct) struct struct1 tstruct; { return
(tstruct.l); }
  float  t_structs_f (tstruct) struct struct1 tstruct; { return
(tstruct.f); }
  double t_structs_d (tstruct) struct struct1 tstruct; { return
(tstruct.d); }
! char  *t_structs_a (tstruct) struct struct1 tstruct; { return
(tstruct.a); }
  #endif
  
  /* Test that calling functions works if there are a lot of arguments. 
*/
--- 146,157 ----
  long   t_structs_l (tstruct) struct struct1 tstruct; { return
(tstruct.l); }
  float  t_structs_f (tstruct) struct struct1 tstruct; { return
(tstruct.f); }
  double t_structs_d (tstruct) struct struct1 tstruct; { return
(tstruct.d); }
! char  *t_structs_a (tstruct) struct struct1 tstruct;
! {
!   static char buf[8];
!   strcpy (buf, tstruct.a);
!   return buf;
! }
  #endif
  
  /* Test that calling functions works if there are a lot of arguments. 
*/
Index: callfwmall.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/callfwmall.c,v
retrieving revision 1.2
diff -c -3 -p -r1.2 callfwmall.c
*** callfwmall.c	2001/11/08 19:08:34	1.2
--- callfwmall.c	2001/11/13 00:36:29
*************** int    t_structs_i (struct struct1 tstru
*** 138,144 ****
  long   t_structs_l (struct struct1 tstruct) { return (tstruct.l); }
  float  t_structs_f (struct struct1 tstruct) { return (tstruct.f); }
  double t_structs_d (struct struct1 tstruct) { return (tstruct.d); }
! char  *t_structs_a (struct struct1 tstruct) { return (tstruct.a); }
  #else
  char   t_structs_c (tstruct) struct struct1 tstruct; { return
(tstruct.c); }
  short  t_structs_s (tstruct) struct struct1 tstruct; { return
(tstruct.s); }
--- 138,149 ----
  long   t_structs_l (struct struct1 tstruct) { return (tstruct.l); }
  float  t_structs_f (struct struct1 tstruct) { return (tstruct.f); }
  double t_structs_d (struct struct1 tstruct) { return (tstruct.d); }
! char  *t_structs_a (struct struct1 tstruct)
! {
!   static char buf[8];
!   strcpy (buf, tstruct.a);
!   return buf;
! }
  #else
  char   t_structs_c (tstruct) struct struct1 tstruct; { return
(tstruct.c); }
  short  t_structs_s (tstruct) struct struct1 tstruct; { return
(tstruct.s); }
*************** int    t_structs_i (tstruct) struct stru
*** 146,152 ****
  long   t_structs_l (tstruct) struct struct1 tstruct; { return
(tstruct.l); }
  float  t_structs_f (tstruct) struct struct1 tstruct; { return
(tstruct.f); }
  double t_structs_d (tstruct) struct struct1 tstruct; { return
(tstruct.d); }
! char  *t_structs_a (tstruct) struct struct1 tstruct; { return
(tstruct.a); }
  #endif
  
  /* Test that calling functions works if there are a lot of arguments. 
*/
--- 151,162 ----
  long   t_structs_l (tstruct) struct struct1 tstruct; { return
(tstruct.l); }
  float  t_structs_f (tstruct) struct struct1 tstruct; { return
(tstruct.f); }
  double t_structs_d (tstruct) struct struct1 tstruct; { return
(tstruct.d); }
! char  *t_structs_a (tstruct) struct struct1 tstruct;
! {
!   static char buf[8];
!   strcpy (buf, tstruct.a);
!   return buf;
! }
  #endif
  
  /* Test that calling functions works if there are a lot of arguments. 
*/


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: RFA: callfuncs.c and callfwmall.c
  2001-11-02  0:29 RFA: callfuncs.c and callfwmall.c Jackie Smith Cashion
@ 2001-11-12 17:07 ` Fernando Nasser
  2001-11-26 11:41   ` Fernando Nasser
  0 siblings, 1 reply; 3+ messages in thread
From: Fernando Nasser @ 2001-11-12 17:07 UTC (permalink / raw)
  To: Jackie Smith Cashion; +Cc: GDB Patches

Approved and checked in.

Fernando


Jackie Smith Cashion wrote:
> 
> The functions "char *t_structs_a" in gdb/testsuite/callfuncs.c and
> callfwmall.c erroneously return a pointer to a local variable. Please
> consider the following change.
> 
> 2001-11-12  Jackie Smith Cashion  <jsmith@redhat.com>
> 
>         * gdb.base/callfuncs.c (t_structs_a): Do not return a pointer
>         to a local (non-static) variable. Copy tstruct.a to a static buffer
>         and return a pointer to that buffer.
>         * gdb.base/callfwmall.c (t_structs_a): Ditto.
> 
> Index: callfuncs.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.base/callfuncs.c,v
> retrieving revision 1.3
> diff -c -3 -p -r1.3 callfuncs.c
> *** callfuncs.c 2001/11/08 19:08:34     1.3
> --- callfuncs.c 2001/11/13 00:36:29
> *************** int    t_structs_i (struct struct1 tstru
> *** 133,139 ****
>   long   t_structs_l (struct struct1 tstruct) { return (tstruct.l); }
>   float  t_structs_f (struct struct1 tstruct) { return (tstruct.f); }
>   double t_structs_d (struct struct1 tstruct) { return (tstruct.d); }
> ! char  *t_structs_a (struct struct1 tstruct) { return (tstruct.a); }
>   #else
>   char   t_structs_c (tstruct) struct struct1 tstruct; { return
> (tstruct.c); }
>   short  t_structs_s (tstruct) struct struct1 tstruct; { return
> (tstruct.s); }
> --- 133,144 ----
>   long   t_structs_l (struct struct1 tstruct) { return (tstruct.l); }
>   float  t_structs_f (struct struct1 tstruct) { return (tstruct.f); }
>   double t_structs_d (struct struct1 tstruct) { return (tstruct.d); }
> ! char  *t_structs_a (struct struct1 tstruct)
> ! {
> !   static char buf[8];
> !   strcpy (buf, tstruct.a);
> !   return buf;
> ! }
>   #else
>   char   t_structs_c (tstruct) struct struct1 tstruct; { return
> (tstruct.c); }
>   short  t_structs_s (tstruct) struct struct1 tstruct; { return
> (tstruct.s); }
> *************** int    t_structs_i (tstruct) struct stru
> *** 141,147 ****
>   long   t_structs_l (tstruct) struct struct1 tstruct; { return
> (tstruct.l); }
>   float  t_structs_f (tstruct) struct struct1 tstruct; { return
> (tstruct.f); }
>   double t_structs_d (tstruct) struct struct1 tstruct; { return
> (tstruct.d); }
> ! char  *t_structs_a (tstruct) struct struct1 tstruct; { return
> (tstruct.a); }
>   #endif
> 
>   /* Test that calling functions works if there are a lot of arguments.
> */
> --- 146,157 ----
>   long   t_structs_l (tstruct) struct struct1 tstruct; { return
> (tstruct.l); }
>   float  t_structs_f (tstruct) struct struct1 tstruct; { return
> (tstruct.f); }
>   double t_structs_d (tstruct) struct struct1 tstruct; { return
> (tstruct.d); }
> ! char  *t_structs_a (tstruct) struct struct1 tstruct;
> ! {
> !   static char buf[8];
> !   strcpy (buf, tstruct.a);
> !   return buf;
> ! }
>   #endif
> 
>   /* Test that calling functions works if there are a lot of arguments.
> */
> Index: callfwmall.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.base/callfwmall.c,v
> retrieving revision 1.2
> diff -c -3 -p -r1.2 callfwmall.c
> *** callfwmall.c        2001/11/08 19:08:34     1.2
> --- callfwmall.c        2001/11/13 00:36:29
> *************** int    t_structs_i (struct struct1 tstru
> *** 138,144 ****
>   long   t_structs_l (struct struct1 tstruct) { return (tstruct.l); }
>   float  t_structs_f (struct struct1 tstruct) { return (tstruct.f); }
>   double t_structs_d (struct struct1 tstruct) { return (tstruct.d); }
> ! char  *t_structs_a (struct struct1 tstruct) { return (tstruct.a); }
>   #else
>   char   t_structs_c (tstruct) struct struct1 tstruct; { return
> (tstruct.c); }
>   short  t_structs_s (tstruct) struct struct1 tstruct; { return
> (tstruct.s); }
> --- 138,149 ----
>   long   t_structs_l (struct struct1 tstruct) { return (tstruct.l); }
>   float  t_structs_f (struct struct1 tstruct) { return (tstruct.f); }
>   double t_structs_d (struct struct1 tstruct) { return (tstruct.d); }
> ! char  *t_structs_a (struct struct1 tstruct)
> ! {
> !   static char buf[8];
> !   strcpy (buf, tstruct.a);
> !   return buf;
> ! }
>   #else
>   char   t_structs_c (tstruct) struct struct1 tstruct; { return
> (tstruct.c); }
>   short  t_structs_s (tstruct) struct struct1 tstruct; { return
> (tstruct.s); }
> *************** int    t_structs_i (tstruct) struct stru
> *** 146,152 ****
>   long   t_structs_l (tstruct) struct struct1 tstruct; { return
> (tstruct.l); }
>   float  t_structs_f (tstruct) struct struct1 tstruct; { return
> (tstruct.f); }
>   double t_structs_d (tstruct) struct struct1 tstruct; { return
> (tstruct.d); }
> ! char  *t_structs_a (tstruct) struct struct1 tstruct; { return
> (tstruct.a); }
>   #endif
> 
>   /* Test that calling functions works if there are a lot of arguments.
> */
> --- 151,162 ----
>   long   t_structs_l (tstruct) struct struct1 tstruct; { return
> (tstruct.l); }
>   float  t_structs_f (tstruct) struct struct1 tstruct; { return
> (tstruct.f); }
>   double t_structs_d (tstruct) struct struct1 tstruct; { return
> (tstruct.d); }
> ! char  *t_structs_a (tstruct) struct struct1 tstruct;
> ! {
> !   static char buf[8];
> !   strcpy (buf, tstruct.a);
> !   return buf;
> ! }
>   #endif
> 
>   /* Test that calling functions works if there are a lot of arguments.
> */

-- 
Fernando Nasser
Red Hat - Toronto                       E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: RFA: callfuncs.c and callfwmall.c
  2001-11-12 17:07 ` Fernando Nasser
@ 2001-11-26 11:41   ` Fernando Nasser
  0 siblings, 0 replies; 3+ messages in thread
From: Fernando Nasser @ 2001-11-26 11:41 UTC (permalink / raw)
  To: Jackie Smith Cashion; +Cc: GDB Patches

Approved and checked in.

Fernando


Jackie Smith Cashion wrote:
> 
> The functions "char *t_structs_a" in gdb/testsuite/callfuncs.c and
> callfwmall.c erroneously return a pointer to a local variable. Please
> consider the following change.
> 
> 2001-11-12  Jackie Smith Cashion  <jsmith@redhat.com>
> 
>         * gdb.base/callfuncs.c (t_structs_a): Do not return a pointer
>         to a local (non-static) variable. Copy tstruct.a to a static buffer
>         and return a pointer to that buffer.
>         * gdb.base/callfwmall.c (t_structs_a): Ditto.
> 
> Index: callfuncs.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.base/callfuncs.c,v
> retrieving revision 1.3
> diff -c -3 -p -r1.3 callfuncs.c
> *** callfuncs.c 2001/11/08 19:08:34     1.3
> --- callfuncs.c 2001/11/13 00:36:29
> *************** int    t_structs_i (struct struct1 tstru
> *** 133,139 ****
>   long   t_structs_l (struct struct1 tstruct) { return (tstruct.l); }
>   float  t_structs_f (struct struct1 tstruct) { return (tstruct.f); }
>   double t_structs_d (struct struct1 tstruct) { return (tstruct.d); }
> ! char  *t_structs_a (struct struct1 tstruct) { return (tstruct.a); }
>   #else
>   char   t_structs_c (tstruct) struct struct1 tstruct; { return
> (tstruct.c); }
>   short  t_structs_s (tstruct) struct struct1 tstruct; { return
> (tstruct.s); }
> --- 133,144 ----
>   long   t_structs_l (struct struct1 tstruct) { return (tstruct.l); }
>   float  t_structs_f (struct struct1 tstruct) { return (tstruct.f); }
>   double t_structs_d (struct struct1 tstruct) { return (tstruct.d); }
> ! char  *t_structs_a (struct struct1 tstruct)
> ! {
> !   static char buf[8];
> !   strcpy (buf, tstruct.a);
> !   return buf;
> ! }
>   #else
>   char   t_structs_c (tstruct) struct struct1 tstruct; { return
> (tstruct.c); }
>   short  t_structs_s (tstruct) struct struct1 tstruct; { return
> (tstruct.s); }
> *************** int    t_structs_i (tstruct) struct stru
> *** 141,147 ****
>   long   t_structs_l (tstruct) struct struct1 tstruct; { return
> (tstruct.l); }
>   float  t_structs_f (tstruct) struct struct1 tstruct; { return
> (tstruct.f); }
>   double t_structs_d (tstruct) struct struct1 tstruct; { return
> (tstruct.d); }
> ! char  *t_structs_a (tstruct) struct struct1 tstruct; { return
> (tstruct.a); }
>   #endif
> 
>   /* Test that calling functions works if there are a lot of arguments.
> */
> --- 146,157 ----
>   long   t_structs_l (tstruct) struct struct1 tstruct; { return
> (tstruct.l); }
>   float  t_structs_f (tstruct) struct struct1 tstruct; { return
> (tstruct.f); }
>   double t_structs_d (tstruct) struct struct1 tstruct; { return
> (tstruct.d); }
> ! char  *t_structs_a (tstruct) struct struct1 tstruct;
> ! {
> !   static char buf[8];
> !   strcpy (buf, tstruct.a);
> !   return buf;
> ! }
>   #endif
> 
>   /* Test that calling functions works if there are a lot of arguments.
> */
> Index: callfwmall.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.base/callfwmall.c,v
> retrieving revision 1.2
> diff -c -3 -p -r1.2 callfwmall.c
> *** callfwmall.c        2001/11/08 19:08:34     1.2
> --- callfwmall.c        2001/11/13 00:36:29
> *************** int    t_structs_i (struct struct1 tstru
> *** 138,144 ****
>   long   t_structs_l (struct struct1 tstruct) { return (tstruct.l); }
>   float  t_structs_f (struct struct1 tstruct) { return (tstruct.f); }
>   double t_structs_d (struct struct1 tstruct) { return (tstruct.d); }
> ! char  *t_structs_a (struct struct1 tstruct) { return (tstruct.a); }
>   #else
>   char   t_structs_c (tstruct) struct struct1 tstruct; { return
> (tstruct.c); }
>   short  t_structs_s (tstruct) struct struct1 tstruct; { return
> (tstruct.s); }
> --- 138,149 ----
>   long   t_structs_l (struct struct1 tstruct) { return (tstruct.l); }
>   float  t_structs_f (struct struct1 tstruct) { return (tstruct.f); }
>   double t_structs_d (struct struct1 tstruct) { return (tstruct.d); }
> ! char  *t_structs_a (struct struct1 tstruct)
> ! {
> !   static char buf[8];
> !   strcpy (buf, tstruct.a);
> !   return buf;
> ! }
>   #else
>   char   t_structs_c (tstruct) struct struct1 tstruct; { return
> (tstruct.c); }
>   short  t_structs_s (tstruct) struct struct1 tstruct; { return
> (tstruct.s); }
> *************** int    t_structs_i (tstruct) struct stru
> *** 146,152 ****
>   long   t_structs_l (tstruct) struct struct1 tstruct; { return
> (tstruct.l); }
>   float  t_structs_f (tstruct) struct struct1 tstruct; { return
> (tstruct.f); }
>   double t_structs_d (tstruct) struct struct1 tstruct; { return
> (tstruct.d); }
> ! char  *t_structs_a (tstruct) struct struct1 tstruct; { return
> (tstruct.a); }
>   #endif
> 
>   /* Test that calling functions works if there are a lot of arguments.
> */
> --- 151,162 ----
>   long   t_structs_l (tstruct) struct struct1 tstruct; { return
> (tstruct.l); }
>   float  t_structs_f (tstruct) struct struct1 tstruct; { return
> (tstruct.f); }
>   double t_structs_d (tstruct) struct struct1 tstruct; { return
> (tstruct.d); }
> ! char  *t_structs_a (tstruct) struct struct1 tstruct;
> ! {
> !   static char buf[8];
> !   strcpy (buf, tstruct.a);
> !   return buf;
> ! }
>   #endif
> 
>   /* Test that calling functions works if there are a lot of arguments.
> */

-- 
Fernando Nasser
Red Hat - Toronto                       E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-11-26 19:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-02  0:29 RFA: callfuncs.c and callfwmall.c Jackie Smith Cashion
2001-11-12 17:07 ` Fernando Nasser
2001-11-26 11:41   ` Fernando Nasser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox