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 bsearch discar...



details:   https://anonhg.NetBSD.org/src/rev/b6b0c1a72f67
branches:  trunk
changeset: 1024089:b6b0c1a72f67
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Oct 09 20:07:37 2021 +0000

description:
indent: fix lint warning about bsearch discarding 'const'

lexi.c(433): warning: call to 'bsearch' effectively discards 'const'
    from argument [346]

diffstat:

 usr.bin/indent/lexi.c |  9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diffs (37 lines):

diff -r 9c2eff5827e6 -r b6b0c1a72f67 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Sat Oct 09 20:03:20 2021 +0000
+++ b/usr.bin/indent/lexi.c     Sat Oct 09 20:07:37 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lexi.c,v 1.87 2021/10/08 23:55:44 rillig Exp $ */
+/*     $NetBSD: lexi.c,v 1.88 2021/10/09 20:07:37 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.87 2021/10/08 23:55:44 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.88 2021/10/09 20:07:37 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -401,7 +401,6 @@
     if (isalnum((unsigned char)*inp.s) ||
        *inp.s == '_' || *inp.s == '$' ||
        (inp.s[0] == '.' && isdigit((unsigned char)inp.s[1]))) {
-       struct keyword *kw;
 
        if (isdigit((unsigned char)*inp.s) ||
            (inp.s[0] == '.' && isdigit((unsigned char)inp.s[1]))) {
@@ -429,8 +428,8 @@
         */
        state->last_u_d = (state->last_token == keyword_struct_union_enum);
 
-       kw = bsearch(token.s, keywords, nitems(keywords),
-           sizeof(keywords[0]), cmp_keyword_by_name);
+       const struct keyword *kw = bsearch(token.s, keywords,
+           nitems(keywords), sizeof(keywords[0]), cmp_keyword_by_name);
        if (kw == NULL) {
            if (is_typename()) {
                state->keyword = kw_type;



Home | Main Index | Thread Index | Old Index