Module Name:    src
Committed By:   christos
Date:           Fri Jun 24 01:10:32 UTC 2011

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

Log Message:
Always use our own align macro and explain a bit more why this is bogus.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/xlint/lint1/lint1.h
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/xlint/lint1/mem1.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.52 src/usr.bin/xlint/lint1/decl.c:1.53
--- src/usr.bin/xlint/lint1/decl.c:1.52	Tue May 24 08:49:11 2011
+++ src/usr.bin/xlint/lint1/decl.c	Thu Jun 23 21:10:31 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.52 2011/05/24 12:49:11 joerg Exp $ */
+/* $NetBSD: decl.c,v 1.53 2011/06/24 01:10:31 christos 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.52 2011/05/24 12:49:11 joerg Exp $");
+__RCSID("$NetBSD: decl.c,v 1.53 2011/06/24 01:10:31 christos Exp $");
 #endif
 
 #include <sys/param.h>
@@ -926,15 +926,15 @@
 	} else if (t == FUNC) {
 		/* compiler takes alignment of function */
 		error(14);
-		a = ALIGN(1) * CHAR_BIT;
+		a = WORST_ALIGN(1) * CHAR_BIT;
 	} else {
 		if ((a = size(t)) == 0) {
 			a = CHAR_BIT;
-		} else if (a > ALIGN(1) * CHAR_BIT) {
-			a = ALIGN(1) * CHAR_BIT;
+		} else if (a > WORST_ALIGN(1) * CHAR_BIT) {
+			a = WORST_ALIGN(1) * CHAR_BIT;
 		}
 	}
-	if (a < CHAR_BIT || a > ALIGN(1) * CHAR_BIT)
+	if (a < CHAR_BIT || a > WORST_ALIGN(1) * CHAR_BIT)
 		LERROR("getbound()");
 	return (a);
 }

Index: src/usr.bin/xlint/lint1/lint1.h
diff -u src/usr.bin/xlint/lint1/lint1.h:1.24 src/usr.bin/xlint/lint1/lint1.h:1.25
--- src/usr.bin/xlint/lint1/lint1.h:1.24	Fri Oct  2 15:01:14 2009
+++ src/usr.bin/xlint/lint1/lint1.h	Thu Jun 23 21:10:31 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.24 2009/10/02 19:01:14 christos Exp $ */
+/* $NetBSD: lint1.h,v 1.25 2011/06/24 01:10:31 christos Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,9 +35,19 @@
 #include "lint.h"
 #include "op.h"
 
-/* XXX - works for most systems, but the whole ALIGN thing needs to go away */
-#ifndef ALIGN
-#define ALIGN(x) (((x) + 7) & ~7)
+/*
+ * XXX - Super conservative so that works for most systems, but we should
+ * not depend on the host settings but the target settings in determining
+ * the alignment. The only valid use for this is in mem1.c; uses in decl.c
+ * are bogus.
+ */
+#ifndef WORST_ALIGN
+#ifdef _LP64
+# define AVAL	15
+#else
+# define AVAL	7
+#endif
+#define WORST_ALIGN(x) (((x) + AVAL) & ~AVAL)
 #endif
 
 /*

Index: src/usr.bin/xlint/lint1/mem1.c
diff -u src/usr.bin/xlint/lint1/mem1.c:1.14 src/usr.bin/xlint/lint1/mem1.c:1.15
--- src/usr.bin/xlint/lint1/mem1.c:1.14	Sun Jan 16 22:04:10 2011
+++ src/usr.bin/xlint/lint1/mem1.c	Thu Jun 23 21:10:31 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: mem1.c,v 1.14 2011/01/17 03:04:10 christos Exp $	*/
+/*	$NetBSD: mem1.c,v 1.15 2011/06/24 01:10:31 christos Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem1.c,v 1.14 2011/01/17 03:04:10 christos Exp $");
+__RCSID("$NetBSD: mem1.c,v 1.15 2011/06/24 01:10:31 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -192,7 +192,7 @@
 	void	*p;
 	size_t	t = 0;
 
-	s = ALIGN(s);
+	s = WORST_ALIGN(s);
 	if ((mb = *mbp) == NULL || mb->nfree < s) {
 		if ((mb = frmblks) == NULL || mb->size < s) {
 			if (s > mblklen) {

Reply via email to