Skip to content

Commit ba6abe6

Browse files
committed
Remove useless assignment to locals
Follow-up to PowerShell#14341.
1 parent bb78d4b commit ba6abe6

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/Microsoft.PowerShell.Security/security/AclCommands.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,7 @@ public static SecurityIdentifier GetCentralAccessPolicyId(PSObject instance)
385385
return null;
386386
}
387387

388-
NativeMethods.ACL sacl = new NativeMethods.ACL();
389-
sacl = Marshal.PtrToStructure<NativeMethods.ACL>(pSacl);
388+
NativeMethods.ACL sacl = Marshal.PtrToStructure<NativeMethods.ACL>(pSacl);
390389
if (sacl.AceCount == 0)
391390
{
392391
return null;
@@ -396,8 +395,7 @@ public static SecurityIdentifier GetCentralAccessPolicyId(PSObject instance)
396395
IntPtr pAce = pSacl + Marshal.SizeOf(new NativeMethods.ACL());
397396
for (ushort aceIdx = 0; aceIdx < sacl.AceCount; aceIdx++)
398397
{
399-
NativeMethods.ACE_HEADER ace = new NativeMethods.ACE_HEADER();
400-
ace = Marshal.PtrToStructure<NativeMethods.ACE_HEADER>(pAce);
398+
NativeMethods.ACE_HEADER ace = Marshal.PtrToStructure<NativeMethods.ACE_HEADER>(pAce);
401399
Dbg.Diagnostics.Assert(ace.AceType ==
402400
NativeMethods.SYSTEM_SCOPED_POLICY_ID_ACE_TYPE,
403401
"Unexpected ACE type: " + ace.AceType.ToString(CultureInfo.CurrentCulture));
@@ -475,8 +473,7 @@ public static string GetCentralAccessPolicyName(PSObject instance)
475473
}
476474

477475
// Get the CAP name.
478-
NativeMethods.CENTRAL_ACCESS_POLICY cap = new NativeMethods.CENTRAL_ACCESS_POLICY();
479-
cap = Marshal.PtrToStructure<NativeMethods.CENTRAL_ACCESS_POLICY>(caps);
476+
NativeMethods.CENTRAL_ACCESS_POLICY cap = Marshal.PtrToStructure<NativeMethods.CENTRAL_ACCESS_POLICY>(caps);
480477
// LSA_UNICODE_STRING is composed of WCHARs, but its length is given in bytes.
481478
return Marshal.PtrToStringUni(cap.Name.Buffer, cap.Name.Length / 2);
482479
}
@@ -528,7 +525,7 @@ public static string[] GetAllCentralAccessPolicies(PSObject instance)
528525

529526
// Add CAP names and IDs to a string array.
530527
string[] policies = new string[capCount];
531-
NativeMethods.CENTRAL_ACCESS_POLICY cap = new NativeMethods.CENTRAL_ACCESS_POLICY();
528+
NativeMethods.CENTRAL_ACCESS_POLICY cap;
532529
IntPtr capPtr = caps;
533530
for (uint capIdx = 0; capIdx < capCount; capIdx++)
534531
{
@@ -1144,7 +1141,7 @@ private IntPtr GetSaclWithCapId(string capStr)
11441141
}
11451142

11461143
// Find the supplied string among available CAP names, use the corresponding CAPID.
1147-
NativeMethods.CENTRAL_ACCESS_POLICY cap = new NativeMethods.CENTRAL_ACCESS_POLICY();
1144+
NativeMethods.CENTRAL_ACCESS_POLICY cap;
11481145
IntPtr capPtr = caps;
11491146
for (uint capIdx = 0; capIdx < capCount; capIdx++)
11501147
{

0 commit comments

Comments
 (0)