Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint lint: miscellaneous cleanup
details: https://anonhg.NetBSD.org/src/rev/4c7d080b92b8
branches: trunk
changeset: 377373:4c7d080b92b8
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jul 09 12:15:07 2023 +0000
description:
lint: miscellaneous cleanup
diffstat:
usr.bin/xlint/common/emit.c | 15 +++++++--------
usr.bin/xlint/lint1/decl.c | 7 ++++---
usr.bin/xlint/lint1/func.c | 9 ++++-----
usr.bin/xlint/lint1/lex.c | 11 ++++++-----
usr.bin/xlint/lint1/lint1.h | 4 ++--
usr.bin/xlint/lint1/mem1.c | 6 +++---
6 files changed, 26 insertions(+), 26 deletions(-)
diffs (196 lines):
diff -r ecbef9459dfd -r 4c7d080b92b8 usr.bin/xlint/common/emit.c
--- a/usr.bin/xlint/common/emit.c Sun Jul 09 12:04:08 2023 +0000
+++ b/usr.bin/xlint/common/emit.c Sun Jul 09 12:15:07 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: emit.c,v 1.19 2023/06/09 13:03:49 rillig Exp $ */
+/* $NetBSD: emit.c,v 1.20 2023/07/09 12:15:07 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: emit.c,v 1.19 2023/06/09 13:03:49 rillig Exp $");
+__RCSID("$NetBSD: emit.c,v 1.20 2023/07/09 12:15:07 rillig Exp $");
#endif
#include <stdio.h>
@@ -91,12 +91,12 @@ outclose(void)
static void
outxbuf(void)
{
- ptrdiff_t coffs;
- coffs = ob.o_next - ob.o_buf;
+ size_t next = (size_t)(ob.o_next - ob.o_buf);
ob.o_len *= 2;
- ob.o_end = (ob.o_buf = xrealloc(ob.o_buf, ob.o_len)) + ob.o_len;
- ob.o_next = ob.o_buf + coffs;
+ ob.o_buf = xrealloc(ob.o_buf, ob.o_len);
+ ob.o_end = ob.o_buf + ob.o_len;
+ ob.o_next = ob.o_buf + next;
}
/*
@@ -106,11 +106,10 @@ outxbuf(void)
void
outclr(void)
{
- size_t sz;
if (ob.o_buf != ob.o_next) {
outchar('\n');
- sz = ob.o_next - ob.o_buf;
+ size_t sz = (size_t)(ob.o_next - ob.o_buf);
if (sz > ob.o_len)
errx(1, "internal error: outclr");
if (fwrite(ob.o_buf, sz, 1, lout) != 1)
diff -r ecbef9459dfd -r 4c7d080b92b8 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c Sun Jul 09 12:04:08 2023 +0000
+++ b/usr.bin/xlint/lint1/decl.c Sun Jul 09 12:15:07 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.347 2023/07/09 11:18:55 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.348 2023/07/09 12:15:07 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: decl.c,v 1.347 2023/07/09 11:18:55 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.348 2023/07/09 12:15:07 rillig Exp $");
#endif
#include <sys/param.h>
@@ -130,6 +130,7 @@ type_t *
gettyp(tspec_t t)
{
+ lint_assert((int)t < (int)STRUCT);
/* TODO: make the return type 'const' */
return &typetab[t];
}
@@ -584,7 +585,7 @@ end_declaration_level(void)
symtab_remove_level(dl->d_first_dlsym);
break;
case DLK_EXTERN:
- /* there is nothing around an external declarations */
+ /* there is nothing around an external declaration */
/* FALLTHROUGH */
default:
lint_assert(/*CONSTCOND*/false);
diff -r ecbef9459dfd -r 4c7d080b92b8 usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c Sun Jul 09 12:04:08 2023 +0000
+++ b/usr.bin/xlint/lint1/func.c Sun Jul 09 12:15:07 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: func.c,v 1.166 2023/07/09 11:01:27 rillig Exp $ */
+/* $NetBSD: func.c,v 1.167 2023/07/09 12:15:07 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: func.c,v 1.166 2023/07/09 11:01:27 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.167 2023/07/09 12:15:07 rillig Exp $");
#endif
#include <stdlib.h>
@@ -447,15 +447,14 @@ named_label(sym_t *sym)
static void
check_case_label_bitand(const tnode_t *case_expr, const tnode_t *switch_expr)
{
- uint64_t case_value, mask;
if (switch_expr->tn_op != BITAND ||
switch_expr->tn_right->tn_op != CON)
return;
lint_assert(case_expr->tn_op == CON);
- case_value = case_expr->tn_val.u.integer;
- mask = switch_expr->tn_right->tn_val.u.integer;
+ uint64_t case_value = (uint64_t)case_expr->tn_val.u.integer;
+ uint64_t mask = (uint64_t)switch_expr->tn_right->tn_val.u.integer;
if ((case_value & ~mask) != 0) {
/* statement not reached */
diff -r ecbef9459dfd -r 4c7d080b92b8 usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Sun Jul 09 12:04:08 2023 +0000
+++ b/usr.bin/xlint/lint1/lex.c Sun Jul 09 12:15:07 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.171 2023/07/09 11:18:55 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.172 2023/07/09 12:15:07 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: lex.c,v 1.171 2023/07/09 11:18:55 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.172 2023/07/09 12:15:07 rillig Exp $");
#endif
#include <ctype.h>
@@ -615,9 +615,10 @@ convert_integer(int64_t si, tspec_t t, u
len = size_in_bits(t);
uint64_t vbits = value_bits(len);
- return t == PTR || is_uinteger(t) || ((si & bit(len - 1)) == 0)
- ? (int64_t)(si & vbits)
- : (int64_t)(si | ~vbits);
+ uint64_t ui = (uint64_t)si;
+ return t == PTR || is_uinteger(t) || ((ui & bit(len - 1)) == 0)
+ ? (int64_t)(ui & vbits)
+ : (int64_t)(ui | ~vbits);
}
int
diff -r ecbef9459dfd -r 4c7d080b92b8 usr.bin/xlint/lint1/lint1.h
--- a/usr.bin/xlint/lint1/lint1.h Sun Jul 09 12:04:08 2023 +0000
+++ b/usr.bin/xlint/lint1/lint1.h Sun Jul 09 12:15:07 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.181 2023/07/03 07:19:57 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.182 2023/07/09 12:15:07 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -574,7 +574,7 @@ bit(unsigned i)
static inline bool
msb(int64_t si, tspec_t t)
{
- return (si & bit(size_in_bits(t) - 1)) != 0;
+ return ((uint64_t)si & bit(size_in_bits(t) - 1)) != 0;
}
static inline uint64_t
diff -r ecbef9459dfd -r 4c7d080b92b8 usr.bin/xlint/lint1/mem1.c
--- a/usr.bin/xlint/lint1/mem1.c Sun Jul 09 12:04:08 2023 +0000
+++ b/usr.bin/xlint/lint1/mem1.c Sun Jul 09 12:15:07 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mem1.c,v 1.66 2023/06/30 12:21:25 rillig Exp $ */
+/* $NetBSD: mem1.c,v 1.67 2023/07/09 12:15:07 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: mem1.c,v 1.66 2023/06/30 12:21:25 rillig Exp $");
+__RCSID("$NetBSD: mem1.c,v 1.67 2023/07/09 12:15:07 rillig Exp $");
#endif
#include <sys/param.h>
@@ -93,7 +93,7 @@ add_directory_replacement(char *arg)
*sep = '\0';
r->orig = arg;
- r->orig_len = sep - arg;
+ r->orig_len = (size_t)(sep - arg);
r->repl = sep + 1;
r->next = filename_replacements;
filename_replacements = r;
Home |
Main Index |
Thread Index |
Old Index