On Tue, 20 Dec 2022 23:44:08 +0100, Patrick Wildt wrote:

> clang complains when the function is declared with a fixed array size in
> a parameter while the prototype is unbounded, like this:
>
> /usr/src/sys/net/pf.c:4353:54: error: argument 'sns' of type 'struct pf_src_n
> ode *[4]' with mismatched bound [-Werror,-Warray-parameter]
>     struct pf_rule_actions *act, struct pf_src_node *sns[PF_SN_MAX])
>                                                      ^
> /usr/src/sys/net/pf.c:203:28: note: previously declared as 'struct pf_src_nod
> e *[]' here
>                             struct pf_src_node *[]);
>                                                 ^
> 1 error generated.
>
> We have a few of that, and was wondering what the better solution is.
> clang apparently accepts using * instead of [].  The alternative would
> be to hardcode the size in the prototype as well.  Here's a diff for
> a three files for the first version, as example.

Using * instead of [] is the saner approach.  Hard-coding the sizes
into the prototype seems like a bad idea, even if clang is now smart
enough to complain about a mismatch.

 - todd

Reply via email to