From fd959ea4bb3dd91423f99bb158033cf44e424c26 Mon Sep 17 00:00:00 2001 From: Jules Clero Date: Mon, 23 Mar 2015 00:05:18 +0000 Subject: [PATCH 1/4] Fix hidden overloaded virtual function in BitParameter.h accessAsInteger function prototype is defined in BaseParameter abstract class with an uint32_t type. Nevertheless in BitParameter the overloaded function take an uin64_t. It seems that GCC accepts wrongly this mistake but clang don't. This patch corrects the function prototype accordingly to the one defined in BaseParameter. It allows the project to be compiled with clang. Signed-off-by: Jules Clero --- parameter/BitParameter.cpp | 4 ++-- parameter/BitParameter.h | 2 +- parameter/BitParameterType.cpp | 2 +- parameter/BitParameterType.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/parameter/BitParameter.cpp b/parameter/BitParameter.cpp index fb853e479..2a53afd90 100644 --- a/parameter/BitParameter.cpp +++ b/parameter/BitParameter.cpp @@ -87,7 +87,7 @@ bool CBitParameter::accessAsBoolean(bool& bValue, bool bSet, CParameterAccessCon } // Rely on integer access - uint64_t uiValue; + uint32_t uiValue; if (bSet) { @@ -108,7 +108,7 @@ bool CBitParameter::accessAsBoolean(bool& bValue, bool bSet, CParameterAccessCon } // Integer Access -bool CBitParameter::accessAsInteger(uint64_t& uiValue, bool bSet, CParameterAccessContext& parameterAccessContext) const +bool CBitParameter::accessAsInteger(uint32_t& uiValue, bool bSet, CParameterAccessContext& parameterAccessContext) const { uint32_t uiOffset = getOffset(); diff --git a/parameter/BitParameter.h b/parameter/BitParameter.h index 436f32118..f9e2b9d2d 100644 --- a/parameter/BitParameter.h +++ b/parameter/BitParameter.h @@ -49,7 +49,7 @@ class CBitParameter : public CBaseParameter virtual bool accessAsBoolean(bool& bValue, bool bSet, CParameterAccessContext& parameterAccessContext) const; // Integer Access - virtual bool accessAsInteger(uint64_t& uiValue, bool bSet, CParameterAccessContext& parameterAccessContext) const; + virtual bool accessAsInteger(uint32_t& uiValue, bool bSet, CParameterAccessContext& parameterAccessContext) const; // AreaConfiguration creation virtual CAreaConfiguration* createAreaConfiguration(const CSyncerSet* pSyncerSet) const; diff --git a/parameter/BitParameterType.cpp b/parameter/BitParameterType.cpp index 2a400d40f..8488c18b5 100644 --- a/parameter/BitParameterType.cpp +++ b/parameter/BitParameterType.cpp @@ -191,7 +191,7 @@ bool CBitParameterType::toBlackboard(uint64_t uiUserValue, uint64_t& uiValue, CP return true; } -void CBitParameterType::fromBlackboard(uint64_t& uiUserValue, uint64_t uiValue, CParameterAccessContext& parameterAccessContext) const +void CBitParameterType::fromBlackboard(uint32_t& uiUserValue, uint64_t uiValue, CParameterAccessContext& parameterAccessContext) const { (void)parameterAccessContext; diff --git a/parameter/BitParameterType.h b/parameter/BitParameterType.h index 8f147e655..4c91a1a15 100644 --- a/parameter/BitParameterType.h +++ b/parameter/BitParameterType.h @@ -53,7 +53,7 @@ class CBitParameterType : public CTypeElement void fromBlackboard(std::string& strValue, const uint64_t& uiValue, CParameterAccessContext& parameterAccessContext) const; // Integer bool toBlackboard(uint64_t uiUserValue, uint64_t& uiValue, CParameterAccessContext& parameterAccessContext) const; - void fromBlackboard(uint64_t& uiUserValue, uint64_t uiValue, CParameterAccessContext& parameterAccessContext) const; + void fromBlackboard(uint32_t& uiUserValue, uint64_t uiValue, CParameterAccessContext& parameterAccessContext) const; // Access from area configuration uint64_t merge(uint64_t uiOriginData, uint64_t uiNewData) const; From a906540eceb942e506d291a7b4aba7a48b167db8 Mon Sep 17 00:00:00 2001 From: Jules Clero Date: Mon, 23 Mar 2015 17:06:52 +0100 Subject: [PATCH 2/4] Remove -Wno-unused-but-set-variable flag for python binding compilation Swig does not any more generates code which require this flag. Moreover this flag is not present in clang compiler. Change-Id: I386ab576e93003d69dcf2c593670245070770024 Signed-off-by: Jules Clero --- bindings/python/Android.mk | 4 +--- bindings/python/CMakeLists.txt | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/bindings/python/Android.mk b/bindings/python/Android.mk index 977ffb79c..ef6a6758b 100644 --- a/bindings/python/Android.mk +++ b/bindings/python/Android.mk @@ -51,13 +51,11 @@ LOCAL_C_INCLUDES := \ prebuilts/python/linux-x86/2.7.5/include/python2.7 \ $(HOST_OUT_HEADERS)/parameter -# The 'unused-but-set-variable' warning must be disabled because SWIG generates -# files that do not respect that constraint. # '-DSWIG_PYTHON_SILENT_MEMLEAK' is needed because the "memleak" warning # pollutes the standard output. At the time of writing, the only warning is # spurious anyway, as it relates to "ILogger *" which is an abstract # class/interface class and as such cannot be destroyed. -LOCAL_CFLAGS := -Wno-unused-but-set-variable -fexceptions -DSWIG_PYTHON_SILENT_MEMLEAK +LOCAL_CFLAGS := -fexceptions -DSWIG_PYTHON_SILENT_MEMLEAK # Undefined symbols will be resolved at runtime LOCAL_ALLOW_UNDEFINED_SYMBOLS := true diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt index a885febd2..4f47fb1c6 100644 --- a/bindings/python/CMakeLists.txt +++ b/bindings/python/CMakeLists.txt @@ -54,13 +54,11 @@ swig_link_libraries(PyPfw parameter ${PYTHON_LIBRARIES}) # ${CMAKE_CURRENT_BINARY_DIR}. set_property(TARGET _PyPfw PROPERTY LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -# The 'unused-but-set-variable' warning must be disabled because SWIG generates -# files that do not respect that contraint. # '-DSWIG_PYTHON_SILENT_MEMLEAK' is needed because the "memleak" warning # pollutes the standard output. At the time of writing, the only warning is # spurious anyway, as it relates to "ILogger *" which is an abstract # class/interface class and as such cannot be destroyed. -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-but-set-variable -DSWIG_PYTHON_SILENT_MEMLEAK") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSWIG_PYTHON_SILENT_MEMLEAK") # Find the python modules install path. From e332bc146d56b94d22ffd760dc0d427ec66ab978 Mon Sep 17 00:00:00 2001 From: David Brageul Date: Thu, 30 Apr 2015 15:19:26 +0200 Subject: [PATCH 3/4] Update log message for clang compilation --- parameter/ConfigurableDomain.cpp | 2 +- parameter/ConfigurableDomains.cpp | 4 ++-- parameter/Element.cpp | 8 ++++---- parameter/Element.h | 4 ++-- parameter/ParameterMgr.cpp | 4 ++-- parameter/SubsystemObject.cpp | 18 +++++++++++++----- parameter/SubsystemObject.h | 4 ++-- 7 files changed, 26 insertions(+), 18 deletions(-) diff --git a/parameter/ConfigurableDomain.cpp b/parameter/ConfigurableDomain.cpp index aa9da51a6..346b1f9ba 100644 --- a/parameter/ConfigurableDomain.cpp +++ b/parameter/ConfigurableDomain.cpp @@ -847,7 +847,7 @@ void CConfigurableDomain::validate(const CParameterBlackboard* pMainBlackboard) // Ensure validity on areas related to configurable element void CConfigurableDomain::validateAreas(const CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard) { - log_info("Validating domain \"" + getName() + "\" against main blackboard for configurable element \"" + pConfigurableElement->getPath() + "\""); + log_info("Validating domain \"%s\" against main blackboard for configurable element \"%s\"", getName().c_str(), pConfigurableElement->getPath().c_str()); // Propagate size_t uiNbConfigurations = getNbChildren(); diff --git a/parameter/ConfigurableDomains.cpp b/parameter/ConfigurableDomains.cpp index 844ade754..bfa9271cf 100644 --- a/parameter/ConfigurableDomains.cpp +++ b/parameter/ConfigurableDomains.cpp @@ -145,7 +145,7 @@ bool CConfigurableDomains::addDomain(CConfigurableDomain& domain, bool bOverwrit deleteDomain(*pExistingDomain); } - log_info("Adding configurable domain \"" + strDomainName + "\""); + log_info("Adding configurable domain \"%s\"", strDomainName.c_str()); addChild(&domain); @@ -154,7 +154,7 @@ bool CConfigurableDomains::addDomain(CConfigurableDomain& domain, bool bOverwrit void CConfigurableDomains::deleteDomain(CConfigurableDomain& configurableDomain) { - log_info("Deleting configurable domain \"" + configurableDomain.getName() + "\""); + log_info("Deleting configurable domain \"%s\"", configurableDomain.getName().c_str() ); removeChild(&configurableDomain); diff --git a/parameter/Element.cpp b/parameter/Element.cpp index cacf49b6c..fc5863651 100644 --- a/parameter/Element.cpp +++ b/parameter/Element.cpp @@ -49,14 +49,14 @@ CElement::~CElement() } // Logging -void CElement::log_info(const string& strMessage, ...) const +void CElement::log_info(const char* strMessage, ...) const { char *pacBuffer; va_list listPointer; va_start(listPointer, strMessage); - vasprintf(&pacBuffer, strMessage.c_str(), listPointer); + vasprintf(&pacBuffer, strMessage, listPointer); va_end(listPointer); @@ -67,14 +67,14 @@ void CElement::log_info(const string& strMessage, ...) const free(pacBuffer); } -void CElement::log_warning(const string& strMessage, ...) const +void CElement::log_warning(const char* strMessage, ...) const { char *pacBuffer; va_list listPointer; va_start(listPointer, strMessage); - vasprintf(&pacBuffer, strMessage.c_str(), listPointer); + vasprintf(&pacBuffer, strMessage, listPointer); va_end(listPointer); diff --git a/parameter/Element.h b/parameter/Element.h index 8423e32be..41ab736b6 100644 --- a/parameter/Element.h +++ b/parameter/Element.h @@ -49,8 +49,8 @@ class CElement : public IXmlSink, public IXmlSource virtual ~CElement(); // Logging - void log_info(const std::string& strMessage, ...) const; - void log_warning(const std::string& strMessage, ...) const; + void log_info(const char* strMessage, ...) const; + void log_warning(const char* strMessage, ...) const; void log_table(bool bIsWarning, const std::list lstrMessage) const; // Description diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp index 45f1ac2d4..8fca836ce 100644 --- a/parameter/ParameterMgr.cpp +++ b/parameter/ParameterMgr.cpp @@ -548,7 +548,7 @@ bool CParameterMgr::loadStructure(string& strError) // Retrieve system to load structure to CSystemClass* pSystemClass = getSystemClass(); - log_info("Loading " + pSystemClass->getName() + " system class structure"); + log_info("Loading %s system class structure", pSystemClass->getName().c_str()); // Get structure description element const CFrameworkConfigurationLocation* pStructureDescriptionFileLocation = static_cast(getConstFrameworkConfiguration()->findChildOfKind("StructureDescriptionFileLocation")); @@ -592,7 +592,7 @@ bool CParameterMgr::loadSettings(string& strError) if (!success && !_bFailOnFailedSettingsLoad) { // Load can not fail, ie continue but log the load errors - log_info(strLoadError); + log_info("%s", strLoadError.c_str()); log_info("Failed to load settings, continue without domains."); success = true; } diff --git a/parameter/SubsystemObject.cpp b/parameter/SubsystemObject.cpp index 76b954907..0ffb7824a 100644 --- a/parameter/SubsystemObject.cpp +++ b/parameter/SubsystemObject.cpp @@ -149,7 +149,7 @@ bool CSubsystemObject::sync(CParameterBlackboard& parameterBlackboard, bool bBac strError = string("Unable to ") + (bBack ? "back" : "forward") + " synchronize configurable element " + _pInstanceConfigurableElement->getPath() + ": " + strError; - log_warning(strError); + log_warning(strError.c_str()); // Fall back to parameter default initialization if (bBack) { @@ -213,14 +213,15 @@ void CSubsystemObject::blackboardWrite(const void* pvData, uint32_t uiSize) } // Logging -void CSubsystemObject::log_info(const string& strMessage, ...) const +void CSubsystemObject::log_info(const char* strMessage, ...) const { +#if 1 char *pacBuffer; va_list listPointer; va_start(listPointer, strMessage); - vasprintf(&pacBuffer, strMessage.c_str(), listPointer); + vasprintf(&pacBuffer, strMessage, listPointer); va_end(listPointer); @@ -229,16 +230,20 @@ void CSubsystemObject::log_info(const string& strMessage, ...) const } free(pacBuffer); +#else + _pInstanceConfigurableElement->log_info(strMessage.c_str()); +#endif } -void CSubsystemObject::log_warning(const string& strMessage, ...) const +void CSubsystemObject::log_warning(const char* strMessage, ...) const { +#if 1 char *pacBuffer; va_list listPointer; va_start(listPointer, strMessage); - vasprintf(&pacBuffer, strMessage.c_str(), listPointer); + vasprintf(&pacBuffer, strMessage, listPointer); va_end(listPointer); @@ -247,6 +252,9 @@ void CSubsystemObject::log_warning(const string& strMessage, ...) const } free(pacBuffer); +#else + _pInstanceConfigurableElement->log_warning(strMessage.c_str()); +#endif } // Configurable element retrieval diff --git a/parameter/SubsystemObject.h b/parameter/SubsystemObject.h index ab085bc02..57349f95c 100644 --- a/parameter/SubsystemObject.h +++ b/parameter/SubsystemObject.h @@ -83,8 +83,8 @@ class CSubsystemObject : private ISyncer void blackboardRead(void* pvData, uint32_t uiSize); void blackboardWrite(const void* pvData, uint32_t uiSize); // Logging - void log_info(const std::string& strMessage, ...) const; - void log_warning(const std::string& strMessage, ...) const; + void log_info(const char* strMessage, ...) const; + void log_warning(const char* strMessage, ...) const; // Belonging Subsystem retrieval const CSubsystem* getSubsystem() const; From 83fb45570a47a28da543fc312706464d17451cf8 Mon Sep 17 00:00:00 2001 From: David Brageul Date: Thu, 30 Apr 2015 15:29:37 +0200 Subject: [PATCH 4/4] Allow clang compilation --- bindings/python/Android.mk | 3 --- parameter/Android.mk | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/bindings/python/Android.mk b/bindings/python/Android.mk index ef6a6758b..2b8f7909e 100644 --- a/bindings/python/Android.mk +++ b/bindings/python/Android.mk @@ -38,9 +38,6 @@ include $(CLEAR_VARS) LOCAL_MODULE := _PyPfw LOCAL_CPP_EXTENSION := .cxx -# As long as the parameter-framework is compiled with gcc, we must avoid -# compiling the bindings with clang and compile with gcc instead. -LOCAL_CLANG := false # Android only provides a 32bit version of python. LOCAL_32_BIT_ONLY := true diff --git a/parameter/Android.mk b/parameter/Android.mk index 90e33f09b..f8d9a0bab 100644 --- a/parameter/Android.mk +++ b/parameter/Android.mk @@ -158,7 +158,6 @@ LOCAL_STATIC_LIBRARIES := libxmlserializer libpfw_utility libxml2 LOCAL_REQUIRED_MODULES := libremote-processor -LOCAL_CLANG := false include external/stlport/libstlport.mk include $(BUILD_SHARED_LIBRARY) @@ -186,7 +185,7 @@ LOCAL_STATIC_LIBRARIES := libxmlserializer_host libpfw_utility_host libxml2 LOCAL_LDLIBS += -ldl -LOCAL_CLANG := false +#LOCAL_CLANG := false include $(BUILD_HOST_SHARED_LIBRARY) ################################