From 70f9d5c54ddd86ea4ce0cb3ee6a3156dcca60161 Mon Sep 17 00:00:00 2001 From: rillig Date: Sat, 9 Mar 2024 10:47:16 +0000 Subject: [PATCH] lint: remove unneeded checks for left and right operands --- usr.bin/xlint/lint1/cksnprintb.c | 6 +++--- usr.bin/xlint/lint1/lint1.h | 16 +--------------- usr.bin/xlint/lint1/tree.c | 6 +++--- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/usr.bin/xlint/lint1/cksnprintb.c b/usr.bin/xlint/lint1/cksnprintb.c index 955e16073715..ec1ef7cb6e38 100644 --- a/usr.bin/xlint/lint1/cksnprintb.c +++ b/usr.bin/xlint/lint1/cksnprintb.c @@ -1,4 +1,4 @@ -/* $NetBSD: cksnprintb.c,v 1.7 2024/03/03 16:09:01 rillig Exp $ */ +/* $NetBSD: cksnprintb.c,v 1.8 2024/03/09 10:47:16 rillig Exp $ */ /*- * Copyright (c) 2024 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: cksnprintb.c,v 1.7 2024/03/03 16:09:01 rillig Exp $"); +__RCSID("$NetBSD: cksnprintb.c,v 1.8 2024/03/09 10:47:16 rillig Exp $"); #endif #include @@ -59,7 +59,7 @@ static bool match_string_literal(const tnode_t *tn, const buffer **str) { while (tn->tn_op == CVT) - tn = tn_ck_left(tn); + tn = tn->tn_left; return tn->tn_op == ADDR && tn->tn_left->tn_op == STRING && (*str = tn->tn_left->tn_string, (*str)->data != NULL); diff --git a/usr.bin/xlint/lint1/lint1.h b/usr.bin/xlint/lint1/lint1.h index 5c9552cbb4a7..5610cb6bce45 100644 --- a/usr.bin/xlint/lint1/lint1.h +++ b/usr.bin/xlint/lint1/lint1.h @@ -1,4 +1,4 @@ -/* $NetBSD: lint1.h,v 1.216 2024/03/09 10:41:11 rillig Exp $ */ +/* $NetBSD: lint1.h,v 1.217 2024/03/09 10:47:16 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -555,20 +555,6 @@ typedef struct { assert_failed(__FILE__, __LINE__, __func__, #cond); \ } while (false) -static inline tnode_t * -tn_ck_left(const tnode_t *tn) -{ - lint_assert(has_operands(tn)); - return tn->tn_left; -} - -static inline tnode_t * -tn_ck_right(const tnode_t *tn) -{ - lint_assert(has_operands(tn)); - return tn->tn_right; -} - #ifdef DEBUG # include "err-msgs.h" diff --git a/usr.bin/xlint/lint1/tree.c b/usr.bin/xlint/lint1/tree.c index b40996aa96ed..2ddf153e5360 100644 --- a/usr.bin/xlint/lint1/tree.c +++ b/usr.bin/xlint/lint1/tree.c @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.609 2024/03/03 16:09:01 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.610 2024/03/09 10:47:16 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: tree.c,v 1.609 2024/03/03 16:09:01 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.610 2024/03/09 10:47:16 rillig Exp $"); #endif #include @@ -1236,7 +1236,7 @@ build_colon(bool sys, tnode_t *ln, tnode_t *rn) static bool is_cast_redundant(const tnode_t *tn) { - const type_t *ntp = tn->tn_type, *otp = tn_ck_left(tn)->tn_type; + const type_t *ntp = tn->tn_type, *otp = tn->tn_left->tn_type; tspec_t nt = ntp->t_tspec, ot = otp->t_tspec; if (nt == BOOL || ot == BOOL)