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: document undefined behavior in proces...



details:   https://anonhg.NetBSD.org/src/rev/f9ed24a10c50
branches:  trunk
changeset: 1019517:f9ed24a10c50
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Mar 13 10:47:59 2021 +0000

description:
indent: document undefined behavior in processing of comments

No functional change.

diffstat:

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

diffs (29 lines):

diff -r 8fff9c787f19 -r f9ed24a10c50 usr.bin/indent/pr_comment.c
--- a/usr.bin/indent/pr_comment.c       Sat Mar 13 10:32:25 2021 +0000
+++ b/usr.bin/indent/pr_comment.c       Sat Mar 13 10:47:59 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pr_comment.c,v 1.24 2021/03/13 10:32:25 rillig Exp $   */
+/*     $NetBSD: pr_comment.c,v 1.25 2021/03/13 10:47:59 rillig Exp $   */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@
 #include <sys/cdefs.h>
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.24 2021/03/13 10:32:25 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.25 2021/03/13 10:47:59 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -186,6 +186,10 @@
         */
        char *start;
 
+       /*
+        * XXX: ordered comparison between pointers from different objects
+        * invokes undefined behavior (C99 6.5.8).
+        */
        start = buf_ptr >= save_com && buf_ptr < save_com + sc_size ?
            sc_buf : in_buffer;
        ps.n_comment_delta = -indentation_after_range(0, start, buf_ptr - 2);



Home | Main Index | Thread Index | Old Index