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: raise WARNS from the default 5 up to 6



details:   https://anonhg.NetBSD.org/src/rev/35323eac3dac
branches:  trunk
changeset: 1024012:35323eac3dac
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Oct 07 18:32:09 2021 +0000

description:
indent: raise WARNS from the default 5 up to 6

diffstat:

 usr.bin/indent/Makefile |   3 ++-
 usr.bin/indent/args.c   |   6 +++---
 usr.bin/indent/indent.c |  28 +++++++++++++++++-----------
 usr.bin/indent/io.c     |  12 ++++++------
 usr.bin/indent/lexi.c   |   8 ++++----
 5 files changed, 32 insertions(+), 25 deletions(-)

diffs (220 lines):

diff -r a0dba3f8811e -r 35323eac3dac usr.bin/indent/Makefile
--- a/usr.bin/indent/Makefile   Thu Oct 07 18:19:07 2021 +0000
+++ b/usr.bin/indent/Makefile   Thu Oct 07 18:32:09 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.13 2021/09/25 17:11:23 rillig Exp $
+#      $NetBSD: Makefile,v 1.14 2021/10/07 18:32:09 rillig Exp $
 #      from: @(#)Makefile      8.1 (Berkeley) 6/6/93
 
 PROG=  indent
@@ -6,5 +6,6 @@
 
 CPPFLAGS+=     ${DEBUG:D-Ddebug}
 LINTFLAGS+=    -e -w -T
+WARNS=         6
 
 .include <bsd.prog.mk>
diff -r a0dba3f8811e -r 35323eac3dac usr.bin/indent/args.c
--- a/usr.bin/indent/args.c     Thu Oct 07 18:19:07 2021 +0000
+++ b/usr.bin/indent/args.c     Thu Oct 07 18:32:09 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: args.c,v 1.47 2021/10/07 18:07:25 rillig Exp $ */
+/*     $NetBSD: args.c,v 1.48 2021/10/07 18:32:09 rillig Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: args.c,v 1.47 2021/10/07 18:07:25 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.48 2021/10/07 18:32:09 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/args.c 336318 2018-07-15 21:04:21Z pstef $");
 #endif
@@ -228,7 +228,7 @@
        arg_end = arg + 3;
        if (arg_end[0] == '\0')
            goto need_param;
-       opt.case_indent = atof(arg_end);
+       opt.case_indent = (float)atof(arg_end);
        return true;
     }
 
diff -r a0dba3f8811e -r 35323eac3dac usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Thu Oct 07 18:19:07 2021 +0000
+++ b/usr.bin/indent/indent.c   Thu Oct 07 18:32:09 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.109 2021/10/07 18:19:07 rillig Exp $      */
+/*     $NetBSD: indent.c,v 1.110 2021/10/07 18:32:09 rillig Exp $      */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.109 2021/10/07 18:19:07 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.110 2021/10/07 18:32:09 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -386,13 +386,19 @@
     buf->l = buf->buf + bufsize - 5;   /* safety margin, though unreliable */
 }
 
+static size_t
+buf_len(const struct buffer *buf)
+{
+    return (size_t)(buf->e - buf->s);
+}
+
 void
 buf_expand(struct buffer *buf, size_t desired_size)
 {
-    size_t nsize = buf->l - buf->s + 400 + desired_size;
-    size_t code_len = buf->e - buf->s;
+    size_t nsize = (size_t)(buf->l - buf->s) + 400 + desired_size;
+    size_t len = buf_len(buf);
     buf->buf = xrealloc(buf->buf, nsize);
-    buf->e = buf->buf + code_len + 1;
+    buf->e = buf->buf + len + 1;
     buf->l = buf->buf + nsize - 5;
     buf->s = buf->buf + 1;
 }
