Hi Andre, On Wed, Sep 24, 2008 at 4:01 PM, André Goddard Rosa <andre.goddard@xxxxxxxxx> wrote: > From 88a02845c606413444bfb055935303b4896d0271 Mon Sep 17 00:00:00 2001 > From: =?utf-8?q?Andr=C3=A9=20Goddard=20Rosa?= <andre.goddard@xxxxxxxxx> > Date: Wed, 24 Sep 2008 10:25:08 -0300 > Subject: [PATCH] Avoid redundantly filling the position 'n - 1' two times in strncpy() example code. > MIME-Version: 1.0 > Content-Type: text/plain; charset=utf-8 > Content-Transfer-Encoding: 8bit > > When we use 'strncpy(buf, str, n)', strncpy() will fill chars from 0..(n - 1). > As we force the character at position 'n - 1' to be '\0' anyway, don't fill it in strncpy() before. Thanks! Applied for 3.11. Cheers, Michael > Signed-off-by: André Goddard Rosa <andre.goddard@xxxxxxxxx> > --- > man3/strcpy.3 | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/man3/strcpy.3 b/man3/strcpy.3 > index 7a8091f..d2e08a3 100644 > --- a/man3/strcpy.3 > +++ b/man3/strcpy.3 > @@ -115,7 +115,7 @@ as follows: > .in +4n > .nf > > -strncpy(buf, str, n); > +strncpy(buf, str, n \- 1); > if (n > 0) > buf[n \- 1]= \(aq\\0\(aq; > .fi > -- > 1.6.0.2.508.g24593 > > > -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ man-pages online: http://www.kernel.org/doc/man-pages/online_pages.html Found a bug? http://www.kernel.org/doc/man-pages/reporting_bugs.html -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html