NetBSD Problem Report #34766

From www@NetBSD.org  Mon Oct  9 11:15:08 2006
Return-Path: <www@NetBSD.org>
Received: by narn.NetBSD.org (Postfix, from userid 31301)
	id 1AA2263BC04; Mon,  9 Oct 2006 11:15:08 +0000 (UTC)
Message-Id: <20061009111508.1AA2263BC04@narn.NetBSD.org>
Date: Mon,  9 Oct 2006 11:15:08 +0000 (UTC)
From: henning.petersen@t-online.de
Reply-To: henning.petersen@t-online.de
To: gnats-bugs@NetBSD.org
Subject: Changes for xlint
X-Send-Pr-Version: www-1.0

>Number:         34766
>Category:       bin
>Synopsis:       Changes for xlint
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Oct 09 11:20:00 +0000 2006
>Closed-Date:    Sun Feb 28 23:00:16 +0000 2021
>Last-Modified:  Sun Feb 28 23:00:16 +0000 2021
>Originator:     Henning Petersen
>Release:        NetBSD-current
>Organization:
>Environment:
>Description:
Add sizeof(term) from OpenBSD;
Missing strg1->st_len=len in function catstrg;
Typos in comments;
>How-To-Repeat:

>Fix:
Index: xlint/lint1/cgram.y
===================================================================
RCS file: /cvsroot/src/usr.bin/xlint/lint1/cgram.y,v
retrieving revision 1.37
diff -u -r1.37 cgram.y
--- xlint/lint1/cgram.y	12 Jul 2006 20:03:48 -0000	1.37
+++ xlint/lint1/cgram.y	9 Oct 2006 10:01:21 -0000
@@ -1658,7 +1658,7 @@
 		}
 	  }
 	| T_SIZEOF term					%prec T_SIZEOF {
-		if (($$ = $2 == NULL ? NULL : bldszof($2->tn_type)) != NULL)
+		if (($$ = $2 == NULL ? NULL : bldszoftrm($2)) != NULL)
 			chkmisc($2, 0, 0, 0, 0, 0, 1);
 	  }
 	| T_SIZEOF T_LPARN type_name T_RPARN		%prec T_SIZEOF {
Index: xlint/lint1/decl.c
===================================================================
RCS file: /cvsroot/src/usr.bin/xlint/lint1/decl.c,v
retrieving revision 1.35
diff -u -r1.35 decl.c
--- xlint/lint1/decl.c	13 Jul 2006 17:49:29 -0000	1.35
+++ xlint/lint1/decl.c	9 Oct 2006 10:01:24 -0000
@@ -129,7 +129,7 @@
 /*
  * Returns a shared type structure vor arithmetic types and void.
  *
- * It's important do duplicate this structure (using duptyp() or tdupdyp())
+ * It's important to duplicate this structure (using duptyp() or tdupdyp())
  * if it is to be modified (adding qualifiers or anything else).
  */
 type_t *
@@ -164,7 +164,7 @@
 }

 /*
- * Returns 1 if the argument is void or an incomplete array,
+ * Returns 1 if the argument is void or a incomplete array,
  * struct, union or enum type.
  */
 int
@@ -810,7 +810,7 @@
 }

 /*
- * Get the alignment of the given Type in bits.
+ * Get the alignment of the given type in bits.
  */
 int
 getbound(type_t *tp)
@@ -991,7 +991,7 @@
 		/*
 		 * bit field
 		 *
-		 * only unsigned und signed int are protable bit-field types
+		 * only unsigned and signed int are portable bit-field types
 		 *(at least in ANSI C, in traditional C only unsigned int)
 		 */
 		if (t == CHAR || t == UCHAR || t == SCHAR ||
@@ -1152,8 +1152,8 @@

 	if (p2->p_pcnt != 0) {
 		/* left '*' at the end of the list */
-		for (p = p2; p->p_nxt != NULL; p = p->p_nxt)
-			continue;
+		for (p = p2; p->p_nxt != NULL; p = p->p_nxt);
+
 		p->p_nxt = p1;
 		return (p2);
 	} else {
@@ -1180,7 +1180,7 @@
  * Followint 3 functions extend the type of a declarator with
  * pointer, function and array types.
  *
- * The current type is the Type built by deftyp() (dcs->d_type) and
+ * The current type is the type built by deftyp() (dcs->d_type) and
  * pointer, function and array types already added for this
  * declarator. The new type extension is inserted between both.
  */
@@ -1566,7 +1566,7 @@
 			tp->t_enum = getblk(sizeof (enum_t));
 			tp->t_enum->etag = tag;
 		}
-		/* ist unvollstaendiger Typ */
+		/* is incomplete type */
 		setcompl(tp, 1);
 	}

