Module Name:    src
Committed By:   rillig
Date:           Sun Apr 18 17:36:18 UTC 2021

Modified Files:
        src/usr.bin/xlint/lint1: ckgetopt.c decl.c err.c externs1.h func.c

Log Message:
lint: pass pos_t via const pointer

Thanks for the suggestion, christos@.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/xlint/lint1/ckgetopt.c
cvs rdiff -u -r1.177 -r1.178 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.115 -r1.116 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.107 -r1.108 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.104 -r1.105 src/usr.bin/xlint/lint1/func.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/ckgetopt.c
diff -u src/usr.bin/xlint/lint1/ckgetopt.c:1.8 src/usr.bin/xlint/lint1/ckgetopt.c:1.9
--- src/usr.bin/xlint/lint1/ckgetopt.c:1.8	Sun Apr 18 08:53:35 2021
+++ src/usr.bin/xlint/lint1/ckgetopt.c	Sun Apr 18 17:36:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ckgetopt.c,v 1.8 2021/04/18 08:53:35 rillig Exp $ */
+/* $NetBSD: ckgetopt.c,v 1.9 2021/04/18 17:36:18 rillig Exp $ */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: ckgetopt.c,v 1.8 2021/04/18 08:53:35 rillig Exp $");
+__RCSID("$NetBSD: ckgetopt.c,v 1.9 2021/04/18 17:36:18 rillig Exp $");
 #endif
 
 #include <stdbool.h>
@@ -135,7 +135,7 @@ check_unhandled_option(void)
 			continue;
 
 		/* option '%c' should be handled in the switch */
-		warning_at(338, ck.options_pos, *opt);
+		warning_at(338, &ck.options_pos, *opt);
 	}
 }
 

Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.177 src/usr.bin/xlint/lint1/decl.c:1.178
--- src/usr.bin/xlint/lint1/decl.c:1.177	Sun Apr 18 09:37:18 2021
+++ src/usr.bin/xlint/lint1/decl.c	Sun Apr 18 17:36:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.177 2021/04/18 09:37:18 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.178 2021/04/18 17:36:18 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.177 2021/04/18 09:37:18 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.178 2021/04/18 17:36:18 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -3033,7 +3033,7 @@ check_argument_usage(bool novar, sym_t *
 
 	if (!arg->s_used && vflag) {
 		/* argument '%s' unused in function '%s' */
-		warning_at(231, arg->s_def_pos, arg->s_name, funcsym->s_name);
+		warning_at(231, &arg->s_def_pos, arg->s_name, funcsym->s_name);
 	}
 }
 
