Clean build warnings 65/23965/3
authorGeorge Nash <george.nash@intel.com>
Fri, 19 Jan 2018 23:30:31 +0000 (15:30 -0800)
committerRick Bell <richard.s.bell@intel.com>
Thu, 1 Feb 2018 23:14:53 +0000 (23:14 +0000)
This cleans new build warnings discovered when building
iotivity with GCC 7.2.1

-Werror=format-truncation
Fixed in json2cbor that was a result of incorrect buffer size in snprintf

-Werror=implicit-fallthrough
With the addition of the [[fallthrough]] keyword in C++17 GCC now detects
fallthrough locations. The fallthrough error can be hidden by adding
the comment "fall through" to the case that is falling though.

-Werror=pragmas and -Werror=attributes
are from the external tinyCbor code. We Ignore build warnings from extern
libraries. We may fix the warnings by working witht he external project
but it should not block any work in IoTivity.

Change-Id: I86c9fb42b987858c66698fe48e4c2a405769b004
Signed-off-by: George Nash <george.nash@intel.com>
resource/csdk/security/SConscript
resource/csdk/security/provisioning/src/pmutility.c
resource/csdk/security/src/ocsecurity.c
resource/csdk/security/tool/json2cbor.c

index 2daa1ae..42e71ed 100644 (file)
@@ -74,6 +74,11 @@ if target_os == 'arduino':
     libocsrm_env.Replace(CC=libocsrm_env.get('CXX'))
     libocsrm_env.Replace(CFLAGS=libocsrm_env.get('CXXFLAGS'))
 
+if target_os in ['linux']:
+    if env.get('ERROR_ON_WARN'):
+        # Ignore warnings from external tinycbor project
+        libocsrm_env.AppendUnique(CFLAGS=['-Wno-error=pragmas', '-Wno-error=attributes'])
+
 if target_os not in ['arduino', 'windows']:
     libocsrm_env.AppendUnique(CPPDEFINES=['WITH_POSIX', '_GNU_SOURCE'])
     libocsrm_env.AppendUnique(CFLAGS=['-std=c99', '-Wall'])
index 43d413f..1ea699a 100644 (file)
@@ -573,6 +573,7 @@ bool OC_CALL PMGenerateQuery(bool isSecure,
     {
         case CT_ADAPTER_TCP:
             prefix = (isSecure == true) ? COAPS_TCP_PREFIX : COAP_TCP_PREFIX;
+            /* fall through */
         case CT_ADAPTER_IP:
             switch(connType & CT_MASK_FLAGS & ~CT_FLAG_SECURE)
             {
index 02f6894..9332d8f 100644 (file)
@@ -73,7 +73,11 @@ static bool GenerateQuery(bool isSecure,
     {
     case CT_ADAPTER_TCP:
         prefix = (isSecure == true) ? COAPS_TCP_PREFIX : COAP_TCP_PREFIX;
-        /* Fall-through to the IP adapter case instead of break here */
+        /*
+         * Fall-through to the IP adapter case instead of break here next
+         * words placed on its own line to satisfy gcc implicit-fallthrough warning
+         */
+        /* fall through */
     case CT_ADAPTER_IP:
         switch (connType & CT_MASK_FLAGS & ~CT_FLAG_SECURE)
         {
@@ -266,4 +270,4 @@ OCStackResult OC_CALL OCAssertRoles(void *ctx, const OCDevAddr *devAddr, OCAsser
     return ret;
 }
 
-#endif /* defined(__WITH_TLS__) || defined(__WITH_DTLS__) */
\ No newline at end of file
+#endif /* defined(__WITH_TLS__) || defined(__WITH_DTLS__) */
index fbe5f9a..7942120 100644 (file)
@@ -1268,7 +1268,7 @@ static OicSecCred_t *JSONToCredBinWithRowner(const char *jsonStr,OicUuid_t *rown
                 VERIFY_NOT_NULL(TAG, buf, ERROR);
                 for(size_t i = 0, p = 0 ; i < jsonObjLen; i+=2, ++p)
                 {
-                    snprintf(tmp, 2, "%c%c", jsonPriv->valuestring[i], jsonPriv->valuestring[i+1]);
+                    snprintf(tmp, sizeof(tmp), "%c%c", jsonPriv->valuestring[i], jsonPriv->valuestring[i+1]);
                     buf[p] = (char)strtol(tmp, NULL, 16);
                 }
                 cred->privateData.len = jsonObjLen/2;
@@ -1297,7 +1297,7 @@ static OicSecCred_t *JSONToCredBinWithRowner(const char *jsonStr,OicUuid_t *rown
                 VERIFY_NOT_NULL(TAG, buf, ERROR);
                 for(size_t i = 0, p = 0 ; i < jsonObjLen; i+=2, ++p)
                 {
-                    snprintf(tmp, 2, "%c%c", jsonPub->valuestring[i], jsonPub->valuestring[i+1]);
+                    snprintf(tmp, sizeof(tmp), "%c%c", jsonPub->valuestring[i], jsonPub->valuestring[i+1]);
                     buf[p] = (char)strtol(tmp, NULL, 16);
                 }
                 cred->publicData.len = jsonObjLen/2;
@@ -1326,7 +1326,7 @@ static OicSecCred_t *JSONToCredBinWithRowner(const char *jsonStr,OicUuid_t *rown
                 VERIFY_NOT_NULL(TAG, buf, ERROR);
                 for(size_t i = 0, p = 0; i < jsonObjLen; i+=2, ++p)
                 {
-                    snprintf(tmp, 2, "%c%c", jsonOpt->valuestring[i], jsonOpt->valuestring[i+1]);
+                    snprintf(tmp, sizeof(tmp), "%c%c", jsonOpt->valuestring[i], jsonOpt->valuestring[i+1]);
                     buf[p] = (char)strtol(tmp, NULL, 16);
                 }
                 cred->optionalData.len = jsonObjLen/2;