@@ -560,7 +566,7 @@
                                 * '}' */
     if (com.s != com.e) {      /* the turkey has embedded a comment in a
                                 * line. fix it */
-       size_t len = com.e - com.s;
+       size_t len = buf_len(&com);
 
        check_size_code(len + 3);
        *code.e++ = ' ';
@@ -701,7 +707,7 @@
        *code.e++ = ' ';
 
     {
-       size_t len = token.e - token.s;
+       size_t len = buf_len(&token);
 
        check_size_code(len);
        memcpy(code.e, token.s, len);
@@ -713,7 +719,7 @@
 static void
 process_binary_op(void)
 {
-    size_t len = token.e - token.s;
+    size_t len = buf_len(&token);
 
     check_size_code(len + 1);
     if (ps.want_blank)
@@ -766,7 +772,7 @@
      * turn everything so far into a label
      */
     {
-       size_t len = code.e - code.s;
+       size_t len = buf_len(&code);
 
        check_size_label(len + 3);
        memcpy(lab.e, code.s, len);
@@ -1036,7 +1042,7 @@
 static void
 copy_id(void)
 {
-    size_t len = token.e - token.s;
+    size_t len = buf_len(&token);
 
     check_size_code(len + 1);
     if (ps.want_blank)
@@ -1048,7 +1054,7 @@
 static void
 process_string_prefix(void)
 {
-    size_t len = token.e - token.s;
+    size_t len = buf_len(&token);
 
     check_size_code(len + 1);
     if (ps.want_blank)
diff -r a0dba3f8811e -r 35323eac3dac usr.bin/indent/io.c
--- a/usr.bin/indent/io.c       Thu Oct 07 18:19:07 2021 +0000
+++ b/usr.bin/indent/io.c       Thu Oct 07 18:32:09 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: io.c,v 1.73 2021/10/05 21:05:12 rillig Exp $   */
+/*     $NetBSD: io.c,v 1.74 2021/10/07 18:32:09 rillig Exp $   */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.73 2021/10/05 21:05:12 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.74 2021/10/07 18:32:09 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -199,7 +199,7 @@
                         * XXX: this mix of 'indent' and 'column' smells like
                         * an off-by-one error.
                         */
-                       ps.paren_indents[i] = -(ind + target_col);
+                       ps.paren_indents[i] = (short)-(ind + target_col);
                        debug_println(
                            "setting pi[%d] from %d to %d for column %d",
                            i, ind, ps.paren_indents[i], target_col);
@@ -319,7 +319,7 @@
 compute_label_indent(void)
 {
     if (ps.pcase)
-       return (int)(case_ind * opt.indent_size);
+       return (int)(case_ind * (float)opt.indent_size);
     if (lab.s[0] == '#')
        return 0;
     return opt.indent_size * (ps.ind_level - label_offset);
@@ -406,8 +406,8 @@
     }
     for (p = in_buffer;;) {
        if (p >= in_buffer_limit) {
-           size_t size = (in_buffer_limit - in_buffer) * 2 + 10;
-           size_t offset = p - in_buffer;
+           size_t size = (size_t)(in_buffer_limit - in_buffer) * 2 + 10;
+           size_t offset = (size_t)(p - in_buffer);
            in_buffer = xrealloc(in_buffer, size);
            p = in_buffer + offset;
            in_buffer_limit = in_buffer + size - 2;
diff -r a0dba3f8811e -r 35323eac3dac usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Thu Oct 07 18:19:07 2021 +0000
+++ b/usr.bin/indent/lexi.c     Thu Oct 07 18:32:09 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lexi.c,v 1.72 2021/10/05 22:22:46 rillig Exp $ */
+/*     $NetBSD: lexi.c,v 1.73 2021/10/07 18:32:09 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.72 2021/10/05 22:22:46 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.73 2021/10/07 18:32:09 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -129,7 +129,7 @@
  * HP H+ "."    P  FS  -> $float;    BP B+           IS? -> $int;
  */
 /* INDENT OFF */
-static const char num_lex_state[][26] = {
+static const unsigned char num_lex_state[][26] = {
     /*                examples:
                                      00
              s                      0xx
@@ -706,6 +706,6 @@
        return;                 /* already in the list */
     pos = -(pos + 1);
     memmove(typenames.items + pos + 1, typenames.items + pos,
-       sizeof(typenames.items[0]) * (typenames.len++ - pos));
+       sizeof(typenames.items[0]) * (typenames.len++ - (unsigned)pos));
     typenames.items[pos] = xstrdup(name);
 }



Home | Main Index | Thread Index | Old Index