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: flatten check_pointer_integer_conv...



details:   https://anonhg.NetBSD.org/src/rev/efcfd2aeafd8
branches:  trunk
changeset: 958704:efcfd2aeafd8
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jan 17 14:26:31 2021 +0000

description:
lint: flatten check_pointer_integer_conversion

diffstat:

 usr.bin/xlint/lint1/tree.c |  29 +++++++++++++----------------
 1 files changed, 13 insertions(+), 16 deletions(-)

diffs (58 lines):

diff -r 4240102a19ba -r efcfd2aeafd8 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Sun Jan 17 13:50:32 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Sun Jan 17 14:26:31 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.165 2021/01/17 13:50:32 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.166 2021/01/17 14:26:31 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.165 2021/01/17 13:50:32 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.166 2021/01/17 14:26:31 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -2150,20 +2150,17 @@
 
        if (tn->tn_op == CON)
                return;
-
-       if (op != CVT) {
-               /* We got already an error. */
+       if (op != CVT)
+               return;         /* We got already an error. */
+       if (psize(nt) >= psize(PTR))
                return;
-       }
-
-       if (psize(nt) < psize(PTR)) {
-               if (pflag && size(nt) >= size(PTR)) {
-                       /* conversion of pointer to '%s' may lose bits */
-                       warning(134, type_name(tp));
-               } else {
-                       /* conversion of pointer to '%s' loses bits */
-                       warning(133, type_name(tp));
-               }
+
+       if (pflag && size(nt) >= size(PTR)) {
+               /* conversion of pointer to '%s' may lose bits */
+               warning(134, type_name(tp));
+       } else {
+               /* conversion of pointer to '%s' loses bits */
+               warning(133, type_name(tp));
        }
 }
 
@@ -2219,7 +2216,7 @@
 }
 
 /*
- * Converts a typed constant in a constant of another type.
+ * Converts a typed constant to a constant of another type.
  *
  * op          operator which requires conversion
  * arg         if op is FARG, # of argument



Home | Main Index | Thread Index | Old Index