changeset 10479:d4880c6fefec

8179464: [Windows][prism-d3d] Fix compiler _CRT_SECURE_ warnings Reviewed-by: kcr
author ckyang
date Mon, 08 May 2017 15:34:38 -0700
parents bc1e07d1e726
children 97dc48e51225
files modules/javafx.graphics/src/main/native-prism-d3d/D3DPipelineManager.cc modules/javafx.graphics/src/main/native-prism-d3d/Trace.cc
diffstat 2 files changed, 19 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/modules/javafx.graphics/src/main/native-prism-d3d/D3DPipelineManager.cc	Fri May 05 07:45:05 2017 -0700
+++ b/modules/javafx.graphics/src/main/native-prism-d3d/D3DPipelineManager.cc	Mon May 08 15:34:38 2017 -0700
@@ -34,8 +34,6 @@
 // this state is set if adapter was successfully created
 #define CONTEXT_CREATED 1
 
-static BOOL bNoHwCheck = (getenv("NEWT_D3D_NO_HWCHECK") != NULL);
-
 static const size_t MAX_WARNING_MESSAGE_LEN = 256;
 static char messageBuffer[MAX_WARNING_MESSAGE_LEN];
 static char* warningMessage = NULL;
@@ -181,11 +179,6 @@
     }
     RlsTraceLn(NWT_TRACE_ERROR,
                   "D3DPPLM::CheckOSVersion: Windows 2000 or earlier OS detected, failed");
-    if (bNoHwCheck) {
-        RlsTraceLn(NWT_TRACE_WARNING,
-                      "  OS check overridden via NEWT_D3D_NO_HWCHECK");
-        return S_OK;
-    }
     return E_FAIL;
 }
 
@@ -432,9 +425,12 @@
 
 D3DDEVTYPE D3DPipelineManager::SelectDeviceType()
 {
-    char *pRas = getenv("NEWT_D3D_RASTERIZER");
+    char *pRas = NULL;
+    size_t size = 0;
+
     D3DDEVTYPE dtype = D3DDEVTYPE_HAL;
-    if (pRas != NULL) {
+    if ((_dupenv_s(&pRas, &size, "NWT_D3D_RASTERIZER") == 0)
+            && (pRas != NULL)) {
         RlsTrace(NWT_TRACE_WARNING, "[W] D3DPPLM::SelectDeviceType: ");
         if (strncmp(pRas, "ref", 3) == 0 || strncmp(pRas, "rgb", 3) == 0) {
             RlsTrace(NWT_TRACE_WARNING, "ref rasterizer selected");
@@ -451,6 +447,7 @@
                 "supported, hal selected instead", pRas);
         }
         RlsTrace(NWT_TRACE_WARNING, "\n");
+        free(pRas);
     }
     return dtype;
 }
--- a/modules/javafx.graphics/src/main/native-prism-d3d/Trace.cc	Fri May 05 07:45:05 2017 -0700
+++ b/modules/javafx.graphics/src/main/native-prism-d3d/Trace.cc	Mon May 08 15:34:38 2017 -0700
@@ -74,24 +74,28 @@
     }
 }
 
-void TraceInit()
-{
-    char *decTraceLevelString = getenv("NWT_TRACE_LEVEL");
+void TraceInit() {
+    char *decTraceLevelString = NULL;
+    size_t size = 0;
+
     decTraceLevel = NWT_TRACE_OFF;
-    if (decTraceLevelString) {
+    if ((_dupenv_s(&decTraceLevelString, &size, "NWT_TRACE_LEVEL") == 0)
+            && (decTraceLevelString != NULL)) {
         int traceLevelTmp = -1;
-        int args = sscanf(decTraceLevelString, "%d", &traceLevelTmp);
+        int args = sscanf_s(decTraceLevelString, "%d", &traceLevelTmp);
         if (args > 0 && traceLevelTmp > NWT_TRACE_INVALID) {
             decTraceLevel = traceLevelTmp;
         }
+        free(decTraceLevelString);
     }
 
-    char *decTraceFileName = getenv("NWT_TRACE_FILE");
-    if (decTraceFileName) {
-        decTraceFile = fopen(decTraceFileName, "w");
-        if (!decTraceFile) {
+    char *decTraceFileName = NULL;
+    if ((_dupenv_s(&decTraceFileName, &size, "NWT_TRACE_FILE") == 0)
+            && (decTraceFileName != NULL)) {
+        if (fopen_s(&decTraceFile, decTraceFileName, "w") != 0) {
             printf("(E): Error opening trace file %s\n", decTraceFileName);
         }
+        free(decTraceFileName);
     }
     if (!decTraceFile) {
         decTraceFile = stdout;