From df7caefee6e6f3bfa4b23aa4417e574165597f38 Mon Sep 17 00:00:00 2001 From: Abhimanyu Vishwakarma Date: Tue, 27 Sep 2016 12:05:38 +0530 Subject: [PATCH 1/2] fix compiler warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. fix type-punnned pointer warning awalwm2m-0.2.4/core/src/common/lwm2m_tlv.c:344:9: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] int32_t temp = htonl(*(uint32_t*)&f); 2. fix may be used uninitialized warning daemon/src/server/lwm2m_server_xml_handlers.c: In function ‘xmlif_HandlerWriteRequest’: daemon/src/server/lwm2m_server_xml_handlers.c:1781:5: error: ‘root’ may be used uninitialized in this function [-Werror=maybe-uninitialized] Lwm2mTreeNode_DeleteRecursive(root); ^ Signed-off-by: Abhimanyu Vishwakarma --- core/src/common/lwm2m_tlv.c | 8 ++++++-- daemon/src/server/lwm2m_server_xml_handlers.c | 3 +-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/core/src/common/lwm2m_tlv.c b/core/src/common/lwm2m_tlv.c index d730379..eae58b8 100644 --- a/core/src/common/lwm2m_tlv.c +++ b/core/src/common/lwm2m_tlv.c @@ -341,12 +341,16 @@ static int TlvEncodeFloat(uint8_t * buffer, int bufferLen, int type, int id, dou if (floatSize == 4) { float f = value; - int32_t temp = htonl(*(uint32_t*)&f); + int32_t temp; + memcpy(&temp, &f, sizeof(temp)); + temp = htonl(temp); memcpy(valueBuffer, &temp, floatSize); } else if (floatSize == 8) { - int64_t temp = htonll(*(uint64_t*)&value); + int64_t temp; + memcpy(&temp, &value, sizeof(temp)); + temp = htonll(temp); memcpy(valueBuffer, &temp, floatSize); } // once encoded, we can just treat this as opaque diff --git a/daemon/src/server/lwm2m_server_xml_handlers.c b/daemon/src/server/lwm2m_server_xml_handlers.c index 556e02d..c8726ee 100644 --- a/daemon/src/server/lwm2m_server_xml_handlers.c +++ b/daemon/src/server/lwm2m_server_xml_handlers.c @@ -1482,14 +1482,13 @@ static int xmlif_HandlerWriteRequest(RequestInfoType * request, TreeNode content IpcCoapRequestContext * requestContext; Lwm2mClientType * client; int numCoapRequests = 0; + Lwm2mTreeNode * root = NULL; if (xmlif_HandleRequestHeader(request, content, &requestContext, &requestObjectsNode, &client) != 0) { goto error; } - Lwm2mTreeNode * root = NULL; - TreeNode requestClientNode = TreeNode_GetParent(requestObjectsNode); AwaWriteMode defaultWriteMode = AwaWriteMode_LAST; From c4b7eb360bf165852633788a0a3465edbb8b8a21 Mon Sep 17 00:00:00 2001 From: Abhimanyu Vishwakarma Date: Tue, 27 Sep 2016 15:27:02 +0530 Subject: [PATCH 2/2] add new WITH_SYSTEMD compile option install systemd service file only if WITH_SYSTEMD is enabled as not all system will use systemd by default especially embedded systems. Signed-off-by: Abhimanyu Vishwakarma --- CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 58e0ecf..7772efa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ option (WITH_ERBIUM "Enable Erbium CoAP support)" ON) option (WITH_GNUTLS "Enable GnuTLS DTLS support" OFF) option (WITH_CYASSL "Enable CyaSSL DTLS support" OFF) option (WITH_TINYDTLS "Enable TinyDTLS DTLS support" OFF) +option (WITH_SYSTEMD "Install systemd service files" OFF) if (WITH_LIBCOAP) message (WARNING "Disabling erbium support") @@ -73,7 +74,9 @@ add_subdirectory (api) add_subdirectory (tools) # install systemd files -install ( - DIRECTORY systemd/ - DESTINATION / -) +if (WITH_SYSTEMD) + install ( + DIRECTORY systemd/ + DESTINATION / + ) +endif ()