From 070ce19d0cb8078f0a7f8df0fa95be36c5ae2f42 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Tue, 15 Oct 2024 13:28:41 +0200 Subject: [PATCH] tools/gcc-plugins: don't crash on array parameters Need to have arrays as a stop condition in this type normalization function, like pointers and function pointers. Actual arrays as argument types are extremely rare to see because C has this array-decay-to-pointer thing, but it can happen. Signed-off-by: David Lamparter --- tools/gcc-plugins/frr-format.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/gcc-plugins/frr-format.c b/tools/gcc-plugins/frr-format.c index 963741e479..d9e38f62ca 100644 --- a/tools/gcc-plugins/frr-format.c +++ b/tools/gcc-plugins/frr-format.c @@ -2685,7 +2685,8 @@ tree type_normalize (tree type, tree *cousin, tree target = NULL) { while (1) { - if (TREE_CODE (type) == FUNCTION_TYPE || TREE_CODE (type) == POINTER_TYPE) + if (TREE_CODE (type) == FUNCTION_TYPE || TREE_CODE (type) == POINTER_TYPE + || TREE_CODE (type) == ARRAY_TYPE) return type; if (target) /* Strip off any "const" etc. */