Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Andrew Cagney <cagney@gnu.org>
To: Daniel Jacobowitz <drow@false.org>
Cc: Mark Kettenis <kettenis@gnu.org>, gdb@sources.redhat.com
Subject: Re: [RFC] xnsprintf()
Date: Fri, 08 Apr 2005 23:33:00 -0000	[thread overview]
Message-ID: <42571449.9030800@gnu.org> (raw)
In-Reply-To: <20050313154155.GB18342@nevyn.them.org>

Daniel Jacobowitz wrote:
> On Sun, Mar 13, 2005 at 03:48:52PM +0100, Mark Kettenis wrote:
> 
>>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?
> 
> 
> Sure.  Seems like a good fit with xasprintf and xstrprintf.

I like this positive change.

http://sources.redhat.com/ml/gdb-patches/2003-04/msg00404.html
I disagree.  Why on earth wouldn't we use sprintf?  Just because it can
be used incorrectly is no excuse.


  parent reply	other threads:[~2005-04-08 23:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-13 14:49 Mark Kettenis
2005-03-13 15:41 ` Daniel Jacobowitz
2005-03-16  0:27   ` Kevin Buettner
2005-04-08 23:33   ` Andrew Cagney [this message]
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=42571449.9030800@gnu.org \
    --to=cagney@gnu.org \
    --cc=drow@false.org \
    --cc=gdb@sources.redhat.com \
    --cc=kettenis@gnu.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