Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 lint: unclutter debug logging for nodes



details:   https://anonhg.NetBSD.org/src/rev/aab063ca980c
branches:  trunk
changeset: 372963:aab063ca980c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jan 08 14:05:02 2023 +0000

description:
lint: unclutter debug logging for nodes

No functional change.

diffstat:

 usr.bin/xlint/lint1/debug.c |  64 ++++++++++++++++++++++++--------------------
 1 files changed, 35 insertions(+), 29 deletions(-)

diffs (86 lines):

diff -r 692855aaa7df -r aab063ca980c usr.bin/xlint/lint1/debug.c
--- a/usr.bin/xlint/lint1/debug.c       Sun Jan 08 12:00:21 2023 +0000
+++ b/usr.bin/xlint/lint1/debug.c       Sun Jan 08 14:05:02 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: debug.c,v 1.23 2022/07/16 22:23:38 rillig Exp $ */
+/* $NetBSD: debug.c,v 1.24 2023/01/08 14:05:02 rillig Exp $ */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: debug.c,v 1.23 2022/07/16 22:23:38 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.24 2023/01/08 14:05:02 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -165,34 +165,40 @@
        if (tn->tn_sys)
                debug_printf(", sys");
 
-       if (op == NAME)
+       switch (op) {
+       case NAME:
                debug_printf("\n");
-       else if (op == CON && is_floating(tn->tn_type->t_tspec))
-               debug_printf(", value %Lg\n", tn->tn_val->v_ldbl);
-       else if (op == CON && is_uinteger(tn->tn_type->t_tspec))
-               debug_printf(", value %llu\n",
-                   (unsigned long long)tn->tn_val->v_quad);
-       else if (op == CON && is_integer(tn->tn_type->t_tspec))
-               debug_printf(", value %lld\n",
-                   (long long)tn->tn_val->v_quad);
-       else if (op == CON && tn->tn_type->t_tspec == BOOL)
-               debug_printf(", value %s\n",
-                   tn->tn_val->v_quad != 0 ? "true" : "false");
-       else if (op == CON)
-               debug_printf(", unknown value\n");
-       else if (op == STRING && tn->tn_string->st_char)
-               debug_printf(", length %zu, \"%s\"\n",
-                   tn->tn_string->st_len,
-                   (const char *)tn->tn_string->st_mem);
-       else if (op == STRING) {
-               size_t n = MB_CUR_MAX * (tn->tn_string->st_len + 1);
-               char *s = xmalloc(n);
-               (void)wcstombs(s, tn->tn_string->st_mem, n);
-               debug_printf(", length %zu, L\"%s\"\n",
-                   tn->tn_string->st_len, s);
-               free(s);
-
-       } else {
+               break;
+       case CON:
+               if (is_floating(tn->tn_type->t_tspec))
+                       debug_printf(", value %Lg\n", tn->tn_val->v_ldbl);
+               else if (is_uinteger(tn->tn_type->t_tspec))
+                       debug_printf(", value %llu\n",
+                           (unsigned long long)tn->tn_val->v_quad);
+               else if (is_integer(tn->tn_type->t_tspec))
+                       debug_printf(", value %lld\n",
+                           (long long)tn->tn_val->v_quad);
+               else if (tn->tn_type->t_tspec == BOOL)
+                       debug_printf(", value %s\n",
+                           tn->tn_val->v_quad != 0 ? "true" : "false");
+               else
+                       debug_printf(", unknown value\n");
+               break;
+       case STRING:
+               if (tn->tn_string->st_char)
+                       debug_printf(", length %zu, \"%s\"\n",
+                           tn->tn_string->st_len,
+                           (const char *)tn->tn_string->st_mem);
+               else {
+                       size_t n = MB_CUR_MAX * (tn->tn_string->st_len + 1);
+                       char *s = xmalloc(n);
+                       (void)wcstombs(s, tn->tn_string->st_mem, n);
+                       debug_printf(", length %zu, L\"%s\"\n",
+                           tn->tn_string->st_len, s);
+                       free(s);
+               }
+               break;
+       default:
                debug_printf("\n");
 
                debug_indent_inc();



Home | Main Index | Thread Index | Old Index