docs: deprecated.rst: Clarify open-coded arithmetic with literals
Subsystems (2)
PATCH 1/1 docs: deprecated.rst: Clarify open-coded arithmetic with literals
Although using literals for size calculation in allocator arguments may be harmless due to compiler warnings in case of overflows, it is better to refactor the code to avoid the use of open-coded math idiom.
So, clarify the preferred way in these cases.
--- Documentation/process/deprecated.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/process/deprecated.rst +2 -1
@@ -60,7 +60,8 @@ smaller allocation being made than the caller was expecting. Using those allocations could lead to linear overflows of heap memory and other misbehaviors. (One exception to this is literal values where the compiler can warn if they might overflow. Though using literals for arguments as -suggested below is also harmless.) +suggested below is also harmless. So, the preferred way in these cases is +to refactor the code to keep the open-coded math idiom out.) For example, do not use ``count * size`` as an argument, as in::
--
2.25.1
Quoted 5 lines · Len Baker
Although using literals for size calculation in allocator arguments may be harmless due to compiler warnings in case of overflows, it is better to refactor the code to avoid the use of open-coded math idiom.
So, clarify the preferred way in these cases.
[]
Documentation/process/deprecated.rst
Quoted 1 line
Documentation/process/deprecated.rst +0
-0
[]
Documentation/process/deprecated.rst smaller allocation being made than the caller was expecting. Using those · line 64
Quoted 7 lines
Documentation/process/deprecated.rst +0
-0@@ -60,7 +60,8 @@ smaller allocation being made than the caller was expecting. Using thoseallocations could lead to linear overflows of heap memory and other misbehaviors. (One exception to this is literal values where the compiler can warn if they might overflow. Though using literals for arguments as
Documentation/process/deprecated.rst +2
-1-suggested below is also harmless.) +suggested below is also harmless. So, the preferred way in these cases is +to refactor the code to keep the open-coded math idiom out.)
wordsmithing trivia:
'keep <foo> out' is difficult to parse as 'keep' is generally a positive word but its meaning is later reversed with out.
'avoid <foo>' maybe be better phrasing.
Quoted 19 lines · Joe Perches
Quoted 5 lines · Len Baker
Although using literals for size calculation in allocator arguments may be harmless due to compiler warnings in case of overflows, it is better to refactor the code to avoid the use of open-coded math idiom.
So, clarify the preferred way in these cases.
[]
Documentation/process/deprecated.rst
Quoted 1 line
Documentation/process/deprecated.rst +0
-0[]
Documentation/process/deprecated.rst smaller allocation being made than the caller was expecting. Using those · line 64
Quoted 7 lines
Documentation/process/deprecated.rst +0
-0@@ -60,7 +60,8 @@ smaller allocation being made than the caller was expecting. Using thoseallocations could lead to linear overflows of heap memory and other misbehaviors. (One exception to this is literal values where the compiler can warn if they might overflow. Though using literals for arguments as
Documentation/process/deprecated.rst +2
-1-suggested below is also harmless.) +suggested below is also harmless. So, the preferred way in these cases is +to refactor the code to keep the open-coded math idiom out.)wordsmithing trivia:
Quoted 4 lines
'keep <foo> out' is difficult to parse as 'keep' is generally a positive word but its meaning is later reversed with out.
'avoid <foo>' maybe be better phrasing.
+1
--
Gustavo
Hi,
Quoted 19 lines · Joe Perches
Quoted 5 lines · Len Baker
Although using literals for size calculation in allocator arguments may be harmless due to compiler warnings in case of overflows, it is better to refactor the code to avoid the use of open-coded math idiom.
So, clarify the preferred way in these cases.
[]
Documentation/process/deprecated.rst
Quoted 1 line
Documentation/process/deprecated.rst +0
-0[]
Documentation/process/deprecated.rst smaller allocation being made than the caller was expecting. Using those · line 64
Quoted 7 lines
Documentation/process/deprecated.rst +0
-0@@ -60,7 +60,8 @@ smaller allocation being made than the caller was expecting. Using thoseallocations could lead to linear overflows of heap memory and other misbehaviors. (One exception to this is literal values where the compiler can warn if they might overflow. Though using literals for arguments as
Documentation/process/deprecated.rst +2
-1-suggested below is also harmless.) +suggested below is also harmless. So, the preferred way in these cases is +to refactor the code to keep the open-coded math idiom out.)wordsmithing trivia:
Quoted 5 lines
'keep <foo> out' is difficult to parse as 'keep' is generally a positive word but its meaning is later reversed with out.
'avoid <foo>' maybe be better phrasing.
Understood. I will do this change and I will send a new version. Thanks for the review.
Regards,
Len