Skip to content

Uses var (otherwise not used) as parameter to open file in CFFileUtilities #2814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions CoreFoundation/Base.subproj/CFFileUtilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,22 +164,21 @@ CF_PRIVATE Boolean _CFReadBytesFromFile(CFAllocatorRef alloc, CFURLRef url, void

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

int no_hang_fd = openAutoFSNoWait();
mode = 0666;
int mode = 0666;
if (0 == stat(path, &statBuf)) {
mode = statBuf.st_mode;
} else if (thread_errno() != ENOENT) {
closeAutoFSNoWait(no_hang_fd);
return false;
}
fd = open(path, O_WRONLY|O_CREAT|O_TRUNC|CF_OPENFLGS, 0666);
fd = open(path, O_WRONLY|O_CREAT|O_TRUNC|CF_OPENFLGS, mode);
if (fd < 0) {
closeAutoFSNoWait(no_hang_fd);
return false;
Expand Down