From: Mark Kettenis <kettenis@gnu.org>
To: gdb@sources.redhat.com
Subject: [RFC] xnsprintf()
Date: Sun, 13 Mar 2005 14:49:00 -0000 [thread overview]
Message-ID: <200503131448.j2DEmqZ0029001@elgar.sibelius.xs4all.nl> (raw)
The bootdisk of my workstation crashed, so I found myself replacing my
aging FreeBSD environment with a fresh OpenBSD snapshot. The OpenBSD
toolchain complains about using dangerous functions like snprintf:
libgdb.a(remote.o)(.text+0xb3b): In function `set_thread':
../../src/gdb/remote.c:1066: warning: sprintf() is often misused,
please use snprintf()
Of course it is right, so I've started converting sprintf() into
snprintf(). While doing so, I find myself writing the following bit
of code over and over again:
int size;
size = snprintf (buf, sizeof buf, ...);
gdb_assert (size < sizeof buf);
So right now I'm wondering whether we should have a function, say
xsnprintf(), that checks whether the string fits in the buffer, and
throws an internal-error if it doesn't.
Opinions?
Mark
next reply other threads:[~2005-03-13 14:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-13 14:49 Mark Kettenis [this message]
2005-03-13 15:41 ` Daniel Jacobowitz
2005-03-16 0:27 ` Kevin Buettner
2005-04-08 23:33 ` Andrew Cagney
2005-04-08 23:39 ` Daniel Jacobowitz
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=200503131448.j2DEmqZ0029001@elgar.sibelius.xs4all.nl \
--to=kettenis@gnu.org \
--cc=gdb@sources.redhat.com \
/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