From 423098f35de8c0658ff2a9858dc9dd09a7812b4d Mon Sep 17 00:00:00 2001 From: Pawel Winogrodzki Date: Mon, 12 Jun 2017 17:12:12 -0700 Subject: [PATCH] stack/samples: Removing /W4 warnings. 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: I9b20da2c4ebea8bdb4bbc3b64c7d308060bf258e Signed-off-by: Pawel Winogrodzki Reviewed-on: https://gerrit.iotivity.org/gerrit/20735 Reviewed-by: Dan Mihai Tested-by: jenkins-iotivity Reviewed-by: Ziran Sun --- .../samples/linux/SimpleClientServer/ocserver.cpp | 51 +++++++++++----------- .../linux/SimpleClientServer/ocservercoll.cpp | 10 ++--- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp b/resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp index 40aa69b..cfdb70a 100644 --- a/resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp +++ b/resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp @@ -82,24 +82,23 @@ static bool observeThreadStarted = false; #endif char *gResourceUri = (char *)"/a/light"; -const char *dateOfManufacture = "2016-01-15"; -const char *deviceName = "myDeviceName"; -const char *deviceUUID = "51b55ddc-ccbb-4cb3-a57f-494eeca13a21"; -const char *firmwareVersion = "myFirmwareVersion"; -const char *manufacturerName = "myName"; -const char *operatingSystemVersion = "myOS"; -const char *hardwareVersion = "myHardwareVersion"; -const char *platformID = "0A3E0D6F-DBF5-404E-8719-D6880042463A"; -const char *protocolIndependentID = "6ef9211d-2d5c-401e-8e5d-4b3af48a054f"; -const char *manufacturerLink = "https://www.iotivity.org"; -const char *modelNumber = "myModelNumber"; -const char *platformVersion = "myPlatformVersion"; -const char *supportLink = "https://www.iotivity.org"; -const char *version = "myVersion"; -const char *systemTime = "2015-05-15T11.04"; -const char *specVersion = "ocf.1.1.0"; -const char *dataModelVersions = "ocf.res.1.1.0,ocf.sh.1.1.0"; -const char *deviceType = "oic.d.tv"; +const char *gDateOfManufacture = "2016-01-15"; +const char *gDeviceName = "myDeviceName"; +const char *gDeviceUUID = "51b55ddc-ccbb-4cb3-a57f-494eeca13a21"; +const char *gFirmwareVersion = "myFirmwareVersion"; +const char *gManufacturerName = "myName"; +const char *gOperatingSystemVersion = "myOS"; +const char *gHardwareVersion = "myHardwareVersion"; +const char *gPlatformID = "0A3E0D6F-DBF5-404E-8719-D6880042463A"; +const char *gProtocolIndependentID = "6ef9211d-2d5c-401e-8e5d-4b3af48a054f"; +const char *gManufacturerLink = "https://www.iotivity.org"; +const char *gModelNumber = "myModelNumber"; +const char *gPlatformVersion = "myPlatformVersion"; +const char *gSupportLink = "https://www.iotivity.org"; +const char *gSystemTime = "2015-05-15T11.04"; +const char *gSpecVersion = "ocf.1.1.0"; +const char *gDataModelVersions = "ocf.res.1.1.0,ocf.sh.1.1.0"; +const char *gDeviceType = "oic.d.tv"; OCPlatformInfo platformInfo; @@ -1034,13 +1033,13 @@ OCStackResult SetDeviceInfo() goto exit; } - VERIFY_SUCCESS(OCBindResourceTypeToResource(resourceHandle, deviceType)); - VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_DEVICE_NAME, deviceName)); - VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_SPEC_VERSION, specVersion)); + VERIFY_SUCCESS(OCBindResourceTypeToResource(resourceHandle, gDeviceType)); + VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_DEVICE_NAME, gDeviceName)); + VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_SPEC_VERSION, gSpecVersion)); VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_DATA_MODEL_VERSION, - dataModelVersions)); + gDataModelVersions)); VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID, - protocolIndependentID)); + gProtocolIndependentID)); OIC_LOG(INFO, TAG, "Device information initialized successfully."); return OC_STACK_OK; @@ -1212,9 +1211,9 @@ int main(int argc, char* argv[]) OCSetDefaultDeviceEntityHandler(OCDeviceEntityHandlerCb, NULL); OCStackResult registrationResult = - SetPlatformInfo(platformID, manufacturerName, manufacturerLink, modelNumber, - dateOfManufacture, platformVersion, operatingSystemVersion, - hardwareVersion, firmwareVersion, supportLink, systemTime); + SetPlatformInfo(gPlatformID, gManufacturerName, gManufacturerLink, gModelNumber, + gDateOfManufacture, gPlatformVersion, gOperatingSystemVersion, + gHardwareVersion, gFirmwareVersion, gSupportLink, gSystemTime); if (registrationResult != OC_STACK_OK) { diff --git a/resource/csdk/stack/samples/linux/SimpleClientServer/ocservercoll.cpp b/resource/csdk/stack/samples/linux/SimpleClientServer/ocservercoll.cpp index bedce0d..ac9ea30 100644 --- a/resource/csdk/stack/samples/linux/SimpleClientServer/ocservercoll.cpp +++ b/resource/csdk/stack/samples/linux/SimpleClientServer/ocservercoll.cpp @@ -51,7 +51,7 @@ typedef struct LIGHTRESOURCE{ int power; } LightResource; -static LightResource light; +static LightResource gLight; char *gLightResourceUri= (char *)"/a/light"; char *gRoomResourceUri= (char *)"/a/room"; @@ -473,12 +473,12 @@ void *ChangeLightRepresentation (void *param) while (!gQuitFlag) { sleep(10); - light.power += 5; + gLight.power += 5; if (gLightUnderObservation) { OIC_LOG_V(INFO, TAG, - " =====> Notifying stack of new power level %d\n", light.power); - result = OCNotifyAllObservers (light.handle, OC_NA_QOS); + " =====> Notifying stack of new power level %d\n", gLight.power); + result = OCNotifyAllObservers (gLight.handle, OC_NA_QOS); if (OC_STACK_NO_OBSERVERS == result) { gLightUnderObservation = 0; @@ -564,7 +564,7 @@ int main(int argc, char* argv[]) void createResources() { - light.state = false; + gLight.state = false; OCResourceHandle fan; OCStackResult res = OCCreateResource(&fan, -- 2.7.4