Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit e16ba60

Browse files
committed
Merge pull request #359 from terahxluna/clang-tidy
Clean up code using clang-tidy Checks applied: - modernize-use-nullptr - llvm-namespace-comment - modernize-use-auto
2 parents a74c8c1 + 3afc389 commit e16ba60

File tree

66 files changed

+200
-201
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+200
-201
lines changed

bindings/c/ParameterFramework.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ namespace pfw
5050
typedef ISelectionCriterionInterface Criterion;
5151
typedef std::map<string, Criterion *> Criteria;
5252
typedef CParameterMgrPlatformConnector Pfw;
53-
}
53+
} // namespace pfw
5454

5555
/** Class to abstract the boolean+string status api. */
5656
class Status
@@ -110,7 +110,7 @@ static void defaultLogCb(void *, PfwLogLevel level, const char *logLine)
110110
};
111111
}
112112

113-
static PfwLogger defaultLogger = {NULL, &defaultLogCb};
113+
static PfwLogger defaultLogger = {nullptr, &defaultLogCb};
114114

115115
class LogWrapper : public CParameterMgrPlatformConnector::ILogger
116116
{
@@ -127,7 +127,7 @@ class LogWrapper : public CParameterMgrPlatformConnector::ILogger
127127
{
128128
// A LogWrapper should NOT be register to the pfw (thus log called)
129129
// if logCb is NULL.
130-
assert(mLogger.logCb != NULL);
130+
assert(mLogger.logCb != nullptr);
131131
mLogger.logCb(mLogger.userCtx, level, strLog.c_str());
132132
}
133133

@@ -167,10 +167,10 @@ void pfwDestroy(PfwHandler *handle)
167167

168168
void PfwHandler::setLogger(const PfwLogger *logger)
169169
{
170-
if (logger != NULL and logger->logCb == NULL) {
170+
if (logger != nullptr and logger->logCb == nullptr) {
171171
return; // There is no callback, do not log => do not add a logger
172172
}
173-
mLogger = logger != NULL ? *logger : defaultLogger;
173+
mLogger = logger != nullptr ? *logger : defaultLogger;
174174
pfw->setLogger(&mLogger);
175175
}
176176

@@ -180,10 +180,10 @@ bool PfwHandler::createCriteria(const PfwCriterion criteriaArray[], size_t crite
180180
// Add criteria
181181
for (size_t criterionIndex = 0; criterionIndex < criterionNb; ++criterionIndex) {
182182
const PfwCriterion &criterion = criteriaArray[criterionIndex];
183-
if (criterion.name == NULL) {
183+
if (criterion.name == nullptr) {
184184
return status.failure("Criterion name is NULL");
185185
}
186-
if (criterion.values == NULL) {
186+
if (criterion.values == nullptr) {
187187
return status.failure("Criterion values is NULL");
188188
}
189189
// Check that the criterion does not exist
@@ -194,9 +194,9 @@ bool PfwHandler::createCriteria(const PfwCriterion criteriaArray[], size_t crite
194194
// Create criterion type
195195
ISelectionCriterionTypeInterface *type =
196196
pfw->createSelectionCriterionType(criterion.inclusive);
197-
assert(type != NULL);
197+
assert(type != nullptr);
198198
// Add criterion values
199-
for (size_t valueIndex = 0; criterion.values[valueIndex] != NULL; ++valueIndex) {
199+
for (size_t valueIndex = 0; criterion.values[valueIndex] != nullptr; ++valueIndex) {
200200
int value;
201201
if (criterion.inclusive) {
202202
// Check that (int)1 << valueIndex would not overflow (UB)
@@ -227,7 +227,7 @@ bool pfwStart(PfwHandler *handle, const char *configPath, const PfwCriterion cri
227227
// Check that the api is correctly used
228228
Status &status = handle->lastStatus;
229229

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

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

256256
bool pfwSetCriterion(PfwHandler *handle, const char name[], int value)
257257
{
258258
Status &status = handle->lastStatus;
259-
if (handle->pfw == NULL) {
259+
if (handle->pfw == nullptr) {
260260
return status.failure("Can not set criterion \"" + string(name) +
261261
"\" as the parameter framework is not started.");
262262
}
263263
pfw::Criterion *criterion = getCriterion(handle->criteria, name);
264-
if (criterion == NULL) {
264+
if (criterion == nullptr) {
265265
return status.failure("Can not set criterion " + string(name) + " as does not exist");
266266
}
267267
criterion->setCriterionState(value);
@@ -270,12 +270,12 @@ bool pfwSetCriterion(PfwHandler *handle, const char name[], int value)
270270
bool pfwGetCriterion(const PfwHandler *handle, const char name[], int *value)
271271
{
272272
Status &status = handle->lastStatus;
273-
if (handle->pfw == NULL) {
273+
if (handle->pfw == nullptr) {
274274
return status.failure("Can not get criterion \"" + string(name) +
275275
"\" as the parameter framework is not started.");
276276
}
277277
pfw::Criterion *criterion = getCriterion(handle->criteria, name);
278-
if (criterion == NULL) {
278+
if (criterion == nullptr) {
279279
return status.failure("Can not get criterion " + string(name) + " as it does not exist");
280280
}
281281
*value = criterion->getCriterionState();
@@ -285,7 +285,7 @@ bool pfwGetCriterion(const PfwHandler *handle, const char name[], int *value)
285285
bool pfwApplyConfigurations(const PfwHandler *handle)
286286
{
287287
Status &status = handle->lastStatus;
288-
if (handle->pfw == NULL) {
288+
if (handle->pfw == nullptr) {
289289
return status.failure("Can not commit criteria "
290290
"as the parameter framework is not started.");
291291
}
@@ -306,17 +306,17 @@ struct PfwParameterHandler_
306306
PfwParameterHandler *pfwBindParameter(PfwHandler *handle, const char path[])
307307
{
308308
Status &status = handle->lastStatus;
309-
if (handle->pfw == NULL) {
309+
if (handle->pfw == nullptr) {
310310
status.failure("The parameter framework is not started, "
311311
"while trying to bind parameter \"" +
312312
string(path) + "\")");
313-
return NULL;
313+
return nullptr;
314314
}
315315

316316
CParameterHandle *paramHandle;
317317
paramHandle = handle->pfw->createParameterHandle(path, status.msg());
318-
if (paramHandle == NULL) {
319-
return NULL;
318+
if (paramHandle == nullptr) {
319+
return nullptr;
320320
}
321321

322322
status.success();
@@ -344,7 +344,7 @@ bool pfwSetIntParameter(PfwParameterHandler *handle, int32_t value)
344344
bool pfwGetStringParameter(const PfwParameterHandler *handle, char *value[])
345345
{
346346
Status &status = handle->pfw.lastStatus;
347-
*value = NULL;
347+
*value = nullptr;
348348
string retValue;
349349
bool success = handle->parameter.getAsString(retValue, status.msg());
350350
if (not success) {

bindings/c/Test.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ struct Test
114114
TEST_CASE_METHOD(Test, "Parameter-framework c api use")
115115
{
116116
// Create criteria
117-
const char *letterList[] = {"a", "b", "c", NULL};
118-
const char *numberList[] = {"1", "2", "3", NULL};
117+
const char *letterList[] = {"a", "b", "c", nullptr};
118+
const char *numberList[] = {"1", "2", "3", nullptr};
119119
const PfwCriterion criteria[] = {
120120
{"inclusiveCrit", true, letterList}, {"exclusiveCrit", false, numberList},
121121
};
@@ -165,23 +165,23 @@ TEST_CASE_METHOD(Test, "Parameter-framework c api use")
165165
REQUIRE_FAILURE(pfwStart(pfw, config, duplicatedCriteria, 2, &logger));
166166
}
167167
WHEN ("The pfw is started with duplicated criterion value state") {
168-
const char *values[] = {"a", "a", NULL};
168+
const char *values[] = {"a", "a", nullptr};
169169
const PfwCriterion duplicatedCriteria[] = {{"name", true, values}};
170170

171171
WHEN ("Using test logger") {
172172
REQUIRE_FAILURE(pfwStart(pfw, config, duplicatedCriteria, 1, &logger));
173173
}
174174
WHEN ("Using default logger") {
175175
// Test coverage of default logger warning
176-
REQUIRE_FAILURE(pfwStart(pfw, config, duplicatedCriteria, 1, NULL));
176+
REQUIRE_FAILURE(pfwStart(pfw, config, duplicatedCriteria, 1, nullptr));
177177
}
178178
}
179179
WHEN ("The pfw is started with NULL name criterion") {
180-
const PfwCriterion duplicatedCriteria[] = {{NULL, true, letterList}};
180+
const PfwCriterion duplicatedCriteria[] = {{nullptr, true, letterList}};
181181
REQUIRE_FAILURE(pfwStart(pfw, config, duplicatedCriteria, 1, &logger));
182182
}
183183
WHEN ("The pfw is started with NULL criterion state list") {
184-
const PfwCriterion duplicatedCriteria[] = {{"name", true, NULL}};
184+
const PfwCriterion duplicatedCriteria[] = {{"name", true, nullptr}};
185185
REQUIRE_FAILURE(pfwStart(pfw, config, duplicatedCriteria, 1, &logger));
186186
}
187187
GIVEN ("A criteria with lots of values") {
@@ -192,7 +192,7 @@ TEST_CASE_METHOD(Test, "Parameter-framework c api use")
192192
for (size_t i = 0; i < values.size(); ++i) {
193193
values[i] = &names[i];
194194
}
195-
values.back() = NULL;
195+
values.back() = nullptr;
196196
/* The pfw c api requires criterion values to be a NULL terminated
197197
* array of string. Each string is a pointer to a NULL terminated
198198
* array of char. The pfw requires each string to be different
@@ -225,7 +225,7 @@ TEST_CASE_METHOD(Test, "Parameter-framework c api use")
225225
REQUIRE_FAILURE(pfwStart(pfw, config, duplicatedCriteria, 1, &logger));
226226
}
227227
WHEN ("The pfw is started with max length criterion state list") {
228-
values[values.size() - 2] = NULL; // Hide last value
228+
values[values.size() - 2] = nullptr; // Hide last value
229229
REQUIRE_SUCCESS(pfwStart(pfw, config, duplicatedCriteria, 1, &logger));
230230
}
231231
}
@@ -240,11 +240,11 @@ TEST_CASE_METHOD(Test, "Parameter-framework c api use")
240240
}
241241

242242
WHEN ("The pfw is started without a logger callback") {
243-
PfwLogger noLog = {NULL, NULL};
243+
PfwLogger noLog = {nullptr, nullptr};
244244
REQUIRE_SUCCESS(pfwStart(pfw, config, criteria, criterionNb, &noLog));
245245
}
246246
WHEN ("The pfw is started with default logger") {
247-
REQUIRE_SUCCESS(pfwStart(pfw, config, criteria, criterionNb, NULL));
247+
REQUIRE_SUCCESS(pfwStart(pfw, config, criteria, criterionNb, nullptr));
248248
}
249249

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

317317
GIVEN ("An integer parameter handle") {
318318
PfwParameterHandler *param = pfwBindParameter(pfw, intParameterPath);
319-
REQUIRE_SUCCESS(param != NULL);
319+
REQUIRE_SUCCESS(param != nullptr);
320320

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

336336
GIVEN ("An string parameter handle") {
337337
PfwParameterHandler *param = pfwBindParameter(pfw, stringParameterPath);
338-
REQUIRE_SUCCESS(param != NULL);
338+
REQUIRE_SUCCESS(param != nullptr);
339339

340340
WHEN ("Set parameter out of range") {
341341
REQUIRE_FAILURE(pfwSetStringParameter(param, "ko_1234567"));

parameter/BitParameterType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ bool CBitParameterType::toBlackboard(const string &strValue, uint64_t &uiValue,
123123
CParameterAccessContext &parameterAccessContext) const
124124
{
125125
// Get value
126-
uint64_t uiConvertedValue = strtoull(strValue.c_str(), NULL, 0);
126+
uint64_t uiConvertedValue = strtoull(strValue.c_str(), nullptr, 0);
127127

128128
if (uiConvertedValue > _uiMax) {
129129

parameter/ComponentType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,5 @@ CInstanceConfigurableElement *CComponentType::doInstantiate() const
129129
// Not supposed to be called directly (instantiation made through CComponentInstance object)
130130
assert(0);
131131

132-
return NULL;
132+
return nullptr;
133133
}

parameter/ConfigurableDomain.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ bool CConfigurableDomain::parseConfigurableElements(const CXmlElement &xmlElemen
301301
}
302302
// Add found element to domain
303303
core::Results infos;
304-
if (!addConfigurableElement(pConfigurableElement, NULL, infos)) {
304+
if (!addConfigurableElement(pConfigurableElement, nullptr, infos)) {
305305

306306
strError = utility::asString(infos);
307307
serializingContext.setError(strError);
@@ -439,7 +439,7 @@ CParameterBlackboard *CConfigurableDomain::findConfigurationBlackboard(
439439

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

442-
return NULL;
442+
return nullptr;
443443
}
444444

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

464464
strError = "Element not associated to the Domain";
465465

466-
return NULL;
466+
return nullptr;
467467
}
468468

469469
// Domain splitting
@@ -535,7 +535,7 @@ const CDomainConfiguration *CConfigurableDomain::getPendingConfiguration() const
535535
}
536536
}
537537

538-
return NULL;
538+
return nullptr;
539539
}
540540

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

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

571571
// Do the restore
572-
pApplicableDomainConfiguration->restore(pParameterBlackboard, bSync, NULL);
572+
pApplicableDomainConfiguration->restore(pParameterBlackboard, bSync, nullptr);
573573

574574
// Record last applied configuration
575575
_pLastAppliedConfiguration = pApplicableDomainConfiguration;
@@ -627,7 +627,7 @@ bool CConfigurableDomain::createConfiguration(const string &strName,
627627
}
628628

629629
// Creation
630-
CDomainConfiguration *pDomainConfiguration = new CDomainConfiguration(strName);
630+
auto pDomainConfiguration = new CDomainConfiguration(strName);
631631

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

674674
// Forget about it
675-
_pLastAppliedConfiguration = NULL;
675+
_pLastAppliedConfiguration = nullptr;
676676
}
677677

678678
// Hierarchy
@@ -719,7 +719,7 @@ bool CConfigurableDomain::restoreConfiguration(const string &configurationName,
719719

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

722-
if (configuration == NULL) {
722+
if (configuration == nullptr) {
723723

724724
errors.push_back(error);
725725
return false;
@@ -994,7 +994,7 @@ const CDomainConfiguration *CConfigurableDomain::findValidDomainConfiguration(
994994
return pDomainConfiguration;
995995
}
996996
}
997-
return NULL;
997+
return nullptr;
998998
}
999999

10001000
// Search for an applicable configuration
@@ -1012,7 +1012,7 @@ const CDomainConfiguration *CConfigurableDomain::findApplicableDomainConfigurati
10121012
return pDomainConfiguration;
10131013
}
10141014
}
1015-
return NULL;
1015+
return nullptr;
10161016
}
10171017

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

11081108
// Create associated syncer set
1109-
CSyncerSet *pSyncerSet = new CSyncerSet;
1109+
auto pSyncerSet = new CSyncerSet;
11101110

11111111
// Add to sync set the configurable element one
11121112
pConfigurableElement->fillSyncerSet(*pSyncerSet);
@@ -1182,8 +1182,7 @@ void CConfigurableDomain::doRemoveConfigurableElement(CConfigurableElement *pCon
11821182
CSyncerSet *CConfigurableDomain::getSyncerSet(
11831183
const CConfigurableElement *pConfigurableElement) const
11841184
{
1185-
ConfigurableElementToSyncerSetMapIterator mapIt =
1186-
_configurableElementToSyncerSetMap.find(pConfigurableElement);
1185+
auto mapIt = _configurableElementToSyncerSetMap.find(pConfigurableElement);
11871186

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

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

1205-
return NULL;
1204+
return nullptr;
12061205
}
12071206
return pDomainConfiguration;
12081207
}
@@ -1217,7 +1216,7 @@ const CDomainConfiguration *CConfigurableDomain::findConfiguration(const string
12171216

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

1220-
return NULL;
1219+
return nullptr;
12211220
}
12221221
return pDomainConfiguration;
12231222
}

0 commit comments

Comments
 (0)