Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Abdoulbari Zaher  <[email protected]>
  • Loading branch information
flomnes and a-zakir authored Jul 1, 2024
1 parent 6d644b0 commit c75f4fa
Show file tree
Hide file tree
Showing 42 changed files with 86 additions and 84 deletions.
6 changes: 3 additions & 3 deletions src/analyzer/atsp/load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ bool ATSP::loadFromINIFile(const String& filename)
CString<50, false> key;
CString<50, false> value;

for (section = ini.firstSection; section != nullptr; section = section->next)
for (section = ini.firstSection; section; section = section->next)
{
if (section->name == ".general")
{
IniFile::Property* p = section->firstProperty;
for (; p != nullptr; p = p->next)
for (; p ; p = p->next)
{
key = p->key;
key.toLower();
Expand Down Expand Up @@ -180,7 +180,7 @@ bool ATSP::loadFromINIFile(const String& filename)
info->distribution = Data::XCast::dtBeta;

IniFile::Property* p = section->firstProperty;
for (; p != nullptr; p = p->next)
for (; p; p = p->next)
{
key = p->key;
key.toLower();
Expand Down
2 changes: 1 addition & 1 deletion src/ext/yuni/src/yuni/core/dynamiclibrary/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ bool File::loadFromRawFilename(const AnyString& filename, File::Relocation r, Fi
bool File::hasSymbol(const AnyString& name) const
{
return NullHandle != pHandle
and nullptr != reinterpret_cast<Symbol::Handle>(YUNI_DYNLIB_DLSYM(pHandle, name.c_str()));
&& reinterpret_cast<Symbol::Handle>(YUNI_DYNLIB_DLSYM(pHandle, name.c_str()));
}

Symbol File::resolve(const AnyString& name) const
Expand Down
4 changes: 2 additions & 2 deletions src/ext/yuni/src/yuni/core/getopt/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ inline Context::Context(Parser& parser) : pParser(parser), pTokenIndex(1), pPara

bool Context::findNextParameter(IOption* option, int argc, char* argv[])
{
assert(option != nullptr);
assert(option);

if (not option->requireAdditionalParameter())
{
Expand Down Expand Up @@ -343,7 +343,7 @@ GetOpt::ReturnCode Parser::operator()(int argc, char* argv[])

void Parser::helpUsage(const char* argv0)
{
assert(argv0 != nullptr); // just in case
assert(argv0); // just in case// OK

std::cout.write("Usage: ", 7);
std::cout << ExtractFilenameOnly(argv0);
Expand Down
4 changes: 2 additions & 2 deletions src/ext/yuni/src/yuni/core/system/gettimeofday.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ namespace Yuni
{
int gettimeofday(struct timeval* tv, struct timezone* tz)
{
if (nullptr != tv)
if (tv)
{
struct _timeb timebuffer;
_ftime64_s(&timebuffer);
tv->tv_sec = (int64_t)(timebuffer.time);
tv->tv_usec = (int64_t)(timebuffer.millitm * 1000);
}

if (nullptr != tz)
if (tz)
{
static int tzflag = 0;
if (!tzflag)
Expand Down
16 changes: 8 additions & 8 deletions src/ext/yuni/src/yuni/io/directory/info/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ void IteratorDataFree(const IteratorData* data)

IteratorData* IteratorDataNext(IteratorData* data)
{
assert(data != nullptr);
assert(data);
if (data->next())
return data;
delete data;
Expand All @@ -365,43 +365,43 @@ IteratorData* IteratorDataNext(IteratorData* data)

const String& IteratorDataFilename(const IteratorData* data)
{
assert(data != nullptr);
assert(data);
return data->dirinfo.front().filename;
}

const String& IteratorDataParentName(const IteratorData* data)
{
assert(data != nullptr);
assert(data);
return data->dirinfo.front().parent;
}

const String& IteratorDataName(const IteratorData* data)
{
assert(data != nullptr);
assert(data);
return data->dirinfo.front().name;
}

uint64_t IteratorDataSize(const IteratorData* data)
{
assert(data != nullptr);
assert(data);
return data->dirinfo.front().size;
}

int64_t IteratorDataModified(const IteratorData* data)
{
assert(data != nullptr);
assert(data);
return data->dirinfo.front().modified;
}

bool IteratorDataIsFolder(const IteratorData* data)
{
assert(data != nullptr);
assert(data);
return data->dirinfo.front().isFolder;
}

bool IteratorDataIsFile(const IteratorData* data)
{
assert(data != nullptr);
assert(data);
return !data->dirinfo.front().isFolder;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ext/yuni/src/yuni/io/directory/iterator/iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Flow TraverseWindowsFolder(const String& filename,
bool files)
{
// Convertir the filename
assert(opts.wbuffer != nullptr);
assert(opts.wbuffer);
opts.wbuffer[0] = L'\\';
opts.wbuffer[1] = L'\\';
opts.wbuffer[2] = L'?';
Expand Down
2 changes: 1 addition & 1 deletion src/ext/yuni/src/yuni/io/directory/remove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static bool RmDirRecursiveInternal(const AnyString& path)
buffer.clear() << path << SEP << (const char*)ep->d_name;
::unlink(buffer.c_str());
}
} while (nullptr != (ep = ::readdir(dp)));
} while ( ep = ::readdir(dp); ep ); // ...
}
(void)::closedir(dp);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ext/yuni/src/yuni/io/file/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ bool Stream::open(const AnyString& filename, int mode)
pFd = ::fopen(filename.c_str(), OpenMode::ToCString(mode));
#endif

return (nullptr != pFd);
return (pFd);
}

bool Stream::close()
Expand Down
4 changes: 2 additions & 2 deletions src/ext/yuni/src/yuni/job/job.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ IJob::IJob() : pThread(nullptr)

IJob::~IJob()
{
assert(this != nullptr and "IJob: Destructor: Oo `this' is null !?");
assert(pThread == nullptr and "A job can not be attached to a thread when destroyed");
assert(this && "IJob: Destructor: Oo `this' is null !?");
assert(!pThread && "A job can not be attached to a thread when destroyed");
}

bool IJob::suspend(uint delay) const
Expand Down
4 changes: 2 additions & 2 deletions src/libs/antares/correlation/correlation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,13 @@ int InterAreaCorrelationLoadFromIniFile(Matrix<>* m, AreaList* l, IniFile* ini,
if (ini)
{
IniFile::Section* s;
for (s = ini->firstSection; s != nullptr; s = s->next) /* Each section */
for (s = ini->firstSection; s; s = s->next) /* Each section */
{
Area* from = AreaListLFind(l, s->name.c_str());
if (from)
{
IniFile::Property* p;
for (p = s->firstProperty; p != nullptr; p = p->next) /* Each property*/
for (p = s->firstProperty; p; p = p->next) /* Each property*/
{
Area* to = AreaListLFind(l, p->key.c_str());
if (to and to != from)
Expand Down
4 changes: 2 additions & 2 deletions src/libs/antares/locale/locale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ namespace Antares
void InitializeDefaultLocale()
{
#ifdef YUNI_OS_WINDOWS
if (nullptr == std::setlocale(LC_ALL, "English"))
if (!std::setlocale(LC_ALL, "English"))
{
std::cerr << "impossible to set locale to English" << std::endl;
}

#else
if (nullptr == std::setlocale(LC_ALL, "en_US.utf8"))
if (! std::setlocale(LC_ALL, "en_US.utf8"))
{
std::cerr << "impossible to set locale to en_US.utf8" << std::endl;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libs/antares/resources/resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ bool FindExampleFolder(Yuni::String& folder)

void Initialize(int argc, char** argv, bool initializeSearchPath)
{
if (argc < 1 or argv[0] == nullptr)
if (argc < 1 or !argv[0])
{
logs.error() << "Impossible to find the root folder";
return;
Expand Down
4 changes: 2 additions & 2 deletions src/libs/fswalker/fswalker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ bool WalkerThread::triggerFileEvent(const String& filename,
int64_t modified,
uint64_t size)
{
assert(pFileJob != nullptr);
assert(pFileJob);

// Statistics
++statistics.fileCount;
Expand Down Expand Up @@ -320,7 +320,7 @@ void WalkerThread::walk(const String& path)

do
{
assert(pContext.top() != nullptr);
assert(pContext.top() );
auto& context = *(pContext.top());

if (pShouldStop)
Expand Down
4 changes: 2 additions & 2 deletions src/solver/constraints-builder/cbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,12 @@ bool CBuilder::completeCBuilderFromFile(const std::string& filename)
CString<50, false> key;
CString<50, false> value;

for (section = ini.firstSection; section != nullptr; section = section->next)
for (section = ini.firstSection; section ; section = section->next)
{
if (section->name == ".general")
{
IniFile::Property* p = section->firstProperty;
for (; p != nullptr; p = p->next)
for (; p ; p = p->next)
{
key = p->key;
key.toLower();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
void OPT_ConstruireLaListeDesVariablesOptimiseesDuProblemeQuadratique(PROBLEME_HEBDO* problemeHebdo)
{
const auto& ProblemeAResoudre = problemeHebdo->ProblemeAResoudre;
assert(ProblemeAResoudre != nullptr);
assert(ProblemeAResoudre );

int nombreDeVariables = 0;
auto variableManager = VariableManagerFromProblemHebdo(problemeHebdo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void OPT_LiberationProblemesSimplexe(const OptimizationOptions& options,
ORTOOLS_LibererProbleme(solver);
solver = nullptr;
}
else if (ProbSpx != nullptr)
else if (ProbSpx)
{
SPX_LibererProbleme(ProbSpx);
ProbSpx = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/solver/ts-generator/xcast/math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace XCast
{
void XCast::normal(float& x, float& y)
{
assert(random != nullptr);
assert(random);

double z;
double xd;
Expand Down
2 changes: 1 addition & 1 deletion src/tests/src/solver/simulation/tests-ts-numbers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void initializeStudy(Study::Ptr study, unsigned int nbYears = 1)
Area* addAreaToStudy(Study::Ptr study, const std::string& areaName)
{
Area* area = study->areaAdd(areaName);
BOOST_CHECK(area != nullptr);
BOOST_CHECK(area);

return area;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/action/handler/antares-study/area/create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ bool Create::performWL(Context& ctx)
}
}
ctx.autoselectAreas.push_back(ctx.area);
return (ctx.area != nullptr);
return (ctx.area);
}

void Create::createActionsForAStandardAreaCopy(Context& ctx, bool copyPosition)
Expand Down
2 changes: 1 addition & 1 deletion src/ui/action/handler/antares-study/constraint/create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ bool Create::performWL(Context& ctx)
// ctx.constraint->type(pType);
}
ctx.autoselectConstraints.push_back(ctx.constraint);
return (ctx.constraint != nullptr);
return (ctx.constraint);
}

void Create::createActionsForAStandardConstraintCopy(Context&)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ bool Create::performWL(Context& ctx)
if (pInfos.behavior == bhOverwrite)
(ctx.cluster)->reset();
}
return (ctx.area != nullptr);
return (ctx.area);
}
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ui/common/component/spotlight/spotlight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,9 @@ void Spotlight::resizeParentWindow()
parent->SetSize(parent->GetSize().GetWidth(), idealH);
}

assert(parent->GetSizer() != nullptr);
assert(parent->GetSizer());
parent->GetSizer()->Layout();
assert(GetSizer() != nullptr);
assert(GetSizer());
GetSizer()->Layout();
Dispatcher::GUI::Refresh(parent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace Forms
{
void ApplWnd::createNBNodalOptimization()
{
assert(nullptr != pNotebook);
assert(pNotebook);

// Create a standard page with an input selector
std::pair<Component::Notebook*, Toolbox::InputSelector::Area*> page
Expand Down
2 changes: 1 addition & 1 deletion src/ui/simulator/application/main/build/load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace Forms
{
void ApplWnd::createNBLoad()
{
assert(nullptr != pNotebook);
assert(pNotebook);

// Create a standard page with an input selector
std::pair<Component::Notebook*, Toolbox::InputSelector::Area*> page
Expand Down
2 changes: 1 addition & 1 deletion src/ui/simulator/application/main/build/notes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace Forms
{
void ApplWnd::createNBNotes()
{
assert(nullptr != pNotebook);
assert(pNotebook);

pUserNotes = new Window::Notes(pNotebook);
pNotebook->add(pUserNotes, wxT("notes"), wxT("User's Notes"));
Expand Down
2 changes: 1 addition & 1 deletion src/ui/simulator/application/main/build/sets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace Forms
{
void ApplWnd::createNBSets()
{
assert(nullptr != pNotebook);
assert(pNotebook);

pSets = new Window::Sets(pNotebook);
pNotebook->add(pSets, wxT("sets"), wxT(""));
Expand Down
2 changes: 1 addition & 1 deletion src/ui/simulator/application/main/build/solar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace Forms
{
void ApplWnd::createNBSolar()
{
assert(nullptr != pNotebook);
assert(pNotebook);

// Create a standard page with an input selector
std::pair<Component::Notebook*, Toolbox::InputSelector::Area*> page
Expand Down
2 changes: 1 addition & 1 deletion src/ui/simulator/application/main/build/wind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace Forms
{
void ApplWnd::createNBWind()
{
assert(nullptr != pNotebook);
assert(pNotebook);

// Create a standard page with an input selector
std::pair<Component::Notebook*, Toolbox::InputSelector::Area*> page
Expand Down
2 changes: 1 addition & 1 deletion src/ui/simulator/application/main/internal-data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ MainFormData::MainFormData(ApplWnd& form) : wipEnabled(false), wipPanel(nullptr)

void MainFormData::editCurrentLocation(const wxString& string)
{
assert(pEditCurrentLocation != nullptr);
assert(pEditCurrentLocation);
pEditCurrentLocation->SetItemLabel(wxString(wxT("Current tab : ")) << string);
}

Expand Down
Loading

0 comments on commit c75f4fa

Please sign in to comment.