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)
Feb 10 2024, 9:37 PM
Unknown Object (File)
Feb 2 2024, 10:50 PM
Unknown Object (File)
Dec 20 2023, 11:12 AM
Unknown Object (File)
Dec 20 2023, 2:51 AM
Unknown Object (File)
Dec 2 2023, 3:11 PM
Unknown Object (File)
Sep 2 2023, 9:50 PM
Unknown Object (File)
Sep 2 2023, 9:31 PM
Unknown Object (File)
Sep 2 2023, 9:30 PM
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.