Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/indent indent: mark obviously broken code



details:   https://anonhg.NetBSD.org/src/rev/aa186c647402
branches:  trunk
changeset: 990516:aa186c647402
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Oct 29 18:50:52 2021 +0000

description:
indent: mark obviously broken code

diffstat:

 usr.bin/indent/indent.c |  10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diffs (31 lines):

diff -r 8446dd464a47 -r aa186c647402 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Fri Oct 29 18:18:03 2021 +0000
+++ b/usr.bin/indent/indent.c   Fri Oct 29 18:50:52 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.171 2021/10/29 17:50:37 rillig Exp $      */
+/*     $NetBSD: indent.c,v 1.172 2021/10/29 18:50:52 rillig Exp $      */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.171 2021/10/29 17:50:37 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.172 2021/10/29 18:50:52 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -188,6 +188,12 @@
         * process_comment() will use that to calculate original indentation
         * of a boxed comment.
         */
+       /*
+        * FIXME: This '4' needs an explanation. For example, in the snippet
+        * 'if(expr)/''*comment', the 'r)' of the code is not copied. If there
+        * is an additional line break before the ')', memcpy tries to copy
+        * (size_t)-1 bytes.
+        */
        memcpy(sc_buf, inp.buf, (size_t)(inp.s - inp.buf) - 4);
        save_com = sc_buf + (inp.s - inp.buf - 4);
        save_com[0] = save_com[1] = ' ';



Home | Main Index | Thread Index | Old Index