Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 37725be

Browse files
Apply suggestions from code review
Co-authored-by: Erlend E. Aasland <[email protected]>
1 parent 64883ac commit 37725be

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

Modules/posixmodule.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3323,10 +3323,12 @@ win32_lchmod(LPCWSTR path, int mode)
33233323
if (attr == INVALID_FILE_ATTRIBUTES) {
33243324
return 0;
33253325
}
3326-
if (mode & _S_IWRITE)
3326+
if (mode & _S_IWRITE) {
33273327
attr &= ~FILE_ATTRIBUTE_READONLY;
3328-
else
3328+
}
3329+
else {
33293330
attr |= FILE_ATTRIBUTE_READONLY;
3331+
}
33303332
return SetFileAttributesW(path, attr);
33313333
}
33323334
#endif
@@ -3404,14 +3406,16 @@ os_chmod_impl(PyObject *module, path_t *path, int mode, int dir_fd,
34043406
if (GetFileInformationByHandleEx(hfile, FileBasicInfo,
34053407
&info, sizeof(info)))
34063408
{
3407-
if (mode & _S_IWRITE)
3409+
if (mode & _S_IWRITE) {
34083410
info.FileAttributes &= ~FILE_ATTRIBUTE_READONLY;
3409-
else
3411+
}
3412+
else {
34103413
info.FileAttributes |= FILE_ATTRIBUTE_READONLY;
3414+
}
34113415
result = SetFileInformationByHandle(hfile, FileBasicInfo,
34123416
&info, sizeof(info));
34133417
}
3414-
CloseHandle(hfile);
3418+
(void)CloseHandle(hfile);
34153419
}
34163420
}
34173421
else {

0 commit comments

Comments
 (0)