File tree 5 files changed +14
-2
lines changed
5 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ exit 0;
101
101
102
102
sub check_only_option {
103
103
my ($arg ) = @_ ;
104
- return 1 if $arg =~ / ^-W(no-?)?(address-space|bitwise|cast-to-as|cast-truncate|context|decl|default-bitfield-sign|designated-init|do-while|enum-mismatch|init-cstring|non-pointer-null|old-initializer|one-bit-signed-bitfield|override-init-all|paren-string|ptr-subtraction-blows|return-void|sizeof-bool|sparse-all|sparse-error|transparent-union|typesign|undef|unknown-attribute)$ / ;
104
+ return 1 if $arg =~ / ^-W(no-?)?(address-space|bitwise|cast-to-as|cast-truncate|context|decl|default-bitfield-sign|designated-init|do-while|enum-mismatch|init-cstring|memcpy-max-count| non-pointer-null|old-initializer|one-bit-signed-bitfield|override-init-all|paren-string|ptr-subtraction-blows|return-void|sizeof-bool|sparse-all|sparse-error|transparent-union|typesign|undef|unknown-attribute)$ / ;
105
105
return 1 if $arg =~ / ^-v(no-?)?(entry|dead)$ / ;
106
106
return 1 if $arg =~ / ^-f(dump-linearize)(=\S *)?$ / ;
107
107
return 0;
Original file line number Diff line number Diff line change @@ -230,6 +230,7 @@ int Wdo_while = 0;
230
230
int Winit_cstring = 0 ;
231
231
int Wenum_mismatch = 1 ;
232
232
int Wsparse_error = 0 ;
233
+ int Wmemcpy_max_count = 1 ;
233
234
int Wnon_pointer_null = 1 ;
234
235
int Wold_initializer = 1 ;
235
236
int Wone_bit_signed_bitfield = 1 ;
@@ -506,6 +507,7 @@ static const struct warning {
506
507
{ "do-while" , & Wdo_while },
507
508
{ "enum-mismatch" , & Wenum_mismatch },
508
509
{ "init-cstring" , & Winit_cstring },
510
+ { "memcpy-max-count" , & Wmemcpy_max_count },
509
511
{ "non-pointer-null" , & Wnon_pointer_null },
510
512
{ "old-initializer" , & Wold_initializer },
511
513
{ "one-bit-signed-bitfield" , & Wone_bit_signed_bitfield },
Original file line number Diff line number Diff line change @@ -120,6 +120,7 @@ extern int Wdo_while;
120
120
extern int Wenum_mismatch ;
121
121
extern int Wsparse_error ;
122
122
extern int Winit_cstring ;
123
+ extern int Wmemcpy_max_count ;
123
124
extern int Wnon_pointer_null ;
124
125
extern int Wold_initializer ;
125
126
extern int Wone_bit_signed_bitfield ;
Original file line number Diff line number Diff line change @@ -210,6 +210,14 @@ trouble.
210
210
Sparse does not issue these warnings by default.
211
211
.
212
212
.TP
213
+ .B \- Wmemcpy\- max\- count
214
+ Warn about call of \fB memcpy() \fR , \fB memset() \fR , \fB copy_from_user() \fR , or
215
+ \fB copy_to_user() \fR with a large compile-time byte count.
216
+
217
+ Sparse issues these warnings by default. To turn them off, use
218
+ \fB \- Wno \- memcpy \- max \- count \fR .
219
+ .
220
+ .TP
213
221
.B \- Wnon\- pointer\- null
214
222
Warn about the use of 0 as a NULL pointer.
215
223
Original file line number Diff line number Diff line change @@ -153,7 +153,8 @@ static void check_byte_count(struct instruction *insn, pseudo_t count)
153
153
return ;
154
154
if (count -> type == PSEUDO_VAL ) {
155
155
unsigned long long val = count -> value ;
156
- if (val > 100000ULL )
156
+ if (Wmemcpy_max_count && val > 100000ULL )
157
+
157
158
warning (insn -> pos , "%s with byte count of %llu" ,
158
159
show_ident (insn -> func -> sym -> ident ), val );
159
160
return ;
You can’t perform that action at this time.
0 commit comments