resource/examples: Removing /W4 warnings.
authorPawel Winogrodzki <pawelwi@microsoft.com>
Tue, 13 Jun 2017 00:12:53 +0000 (17:12 -0700)
committerDan Mihai <Daniel.Mihai@microsoft.com>
Fri, 16 Jun 2017 04:06:27 +0000 (04:06 +0000)
Removing variable shadowing warnings: there were a few
variables using the same name in one scope and thus one
overwritten the other.

Bug: https://jira.iotivity.org/browse/IOT-1583

Change-Id: Ifb3d1237bea27faa4b94739c13607c48cb0de46a
Signed-off-by: Pawel Winogrodzki <pawelwi@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/20737
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
resource/examples/devicediscoveryserver.cpp
resource/examples/simpleserver.cpp
resource/examples/simpleserverHQ.cpp
resource/examples/winuiclient.cpp
resource/examples/winuiclientgui.cpp

index 3b6aa3a..ce216be 100644 (file)
 using namespace OC;
 
 // Set of strings for each of platform Info fields
-std::string  platformID = "0A3E0D6F-DBF5-404E-8719-D6880042463A";
-std::string  manufacturerName = "myName";
-std::string  manufacturerLink = "https://www.example.com";
-std::string  modelNumber = "myModelNumber";
-std::string  dateOfManufacture = "2016-01-15";
-std::string  platformVersion = "platformVersion";
-std::string  operatingSystemVersion = "myOS";
-std::string  hardwareVersion = "myHardwareVersion";
-std::string  firmwareVersion = "1.0";
-std::string  supportLink = "https://www.examplesupport.com";
-std::string  systemTime = "2016-01-15T11.01";
+std::string gPlatformID = "0A3E0D6F-DBF5-404E-8719-D6880042463A";
+std::string gManufacturerName = "myName";
+std::string gManufacturerLink = "https://www.example.com";
+std::string gModelNumber = "myModelNumber";
+std::string gDateOfManufacture = "2016-01-15";
+std::string gPlatformVersion = "platformVersion";
+std::string gOperatingSystemVersion = "myOS";
+std::string gHardwareVersion = "myHardwareVersion";
+std::string gFirmwareVersion = "1.0";
+std::string gSupportLink = "https://www.examplesupport.com";
+std::string gSystemTime = "2016-01-15T11.01";
 
 // Set of strings for each of device info fields
 std::string  deviceName = "Bill's Battlestar";
@@ -164,9 +164,9 @@ int main()
 
     std::cout<<"Starting server & setting platform info\n";
 
-    OCStackResult result = SetPlatformInfo(platformID, manufacturerName, manufacturerLink,
-            modelNumber, dateOfManufacture, platformVersion,  operatingSystemVersion,
-            hardwareVersion, firmwareVersion,  supportLink, systemTime);
+    OCStackResult result = SetPlatformInfo(gPlatformID, gManufacturerName, gManufacturerLink,
+            gModelNumber, gDateOfManufacture, gPlatformVersion,  gOperatingSystemVersion,
+            gHardwareVersion, gFirmwareVersion,  gSupportLink, gSystemTime);
 
     result = OCPlatform::registerPlatformInfo(platformInfo);
 
index 49583c6..0553b23 100644 (file)
@@ -52,17 +52,17 @@ void * ChangeLightRepresentation (void *param);
 void * handleSlowResponse (void *param, std::shared_ptr<OCResourceRequest> pRequest);
 
 // Set of strings for each of platform Info fields
