Skip to content

Commit 2c32228

Browse files
authored
Merge pull request #2814 from valeriyvan/CFFileUtilities
Uses var (otherwise not used) as parameter to open file in CFFileUtilities
2 parents bbd6962 + 49b405d commit 2c32228

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

CoreFoundation/Base.subproj/CFFileUtilities.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,22 +164,21 @@ CF_PRIVATE Boolean _CFReadBytesFromFile(CFAllocatorRef alloc, CFURLRef url, void
164164

165165
CF_PRIVATE Boolean _CFWriteBytesToFile(CFURLRef url, const void *bytes, CFIndex length) {
166166
int fd = -1;
167-
int mode;
168167
struct statinfo statBuf;
169168
char path[CFMaxPathSize];
170169
if (!CFURLGetFileSystemRepresentation(url, true, (uint8_t *)path, CFMaxPathSize)) {
171170
return false;
172171
}
173172

174173
int no_hang_fd = openAutoFSNoWait();
175-
mode = 0666;
174+
int mode = 0666;
176175
if (0 == stat(path, &statBuf)) {
177176
mode = statBuf.st_mode;
178177
} else if (thread_errno() != ENOENT) {
179178
closeAutoFSNoWait(no_hang_fd);
180179
return false;
181180
}
182-
fd = open(path, O_WRONLY|O_CREAT|O_TRUNC|CF_OPENFLGS, 0666);
181+
fd = open(path, O_WRONLY|O_CREAT|O_TRUNC|CF_OPENFLGS, mode);
183182
if (fd < 0) {
184183
closeAutoFSNoWait(no_hang_fd);
185184
return false;

0 commit comments

Comments
 (0)