@@ -1776,7 +1776,7 @@
 	if (plibflg && llibflg &&
 	    dsym->s_type->t_tspec == FUNC && dsym->s_type->t_proto) {
 		/*
-		 * With both LINTLIBRARY and PROTOLIB the prototyp is
+		 * With both LINTLIBRARY and PROTOLIB the prototype is
 		 * written as a function definition to the output file.
 		 */
 		rval = dsym->s_type->t_subt->t_tspec != VOID;
@@ -2157,7 +2157,7 @@
 			if (dst->t_dim == 0 && src->t_dim != 0) {
 				*dstp = dst = duptyp(dst);
 				dst->t_dim = src->t_dim;
-				/* now a complete Typ */
+				/* now a complete type */
 				setcompl(dst, 0);
 			}
 		} else if (dst->t_tspec == FUNC) {
@@ -2236,7 +2236,7 @@
  * Does some checks for lint directives which apply to functions.
  * Processes arguments in old style function definitions which default
  * to int.
- * Checks compatiblility of old style function definition with previous
+ * Checks compatibility of old style function definition with previous
  * prototype.
  */
 void
@@ -2307,7 +2307,7 @@
 	}

 	/*
-	 * print a warning for each argument off an old style function
+	 * print a warning for each argument of an old style function
 	 * definition which defaults to int
 	 */
 	for (arg = args; arg != NULL; arg = arg->s_nxt) {
@@ -2320,7 +2320,7 @@
 	}

 	/*
-	 * If this is an old style function definition and a prototyp
+	 * If this is an old style function definition and a prototype
 	 * exists, compare the types of arguments.
 	 */
 	if (funcsym->s_osdef && funcsym->s_type->t_proto) {
@@ -2590,7 +2590,7 @@

 /*
  * Print an error or a warning if the symbol cant be initialized due
- * to type/storage class. Returnvalue is 1 if an error has been
+ * to type/storage class. Return value is 1 if an error has been
  * detected.
  */
 static int
Index: xlint/lint1/emit1.c
===================================================================
RCS file: /cvsroot/src/usr.bin/xlint/lint1/emit1.c,v
retrieving revision 1.16
diff -u -r1.16 emit1.c
--- xlint/lint1/emit1.c	24 Sep 2005 15:30:35 -0000	1.16
+++ xlint/lint1/emit1.c	9 Oct 2006 10:01:24 -0000
@@ -429,8 +429,7 @@
 	/* informations about arguments */
 	for (n = 1; n <= narg; n++) {
 		/* the last argument is the top one in the tree */
-		for (i = narg, arg = args; i > n; i--, arg = arg->tn_right)
-			continue;
+		for (i = narg, arg = args; i > n; i--, arg = arg->tn_right) ;
 		arg = arg->tn_left;
 		if (arg->tn_op == CON) {
 			if (isityp(t = arg->tn_type->t_tspec)) {
@@ -471,8 +470,7 @@
 	outint(narg);
 	for (n = 1; n <= narg; n++) {
 		/* the last argument is the top one in the tree */
-		for (i = narg, arg = args; i > n; i--, arg = arg->tn_right)
-			continue;
+		for (i = narg, arg = args; i > n; i--, arg = arg->tn_right);
 		outtype(arg->tn_left->tn_type);
 	}
 	/* expected type of return value */
@@ -481,7 +479,7 @@

 /*
  * extracts potential format specifiers for printf() and scanf() and
- * writes them, enclosed in "" and qouted if necessary, to the output buffer
+ * writes them, enclosed in "" and quoted if necessary, to the output buffer
  */
 static void
 outfstrg(strg_t *strg)
Index: xlint/lint1/err.c
===================================================================
RCS file: /cvsroot/src/usr.bin/xlint/lint1/err.c,v
retrieving revision 1.29
diff -u -r1.29 err.c
--- xlint/lint1/err.c	2 Jan 2005 10:40:49 -0000	1.29
+++ xlint/lint1/err.c	9 Oct 2006 10:01:25 -0000
@@ -381,6 +381,7 @@
 	"compound literals are a C9X/GCC extension",		      /* 319 */
 	"({ }) is a GCC extension",				      /* 320 */
 	"array initializer with designators is a C9X feature",	      /* 321 */
+	"suspicious operator for sizeof: %s"			      /* 322 */
 };

 /*
Index: xlint/lint1/externs1.h
===================================================================
RCS file: /cvsroot/src/usr.bin/xlint/lint1/externs1.h,v
retrieving revision 1.21
diff -u -r1.21 externs1.h
--- xlint/lint1/externs1.h	7 Apr 2005 16:28:40 -0000	1.21
+++ xlint/lint1/externs1.h	9 Oct 2006 10:01:25 -0000
@@ -197,6 +197,7 @@
 extern	tnode_t	*promote(op_t, int, tnode_t *);
 extern	tnode_t	*convert(op_t, int, type_t *, tnode_t *);
 extern	void	cvtcon(op_t, int, type_t *, val_t *, val_t *);
+extern	tnode_t	*bldszoftrm(tnode_t *);
 extern	tnode_t	*bldszof(type_t *);
 extern	tnode_t	*cast(tnode_t *, type_t *);
 extern	tnode_t	*funcarg(tnode_t *, tnode_t *);
Index: xlint/lint1/func.c
===================================================================
RCS file: /cvsroot/src/usr.bin/xlint/lint1/func.c,v
retrieving revision 1.22
diff -u -r1.22 func.c
--- xlint/lint1/func.c	24 Sep 2005 15:30:35 -0000	1.22
+++ xlint/lint1/func.c	9 Oct 2006 10:01:27 -0000
@@ -62,7 +62,7 @@
 int	rchflg;

 /*
- * In conjunction with reached ontrols printing of "fallthrough on ..."
+ * In conjunction with reached controls printing of "fallthrough on ..."
  * warnings.
  * Reset by each statement and set by FALLTHROUGH, switch (switch1())
  * and case (label()).
@@ -110,13 +110,13 @@
 pos_t	scflpos;

 /*
- * Are both plibflg and llibflg set, prototypes are writen as function
+ * Are both plibflg and llibflg set, prototypes are written as function
  * definitions to the output file.
  */
 int	plibflg;

 /*
- * Nonzero means that no warnings about constands in conditional
+ * Nonzero means that no warnings about constants in conditional
  * context are printed.
  */
 int	ccflg;
@@ -201,7 +201,7 @@
  * Called after a function declaration which introduces a function definition
  * and before an (optional) old style argument declaration list.
  *
- * Puts all symbols declared in the Prototype or in an old style argument
+ * Puts all symbols declared in the prototype or in an old style argument
  * list back to the symbol table.
  *
  * Does the usual checking of storage class, type (return value),
@@ -428,8 +428,7 @@
 	case T_CASE:

 		/* find the stack entry for the innermost switch statement */
-		for (ci = cstk; ci != NULL && !ci->c_switch; ci = ci->c_nxt)
-			continue;
+		for (ci = cstk; ci != NULL && !ci->c_switch; ci = ci->c_nxt) ;

 		if (ci == NULL) {
 			/* case not in switch */
@@ -501,8 +500,7 @@
 	case T_DEFAULT:

 		/* find the stack entry for the innermost switch statement */
-		for (ci = cstk; ci != NULL && !ci->c_switch; ci = ci->c_nxt)
-			continue;
+		for (ci = cstk; ci != NULL && !ci->c_switch; ci = ci->c_nxt);

 		if (ci == NULL) {
 			/* default outside switch */
@@ -942,8 +940,7 @@
 {
 	cstk_t	*ci;

-	for (ci = cstk; ci != NULL && !ci->c_loop; ci = ci->c_nxt)
-		continue;
+	for (ci = cstk; ci != NULL && !ci->c_loop; ci = ci->c_nxt) ;

 	if (ci == NULL) {
 		/* continue outside loop */
@@ -968,8 +965,7 @@
 	cstk_t	*ci;
 	op_t	op;

-	for (ci = cstk; ci->c_nxt != NULL; ci = ci->c_nxt)
-		continue;
+	for (ci = cstk; ci->c_nxt != NULL; ci = ci->c_nxt);

 	if (tn != NULL) {
 		ci->c_retval = 1;
Index: xlint/lint1/lint1.h
===================================================================
RCS file: /cvsroot/src/usr.bin/xlint/lint1/lint1.h,v
retrieving revision 1.19
diff -u -r1.19 lint1.h
--- xlint/lint1/lint1.h	24 Sep 2005 15:30:35 -0000	1.19
+++ xlint/lint1/lint1.h	9 Oct 2006 10:01:27 -0000
@@ -104,7 +104,7 @@
  * Structures of type str_t uniqely identify structures. This can't
  * be done in structures of type type_t, because these are copied
  * if they must be modified. So it would not be possible to check
- * if to structures are identical by comparing the pointers to
+ * if two structures are identical by comparing the pointers to
  * the type structures.
  *
  * The typename is used if the structure is unnamed to identify
Index: xlint/lint1/scan.l
===================================================================
RCS file: /cvsroot/src/usr.bin/xlint/lint1/scan.l,v
retrieving revision 1.34
diff -u -r1.34 scan.l
--- xlint/lint1/scan.l	22 Mar 2006 02:14:03 -0000	1.34
+++ xlint/lint1/scan.l	9 Oct 2006 10:01:29 -0000
@@ -514,7 +514,7 @@
 		warning(252);

 	/*
-	 * If the value is to big for the current type, we must choose
+	 * If the value is too big for the current type, we must choose
 	 * another type.
 	 */
 	ansiu = 0;
@@ -649,7 +649,7 @@
 }

 /*
- * Convert a string representing a floating point value into its interal
+ * Convert a string representing a floating point value into its integral
  * representation. Type and value are returned in yylval. fcon()
  * (and yylex()) returns T_CON.
  * XXX Currently it is not possible to convert constants of type
@@ -958,8 +958,7 @@
 	static	int first = 1;

 	/* Go to first non-whitespace after # */
-	for (cp = yytext + 1; (c = *cp) == ' ' || c == '\t'; cp++)
-		continue;
+	for (cp = yytext + 1; (c = *cp) == ' ' || c == '\t'; cp++);

 	if (!isdigit((unsigned char)c)) {
 	error:
@@ -972,8 +971,8 @@
 		goto error;
 	if ((c = *(cp = eptr)) != ' ' && c != '\t' && c != '\0')
 		goto error;
-	while ((c = *cp++) == ' ' || c == '\t')
-		continue;
+	while ((c = *cp++) == ' ' || c == '\t');
+
 	if (c != '\0') {
 		if (c != '"')
 			goto error;
@@ -984,8 +983,8 @@
 			goto error;
 		if ((fnl = cp++ - fn) > PATH_MAX)
 			goto error;
-		while ((c = *cp++) == ' ' || c == '\t')
-			continue;
+		while ((c = *cp++) == ' ' || c == '\t');
+
 #if 0
 		if (c != '\0')
 			warning("extra character(s) after directive");
@@ -1067,8 +1066,8 @@
 	eoc = 0;

 	/* Skip white spaces after the start of the comment */
-	while ((c = inpc()) != EOF && isspace(c))
-		continue;
+	while ((c = inpc()) != EOF && isspace(c));
+

 	/* Read the potential keyword to keywd */
 	l = 0;
@@ -1145,8 +1144,7 @@
 		/* // comments only supported in C99 */
 		(void)gnuism(312, tflag ? "traditional" : "ANSI");

-	while ((c = inpc()) != EOF && c != '\n')
-		continue;
+	while ((c = inpc()) != EOF && c != '\n');
 }

 /*
Index: xlint/lint1/tree.c
===================================================================
RCS file: /cvsroot/src/usr.bin/xlint/lint1/tree.c,v
retrieving revision 1.42
diff -u -r1.42 tree.c
--- xlint/lint1/tree.c	22 Mar 2006 02:08:55 -0000	1.42
+++ xlint/lint1/tree.c	9 Oct 2006 10:01:33 -0000
@@ -561,7 +561,7 @@

 	/*
 	 * Apply class conversions to the left operand, but only if its
-	 * value is needed or it is compaired with null.
+	 * value is needed or it is compared with null.
 	 */
 	if (mp->m_vctx || mp->m_tctx)
 		ln = cconv(ln);
@@ -618,7 +618,7 @@

 	/*
 	 * Check types for compatibility with the operation and mutual
-	 * compatibility. Return if there are serios problems.
+	 * compatibility. Return if there are serious problems.
 	 */
 	if (!typeok(op, 0, ln, rn))
 		return (NULL);
@@ -763,7 +763,7 @@

 /*
  * Perform most type checks. First the types are checked using
- * informations from modtab[]. After that it is done by hand for
+ * information from modtab[]. After that it is done by hand for
  * more complicated operators and type combinations.
  *
  * If the types are ok, typeok() returns 1, otherwise 0.
@@ -816,11 +816,9 @@
 		 * For these operations we need the types before promotion
 		 * and balancing.
 		 */
-		for (tn=ln; tn->tn_op==CVT && !tn->tn_cast; tn=tn->tn_left)
-			continue;
+		for (tn=ln; tn->tn_op==CVT && !tn->tn_cast; tn=tn->tn_left);
 		olt = tn->tn_type->t_tspec;
-		for (tn=rn; tn->tn_op==CVT && !tn->tn_cast; tn=tn->tn_left)
-			continue;
+		for (tn=rn; tn->tn_op==CVT && !tn->tn_cast; tn=tn->tn_left);
 		ort = tn->tn_type->t_tspec;
 	}

@@ -828,7 +826,7 @@
 	case POINT:
 		/*
 		 * Most errors required by ANSI C are reported in strmemb().
-		 * Here we only must check for totaly wrong things.
+		 * Here we only must check for totally wrong things.
 		 */
 		if (lt == FUNC || lt == VOID || ltp->t_isfield ||
 		    ((lt != STRUCT && lt != UNION) && !ln->tn_lvalue)) {
@@ -975,14 +973,14 @@
 		 * ANSI C does not perform balancing for shift operations,
 		 * but traditional C does. If the width of the right operand
 		 * is greather than the width of the left operand, than in
-		 * traditional C the left operand would be extendet to the
+		 * traditional C the left operand would be extended to the
 		 * width of the right operand. For SHL this may result in
 		 * different results.
 		 */
 		if (psize(lt) < psize(rt)) {
 			/*
 			 * XXX If both operands are constant make sure
-			 * that there is really a differencs between
+			 * that there is really a difference between
 			 * ANSI C and traditional C.
 			 */
 			if (hflag)
@@ -995,7 +993,7 @@
 				/* negative shift */
 				warning(121);
 			} else if ((uint64_t)rn->tn_val->v_quad == size(lt)) {
-				/* shift equal to size fo object */
+				/* shift equal to size of object */
 				warning(267);
 			} else if ((uint64_t)rn->tn_val->v_quad > size(lt)) {
 				/* shift greater than size of object */
@@ -1121,7 +1119,7 @@
 		goto assign;
 	case SHRASS:
 		if (pflag && !isutyp(lt) && !(tflag && isutyp(rt))) {
-			/* bitwise operation on s.v. possibly nonportabel */
+			/* bitwise operation on s.v. possibly nonportable */
 			warning(117);
 		}
 		goto assign;
@@ -1767,7 +1765,7 @@
 }

 /*
- * Print warnings for conversions of integer types which my cause
+ * Print warnings for conversions of integer types which may cause
  * problems.
  */
 /* ARGSUSED */
@@ -2934,6 +2932,26 @@
 }

 /*
+ * Create a constant node for sizeof(term).
+ */
+tnode_t *
+bldszoftrm(tnode_t *tn)
+{
+	switch (tn->tn_op) {
+	case POINT:
+	case STAR:
+	case NAME:
+	case STRING:
+		break;
+	default:
+		warning(322, modtab[tn->tn_op].m_name);
+	}
+
+
+	return bldszof(tn->tn_type);
+}
+
+/*
  * Create a constant node for sizeof.
  */
 tnode_t *
@@ -3154,8 +3172,7 @@
 		 * The rightmost argument is at the top of the argument
 		 * subtree.
 		 */
-		for (i = narg, arg = args; i > n; i--, arg = arg->tn_right)
-			continue;
+		for (i = narg, arg = args; i > n; i--, arg = arg->tn_right);

 		/* some things which are always not allowd */
 		if ((at = arg->tn_left->tn_type->t_tspec) == VOID) {
@@ -3714,7 +3731,7 @@
 }

 /*
- * Takes an expression an returns 0 if this expression can be used
+ * Takes an expression and returns 0 if this expression can be used
  * for static initialisation, otherwise -1.
  *
  * Constant initialisation expressions must be constant or an address
@@ -3825,6 +3842,7 @@
 		free(strg2->st_wcp);
 	}
 	free(strg2);
+	strg1->st_len = len;

 	return (strg1);
 }
Index: xlint/lint2/main2.c
===================================================================
RCS file: /cvsroot/src/usr.bin/xlint/lint2/main2.c,v
retrieving revision 1.7
diff -u -r1.7 main2.c
--- xlint/lint2/main2.c	20 Jun 2004 22:20:17 -0000	1.7
+++ xlint/lint2/main2.c	9 Oct 2006 10:01:33 -0000
@@ -137,8 +137,7 @@
 			Fflag = 1;
 			break;
 		case 'l':
-			for (i = 0; libs[i] != NULL; i++)
-				continue;
+			for (i = 0; libs[i] != NULL; i++);
 			libs = xrealloc(libs, (i + 2) * sizeof (char *));
 			libs[i] = xstrdup(optarg);
 			libs[i + 1] = NULL;
Index: xlint/lint2/read.c
===================================================================
RCS file: /cvsroot/src/usr.bin/xlint/lint2/read.c,v
retrieving revision 1.18
diff -u -r1.18 read.c
--- xlint/lint2/read.c	22 Mar 2006 16:16:59 -0000	1.18
+++ xlint/lint2/read.c	9 Oct 2006 10:01:34 -0000
@@ -1171,8 +1171,8 @@
 	 * XXX this entry should be put at the beginning of the list to
 	 * avoid to process the same symbol twice.
 	 */
-	for (nhte = hte; nhte->h_link != NULL; nhte = nhte->h_link)
-		continue;
+	for (nhte = hte; nhte->h_link != NULL; nhte = nhte->h_link);
+
 	nhte->h_link = xmalloc(sizeof (hte_t));
 	nhte = nhte->h_link;
 	nhte->h_name = hte->h_name;
Index: xlint/xlint/xlint.c
===================================================================
RCS file: /cvsroot/src/usr.bin/xlint/xlint/xlint.c,v
retrieving revision 1.37
diff -u -r1.37 xlint.c
--- xlint/xlint/xlint.c	2 Jun 2005 04:38:46 -0000	1.37
+++ xlint/xlint/xlint.c	9 Oct 2006 10:01:35 -0000
@@ -157,8 +157,7 @@
 	int	i;

 	olst = *lstp;
-	for (i = 0; olst[i] != NULL; i++)
-		continue;
+	for (i = 0; olst[i] != NULL; i++);
 	lst = xrealloc(olst, (i + 2) * sizeof (char *));
 	lst[i] = s;
 	lst[i + 1] = NULL;
@@ -179,10 +178,8 @@
 	char	**dest, **odest;

 	odest = *destp;
-	for (i = 0; odest[i] != NULL; i++)
-		continue;
-	for (k = 0; src[k] != NULL; k++)
-		continue;
+	for (i = 0; odest[i] != NULL; i++);
+	for (k = 0; src[k] != NULL; k++);
 	dest = xrealloc(odest, (i + k + 1) * sizeof (char *));
 	for (k = 0; src[k] != NULL; k++)
 		dest[i + k] = xstrdup(src[k]);
@@ -196,8 +193,7 @@
 	char	*s;
 	int	i;

-	for (i = 0; (*lstp)[i] != NULL; i++)
-		continue;
+	for (i = 0; (*lstp)[i] != NULL; i++);
 	while (i-- > 0) {
 		s = (*lstp)[i];
 		(*lstp)[i] = NULL;

>Release-Note:

>Audit-Trail:
From: David Laight <david@l8s.co.uk>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/34766: Changes for xlint
Date: Mon, 9 Oct 2006 12:26:58 +0100

 On Mon, Oct 09, 2006 at 11:20:00AM +0000, henning.petersen@t-online.de wrote:
 > Add sizeof(term) from OpenBSD;
 > Missing strg1->st_len=len in function catstrg;
 > Typos in comments;

 Can you separate the patches?

 > -		for (p = p2; p->p_nxt != NULL; p = p->p_nxt)
 > -			continue;
 > +		for (p = p2; p->p_nxt != NULL; p = p->p_nxt);

 The continue here is deliberate and good practise, they don't want
 removing.

 	David

 -- 
 David Laight: david@l8s.co.uk

From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org
Cc: 
Subject: Re: bin/34766: Changes for xlint
Date: Mon, 9 Oct 2006 09:03:08 -0400

 On Oct 9, 11:20am, henning.petersen@t-online.de (henning.petersen@t-online.de) wrote:
 -- Subject: bin/34766: Changes for xlint

 | >Number:         34766
 | >Category:       bin
 | >Synopsis:       Changes for xlint
 | >Confidential:   no
 | >Severity:       non-critical
 | >Priority:       medium
 | >Responsible:    bin-bug-people
 | >State:          open
 | >Class:          sw-bug
 | >Submitter-Id:   net
 | >Arrival-Date:   Mon Oct 09 11:20:00 +0000 2006
 | >Originator:     Henning Petersen
 | >Release:        NetBSD-current
 | >Organization:
 | >Environment:
 | >Description:
 | Add sizeof(term) from OpenBSD;
 | Missing strg1->st_len=len in function catstrg;
 | Typos in comments;
 | >How-To-Repeat:

 Thanks, can you please re-submit without the bogus:

 -	loop ()
 -		continue;
 +	loop ();

 changes? These are bad, and make gcc -Wextra whine.

 christos

From: henning petersen <henning.petersen@t-online.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: [Fwd: Re: bin/34766: Changes for xlint]
Date: Mon, 09 Oct 2006 16:06:24 +0200

 This is a multi-part message in MIME format.
 --------------070404010004060102080004
 Content-Type: text/plain; charset=ISO-8859-15; format=flowed
 Content-Transfer-Encoding: 7bit



 --------------070404010004060102080004
 Content-Type: message/rfc822;
  name="Re: bin/34766: Changes for xlint"
 Content-Transfer-Encoding: 8bit
 Content-Disposition: inline;
  filename="Re: bin/34766: Changes for xlint"

 X-Identity-Key: id1
 Message-ID: <452A4735.2010801@t-online.de>
 Date: Mon, 09 Oct 2006 14:57:25 +0200
 From: henning petersen <henning.petersen@t-online.de>
 User-Agent: Thunderbird 1.5.0.7 (Windows/20060909)
 MIME-Version: 1.0
 To:  gnats-bugs@NetBSD.org
 Subject: Re: bin/34766: Changes for xlint
 References: <pr-bin-34766@gnats.netbsd.org> <20061009113501.CC13263BC04@narn.NetBSD.org>
 In-Reply-To: <20061009113501.CC13263BC04@narn.NetBSD.org>
 Content-Type: multipart/mixed;
  boundary="------------060400060700080903070209"

 This is a multi-part message in MIME format.
 --------------060400060700080903070209
 Content-Type: text/plain; charset=ISO-8859-15; format=flowed
 Content-Transfer-Encoding: 8bit

 David Laight schrieb:
 > The following reply was made to PR bin/34766; it has been noted by GNATS.
 >
 > From: David Laight <david@l8s.co.uk>
 > To: gnats-bugs@NetBSD.org
 > Cc: 
 > Subject: Re: bin/34766: Changes for xlint
 > Date: Mon, 9 Oct 2006 12:26:58 +0100
 >
 >  On Mon, Oct 09, 2006 at 11:20:00AM +0000, henning.petersen@t-online.de wrote:
 >  > Add sizeof(term) from OpenBSD;
 >  > Missing strg1->st_len=len in function catstrg;
 >  > Typos in comments;
 >  
 >  Can you separate the patches?
 >  
 >  > -		for (p = p2; p->p_nxt != NULL; p = p->p_nxt)
 >  > -			continue;
 >  > +		for (p = p2; p->p_nxt != NULL; p = p->p_nxt);
 >  
 >  The continue here is deliberate and good practise, they don't want
 >  removing.
 >  
 >  	David
 >  
 >  -- 
 >  David Laight: david@l8s.co.uk
 >  
 >
 > __________ NOD32 1.1795 (20061009) Information __________
 >
 > Diese E-Mail wurde vom NOD32 antivirus system geprüft
 > http://www.nod32.com
 >
 >
 >
 >   


 --------------060400060700080903070209
 Content-Type: text/plain;
  name="scan.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="scan.diff"

 Index: scan.l
 ===================================================================
 RCS file: /cvsroot/src/usr.bin/xlint/lint1/scan.l,v
 retrieving revision 1.34
 diff -u -r1.34 scan.l
 --- scan.l	22 Mar 2006 02:14:03 -0000	1.34
 +++ scan.l	9 Oct 2006 12:43:23 -0000
 @@ -514,7 +514,7 @@
  		warning(252);

  	/*
 -	 * If the value is to big for the current type, we must choose
 +	 * If the value is too big for the current type, we must choose
  	 * another type.
  	 */
  	ansiu = 0;
 @@ -649,7 +649,7 @@
  }

  /*
 - * Convert a string representing a floating point value into its interal
 + * Convert a string representing a floating point value into its integral
   * representation. Type and value are returned in yylval. fcon()
   * (and yylex()) returns T_CON.
   * XXX Currently it is not possible to convert constants of type

 --------------060400060700080903070209
 Content-Type: text/plain;
  name="tree.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="tree.diff"

 Index: tree.c
 ===================================================================
 RCS file: /cvsroot/src/usr.bin/xlint/lint1/tree.c,v
 retrieving revision 1.42
 diff -u -r1.42 tree.c
 --- tree.c	22 Mar 2006 02:08:55 -0000	1.42
 +++ tree.c	9 Oct 2006 12:34:09 -0000
 @@ -561,7 +561,7 @@

  	/*
  	 * Apply class conversions to the left operand, but only if its
 -	 * value is needed or it is compaired with null.
 +	 * value is needed or it is compared with null.
  	 */
  	if (mp->m_vctx || mp->m_tctx)
  		ln = cconv(ln);
 @@ -618,7 +618,7 @@

  	/*
  	 * Check types for compatibility with the operation and mutual
 -	 * compatibility. Return if there are serios problems.
 +	 * compatibility. Return if there are serious problems.
  	 */
  	if (!typeok(op, 0, ln, rn))
  		return (NULL);
 @@ -763,7 +763,7 @@

  /*
   * Perform most type checks. First the types are checked using
 - * informations from modtab[]. After that it is done by hand for
 + * information from modtab[]. After that it is done by hand for
   * more complicated operators and type combinations.
   *
   * If the types are ok, typeok() returns 1, otherwise 0.
 @@ -828,7 +828,7 @@
  	case POINT:
  		/*
  		 * Most errors required by ANSI C are reported in strmemb().
 -		 * Here we only must check for totaly wrong things.
 +		 * Here we only must check for totally wrong things.
  		 */
  		if (lt == FUNC || lt == VOID || ltp->t_isfield ||
  		    ((lt != STRUCT && lt != UNION) && !ln->tn_lvalue)) {
 @@ -975,14 +975,14 @@
  		 * ANSI C does not perform balancing for shift operations,
  		 * but traditional C does. If the width of the right operand
  		 * is greather than the width of the left operand, than in
 -		 * traditional C the left operand would be extendet to the
 +		 * traditional C the left operand would be extended to the
  		 * width of the right operand. For SHL this may result in
  		 * different results.
  		 */
  		if (psize(lt) < psize(rt)) {
  			/*
  			 * XXX If both operands are constant make sure
 -			 * that there is really a differencs between
 +			 * that there is really a difference between
  			 * ANSI C and traditional C.
  			 */
  			if (hflag)
 @@ -995,7 +995,7 @@
  				/* negative shift */
  				warning(121);
  			} else if ((uint64_t)rn->tn_val->v_quad == size(lt)) {
 -				/* shift equal to size fo object */
 +				/* shift equal to size of object */
  				warning(267);
  			} else if ((uint64_t)rn->tn_val->v_quad > size(lt)) {
  				/* shift greater than size of object */
 @@ -1121,7 +1121,7 @@
  		goto assign;
  	case SHRASS:
  		if (pflag && !isutyp(lt) && !(tflag && isutyp(rt))) {
 -			/* bitwise operation on s.v. possibly nonportabel */
 +			/* bitwise operation on s.v. possibly nonportable */
  			warning(117);
  		}
  		goto assign;
 @@ -1767,7 +1767,7 @@
  }

  /*
 - * Print warnings for conversions of integer types which my cause
 + * Print warnings for conversions of integer types which may cause
   * problems.
   */
  /* ARGSUSED */
 @@ -2934,6 +2934,26 @@
  }

  /*
 + * Create a constant node for sizeof(term).
 + */
 +tnode_t *
 +bldszoftrm(tnode_t *tn)
 +{
 +	switch (tn->tn_op) {
 +	case POINT:
 +	case STAR:
 +	case NAME:
 +	case STRING:
 +		break;
 +	default:
 +		warning(322, modtab[tn->tn_op].m_name);
 +	}
 +
 +
 +	return bldszof(tn->tn_type);
 +}
 +
 +/*
   * Create a constant node for sizeof.
   */
  tnode_t *
 @@ -3714,7 +3734,7 @@
  }

  /*
 - * Takes an expression an returns 0 if this expression can be used
 + * Takes an expression and returns 0 if this expression can be used
   * for static initialisation, otherwise -1.
   *
   * Constant initialisation expressions must be constant or an address
 @@ -3825,6 +3845,7 @@
  		free(strg2->st_wcp);
  	}
  	free(strg2);
 +	strg1->st_len = len;

  	return (strg1);
  }

 --------------060400060700080903070209
 Content-Type: text/plain;
  name="cgram.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="cgram.diff"

 Index: cgram.y
 ===================================================================
 RCS file: /cvsroot/src/usr.bin/xlint/lint1/cgram.y,v
 retrieving revision 1.37
 diff -u -r1.37 cgram.y
 --- cgram.y	12 Jul 2006 20:03:48 -0000	1.37
 +++ cgram.y	9 Oct 2006 12:35:09 -0000
 @@ -1658,7 +1658,7 @@
  		}
  	  }
  	| T_SIZEOF term					%prec T_SIZEOF {
 -		if (($$ = $2 == NULL ? NULL : bldszof($2->tn_type)) != NULL)
 +		if (($$ = $2 == NULL ? NULL : bldszoftrm($2)) != NULL)
  			chkmisc($2, 0, 0, 0, 0, 0, 1);
  	  }
  	| T_SIZEOF T_LPARN type_name T_RPARN		%prec T_SIZEOF {

 --------------060400060700080903070209
 Content-Type: text/plain;
  name="decl.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="decl.diff"

 Index: decl.c
 ===================================================================
 RCS file: /cvsroot/src/usr.bin/xlint/lint1/decl.c,v
 retrieving revision 1.35
 diff -u -r1.35 decl.c
 --- decl.c	13 Jul 2006 17:49:29 -0000	1.35
 +++ decl.c	9 Oct 2006 12:35:29 -0000
 @@ -129,7 +129,7 @@
  /*
   * Returns a shared type structure vor arithmetic types and void.
   *
 - * It's important do duplicate this structure (using duptyp() or tdupdyp())
 + * It's important to duplicate this structure (using duptyp() or tdupdyp())
   * if it is to be modified (adding qualifiers or anything else).
   */
  type_t *
 @@ -164,7 +164,7 @@
  }

  /*
 - * Returns 1 if the argument is void or an incomplete array,
 + * Returns 1 if the argument is void or a incomplete array,
   * struct, union or enum type.
   */
  int
 @@ -810,7 +810,7 @@
  }

  /*
 - * Get the alignment of the given Type in bits.
 + * Get the alignment of the given type in bits.
   */
  int
  getbound(type_t *tp)
 @@ -991,7 +991,7 @@
  		/*
  		 * bit field
  		 *
 -		 * only unsigned und signed int are protable bit-field types
 +		 * only unsigned and signed int are portable bit-field types
  		 *(at least in ANSI C, in traditional C only unsigned int)
  		 */
  		if (t == CHAR || t == UCHAR || t == SCHAR ||
 @@ -1154,6 +1154,7 @@
  		/* left '*' at the end of the list */
  		for (p = p2; p->p_nxt != NULL; p = p->p_nxt)
  			continue;
 +
  		p->p_nxt = p1;
  		return (p2);
  	} else {
 @@ -1180,7 +1181,7 @@
   * Followint 3 functions extend the type of a declarator with
   * pointer, function and array types.
   *
 - * The current type is the Type built by deftyp() (dcs->d_type) and
 + * The current type is the type built by deftyp() (dcs->d_type) and
   * pointer, function and array types already added for this
   * declarator. The new type extension is inserted between both.
   */
 @@ -1401,7 +1402,7 @@
  	switch (dcs->d_ctx) {
  	case MOS:
  	case MOU:
 -		/* Parent setzen */
 +		/* Set parent */
  		sym->s_styp = dcs->d_tagtyp->t_str;
  		sym->s_def = DEF;
  		sym->s_value.v_tspec = INT;
 @@ -1566,7 +1567,7 @@
  			tp->t_enum = getblk(sizeof (enum_t));
  			tp->t_enum->etag = tag;
  		}
 -		/* ist unvollstaendiger Typ */
 +		/* is incomplete type */
  		setcompl(tp, 1);
  	}

 @@ -1776,7 +1777,7 @@
  	if (plibflg && llibflg &&
  	    dsym->s_type->t_tspec == FUNC && dsym->s_type->t_proto) {
  		/*
 -		 * With both LINTLIBRARY and PROTOLIB the prototyp is
 +		 * With both LINTLIBRARY and PROTOLIB the prototype is
  		 * written as a function definition to the output file.
  		 */
  		rval = dsym->s_type->t_subt->t_tspec != VOID;
 @@ -2157,7 +2158,7 @@
  			if (dst->t_dim == 0 && src->t_dim != 0) {
  				*dstp = dst = duptyp(dst);
  				dst->t_dim = src->t_dim;
 -				/* now a complete Typ */
 +				/* now a complete type */
  				setcompl(dst, 0);
  			}
  		} else if (dst->t_tspec == FUNC) {
 @@ -2236,7 +2237,7 @@
   * Does some checks for lint directives which apply to functions.
   * Processes arguments in old style function definitions which default
   * to int.
 - * Checks compatiblility of old style function definition with previous
 + * Checks compatibility of old style function definition with previous
   * prototype.
   */
  void
 @@ -2307,7 +2308,7 @@
  	}

  	/*
 -	 * print a warning for each argument off an old style function
 +	 * print a warning for each argument of an old style function
  	 * definition which defaults to int
  	 */
  	for (arg = args; arg != NULL; arg = arg->s_nxt) {
 @@ -2320,7 +2321,7 @@
  	}

  	/*
 -	 * If this is an old style function definition and a prototyp
 +	 * If this is an old style function definition and a prototype
  	 * exists, compare the types of arguments.
  	 */
  	if (funcsym->s_osdef && funcsym->s_type->t_proto) {
 @@ -2590,7 +2591,7 @@

  /*
   * Print an error or a warning if the symbol cant be initialized due
 - * to type/storage class. Returnvalue is 1 if an error has been
 + * to type/storage class. Return value is 1 if an error has been
   * detected.
   */
  static int

 --------------060400060700080903070209
 Content-Type: text/plain;
  name="emit1.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="emit1.diff"

 Index: emit1.c
 ===================================================================
 RCS file: /cvsroot/src/usr.bin/xlint/lint1/emit1.c,v
 retrieving revision 1.16
 diff -u -r1.16 emit1.c
 --- emit1.c	24 Sep 2005 15:30:35 -0000	1.16
 +++ emit1.c	9 Oct 2006 12:35:47 -0000
 @@ -481,7 +481,7 @@

  /*
   * extracts potential format specifiers for printf() and scanf() and
 - * writes them, enclosed in "" and qouted if necessary, to the output buffer
 + * writes them, enclosed in "" and quoted if necessary, to the output buffer
   */
  static void
  outfstrg(strg_t *strg)

 --------------060400060700080903070209
 Content-Type: text/plain;
  name="externs1.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="externs1.diff"

 Index: externs1.h
 ===================================================================
 RCS file: /cvsroot/src/usr.bin/xlint/lint1/externs1.h,v
 retrieving revision 1.21
 diff -u -r1.21 externs1.h
 --- externs1.h	7 Apr 2005 16:28:40 -0000	1.21
 +++ externs1.h	9 Oct 2006 12:36:32 -0000
 @@ -197,6 +197,7 @@
  extern	tnode_t	*promote(op_t, int, tnode_t *);
  extern	tnode_t	*convert(op_t, int, type_t *, tnode_t *);
  extern	void	cvtcon(op_t, int, type_t *, val_t *, val_t *);
 +extern	tnode_t	*bldszoftrm(tnode_t *);
  extern	tnode_t	*bldszof(type_t *);
  extern	tnode_t	*cast(tnode_t *, type_t *);
  extern	tnode_t	*funcarg(tnode_t *, tnode_t *);

 --------------060400060700080903070209
 Content-Type: text/plain;
  name="func.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="func.diff"

 Index: func.c
 ===================================================================
 RCS file: /cvsroot/src/usr.bin/xlint/lint1/func.c,v
 retrieving revision 1.22
 diff -u -r1.22 func.c
 --- func.c	24 Sep 2005 15:30:35 -0000	1.22
 +++ func.c	9 Oct 2006 12:40:24 -0000
 @@ -62,7 +62,7 @@
  int	rchflg;

  /*
 - * In conjunction with reached ontrols printing of "fallthrough on ..."
 + * In conjunction with reached controls printing of "fallthrough on ..."
   * warnings.
   * Reset by each statement and set by FALLTHROUGH, switch (switch1())
   * and case (label()).
 @@ -110,13 +110,13 @@
  pos_t	scflpos;

  /*
 - * Are both plibflg and llibflg set, prototypes are writen as function
 + * Are both plibflg and llibflg set, prototypes are written as function
   * definitions to the output file.
   */
  int	plibflg;

  /*
 - * Nonzero means that no warnings about constands in conditional
 + * Nonzero means that no warnings about constants in conditional
   * context are printed.
   */
  int	ccflg;
 @@ -201,7 +201,7 @@
   * Called after a function declaration which introduces a function definition
   * and before an (optional) old style argument declaration list.
   *
 - * Puts all symbols declared in the Prototype or in an old style argument
 + * Puts all symbols declared in the prototype or in an old style argument
   * list back to the symbol table.
   *
   * Does the usual checking of storage class, type (return value),

 --------------060400060700080903070209
 Content-Type: text/plain;
  name="lint1.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="lint1.diff"

 Index: lint1.h
 ===================================================================
 RCS file: /cvsroot/src/usr.bin/xlint/lint1/lint1.h,v
 retrieving revision 1.19
 diff -u -r1.19 lint1.h
 --- lint1.h	24 Sep 2005 15:30:35 -0000	1.19
 +++ lint1.h	9 Oct 2006 12:37:13 -0000
 @@ -104,7 +104,7 @@
   * Structures of type str_t uniqely identify structures. This can't
   * be done in structures of type type_t, because these are copied
   * if they must be modified. So it would not be possible to check
 - * if to structures are identical by comparing the pointers to
 + * if two structures are identical by comparing the pointers to
   * the type structures.
   *
   * The typename is used if the structure is unnamed to identify

 --------------060400060700080903070209--


 --------------070404010004060102080004--

State-Changed-From-To: open->closed
State-Changed-By: rillig@NetBSD.org
State-Changed-When: Sun, 28 Feb 2021 23:00:16 +0000
State-Changed-Why:

Thanks for the PR.
The typos have all been fixed.
The missing st_len has also been added.
The check for suspicious sizeof will not be added,
there is not enough convincing reason or code samples,
in fact, the patch does not give a single example of code
to which this check might apply.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.