Module Name:    src
Committed By:   rillig
Date:           Sat Jul 31 19:07:52 UTC 2021

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

Log Message:
lint: clean up debug logging

The calls to debug_step, unlike printf, don't need a trailing newline.

Remove the debug_step0 macro and its relatives since lint already uses
enough other features from C99 that it essentially requires this
standard, which supports varargs macro arguments.  Among these features
are __func__ and printf("%zu").

In non-debug mode, do not evaluate the arguments of debug_step.
Evaluating the arguments had caused an internal error when running the
test op_shl_lp64.  This is indeed a bug since initdecl should have
initialized the type table for __uint128_t.  This had been forgotten
when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.212 -r1.213 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.131 -r1.132 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.124 -r1.125 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.116 -r1.117 src/usr.bin/xlint/lint1/func.c
cvs rdiff -u -r1.205 -r1.206 src/usr.bin/xlint/lint1/init.c
cvs rdiff -u -r1.57 -r1.58 src/usr.bin/xlint/lint1/lex.c
cvs rdiff -u -r1.49 -r1.50 src/usr.bin/xlint/lint1/main1.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.212 src/usr.bin/xlint/lint1/decl.c:1.213
--- src/usr.bin/xlint/lint1/decl.c:1.212	Sat Jul 31 17:09:21 2021
+++ src/usr.bin/xlint/lint1/decl.c	Sat Jul 31 19:07:52 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.212 2021/07/31 17:09:21 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.213 2021/07/31 19:07:52 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.212 2021/07/31 17:09:21 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.213 2021/07/31 19:07:52 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -289,9 +289,8 @@ void
 add_type(type_t *tp)
 {
 	tspec_t	t;
-#ifdef DEBUG
-	printf("%s: %s\n", __func__, type_name(tp));
-#endif
+
+	debug_step("%s: %s", __func__, type_name(tp));
 	if (tp->t_typedef) {
 		/*
 		 * something like "typedef int a; int a b;"
@@ -801,9 +800,7 @@ dcs_merge_declaration_specifiers(void)
 	l = dcs->d_rank_mod;	/* SHORT, LONG or QUAD */
 	tp = dcs->d_type;
 
-#ifdef DEBUG
-	printf("%s: %s\n", __func__, type_name(tp));
-#endif
+	debug_step("%s: %s", __func__, type_name(tp));
 	if (t == NOTSPEC && s == NOTSPEC && l == NOTSPEC && c == NOTSPEC &&
 	    tp == NULL)
 		dcs->d_notyp = true;
@@ -3011,17 +3008,13 @@ check_usage(dinfo_t *di)
 	mklwarn = lwarn;
 	lwarn = LWARN_ALL;
 
-#ifdef DEBUG
-	printf("%s, %d: >temp lwarn = %d\n", curr_pos.p_file, curr_pos.p_line,
-	    lwarn);
-#endif
+	debug_step("%s, %d: >temp lwarn = %d",
+	    curr_pos.p_file, curr_pos.p_line, lwarn);
 	for (sym = di->d_dlsyms; sym != NULL; sym = sym->s_dlnxt)
 		check_usage_sym(di->d_asm, sym);
 	lwarn = mklwarn;
-#ifdef DEBUG
-	printf("%s, %d: <temp lwarn = %d\n", curr_pos.p_file, curr_pos.p_line,
-	    lwarn);
-#endif
+	debug_step("%s, %d: <temp lwarn = %d",
+	    curr_pos.p_file, curr_pos.p_line, lwarn);
 }
 
 /*

Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.131 src/usr.bin/xlint/lint1/err.c:1.132
--- src/usr.bin/xlint/lint1/err.c:1.131	Sun Jul 25 10:39:10 2021
+++ src/usr.bin/xlint/lint1/err.c	Sat Jul 31 19:07:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: err.c,v 1.131 2021/07/25 10:39:10 rillig Exp $	*/
+/*	$NetBSD: err.c,v 1.132 2021/07/31 19:07:52 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.131 2021/07/25 10:39:10 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.132 2021/07/31 19:07:52 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -511,9 +511,7 @@ vwarning_at(int msgid, const pos_t *pos,
 	if (ERR_ISSET(msgid, &msgset))
 		return;
 
-#ifdef DEBUG
-	printf("%s: lwarn=%d msgid=%d\n", __func__, lwarn, msgid);
-#endif
+	debug_step("%s: lwarn=%d msgid=%d", __func__, lwarn, msgid);
 	if (lwarn == LWARN_NONE || lwarn == msgid)
 		/* this warning is suppressed by a LINTED comment */
 		return;

Index: src/usr.bin/xlint/lint1/externs1.h
diff -u src/usr.bin/xlint/lint1/externs1.h:1.124 src/usr.bin/xlint/lint1/externs1.h:1.125
--- src/usr.bin/xlint/lint1/externs1.h:1.124	Sat Jul 31 18:16:42 2021
+++ src/usr.bin/xlint/lint1/externs1.h	Sat Jul 31 19:07:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs1.h,v 1.124 2021/07/31 18:16:42 rillig Exp $	*/
+/*	$NetBSD: externs1.h,v 1.125 2021/07/31 19:07:52 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -123,27 +123,20 @@ void	debug_indent_inc(void);
 void	debug_indent_dec(void);
 void	debug_enter(const char *);
 void	debug_step(const char *fmt, ...) __printflike(1, 2);
-#define	debug_step0		debug_step
-#define	debug_step1		debug_step
-#define	debug_step2		debug_step
 void	debug_leave(const char *);
 #define	debug_enter()		(debug_enter)(__func__)
 #define	debug_leave()		(debug_leave)(__func__)
 #else
 #define	debug_noop()		do { } while (false)
-#define	debug_node(tn, indent) debug_noop()
-/* ARGSUSED */
-static inline void __printflike(1, 2) debug_printf(const char *fmt, ...) {}
-#define debug_indent()		debug_noop()
-/* ARGSUSED */
+#define	debug_node(tn, indent)	debug_noop()
+#define	debug_printf(...)	debug_noop()
+#define	debug_indent()		debug_noop()
 static inline void __printflike(1, 2) debug_step(const char *fmt, ...) {}
+/*#define	debug_step(...)		debug_noop()*/
 #define	debug_indent()		debug_noop()
 #define	debug_indent_inc()	debug_noop()
 #define	debug_indent_dec()	debug_noop()
 #define	debug_enter()		debug_noop()
-#define	debug_step0(fmt)	debug_noop()
-#define	debug_step1(fmt, arg0)	debug_noop()
-#define	debug_step2(fmt, arg1, arg2) debug_noop()
 #define	debug_leave()		debug_noop()
 #endif
 

Index: src/usr.bin/xlint/lint1/func.c
diff -u src/usr.bin/xlint/lint1/func.c:1.116 src/usr.bin/xlint/lint1/func.c:1.117
--- src/usr.bin/xlint/lint1/func.c:1.116	Sat Jul 31 11:03:04 2021
+++ src/usr.bin/xlint/lint1/func.c	Sat Jul 31 19:07:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: func.c,v 1.116 2021/07/31 11:03:04 rillig Exp $	*/
+/*	$NetBSD: func.c,v 1.117 2021/07/31 19:07:52 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.116 2021/07/31 11:03:04 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.117 2021/07/31 19:07:52 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -192,11 +192,10 @@ end_control_statement(control_statement_
 static void
 set_reached(bool new_reached)
 {
-#ifdef DEBUG
-	printf("%s:%d: %s -> %s\n", curr_pos.p_file, curr_pos.p_line,
+	debug_step("%s:%d: %s -> %s",
+	    curr_pos.p_file, curr_pos.p_line,
 	    reached ? "reachable" : "unreachable",
 	    new_reached ? "reachable" : "unreachable");
-#endif
 	reached = new_reached;
 	warn_about_unreachable = true;
 }
@@ -1328,9 +1327,8 @@ void
 linted(int n)
 {
 
-#ifdef DEBUG
-	printf("%s, %d: lwarn = %d\n", curr_pos.p_file, curr_pos.p_line, n);
-#endif
+	debug_step("%s, %d: lwarn = %d",
+	    curr_pos.p_file, curr_pos.p_line, n);
 	lwarn = n;
 }
 
@@ -1342,10 +1340,8 @@ void
 bitfieldtype(int n)
 {
 
-#ifdef DEBUG
-	printf("%s, %d: bitfieldtype_ok = true\n", curr_pos.p_file,
-	    curr_pos.p_line);
-#endif
+	debug_step("%s, %d: bitfieldtype_ok = true",
+	    curr_pos.p_file, curr_pos.p_line);
 	bitfieldtype_ok = true;
 }
 

Index: src/usr.bin/xlint/lint1/init.c
diff -u src/usr.bin/xlint/lint1/init.c:1.205 src/usr.bin/xlint/lint1/init.c:1.206
--- src/usr.bin/xlint/lint1/init.c:1.205	Sat Jul 31 18:16:42 2021
+++ src/usr.bin/xlint/lint1/init.c	Sat Jul 31 19:07:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: init.c,v 1.205 2021/07/31 18:16:42 rillig Exp $	*/
+/*	$NetBSD: init.c,v 1.206 2021/07/31 19:07:52 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.205 2021/07/31 18:16:42 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.206 2021/07/31 19:07:52 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -346,7 +346,7 @@ check_init_expr(const type_t *tp, sym_t 
 	lt = ln->tn_type->t_tspec;
 	rt = tn->tn_type->t_tspec;
 
-	debug_step2("typeok '%s', '%s'",
+	debug_step("typeok '%s', '%s'",
 	    type_name(ln->tn_type), type_name(tn->tn_type));
 	if (!typeok(INIT, 0, ln, tn))
 		return;
@@ -828,7 +828,7 @@ initialization_expr_using_assign(struct 
 	if (in->in_sym->s_type->t_tspec == ARRAY)
 		return false;
 
-	debug_step0("handing over to ASSIGN");
+	debug_step("handing over to ASSIGN");
 
 	ln = build_name(in->in_sym, 0);
 	ln->tn_type = expr_unqualified_type(ln->tn_type);
@@ -929,7 +929,7 @@ initialization_expr(struct initializatio
 		goto done;
 	}
 
-	debug_step2("expecting '%s', expression has '%s'",
+	debug_step("expecting '%s', expression has '%s'",
 	    type_name(tp), type_name(tn->tn_type));
 	check_init_expr(tp, in->in_sym, tn);
 
@@ -968,7 +968,7 @@ begin_initialization(sym_t *sym)
 {
 	struct initialization *in;
 
-	debug_step1("begin initialization of '%s'", type_name(sym->s_type));
+	debug_step("begin initialization of '%s'", type_name(sym->s_type));
 	debug_indent_inc();
 
 	in = initialization_new(sym);
@@ -986,7 +986,7 @@ end_initialization(void)
 	initialization_free(in);
 
 	debug_indent_dec();
-	debug_step0("end initialization");
+	debug_step("end initialization");
 }
 
 void

Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.57 src/usr.bin/xlint/lint1/lex.c:1.58
--- src/usr.bin/xlint/lint1/lex.c:1.57	Sat Jul 31 13:47:19 2021
+++ src/usr.bin/xlint/lint1/lex.c	Sat Jul 31 19:07:52 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.57 2021/07/31 13:47:19 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.58 2021/07/31 19:07:52 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: lex.c,v 1.57 2021/07/31 13:47:19 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.58 2021/07/31 19:07:52 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -82,9 +82,7 @@ lex_next_line(void)
 {
 	curr_pos.p_line++;
 	curr_pos.p_uniq = 0;
-#ifdef DEBUG
-	printf("parsing %s:%d\n", curr_pos.p_file, curr_pos.p_line);
-#endif
+	debug_step("parsing %s:%d", curr_pos.p_file, curr_pos.p_line);
 	if (curr_pos.p_file == csrc_pos.p_file) {
 		csrc_pos.p_line++;
 		csrc_pos.p_uniq = 0;

Index: src/usr.bin/xlint/lint1/main1.c
diff -u src/usr.bin/xlint/lint1/main1.c:1.49 src/usr.bin/xlint/lint1/main1.c:1.50
--- src/usr.bin/xlint/lint1/main1.c:1.49	Sun Jul  4 05:49:20 2021
+++ src/usr.bin/xlint/lint1/main1.c	Sat Jul 31 19:07:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main1.c,v 1.49 2021/07/04 05:49:20 rillig Exp $	*/
+/*	$NetBSD: main1.c,v 1.50 2021/07/31 19:07:52 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: main1.c,v 1.49 2021/07/04 05:49:20 rillig Exp $");
+__RCSID("$NetBSD: main1.c,v 1.50 2021/07/31 19:07:52 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -284,9 +284,8 @@ main(int argc, char *argv[])
 
 	/* Following warnings cannot be suppressed by LINTED */
 	lwarn = LWARN_ALL;
-#ifdef DEBUG
-	printf("%s, %d: lwarn = %d\n", curr_pos.p_file, curr_pos.p_line, lwarn);
-#endif
+	debug_step("%s, %d: lwarn = %d",
+	    curr_pos.p_file, curr_pos.p_line, lwarn);
 
 	check_global_symbols();
 

Reply via email to