IOT-2539 Fix -Wswitch simulator 93/22893/2
authorGeorge Nash <george.nash@intel.com>
Tue, 17 Oct 2017 23:20:04 +0000 (16:20 -0700)
committerUze Choi <uzchoi@samsung.com>
Thu, 19 Oct 2017 06:42:20 +0000 (06:42 +0000)
Fixed the switch warning in the simulator code.

In the request_model_builder the other posible values
for the switch are not expected if they occure print
an error and exit assert. Just in case it is a release
build an empty string is returned.

In simulatory_utils the un-handled case statments were
added to the switch.

Bug: https://jira.iotivity.org/browse/IOT-2539
Change-Id: Iebb79bd22410727c65c33ed73ec8704a1b8a33a4
Signed-off-by: George Nash <george.nash@intel.com>
service/simulator/src/common/request_model_builder.cpp
service/simulator/src/common/simulator_utils.cpp

index 51257a9..6f1fbbd 100644 (file)
@@ -22,6 +22,7 @@
 #include "resource_model_schema_builder.h"
 #include "logger.h"
 #include "Raml.h"
+#include <assert.h>
 
 #define TAG "REQ_MODEL_BUILDER"
 
@@ -37,6 +38,10 @@ static std::string getRequestType(RAML::ActionType actionType)
             return "POST";
         case RAML::ActionType::DELETE:
             return "DELETE";
+        default:
+            OIC_LOG(ERROR, TAG, "Unsupported RequestType!");
+            assert(0);
+            return "";
     }
 
     return ""; // This code should never reach
index 6625203..43e6845 100644 (file)
@@ -124,6 +124,12 @@ std::string getPayloadTypeString(OCPayloadType type)
         case PAYLOAD_TYPE_DISCOVERY:
             typeStr = "PAYLOAD_TYPE_DISCOVERY";
             break;
+        case PAYLOAD_TYPE_DEVICE:
+            typeStr = "PAYLOAD_TYPE_DEVICE";
+            break;
+        case PAYLOAD_TYPE_PLATFORM:
+            typeStr = "PAYLOAD_TYPE_PLATFORM";
+            break;
         case PAYLOAD_TYPE_REPRESENTATION:
             typeStr = "PAYLOAD_TYPE_REPRESENTATION";
             break;
@@ -133,6 +139,12 @@ std::string getPayloadTypeString(OCPayloadType type)
         case PAYLOAD_TYPE_PRESENCE:
             typeStr = "PAYLOAD_TYPE_PRESENCE";
             break;
+        case PAYLOAD_TYPE_DIAGNOSTIC:
+            typeStr = "PAYLOAD_TYPE_DIAGNOSTIC";
+            break;
+        case PAYLOAD_TYPE_INTROSPECTION:
+            typeStr = "PAYLOAD_TYPE_INTROSPECTION";
+            break;
     }
     return typeStr;
 }