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 11, 1:17 AM
Unknown Object (File)
Fri, Oct 10, 3:50 AM
Unknown Object (File)
Sun, Oct 5, 4:45 AM
Unknown Object (File)
Sat, Sep 27, 4:34 PM
Unknown Object (File)
Sep 15 2025, 8:19 AM
Unknown Object (File)
Sep 12 2025, 10:24 PM
Unknown Object (File)
Aug 29 2025, 5:41 AM
Unknown Object (File)
Aug 26 2025, 5:00 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.