Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/xlint/lint1 lint: fix off-by-one error in 'case 3...5'



details:   https://anonhg.NetBSD.org/src/rev/163ea2e34ae1
branches:  trunk
changeset: 1019349:163ea2e34ae1
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Mar 07 18:02:45 2021 +0000

description:
lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.

diffstat:

 usr.bin/xlint/lint1/cgram.y |  6 +++---
 usr.bin/xlint/lint1/lint1.h |  6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diffs (48 lines):

diff -r da9193e68ef7 -r 163ea2e34ae1 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Sun Mar 07 17:57:52 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Sun Mar 07 18:02:45 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.164 2021/03/07 17:57:52 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.165 2021/03/07 18:02:45 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.164 2021/03/07 17:57:52 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.165 2021/03/07 18:02:45 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -1348,7 +1348,7 @@
 range:
          constant {
                $$.lo = toicon($1, 1);
-               $$.hi = $$.lo + 1;
+               $$.hi = $$.lo;
          }
        | constant T_ELLIPSIS constant {
                $$.lo = toicon($1, 1);
diff -r da9193e68ef7 -r 163ea2e34ae1 usr.bin/xlint/lint1/lint1.h
--- a/usr.bin/xlint/lint1/lint1.h       Sun Mar 07 17:57:52 2021 +0000
+++ b/usr.bin/xlint/lint1/lint1.h       Sun Mar 07 18:02:45 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.69 2021/02/28 19:24:15 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.70 2021/03/07 18:02:45 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -403,8 +403,8 @@
 } cstk_t;
 
 typedef struct {
-       size_t lo;
-       size_t hi;
+       size_t lo;                      /* inclusive */
+       size_t hi;                      /* inclusive */
 } range_t;
 
 #include "externs1.h"



Home | Main Index | Thread Index | Old Index