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: fix return type of conaddr
details: https://anonhg.NetBSD.org/src/rev/b70e7b0db872
branches: trunk
changeset: 949819:b70e7b0db872
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jan 17 15:40:27 2021 +0000
description:
lint: fix return type of conaddr
diffstat:
usr.bin/xlint/lint1/externs1.h | 4 ++--
usr.bin/xlint/lint1/init.c | 6 +++---
usr.bin/xlint/lint1/tree.c | 35 +++++++++++++++++------------------
3 files changed, 22 insertions(+), 23 deletions(-)
diffs (143 lines):
diff -r cf9cda5743f9 -r b70e7b0db872 usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h Sun Jan 17 15:31:11 2021 +0000
+++ b/usr.bin/xlint/lint1/externs1.h Sun Jan 17 15:40:27 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: externs1.h,v 1.56 2021/01/16 02:40:02 rillig Exp $ */
+/* $NetBSD: externs1.h,v 1.57 2021/01/17 15:40:27 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -219,7 +219,7 @@
extern void expr(tnode_t *, bool, bool, bool);
extern void check_expr_misc(const tnode_t *, bool, bool, bool,
bool, bool, bool);
-extern int conaddr(tnode_t *, sym_t **, ptrdiff_t *);
+extern bool constant_addr(tnode_t *, sym_t **, ptrdiff_t *);
extern strg_t *cat_strings(strg_t *, strg_t *);
extern int64_t tsize(type_t *);
diff -r cf9cda5743f9 -r b70e7b0db872 usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c Sun Jan 17 15:31:11 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c Sun Jan 17 15:40:27 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.63 2021/01/16 16:53:23 rillig Exp $ */
+/* $NetBSD: init.c,v 1.64 2021/01/17 15:40:27 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.63 2021/01/16 16:53:23 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.64 2021/01/17 15:40:27 rillig Exp $");
#endif
#include <stdlib.h>
@@ -646,7 +646,7 @@
if (tn != NULL && tn->tn_op != CON) {
sym = NULL;
offs = 0;
- if (conaddr(tn, &sym, &offs) == -1) {
+ if (!constant_addr(tn, &sym, &offs)) {
if (sc == AUTO || sc == REG) {
/* non-constant initializer */
c99ism(177);
diff -r cf9cda5743f9 -r b70e7b0db872 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Sun Jan 17 15:31:11 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c Sun Jan 17 15:40:27 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.173 2021/01/17 15:31:11 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.174 2021/01/17 15:40:27 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.173 2021/01/17 15:31:11 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.174 2021/01/17 15:40:27 rillig Exp $");
#endif
#include <float.h>
@@ -4174,8 +4174,7 @@
}
/*
- * Takes an expression an returns 0 if this expression can be used
- * for static initialisation, otherwise -1.
+ * Return whether the expression can be used for static initialisation.
*
* Constant initialisation expressions must be constant or an address
* of a static object with an optional offset. In the first case,
@@ -4186,8 +4185,8 @@
* CON. Type conversions are allowed if they do not change binary
* representation (including width).
*/
-int
-conaddr(tnode_t *tn, sym_t **symp, ptrdiff_t *offsp)
+bool
+constant_addr(tnode_t *tn, sym_t **symp, ptrdiff_t *offsp)
{
sym_t *sym;
ptrdiff_t offs1, offs2;
@@ -4196,24 +4195,24 @@
switch (tn->tn_op) {
case MINUS:
if (tn->tn_right->tn_op == CVT)
- return conaddr(tn->tn_right, symp, offsp);
+ return constant_addr(tn->tn_right, symp, offsp);
else if (tn->tn_right->tn_op != CON)
- return -1;
+ return false;
/* FALLTHROUGH */
case PLUS:
offs1 = offs2 = 0;
if (tn->tn_left->tn_op == CON) {
offs1 = (ptrdiff_t)tn->tn_left->tn_val->v_quad;
- if (conaddr(tn->tn_right, &sym, &offs2) == -1)
- return -1;
+ if (!constant_addr(tn->tn_right, &sym, &offs2))
+ return false;
} else if (tn->tn_right->tn_op == CON) {
offs2 = (ptrdiff_t)tn->tn_right->tn_val->v_quad;
if (tn->tn_op == MINUS)
offs2 = -offs2;
- if (conaddr(tn->tn_left, &sym, &offs1) == -1)
- return -1;
+ if (!constant_addr(tn->tn_left, &sym, &offs1))
+ return false;
} else {
- return -1;
+ return false;
}
*symp = sym;
*offsp = offs1 + offs2;
@@ -4235,7 +4234,7 @@
ot = tn->tn_left->tn_type->t_tspec;
if ((!is_integer(t) && t != PTR) ||
(!is_integer(ot) && ot != PTR)) {
- return -1;
+ return false;
}
#ifdef notdef
/*
@@ -4250,13 +4249,13 @@
else if (psize(t) != psize(ot))
return -1;
#endif
- if (conaddr(tn->tn_left, symp, offsp) == -1)
- return -1;
+ if (!constant_addr(tn->tn_left, symp, offsp))
+ return false;
break;
default:
- return -1;
+ return false;
}
- return 0;
+ return true;
}
/*
Home |
Main Index |
Thread Index |
Old Index