lint: skip alignment computation if possible

Testing a global variable is simpler than calling a 20-line function.

No functional change.
This commit is contained in:
rillig 2021-02-28 00:28:47 +00:00
parent 2659adfbbb
commit f6dafdc19b

View File

@ -1,4 +1,4 @@
/* $NetBSD: tree.c,v 1.220 2021/02/28 00:23:55 rillig Exp $ */
/* $NetBSD: tree.c,v 1.221 2021/02/28 00:28:47 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.220 2021/02/28 00:23:55 rillig Exp $");
__RCSID("$NetBSD: tree.c,v 1.221 2021/02/28 00:28:47 rillig Exp $");
#endif
#include <float.h>
@ -2243,12 +2243,12 @@ check_pointer_conversion(op_t op, tnode_t *tn, type_t *tp)
return;
}
if (alignment_in_bits(tp->t_subt) >
alignment_in_bits(tn->tn_type->t_subt)) {
if (hflag)
/* possible pointer alignment problem */
warning(135);
if (hflag && alignment_in_bits(tp->t_subt) >
alignment_in_bits(tn->tn_type->t_subt)) {
/* possible pointer alignment problem */
warning(135);
}
if (((nt == STRUCT || nt == UNION) &&
tp->t_subt->t_str != tn->tn_type->t_subt->t_str) ||
psize(nt) != psize(ot)) {