summaryrefslogtreecommitdiff
path: root/lib/checksrc.pl
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2015-06-02 08:28:10 +0200
committerDaniel Stenberg <daniel@haxx.se>2015-06-02 08:28:10 +0200
commit33ee4118483111876c00e68004bc50674992eda2 (patch)
tree66e7040773cd32fd87e4f696c73f49e737dc25eb /lib/checksrc.pl
parent3bbcb4b03605bafa0d8e79f82240b1bc8de7a7e7 (diff)
downloadcurl-33ee4118483111876c00e68004bc50674992eda2.tar.gz
checksrc: detect fopen() for text without the FOPEN_* macros
Follow-up to e8423f9ce150 with discussionis in https://github.com/bagder/curl/pull/258 This check scans for fopen() with a mode string without 'b' present, as it may indicate that an FOPEN_* define should rather be used.
Diffstat (limited to 'lib/checksrc.pl')
-rwxr-xr-xlib/checksrc.pl9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/checksrc.pl b/lib/checksrc.pl
index 292ad3424..8fad2cfcb 100755
--- a/lib/checksrc.pl
+++ b/lib/checksrc.pl
@@ -228,6 +228,15 @@ sub scanfile {
"use of $2 is banned");
}
+ # scan for use of non-binary fopen without the macro
+ if($l =~ /^(.*\W)fopen\s*\([^"]*\"([^"]*)/) {
+ my $mode = $2;
+ if($mode !~ /b/) {
+ checkwarn($line, length($1), $file, $l,
+ "use of non-binary fopen without FOPEN_* macro");
+ }
+ }
+
# check for open brace first on line but not first column
# only alert if previous line ended with a close paren and wasn't a cpp
# line