This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: RFA: callfuncs.c and callfwmall.c
- From: Fernando Nasser <fnasser at cygnus dot com>
- To: Jackie Smith Cashion <jsmith at redhat dot com>
- Cc: GDB Patches <gdb-patches at sources dot redhat dot com>
- Date: Mon, 26 Nov 2001 14:40:39 -0500
- Subject: Re: RFA: callfuncs.c and callfwmall.c
- Organization: Red Hat , Inc. - Toronto
- References: <3BF07179.B6E9C4FF@redhat.com>
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