Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make Don't use memcpy for overlapping ranges. Simpli...



details:   https://anonhg.NetBSD.org/src/rev/c76459935d3a
branches:  trunk
changeset: 807624:c76459935d3a
user:      joerg <joerg%NetBSD.org@localhost>
date:      Thu Apr 16 11:39:23 2015 +0000

description:
Don't use memcpy for overlapping ranges. Simplify, memmove is good
enough to skip empty ranges.

diffstat:

 usr.bin/make/job.c |  22 +++++++---------------
 1 files changed, 7 insertions(+), 15 deletions(-)

diffs (49 lines):

diff -r 99389032e0a1 -r c76459935d3a usr.bin/make/job.c
--- a/usr.bin/make/job.c        Thu Apr 16 10:08:59 2015 +0000
+++ b/usr.bin/make/job.c        Thu Apr 16 11:39:23 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.178 2015/04/09 18:21:01 sjg Exp $    */
+/*     $NetBSD: job.c,v 1.179 2015/04/16 11:39:23 joerg Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.178 2015/04/09 18:21:01 sjg Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.179 2015/04/16 11:39:23 joerg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)job.c      8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: job.c,v 1.178 2015/04/09 18:21:01 sjg Exp $");
+__RCSID("$NetBSD: job.c,v 1.179 2015/04/16 11:39:23 joerg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1878,18 +1878,10 @@
                (void)fflush(stdout);
            }
        }
-       if (i < max - 1) {
-           /* shift the remaining characters down */
-           (void)memcpy(job->outBuf, &job->outBuf[i + 1], max - (i + 1));
-           job->curPos = max - (i + 1);
-
-       } else {
-           /*
-            * We have written everything out, so we just start over
-            * from the start of the buffer. No copying. No nothing.
-            */
-           job->curPos = 0;
-       }
+       assert(i < max);
+       /* shift the remaining characters down */
+       (void)memmove(job->outBuf, &job->outBuf[i + 1], max - (i + 1));
+       job->curPos = max - (i + 1);
     }
     if (finish) {
        /*



Home | Main Index | Thread Index | Old Index