Microsoft Azure IoTHub client libraries
Dependents: sht15_remote_monitoring RobotArmDemo iothub_client_sample_amqp f767zi_mqtt ... more
This library implements the Microsoft Azure IoTHub client library. The code is replicated from https://github.com/Azure/azure-iot-sdks
Diff: iothub_client_diagnostic.c
- Revision:
- 89:a2ed767a532e
- Parent:
- 88:248736be106e
- Child:
- 92:97148cf9aa2a
--- a/iothub_client_diagnostic.c Mon Jun 11 15:39:23 2018 -0700 +++ b/iothub_client_diagnostic.c Tue Jun 26 19:14:28 2018 -0700 @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. #include <stdlib.h> +#include <inttypes.h> #include <math.h> #include "azure_c_shared_utility/optimize_size.h" #include "azure_c_shared_utility/gballoc.h" @@ -22,7 +23,7 @@ char* result; time_t epochTime; int timeLen = sizeof(time_t); - + if ((epochTime = get_time(NULL)) == INDEFINITE_TIME) { LogError("Failed getting current time"); @@ -30,8 +31,7 @@ } else if (timeLen == sizeof(int64_t)) { - long long llTime = (long long)epochTime; - if (sprintf(timeBuffer, "%lld", llTime) < 0) + if (sprintf(timeBuffer, "%"PRIu64, (int64_t)epochTime) < 0) { LogError("Failed sprintf to timeBuffer with 8 bytes of time_t"); result = NULL; @@ -43,7 +43,7 @@ } else if (timeLen == sizeof(int32_t)) { - if (sprintf(timeBuffer, "%d", (int32_t)epochTime) < 0) + if (sprintf(timeBuffer, "%"PRIu32, (int32_t)epochTime) < 0) { LogError("Failed sprintf to timeBuffer with 4 bytes of time_t"); result = NULL; @@ -55,10 +55,10 @@ } else { - LogError("Unknow size of time_t"); + LogError("Unknown size of time_t"); result = NULL; } - + return result; } @@ -91,7 +91,7 @@ { double number; double percentage; - + if (diagSetting->currentMessageNumber == UINT32_MAX) { diagSetting->currentMessageNumber %= diagSetting->diagSamplingPercentage * 100; @@ -124,7 +124,7 @@ else { char* timeBuffer; - + (void)generate_eight_random_characters(diagId); result->diagnosticId = diagId;