[IOT-2808]Static Analysis warning fixes for NS. 15/22815/6
authorabitha.s <abitha.s@samsung.com>
Fri, 13 Oct 2017 05:40:32 +0000 (11:10 +0530)
committerAshok Babu Channa <ashok.channa@samsung.com>
Mon, 16 Oct 2017 18:25:17 +0000 (18:25 +0000)
1. Indentation fixes.
2. Uninitialized variable fixes

Change-Id: Iea41f46fcd1540cf8ef3985a030fa7b07e399681
Signed-off-by: abitha.s <abitha.s@samsung.com>
service/notification/cpp-wrapper/common/NSException.h
service/notification/examples/linux/cloud_connector.c
service/notification/src/consumer/NSConsumerScheduler.c
service/notification/src/provider/NSProviderNotification.c

index 01fec7b..8624546 100644 (file)
@@ -45,19 +45,23 @@ namespace OIC
                       *
                       * @param message - String describing the error messsage.
                       */
-                NSException(const std::string &message) : m_message(message) {}
+                NSException(const std::string &message) : m_message(message)
+                {
+                }
 
                 /**
                       * API to get error message describing exception reason.
                       *
                       * @return Null terminated string.
                       */
-                virtual const char *what() const noexcept                
+                virtual const char *what() const noexcept
                 {
                     return m_message.c_str();
                 }
 
-                virtual ~NSException() throw() {}
+                virtual ~NSException() throw()
+                {
+                }
 
             private:
                 std::string m_message;
index 99190d5..117592f 100644 (file)
@@ -134,32 +134,32 @@ void printRepresentation(OCRepPayloadValue *value)
                 printf("Key: %s / ", value->name);
                 switch (value->type)
                 {
-                case OCREP_PROP_NULL:
-                        printf("Value: None\n");
-                        break;
-                case OCREP_PROP_INT:
-                        printf("Value: %ld\n", value->i);
-                        break;
-                case OCREP_PROP_DOUBLE:
-                        printf("Value: %f\n", value->d);
-                        break;
-                case OCREP_PROP_BOOL:
-                        printf("Value: %d\n", value->b);
-                        break;
-                case OCREP_PROP_STRING:
-                        printf("Value: %s\n", value->str);
-                        break;
-                case OCREP_PROP_BYTE_STRING:
-                        printf("Value: Byte String\n");
-                        break;
-                case OCREP_PROP_OBJECT:
-                        printf("Value: Object\n");
-                        break;
-                case OCREP_PROP_ARRAY:
-                        printf("Value: Array\n");
-                        break;
-                default:
-                        break;
+                    case OCREP_PROP_NULL:
+                            printf("Value: None\n");
+                            break;
+                    case OCREP_PROP_INT:
+                            printf("Value: %ld\n", value->i);
+                            break;
+                    case OCREP_PROP_DOUBLE:
+                            printf("Value: %f\n", value->d);
+                            break;
+                    case OCREP_PROP_BOOL:
+                            printf("Value: %d\n", value->b);
+                            break;
+                    case OCREP_PROP_STRING:
+                            printf("Value: %s\n", value->str);
+                            break;
+                    case OCREP_PROP_BYTE_STRING:
+                            printf("Value: Byte String\n");
+                            break;
+                    case OCREP_PROP_OBJECT:
+                            printf("Value: Object\n");
+                            break;
+                    case OCREP_PROP_ARRAY:
+                            printf("Value: Array\n");
+                            break;
+                    default:
+                            break;
                 }
                 value = value->next;
         }
index c313453..0ae571f 100644 (file)
@@ -123,10 +123,9 @@ void NSConsumerMessageHandlerExit()
     while (!NSIsQueueEmpty(g_queue))
     {
         NSConsumerQueueObject * obj = NSPopQueue(g_queue);
-        NS_LOG_V(DEBUG, "Execute remaining task type : %d", ((NSTask *)(obj->data))->taskType);
-
         if (obj)
         {
+            NS_LOG_V(DEBUG, "Execute remaining task type : %d", ((NSTask *)(obj->data))->taskType);
             NSConsumerTaskProcessing((NSTask *)(obj->data));
             NSOICFree(obj);
         }
index f97ef2c..648f0a6 100644 (file)
@@ -90,16 +90,22 @@ OCStackResult NSProviderPublishTopic(OCRepPayload * payload, OCClientResponseHan
 
     NSMQServerInfo * serverInfo = NSGetMQServerInfo();
 
-    if (serverInfo)
+    if (!serverInfo)
     {
-        NS_LOG(DEBUG, "serverInfo is not NULL");
-        NS_LOG_V(DEBUG, "serverInfo->serverUri = %s", serverInfo->serverUri);
+        NS_LOG(DEBUG, "serverInfo is NULL");
+        return OC_STACK_ERROR;
+    }
+    NS_LOG_V(DEBUG, "serverInfo->serverUri = %s", serverInfo->serverUri);
+    OCStackResult res = OCDoResource(NULL, OC_REST_POST, serverInfo->serverUri, serverInfo->devAddr,
+            (OCPayload *)payload, CT_ADAPTER_TCP, OC_LOW_QOS, &cbData, NULL, 0);
+    if (OC_STACK_OK != res)
+    {
+        NS_LOG_V(ERROR, "Failed to send publish request! (err=%d)",  res);
+        return res;
     }
 
     NS_LOG(DEBUG, "NSProviderPublishTopic - OUT");
-
-    return OCDoResource(NULL, OC_REST_POST, serverInfo->serverUri, serverInfo->devAddr,
-            (OCPayload *)payload, CT_ADAPTER_TCP, OC_LOW_QOS, &cbData, NULL, 0);
+    return res;
 }
 #endif