Module Name:    src
Committed By:   rillig
Date:           Sat Mar 20 20:56:58 UTC 2021

Modified Files:
        src/usr.bin/xlint/lint1: op.h oper.c print.c tree.c

Log Message:
lint: move getopname over to tree.c

Except for the one use in print_tnode, the name of the operator is only
used in tree.c.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/xlint/lint1/op.h
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/xlint/lint1/oper.c
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/xlint/lint1/print.c
cvs rdiff -u -r1.240 -r1.241 src/usr.bin/xlint/lint1/tree.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/lint1/op.h
diff -u src/usr.bin/xlint/lint1/op.h:1.15 src/usr.bin/xlint/lint1/op.h:1.16
--- src/usr.bin/xlint/lint1/op.h:1.15	Sat Mar 20 20:39:35 2021
+++ src/usr.bin/xlint/lint1/op.h	Sat Mar 20 20:56:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: op.h,v 1.15 2021/03/20 20:39:35 rillig Exp $	*/
+/*	$NetBSD: op.h,v 1.16 2021/03/20 20:56:58 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -72,5 +72,3 @@ extern const mod_t modtab[];
 	name,
 #define end_ops() } op_t;
 #include "ops.def"
-
-const char *getopname(op_t);

Index: src/usr.bin/xlint/lint1/oper.c
diff -u src/usr.bin/xlint/lint1/oper.c:1.8 src/usr.bin/xlint/lint1/oper.c:1.9
--- src/usr.bin/xlint/lint1/oper.c:1.8	Sat Mar 20 20:39:35 2021
+++ src/usr.bin/xlint/lint1/oper.c	Sat Mar 20 20:56:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: oper.c,v 1.8 2021/03/20 20:39:35 rillig Exp $	*/
+/*	$NetBSD: oper.c,v 1.9 2021/03/20 20:56:58 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -51,9 +51,3 @@ const mod_t modtab[NOPS] =
 	},
 #define end_ops(n) };
 #include "ops.def"
-
-const char *
-getopname(op_t op)
-{
-	return modtab[op].m_name;
-}

Index: src/usr.bin/xlint/lint1/print.c
diff -u src/usr.bin/xlint/lint1/print.c:1.10 src/usr.bin/xlint/lint1/print.c:1.11
--- src/usr.bin/xlint/lint1/print.c:1.10	Tue Jan  5 23:20:53 2021
+++ src/usr.bin/xlint/lint1/print.c	Sat Mar 20 20:56:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.10 2021/01/05 23:20:53 rillig Exp $	*/
+/*	$NetBSD: print.c,v 1.11 2021/03/20 20:56:58 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: print.c,v 1.10 2021/01/05 23:20:53 rillig Exp $");
+__RCSID("$NetBSD: print.c,v 1.11 2021/03/20 20:56:58 rillig Exp $");
 #endif
 
 #include <stdio.h>
@@ -82,7 +82,7 @@ print_tnode(char *buf, size_t bufsiz, co
 		}
 		break;
 	default:
-		(void)snprintf(buf, bufsiz, "%s", getopname(tn->tn_op));
+		(void)snprintf(buf, bufsiz, "%s", modtab[tn->tn_op].m_name);
 		break;
 	}
 	return buf;

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.240 src/usr.bin/xlint/lint1/tree.c:1.241
--- src/usr.bin/xlint/lint1/tree.c:1.240	Sat Mar 20 20:39:35 2021
+++ src/usr.bin/xlint/lint1/tree.c	Sat Mar 20 20:56:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.240 2021/03/20 20:39:35 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.241 2021/03/20 20:56:58 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.240 2021/03/20 20:39:35 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.241 2021/03/20 20:56:58 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -97,6 +97,12 @@ static	void	check_precedence_confusion(t
 
 extern sig_atomic_t fpe;
 
+static const char *
+getopname(op_t op)
+{
+	return modtab[op].m_name;
+}
+
 #ifdef DEBUG
 void
 debug_node(const tnode_t *tn, int indent)
@@ -472,7 +478,7 @@ struct_or_union_member(tnode_t *tn, op_t
 			error(105, op == POINT ? "object" : "pointer");
 		} else {
 			/* unacceptable operand of '%s' */
-			error(111, modtab[op].m_name);
+			error(111, getopname(op));
 		}
 	}
 
@@ -1781,7 +1787,7 @@ check_enum_int_mismatch(op_t op, int arg
 	default:
 		/* combination of '%s' and '%s', op %s */
 		warning(242, type_name(ln->tn_type), type_name(rn->tn_type),
-		    modtab[op].m_name);
+		    getopname(op));
 		break;
 	}
 }
@@ -2414,7 +2420,7 @@ convert_constant(op_t op, int arg, type_
 			 */
 			if (nsz < osz && (v->v_quad & xmask) != 0) {
 				/* constant truncated by conv., op %s */
-				warning(306, modtab[op].m_name);
+				warning(306, getopname(op));
 			}
 		} else if (op == ANDASS || op == BITAND) {
 			/*
@@ -2427,12 +2433,12 @@ convert_constant(op_t op, int arg, type_
 			    (nv->v_quad & xmask) != xmask) {
 				/* extra bits set to 0 in conv. of '%s' ... */
 				warning(309, type_name(gettyp(ot)),
-				    type_name(tp), modtab[op].m_name);
+				    type_name(tp), getopname(op));
 			} else if (nsz < osz &&
 				   (v->v_quad & xmask) != xmask &&
 				   (v->v_quad & xmask) != 0) {
 				/* constant truncated by conv., op %s */
-				warning(306, modtab[op].m_name);
+				warning(306, getopname(op));
 			}
 		} else if ((nt != PTR && is_uinteger(nt)) &&
 			   (ot != PTR && !is_uinteger(ot)) &&
@@ -2930,7 +2936,7 @@ build_assignment(op_t op, tnode_t *ln, t
 				error(212);
 			} else {
 				/* unknown operand size, op %s */
-				error(138, modtab[op].m_name);
+				error(138, getopname(op));
 			}
 			return NULL;
 		}

Reply via email to