@@ -3065,17 +3065,17 @@ check_variable_usage(bool novar, sym_t *
 	if (sc == EXTERN) {
 		if (!sym->s_used && !sym->s_set) {
 			/* '%s' unused in function '%s' */
-			warning_at(192, sym->s_def_pos,
+			warning_at(192, &sym->s_def_pos,
 			    sym->s_name, funcsym->s_name);
 		}
 	} else {
 		if (sym->s_set && !sym->s_used) {
 			/* '%s' set but not used in function '%s' */
-			warning_at(191, sym->s_set_pos,
+			warning_at(191, &sym->s_set_pos,
 			    sym->s_name, funcsym->s_name);
 		} else if (!sym->s_used) {
 			/* '%s' unused in function '%s' */
-			warning_at(192, sym->s_def_pos,
+			warning_at(192, &sym->s_def_pos,
 			    sym->s_name, funcsym->s_name);
 		}
 	}
@@ -3113,10 +3113,10 @@ check_label_usage(sym_t *lab)
 
 	if (lab->s_set && !lab->s_used) {
 		/* label %s unused in function %s */
-		warning_at(232, lab->s_set_pos, lab->s_name, funcsym->s_name);
+		warning_at(232, &lab->s_set_pos, lab->s_name, funcsym->s_name);
 	} else if (!lab->s_set) {
 		/* undefined label %s */
-		warning_at(23, lab->s_use_pos, lab->s_name);
+		warning_at(23, &lab->s_use_pos, lab->s_name);
 	}
 }
 
@@ -3134,15 +3134,15 @@ check_tag_usage(sym_t *sym)
 	switch (sym->s_type->t_tspec) {
 	case STRUCT:
 		/* struct %s never defined */
-		warning_at(233, sym->s_def_pos, sym->s_name);
+		warning_at(233, &sym->s_def_pos, sym->s_name);
 		break;
 	case UNION:
 		/* union %s never defined */
-		warning_at(234, sym->s_def_pos, sym->s_name);
+		warning_at(234, &sym->s_def_pos, sym->s_name);
 		break;
 	case ENUM:
 		/* enum %s never defined */
-		warning_at(235, sym->s_def_pos, sym->s_name);
+		warning_at(235, &sym->s_def_pos, sym->s_name);
 		break;
 	default:
 		lint_assert(/*CONSTCOND*/false);
@@ -3185,17 +3185,17 @@ check_unused_static_global_variable(cons
 		if (sym->s_def == DEF) {
 			if (!sym->s_inline)
 				/* static function %s unused */
-				warning_at(236, sym->s_def_pos, sym->s_name);
+				warning_at(236, &sym->s_def_pos, sym->s_name);
 		} else {
 			/* static function %s declared but not defined */
-			warning_at(290, sym->s_def_pos, sym->s_name);
+			warning_at(290, &sym->s_def_pos, sym->s_name);
 		}
 	} else if (!sym->s_set) {
 		/* static variable %s unused */
-		warning_at(226, sym->s_def_pos, sym->s_name);
+		warning_at(226, &sym->s_def_pos, sym->s_name);
 	} else {
 		/* static variable %s set but not used */
-		warning_at(307, sym->s_def_pos, sym->s_name);
+		warning_at(307, &sym->s_def_pos, sym->s_name);
 	}
 }
 
@@ -3204,7 +3204,7 @@ check_static_global_variable(const sym_t
 {
 	if (sym->s_type->t_tspec == FUNC && sym->s_used && sym->s_def != DEF) {
 		/* static function called but not defined: %s() */
-		error_at(225, sym->s_use_pos, sym->s_name);
+		error_at(225, &sym->s_use_pos, sym->s_name);
 	}
 
 	if (!sym->s_used)
@@ -3212,7 +3212,7 @@ check_static_global_variable(const sym_t
 
 	if (!tflag && sym->s_def == TDEF && sym->s_type->t_const) {
 		/* const object %s should have initializer */
-		warning_at(227, sym->s_def_pos, sym->s_name);
+		warning_at(227, &sym->s_def_pos, sym->s_name);
 	}
 }
 
@@ -3258,10 +3258,10 @@ check_global_variable_size(const sym_t *
 	    sym->s_type->t_tspec == ARRAY && sym->s_type->t_dim == 0) {
 		if (tflag || (sym->s_scl == EXTERN && !sflag)) {
 			/* empty array declaration: %s */
-			warning_at(190, sym->s_def_pos, sym->s_name);
+			warning_at(190, &sym->s_def_pos, sym->s_name);
 		} else {
 			/* empty array declaration: %s */
-			error_at(190, sym->s_def_pos, sym->s_name);
+			error_at(190, &sym->s_def_pos, sym->s_name);
 		}
 	}
 }
@@ -3277,13 +3277,13 @@ print_previous_declaration(int msg, cons
 		return;
 
 	if (msg != -1) {
-		(message_at)(msg, psym->s_def_pos);
+		(message_at)(msg, &psym->s_def_pos);
 	} else if (psym->s_def == DEF || psym->s_def == TDEF) {
 		/* previous definition of %s */
-		message_at(261, psym->s_def_pos, psym->s_name);
+		message_at(261, &psym->s_def_pos, psym->s_name);
 	} else {
 		/* previous declaration of %s */
-		message_at(260, psym->s_def_pos, psym->s_name);
+		message_at(260, &psym->s_def_pos, psym->s_name);
 	}
 }
 

Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.115 src/usr.bin/xlint/lint1/err.c:1.116
--- src/usr.bin/xlint/lint1/err.c:1.115	Sun Apr 18 10:09:49 2021
+++ src/usr.bin/xlint/lint1/err.c	Sun Apr 18 17:36:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: err.c,v 1.115 2021/04/18 10:09:49 rillig Exp $	*/
+/*	$NetBSD: err.c,v 1.116 2021/04/18 17:36:18 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.115 2021/04/18 10:09:49 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.116 2021/04/18 17:36:18 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -484,15 +484,15 @@ lbasename(const char *path)
 }
 
 static void
-verror_at(int msgid, pos_t pos, va_list ap)
+verror_at(int msgid, const pos_t *pos, va_list ap)
 {
 	const	char *fn;
 
 	if (ERR_ISSET(msgid, &msgset))
 		return;
 
-	fn = lbasename(pos.p_file);
-	(void)printf("%s(%d): error: ", fn, pos.p_line);
+	fn = lbasename(pos->p_file);
+	(void)printf("%s(%d): error: ", fn, pos->p_line);
 	(void)vprintf(msgs[msgid], ap);
 	(void)printf(" [%d]\n", msgid);
 	nerr++;
@@ -500,7 +500,7 @@ verror_at(int msgid, pos_t pos, va_list 
 }
 
 static void
-vwarning_at(int msgid, pos_t pos, va_list ap)
+vwarning_at(int msgid, const pos_t *pos, va_list ap)
 {
 	const	char *fn;
 
@@ -514,8 +514,8 @@ vwarning_at(int msgid, pos_t pos, va_lis
 		/* this warning is suppressed by a LINTED comment */
 		return;
 
-	fn = lbasename(pos.p_file);
-	(void)printf("%s(%d): warning: ", fn, pos.p_line);
+	fn = lbasename(pos->p_file);
+	(void)printf("%s(%d): warning: ", fn, pos->p_line);
 	(void)vprintf(msgs[msgid], ap);
 	(void)printf(" [%d]\n", msgid);
 	if (wflag)
@@ -524,22 +524,22 @@ vwarning_at(int msgid, pos_t pos, va_lis
 }
 
 static void
-vmessage_at(int msgid, pos_t pos, va_list ap)
+vmessage_at(int msgid, const pos_t *pos, va_list ap)
 {
 	const char *fn;
 
 	if (ERR_ISSET(msgid, &msgset))
 		return;
 
-	fn = lbasename(pos.p_file);
-	(void)printf("%s(%d): ", fn, pos.p_line);
+	fn = lbasename(pos->p_file);
+	(void)printf("%s(%d): ", fn, pos->p_line);
 	(void)vprintf(msgs[msgid], ap);
 	(void)printf(" [%d]\n", msgid);
 	print_stack_trace();
 }
 
 void
-(error_at)(int msgid, pos_t pos, ...)
+(error_at)(int msgid, const pos_t *pos, ...)
 {
 	va_list	ap;
 
@@ -554,7 +554,7 @@ void
 	va_list	ap;
 
 	va_start(ap, msgid);
-	verror_at(msgid, curr_pos, ap);
+	verror_at(msgid, &curr_pos, ap);
 	va_end(ap);
 }
 
@@ -589,7 +589,7 @@ assert_failed(const char *file, int line
 }
 
 void
-(warning_at)(int msgid, pos_t pos, ...)
+(warning_at)(int msgid, const pos_t *pos, ...)
 {
 	va_list	ap;
 
@@ -604,12 +604,12 @@ void
 	va_list	ap;
 
 	va_start(ap, msgid);
-	vwarning_at(msgid, curr_pos, ap);
+	vwarning_at(msgid, &curr_pos, ap);
 	va_end(ap);
 }
 
 void
-(message_at)(int msgid, pos_t pos, ...)
+(message_at)(int msgid, const pos_t *pos, ...)
 {
 	va_list ap;
 
@@ -624,7 +624,7 @@ void
 	va_list	ap;
 
 	va_start(ap, msgid);
-	vmessage_at(msgid, curr_pos, ap);
+	vmessage_at(msgid, &curr_pos, ap);
 	va_end(ap);
 }
 
@@ -642,9 +642,9 @@ void
 
 	va_start(ap, msgid);
 	if (sflag && !extensions_ok) {
-		verror_at(msgid, curr_pos, ap);
+		verror_at(msgid, &curr_pos, ap);
 	} else if (sflag || !extensions_ok) {
-		vwarning_at(msgid, curr_pos, ap);
+		vwarning_at(msgid, &curr_pos, ap);
 	}
 	va_end(ap);
 }
@@ -657,7 +657,7 @@ void
 	if (c11flag || gflag)
 		return;
 	va_start(ap, msgid);
-	verror_at(msgid, curr_pos, ap);
+	verror_at(msgid, &curr_pos, ap);
 	va_end(ap);
 }
 
@@ -668,9 +668,9 @@ void
 
 	va_start(ap, msgid);
 	if (sflag && !gflag) {
-		verror_at(msgid, curr_pos, ap);
+		verror_at(msgid, &curr_pos, ap);
 	} else if (sflag || !gflag) {
-		vwarning_at(msgid, curr_pos, ap);
+		vwarning_at(msgid, &curr_pos, ap);
 	}
 	va_end(ap);
 }

Index: src/usr.bin/xlint/lint1/externs1.h
diff -u src/usr.bin/xlint/lint1/externs1.h:1.107 src/usr.bin/xlint/lint1/externs1.h:1.108
--- src/usr.bin/xlint/lint1/externs1.h:1.107	Sun Apr 18 08:52:04 2021
+++ src/usr.bin/xlint/lint1/externs1.h	Sun Apr 18 17:36:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs1.h,v 1.107 2021/04/18 08:52:04 rillig Exp $	*/
+/*	$NetBSD: externs1.h,v 1.108 2021/04/18 17:36:18 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -120,9 +120,9 @@ extern	int	sytxerr;
 extern	const char *const msgs[];
 
 extern	void	msglist(void);
-extern	void	error_at(int, pos_t, ...);
-extern	void	warning_at(int, pos_t, ...);
-extern	void	message_at(int, pos_t, ...);
+extern	void	error_at(int, const pos_t *, ...);
+extern	void	warning_at(int, const pos_t *, ...);
+extern	void	message_at(int, const pos_t *, ...);
 extern	void	error(int, ...);
 extern	void	warning(int, ...);
 extern	void	message(int, ...);

Index: src/usr.bin/xlint/lint1/func.c
diff -u src/usr.bin/xlint/lint1/func.c:1.104 src/usr.bin/xlint/lint1/func.c:1.105
--- src/usr.bin/xlint/lint1/func.c:1.104	Sun Apr 18 09:39:53 2021
+++ src/usr.bin/xlint/lint1/func.c	Sun Apr 18 17:36:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: func.c,v 1.104 2021/04/18 09:39:53 rillig Exp $	*/
+/*	$NetBSD: func.c,v 1.105 2021/04/18 17:36:18 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: func.c,v 1.104 2021/04/18 09:39:53 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.105 2021/04/18 17:36:18 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -1088,28 +1088,28 @@ global_clean_up_decl(bool silent)
 	if (nargusg != -1) {
 		if (!silent) {
 			/* must precede function definition: ** %s ** */
-			warning_at(282, argsused_pos, "ARGSUSED");
+			warning_at(282, &argsused_pos, "ARGSUSED");
 		}
 		nargusg = -1;
 	}
 	if (nvararg != -1) {
 		if (!silent) {
 			/* must precede function definition: ** %s ** */
-			warning_at(282, vapos, "VARARGS");
+			warning_at(282, &vapos, "VARARGS");
 		}
 		nvararg = -1;
 	}
 	if (printflike_argnum != -1) {
 		if (!silent) {
 			/* must precede function definition: ** %s ** */
-			warning_at(282, printflike_pos, "PRINTFLIKE");
+			warning_at(282, &printflike_pos, "PRINTFLIKE");
 		}
 		printflike_argnum = -1;
 	}
 	if (scanflike_argnum != -1) {
 		if (!silent) {
 			/* must precede function definition: ** %s ** */
-			warning_at(282, scanflike_pos, "SCANFLIKE");
+			warning_at(282, &scanflike_pos, "SCANFLIKE");
 		}
 		scanflike_argnum = -1;
 	}

Reply via email to