Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions bindings/c/ParameterFramework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace pfw
typedef ISelectionCriterionInterface Criterion;
typedef std::map<string, Criterion *> Criteria;
typedef CParameterMgrPlatformConnector Pfw;
}
} // namespace pfw

/** Class to abstract the boolean+string status api. */
class Status
Expand Down Expand Up @@ -110,7 +110,7 @@ static void defaultLogCb(void *, PfwLogLevel level, const char *logLine)
};
}

static PfwLogger defaultLogger = {NULL, &defaultLogCb};
static PfwLogger defaultLogger = {nullptr, &defaultLogCb};

class LogWrapper : public CParameterMgrPlatformConnector::ILogger
{
Expand All @@ -127,7 +127,7 @@ class LogWrapper : public CParameterMgrPlatformConnector::ILogger
{
// A LogWrapper should NOT be register to the pfw (thus log called)
// if logCb is NULL.
assert(mLogger.logCb != NULL);
assert(mLogger.logCb != nullptr);
mLogger.logCb(mLogger.userCtx, level, strLog.c_str());
}

Expand Down Expand Up @@ -167,10 +167,10 @@ void pfwDestroy(PfwHandler *handle)

void PfwHandler::setLogger(const PfwLogger *logger)
{
if (logger != NULL and logger->logCb == NULL) {
if (logger != nullptr and logger->logCb == nullptr) {
return; // There is no callback, do not log => do not add a logger
}
mLogger = logger != NULL ? *logger : defaultLogger;
mLogger = logger != nullptr ? *logger : defaultLogger;
pfw->setLogger(&mLogger);
}

Expand All @@ -180,10 +180,10 @@ bool PfwHandler::createCriteria(const PfwCriterion criteriaArray[], size_t crite
// Add criteria
for (size_t criterionIndex = 0; criterionIndex < criterionNb; ++criterionIndex) {
const PfwCriterion &criterion = criteriaArray[criterionIndex];
if (criterion.name == NULL) {
if (criterion.name == nullptr) {
return status.failure("Criterion name is NULL");
}
if (criterion.values == NULL) {
if (criterion.values == nullptr) {
return status.failure("Criterion values is NULL");
}
// Check that the criterion does not exist
Expand All @@ -194,9 +194,9 @@ bool PfwHandler::createCriteria(const PfwCriterion criteriaArray[], size_t crite
// Create criterion type
ISelectionCriterionTypeInterface *type =
pfw->createSelectionCriterionType(criterion.inclusive);
assert(type != NULL);
assert(type != nullptr);
// Add criterion values
for (size_t valueIndex = 0; criterion.values[valueIndex] != NULL; ++valueIndex) {
for (size_t valueIndex = 0; criterion.values[valueIndex] != nullptr; ++valueIndex) {
int value;
if (criterion.inclusive) {
// Check that (int)1 << valueIndex would not overflow (UB)
Expand Down Expand Up @@ -227,7 +227,7 @@ bool pfwStart(PfwHandler *handle, const char *configPath, const PfwCriterion cri
// Check that the api is correctly used
Status &status = handle->lastStatus;

if (handle->pfw != NULL) {
if (handle->pfw != nullptr) {
return status.failure("Can not start an already started parameter framework");
}
// Create a pfw
Expand All @@ -249,19 +249,19 @@ const char *pfwGetLastError(const PfwHandler *handle)

static pfw::Criterion *getCriterion(const pfw::Criteria &criteria, const string &name)
{
pfw::Criteria::const_iterator it = criteria.find(name);
return it == criteria.end() ? NULL : it->second;
auto it = criteria.find(name);
return it == criteria.end() ? nullptr : it->second;
}

bool pfwSetCriterion(PfwHandler *handle, const char name[], int value)
{
Status &status = handle->lastStatus;
if (handle->pfw == NULL) {
if (handle->pfw == nullptr) {
return status.failure("Can not set criterion \"" + string(name) +
"\" as the parameter framework is not started.");
}
pfw::Criterion *criterion = getCriterion(handle->criteria, name);
if (criterion == NULL) {
if (criterion == nullptr) {
return status.failure("Can not set criterion " + string(name) + " as does not exist");
}
criterion->setCriterionState(value);
Expand All @@ -270,12 +270,12 @@ bool pfwSetCriterion(PfwHandler *handle, const char name[], int value)
bool pfwGetCriterion(const PfwHandler *handle, const char name[], int *value)
{
Status &status = handle->lastStatus;
if (handle->pfw == NULL) {
if (handle->pfw == nullptr) {
return status.failure("Can not get criterion \"" + string(name) +
"\" as the parameter framework is not started.");
}
pfw::Criterion *criterion = getCriterion(handle->criteria, name);
if (criterion == NULL) {
if (criterion == nullptr) {
return status.failure("Can not get criterion " + string(name) + " as it does not exist");
}
*value = criterion->getCriterionState();
Expand All @@ -285,7 +285,7 @@ bool pfwGetCriterion(const PfwHandler *handle, const char name[], int *value)
bool pfwApplyConfigurations(const PfwHandler *handle)
{
Status &status = handle->lastStatus;
if (handle->pfw == NULL) {
if (handle->pfw == nullptr) {
return status.failure("Can not commit criteria "
"as the parameter framework is not started.");
}
Expand All @@ -306,17 +306,17 @@ struct PfwParameterHandler_
PfwParameterHandler *pfwBindParameter(PfwHandler *handle, const char path[])
{
Status &status = handle->lastStatus;
if (handle->pfw == NULL) {
if (handle->pfw == nullptr) {
status.failure("The parameter framework is not started, "
"while trying to bind parameter \"" +
string(path) + "\")");
return NULL;
return nullptr;
}

CParameterHandle *paramHandle;
paramHandle = handle->pfw->createParameterHandle(path, status.msg());
if (paramHandle == NULL) {
return NULL;
if (paramHandle == nullptr) {
return nullptr;
}

status.success();
Expand Down Expand Up @@ -344,7 +344,7 @@ bool pfwSetIntParameter(PfwParameterHandler *handle, int32_t value)
bool pfwGetStringParameter(const PfwParameterHandler *handle, char *value[])
{
Status &status = handle->pfw.lastStatus;
*value = NULL;
*value = nullptr;
string retValue;
bool success = handle->parameter.getAsString(retValue, status.msg());
if (not success) {
Expand Down
26 changes: 13 additions & 13 deletions bindings/c/Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ struct Test
TEST_CASE_METHOD(Test, "Parameter-framework c api use")
{
// Create criteria
const char *letterList[] = {"a", "b", "c", NULL};
const char *numberList[] = {"1", "2", "3", NULL};
const char *letterList[] = {"a", "b", "c", nullptr};
const char *numberList[] = {"1", "2", "3", nullptr};
const PfwCriterion criteria[] = {
{"inclusiveCrit", true, letterList}, {"exclusiveCrit", false, numberList},
};
Expand Down Expand Up @@ -165,23 +165,23 @@ TEST_CASE_METHOD(Test, "Parameter-framework c api use")
REQUIRE_FAILURE(pfwStart(pfw, config, duplicatedCriteria, 2, &logger));
}
WHEN ("The pfw is started with duplicated criterion value state") {
const char *values[] = {"a", "a", NULL};
const char *values[] = {"a", "a", nullptr};
const PfwCriterion duplicatedCriteria[] = {{"name", true, values}};

WHEN ("Using test logger") {
REQUIRE_FAILURE(pfwStart(pfw, config, duplicatedCriteria, 1, &logger));
}
WHEN ("Using default logger") {
// Test coverage of default logger warning
REQUIRE_FAILURE(pfwStart(pfw, config, duplicatedCriteria, 1, NULL));
REQUIRE_FAILURE(pfwStart(pfw, config, duplicatedCriteria, 1, nullptr));
}
}
WHEN ("The pfw is started with NULL name criterion") {
const PfwCriterion duplicatedCriteria[] = {{NULL, true, letterList}};
const PfwCriterion duplicatedCriteria[] = {{nullptr, true, letterList}};
REQUIRE_FAILURE(pfwStart(pfw, config, duplicatedCriteria, 1, &logger));
}
WHEN ("The pfw is started with NULL criterion state list") {
const PfwCriterion duplicatedCriteria[] = {{"name", true, NULL}};
const PfwCriterion duplicatedCriteria[] = {{"name", true, nullptr}};
REQUIRE_FAILURE(pfwStart(pfw, config, duplicatedCriteria, 1, &logger));
}
GIVEN ("A criteria with lots of values") {
Expand All @@ -192,7 +192,7 @@ TEST_CASE_METHOD(Test, "Parameter-framework c api use")
for (size_t i = 0; i < values.size(); ++i) {
values[i] = &names[i];
}
values.back() = NULL;
values.back() = nullptr;
/* The pfw c api requires criterion values to be a NULL terminated
* array of string. Each string is a pointer to a NULL terminated
* array of char. The pfw requires each string to be different
Expand Down Expand Up @@ -225,7 +225,7 @@ TEST_CASE_METHOD(Test, "Parameter-framework c api use")
REQUIRE_FAILURE(pfwStart(pfw, config, duplicatedCriteria, 1, &logger));
}
WHEN ("The pfw is started with max length criterion state list") {
values[values.size() - 2] = NULL; // Hide last value
values[values.size() - 2] = nullptr; // Hide last value
REQUIRE_SUCCESS(pfwStart(pfw, config, duplicatedCriteria, 1, &logger));
}
}
Expand All @@ -240,11 +240,11 @@ TEST_CASE_METHOD(Test, "Parameter-framework c api use")
}

WHEN ("The pfw is started without a logger callback") {
PfwLogger noLog = {NULL, NULL};
PfwLogger noLog = {nullptr, nullptr};
REQUIRE_SUCCESS(pfwStart(pfw, config, criteria, criterionNb, &noLog));
}
WHEN ("The pfw is started with default logger") {
REQUIRE_SUCCESS(pfwStart(pfw, config, criteria, criterionNb, NULL));
REQUIRE_SUCCESS(pfwStart(pfw, config, criteria, criterionNb, nullptr));
}

WHEN ("Get criterion of a stopped pfw") {
Expand Down Expand Up @@ -311,12 +311,12 @@ TEST_CASE_METHOD(Test, "Parameter-framework c api use")
REQUIRE_SUCCESS(pfwApplyConfigurations(pfw));
}
WHEN ("Bind a non existing parameter") {
REQUIRE_FAILURE(pfwBindParameter(pfw, "do/not/exist") != NULL);
REQUIRE_FAILURE(pfwBindParameter(pfw, "do/not/exist") != nullptr);
}

GIVEN ("An integer parameter handle") {
PfwParameterHandler *param = pfwBindParameter(pfw, intParameterPath);
REQUIRE_SUCCESS(param != NULL);
REQUIRE_SUCCESS(param != nullptr);

WHEN ("Set parameter out of range") {
REQUIRE_FAILURE(pfwSetIntParameter(param, 101));
Expand All @@ -335,7 +335,7 @@ TEST_CASE_METHOD(Test, "Parameter-framework c api use")

GIVEN ("An string parameter handle") {
PfwParameterHandler *param = pfwBindParameter(pfw, stringParameterPath);
REQUIRE_SUCCESS(param != NULL);
REQUIRE_SUCCESS(param != nullptr);

WHEN ("Set parameter out of range") {
REQUIRE_FAILURE(pfwSetStringParameter(param, "ko_1234567"));
Expand Down
2 changes: 1 addition & 1 deletion parameter/BitParameterType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ bool CBitParameterType::toBlackboard(const string &strValue, uint64_t &uiValue,
CParameterAccessContext &parameterAccessContext) const
{
// Get value
uint64_t uiConvertedValue = strtoull(strValue.c_str(), NULL, 0);
uint64_t uiConvertedValue = strtoull(strValue.c_str(), nullptr, 0);

if (uiConvertedValue > _uiMax) {

Expand Down
2 changes: 1 addition & 1 deletion parameter/ComponentType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,5 @@ CInstanceConfigurableElement *CComponentType::doInstantiate() const
// Not supposed to be called directly (instantiation made through CComponentInstance object)
assert(0);

return NULL;
return nullptr;
}
31 changes: 15 additions & 16 deletions parameter/ConfigurableDomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ bool CConfigurableDomain::parseConfigurableElements(const CXmlElement &xmlElemen
}
// Add found element to domain
core::Results infos;
if (!addConfigurableElement(pConfigurableElement, NULL, infos)) {
if (!addConfigurableElement(pConfigurableElement, nullptr, infos)) {

strError = utility::asString(infos);
serializingContext.setError(strError);
Expand Down Expand Up @@ -439,7 +439,7 @@ CParameterBlackboard *CConfigurableDomain::findConfigurationBlackboard(

strError = "Domain configuration " + strConfiguration + " not found";

return NULL;
return nullptr;
}

// Parse all configurable elements
Expand All @@ -463,7 +463,7 @@ CParameterBlackboard *CConfigurableDomain::findConfigurationBlackboard(

strError = "Element not associated to the Domain";

return NULL;
return nullptr;
}

// Domain splitting
Expand Down Expand Up @@ -535,7 +535,7 @@ const CDomainConfiguration *CConfigurableDomain::getPendingConfiguration() const
}
}

return NULL;
return nullptr;
}

// Configuration application if required
Expand All @@ -551,7 +551,7 @@ void CConfigurableDomain::apply(CParameterBlackboard *pParameterBlackboard, CSyn

if (bForce) {
// Force a configuration restore by forgetting about last applied configuration
_pLastAppliedConfiguration = NULL;
_pLastAppliedConfiguration = nullptr;
}
const CDomainConfiguration *pApplicableDomainConfiguration =
findApplicableDomainConfiguration();
Expand All @@ -569,7 +569,7 @@ void CConfigurableDomain::apply(CParameterBlackboard *pParameterBlackboard, CSyn
bool bSync = !pSyncerSet && _bSequenceAware;

// Do the restore
pApplicableDomainConfiguration->restore(pParameterBlackboard, bSync, NULL);
pApplicableDomainConfiguration->restore(pParameterBlackboard, bSync, nullptr);

// Record last applied configuration
_pLastAppliedConfiguration = pApplicableDomainConfiguration;
Expand Down Expand Up @@ -627,7 +627,7 @@ bool CConfigurableDomain::createConfiguration(const string &strName,
}

// Creation
CDomainConfiguration *pDomainConfiguration = new CDomainConfiguration(strName);
auto pDomainConfiguration = new CDomainConfiguration(strName);

// Configurable elements association
ConfigurableElementListIterator it;
Expand Down Expand Up @@ -672,7 +672,7 @@ bool CConfigurableDomain::deleteConfiguration(const string &strName, string &str
if (pDomainConfiguration == _pLastAppliedConfiguration) {

// Forget about it
_pLastAppliedConfiguration = NULL;
_pLastAppliedConfiguration = nullptr;
}

// Hierarchy
Expand Down Expand Up @@ -719,7 +719,7 @@ bool CConfigurableDomain::restoreConfiguration(const string &configurationName,

const CDomainConfiguration *configuration = findConfiguration(configurationName, error);

if (configuration == NULL) {
if (configuration == nullptr) {

errors.push_back(error);
return false;
Expand Down Expand Up @@ -994,7 +994,7 @@ const CDomainConfiguration *CConfigurableDomain::findValidDomainConfiguration(
return pDomainConfiguration;
}
}
return NULL;
return nullptr;
}

// Search for an applicable configuration
Expand All @@ -1012,7 +1012,7 @@ const CDomainConfiguration *CConfigurableDomain::findApplicableDomainConfigurati
return pDomainConfiguration;
}
}
return NULL;
return nullptr;
}

// Gather set of configurable elements
Expand Down Expand Up @@ -1106,7 +1106,7 @@ void CConfigurableDomain::doAddConfigurableElement(CConfigurableElement *pConfig
pConfigurableElement->addAttachedConfigurableDomain(this);

// Create associated syncer set
CSyncerSet *pSyncerSet = new CSyncerSet;
auto pSyncerSet = new CSyncerSet;

// Add to sync set the configurable element one
pConfigurableElement->fillSyncerSet(*pSyncerSet);
Expand Down Expand Up @@ -1182,8 +1182,7 @@ void CConfigurableDomain::doRemoveConfigurableElement(CConfigurableElement *pCon
CSyncerSet *CConfigurableDomain::getSyncerSet(
const CConfigurableElement *pConfigurableElement) const
{
ConfigurableElementToSyncerSetMapIterator mapIt =
_configurableElementToSyncerSetMap.find(pConfigurableElement);
auto mapIt = _configurableElementToSyncerSetMap.find(pConfigurableElement);

ALWAYS_ASSERT(mapIt != _configurableElementToSyncerSetMap.end(),
"Could not find syncer set for " << getName() << " configurable domain");
Expand All @@ -1202,7 +1201,7 @@ CDomainConfiguration *CConfigurableDomain::findConfiguration(const string &strCo

strError = "Domain configuration " + strConfiguration + " not found";

return NULL;
return nullptr;
}
return pDomainConfiguration;
}
Expand All @@ -1217,7 +1216,7 @@ const CDomainConfiguration *CConfigurableDomain::findConfiguration(const string

strError = "Domain configuration " + strConfiguration + " not found";

return NULL;
return nullptr;
}
return pDomainConfiguration;
}
Loading