Skip to content

Commit 3055a34

Browse files
FabioGhattasPolimiguitargeek
authored andcommitted
Apply suggestions from code review by Philippe Canal
1 parent 0f527e2 commit 3055a34

File tree

17 files changed

+102
-69
lines changed

17 files changed

+102
-69
lines changed

core/base/src/TEnv.cxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,10 +419,12 @@ TEnv::TEnv(const char *name)
419419
ReadFile(s, kEnvGlobal);
420420
if (!gSystem->Getenv("ROOTENV_NO_HOME")) {
421421
if (const auto rootrcPath = gSystem->Getenv("ROOTENV_USER_PATH")) {
422-
const char *s1 = gSystem->PrependPathName(rootrcPath, TString(name));
422+
TString temp(name);
423+
const char *s1 = gSystem->PrependPathName(rootrcPath, temp);
423424
ReadFile(s1, kEnvUser);
424425
} else {
425-
const char *s1 = gSystem->PrependPathName(gSystem->HomeDirectory(), TString(name));
426+
TString temp(name);
427+
const char *s1 = gSystem->PrependPathName(gSystem->HomeDirectory(), temp);
426428
ReadFile(s1, kEnvUser);
427429
}
428430
if (strcmp(gSystem->HomeDirectory(), gSystem->WorkingDirectory())) {

core/base/src/TPluginManager.cxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,8 @@ void TPluginManager::LoadHandlersFromPluginDirs(const char *base)
542542
const char *f1;
543543
while ((f1 = gSystem->GetDirEntry(dirp))) {
544544
TString f = f1;
545-
const char *p1 = gSystem->PrependPathName(d, TString(f));
545+
TString temp = f1;
546+
const char *p1 = gSystem->PrependPathName(d, temp);
546547
LoadHandlerMacros(p1);
547548
fBasesLoaded->Add(new TObjString(f));
548549
}
@@ -685,7 +686,8 @@ Int_t TPluginManager::WritePluginMacros(const char *dir, const char *plugin) con
685686
base = h->fBase;
686687
} else
687688
idx += 10;
688-
TString sdd = gSystem->PrependPathName(d, TString(h->fBase));
689+
TString temp = h->fBase;
690+
TString sdd = gSystem->PrependPathName(d, temp);
689691
sdd.ReplaceAll("::", "@@");
690692
if (gSystem->AccessPathName(sdd, kWritePermission)) {
691693
if (gSystem->MakeDirectory(sdd) < 0) {

core/base/src/TSystem.cxx

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2586,8 +2586,8 @@ static void R__WriteDependencyFile(const TString & build_loc, const TString &dep
25862586
#ifndef WIN32
25872587
const char * stderrfile = "/dev/null";
25882588
#else
2589-
TString stderrfile;
2590-
stderrfile = gSystem->PrependPathName(build_loc,TString("stderr.tmp"));
2589+
TString stderrfile= "stderr.tmp";
2590+
gSystem->PrependPathName(build_loc, stderrfile);
25912591
#endif
25922592
TString bakdepfilename = depfilename + ".bak";
25932593

@@ -2898,7 +2898,7 @@ int TSystem::CompileMacro(const char *filename, Option_t *opt,
28982898
if (build_loc == ".") {
28992899
build_loc = WorkingDirectory();
29002900
} else if (build_loc.Length() && (!IsAbsoluteFileName(build_loc)) ) {
2901-
build_loc = PrependPathName( WorkingDirectory(), build_loc );
2901+
PrependPathName( WorkingDirectory(), build_loc );
29022902
}
29032903

29042904
// Get the include directory list in the dir1:dir2:dir3 format
@@ -2991,7 +2991,7 @@ int TSystem::CompileMacro(const char *filename, Option_t *opt,
29912991
library = library_specified;
29922992
ExpandPathName( library );
29932993
if (! IsAbsoluteFileName(library) ) {
2994-
library = PrependPathName( WorkingDirectory(), library );
2994+
PrependPathName( WorkingDirectory(), library );
29952995
}
29962996
libname_noext = library_specified;
29972997
library = TString(library) + "." + fSoExt;
@@ -3030,15 +3030,17 @@ int TSystem::CompileMacro(const char *filename, Option_t *opt,
30303030
if (pos==0) lib_location.Remove(pos,3);
30313031

30323032
if (flatBuildDir) {
3033-
library = PrependPathName( build_loc, TString(libname_ext)) ;
3033+
library = libname_ext;
3034+
PrependPathName( build_loc, library) ;
30343035
} else {
3035-
library = PrependPathName( build_loc, library) ;
3036+
PrependPathName( build_loc, library) ;
30363037
}
30373038

30383039
Bool_t canWriteBuild_loc = !gSystem->AccessPathName(build_loc,kWritePermission);
30393040
TString build_loc_store( build_loc );
30403041
if (!flatBuildDir) {
3041-
build_loc = PrependPathName( build_loc, TString(lib_location));
3042+
TString temp_lib_location = lib_location;
3043+
build_loc = PrependPathName( build_loc, temp_lib_location);
30423044
}
30433045

30443046
if (gSystem->AccessPathName(build_loc,kFileExists)) {
@@ -3140,8 +3142,8 @@ int TSystem::CompileMacro(const char *filename, Option_t *opt,
31403142
{
31413143
UserGroup_t *ug = gSystem->GetUserInfo(gSystem->GetUid());
31423144
if (ug) {
3143-
TString user = (ug->fUser).Data();
3144-
emergency_loc = PrependPathName( TempDirectory(), user );
3145+
emergency_loc = (ug->fUser).Data();
3146+
PrependPathName( TempDirectory(), emergency_loc );
31453147
delete ug;
31463148
} else {
31473149
emergency_loc = TempDirectory();
@@ -3154,8 +3156,8 @@ int TSystem::CompileMacro(const char *filename, Option_t *opt,
31543156

31553157
// Generate the dependency filename
31563158
TString depdir = build_loc;
3157-
TString depfilename;
3158-
depfilename = PrependPathName(depdir, TString(BaseName(libname_noext)));
3159+
TString depfilename = BaseName(libname_noext);
3160+
PrependPathName(depdir, depfilename);
31593161
depfilename += "_" + extension + ".d";
31603162

31613163
if ( !recompile ) {
@@ -3175,7 +3177,8 @@ int TSystem::CompileMacro(const char *filename, Option_t *opt,
31753177
if ( gSystem->GetPathInfo( depfilename, nullptr,(Long_t*) nullptr, nullptr, &file_time ) != 0 ) {
31763178
if (!canWrite) {
31773179
depdir = emergency_loc;
3178-
depfilename = PrependPathName(depdir, TString(BaseName(libname_noext)));
3180+
depfilename = BaseName(libname_noext);
3181+
PrependPathName(depdir, depfilename);
31793182
depfilename += "_" + extension + ".d";
31803183
}
31813184
R__WriteDependencyFile(build_loc, depfilename, filename_fullpath, library, libname, extension, version_var_prefix, includes, defines, incPath);
@@ -3327,8 +3330,8 @@ int TSystem::CompileMacro(const char *filename, Option_t *opt,
33273330

33283331
}
33293332

3330-
TString libmapfilename;
3331-
libmapfilename = PrependPathName( build_loc, TString(libname) );
3333+
TString libmapfilename = libname;
3334+
PrependPathName( build_loc, libmapfilename );
33323335
libmapfilename += ".rootmap";
33333336
#if (defined(R__MACOSX) && !defined(MAC_OS_X_VERSION_10_5)) || defined(R__WIN32)
33343337
Bool_t produceRootmap = kTRUE;
@@ -3448,8 +3451,8 @@ int TSystem::CompileMacro(const char *filename, Option_t *opt,
34483451
dictObj += fObjExt;
34493452

34503453
// ======= Generate a linkdef file
3451-
3452-
TString linkdef = PrependPathName( build_loc, TString(libname) );
3454+
TString linkdef = libname;
3455+
PrependPathName( build_loc, linkdef );
34533456
linkdef += "_ACLiC_linkdef.h";
34543457
std::ofstream linkdefFile( linkdef, std::ios::out );
34553458
linkdefFile << "// File Automatically generated by the ROOT Script Compiler "
@@ -3500,8 +3503,8 @@ int TSystem::CompileMacro(const char *filename, Option_t *opt,
35003503
linkdefFile.close();
35013504
// ======= Generate the list of rootmap files to be looked at
35023505

3503-
TString mapfile;
3504-
mapfile = PrependPathName( build_loc, TString(libname) );
3506+
TString mapfile = libname;
3507+
PrependPathName( build_loc, mapfile );
35053508
mapfile += "_ACLiC_map";
35063509
TString mapfilein = mapfile + ".in";
35073510
TString mapfileout = mapfile + ".out";
@@ -3518,20 +3521,23 @@ int TSystem::CompileMacro(const char *filename, Option_t *opt,
35183521
{
35193522
TString name = ".rootmap";
35203523
TString sname = "system.rootmap";
3521-
TString file;
3522-
file = PrependPathName(TROOT::GetEtcDir(), TString(sname));
3524+
TString file = sname;
3525+
PrependPathName(TROOT::GetEtcDir(), file);
35233526
if (gSystem->AccessPathName(file)) {
35243527
// for backward compatibility check also $ROOTSYS/system<name> if
35253528
// $ROOTSYS/etc/system<name> does not exist
3526-
file = PrependPathName(TROOT::GetRootSys(), sname);
3529+
file = sname;
3530+
PrependPathName(TROOT::GetRootSys(), file);
35273531
if (gSystem->AccessPathName(file)) {
35283532
// for backward compatibility check also $ROOTSYS/<name> if
35293533
// $ROOTSYS/system<name> does not exist
3530-
file = PrependPathName(TROOT::GetRootSys(), TString(name));
3534+
file = name;
3535+
PrependPathName(TROOT::GetRootSys(), file);
35313536
}
35323537
}
35333538
mapfileStream << file << std::endl;
3534-
file = PrependPathName(gSystem->HomeDirectory(), TString(name) );
3539+
file = name;
3540+
PrependPathName(gSystem->HomeDirectory(), file );
35353541
mapfileStream << file << std::endl;
35363542
mapfileStream << name << std::endl;
35373543
if (gInterpreter->GetRootMapFiles()) {
@@ -3748,7 +3754,8 @@ int TSystem::CompileMacro(const char *filename, Option_t *opt,
37483754
#endif
37493755

37503756
TString testcmd = fMakeExe;
3751-
TString fakeMain = PrependPathName( build_loc, TString(libname) );
3757+
TString fakeMain = libname;
3758+
PrependPathName( build_loc, fakeMain );
37523759
fakeMain += "_ACLiC_main";
37533760
fakeMain += extension;
37543761
std::ofstream fakeMainFile( fakeMain, std::ios::out );
@@ -3764,7 +3771,8 @@ int TSystem::CompileMacro(const char *filename, Option_t *opt,
37643771
// however compilation would fail if a main is already there
37653772
// (like stress.cxx)
37663773
// dict.Append(" ").Append(fakeMain);
3767-
TString exec = PrependPathName( build_loc, TString(libname) );
3774+
TString exec = libname;
3775+
PrependPathName( build_loc, exec );
37683776
exec += "_ACLiC_exec";
37693777
testcmd.ReplaceAll("$SourceFiles","-D__ACLIC__ \"$SourceFiles\"");
37703778
testcmd.ReplaceAll("$SourceFiles",dict);

core/base/src/TSystemFile.cxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ void TSystemFile::Copy(const char *to)
104104

105105
if (IsDirectory(to)) {
106106
if (name.EndsWith("/")) name.Chop();
107-
name = gSystem->PrependPathName(name, TString(fName));
107+
TString temp = fName;
108+
name = gSystem->PrependPathName(name, temp);
108109
}
109110

110111
Int_t status = gSystem->CopyFile(fName, name, kFALSE);
@@ -130,7 +131,8 @@ void TSystemFile::Move(const char *to)
130131

131132
if (IsDirectory(to)) {
132133
if (name.EndsWith("/")) name.Chop();
133-
name = gSystem->PrependPathName(name, TString(fName));
134+
TString temp = fName;
135+
name = gSystem->PrependPathName(name, temp);
134136
}
135137
Int_t status = gSystem->CopyFile(fName, name, kFALSE);
136138

core/metacling/src/TCling.cxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5729,13 +5729,15 @@ void TCling::InitRootmapFile(const char *name)
57295729

57305730
TString sname = "system";
57315731
sname += name;
5732-
const char *s1 = gSystem->PrependPathName(TROOT::GetEtcDir(), TString(sname));
5732+
TString temp_sname = sname;
5733+
const char *s1 = gSystem->PrependPathName(TROOT::GetEtcDir(), temp_sname);
57335734

57345735
Int_t ret = ReadRootmapFile(s1);
57355736
if (ret == -3) // old format
57365737
fMapfile->ReadFile(s1, kEnvGlobal);
57375738
if (!gSystem->Getenv("ROOTENV_NO_HOME")) {
5738-
const char *s2 = gSystem->PrependPathName(gSystem->HomeDirectory(), TString(name));
5739+
TString temp_name = name;
5740+
const char *s2 = gSystem->PrependPathName(gSystem->HomeDirectory(), temp_name);
57395741
ret = ReadRootmapFile(s2);
57405742
if (ret == -3) // old format
57415743
fMapfile->ReadFile(s2, kEnvUser);

core/rint/src/TRint.cxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,13 @@ void TRint::ExecLogon()
349349
TString name = ".rootlogon.C";
350350
TString sname = "system";
351351
sname += name;
352-
const char *s = gSystem->PrependPathName(TROOT::GetEtcDir(), TString(sname));
352+
TString temp_sname = sname;
353+
TString temp_name = name;
354+
const char *s = gSystem->PrependPathName(TROOT::GetEtcDir(), temp_sname);
353355
if (!gSystem->AccessPathName(s, kReadPermission)) {
354356
ProcessFile(s);
355357
}
356-
const char *s1 = gSystem->PrependPathName(gSystem->HomeDirectory(), TString(name));
358+
const char *s1 = gSystem->PrependPathName(gSystem->HomeDirectory(), temp_name);
357359
if (!gSystem->AccessPathName(s1, kReadPermission)) {
358360
ProcessFile(s1);
359361
}

core/unix/src/TUnixSystem.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ const char *TUnixSystem::TempDirectory() const
15211521

15221522
FILE *TUnixSystem::TempFileName(TString &base, const char *dir, const char *suffix)
15231523
{
1524-
base = PrependPathName(dir ? dir : TempDirectory(), base);
1524+
PrependPathName(dir ? dir : TempDirectory(), base);
15251525
base += "XXXXXX";
15261526
const bool hasSuffix = suffix && *suffix;
15271527
if (hasSuffix)

gui/gui/src/TGFileBrowser.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ TString TGFileBrowser::FullPathName(TGListTreeItem* item)
10931093
TString dirname = itm->GetText();
10941094

10951095
while ((parent=itm->GetParent())) {
1096-
dirname = gSystem->PrependPathName(parent->GetText(), dirname);
1096+
gSystem->PrependPathName(parent->GetText(), dirname);
10971097
itm = parent;
10981098
}
10991099
gSystem->ExpandPathName(dirname);

gui/gui/src/TGFileDialog.cxx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ Bool_t TGFileDialog::ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t)
431431
void *p = 0;
432432
TString txt;
433433
TString sdir = gSystem->WorkingDirectory();
434+
TString temp_string = fTbfname->GetString();
434435

435436
switch (GET_MSG(msg)) {
436437
case kC_COMMAND:
@@ -464,9 +465,10 @@ Bool_t TGFileDialog::ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t)
464465
// FIXME: once appropriate gSystem method exists, use SetFilename here
465466
if (gSystem->IsAbsoluteFileName(fTbfname->GetString()))
466467
fFileInfo->SetFilename(fTbfname->GetString());
467-
else
468-
fFileInfo->fFilename = strdup(gSystem->PrependPathName(fFc->GetDirectory(),
469-
TString(fTbfname->GetString())));
468+
else {
469+
TString temp = fTbfname->GetString();
470+
fFileInfo->fFilename = strdup(gSystem->PrependPathName(fFc->GetDirectory(), temp));
471+
}
470472
pExpandUnixPathName(*fFileInfo);
471473
}
472474
if (fCheckB && (fCheckB->GetState() == kButtonDown))
@@ -610,8 +612,8 @@ Bool_t TGFileDialog::ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t)
610612
fFileInfo->fFileNamesList = new TList();
611613
}
612614
while ((el = (TObjString *) next())) {
613-
const char *s = gSystem->PrependPathName(fFc->GetDirectory(),
614-
TString(el->GetString()));
615+
TString temp = el->GetString();
616+
const char *s = gSystem->PrependPathName(fFc->GetDirectory(), temp);
615617
tmpString += "\"" + el->GetString() + "\" ";
616618
fFileInfo->fFileNamesList->Add(new TObjString(s));
617619
}
@@ -659,9 +661,10 @@ Bool_t TGFileDialog::ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t)
659661
// FIXME: once appropriate gSystem method exists, use SetFilename here
660662
if (gSystem->IsAbsoluteFileName(fTbfname->GetString()))
661663
fFileInfo->SetFilename(fTbfname->GetString());
662-
else
663-
fFileInfo->fFilename = strdup(gSystem->PrependPathName(fFc->GetDirectory(),
664-
TString(fTbfname->GetString())));
664+
else {
665+
TString temp = fTbfname->GetString();
666+
fFileInfo->fFilename = strdup(gSystem->PrependPathName(fFc->GetDirectory(), temp));
667+
}
665668
pExpandUnixPathName(*fFileInfo);
666669
if (fCheckB && (fCheckB->GetState() == kButtonDown))
667670
fFileInfo->fOverwrite = kTRUE;
@@ -721,8 +724,8 @@ Bool_t TGFileDialog::ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t)
721724
}
722725
fFileInfo->SetFilename(nullptr);
723726
// FIXME: once appropriate gSystem method exists, use SetFilename here
724-
fFileInfo->fFilename = strdup(gSystem->PrependPathName(fFc->GetDirectory(),
725-
TString(fTbfname->GetString())));
727+
temp_string = fTbfname->GetString();
728+
fFileInfo->fFilename = strdup(gSystem->PrependPathName(fFc->GetDirectory(), temp_string));
726729
pExpandUnixPathName(*fFileInfo);
727730
if (fCheckB && (fCheckB->GetState() == kButtonDown))
728731
fFileInfo->fOverwrite = kTRUE;

gui/gui/src/TGIcon.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ void TGIcon::Reset()
177177

178178
TString name = fImage->GetName();
179179
name.Chop();
180-
const char *path = gSystem->PrependPathName(fPath.Data(), TString(name.Data()));
180+
TString temp = name;
181+
const char *path = gSystem->PrependPathName(fPath.Data(), temp);
181182
SetImage(path);
182183
}
183184

0 commit comments

Comments
 (0)