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

On Fri, Apr 08, 2005 at 07:31:21PM -0400, Andrew Cagney wrote:
> 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.

Mark has a valid reason - that OpenBSD has begun to warn about it - and
even if I think it's a bit objectionable for an OS to issue such a
warning, we don't get to decide that.

He was also offering a constructive idea for a new interface instead of
objecting to anything.  The question I answered here is not the same
as the opinion I offered in your quoted message.

Anyway, did you have anything useful to contribute, or did you just pop
out of the woodwork to be sarcastic at me?  I don't appreciate it.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


      reply	other threads:[~2005-04-08 23:39 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
2005-04-08 23:39     ` Daniel Jacobowitz [this message]

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=20050408233932.GA20587@nevyn.them.org \
    --to=drow@false.org \
    --cc=cagney@gnu.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