Page MenuHomeFreeBSD

if_media.c SIOCGMEDIAX handler: improve loop
ClosedPublic

Authored by kib on Nov 3 2020, 12:20 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Oct 25, 12:03 PM
Unknown Object (File)
Fri, Oct 24, 1:03 AM
Unknown Object (File)
Wed, Oct 22, 10:41 PM
Unknown Object (File)
Wed, Oct 22, 1:56 PM
Unknown Object (File)
Wed, Oct 22, 1:16 AM
Unknown Object (File)
Tue, Oct 21, 1:42 PM
Unknown Object (File)
Oct 11 2025, 1:17 AM
Unknown Object (File)
Oct 10 2025, 3:50 AM
Subscribers

Details

Summary

Stop advancing counter past the current iteration number at the start of iteration. This removes the need of subtracting one when calculating index for copyout, and arguably fixes off-by-one reporting of copied out elements when copyout failed.

Sponsored by: Mellanox Technologies / NVidia Networking

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Nov 3 2020, 12:20 PM
sys/net/if_media.c
312 ↗(On Diff #79124)

I think this if should just read:

if (ep == NULL)

--HPS

sys/net/if_media.c
312 ↗(On Diff #79124)

if (ep == NULL && i > ifm->ifm_count)

This revision is now accepted and ready to land.Nov 3 2020, 12:47 PM
sys/net/if_media.c
312 ↗(On Diff #79124)

Do you suggest that this would make any functional change ? I believe it is not, and for me using counters for both sides of 'and' is somewhat cleaner.

sys/net/if_media.c
312 ↗(On Diff #79124)

No, it doesn't make any functional change. It just took some time to understand the code. Maybe that if (error != 0) break, should be a goto, because the if (error == 0) is then a NOP. Anyways, I've also accepted the current version.

This revision was automatically updated to reflect the committed changes.