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
details: https://anonhg.NetBSD.org/src/rev/8b954a2dcf76
branches: trunk
changeset: 1019541:8b954a2dcf76
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Mar 14 00:22:16 2021 +0000
description:
indent: fix lint warnings
No functional change.
diffstat:
usr.bin/indent/Makefile | 7 +++++--
usr.bin/indent/args.c | 9 +++++----
usr.bin/indent/indent.c | 39 ++++++++++++++++++++-------------------
usr.bin/indent/io.c | 8 ++++----
usr.bin/indent/lexi.c | 6 +++---
usr.bin/indent/pr_comment.c | 6 +++---
6 files changed, 40 insertions(+), 35 deletions(-)
diffs (truncated from 308 to 300 lines):
diff -r 615ba2dfc16b -r 8b954a2dcf76 usr.bin/indent/Makefile
--- a/usr.bin/indent/Makefile Sat Mar 13 23:42:23 2021 +0000
+++ b/usr.bin/indent/Makefile Sun Mar 14 00:22:16 2021 +0000
@@ -1,10 +1,13 @@
-# $NetBSD: Makefile,v 1.10 2021/03/12 19:11:29 rillig Exp $
+# $NetBSD: Makefile,v 1.11 2021/03/14 00:22:16 rillig Exp $
# from: @(#)Makefile 8.1 (Berkeley) 6/6/93
PROG= indent
SRCS= indent.c io.c lexi.c parse.c pr_comment.c args.c
CPPFLAGS+= ${DEBUG:D-Ddebug}
-LINTFLAGS+= -e
+LINTFLAGS+= -e -w
+
+# bug in lint; see tests/usr.bin/lint/lint1/msg_168.c
+LINTFLAGS.lexi.c+= -X 168
.include <bsd.prog.mk>
diff -r 615ba2dfc16b -r 8b954a2dcf76 usr.bin/indent/args.c
--- a/usr.bin/indent/args.c Sat Mar 13 23:42:23 2021 +0000
+++ b/usr.bin/indent/args.c Sun Mar 14 00:22:16 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: args.c,v 1.21 2021/03/13 13:51:08 rillig Exp $ */
+/* $NetBSD: args.c,v 1.22 2021/03/14 00:22:16 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@
#include <sys/cdefs.h>
#ifndef lint
#if defined(__NetBSD__)
-__RCSID("$NetBSD: args.c,v 1.21 2021/03/13 13:51:08 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.22 2021/03/14 00:22:16 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/args.c 336318 2018-07-15 21:04:21Z pstef $");
#endif
@@ -212,12 +212,12 @@
char *p;
char buf[BUFSIZ];
- while (1) {
+ for (;;) {
p = buf;
comment_index = 0;
while ((i = getc(f)) != EOF) {
if (i == '*' && !comment_index && p > buf && p[-1] == '/') {
- comment_index = p - buf;
+ comment_index = (int)(p - buf);
*p++ = i;
} else if (i == '/' && comment_index && p > buf && p[-1] == '*') {
p = buf + comment_index - 1;
@@ -314,6 +314,7 @@
case VERSION:
printf("FreeBSD indent %s\n", INDENT_VERSION);
exit(0);
+ /*NOTREACHED*/
default:
errx(1, "set_option: internal error: p_special %d", p->p_special);
diff -r 615ba2dfc16b -r 8b954a2dcf76 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c Sat Mar 13 23:42:23 2021 +0000
+++ b/usr.bin/indent/indent.c Sun Mar 14 00:22:16 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.58 2021/03/13 18:46:39 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.59 2021/03/14 00:22:16 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.58 2021/03/13 18:46:39 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.59 2021/03/14 00:22:16 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
#endif
@@ -206,6 +206,7 @@
* done earlier.
*/
*inout_force_nl = false;
+ break;
case form_feed:
break;
case comment:
@@ -215,7 +216,7 @@
* process_comment() will use that to calculate original
* indentation of a boxed comment.
*/
- memcpy(sc_buf, in_buffer, buf_ptr - in_buffer - 4);
+ memcpy(sc_buf, in_buffer, (size_t)(buf_ptr - in_buffer) - 4);
save_com = sc_buf + (buf_ptr - in_buffer - 4);
save_com[0] = save_com[1] = ' ';
sc_end = &save_com[2];
@@ -532,7 +533,7 @@
char *p = buf_ptr;
int col = 1;
- while (1) {
+ for (;;) {
if (*p == ' ')
col++;
else if (*p == '\t')
@@ -585,7 +586,7 @@
* '}' */
if (s_com != e_com) { /* the turkey has embedded a comment
* in a line. fix it */
- int len = e_com - s_com;
+ size_t len = e_com - s_com;
check_size_code(len + 3);
*e_code++ = ' ';
@@ -724,7 +725,7 @@
*e_code++ = ' ';
{
- int len = e_token - s_token;
+ size_t len = e_token - s_token;
check_size_code(len);
memcpy(e_code, token, len);
@@ -736,7 +737,7 @@
static void
process_binary_op(void)
{
- int len = e_token - s_token;
+ size_t len = e_token - s_token;
check_size_code(len + 1);
if (ps.want_blank)
@@ -789,7 +790,7 @@
* turn everything so far into a label
*/
{
- int len = e_code - s_code;
+ size_t len = e_code - s_code;
check_size_label(len + 3);
memcpy(e_lab, s_code, len);
@@ -1066,7 +1067,7 @@
static void
copy_id(void)
{
- int len = e_token - s_token;
+ size_t len = e_token - s_token;
check_size_code(len + 1);
if (ps.want_blank)
@@ -1078,7 +1079,7 @@
static void
process_string_prefix(void)
{
- int len = e_token - s_token;
+ size_t len = e_token - s_token;
check_size_code(len + 1);
if (ps.want_blank)
@@ -1155,7 +1156,7 @@
if (*buf_ptr == '*' && !in_comment && quote == '\0') {
in_comment = 1;
*e_lab++ = *buf_ptr++;
- com_start = e_lab - s_lab - 2;
+ com_start = (int)(e_lab - s_lab) - 2;
}
break;
case '"':
@@ -1174,7 +1175,7 @@
if (*buf_ptr == '/' && in_comment) {
in_comment = 0;
*e_lab++ = *buf_ptr++;
- com_end = e_lab - s_lab;
+ com_end = (int)(e_lab - s_lab);
}
break;
}
@@ -1294,7 +1295,7 @@
squest = 0;
tabs_to_var = 0;
- while (1) { /* this is the main loop. it will go until we
+ for (;;) { /* this is the main loop. it will go until we
* reach eof */
int comment_buffered = false;
@@ -1384,7 +1385,7 @@
case lbrace: /* got a '{' */
process_lbrace(&force_nl, &sp_sw, hd_type, di_stack,
- nitems(di_stack), &dec_ind);
+ (int)nitems(di_stack), &dec_ind);
break;
case rbrace: /* got a '}' */
@@ -1484,9 +1485,9 @@
static void
bakcopy(void)
{
- int n,
- bakchn;
- char buff[8 * 1024];
+ ssize_t n;
+ int bakchn;
+ char buff[8 * 1024];
const char *p;
/* construct file name .Bfile */
@@ -1502,7 +1503,7 @@
if (bakchn < 0)
err(1, "%s", bakfile);
while ((n = read(fileno(input), buff, sizeof(buff))) > 0)
- if (write(bakchn, buff, n) != n)
+ if (write(bakchn, buff, (size_t)n) != n)
err(1, "%s", bakfile);
if (n < 0)
err(1, "%s", in_name);
@@ -1524,7 +1525,7 @@
static void
indent_declaration(int cur_dec_ind, int tabs_to_var)
{
- int pos = e_code - s_code;
+ int pos = (int)(e_code - s_code);
char *startpos = e_code;
/*
diff -r 615ba2dfc16b -r 8b954a2dcf76 usr.bin/indent/io.c
--- a/usr.bin/indent/io.c Sat Mar 13 23:42:23 2021 +0000
+++ b/usr.bin/indent/io.c Sun Mar 14 00:22:16 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: io.c,v 1.47 2021/03/13 18:46:39 rillig Exp $ */
+/* $NetBSD: io.c,v 1.48 2021/03/14 00:22:16 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@
#include <sys/cdefs.h>
#ifndef lint
#if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.47 2021/03/13 18:46:39 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.48 2021/03/14 00:22:16 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
#endif
@@ -353,8 +353,8 @@
}
for (p = in_buffer;;) {
if (p >= in_buffer_limit) {
- int size = (in_buffer_limit - in_buffer) * 2 + 10;
- int offset = p - in_buffer;
+ size_t size = (in_buffer_limit - in_buffer) * 2 + 10;
+ size_t offset = p - in_buffer;
in_buffer = realloc(in_buffer, size);
if (in_buffer == NULL)
errx(1, "input line too long");
diff -r 615ba2dfc16b -r 8b954a2dcf76 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c Sat Mar 13 23:42:23 2021 +0000
+++ b/usr.bin/indent/lexi.c Sun Mar 14 00:22:16 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lexi.c,v 1.40 2021/03/13 11:27:01 rillig Exp $ */
+/* $NetBSD: lexi.c,v 1.41 2021/03/14 00:22:16 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.40 2021/03/13 11:27:01 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.41 2021/03/14 00:22:16 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
#endif
@@ -481,7 +481,7 @@
case '"': /* start of string */
qchar = *token;
do { /* copy the string */
- while (1) { /* move one character or [/<char>]<char> */
+ for (;;) { /* move one character or [/<char>]<char> */
if (*buf_ptr == '\n') {
diag(1, "Unterminated literal");
goto stop_lit;
diff -r 615ba2dfc16b -r 8b954a2dcf76 usr.bin/indent/pr_comment.c
--- a/usr.bin/indent/pr_comment.c Sat Mar 13 23:42:23 2021 +0000
+++ b/usr.bin/indent/pr_comment.c Sun Mar 14 00:22:16 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pr_comment.c,v 1.30 2021/03/13 18:11:31 rillig Exp $ */
+/* $NetBSD: pr_comment.c,v 1.31 2021/03/14 00:22:16 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@
#include <sys/cdefs.h>
#ifndef lint
#if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.30 2021/03/13 18:11:31 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.31 2021/03/14 00:22:16 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
#endif
@@ -222,7 +222,7 @@
Home |
Main Index |
Thread Index |
Old Index