A modelling and serializer library for Microsoft Azure IoTHub client applications

Dependents:   sht15_remote_monitoring f767zi_mqtt remote_monitoring simplesample_amqp ... more

This library implements a serializer library to be used in projects involving Microsoft Azure IoT Hub connectivity. The code is replicated from https://github.com/Azure/azure-iot-sdks

Revision:
22:422d94bd3c18
Parent:
21:6d3dea1abd9c
Child:
29:f6b8978f8581
diff -r 6d3dea1abd9c -r 422d94bd3c18 agenttypesystem.c
--- a/agenttypesystem.c	Tue Jan 24 15:24:19 2017 -0800
+++ b/agenttypesystem.c	Sat Jan 28 09:35:06 2017 -0800
@@ -282,7 +282,7 @@
                 }
                 else
                 {
-                    memcpy(agentData->value.edmBinary.data, v.data, v.size);
+                    (void)memcpy(agentData->value.edmBinary.data, v.data, v.size);
                     agentData->type = EDM_BINARY_TYPE;
                     agentData->value.edmBinary.size = v.size;
                     result = AGENT_DATA_TYPES_OK;
@@ -2501,7 +2501,7 @@
                     else
                     {
                         dest->value.edmBinary.size = src->value.edmBinary.size;
-                        memcpy(dest->value.edmBinary.data, src->value.edmBinary.data, src->value.edmBinary.size);
+                        (void)memcpy(dest->value.edmBinary.data, src->value.edmBinary.data, src->value.edmBinary.size);
                         dest->type = EDM_BINARY_TYPE;
                         result = AGENT_DATA_TYPES_OK;
                     }
@@ -3013,13 +3013,19 @@
 /*this function only exists because of optimizing valgrind time, otherwise sscanf would be just as good*/
 static int sscanfd(const char *src, int* dst)
 {
+    int result;
     char* next;
-    (*dst) = strtol(src, &next, 10);
-    if ((src == next) || ((((*dst) == LONG_MAX) || ((*dst) == LONG_MIN)) && (errno != 0)))
+    long int temp = strtol(src, &next, 10);
+    if ((src == next) || (((temp == LONG_MAX) || (temp == LONG_MIN)) && (errno != 0)))
     {
-        return EOF;
+        result = EOF;
     }
-    return 1;
+    else
+    {
+        (*dst) = temp;
+        result = 1;
+    }
+    return result;
 }
 
 /*the following function does the same as  sscanf(src, "%llu", &dst), but, it changes the src pointer.*/
@@ -3056,16 +3062,21 @@
 }
 
 /*the following function does the same as  sscanf(src, "%u", &dst)*/
-static int sscanfu(const char*src, unsigned int* dst)
+static int sscanfu(const char* src, unsigned int* dst)
 {
+    int result;
     char* next;
-    (*dst) = strtoul(src, &next, 10);
-    int error = errno;
-    if ((src == next) || (((*dst) == ULONG_MAX) && (error != 0)))
+    unsigned long int temp = strtoul(src, &next, 10);
+    if ((src == next) || ((temp == ULONG_MAX) && (errno != 0)))
     {
-        return EOF; 
+        result = EOF;
     }
-    return 1;
+    else
+    {
+        result = 1;
+        (*dst) = temp;
+    }
+    return result;
 }
 
 /*the following function does the same as  sscanf(src, "%f", &dst)*/
@@ -3074,8 +3085,7 @@
     int result = 1;
     char* next;
     (*dst) = strtof(src, &next);
-    errno_t error = errno;
-    if ((src == next) || (((*dst) == HUGE_VALF) && (error != 0)))
+    if ((src == next) || (((*dst) == HUGE_VALF) && (errno != 0)))
     {
         result = EOF;
     }
@@ -3088,8 +3098,7 @@
     int result = 1;
     char* next;
     (*dst) = strtod(src, &next);
-    errno_t error = errno;
-    if ((src == next) || (((*dst) == HUGE_VALL) && (error != 0)))
+    if ((src == next) || (((*dst) == HUGE_VALL) && (errno != 0)))
     {
         result = EOF;
     }