-std::string  platformId = "0A3E0D6F-DBF5-404E-8719-D6880042463A";
-std::string  manufacturerName = "OCF";
-std::string  manufacturerLink = "https://www.iotivity.org";
-std::string  modelNumber = "myModelNumber";
-std::string  dateOfManufacture = "2016-01-15";
-std::string  platformVersion = "myPlatformVersion";
-std::string  operatingSystemVersion = "myOS";
-std::string  hardwareVersion = "myHardwareVersion";
-std::string  firmwareVersion = "1.0";
-std::string  supportLink = "https://www.iotivity.org";
-std::string  systemTime = "2016-01-15T11.01";
+std::string gPlatformId = "0A3E0D6F-DBF5-404E-8719-D6880042463A";
+std::string gManufacturerName = "OCF";
+std::string gManufacturerLink = "https://www.iotivity.org";
+std::string gModelNumber = "myModelNumber";
+std::string gDateOfManufacture = "2016-01-15";
+std::string gPlatformVersion = "myPlatformVersion";
+std::string gOperatingSystemVersion = "myOS";
+std::string gHardwareVersion = "myHardwareVersion";
+std::string gFirmwareVersion = "1.0";
+std::string gSupportLink = "https://www.iotivity.org";
+std::string gSystemTime = "2016-01-15T11.01";
 
 // Set of strings for each of device info fields
 std::string  deviceName = "IoTivity Simple Server";
@@ -683,9 +683,9 @@ int main(int argc, char* argv[])
     OC_VERIFY(OCPlatform::start() == OC_STACK_OK);
     std::cout << "Starting server & setting platform info\n";
 
-    OCStackResult result = SetPlatformInfo(platformId, manufacturerName, manufacturerLink,
-            modelNumber, dateOfManufacture, platformVersion, operatingSystemVersion,
-            hardwareVersion, firmwareVersion, supportLink, systemTime);
+    OCStackResult result = SetPlatformInfo(gPlatformId, gManufacturerName, gManufacturerLink,
+            gModelNumber, gDateOfManufacture, gPlatformVersion, gOperatingSystemVersion,
+            gHardwareVersion, gFirmwareVersion, gSupportLink, gSystemTime);
 
     result = OCPlatform::registerPlatformInfo(platformInfo);
 
index 89e68b4..9fce365 100644 (file)
@@ -49,17 +49,17 @@ int gObservation = 0;
 void * ChangeLightRepresentation (void *param);
 
 // Set of strings for each of platform Info fields
-std::string  platformId = "0A3E0D6F-DBF5-404E-8719-D6880042463A";
-std::string  manufacturerName = "OCF";
-std::string  manufacturerLink = "https://www.iotivity.org";
-std::string  modelNumber = "myModelNumber";
-std::string  dateOfManufacture = "2016-01-15";
-std::string  platformVersion = "myPlatformVersion";
-std::string  operatingSystemVersion = "myOS";
-std::string  hardwareVersion = "myHardwareVersion";
-std::string  firmwareVersion = "1.0";
-std::string  supportLink = "https://www.iotivity.org";
-std::string  systemTime = "2016-01-15T11.01";
+std::string  gPlatformId = "0A3E0D6F-DBF5-404E-8719-D6880042463A";
+std::string  gManufacturerName = "OCF";
+std::string  gManufacturerLink = "https://www.iotivity.org";
+std::string  gModelNumber = "myModelNumber";
+std::string  gDateOfManufacture = "2016-01-15";
+std::string  gPlatformVersion = "myPlatformVersion";
+std::string  gOperatingSystemVersion = "myOS";
+std::string  gHardwareVersion = "myHardwareVersion";
+std::string  gFirmwareVersion = "1.0";
+std::string  gSupportLink = "https://www.iotivity.org";
+std::string  gSystemTime = "2016-01-15T11.01";
 
 // Set of strings for each of device info fields
 std::string  deviceName = "IoTivity Simple Server HQ";
@@ -554,9 +554,9 @@ int main(int argc, char* argv[])
     OCPlatform::Configure(cfg);
     std::cout << "Starting server & setting platform info\n";
 
-    OCStackResult result = SetPlatformInfo(platformId, manufacturerName, manufacturerLink,
-            modelNumber, dateOfManufacture, platformVersion, operatingSystemVersion,
-            hardwareVersion, firmwareVersion, supportLink, systemTime);
+    OCStackResult result = SetPlatformInfo(gPlatformId, gManufacturerName, gManufacturerLink,
+            gModelNumber, gDateOfManufacture, gPlatformVersion, gOperatingSystemVersion,
+            gHardwareVersion, gFirmwareVersion, gSupportLink, gSystemTime);
 
     result = OCPlatform::registerPlatformInfo(platformInfo);
 
