From: Mark Kettenis <kettenis@gnu.org>
To: gdb-patches@sourceware.org
Subject: [RFC] Avoid using sprintf in the testsuite
Date: Thu, 17 Mar 2005 21:12:00 -0000 [thread overview]
Message-ID: <200503172111.j2HLBnk9024999@elgar.sibelius.xs4all.nl> (raw)
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 <kettenis@gnu.org>
* 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 $"
next reply other threads:[~2005-03-17 21:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-17 21:12 Mark Kettenis [this message]
2005-03-17 21:46 ` Frank Ch. Eigler
2005-03-20 21:28 ` Mark Kettenis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200503172111.j2HLBnk9024999@elgar.sibelius.xs4all.nl \
--to=kettenis@gnu.org \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox