From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6127 invoked by alias); 17 Mar 2005 21:12:17 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 5630 invoked from network); 17 Mar 2005 21:11:56 -0000 Received: from unknown (HELO sibelius.xs4all.nl) (82.92.89.47) by sourceware.org with SMTP; 17 Mar 2005 21:11:56 -0000 Received: from elgar.sibelius.xs4all.nl (root@elgar.sibelius.xs4all.nl [192.168.0.2]) by sibelius.xs4all.nl (8.13.0/8.13.0) with ESMTP id j2HLBoPS029425 for ; Thu, 17 Mar 2005 22:11:50 +0100 (CET) Received: from elgar.sibelius.xs4all.nl (kettenis@localhost.sibelius.xs4all.nl [127.0.0.1]) by elgar.sibelius.xs4all.nl (8.13.3/8.13.3) with ESMTP id j2HLBn3R003232 for ; Thu, 17 Mar 2005 22:11:49 +0100 (CET) Received: (from kettenis@localhost) by elgar.sibelius.xs4all.nl (8.13.3/8.13.3/Submit) id j2HLBnk9024999; Thu, 17 Mar 2005 22:11:49 +0100 (CET) Date: Thu, 17 Mar 2005 21:12:00 -0000 Message-Id: <200503172111.j2HLBnk9024999@elgar.sibelius.xs4all.nl> From: Mark Kettenis To: gdb-patches@sourceware.org Subject: [RFC] Avoid using sprintf in the testsuite X-SW-Source: 2005-03/txt/msg00234.txt.bz2 Using sprintf in the testsuite causes problems with the upcoming OpenBSD 3.7. The warning about its usuge printed by the linker makes us think the compilation failed. Here's a patch that replaces the usage of sprintf in gdb.base/fileio.{c,exp} with simple string concatenation. I'd rather do this instead of using snprintf, since the latter is not available on HP-UX 10.20. Objections? Otherwise I'll check this in next weekend. Mark Index: testsuite/ChangeLog from Mark Kettenis * gdb.base/fileio.c (test_system, test_unlink): Avoid using sprintf. * gdb.base/fileio.exp: Adjust line number. Index: testsuite/gdb.base/fileio.c =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/fileio.c,v retrieving revision 1.8 diff -u -p -r1.8 fileio.c --- testsuite/gdb.base/fileio.c 10 Jan 2005 15:58:23 -0000 1.8 +++ testsuite/gdb.base/fileio.c 17 Mar 2005 21:04:09 -0000 @@ -334,10 +334,10 @@ test_system () * Requires test framework to switch on "set remote system-call-allowed 1" */ int ret; - char sys[512]; + char *sys; /* This test prepares the directory for test_rename() */ - sprintf (sys, "mkdir -p %s %s", TESTSUBDIR, TESTDIR2); + sys = "mkdir -p " TESTSUBDIR " " TESTDIR2; ret = system (sys); if (ret == 127) printf ("system 1: ret = %d /bin/sh unavailable???\n", ret); @@ -400,21 +400,21 @@ int test_unlink () { int ret; - char name[256]; - char sys[512]; + char *name; + char *sys; /* Test unlink */ errno = 0; ret = unlink (RENAMED); printf ("unlink 1: ret = %d, errno = %d %s\n", ret, errno, strerrno (errno)); + name = TESTDIR2 "/" FILENAME; /* No write access */ - sprintf (name, "%s/%s", TESTDIR2, FILENAME); errno = 0; ret = open (name, O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR); if (ret >= 0) { - sprintf (sys, "chmod -w %s", TESTDIR2); + sys = "chmod -w " TESTDIR2; ret = system (sys); if (!ret) { Index: testsuite/gdb.base/fileio.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/fileio.exp,v retrieving revision 1.7 diff -u -p -r1.7 fileio.exp --- testsuite/gdb.base/fileio.exp 18 Jan 2004 21:17:57 -0000 1.7 +++ testsuite/gdb.base/fileio.exp 17 Mar 2005 21:04:09 -0000 @@ -240,9 +240,9 @@ gdb_test continue \ "Continuing\\..*rename 5:.*ENOENT.*test_rename \\(\\) at.*$srcfile:397.*" \ "Renaming a nonexistant file returns ENOENT" -send_gdb "tbreak 412\n" ; gdb_expect -re "$gdb_prompt $" +send_gdb "tbreak 413\n" ; gdb_expect -re "$gdb_prompt $" gdb_test continue \ -"Continuing\\..*unlink 1:.*OK.*test_unlink \\(\\) at.*$srcfile:412.*" \ +"Continuing\\..*unlink 1:.*OK.*test_unlink \\(\\) at.*$srcfile:413.*" \ "Unlink a file" send_gdb "tbreak 432\n" ; gdb_expect -re "$gdb_prompt $"