From 3edea6790968124467a1788922741b34233cf4b9 Mon Sep 17 00:00:00 2001 From: "dh79.pyun@samsung.com" Date: Tue, 17 Apr 2018 15:31:54 +0900 Subject: [PATCH] Fix Asan build errors (#281) Remove duplicate variables multiple definition of `g_ESEasySetupResource' multiple definition of `g_ESDevConfResource' multiple definition of `g_ESCoapCloudConfResource' multiple definition of `g_ESWiFiConfResource' https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/281 (cherry picked from commit 0cbbcfa65ff14d751dd1193f75b7c20269e26991) Change-Id: If5f4a7d87e95350d70187cb21e070c5193130487 Signed-off-by: Oleg Ogurtsov Signed-off-by: DoHyun Pyun --- build_common/SConscript | 1 + extlibs/mbedtls/SConscript | 5 +++++ extlibs/mbedtls/mbedtls/configs/config-mini-tls1_1.h | 2 ++ extlibs/mbedtls/mbedtls/configs/config-picocoin.h | 2 ++ extlibs/mbedtls/mbedtls/configs/config-suite-b.h | 2 ++ extlibs/mbedtls/mbedtls/configs/config-thread.h | 2 ++ extlibs/mbedtls/mbedtls/include/mbedtls/config.h | 6 ++++++ service/easy-setup/enrollee/src/samsung/sc_easysetup.c | 5 ----- .../notification/src/provider/NSProviderCallbackResponse.c | 2 +- service/notification/src/provider/NSProviderMemoryCache.c | 3 +++ service/notification/src/provider/NSProviderMemoryCache.h | 4 ++-- service/notification/src/provider/NSProviderSubscription.c | 2 ++ service/notification/src/provider/NSProviderSubscription.h | 2 +- service/notification/src/provider/NSProviderTopic.c | 3 +++ service/notification/src/provider/NSProviderTopic.h | 4 ++-- 15 files changed, 34 insertions(+), 11 deletions(-) mode change 100755 => 100644 service/easy-setup/enrollee/src/samsung/sc_easysetup.c diff --git a/build_common/SConscript b/build_common/SConscript index b373665da..e16a27d80 100644 --- a/build_common/SConscript +++ b/build_common/SConscript @@ -104,6 +104,7 @@ help_vars.Add(ListVariable('RD_MODE', 'Resource Directory build mode', 'CLIENT', help_vars.Add(BoolVariable('SIMULATOR', 'Build with simulator module', False)) help_vars.Add(BoolVariable('WITH_RA_IBB', 'Build with Remote Access module(workssys)', False)) +help_vars.Add(BoolVariable('WITH_ASAN', 'Build with Address Sanitizer support', False)) if target_os in targets_disallow_multitransport: diff --git a/extlibs/mbedtls/SConscript b/extlibs/mbedtls/SConscript index cfcec9dab..152c4baab 100644 --- a/extlibs/mbedtls/SConscript +++ b/extlibs/mbedtls/SConscript @@ -77,6 +77,11 @@ mbedtls_env.PrependUnique(CPPPATH = [mbedtls_dir]) mbedtls_env.AppendUnique(CPPPATH = [mbedtls_dir+'include/']) mbedtls_env.AppendUnique(CFLAGS = ['-fPIC', '-Wall']) +asan_build = env.get('WITH_ASAN') +print 'Asan build: {}'.format(asan_build) +if asan_build: + mbedtls_env.AppendUnique(CFLAGS = ['-UMBEDTLS_HAVE_ASM']) + ###################################################################### # Source files and Target(s) ###################################################################### diff --git a/extlibs/mbedtls/mbedtls/configs/config-mini-tls1_1.h b/extlibs/mbedtls/mbedtls/configs/config-mini-tls1_1.h index e22363d1a..2d6d5ac1b 100644 --- a/extlibs/mbedtls/mbedtls/configs/config-mini-tls1_1.h +++ b/extlibs/mbedtls/mbedtls/configs/config-mini-tls1_1.h @@ -29,7 +29,9 @@ #define MBEDTLS_CONFIG_H /* System support */ +#if !defined(__SANITIZE_ADDRESS__) #define MBEDTLS_HAVE_ASM +#endif #define MBEDTLS_HAVE_TIME /* mbed TLS feature support */ diff --git a/extlibs/mbedtls/mbedtls/configs/config-picocoin.h b/extlibs/mbedtls/mbedtls/configs/config-picocoin.h index 26b24a9e2..7fe0ee761 100644 --- a/extlibs/mbedtls/mbedtls/configs/config-picocoin.h +++ b/extlibs/mbedtls/mbedtls/configs/config-picocoin.h @@ -33,7 +33,9 @@ #define MBEDTLS_CONFIG_H /* System support */ +#if !defined(__SANITIZE_ADDRESS__) #define MBEDTLS_HAVE_ASM +#endif #define MBEDTLS_HAVE_TIME /* mbed TLS feature support */ diff --git a/extlibs/mbedtls/mbedtls/configs/config-suite-b.h b/extlibs/mbedtls/mbedtls/configs/config-suite-b.h index 3c4804c79..45ad8d23a 100644 --- a/extlibs/mbedtls/mbedtls/configs/config-suite-b.h +++ b/extlibs/mbedtls/mbedtls/configs/config-suite-b.h @@ -36,7 +36,9 @@ #define MBEDTLS_CONFIG_H /* System support */ +#if !defined(__SANITIZE_ADDRESS__) #define MBEDTLS_HAVE_ASM +#endif #define MBEDTLS_HAVE_TIME /* mbed TLS feature support */ diff --git a/extlibs/mbedtls/mbedtls/configs/config-thread.h b/extlibs/mbedtls/mbedtls/configs/config-thread.h index 990fe08c6..f1f8ff575 100644 --- a/extlibs/mbedtls/mbedtls/configs/config-thread.h +++ b/extlibs/mbedtls/mbedtls/configs/config-thread.h @@ -35,7 +35,9 @@ #define MBEDTLS_CONFIG_H /* System support */ +#if !defined(__SANITIZE_ADDRESS__) #define MBEDTLS_HAVE_ASM +#endif /* mbed TLS feature support */ #define MBEDTLS_AES_ROM_TABLES diff --git a/extlibs/mbedtls/mbedtls/include/mbedtls/config.h b/extlibs/mbedtls/mbedtls/include/mbedtls/config.h index 9798b395a..083c56e23 100644 --- a/extlibs/mbedtls/mbedtls/include/mbedtls/config.h +++ b/extlibs/mbedtls/mbedtls/include/mbedtls/config.h @@ -39,6 +39,7 @@ * \{ */ +#if !defined(__SANITIZE_ADDRESS__) /** * \def MBEDTLS_HAVE_ASM * @@ -54,6 +55,7 @@ * Comment to disable the use of assembly code. */ #define MBEDTLS_HAVE_ASM +#endif /** * \def MBEDTLS_HAVE_SSE2 @@ -1404,6 +1406,7 @@ * \{ */ +#if !defined(__SANITIZE_ADDRESS__) /** * \def MBEDTLS_AESNI_C * @@ -1417,6 +1420,7 @@ * This modules adds support for the AES-NI instructions on x86-64 */ #define MBEDTLS_AESNI_C +#endif /** * \def MBEDTLS_AES_C @@ -2006,6 +2010,7 @@ */ #define MBEDTLS_OID_C +#if !defined(__SANITIZE_ADDRESS__) /** * \def MBEDTLS_PADLOCK_C * @@ -2019,6 +2024,7 @@ * This modules adds support for the VIA PadLock on x86. */ #define MBEDTLS_PADLOCK_C +#endif /** * \def MBEDTLS_PEM_PARSE_C diff --git a/service/easy-setup/enrollee/src/samsung/sc_easysetup.c b/service/easy-setup/enrollee/src/samsung/sc_easysetup.c old mode 100755 new mode 100644 index 5c7a2e3b0..e86e1b92e --- a/service/easy-setup/enrollee/src/samsung/sc_easysetup.c +++ b/service/easy-setup/enrollee/src/samsung/sc_easysetup.c @@ -37,11 +37,6 @@ */ #define SC_ENROLLEE_TAG "ES_SC_ENROLLEE" -EasySetupResource g_ESEasySetupResource; -WiFiConfResource g_ESWiFiConfResource; -CoapCloudConfResource g_ESCoapCloudConfResource; -DevConfResource g_ESDevConfResource; - SCProperties g_SCProperties; static void ReadAccountData(OCRepPayload* payload,void** userdata); diff --git a/service/notification/src/provider/NSProviderCallbackResponse.c b/service/notification/src/provider/NSProviderCallbackResponse.c index e702bab13..2902df04e 100644 --- a/service/notification/src/provider/NSProviderCallbackResponse.c +++ b/service/notification/src/provider/NSProviderCallbackResponse.c @@ -34,7 +34,7 @@ static NSSubscribeRequestCallback g_subscribeRequestCb = NULL; static NSProviderSyncInfoCallback g_syncCb = NULL; -pthread_mutex_t nsInitMutex; +extern pthread_mutex_t nsInitMutex; void NSRegisterSubscribeRequestCb(NSSubscribeRequestCallback subscribeRequestCb) { diff --git a/service/notification/src/provider/NSProviderMemoryCache.c b/service/notification/src/provider/NSProviderMemoryCache.c index 9e4dd6935..484f6238d 100644 --- a/service/notification/src/provider/NSProviderMemoryCache.c +++ b/service/notification/src/provider/NSProviderMemoryCache.c @@ -34,6 +34,9 @@ } \ } +pthread_mutex_t NSCacheMutex; +pthread_mutexattr_t NSCacheMutexAttr; + NSCacheList * NSProviderStorageCreate() { pthread_mutex_lock(&NSCacheMutex); diff --git a/service/notification/src/provider/NSProviderMemoryCache.h b/service/notification/src/provider/NSProviderMemoryCache.h index df2733d97..05440f811 100644 --- a/service/notification/src/provider/NSProviderMemoryCache.h +++ b/service/notification/src/provider/NSProviderMemoryCache.h @@ -57,7 +57,7 @@ bool NSProviderIsTopicSubScribed(NSCacheElement * conTopicList, char * cId, char NSResult NSProviderDeleteConsumerTopic(NSCacheList * conTopicList, NSCacheTopicSubData * topicSubData); -pthread_mutex_t NSCacheMutex; -pthread_mutexattr_t NSCacheMutexAttr; +extern pthread_mutex_t NSCacheMutex; +extern pthread_mutexattr_t NSCacheMutexAttr; #endif /* _NS_PROVIDER_CACHEADAPTER__H_ */ diff --git a/service/notification/src/provider/NSProviderSubscription.c b/service/notification/src/provider/NSProviderSubscription.c index 3116cbb4f..3d01f3edf 100644 --- a/service/notification/src/provider/NSProviderSubscription.c +++ b/service/notification/src/provider/NSProviderSubscription.c @@ -21,6 +21,8 @@ #include "NSProviderSubscription.h" #include "NSProviderListener.h" +NSCacheList * consumerSubList; + NSResult NSInitSubscriptionList() { NS_LOG(DEBUG, "NSInitSubscriptionList - IN"); diff --git a/service/notification/src/provider/NSProviderSubscription.h b/service/notification/src/provider/NSProviderSubscription.h index dd112731c..89acd5ea8 100644 --- a/service/notification/src/provider/NSProviderSubscription.h +++ b/service/notification/src/provider/NSProviderSubscription.h @@ -34,7 +34,7 @@ #include "oic_malloc.h" #include -NSCacheList * consumerSubList; +extern NSCacheList * consumerSubList; NSResult NSInitSubscriptionList(); NSResult NSSetSubscriptionAccessPolicy(bool policy); diff --git a/service/notification/src/provider/NSProviderTopic.c b/service/notification/src/provider/NSProviderTopic.c index 055dc47b3..f6aa8e941 100644 --- a/service/notification/src/provider/NSProviderTopic.c +++ b/service/notification/src/provider/NSProviderTopic.c @@ -23,6 +23,9 @@ #include "oic_malloc.h" #include +NSCacheList * consumerTopicList; +NSCacheList * registeredTopicList; + NSResult NSSendTopicUpdation(); NSResult NSInitTopicList() diff --git a/service/notification/src/provider/NSProviderTopic.h b/service/notification/src/provider/NSProviderTopic.h index f75a1f58c..5c858454b 100644 --- a/service/notification/src/provider/NSProviderTopic.h +++ b/service/notification/src/provider/NSProviderTopic.h @@ -42,8 +42,8 @@ typedef struct { NSResult result; } NSTopicSyncResult; -NSCacheList * consumerTopicList; -NSCacheList * registeredTopicList; +extern NSCacheList * consumerTopicList; +extern NSCacheList * registeredTopicList; NSResult NSInitTopicList(); NSTopicList * NSGetTopics(char *consumerId); -- 2.34.1