Commit cba0de12 authored by George Nash's avatar George Nash Committed by Nathan Heldt-Sheller

IOT-2539 Cleanup -Wformat= warnings

The -Wformat= warning is given when the conversion specifier
in a printf or scanf command does not match the value actually
passed in.

In this commit all of the issues are found in LOG functions.
If type passed in was a variable size parameter like a pointer or
size_t. The the PRIuPTR value from the inttypes.h
header is used. For ssize_t variables the PRIdPTR was used.

Bug: https://jira.iotivity.org/browse/IOT-2539
Change-Id: I4977253ac7ee68d2e80a26a0963b770b2ce87032
Signed-off-by: George Nash's avatarGeorge Nash <george.nash@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/21771Tested-by: default avatarjenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: default avatarDan Mihai <Daniel.Mihai@microsoft.com>
(cherry picked from commit 60d89aa8
)
parent 79ba615e
......@@ -28,6 +28,7 @@
#include <stddef.h>
#include <stdbool.h>
#include <assert.h>
#include <inttypes.h>
#include "ca_adapter_net_ssl.h"
#include "cacommon.h"
#include "caipinterface.h"
......@@ -588,7 +589,7 @@ static int SendCallBack(void * tep, const unsigned char * data, size_t dataLen)
else if ((size_t)sentLen != dataLen)
{
OIC_LOG_V(DEBUG, NET_SSL_TAG,
"Packet was partially sent - sent/total/remained bytes : %d/%" PRIuPTR "/%" PRIuPTR,
"Packet was partially sent - sent/total/remained bytes : %" PRIdPTR "/%" PRIuPTR "/%" PRIuPTR,
sentLen, dataLen, (dataLen - sentLen));
}
}
......
......@@ -26,6 +26,7 @@
#include "oic_string.h"
#include "oic_malloc.h"
#include <errno.h>
#include <inttypes.h>
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
......@@ -387,7 +388,7 @@ void CALogSendStateInfo(CATransportAdapter_t adapter,
if (true == isSuccess)
{
OIC_LOG_V(DEBUG, ANALYZER_TAG, "Send Success, sent length = [%d]", sentLen);
OIC_LOG_V(DEBUG, ANALYZER_TAG, "Send Success, sent length = [%" PRIdPTR "]", sentLen);
}
else
{
......
......@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include "cafragmentation.h"
......@@ -1367,7 +1368,7 @@ static void CALEServerSendDataThread(void *threadData)
OIC_LOG_V(DEBUG,
CALEADAPTER_TAG,
"Server Sent Unicast First Data - data length [%zu]",
"Server Sent Unicast First Data - data length [%u]",
length);
result = CAGenerateHeader(dataHeader,
......@@ -1780,7 +1781,7 @@ static void CALEClientSendDataThread(void *threadData)
}
OIC_LOG_V(DEBUG,
CALEADAPTER_TAG,
"Client Sent Unicast First Data - data length [%zu]",
"Client Sent Unicast First Data - data length [%u]",
length);
result = CAGenerateHeader(dataHeader,
......@@ -1842,7 +1843,7 @@ static void CALEClientSendDataThread(void *threadData)
}
OIC_LOG_V(DEBUG,
CALEADAPTER_TAG,
"Client Sent Unicast %d Data - data(mtu) length [%zu]",
"Client Sent Unicast %d Data - data(mtu) length [%u]",
index + 1,
g_mtuSize);
}
......@@ -2827,7 +2828,7 @@ static ssize_t CALESecureSendDataCB(CAEndpoint_t *endpoint,
VERIFY_NON_NULL_RET(endpoint, CALEADAPTER_TAG, "endpoint is NULL", -1);
VERIFY_NON_NULL_RET(data, CALEADAPTER_TAG, "data is NULL", -1);
OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "Secure Data Send - encrypted datalen = %d", dataLen);
OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "Secure Data Send - encrypted datalen = %" PRIuPTR, dataLen);
CAResult_t result;
CADataType_t dataType = g_dataType;
......@@ -2881,7 +2882,7 @@ static void CALESecureReceiveDataCB(const CASecureEndpoint_t *sep,
VERIFY_NON_NULL_VOID(sep, CALEADAPTER_TAG, "sep is NULL");
VERIFY_NON_NULL_VOID(data, CALEADAPTER_TAG, "data is NULL");
OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "Secure Data Receive - decrypted datalen = %d", dataLen);
OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "Secure Data Receive - decrypted datalen = %" PRIuPTR, dataLen);
if (dataLen == 0)
{
......@@ -3782,7 +3783,7 @@ static CAResult_t CALEAdapterClientReceivedData(const char *remoteAddress,
// Create bleData to add to queue
OIC_LOG_V(DEBUG,
CALEADAPTER_TAG,
"Data received from LE Client layer [%zu]",
"Data received from LE Client layer [%u]",
dataLength);
CALEData_t * const bleData =
......
......@@ -471,7 +471,7 @@ CAResult_t CAGetNetworkInfo(CAEndpoint_t **info, size_t *size)
OIC_LOG_V(DEBUG,
TAG,
"%" PRIu32 " adapter network info size is %" PRIu32 " res:%d",
"%" PRIuPTR " adapter network info size is %" PRIuPTR " res:%u",
index,
tempSize[index],
res);
......@@ -864,4 +864,3 @@ CAResult_t CAReadData()
return CA_STATUS_OK;
}
#endif
......@@ -1499,7 +1499,7 @@ static void CALogPDUInfo(const CAData_t *data, const coap_pdu_t *pdu)
#ifdef TB_LOG
size_t payloadLen = (pdu->data) ? (unsigned char *)pdu->hdr + pdu->length - pdu->data : 0;
#endif
OIC_LOG_V(DEBUG, ANALYZER_TAG, "CoAP Message Full Size = [%lu]", pdu->length);
OIC_LOG_V(DEBUG, ANALYZER_TAG, "CoAP Message Full Size = [%u]", pdu->length);
OIC_LOG(DEBUG, ANALYZER_TAG, "CoAP Header (+ 0xFF)");
OIC_LOG_BUFFER(DEBUG, ANALYZER_TAG, (const uint8_t *) pdu->transport_hdr,
pdu->length - payloadLen);
......
......@@ -62,6 +62,7 @@
#endif
#include <coap/pdu.h>
#include <inttypes.h>
#include "caipinterface.h"
#include "caipnwmonitor.h"
#include "caadapterutils.h"
......@@ -1197,7 +1198,7 @@ CAResult_t CAIPStartListenServer()
}
size_t len = u_arraylist_length(iflist);
OIC_LOG_V(DEBUG, TAG, "IP network interfaces found: %d", len);
OIC_LOG_V(DEBUG, TAG, "IP network interfaces found: %" PRIuPTR, len);
for (size_t i = 0; i < len; i++)
{
......@@ -1238,7 +1239,7 @@ CAResult_t CAIPStopListenServer()
}
size_t len = u_arraylist_length(iflist);
OIC_LOG_V(DEBUG, TAG, "IP network interfaces found: %d", len);
OIC_LOG_V(DEBUG, TAG, "IP network interfaces found: %" PRIuPTR, len);
for (size_t i = 0; i < len; i++)
{
......
......@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <inttypes.h>
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
......@@ -211,7 +212,7 @@ void CATCPPacketReceivedCB(const CASecureEndpoint_t *sep, const void *data,
}
else
{
OIC_LOG_V(DEBUG, TAG, "%u bytes required for complete CoAP",
OIC_LOG_V(DEBUG, TAG, "%" PRIuPTR " bytes required for complete CoAP",
svritem->totalLen - svritem->len);
}
}
......@@ -230,7 +231,7 @@ static ssize_t CATCPPacketSendCB(CAEndpoint_t *endpoint, const void *data, size_
ssize_t ret = CATCPSendData(endpoint, data, dataLength);
OIC_LOG_V(DEBUG, TAG, "Out %s : %d bytes sent", __func__, ret);
OIC_LOG_V(DEBUG, TAG, "Out %s : %" PRIdPTR " bytes sent", __func__, ret);
return ret;
}
#endif
......
......@@ -66,6 +66,7 @@
#include <coap/pdu.h>
#include <coap/utlist.h>
#include <inttypes.h>
#ifdef __WITH_TLS__
#include "ca_adapter_net_ssl.h"
......@@ -647,7 +648,7 @@ CAResult_t CAConstructCoAP(CATCPSessionInfo_t *svritem, unsigned char **data,
unsigned char *inBuffer = *data;
size_t inLen = *dataLength;
OIC_LOG_V(DEBUG, TAG, "before-datalength : %u", *dataLength);
OIC_LOG_V(DEBUG, TAG, "before-datalength : %" PRIuPTR, *dataLength);
if (NULL == svritem->data && inLen > 0)
{
......@@ -737,7 +738,7 @@ CAResult_t CAConstructCoAP(CATCPSessionInfo_t *svritem, unsigned char **data,
*data = inBuffer;
*dataLength = inLen;
OIC_LOG_V(DEBUG, TAG, "after-datalength : %u", *dataLength);
OIC_LOG_V(DEBUG, TAG, "after-datalength : %" PRIuPTR, *dataLength);
OIC_LOG_V(DEBUG, TAG, "Out %s", __func__);
return CA_STATUS_OK;
}
......@@ -766,10 +767,10 @@ static CAResult_t CAReceiveMessage(CATCPSessionInfo_t *svritem)
//[3][4] bytes in tls header are tls payload length
tlsLength = TLS_HEADER_SIZE +
(size_t)((svritem->tlsdata[3] << 8) | svritem->tlsdata[4]);
OIC_LOG_V(DEBUG, TAG, "toal tls length = %u", tlsLength);
OIC_LOG_V(DEBUG, TAG, "total tls length = %" PRIuPTR, tlsLength);
if (tlsLength > sizeof(svritem->tlsdata))
{
OIC_LOG_V(ERROR, TAG, "toal tls length is too big (buffer size : %u)",
OIC_LOG_V(ERROR, TAG, "total tls length is too big (buffer size : %" PRIuPTR ")",
sizeof(svritem->tlsdata));
return CA_RECEIVE_FAILED;
}
......@@ -790,7 +791,7 @@ static CAResult_t CAReceiveMessage(CATCPSessionInfo_t *svritem)
else
{
svritem->tlsLen += len;
OIC_LOG_V(DEBUG, TAG, "nb_read : %u bytes , recv() : %d bytes, svritem->tlsLen : %u bytes",
OIC_LOG_V(DEBUG, TAG, "nb_read : %" PRIuPTR " bytes , recv() : %d bytes, svritem->tlsLen : %" PRIuPTR " bytes",
nbRead, len, svritem->tlsLen);
if (tlsLength > 0 && tlsLength == svritem->tlsLen)
{
......
......@@ -26,6 +26,7 @@
#include <stddef.h>
#include <string.h>
#include <assert.h>
#include <inttypes.h>
#include "oic_malloc.h"
#include "oic_string.h"
#include "cacommon.h"
......@@ -677,7 +678,7 @@ OCStackResult OC_CALL OCGetUuidFromCSR(const char* csr, OicUuid_t* uuid)
ret = mbedtls_x509_dn_gets(uuidStr, sizeof(uuidStr), &csrObj.subject);
if (ret != (sizeof(uuidStr) - 1))
{
OIC_LOG_V(ERROR, TAG, "mbedtls_x509_dn_gets returned length or error: %d, expected %d", ret, sizeof(uuidStr) - 1);
OIC_LOG_V(ERROR, TAG, "mbedtls_x509_dn_gets returned length or error: %d, expected %" PRIuPTR, ret, sizeof(uuidStr) - 1);
mbedtls_x509_csr_free(&csrObj);
return OC_STACK_ERROR;
}
......
......@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include "ocstack.h"
#include "oic_malloc.h"
......@@ -208,7 +209,7 @@ OCStackResult PstatToCBORPayloadPartial(const OicSecPstat_t *pstat,
pstatMapSize++;
}
}
OIC_LOG_V(INFO, TAG, "%s: creating pstat CBOR payload with %zu Properties.",
OIC_LOG_V(INFO, TAG, "%s: creating pstat CBOR payload with %" PRIuPTR " Properties.",
__func__, pstatMapSize - PSTAT_EMPTY_MAP_SIZE);
// Top Level Pstat Map
......@@ -1263,4 +1264,3 @@ exit:
OICFree(cborPayload);
return ret;
}
......@@ -716,7 +716,7 @@ OCStackResult CBORPayloadToRoles(const uint8_t *cborPayload, size_t size, RoleCe
/* Only SIGNED_ASYMMETRIC_KEY is supported. */
if (SIGNED_ASYMMETRIC_KEY != (OicSecCredType_t)credType)
{
OIC_LOG_V(ERROR, TAG, "Unsupported role credential type: %llu", credType);
OIC_LOG_V(ERROR, TAG, "Unsupported role credential type: %lu", credType);
goto exit;
}
}
......
......@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include "iotivity_config.h"
#include "CoapHttpParser.h"
......@@ -552,7 +553,7 @@ static size_t CHPEasyHandleWriteCb(char *buffer, size_t size, size_t num, void *
void *newPayload = OICRealloc(resp->payload, ctx->writeOffset + dataToWrite);
if (!newPayload)
{
OIC_LOG_V(ERROR, TAG, "Realloc failed! Current: %u Extra: %u", ctx->writeOffset,
OIC_LOG_V(ERROR, TAG, "Realloc failed! Current: %" PRIuPTR " Extra: %" PRIuPTR, ctx->writeOffset,
dataToWrite);
resp->payloadLength = 0;
ctx->writeOffset = 0;
......@@ -567,7 +568,7 @@ static size_t CHPEasyHandleWriteCb(char *buffer, size_t size, size_t num, void *
ctx->writeOffset += dataToWrite;
resp->payloadLength = ctx->writeOffset;
OIC_LOG_V(DEBUG, TAG, "%s OUT %u : %u", __func__, resp->payloadLength, dataToWrite);
OIC_LOG_V(DEBUG, TAG, "%s OUT %" PRIuPTR " : %" PRIuPTR, __func__, resp->payloadLength, dataToWrite);
return dataToWrite;
}
......@@ -867,4 +868,3 @@ OCStackResult CHPPostHttpRequest(HttpRequest_t *req, CHPResponseCallback httpcb,
OIC_LOG_V(DEBUG, TAG, "%s OUT", __func__);
return OC_STACK_OK;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment