Project

General

Profile

Actions

Development #1391

closed

Development #1353: Code cleanup for OCT19

Code cleanup: analysis/papa/PairAnalysisStyler.h

Added by Volker Friese almost 3 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
09/21/2019
Due date:
09/27/2019
% Done:

100%

Estimated time:
1.00 h
Spent time:

Description

The folloswing warnings show up for several translation units which include PairAnalysisStyler.h (only with gcc, not with clang):


/home/uhlig/cbm/release/oct19/analysis/papa/PairAnalysisHistos.cxx: In member function 'TH1* PairAnalysisHistos::GetTHist(const char*, const char*, const char*, const TVectorD*, const TVectorD*, const TVectorD*)':
[CTest: warning matched] /home/uhlig/cbm/release/oct19/analysis/papa/PairAnalysisHistos.cxx:438:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
In file included from /home/uhlig/cbm/release/oct19/analysis/papa/PairAnalysisHistos.cxx:97:0:
/home/uhlig/cbm/release/oct19/analysis/papa/PairAnalysisStyler.h: At global scope:
[CTest: warning matched] /home/uhlig/cbm/release/oct19/analysis/papa/PairAnalysisStyler.h:26:19: warning: 'PairAnalysisStyler::fCol' defined but not used [-Wunused-variable]
   static Int_t    fCol[kNidx-kRaw]={kBlack,kTeal-8,kBlack,kTeal-7,kTeal-7};
                   ^
[CTest: warning matched] /home/uhlig/cbm/release/oct19/analysis/papa/PairAnalysisStyler.h:27:19: warning: 'PairAnalysisStyler::fMrk' defined but not used [-Wunused-variable]
   static Int_t    fMrk[kNidx-kRaw]={kFullCircle,kOpenCircle,kOpenCircle,kDot,kDot};
                   ^
[CTest: warning matched] /home/uhlig/cbm/release/oct19/analysis/papa/PairAnalysisStyler.h:28:19: warning: 'PairAnalysisStyler::fSze' defined but not used [-Wunused-variable]
   static Double_t fSze[kNidx-kRaw]={1.,1.,1.,1.,1.};
                   ^
[CTest: warning matched] /home/uhlig/cbm/release/oct19/analysis/papa/PairAnalysisStyler.h:29:19: warning: 'PairAnalysisStyler::fLne' defined but not used [-Wunused-variable]
   static Int_t    fLne[kNidx-kRaw]={kSolid,kSolid,kSolid,kSolid,kSolid};
                   ^
[CTest: warning matched] /home/uhlig/cbm/release/oct19/analysis/papa/PairAnalysisStyler.h:30:19: warning: 'PairAnalysisStyler::fWdt' defined but not used [-Wunused-variable]
   static Double_t fWdt[kNidx-kRaw]={2.,2.,2.,2.,2.};
                   ^
[CTest: warning matched] /home/uhlig/cbm/release/oct19/analysis/papa/PairAnalysisStyler.h:31:19: warning: 'PairAnalysisStyler::fFll' defined but not used [-Wunused-variable]
   static Int_t    fFll[kNidx-kRaw]={0,0,0,0,0}; //kFEmpty
                   ^
[CTest: warning matched] /home/uhlig/cbm/release/oct19/analysis/papa/PairAnalysisStyler.h:35:16: warning: 'PairAnalysisStyler::Marker' defined but not used [-Wunused-variable]
   static Int_t Marker[]= {kFullCircle,
                ^
[CTest: warning matched] /home/uhlig/cbm/release/oct19/analysis/papa/PairAnalysisStyler.h:49:16: warning: 'PairAnalysisStyler::Line' defined but not used [-Wunused-variable]
   static Int_t Line[]= {kSolid,
                ^
[CTest: warning matched] /home/uhlig/cbm/release/oct19/analysis/papa/PairAnalysisStyler.h:55:16: warning: 'PairAnalysisStyler::Color' defined but not used [-Wunused-variable]
   static Int_t Color[]= {kRed-4
                ^
[CTest: warning matched] /home/uhlig/cbm/release/oct19/analysis/papa/PairAnalysisStyler.h:74:16: warning: 'PairAnalysisStyler::Fill' defined but not used [-Wunused-variable]
   static Int_t Fill[]= {-1};
                ^
[CTest: warning matched] /home/uhlig/cbm/release/oct19/analysis/papa/PairAnalysisStyler.h:76:18: warning: 'PairAnalysisStyler::fUserDielStyle' defined but not used [-Wunused-variable]
   static TStyle *fUserDielStyle = NULL;   // user defined style
                  ^
In file included from /home/uhlig/cbm/release/oct19/analysis/papa/PairAnalysisHistos.cxx:97:0:
[CTest: warning matched] /home/uhlig/cbm/release/oct19/analysis/papa/PairAnalysisStyler.h:92:17: warning: 'PairAnalysisStyler::fLegAlign' defined but not used [-Wunused-variable]
   static UInt_t fLegAlign = 22;           // legend alignement (11,12,21,22)

In my opinion, the definition of the static variables in the header file is incorrect.

1. Either these variables shall be common for all translation units. Then, they should not be declared static.

2. Or: They are supposed to be different for each translation unit. Then the qualification as static is in order, but each translation unit has to initialise those that are actually used in the implementation file.

I do not know the intention of the author, but I suppose case 1 is the case, since I see nowhere an initialisation of the static variables outside of PairAnalysisStyle.h. So, I suggest to declare them non-static. What do you think?

Actions #1

Updated by Volker Friese almost 3 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

Fixed.

Actions #2

Updated by Florian Uhlig almost 3 years ago

The problem with the variables is that they are not defined in a class but a namespace together with some functions which use the variables. I am not sure why this was implemented in such a way. All variables are only needed in one source file where the unctions of the namespace are implemented. So I moved the variables such that they are only included in that one source file. Probably this code should be refactored in future to implement the functionality in a cleaner way.

Actions

Also available in: Atom PDF