This is the mail archive of the gdb-patches@sources.redhat.com 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: [RFA] Fix gdb.gdbtk/simple.c strncpy args


On Sat, 7 Sep 2002, Fred Fish wrote:

> Strncpy is supposed to take pointers...
> 
>   simple.c: In function `main':
>   simple.c:15: warning: passing arg 1 of `strncpy' makes pointer from integer without a cast
>   simple.c:15: warning: passing arg 2 of `strncpy' makes pointer from integer without a cast
>   WARNING: Testcase compile failed, so some tests in this file will automatically fail.

Wow, I thought I'd fixed this a long time ago... Hmmm. Oh, well. I guess 
not!

Of course this is approved! [BTW, insight also follows gdb's standard 
"obvious fix" rules, too.]

Thanks!
Keith

> 2002-09-07  Fred Fish  <fnf@intrinsity.com>
> 
> 	* simple.c:  Pass addresses to strncpy, not chars.
> 
> Index: simple.c
> ===================================================================
> RCS file: /mips/newtools/fsf/gdb/gdb/testsuite/gdb.gdbtk/simple.c,v
> retrieving revision 1.1.1.1
> diff -c -p -r1.1.1.1 simple.c
> *** simple.c	2002/07/04 20:33:37	1.1.1.1
> --- simple.c	2002/09/08 01:23:50
> *************** main(int argc, char * argv[])
> *** 12,18 ****
>        {
>          int j = i % 3;
>          int k = 3 - j;
> !        strncpy (a[i], b[k], j);
>          foo = (long) j * k / i + 2 * k * k * k;
>        }
>      return 0;
> --- 12,18 ----
>        {
>          int j = i % 3;
>          int k = 3 - j;
> !        strncpy (&a[i], &b[k], j);
>          foo = (long) j * k / i + 2 * k * k * k;
>        }
>      return 0;
> 


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