Commit ac153614 authored by George Nash's avatar George Nash Committed by Rick Bell

Clean build warnings

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's avatarGeorge Nash <george.nash@intel.com>
parent 714f7564
......@@ -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'])
......
......@@ -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)
{
......
......@@ -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__) */
......@@ -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;
......
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