Fixing Build Errors after applying -Werror 09/23009/6
authorAbhishek Pandey <abhi.siso@samsung.com>
Thu, 26 Oct 2017 08:43:31 +0000 (14:13 +0530)
committerAshok Babu Channa <ashok.channa@samsung.com>
Fri, 27 Oct 2017 11:45:52 +0000 (11:45 +0000)
JIRA IOT-2845: https://jira.iotivity.org/browse/IOT-2845

This seems to be side effect of JIRA [IOT-2539]. Build is
breaking on some linux platforms (i.e. i686). Most
compilation errors are related to printf format
specifiers. Probably this wasn't caught by jenkins
when merging patch for IOT-2845 due to its system
configuration matches expected size for all data types.

Fixed the error by using portable format specifiers while
logging.

%PRId - for int64_t
%PRIu - for unit64_t
%PRIuPTR - for size_t (unsigned)

Change-Id: I30a21cacdddc84776392100ee783ccbe7e1eae0d
Signed-off-by: Abhishek Pandey <abhi.siso@samsung.com>
resource/csdk/connectivity/src/camessagehandler.c
resource/csdk/security/src/rolesresource.c
resource/csdk/stack/include/payload_logging.h

index 4f83171..a3eab7d 100644 (file)
@@ -1503,11 +1503,11 @@ static void CALogPDUInfo(const CAData_t *data, const coap_pdu_t *pdu)
     OIC_LOG(DEBUG, ANALYZER_TAG, "CoAP Header (+ 0xFF)");
     OIC_LOG_BUFFER(DEBUG, ANALYZER_TAG,  (const uint8_t *) pdu->transport_hdr,
                    pdu->length - payloadLen);
-    OIC_LOG_V(DEBUG, ANALYZER_TAG, "CoAP Header size = [%lu]", pdu->length - payloadLen);
+    OIC_LOG_V(DEBUG, ANALYZER_TAG, "CoAP Header size = [%" PRIuPTR "]", (size_t) pdu->length - payloadLen);
 
     OIC_LOG_V(DEBUG, ANALYZER_TAG, "CoAP Payload");
     //OIC_LOG_BUFFER(DEBUG, ANALYZER_TAG, pdu->data, payloadLen);
-    OIC_LOG_V(DEBUG, ANALYZER_TAG, "CoAP Payload Size = [%lu]", payloadLen);
+    OIC_LOG_V(DEBUG, ANALYZER_TAG, "CoAP Payload Size = [%" PRIuPTR "]", payloadLen);
     OIC_LOG(DEBUG, ANALYZER_TAG, "=================================================");
     OIC_TRACE_END();
 }
index 5861723..2b7f60d 100644 (file)
@@ -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: %lu", credType);
+                                    OIC_LOG_V(ERROR, TAG, "Unsupported role credential type: %" PRIu64 , credType);
                                     goto exit;
                                 }
                             }
index a801524..51dc912 100644 (file)
@@ -64,7 +64,7 @@ INLINE_API void OCPayloadLogRepValues(LogLevel level, OCRepPayloadValue* val)
                 OIC_LOG_V(level, PL_TAG, "\t\t%s: NULL", val->name);
                 break;
             case OCREP_PROP_INT:
-                OIC_LOG_V(level, PL_TAG, "\t\t%s(int):%zd", val->name, val->i);
+                OIC_LOG_V(level, PL_TAG, "\t\t%s(int):%" PRId64, val->name, val->i);
                 break;
             case OCREP_PROP_DOUBLE:
                 OIC_LOG_V(level, PL_TAG, "\t\t%s(double):%f", val->name, val->d);
@@ -96,7 +96,7 @@ INLINE_API void OCPayloadLogRepValues(LogLevel level, OCRepPayloadValue* val)
                         OIC_LOG(level, PL_TAG, "\t\t Values:");
                         for (size_t i = 0; i < val->arr.dimensions[0]; i++)
                         {
-                            OIC_LOG_V(level, PL_TAG, "\t\t\t %zd", val->arr.iArray[i]);
+                            OIC_LOG_V(level, PL_TAG, "\t\t\t %" PRId64, val->arr.iArray[i]);
                         }
                         break;
                     case OCREP_PROP_DOUBLE: