From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fernando Nasser To: Jackie Smith Cashion Cc: GDB Patches Subject: Re: RFA: callfuncs.c and callfwmall.c Date: Mon, 26 Nov 2001 11:41:00 -0000 Message-ID: <3C029AB7.127B4F7@cygnus.com> References: <3BF07179.B6E9C4FF@redhat.com> X-SW-Source: 2001-11/msg00452.html Message-ID: <20011126114100.5uwVj3dmL15Aq507jlpZw8V7aD2JYAPGfwOcfnFovYo@z> 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 > > * 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