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 warnings about type conversi...



details:   https://anonhg.NetBSD.org/src/rev/3ca81a86adca
branches:  trunk
changeset: 1023118:3ca81a86adca
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Aug 25 22:26:30 2021 +0000

description:
indent: fix lint warnings about type conversions on ilp32

No functional change.

diffstat:

 usr.bin/indent/indent.c |  32 +++++++++++---------------------
 usr.bin/indent/lexi.c   |   6 +++---
 2 files changed, 14 insertions(+), 24 deletions(-)

diffs (99 lines):

diff -r 81e9dfe4cf33 -r 3ca81a86adca usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Wed Aug 25 22:14:38 2021 +0000
+++ b/usr.bin/indent/indent.c   Wed Aug 25 22:26:30 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.60 2021/03/26 22:02:00 rillig Exp $       */
+/*     $NetBSD: indent.c,v 1.61 2021/08/25 22:26:30 rillig Exp $       */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@
 #include <sys/cdefs.h>
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.60 2021/03/26 22:02:00 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.61 2021/08/25 22:26:30 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -1197,7 +1197,7 @@
            }
            if (sc_end - save_com + com_end - com_start > sc_size)
                errx(1, "input too long");
-           memmove(sc_end, s_lab + com_start, com_end - com_start);
+           memmove(sc_end, s_lab + com_start, (size_t)(com_end - com_start));
            sc_end += com_end - com_start;
            e_lab = s_lab + com_start;
            while (e_lab > s_lab && (e_lab[-1] == ' ' || e_lab[-1] == '\t'))
@@ -1235,22 +1235,12 @@
        else
            ifdef_level--;
     } else {
-       static const struct directives {
-           int size;
-           const char *string;
-       } recognized[] = {
-               {7, "include"},
-               {6, "define"},
-               {5, "undef"},
-               {4, "line"},
-               {5, "error"},
-               {6, "pragma"}
-       };
-       int d = nitems(recognized);
-       while (--d >= 0)
-           if (strncmp(s_lab + 1, recognized[d].string, recognized[d].size) == 0)
-               break;
-       if (d < 0) {
+       if (strncmp(s_lab + 1, "pragma", 6) != 0 &&
+           strncmp(s_lab + 1, "error", 5) != 0 &&
+           strncmp(s_lab + 1, "line", 4) != 0 &&
+           strncmp(s_lab + 1, "undef", 5) != 0 &&
+           strncmp(s_lab + 1, "define", 6) != 0 &&
+           strncmp(s_lab + 1, "include", 7) != 0) {
            diag(1, "Unrecognized cpp directive");
            return;
        }
@@ -1538,13 +1528,13 @@
     if (tabs_to_var) {
        int tpos;
 
-       check_size_code(cur_dec_ind / opt.tabsize);
+       check_size_code((size_t)(cur_dec_ind / opt.tabsize));
        while ((tpos = opt.tabsize * (1 + pos / opt.tabsize)) <= cur_dec_ind) {
            *e_code++ = '\t';
            pos = tpos;
        }
     }
-    check_size_code(cur_dec_ind - pos + 1);
+    check_size_code((size_t)(cur_dec_ind - pos + 1));
     while (pos < cur_dec_ind) {
        *e_code++ = ' ';
        pos++;
diff -r 81e9dfe4cf33 -r 3ca81a86adca usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Wed Aug 25 22:14:38 2021 +0000
+++ b/usr.bin/indent/lexi.c     Wed Aug 25 22:26:30 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lexi.c,v 1.41 2021/03/14 00:22:16 rillig Exp $ */
+/*     $NetBSD: lexi.c,v 1.42 2021/08/25 22:26:30 rillig Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@
 #include <sys/cdefs.h>
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.41 2021/03/14 00:22:16 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.42 2021/08/25 22:26:30 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -377,7 +377,7 @@
            /* ... so maybe a type_t or a typedef */
            if ((opt.auto_typedefs && ((u = strrchr(s_token, '_')) != NULL) &&
                strcmp(u, "_t") == 0) || (typename_top >= 0 &&
-                 bsearch(s_token, typenames, typename_top + 1,
+                 bsearch(s_token, typenames, (size_t)typename_top + 1,
                    sizeof typenames[0], compare_string_array))) {
                state->keyword = rw_type;
                state->last_u_d = true;



Home | Main Index | Thread Index | Old Index