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: fix lint warning about signed '>>'



details:   https://anonhg.NetBSD.org/src/rev/b26d7832ea9f
branches:  trunk
changeset: 1023937:b26d7832ea9f
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Oct 03 20:35:59 2021 +0000

description:
indent: fix lint warning about signed '>>'

Lint couldn't infer that indent's list of type names will practically
never contain more that 2 billion entries and that the result of '>>'
would be the same in all cases.

diffstat:

 usr.bin/indent/lexi.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 8a279ff47efc -r b26d7832ea9f usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Sun Oct 03 19:09:59 2021 +0000
+++ b/usr.bin/indent/lexi.c     Sun Oct 03 20:35:59 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lexi.c,v 1.64 2021/09/27 18:21:47 rillig Exp $ */
+/*     $NetBSD: lexi.c,v 1.65 2021/10/03 20:35:59 rillig Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.64 2021/09/27 18:21:47 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.65 2021/10/03 20:35:59 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -670,7 +670,7 @@
     int hi = (int)len - 1;
 
     while (lo <= hi) {
-       int mid = (lo + hi) >> 1;
+       int mid = (int)((unsigned)(lo + hi) >> 1);
        int cmp = strcmp(arr[mid], key);
        if (cmp < 0)
            lo = mid + 1;



Home | Main Index | Thread Index | Old Index