]> git.puffer.fish Git - matthieu/frr.git/commitdiff
tools/gcc-plugins: don't crash on array parameters
authorDavid Lamparter <equinox@opensourcerouting.org>
Tue, 15 Oct 2024 11:28:41 +0000 (13:28 +0200)
committerDavid Lamparter <equinox@opensourcerouting.org>
Tue, 15 Oct 2024 11:35:24 +0000 (13:35 +0200)
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 <equinox@opensourcerouting.org>
tools/gcc-plugins/frr-format.c

index 963741e4798fd166120651561ab3720cecc12edc..d9e38f62cae46a50bb82ae8dfae76585ed68ea61 100644 (file)
@@ -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.  */