Add mode bits to open calls
This was already done internally a while ago, but for us to submit
clang FORTIFY, we need it here, as well.
Bug: 32073964
Test: Clang FORTIFY no longer complains about open calls here.
Change-Id: I72428ac4d3279ffc330ae5aa579960c26703053c
Merged-In: Iaed2538831b19ada26005bbef33cff28209c6512
diff --git a/bench/benchgen.py b/bench/benchgen.py
index 9a2bcd7..c852169 100644
--- a/bench/benchgen.py
+++ b/bench/benchgen.py
@@ -183,7 +183,12 @@
if handle not in defined:
print >>bench, "int ",
defined.add(handle)
- print >>bench, '%s = TEMP_FAILURE_RETRY(open("file%s", %s));' % (handle, f.ident, e.args[2])
+ create_mode = ''
+ if 'O_CREAT' in e.args[2]:
+ assert len(e.args) > 3, 'File creation lacks a mode?'
+ create_mode = ', ' + e.args[3]
+ print >>bench, '%s = TEMP_FAILURE_RETRY(open("file%s", %s%s));' \
+ % (handle, f.ident, e.args[2], create_mode)
elif e.call == "close":
fd, f, handle = extract_file(e, e.args[0])
@@ -273,7 +278,7 @@
LOG(ERROR) << "Failed to read random data";
return -EIO;
}
- if ((out = TEMP_FAILURE_RETRY(open(name, O_WRONLY|O_CREAT|O_TRUNC))) < 0) {
+ if ((out = TEMP_FAILURE_RETRY(open(name, O_WRONLY|O_CREAT|O_TRUNC, 0644))) < 0) {
PLOG(ERROR) << "Failed to open " << name;
return -errno;
}