Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: Mark Kettenis <kettenis@gnu.org>
Cc: gdb@sources.redhat.com
Subject: Re: [RFC] xnsprintf()
Date: Sun, 13 Mar 2005 15:41:00 -0000	[thread overview]
Message-ID: <20050313154155.GB18342@nevyn.them.org> (raw)
In-Reply-To: <200503131448.j2DEmqZ0029001@elgar.sibelius.xs4all.nl>

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.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


  reply	other threads:[~2005-03-13 15:41 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 [this message]
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=20050313154155.GB18342@nevyn.them.org \
    --to=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