Skip to content

Commit c82299f

Browse files
kuba-mooPaolo Abeni
authored andcommitted
docs: netdev: document guidance on cleanup.h
Document what was discussed multiple times on list and various virtual / in-person conversations. guard() being okay in functions <= 20 LoC is a bit of my own invention. If the function is trivial it should be fine, but feel free to disagree :) We'll obviously revisit this guidance as time passes and we and other subsystems get more experience. Reviewed-by: Eric Dumazet <[email protected]> Reviewed-by: Nikolay Aleksandrov <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent f0417c5 commit c82299f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Documentation/process/maintainer-netdev.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,22 @@ When working in existing code which uses nonstandard formatting make
375375
your code follow the most recent guidelines, so that eventually all code
376376
in the domain of netdev is in the preferred format.
377377

378+
Using device-managed and cleanup.h constructs
379+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
380+
381+
Netdev remains skeptical about promises of all "auto-cleanup" APIs,
382+
including even ``devm_`` helpers, historically. They are not the preferred
383+
style of implementation, merely an acceptable one.
384+
385+
Use of ``guard()`` is discouraged within any function longer than 20 lines,
386+
``scoped_guard()`` is considered more readable. Using normal lock/unlock is
387+
still (weakly) preferred.
388+
389+
Low level cleanup constructs (such as ``__free()``) can be used when building
390+
APIs and helpers, especially scoped iterators. However, direct use of
391+
``__free()`` within networking core and drivers is discouraged.
392+
Similar guidance applies to declaring variables mid-function.
393+
378394
Resending after review
379395
~~~~~~~~~~~~~~~~~~~~~~
380396

0 commit comments

Comments
 (0)