docs: netdev: document guidance on cleanup.h
Subsystems (4)
Jakub Kicinski
maintainerPATCH 1/1 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 my own invention. If the function is trivial it should be fine, but feel free to disagree :)
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- Documentation/process/maintainer-netdev.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
Documentation/process/maintainer-netdev.rst +16 -0
@@ -392,6 +392,22 @@ When working in existing code which uses nonstandard formatting make your code follow the most recent guidelines, so that eventually all code in the domain of netdev is in the preferred format. +Using device-managed and cleanup.h constructs +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Netdev remains skeptical about promises of all "auto-cleanup" APIs, +including even ``devm_`` helpers, historically. They are not the preferred +style of implementation, merely an acceptable one. + +Use of ``guard()`` is discouraged within any function longer than 20 lines, +``scoped_guard()`` is considered more readable. Using normal lock/unlock is +still (weakly) preferred. + +Low level cleanup constructs (such as ``__free()``) can be used when building +APIs and helpers, especially scoped interators. However, direct use of +``__free()`` within networking core and drivers is discouraged. +Similar guidance applies to declaring variables mid-function. + Resending after review ~~~~~~~~~~~~~~~~~~~~~~
Signature · 1 line
2.46.0
Quoted 7 lines · Jakub Kicinski
Document what was discussed multiple times on list and various virtual / in-person conversations.
guard()being okay in functions <= 20 LoC is my own invention. If the function is trivial it should be fine, but feel free to disagree :)Signed-off-by Jakub Kicinski <[email protected]>
+2
Quoted 31 lines · Jakub Kicinski
Document what was discussed multiple times on list and various virtual / in-person conversations.
guard()being okay in functions <= 20 LoC is my own invention. If the function is trivial it should be fine, but feel free to disagree :)Signed-off-by Jakub Kicinski <[email protected]>---
CC: [email protected]
CC: [email protected]
CC: [email protected]--- Documentation/process/maintainer-netdev.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)Documentation/process/maintainer-netdev.rst +9
-0@@ -392,6 +392,22 @@ When working in existing code which uses nonstandard formatting make your code follow the most recent guidelines, so that eventually all code in the domain of netdev is in the preferred format. +Using device-managed and cleanup.h constructs +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Netdev remains skeptical about promises of all "auto-cleanup" APIs, +including even ``devm_`` helpers, historically. They are not the preferred +style of implementation, merely an acceptable one. + +Use of ``guard()`` is discouraged within any function longer than 20 lines, +``scoped_guard()`` is considered more readable. Using normal lock/unlock is
Documentation/process/maintainer-netdev.rst When working in existing code which uses nonstandard formatting make · line 413
Quoted 10 lines
Documentation/process/maintainer-netdev.rst +7
-0+still (weakly) preferred. + +Low level cleanup constructs (such as ``__free()``) can be used when building +APIs and helpers, especially scoped interators. However, direct use of +``__free()`` within networking core and drivers is discouraged. +Similar guidance applies to declaring variables mid-function. + Resending after review ~~~~~~~~~~~~~~~~~~~~~~
Definitely and strongly agree.
Quoted 6 lines · Jakub Kicinski
Document what was discussed multiple times on list and various virtual / in-person conversations.
guard()being okay in functions <= 20 LoC is my own invention. If the function is trivial it should be fine, but feel free to disagree :)Signed-off-by Jakub Kicinski <[email protected]>
When discussing guard() etc, i have said we would reconsider this in a couple of years looking at the experience of other subsystems. Maybe something about this could be added to the commit message?
Otherwise:
Andrew
Simon Horman
reviewerQuoted 25 lines · Jakub Kicinski
Document what was discussed multiple times on list and various virtual / in-person conversations.
guard()being okay in functions <= 20 LoC is my own invention. If the function is trivial it should be fine, but feel free to disagree :)Signed-off-by Jakub Kicinski <[email protected]>---
CC: [email protected]
CC: [email protected]
CC: [email protected]--- Documentation/process/maintainer-netdev.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)Documentation/process/maintainer-netdev.rst +3
-0@@ -392,6 +392,22 @@ When working in existing code which uses nonstandard formatting make your code follow the most recent guidelines, so that eventually all code in the domain of netdev is in the preferred format. +Using device-managed and cleanup.h constructs +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +
Documentation/process/maintainer-netdev.rst When working in existing code which uses nonstandard formatting make · line 407
Quoted 10 lines
Documentation/process/maintainer-netdev.rst +10
-0+Netdev remains skeptical about promises of all "auto-cleanup" APIs, +including even ``devm_`` helpers, historically. They are not the preferred +style of implementation, merely an acceptable one. + +Use of ``guard()`` is discouraged within any function longer than 20 lines, +``scoped_guard()`` is considered more readable. Using normal lock/unlock is +still (weakly) preferred. + +Low level cleanup constructs (such as ``__free()``) can be used when building +APIs and helpers, especially scoped interators. However, direct use of
Sorry to nit-pick: iterators
Quoted 10 lines
Documentation/process/maintainer-netdev.rst +3
-0+``__free()`` within networking core and drivers is discouraged. +Similar guidance applies to declaring variables mid-function. + Resending after review ~~~~~~~~~~~~~~~~~~~~~~Signature · 1 line
2.46.0