zigbee_wrapper: Fix types and bitmasks mistakes
authorPhilippe Coval <philippe.coval@osg.samsung.com>
Thu, 30 Mar 2017 11:38:53 +0000 (13:38 +0200)
committerTodd Malsbary <todd.malsbary@intel.com>
Fri, 30 Jun 2017 23:08:19 +0000 (23:08 +0000)
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 <philippe.coval@osg.samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/18403
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Dave Thaler <dthaler@microsoft.com>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-by: Joseph Morrow <joseph.l.morrow@intel.com>
(cherry picked from commit cc58983e9d2a050e529ecab9ff04afbea463afa4)
Reviewed-on: https://gerrit.iotivity.org/gerrit/19625
Reviewed-by: Todd Malsbary <todd.malsbary@intel.com>
plugins/zigbee_wrapper/src/zigbee_wrapper.c

index af78824..aed5e3c 100644 (file)
@@ -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);