Module Name: src Committed By: rillig Date: Thu Oct 7 18:32:09 UTC 2021
Modified Files: src/usr.bin/indent: Makefile args.c indent.c io.c lexi.c Log Message: indent: raise WARNS from the default 5 up to 6 To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/usr.bin/indent/Makefile cvs rdiff -u -r1.47 -r1.48 src/usr.bin/indent/args.c cvs rdiff -u -r1.109 -r1.110 src/usr.bin/indent/indent.c cvs rdiff -u -r1.73 -r1.74 src/usr.bin/indent/io.c cvs rdiff -u -r1.72 -r1.73 src/usr.bin/indent/lexi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/indent/Makefile diff -u src/usr.bin/indent/Makefile:1.13 src/usr.bin/indent/Makefile:1.14 --- src/usr.bin/indent/Makefile:1.13 Sat Sep 25 17:11:23 2021 +++ src/usr.bin/indent/Makefile Thu Oct 7 18:32:09 2021 @@ -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 @@ SRCS= indent.c io.c lexi.c parse.c pr_co CPPFLAGS+= ${DEBUG:D-Ddebug} LINTFLAGS+= -e -w -T +WARNS= 6 .include <bsd.prog.mk> Index: src/usr.bin/indent/args.c diff -u src/usr.bin/indent/args.c:1.47 src/usr.bin/indent/args.c:1.48 --- src/usr.bin/indent/args.c:1.47 Thu Oct 7 18:07:25 2021 +++ src/usr.bin/indent/args.c Thu Oct 7 18:32:09 2021 @@ -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 @@ static char sccsid[] = "@(#)args.c 8.1 ( #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 @@ set_special_option(const char *arg) 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; } Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.109 src/usr.bin/indent/indent.c:1.110 --- src/usr.bin/indent/indent.c:1.109 Thu Oct 7 18:19:07 2021 +++ src/usr.bin/indent/indent.c Thu Oct 7 18:32:09 2021 @@ -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 @@ static char sccsid[] = "@(#)indent.c 5.1 #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_init(struct buffer *buf) 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 @@ process_comment_in_code(token_type ttype * '}' */ 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 @@ process_unary_op(int decl_ind, bool tabs *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 @@ process_unary_op(int decl_ind, bool tabs 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 @@ process_colon(int *seen_quest, bool *for * 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 @@ process_ident(token_type ttype, int decl 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 @@ copy_id(void) 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) Index: src/usr.bin/indent/io.c diff -u src/usr.bin/indent/io.c:1.73 src/usr.bin/indent/io.c:1.74 --- src/usr.bin/indent/io.c:1.73 Tue Oct 5 21:05:12 2021 +++ src/usr.bin/indent/io.c Thu Oct 7 18:32:09 2021 @@ -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 @@ static char sccsid[] = "@(#)io.c 8.1 (Be #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 @@ dump_line(void) * 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 @@ int 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 @@ fill_buffer(void) } 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; Index: src/usr.bin/indent/lexi.c diff -u src/usr.bin/indent/lexi.c:1.72 src/usr.bin/indent/lexi.c:1.73 --- src/usr.bin/indent/lexi.c:1.72 Tue Oct 5 22:22:46 2021 +++ src/usr.bin/indent/lexi.c Thu Oct 7 18:32:09 2021 @@ -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 @@ static char sccsid[] = "@(#)lexi.c 8.1 ( #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 @@ struct { * 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 @@ add_typename(const char *name) 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); }