From: Philippe Coval Date: Thu, 30 Mar 2017 11:38:53 +0000 (+0200) Subject: zigbee_wrapper: Fix types and bitmasks mistakes X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6bf7601fc48fb113c4dd4dfa9d5d7c4d26ed9dab;p=platform%2Fupstream%2Fiotivity.git zigbee_wrapper: Fix types and bitmasks mistakes I am assuming author wanted to use bit mask (& operator) and not "boolean or" (|| operator). This change wasn't tested on device, so double check welcome. Observed warnings using clang on GNU/Linux: plugins/zigbee_wrapper/src/zigbee_wrapper.c:871:27: \ warning: implicit conversion from enumeration type 'OCEntityHandlerResult' to different enumeration type 'OCStackResult' [-Wenum-conversion] stackResult = OC_EH_ERROR; ~ ^~~~~~~~~~~ plugins/zigbee_wrapper/src/zigbee_wrapper.c:1034:39: \ warning: use of logical '||' with constant operand [-Wconstant-logical-operand] if (attributeList.CIEMask || CIE_MOVE_TO_LEVEL) Change-Id: Ieb8f20f121cdd11d5b697c8f8e199bd00ae295ea Signed-off-by: Philippe Coval Reviewed-on: https://gerrit.iotivity.org/gerrit/18403 Tested-by: jenkins-iotivity Reviewed-by: Dave Thaler Reviewed-by: Dan Mihai Reviewed-by: Joseph Morrow (cherry picked from commit cc58983e9d2a050e529ecab9ff04afbea463afa4) Reviewed-on: https://gerrit.iotivity.org/gerrit/19625 Reviewed-by: Todd Malsbary --- diff --git a/plugins/zigbee_wrapper/src/zigbee_wrapper.c b/plugins/zigbee_wrapper/src/zigbee_wrapper.c index af78824..aed5e3c 100644 --- a/plugins/zigbee_wrapper/src/zigbee_wrapper.c +++ b/plugins/zigbee_wrapper/src/zigbee_wrapper.c @@ -867,7 +867,7 @@ OCEntityHandlerResult processGetRequest(PIPluginBase * plugin, if (stackResult != OC_STACK_OK || !outVal) { - stackResult = OC_EH_ERROR; + stackResult = OC_STACK_ERROR; OCRepPayloadDestroy(*payload); goto exit; } @@ -978,7 +978,7 @@ OCEntityHandlerResult processGetRequest(PIPluginBase * plugin, if (boolRes == false) { - stackResult = OC_EH_ERROR; + stackResult = OC_STACK_ERROR; goto exit; } @@ -987,7 +987,8 @@ exit: { OICFree(attributeList.list[attributeListIndex].oicAttribute); } - return stackResult; + + return (stackResult != OC_STACK_OK) ? OC_EH_ERROR : OC_EH_OK; } OCEntityHandlerResult processPutRequest(PIPluginBase * plugin, @@ -1030,7 +1031,7 @@ OCEntityHandlerResult processPutRequest(PIPluginBase * plugin, if (attributeList.list[i].oicType == OIC_ATTR_INT) { char value[MAX_STRLEN_INT] = {}; - if (attributeList.CIEMask || CIE_MOVE_TO_LEVEL) + if (attributeList.CIEMask & CIE_MOVE_TO_LEVEL) { int64_t rangeDiff = 0; // OIC Dimming operates between 0-100, while Zigbee @@ -1134,7 +1135,7 @@ OCEntityHandlerResult processPutRequest(PIPluginBase * plugin, else if (attributeList.list[i].oicType == OIC_ATTR_BOOL) { char * value = attributeList.list[i].val.b ? "1" : "0"; - if (attributeList.CIEMask || CIE_RON_OFF) + if (attributeList.CIEMask & CIE_RON_OFF) { stackResult = TWSwitchOnOff(piResource->nodeId, piResource->endpointId, value, (PIPlugin_Zigbee*)plugin);