Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 lint: use unsigned integers for size cal...
details: https://anonhg.NetBSD.org/src/rev/64c2ac901a34
branches: trunk
changeset: 1023353:64c2ac901a34
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Sep 04 13:27:59 2021 +0000
description:
lint: use unsigned integers for size calculations
No change for type definitions that are smaller than 128 MB. For larger
types, integer overflow might occur, just like before.
diffstat:
usr.bin/xlint/lint1/decl.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diffs (45 lines):
diff -r 200918f15e2f -r 64c2ac901a34 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c Sat Sep 04 12:54:19 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c Sat Sep 04 13:27:59 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.231 2021/09/04 12:37:46 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.232 2021/09/04 13:27:59 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.231 2021/09/04 12:37:46 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.232 2021/09/04 13:27:59 rillig Exp $");
#endif
#include <sys/param.h>
@@ -913,7 +913,7 @@
int
length(const type_t *tp, const char *name)
{
- int elem, elsz;
+ unsigned int elem, elsz;
elem = 1;
while (tp != NULL && tp->t_tspec == ARRAY) {
@@ -948,7 +948,7 @@
INTERNAL_ERROR("length(%d)", elsz);
break;
}
- return elem * elsz;
+ return (int)(elem * elsz);
}
unsigned int
@@ -1136,7 +1136,7 @@
if (!(bitfieldtype_ok || gflag) || !is_integer(t)) {
/* illegal bit-field type '%s' */
warning(35, type_name(tp));
- int sz = tp->t_flen;
+ unsigned int sz = tp->t_flen;
dsym->s_type = tp = dup_type(gettyp(t = INT));
if ((tp->t_flen = sz) > size_in_bits(t))
tp->t_flen = size_in_bits(t);
Home |
Main Index |
Thread Index |
Old Index