Page MenuHomeFreeBSD

mlx5: Fix mismatch in array bounds.
ClosedPublic

Authored by jhb on Nov 29 2022, 7:58 PM.
Tags
None
Referenced Files
F102694909: D37549.diff
Fri, Nov 15, 11:23 PM
Unknown Object (File)
Oct 6 2024, 11:53 PM
Unknown Object (File)
Sep 27 2024, 5:29 PM
Unknown Object (File)
Sep 25 2024, 10:17 PM
Unknown Object (File)
Sep 22 2024, 7:30 PM
Unknown Object (File)
Sep 22 2024, 6:16 PM
Unknown Object (File)
Sep 21 2024, 2:50 PM
Unknown Object (File)
Sep 21 2024, 5:35 AM
Subscribers

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 48641
Build 45527: arc lint + arc unit

Event Timeline

Hmmm, maybe be a little more expansive on the commit message. Why do we need to do this?

This revision is now accepted and ready to land.Nov 29 2022, 8:23 PM

GCC warns when the function definition and prototype do not agree on array bounds. Here the function prototype in vport.h is:

int mlx5_modify_nic_vport_mac_address(struct mlx5_core_dev *dev,
				      u16 vport, u8 mac[ETH_ALEN]);

Now, it may be that the prototype should be fixed instead because in the surrounding context, the other functions use pointers:

int mlx5_query_nic_vport_mac_address(struct mlx5_core_dev *mdev,
				     u16 vport, u8 *addr);
int mlx5_modify_nic_vport_mac_address(struct mlx5_core_dev *dev,
				      u16 vport, u8 mac[ETH_ALEN]);
int mlx5_set_nic_vport_current_mac(struct mlx5_core_dev *mdev, int vport,
				   bool other_vport, u8 *addr);

I think the reason the compiler cares is that the compiler can make optimization assumptions based on explicit array bounds. I think that the danger there is more the opposite case though where the function has a fixed bound and the prototype is missing the bounds, but GCC warns about any mismatch. It's easier to just fix these nits than to shut up the warning IMO.

But I will probably wait to see what Hans thinks though as in this case it's probably more consistent to patch the prototype in vport.h to use a pointer I think,

Just make sure the prototype and the implementation are identical. Also MFC this to 13 and 12 stable.

This revision now requires review to proceed.Dec 7 2022, 8:28 PM
This revision was not accepted when it landed; it landed in state Needs Review.Dec 7 2022, 8:34 PM
This revision was automatically updated to reflect the committed changes.