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. 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
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. 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