Skip to content

Commit

Permalink
Remove unused variables, other code review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dbwiddis committed Aug 20, 2018
1 parent c00cfef commit 706981f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 24 deletions.
6 changes: 3 additions & 3 deletions contrib/platform/src/com/sun/jna/platform/win32/Wbemcli.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.sun.jna.platform.win32.Guid.CLSID;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.Variant.VARIANT;
import com.sun.jna.platform.win32.WTypes;
import com.sun.jna.platform.win32.WTypes.BSTR;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.platform.win32.COM.COMUtils;
Expand All @@ -37,7 +36,9 @@
import com.sun.jna.ptr.PointerByReference;

/**
* This header is used by Remote Desktop Services.
* This header is used by Remote Desktop Services. It contains programming
* interfaces for enumerating and querying Common Information Model (CIM)
* objects.
*/
public interface Wbemcli {

Expand Down Expand Up @@ -109,7 +110,6 @@ public static IWbemLocator create() {
HRESULT hres = Ole32.INSTANCE.CoCreateInstance(CLSID_WbemLocator, null, WTypes.CLSCTX_INPROC_SERVER,
IID_IWbemLocator, pbr);
if (COMUtils.FAILED(hres)) {
Ole32.INSTANCE.CoUninitialize();
throw new WbemcliException("Failed to create WbemLocator object.", hres.intValue());
}

Expand Down
24 changes: 3 additions & 21 deletions contrib/platform/src/com/sun/jna/platform/win32/WbemcliUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ public class WbemcliUtil {
*/
public static final String DEFAULT_NAMESPACE = "ROOT\\CIMV2";

// Constant for WMI used often.
private static final BSTR WQL = OleAuto.INSTANCE.SysAllocString("WQL");

// Track initialization of COM and Security
private static boolean comInitialized = false;
private static boolean securityInitialized = false;

/**
* Enum containing the property used for WMI Namespace query.
*/
Expand Down Expand Up @@ -352,19 +345,6 @@ public void incrementResultCount() {
}
}

/**
* Private construtor for cleanup hook
*/
private WbemcliUtil() {
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
OleAuto.INSTANCE.SysFreeString(WQL);
}
});
}


/**
* Create a WMI Query
*
Expand Down Expand Up @@ -565,9 +545,11 @@ public static <T extends Enum<T>> IEnumWbemClassObject selectProperties(IWbemSer
// Send the query. The flags allow us to return immediately and begin
// enumerating in the forward direction as results come in.
BSTR queryStr = OleAuto.INSTANCE.SysAllocString(sb.toString().replaceAll("\\\\", "\\\\\\\\"));
HRESULT hres = svc.ExecQuery(WQL, queryStr,
BSTR wql = OleAuto.INSTANCE.SysAllocString("WQL");
HRESULT hres = svc.ExecQuery(wql, queryStr,
Wbemcli.WBEM_FLAG_FORWARD_ONLY | Wbemcli.WBEM_FLAG_RETURN_IMMEDIATELY, null, pEnumerator);
OleAuto.INSTANCE.SysFreeString(queryStr);
OleAuto.INSTANCE.SysFreeString(wql);
if (COMUtils.FAILED(hres)) {
svc.Release();
throw new WbemcliException(String.format("Query '%s' failed.", sb.toString()), hres.intValue());
Expand Down

0 comments on commit 706981f

Please sign in to comment.