Page MenuHomeFreeBSD

vnet: make VNET_FOREACH() always be a loop
ClosedPublic

Authored by kp on Jul 6 2022, 8:21 PM.
Tags
None
Referenced Files
Unknown Object (File)
May 10 2024, 4:41 AM
Unknown Object (File)
Feb 20 2024, 5:31 PM
Unknown Object (File)
Jan 31 2024, 5:16 AM
Unknown Object (File)
Dec 20 2023, 7:29 AM
Unknown Object (File)
Oct 17 2023, 2:50 AM
Unknown Object (File)
Sep 10 2023, 5:28 PM
Unknown Object (File)
Aug 22 2023, 11:36 PM
Unknown Object (File)
Jul 8 2023, 12:08 PM

Details

Summary

VNET_FOREACH() is a LIST_FOREACH if VIMAGE is set, but empty if it's
not. This means that users of the macro couldn't use 'continue' or
'break' as one would expect of a loop.

Change VNET_FOREACH() to be a loop in all cases (although one that is
fixed to one iteration if VIMAGE is not set).

Sponsored by: Rubicon Communications, LLC ("Netgate")

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kp requested review of this revision.Jul 6 2022, 8:21 PM

I wonder if compiler removes the loop and produces same code after the change.

This revision is now accepted and ready to land.Jul 6 2022, 8:28 PM

I wonder if compiler removes the loop and produces same code after the change.

It does, yes, so this is a no-op, other than making the loop work the way a reader would expect it to, regardless of VIMAGE or ! VIMAGE.

This revision was automatically updated to reflect the committed changes.