Commit 60d89aa8 authored by George Nash's avatar George Nash Committed by Dan Mihai

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>
parent b678dcbb
......@@ -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"
......@@ -528,7 +529,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,
......@@ -1668,7 +1669,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,
......@@ -1730,7 +1731,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);
}
......@@ -2600,7 +2601,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;
......@@ -2654,7 +2655,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)
{
......@@ -3548,7 +3549,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 =
......
......@@ -622,7 +622,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);
......@@ -1019,4 +1019,3 @@ CAResult_t CAReadData()
return CA_STATUS_OK;
}
#endif
......@@ -1426,7 +1426,7 @@ static void CALogPDUInfo(const CAData_t *data, const coap_pdu_t *pdu)
if (pdu->transport_hdr)
{
OIC_LOG_V(DEBUG, ANALYZER_TAG, "Msg ID = [%u]",
OIC_LOG_V(DEBUG, ANALYZER_TAG, "Msg ID = [%u]",
(uint32_t)ntohs(pdu->transport_hdr->udp.id));
}
......@@ -1456,7 +1456,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"
......@@ -1180,7 +1181,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++)
{
......@@ -1225,7 +1226,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, "total tls length = %u", tlsLength);
OIC_LOG_V(DEBUG, TAG, "total tls length = %" PRIuPTR, tlsLength);
if (tlsLength > sizeof(svritem->tlsdata))
{
OIC_LOG_V(ERROR, TAG, "total 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));
if (CA_STATUS_OK != CAcloseSslConnection(&svritem->sep.endpoint))
{
......@@ -795,7 +796,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)
{
......@@ -1160,7 +1161,7 @@ void CATCPStopServer()
if (caglobals.tcp.started)
{
// Ask the receive thread to shut down.
OC_STATIC_ASSERT((WSA_INVALID_EVENT == ((WSAEVENT)NULL)),
OC_STATIC_ASSERT((WSA_INVALID_EVENT == ((WSAEVENT)NULL)),
"The assert() below relies on the default value of "
"caglobals.tcp.updateEvent being WSA_INVALID_EVENT");
assert(caglobals.tcp.updateEvent != WSA_INVALID_EVENT);
......
......@@ -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"
......@@ -100,7 +101,7 @@ OCStackResult OC_CALL OCGenerateRandomSerialNumber(char **serial, size_t *serial
VERIFY_SUCCESS(TAG, OCGetRandomBytes(random, sizeof(random)), ERROR);
/* Per RFC 5280, 20 octets is the maximum length of a serial number. In ASN.1, if the highest-order
* bit is set it causes a padding octet to be written, which would be 21 and non-compliant.
* bit is set it causes a padding octet to be written, which would be 21 and non-compliant.
* Therefore, always clear the highest-order bit. Integers in ASN.1 are always big-Endian.
*/
random[0] &= 0x7F;
......@@ -324,7 +325,7 @@ static OCStackResult GenerateCertificate(
{
ret = mbedtls_x509write_crt_set_basic_constraints(&outCertCtx, 1, -1);
VERIFY_SUCCESS(TAG, 0 == ret, ERROR);
ret = mbedtls_x509write_crt_set_key_usage(&outCertCtx,
ret = mbedtls_x509write_crt_set_key_usage(&outCertCtx,
MBEDTLS_X509_KU_DIGITAL_SIGNATURE | MBEDTLS_X509_KU_KEY_CERT_SIGN);
VERIFY_SUCCESS(TAG, 0 == ret, ERROR);
}
......@@ -339,7 +340,7 @@ static OCStackResult GenerateCertificate(
MBEDTLS_X509_KU_KEY_AGREEMENT);
VERIFY_SUCCESS(TAG, 0 == ret, ERROR);
}
switch (certType)
{
case CERT_TYPE_ROLE:
......@@ -424,7 +425,7 @@ OCStackResult OC_CALL OCGenerateCACertificate(
{
OCStackResult res = OC_STACK_OK;
OCByteString byteStr = { 0 };
res = GenerateCertificate(
CERT_TYPE_CA,
subject,
......@@ -675,7 +676,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 %d Properties.",
OIC_LOG_V(INFO, TAG, "%s: creating pstat CBOR payload with %" PRIuPTR " Properties.",
__func__, pstatMapSize - PSTAT_EMPTY_MAP_SIZE);
// Top Level Pstat Map
......@@ -1276,4 +1277,3 @@ exit:
OICFree(cborPayload);
return ret;
}
......@@ -76,7 +76,7 @@ static RolesEntry_t *gRoles = NULL;
static SymmetricRoleEntry_t *gSymmetricRoles = NULL;
static uint32_t gIdCounter = 1;
/**
/**
* Default cbor payload size. This value is increased in case of CborErrorOutOfMemory.
* The value of payload size is increased until reaching max cbor size.
*/
......@@ -323,7 +323,7 @@ exit:
static bool RoleCertChainContains(RoleCertChain_t *chain, const RoleCertChain_t* roleCert)
{
RoleCertChain_t *temp = NULL;
LL_FOREACH(chain, temp)
{
if (IsSameSecKey(&temp->certificate, &roleCert->certificate) &&
......@@ -709,7 +709,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;
}
}
......@@ -1151,7 +1151,7 @@ OCStackResult GetEndpointRoles(const CAEndpoint_t *endpoint, OicSecRole_t **role
SymmetricRoleEntry_t *curr = NULL;
LL_FOREACH(gSymmetricRoles, curr)
{
if ((UUID_LENGTH == sep.identity.id_length) &&
if ((UUID_LENGTH == sep.identity.id_length) &&
(0 == memcmp(curr->subject.id, sep.identity.id, sizeof(curr->subject.id))))
{
*roles = (OicSecRole_t *)OICCalloc(1, sizeof(OicSecRole_t));
......
......@@ -149,7 +149,7 @@ static OCStackResult WriteBufferToFile(const char *fileName, uint8_t *buffer, si
}
else
{
OIC_LOG_V(ERROR, TAG, "Failed writing %" PRIuPTR " bytes - Error: %" PRIi64,
OIC_LOG_V(ERROR, TAG, "Failed writing %" PRIuPTR " bytes - Error: %d",
size, ferror(fp));
}
if (0 != fclose(fp))
......
......@@ -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