index ac299ea..3615dd0 100644 (file)
@@ -23,7 +23,7 @@
 #include <functional>\r
 \r
 extern int g_CurSliderVal;\r
-extern HWND hwndVolumeSlider, hwndVolumeExpectedLabel;\r
+extern HWND g_hwndVolumeSlider, g_hwndVolumeExpectedLabel;\r
 using namespace WinUIClient;\r
 void LabelPrintf (HWND hwndEdit, TCHAR * szFormat, ...);\r
 \r
@@ -211,8 +211,8 @@ void WinUIClientApp::onGet(const HeaderOptions& /*headerOptions*/, const OCRepre
             std::cout << "\tname: " << mymedia.m_name << std::endl;\r
 \r
             g_CurSliderVal = mymedia.m_volume;\r
-            SendMessage(hwndVolumeSlider, TBM_SETPOS, TRUE, g_CurSliderVal);\r
-            LabelPrintf(hwndVolumeExpectedLabel,"Volume: %i", g_CurSliderVal);\r
+            SendMessage(g_hwndVolumeSlider, TBM_SETPOS, TRUE, g_CurSliderVal);\r
+            LabelPrintf(g_hwndVolumeExpectedLabel,"Volume: %i", g_CurSliderVal);\r
 \r
         }\r
         else\r
@@ -392,8 +392,8 @@ void WinUIClientApp::onObserve(const HeaderOptions /*headerOptions*/, const OCRe
             std::cout << "\tname: " << mymedia.m_name << std::endl;\r
 \r
             g_CurSliderVal = mymedia.m_volume;\r
-            SendMessage(hwndVolumeSlider, TBM_SETPOS, TRUE, g_CurSliderVal);\r
-            LabelPrintf(hwndVolumeExpectedLabel,"Volume: %i", g_CurSliderVal);\r
+            SendMessage(g_hwndVolumeSlider, TBM_SETPOS, TRUE, g_CurSliderVal);\r
+            LabelPrintf(g_hwndVolumeExpectedLabel,"Volume: %i", g_CurSliderVal);\r
         }\r
         else\r
         {\r
@@ -430,7 +430,7 @@ void WinUIClientApp::BeginObserving()
 void WinUIClientApp::CancelObserving()\r
 {\r
     std::cout<<"Cancelling Observe..."<<std::endl;\r
-    OCStackResult result = curResource->cancelObserve();\r
+    curResource->cancelObserve();\r
 }\r
 \r
 std::shared_ptr<OCResource> WinUIClientApp::GetResource()\r
index 0664892..977c70f 100644 (file)
@@ -33,9 +33,8 @@
 
 int g_CurSliderVal = 0;
 
-HWND hwnd, icon_button, hwndVolumeSlider, hwndVolumeExpectedLabel;
+HWND g_hwnd, g_icon_button, g_hwndVolumeSlider, g_hwndVolumeExpectedLabel;
 HWND hwndButtonPlayPause, hwndButtonFind, hwndButtonGet, hwndButtonPut, hwndButtonPost, hwndButtonBeginObserve, hwndButtonCancelObserve;
-HINSTANCE hInstance, g_hinstTrackBar, g_hinstVolumeSlider, g_hinstVolumeLabel;
 HANDLE Timer, Thread;
 HICON hIcon1;
 HBRUSH g_BkgndBrush;
@@ -60,8 +59,8 @@ FILE* client_open(const char* path, const char* mode)
     }
 }
 
-int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
-            LPSTR lpCmdLine, int nCmdShow )
+int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
+            LPSTR /* lpCmdLine */, int nCmdShow )
 {
     MSG msg;
     WNDCLASS wc = {sizeof(WNDCLASS)};
@@ -73,78 +72,78 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
     wc.hCursor = LoadCursor (NULL, IDC_ARROW);
 
     RegisterClass(&wc);
-    hwnd = CreateWindow( wc.lpszClassName, TEXT("IoTivity Media Client - Windows UI"),
+    g_hwnd = CreateWindow( wc.lpszClassName, TEXT("IoTivity Media Client - Windows UI"),
                    WS_OVERLAPPEDWINDOW ^ WS_THICKFRAME,
                    100, 100, 275, 170, 0, 0, hInstance, 0);
 
     InitCommonControls(); // loads common control's DLL
 
-    hwndVolumeSlider =
-             CreateTrackbar(hwnd,
+    g_hwndVolumeSlider =
+             CreateTrackbar(g_hwnd,
                             10,10,
                             170,40,
                             0,100,
                             0,0);
-    hwndVolumeExpectedLabel =
-                CreateLabel(hwnd,
+    g_hwndVolumeExpectedLabel =
+                CreateLabel(g_hwnd,
                             "Expected Volume",
                             10,50,
                             240,30);
 
-    LabelPrintf(hwndVolumeExpectedLabel,
+    LabelPrintf(g_hwndVolumeExpectedLabel,
                 "Expected Volume: %i",
                 0);
 
     hwndButtonPlayPause =
-                CreateButton(hwnd,
+                CreateButton(g_hwnd,
                              ID_BUTTONPLAYPAUSE,
                              "PlayPause",
                              180,10,
                              80,35);
 
     hwndButtonFind =
-                CreateButton(hwnd,
+                CreateButton(g_hwnd,
                              ID_BUTTONFIND,
                              "Find",
                              10,75,
                              64,25);
 
     hwndButtonGet =
-                CreateButton(hwnd,
+                CreateButton(g_hwnd,
                              ID_BUTTONGET,
                              "Get",
                              10,105,
                              64,25);
 
     hwndButtonPut =
-                CreateButton(hwnd,
+                CreateButton(g_hwnd,
                              ID_BUTTONPUT,
                              "Put",
                              80,75,
                              64,25);
 
     hwndButtonPost =
-                CreateButton(hwnd,
+                CreateButton(g_hwnd,
                              ID_BUTTONPOST,
                              "Post",
                              80,105,
                              64,25);
     hwndButtonBeginObserve =
-                CreateButton(hwnd,
+                CreateButton(g_hwnd,
                              ID_BUTTONBEGINOBSERVE,
                              "Bgn Obs",
                              150,75,
                              64,25);
     hwndButtonCancelObserve =
-                CreateButton(hwnd,
+                CreateButton(g_hwnd,
                              ID_BUTTONCANCELOBSERVE,
                              "Cncl Obs",
                              150,105,
                              64,25);
 
 
-    ShowWindow(hwnd, nCmdShow);
-    UpdateWindow(hwnd);
+    ShowWindow(g_hwnd, nCmdShow);
+    UpdateWindow(g_hwnd);
 
     while (GetMessage(&msg, NULL, 0, 0))
     {
@@ -167,8 +166,8 @@ WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
       case WM_HSCROLL:
         switch (LOWORD(wParam)) {
             case TB_ENDTRACK:
-                g_CurSliderVal = (int)SendMessage(hwndVolumeSlider, TBM_GETPOS, 0, 0);
-                LabelPrintf(hwndVolumeExpectedLabel,"Volume: %i", g_CurSliderVal);
+                g_CurSliderVal = (int)SendMessage(g_hwndVolumeSlider, TBM_GETPOS, 0, 0);
+                LabelPrintf(g_hwndVolumeExpectedLabel,"Volume: %i", g_CurSliderVal);
 
                 myMedia = app->GetMedia();
                 myMedia.m_volume = g_CurSliderVal;
@@ -180,7 +179,7 @@ WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
       case WM_CREATE:
           {
               hIcon1 = LoadIcon (NULL, IDI_WARNING);
-              SendMessage(icon_button,BM_SETIMAGE,IMAGE_ICON,(LPARAM)hIcon1);
+              SendMessage(g_icon_button,BM_SETIMAGE,IMAGE_ICON,(LPARAM)hIcon1);
               GetClientRect(hwnd, &rect);
               g_BkgndBrush = GetSysColorBrush(COLOR_MENU);