Module Name: src Committed By: rillig Date: Sun Feb 28 02:37:04 UTC 2021
Modified Files: src/usr.bin/xlint/common: tyname.c Log Message: lint: extract type_name_of_array from type_name No functional change. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/usr.bin/xlint/common/tyname.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/common/tyname.c diff -u src/usr.bin/xlint/common/tyname.c:1.32 src/usr.bin/xlint/common/tyname.c:1.33 --- src/usr.bin/xlint/common/tyname.c:1.32 Sun Feb 28 02:29:28 2021 +++ src/usr.bin/xlint/common/tyname.c Sun Feb 28 02:37:04 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tyname.c,v 1.32 2021/02/28 02:29:28 rillig Exp $ */ +/* $NetBSD: tyname.c,v 1.33 2021/02/28 02:37:04 rillig Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tyname.c,v 1.32 2021/02/28 02:29:28 rillig Exp $"); +__RCSID("$NetBSD: tyname.c,v 1.33 2021/02/28 02:37:04 rillig Exp $"); #endif #include <limits.h> @@ -314,6 +314,23 @@ type_name_of_enum(buffer *buf, const typ #endif } +static void +type_name_of_array(buffer *buf, const type_t *tp) +{ + buf_add(buf, " of "); + buf_add(buf, type_name(tp->t_subt)); + buf_add(buf, "["); +#ifdef t_str /* lint1 */ + if (tp->t_incomplete_array) + buf_add(buf, "unknown_size"); + else + buf_add_int(buf, tp->t_dim); +#else + buf_add_int(buf, tp->t_dim); +#endif + buf_add(buf, "]"); +} + const char * type_name(const type_t *tp) { @@ -379,23 +396,11 @@ type_name(const type_t *tp) type_name_of_struct_or_union(&buf, tp); break; case ARRAY: - buf_add(&buf, " of "); - buf_add(&buf, type_name(tp->t_subt)); - buf_add(&buf, "["); -#ifdef t_str /* lint1 */ - if (tp->t_incomplete_array) - buf_add(&buf, "unknown_size"); - else - buf_add_int(&buf, tp->t_dim); -#else - buf_add_int(&buf, tp->t_dim); -#endif - buf_add(&buf, "]"); + type_name_of_array(&buf, tp); break; case FUNC: type_name_of_function(&buf, tp); break; - default: LERROR("type_name(%d)", t); }