@@ -63,51 +63,51 @@ Instead, use the helper::
63
63
64
64
header = kzalloc(struct_size(header, item, count), GFP_KERNEL);
65
65
66
- See :c:func: ` array_size `, :c:func: ` array3_size ` , and :c:func: ` struct_size ` ,
67
- for more details as well as the related :c:func: ` check_add_overflow ` and
68
- :c:func: ` check_mul_overflow ` family of functions.
66
+ See array_size(), array3_size() , and struct_size() ,
67
+ for more details as well as the related check_add_overflow() and
68
+ check_mul_overflow() family of functions.
69
69
70
70
simple_strtol(), simple_strtoll(), simple_strtoul(), simple_strtoull()
71
71
----------------------------------------------------------------------
72
- The :c:func: ` simple_strtol `, :c:func: ` simple_strtoll ` ,
73
- :c:func: ` simple_strtoul ` , and :c:func: ` simple_strtoull ` functions
72
+ The simple_strtol(), simple_strtoll() ,
73
+ simple_strtoul() , and simple_strtoull() functions
74
74
explicitly ignore overflows, which may lead to unexpected results
75
- in callers. The respective :c:func: ` kstrtol `, :c:func: ` kstrtoll ` ,
76
- :c:func: ` kstrtoul ` , and :c:func: ` kstrtoull ` functions tend to be the
75
+ in callers. The respective kstrtol(), kstrtoll() ,
76
+ kstrtoul() , and kstrtoull() functions tend to be the
77
77
correct replacements, though note that those require the string to be
78
78
NUL or newline terminated.
79
79
80
80
strcpy()
81
81
--------
82
- :c:func: ` strcpy ` performs no bounds checking on the destination
82
+ strcpy() performs no bounds checking on the destination
83
83
buffer. This could result in linear overflows beyond the
84
84
end of the buffer, leading to all kinds of misbehaviors. While
85
85
`CONFIG_FORTIFY_SOURCE=y ` and various compiler flags help reduce the
86
86
risk of using this function, there is no good reason to add new uses of
87
- this function. The safe replacement is :c:func: ` strscpy ` .
87
+ this function. The safe replacement is strscpy() .
88
88
89
89
strncpy() on NUL-terminated strings
90
90
-----------------------------------
91
- Use of :c:func: ` strncpy ` does not guarantee that the destination buffer
91
+ Use of strncpy() does not guarantee that the destination buffer
92
92
will be NUL terminated. This can lead to various linear read overflows
93
93
and other misbehavior due to the missing termination. It also NUL-pads the
94
94
destination buffer if the source contents are shorter than the destination
95
95
buffer size, which may be a needless performance penalty for callers using
96
- only NUL-terminated strings. The safe replacement is :c:func: ` strscpy ` .
97
- (Users of :c:func: ` strscpy ` still needing NUL-padding should instead
96
+ only NUL-terminated strings. The safe replacement is strscpy() .
97
+ (Users of strscpy() still needing NUL-padding should instead
98
98
use strscpy_pad().)
99
99
100
- If a caller is using non-NUL-terminated strings, :c:func: ` strncpy() ` can
100
+ If a caller is using non-NUL-terminated strings, strncpy()() can
101
101
still be used, but destinations should be marked with the `__nonstring
102
102
<https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html> `_
103
103
attribute to avoid future compiler warnings.
104
104
105
105
strlcpy()
106
106
---------
107
- :c:func: ` strlcpy ` reads the entire source buffer first, possibly exceeding
107
+ strlcpy() reads the entire source buffer first, possibly exceeding
108
108
the given limit of bytes to copy. This is inefficient and can lead to
109
109
linear read overflows if a source string is not NUL-terminated. The
110
- safe replacement is :c:func: ` strscpy ` .
110
+ safe replacement is strscpy() .
111
111
112
112
%p format specifier
113
113
-------------------
0 commit comments