From: Ira Snyder <kernel@irasnyder.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: [KJ] [PATCH] 3c505.c: replacing strcpy to strncpy
Date: Tue, 27 Feb 2007 19:20:59 +0000 [thread overview]
Message-ID: <20070227112059.1452cacb.kernel@irasnyder.com> (raw)
In-Reply-To: <20070225173528.GB3595@localhost.localdomain>
[-- Attachment #1.1: Type: text/plain, Size: 792 bytes --]
On Tue, 27 Feb 2007 11:12:00 -0500
burns.ethan@gmail.com wrote:
> On Tue, Feb 27, 2007 at 10:03:25AM +0100, Standard Azi wrote:
> > char buf[150];
> >
> > strcpy(buf, "LALA");
> >
> > that's one reason, for example
>
> char buf[150] = "LALA";
>
> and if you really need to do it outside of initialization, does the strncpy()
> really hurt it? What if the size of `buf' gets changed, then we would have to
> go check for all strcpy()s and make sure that they are still valid, where
> strncpy would do it by default.
>
Also, what about strlcpy()? It's a drop-in replacement for strncpy(), _ALWAYS_ null terminates the destination string (strncpy() doesn't), and doesn't have to pad out the destination string strncpy().
I pretty much always find it better than strcpy() and strncpy().
Ira
[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 168 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
prev parent reply other threads:[~2007-02-27 19:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-25 16:57 [KJ] [PATCH] 3c505.c: replacing strcpy to strncpy Douglas Schilling Landgraf
2007-02-26 7:54 ` Milind Choudhary
2007-02-27 0:16 ` Douglas Schilling Landgraf
2007-02-27 0:24 ` burns.ethan
2007-02-27 9:03 ` Standard Azi
2007-02-27 9:07 ` Bernhard R. Link
2007-02-27 16:12 ` burns.ethan
2007-02-27 16:31 ` burns.ethan
2007-02-27 17:31 ` Bernhard R. Link
2007-02-27 17:50 ` burns.ethan
2007-02-27 18:07 ` Douglas Landgraf
2007-02-27 19:20 ` Ira Snyder [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=20070227112059.1452cacb.kernel@irasnyder.com \
--to=kernel@irasnyder.com \
--cc=kernel-janitors@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.