Skip to content

Commit 703ea46

Browse files
ChristianTackeGSIkarabowi
authored andcommitted
Fix Some Uninitailized Member Variable Warnings
This cleans up all the classes derived from FairGeoSet. Instead of initializing the member variables in the constructor body, use a default member initializer in the class. Also: * do not set maxSectors to its default value * Add a bunch of override
1 parent 22c96f7 commit 703ea46

33 files changed

Lines changed: 122 additions & 188 deletions

File tree

examples/MQ/pixelDetector/src/PixelGeo.cxx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ PixelGeo::PixelGeo()
1616
// fName has to be the name used in the geometry for all volumes.
1717
// If there is a mismatch the geometry cannot be build.
1818
fName = "Pixel";
19-
strcpy(modName, "Pixel");
20-
strcpy(eleName, "Pixel");
21-
maxSectors = 0;
2219
maxModules = 10;
2320
}
2421

examples/MQ/pixelDetector/src/PixelGeo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
@@ -16,8 +16,8 @@
1616
class PixelGeo : public FairGeoSet
1717
{
1818
protected:
19-
char modName[20]; // name of module
20-
char eleName[20]; // substring for elements in module
19+
char modName[20]{"Pixel"}; // name of module
20+
char eleName[20]{"Pixel"}; // substring for elements in module
2121

2222
public:
2323
PixelGeo();

examples/advanced/Tutorial3/simulation/FairTestDetectorGeo.cxx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ FairTestDetectorGeo::FairTestDetectorGeo()
1616
// fName has to be the name used in the geometry for all volumes.
1717
// If there is a mismatch the geometry cannot be build.
1818
fName = "torino";
19-
strcpy(modName, "torino");
20-
strcpy(eleName, "torino");
21-
maxSectors = 0;
2219
maxModules = 10;
2320
}
2421

examples/advanced/Tutorial3/simulation/FairTestDetectorGeo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
@@ -16,8 +16,8 @@
1616
class FairTestDetectorGeo : public FairGeoSet
1717
{
1818
protected:
19-
char modName[20]; // name of module
20-
char eleName[20]; // substring for elements in module
19+
char modName[20]{"torino"}; // name of module
20+
char eleName[20]{"torino"}; // substring for elements in module
2121
public:
2222
FairTestDetectorGeo();
2323
~FairTestDetectorGeo() override = default;

examples/advanced/propagator/src/FairTutPropGeo.cxx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ FairTutPropGeo::FairTutPropGeo()
1717
// fName has to be the name used in the geometry for all volumes.
1818
// If there is a mismatch the geometry cannot be build.
1919
fName = "Pixel";
20-
strcpy(modName, "Pixel");
21-
strcpy(eleName, "Pixel");
22-
maxSectors = 0;
2320
maxModules = 10;
2421
}
2522

examples/advanced/propagator/src/FairTutPropGeo.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2019-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
@@ -14,17 +14,16 @@
1414

1515
class FairTutPropGeo : public FairGeoSet
1616
{
17-
1817
protected:
19-
char modName[20]; // name of module
20-
char eleName[20]; // substring for elements in module
18+
char modName[20]{"Pixel"}; // name of module
19+
char eleName[20]{"Pixel"}; // substring for elements in module
2120
public:
2221
FairTutPropGeo();
23-
~FairTutPropGeo() {}
24-
const char* getModuleName(Int_t);
25-
const char* getEleName(Int_t);
26-
inline Int_t getModNumInMod(const TString&);
27-
ClassDef(FairTutPropGeo, 1);
22+
~FairTutPropGeo() override = default;
23+
const char* getModuleName(Int_t) override;
24+
const char* getEleName(Int_t) override;
25+
inline Int_t getModNumInMod(const TString&) override;
26+
ClassDefOverride(FairTutPropGeo, 1);
2827
};
2928

3029
inline Int_t FairTutPropGeo::getModNumInMod(const TString& name)
Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
@@ -14,23 +14,21 @@
1414
#include <TString.h> // for TString
1515
#include <iosfwd> // for fstream
1616

17-
class FairGeoMedia;
18-
1917
class FairGeoCave : public FairGeoSet
2018
{
2119
protected:
2220
TString name;
2321

2422
public:
2523
FairGeoCave();
26-
~FairGeoCave() {}
27-
const char* getModuleName(Int_t) { return name.Data(); }
28-
Bool_t read(std::fstream&, FairGeoMedia*);
29-
void addRefNodes();
30-
void write(std::fstream&);
31-
void print();
24+
~FairGeoCave() override = default;
25+
const char* getModuleName(Int_t) override { return name.Data(); }
26+
Bool_t read(std::fstream&, FairGeoMedia*) override;
27+
void addRefNodes() override;
28+
void write(std::fstream&) override;
29+
void print() override;
3230

33-
ClassDef(FairGeoCave, 0); // Class for the geometry of CAVE
31+
ClassDefOverride(FairGeoCave, 0); // Class for the geometry of CAVE
3432
};
3533

3634
#endif /* !FAIRGEOCAVE_H */

examples/common/passive/FairGeoMagnet.cxx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,10 @@
1717

1818
#include "FairGeoMagnet.h"
1919

20-
#include <TString.h> // for TString
21-
#include <string.h> // for strcpy
22-
2320
FairGeoMagnet::FairGeoMagnet()
2421
: FairGeoSet()
2522
{
2623
// Constructor
2724
fName = "magnet";
28-
maxSectors = 0;
2925
maxModules = 1;
30-
strcpy(modName, "m");
31-
strcpy(eleName, "m");
3226
}

examples/common/passive/FairGeoMagnet.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
@@ -15,15 +15,15 @@
1515
class FairGeoMagnet : public FairGeoSet
1616
{
1717
protected:
18-
char modName[2]; // name of module
19-
char eleName[2]; // substring for elements in module
18+
char modName[2]{"m"}; // name of module
19+
char eleName[2]{"m"}; // substring for elements in module
2020

2121
public:
2222
FairGeoMagnet();
23-
~FairGeoMagnet() {}
24-
const char* getModuleName(Int_t) { return modName; }
25-
const char* getEleName(Int_t) { return eleName; }
26-
ClassDef(FairGeoMagnet, 0); // Class for the geometry of Magnet
23+
~FairGeoMagnet() override = default;
24+
const char* getModuleName(Int_t) override { return modName; }
25+
const char* getEleName(Int_t) override { return eleName; }
26+
ClassDefOverride(FairGeoMagnet, 0); // Class for the geometry of Magnet
2727
};
2828

2929
#endif /* !FAIRGEOMAGNET_H */

examples/common/passive/FairGeoPipe.cxx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,15 @@
2222

2323
#include <TList.h> // for TList
2424
#include <TString.h> // for TString
25-
#include <string.h> // for strcpy
2625

2726
FairGeoPipe::FairGeoPipe()
2827
: FairGeoSet()
2928
{
3029
// Constructor
3130
fName = "pipe";
32-
strcpy(modName, "p");
33-
strcpy(eleName, "p");
34-
maxSectors = 0;
3531
maxModules = 1;
3632
}
33+
3734
Bool_t FairGeoPipe::create(FairGeoBuilder* build)
3835
{
3936
Bool_t rc = FairGeoSet::create(build);
@@ -45,5 +42,3 @@ Bool_t FairGeoPipe::create(FairGeoBuilder* build)
4542
}
4643
return rc;
4744
}
48-
49-
FairGeoPipe::~FairGeoPipe() {}

0 commit comments

Comments
 (0)