mirror of
https://github.com/eclipse/wakaama.git
synced 2025-05-08 23:31:37 +08:00
Fix signed integer comparison warnings
This will silence -Wsign-compare warnings.
This commit is contained in:
parent
c70c6a90d4
commit
27ab8059ff
@ -17,6 +17,7 @@
|
||||
*******************************************************************************/
|
||||
|
||||
#include "internals.h"
|
||||
#include <math.h>
|
||||
|
||||
#ifdef LWM2M_SUPPORT_SENML_CBOR
|
||||
|
||||
@ -139,8 +140,6 @@ static int prv_parseItem(const uint8_t *buffer, size_t bufferLen, senml_record_t
|
||||
bvSeen = true;
|
||||
memcpy(baseValue, &data, sizeof(lwm2m_data_t));
|
||||
/* Convert explicit 0 to implicit 0 */
|
||||
_Pragma("GCC diagnostic push");
|
||||
_Pragma("GCC diagnostic ignored \"-Wfloat-equal\"");
|
||||
switch (baseValue->type) {
|
||||
case LWM2M_TYPE_INTEGER:
|
||||
if (baseValue->value.asInteger == 0) {
|
||||
@ -153,7 +152,7 @@ static int prv_parseItem(const uint8_t *buffer, size_t bufferLen, senml_record_t
|
||||
}
|
||||
break;
|
||||
case LWM2M_TYPE_FLOAT:
|
||||
if (baseValue->value.asFloat == 0.0) {
|
||||
if (fpclassify(baseValue->value.asFloat) == FP_ZERO) {
|
||||
baseValue->type = LWM2M_TYPE_UNDEFINED;
|
||||
}
|
||||
break;
|
||||
@ -161,7 +160,6 @@ static int prv_parseItem(const uint8_t *buffer, size_t bufferLen, senml_record_t
|
||||
// Only numeric types are valid
|
||||
return -1;
|
||||
}
|
||||
_Pragma("GCC diagnostic pop");
|
||||
break;
|
||||
case SENML_CBOR_BASE_TIME_LABEL:
|
||||
if (btSeen)
|
||||
|
@ -90,7 +90,7 @@ static void cbor_test_data_expected(const char *uriStr, lwm2m_data_t *dataP, con
|
||||
return;
|
||||
}
|
||||
|
||||
CU_ASSERT_EQUAL(length, expectLen);
|
||||
CU_ASSERT_EQUAL(length, (int)expectLen);
|
||||
if (length == (int)expectLen) {
|
||||
if (memcmp(buffer, expectBuf, expectLen) != 0) {
|
||||
printf("(Serialize lwm2m_data_t %s to %s differs from expected.)\t", id, STR_MEDIA_TYPE(format));
|
||||
|
@ -89,7 +89,7 @@ static void senml_cbor_test_data_and_compare(const char *uriStr, lwm2m_media_typ
|
||||
}
|
||||
|
||||
if (format != LWM2M_CONTENT_JSON && format != LWM2M_CONTENT_SENML_JSON) {
|
||||
CU_ASSERT_EQUAL(original_length, length);
|
||||
CU_ASSERT_EQUAL(length, (int)original_length);
|
||||
|
||||
if ((original_length != (size_t)length) || (memcmp(original_buffer, buffer, length) != 0)) {
|
||||
printf("Comparing buffer after parse/serialize failed for %s:\n", id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user