Skip to content

Commit

Permalink
Fix some compiler warnings (#10)
Browse files Browse the repository at this point in the history
* Fix some compiler warnings

* Fix warnings about implicit copy constructor

* Fix more warnings and allow debug builds

* Create links as it was being done before

---------

Co-authored-by: jmcarcell <jmcarcell@users.noreply.github.com>
  • Loading branch information
jmcarcell and jmcarcell committed Jul 1, 2024
1 parent 0a31904 commit a1246f6
Show file tree
Hide file tree
Showing 20 changed files with 57 additions and 30 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ INSTALL_DIRECTORY( ./include DESTINATION . FILES_MATCHING PATTERN "*.h" )

# ------- symlinks in include directory for backwards compatibility ---------
# FIXME: this symlinks are needed to build Mokka. Should fix this code in Mokka
INSTALL( CODE "EXEC_PROGRAM( \"${CMAKE_COMMAND}\" \"${CMAKE_INSTALL_PREFIX}/include\" ARGS -E create_symlink gear/gearimpl gearimpl )" )
INSTALL( CODE "EXEC_PROGRAM( \"${CMAKE_COMMAND}\" \"${CMAKE_INSTALL_PREFIX}/include\" ARGS -E create_symlink gear/gearxml gearxml )" )
INSTALL( CODE "EXEC_PROGRAM( \"${CMAKE_COMMAND}\" \"${CMAKE_INSTALL_PREFIX}/include\" ARGS -E create_symlink gear/gearsurf gearsurf )" )
INSTALL( CODE "EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink gear/gearimpl gearimpl WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/include )" )
INSTALL( CODE "EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink gear/gearxml gearxml WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/include )" )
INSTALL( CODE "EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink gear/gearsurf gearsurf WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/include )" )

IF( GEAR_TGEO )
INSTALL( CODE "EXEC_PROGRAM( \"${CMAKE_COMMAND}\" \"${CMAKE_INSTALL_PREFIX}/include\" ARGS -E create_symlink gear/geartgeo geartgeo )" )
INSTALL( CODE "EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink gear/geartgeo geartgeo WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/include)" )
ENDIF()


Expand Down
1 change: 1 addition & 0 deletions include/gear/GEAR.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ namespace gear {

public:
virtual ~Exception() { /*no_op*/; }
Exception( const Exception& e ) = default ;

Exception( const std::string& text ){
message = "gear::Exception: " + text ;
Expand Down
19 changes: 19 additions & 0 deletions include/gear/TrackerPlanesLayerLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ class TrackerPlanesMaterialLayer {


public:
/// Constructor
TrackerPlanesMaterialLayer() = default;

/// Destructor.
virtual ~TrackerPlanesMaterialLayer() { /* nop */; }

/// Copy-constructor.
TrackerPlanesMaterialLayer( const TrackerPlanesMaterialLayer& ) = default;

virtual int getID() const = 0;

/** */
Expand Down Expand Up @@ -136,9 +142,15 @@ class TrackerPlanesSensitiveLayer {


public:
/// Constructor
TrackerPlanesSensitiveLayer() = default;

/// Destructor.
virtual ~TrackerPlanesSensitiveLayer() { /* nop */; }

/// Copy-constructor.
TrackerPlanesSensitiveLayer( const TrackerPlanesSensitiveLayer& ) = default;


/** ID of sensitive volume of layer layerIndex - layer indexing starts at 0
* for the layer closest to the beam source.*/
Expand Down Expand Up @@ -282,9 +294,16 @@ class TrackerPlanesSensitiveLayer {
class TrackerPlanesLayer {

public:

/// Constructor
TrackerPlanesLayer() = default;

/// Destructor.
virtual ~TrackerPlanesLayer() { /* nop */; }

// Copy-constructor.
TrackerPlanesLayer( const TrackerPlanesLayer& ) = default;

/** Layer ID of nonsensitive volume of layer layerIndex - layer indexing starts at 0
* for the layer closest to the beam source.*/
virtual int getID() const = 0;
Expand Down
1 change: 0 additions & 1 deletion include/gear/gearimpl/FTDLayerLayoutImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class vframe // TO BE DEPRECATED...
vframe(): x(0),y(0),z(0) { ; }
vframe(const double & xval, const double & yval, const double & zval):
x(xval),y(yval),z(zval) { ; }
~vframe() { ; }

double x{};
double y{};
Expand Down
7 changes: 6 additions & 1 deletion include/gear/gearimpl/GearParametersImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ namespace gear {
typedef std::map< std::string, StringVec > StringVecMap ;


GearParametersImpl() = default ;
GearParametersImpl(const GearParametersImpl&) = default ;
GearParametersImpl& operator = (const GearParametersImpl&) = default ;

/// Destructor.
virtual ~GearParametersImpl() ;
virtual ~GearParametersImpl() = default ;


/** Integer value for key.
* @throws UnknownParameterException
Expand Down
4 changes: 3 additions & 1 deletion include/gear/gearimpl/GlobalPadIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ class GlobalPadIndex {
public:

GlobalPadIndex(int padIndex, int moduleID);
virtual ~GlobalPadIndex();
virtual ~GlobalPadIndex() = default;
GlobalPadIndex(const GlobalPadIndex&) = default;
GlobalPadIndex& operator=(const GlobalPadIndex&) = default;

bool operator < (const GlobalPadIndex & cmp) const
{
Expand Down
8 changes: 8 additions & 0 deletions include/gear/gearimpl/TrackerPlanesLayerLayoutImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class TrackerPlanesMaterialLayerImpl: public TrackerPlanesMaterialLayer {
/// Destructor.
/** */
virtual ~TrackerPlanesMaterialLayerImpl() { /* nop */; }
/// Copy constructor.
TrackerPlanesMaterialLayerImpl(const TrackerPlanesMaterialLayerImpl&) = default;
/** */
virtual int getID() const { return ID ; }
/** */
Expand Down Expand Up @@ -159,6 +161,9 @@ class TrackerPlanesSensitiveLayerImpl: public TrackerPlanesSensitiveLayer {
/// Destructor.
virtual ~TrackerPlanesSensitiveLayerImpl() { /* nop */; }

/// Copy constructor.
TrackerPlanesSensitiveLayerImpl(const TrackerPlanesSensitiveLayerImpl&) = default;

/** */
virtual int getID() const { return ID ; }
/** */
Expand Down Expand Up @@ -284,6 +289,9 @@ class TrackerPlanesLayerImpl: public TrackerPlanesLayer {
/** Destructor.
*/
virtual ~TrackerPlanesLayerImpl() { /* nop */; }
/** Copy constructor.
*/
TrackerPlanesLayerImpl(const TrackerPlanesLayerImpl&) = default;

/** get methods
*/
Expand Down
2 changes: 0 additions & 2 deletions include/gear/gearxml/GearParametersXML.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

#include "gearimpl/GearParametersImpl.h"

#include <string>


namespace gear {

Expand Down
2 changes: 1 addition & 1 deletion src/gearimpl/FTDLayerLayoutImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ double FTDLayerLayoutImpl::getThicknessForAngle(const int & layerIndex,const dou
// -si entra por el petalo
// -cual es la distancia que recorre antes de salir
// -para ello hay que controlar si sale antes de que
// acabe el petalo, en Y es fácil pero en x, al ser
// acabe el petalo, en Y es facil pero en x, al ser
// un petalo, la distancia es variable y dependera
// de la zona Y de salida del rayo
// -controlar y prohibir angulos que no esten en
Expand Down
4 changes: 2 additions & 2 deletions src/gearimpl/FixedPadSizeDiskLayout.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ namespace gear {
return _padWidth / _rows.at( rowNum ).RCenter ;

}
catch(std::out_of_range){
catch(std::out_of_range const&){
return 0. ;
}
}
Expand All @@ -188,7 +188,7 @@ namespace gear {
return _rows.at( rowNum ).PhiPad;

}
catch(std::out_of_range){
catch(std::out_of_range const&){
return 0. ;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/gearimpl/GearMgrImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ namespace gear{

lcalParameters->getDoubleVal("beam_crossing_angle") ;

}catch( UnknownParameterException ){
}catch( UnknownParameterException const& ){

std::cout << "WARNING GearMgrImpl::setLcalParameters: added "
" missing parameter beam_crossing_angle 0.0 ! " << std::endl ;
Expand All @@ -488,7 +488,7 @@ namespace gear{

lhcalParameters->getDoubleVal("beam_crossing_angle") ;

}catch( UnknownParameterException ){
}catch( UnknownParameterException const& ){

std::cout << "WARNING GearMgrImpl::setLHcalParameters: added "
" missing parameter beam_crossing_angle 0.0 ! " << std::endl ;
Expand All @@ -509,7 +509,7 @@ namespace gear{

beamcalParameters->getDoubleVal("beam_crossing_angle") ;

}catch( UnknownParameterException ){
}catch( UnknownParameterException const& ){

std::cout << "WARNING GearMgrImpl::setBeamCalParameters: added "
" missing parameter beam_crossing_angle 0.0 ! " << std::endl ;
Expand Down
4 changes: 0 additions & 4 deletions src/gearimpl/GearParametersImpl.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#include "gearimpl/GearParametersImpl.h"

#include <algorithm>

namespace gear{

GearParametersImpl::~GearParametersImpl() { /* nop */; }

int GearParametersImpl::getIntVal(const std::string & key) const {

IntMap::const_iterator it = _intMap.find( key ) ;
Expand Down
2 changes: 0 additions & 2 deletions src/gearimpl/GlobalPadIndex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ namespace gear {
_padIndex( padIndex) ,
_moduleID (moduleID) {
}
GlobalPadIndex::~GlobalPadIndex(){
}
int GlobalPadIndex::getPadIndex() const {
return _padIndex;
}
Expand Down
2 changes: 1 addition & 1 deletion src/gearimpl/TPCParametersImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace gear {

// call the assignment operator of the GearParametersImpl mother class:
// *dynamic_cast<GearParametersImpl*>(this) = *dynamic_cast<GearParametersImpl const *>(&right);
GearParametersImpl::operator = (right);
this->operator = (right);
}

/// Destructor.
Expand Down
5 changes: 1 addition & 4 deletions src/gearxml/GearParametersXML.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ namespace gear {

}

~Tokenizer(){
}

std::vector<std::string> & result() {

return _tokens ;
Expand Down Expand Up @@ -233,7 +230,7 @@ namespace gear {

value = getXMLAttribute( par , "value" ) ;
}
catch( ParseException ) {
catch( ParseException const& ) {

if( par->FirstChild() )
value = par->FirstChild()->Value() ;
Expand Down
2 changes: 1 addition & 1 deletion src/gearxml/GearXML.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace gear{

try{ detName = mgr->getDetectorName() ;
}
catch( UnknownParameterException ){}
catch( UnknownParameterException const& ){}

global.SetAttribute( "detectorName" , detName ) ;

Expand Down
3 changes: 0 additions & 3 deletions src/gearxml/RectangularPadRowLayoutXML.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ namespace gear {
RectangularPadRowLayout* padRowLayout = new RectangularPadRowLayout( xMin, xMax, yMin ) ;

// ----- rows ------------
int rowId = 0 ;

const TiXmlNode* row = 0 ;
while( ( row = xmlElement->IterateChildren( "row", row ) ) != 0 ){

Expand All @@ -103,7 +101,6 @@ namespace gear {

padRowLayout->addRow( nRow, nPad, padWidth, padHeight, rowHeight, leftOffset, rightOffset ) ;

rowId+= nRow ;
}

padRowLayout->repeatRows( repeatRowCount ) ;
Expand Down
3 changes: 3 additions & 0 deletions src/gearxml/tinyxmlparser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,17 @@ void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* leng
--output;
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
input >>= 6;
[[fallthrough]];
case 3:
--output;
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
input >>= 6;
[[fallthrough]];
case 2:
--output;
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
input >>= 6;
[[fallthrough]];
case 1:
--output;
*output = (char)(input | FIRST_BYTE_MARK[*length]);
Expand Down
2 changes: 2 additions & 0 deletions src/test/testgear.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,13 @@ void testFixedPadSizeDiskLayout( const FixedPadSizeDiskLayout& pl ) {
// which have no neighbour.
if( j == 0 ) {
int ln = pl.getRightNeighbour( pl.getPadIndex( iRow , iPad ) ) ;
(void) ln ;
assert( pl.getPadNumber( ln ) == nPad-1 ) ;
}

if( j == nPad-1 ) {
int rn = pl.getLeftNeighbour( pl.getPadIndex( iRow , iPad ) ) ;
(void) rn ;
assert( pl.getPadNumber( rn ) == 0 ) ;
}

Expand Down
2 changes: 2 additions & 0 deletions src/test/testtpcproto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,15 @@ void testRectangularPadRowLayout( const RectangularPadRowLayout& pl ) {
if( j != 0 ) {

int ln = pl.getLeftNeighbour( pl.getPadIndex( iRow , iPad ) ) ;
(void) ln ;

assert( pl.getPadNumber( ln ) == iPad - 1 ) ;
}

if( j != nPad-1 ) {

int rn = pl.getRightNeighbour( pl.getPadIndex( iRow , iPad ) ) ;
(void) rn ;

assert( pl.getPadNumber( rn ) == iPad + 1 ) ;
}
Expand Down

0 comments on commit a1246f6

Please sign in to comment.