summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorIevgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>2021-11-10 12:39:04 +0100
committerIevgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>2021-11-10 16:45:52 +0100
commitf28e1613617b519ff6442607c99033291623d38f (patch)
treef59615bf95e03141a94c5b9fdc2e85e1620f190f /src/corelib/io
parent605d383a702044e577ca2826e75c7cc56e78727d (diff)
Remove useless blocks
Don't put the code inside two blocks for no reason. Change-Id: I54b8d6fbfab50a26ddcd8ec07ba689e5094bcad3 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp72
1 files changed, 34 insertions, 38 deletions
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index d2da2082fa..f384e48572 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -178,47 +178,43 @@ GlobalSid::~GlobalSid()
GlobalSid::GlobalSid()
{
- {
- {
- // Create TRUSTEE for current user
- HANDLE hnd = ::GetCurrentProcess();
- HANDLE token = 0;
- if (::OpenProcessToken(hnd, TOKEN_QUERY, &token)) {
- DWORD retsize = 0;
- // GetTokenInformation requires a buffer big enough for the TOKEN_USER struct and
- // the SID struct. Since the SID struct can have variable number of subauthorities
- // tacked at the end, its size is variable. Obtain the required size by first
- // doing a dummy GetTokenInformation call.
- ::GetTokenInformation(token, TokenUser, 0, 0, &retsize);
- if (retsize) {
- void *tokenBuffer = malloc(retsize);
- Q_CHECK_PTR(tokenBuffer);
- if (::GetTokenInformation(token, TokenUser, tokenBuffer, retsize, &retsize)) {
- PSID tokenSid = reinterpret_cast<PTOKEN_USER>(tokenBuffer)->User.Sid;
- DWORD sidLen = ::GetLengthSid(tokenSid);
- currentUserSID = reinterpret_cast<PSID>(malloc(sidLen));
- Q_CHECK_PTR(currentUserSID);
- if (::CopySid(sidLen, currentUserSID, tokenSid))
- BuildTrusteeWithSid(&currentUserTrusteeW, currentUserSID);
- }
- free(tokenBuffer);
- }
- ::CloseHandle(token);
+ // Create TRUSTEE for current user
+ HANDLE hnd = ::GetCurrentProcess();
+ HANDLE token = 0;
+ if (::OpenProcessToken(hnd, TOKEN_QUERY, &token)) {
+ DWORD retsize = 0;
+ // GetTokenInformation requires a buffer big enough for the TOKEN_USER struct and
+ // the SID struct. Since the SID struct can have variable number of subauthorities
+ // tacked at the end, its size is variable. Obtain the required size by first
+ // doing a dummy GetTokenInformation call.
+ ::GetTokenInformation(token, TokenUser, 0, 0, &retsize);
+ if (retsize) {
+ void *tokenBuffer = malloc(retsize);
+ Q_CHECK_PTR(tokenBuffer);
+ if (::GetTokenInformation(token, TokenUser, tokenBuffer, retsize, &retsize)) {
+ PSID tokenSid = reinterpret_cast<PTOKEN_USER>(tokenBuffer)->User.Sid;
+ DWORD sidLen = ::GetLengthSid(tokenSid);
+ currentUserSID = reinterpret_cast<PSID>(malloc(sidLen));
+ Q_CHECK_PTR(currentUserSID);
+ if (::CopySid(sidLen, currentUserSID, tokenSid))
+ BuildTrusteeWithSid(&currentUserTrusteeW, currentUserSID);
}
+ free(tokenBuffer);
+ }
+ ::CloseHandle(token);
+ }
- token = nullptr;
- if (::OpenProcessToken(hnd, TOKEN_IMPERSONATE | TOKEN_QUERY | TOKEN_DUPLICATE | STANDARD_RIGHTS_READ, &token)) {
- ::DuplicateToken(token, SecurityImpersonation, &currentUserImpersonatedToken);
- ::CloseHandle(token);
- }
+ token = nullptr;
+ if (::OpenProcessToken(hnd, TOKEN_IMPERSONATE | TOKEN_QUERY | TOKEN_DUPLICATE | STANDARD_RIGHTS_READ, &token)) {
+ ::DuplicateToken(token, SecurityImpersonation, &currentUserImpersonatedToken);
+ ::CloseHandle(token);
+ }
- {
- // Create TRUSTEE for Everyone (World)
- SID_IDENTIFIER_AUTHORITY worldAuth = { SECURITY_WORLD_SID_AUTHORITY };
- if (AllocateAndInitializeSid(&worldAuth, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &worldSID))
- BuildTrusteeWithSid(&worldTrusteeW, worldSID);
- }
- }
+ {
+ // Create TRUSTEE for Everyone (World)
+ SID_IDENTIFIER_AUTHORITY worldAuth = { SECURITY_WORLD_SID_AUTHORITY };
+ if (AllocateAndInitializeSid(&worldAuth, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &worldSID))
+ BuildTrusteeWithSid(&worldTrusteeW, worldSID);
}
}