Module Name:    src
Committed By:   rillig
Date:           Mon Dec 28 22:31:32 UTC 2020

Modified Files:
        src/usr.bin/xlint/lint1: decl.c externs1.h init.c

Log Message:
lint: rename confusing function setcompl

The previous function name suggested that it would set the complete flag
of the type, but it was the exact opposite.  To reduce confusion, negate
the meaning of the parameter.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/xlint/lint1/init.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/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.73 src/usr.bin/xlint/lint1/decl.c:1.74
--- src/usr.bin/xlint/lint1/decl.c:1.73	Mon Dec 28 21:24:55 2020
+++ src/usr.bin/xlint/lint1/decl.c	Mon Dec 28 22:31:31 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.73 2020/12/28 21:24:55 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.74 2020/12/28 22:31:31 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.73 2020/12/28 21:24:55 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.74 2020/12/28 22:31:31 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -189,22 +189,21 @@ incompl(type_t *tp)
 }
 
 /*
- * Set the flag for (in)complete array, struct, union or enum
- * types.
+ * Mark an array, struct, union or enum type as complete or incomplete.
  */
 void
-setcompl(type_t *tp, int ic)
+setcomplete(type_t *tp, int complete)
 {
 	tspec_t	t;
 
 	if ((t = tp->t_tspec) == ARRAY) {
-		tp->t_aincompl = ic;
+		tp->t_aincompl = !complete;
 	} else if (t == STRUCT || t == UNION) {
-		tp->t_str->sincompl = ic;
+		tp->t_str->sincompl = !complete;
 	} else {
 		if (t != ENUM)
-			LERROR("setcompl()");
-		tp->t_enum->eincompl = ic;
+			LERROR("setcomplete()");
+		tp->t_enum->eincompl = !complete;
 	}
 }
 
@@ -1357,8 +1356,7 @@ addarray(sym_t *decl, int dim, int n)
 		/* zero array dimension */
 		c99ism(322, dim);
 	} else if (n == 0 && !dim) {
-		/* is incomplete type */
-		setcompl(tp, 1);
+		setcomplete(tp, 0);
 	}
 
 	return (decl);
@@ -1687,8 +1685,7 @@ mktag(sym_t *tag, tspec_t kind, int decl
 			tp->t_enum = getblk(sizeof(*tp->t_enum));
 			tp->t_enum->etag = tag;
 		}
-		/* ist unvollstaendiger Typ */
-		setcompl(tp, 1);
+		setcomplete(tp, 0);
 	}
 	return (tp);
 }
@@ -1781,8 +1778,7 @@ compltag(type_t *tp, sym_t *fmem)
 	int	n;
 	sym_t	*mem;
 
-	/* from now on the type is complete */
-	setcompl(tp, 0);
+	setcomplete(tp, 1);
 
 	if ((t = tp->t_tspec) != ENUM) {
 		align(dcs->d_stralign, 0);
@@ -2312,8 +2308,7 @@ compltyp(sym_t *dsym, sym_t *ssym)
 			if (dst->t_dim == 0 && src->t_dim != 0) {
 				*dstp = dst = duptyp(dst);
 				dst->t_dim = src->t_dim;
-				/* now a complete Typ */
-				setcompl(dst, 0);
+				setcomplete(dst, 1);
 			}
 		} else if (dst->t_tspec == FUNC) {
 			if (!dst->t_proto && src->t_proto) {

Index: src/usr.bin/xlint/lint1/externs1.h
diff -u src/usr.bin/xlint/lint1/externs1.h:1.35 src/usr.bin/xlint/lint1/externs1.h:1.36
--- src/usr.bin/xlint/lint1/externs1.h:1.35	Mon Mar  6 21:01:39 2017
+++ src/usr.bin/xlint/lint1/externs1.h	Mon Dec 28 22:31:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs1.h,v 1.35 2017/03/06 21:01:39 christos Exp $	*/
+/*	$NetBSD: externs1.h,v 1.36 2020/12/28 22:31:31 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -140,7 +140,7 @@ extern	type_t	*gettyp(tspec_t);
 extern	type_t	*duptyp(const type_t *);
 extern	type_t	*tduptyp(const type_t *);
 extern	int	incompl(type_t *);
-extern	void	setcompl(type_t *, int);
+extern	void	setcomplete(type_t *, int);
 extern	void	addscl(scl_t);
 extern	void	addtype(type_t *);
 extern	void	addqual(tqual_t);

Index: src/usr.bin/xlint/lint1/init.c
diff -u src/usr.bin/xlint/lint1/init.c:1.31 src/usr.bin/xlint/lint1/init.c:1.32
--- src/usr.bin/xlint/lint1/init.c:1.31	Mon Dec 28 19:07:43 2020
+++ src/usr.bin/xlint/lint1/init.c	Mon Dec 28 22:31:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: init.c,v 1.31 2020/12/28 19:07:43 rillig Exp $	*/
+/*	$NetBSD: init.c,v 1.32 2020/12/28 22:31:31 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.31 2020/12/28 19:07:43 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.32 2020/12/28 22:31:31 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -275,8 +275,7 @@ pushinit(void)
 		if (istk->i_type->t_tspec != ARRAY)
 			LERROR("pushinit()");
 		istk->i_type->t_dim++;
-		/* from now its an complete type */
-		setcompl(istk->i_type, 0);
+		setcomplete(istk->i_type, 1);
 	}
 
 	if (istk->i_cnt <= 0)
@@ -671,8 +670,7 @@ strginit(tnode_t *tn)
 	if (istk->i_nolimit) {
 		istk->i_nolimit = 0;
 		istk->i_type->t_dim = len + 1;
-		/* from now complete type */
-		setcompl(istk->i_type, 0);
+		setcomplete(istk->i_type, 1);
 	} else {
 		if (istk->i_type->t_dim < len) {
 			/* non-null byte ignored in string initializer */

Reply via email to