Commit 58e7adde authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Fixed issues reported in compiler warnings

- base class with non-virtual destructor causes undefined behaviour
- missing return statements at the end of non-void functions
- missing const before char* function argument
- reordered initialization of class members
- misleading indentation after for statement
- fixed use of uninitialized variables
- fixed unsequenced modification and access to variables (the C++
  standard does not define the evaluation order of operands, so
  expressions with side-effects such as j++ cause undefined behaviour)
parent 06c2b3e5
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -42,6 +42,8 @@ struct ConfigEntryBase
   virtual bool hasEnumValues() const { return false; };

   virtual void printEnumValues() const {};

   virtual ~ConfigEntryBase() {};
};

} // namespace Config
+8 −2
Original line number Diff line number Diff line
@@ -230,7 +230,10 @@ bool ArrayOperations< Devices::Host, Devices::Cuda >::copyMemory( DestinationEle
         }
         Index j( 0 );
         while( j < Devices::Cuda::getGPUTransferBufferSize() && i + j < size )
            destination[ i + j ] = buffer[ j++ ];
         {
            destination[ i + j ] = buffer[ j ];
            j++;
         }
         i += j;
      }
      delete[] buffer;
@@ -332,7 +335,10 @@ bool ArrayOperations< Devices::Cuda, Devices::Host >::copyMemory( DestinationEle
      {
         Index j( 0 );
         while( j < Devices::Cuda::getGPUTransferBufferSize() && i + j < size )
            buffer[ j ] = source[ i + j++ ];
         {
            buffer[ j ] = source[ i + j ];
            j++;
         }
         if( cudaMemcpy( &destination[ i ],
                         buffer,
                         j * sizeof( DestinationElement ),
+2 −0
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ readHeader()
   this->components = this->decinfo.num_components;
   //this->color_space = this->cinfo.jpeg_color_space;
   //cout << this->height << " x " << this->width << " : " << this->components << " " << this->color_space << std::endl;
   return true;
#else
   std::cerr << "TNL was not compiled with support of JPEG. You may still use PGM format." << std::endl;
   return false;
@@ -192,6 +193,7 @@ writeHeader( const Meshes::Grid< 2, Real, Device, Index >& grid )
   this->cinfo.in_color_space = JCS_GRAYSCALE;
   jpeg_set_defaults( &this->cinfo );
   jpeg_start_compress( &this->cinfo, true );
   return true;
#else
   //cerr << "TNL was not compiled with support of JPEG. You may still use PGM format." << std::endl;
   return false;
+1 −1
Original line number Diff line number Diff line
@@ -265,7 +265,7 @@ writeHeader( const Meshes::Grid< 2, Real, Device, Index >& grid )
                 PNG_FILTER_TYPE_DEFAULT );
   png_init_io( this->png_ptr, this->file );
   png_write_info( png_ptr, info_ptr );
 
   return true;
#else
   std::cerr << "TNL was not compiled with support of PNG. You may still use PGM format." << std::endl;
   return false;
+1 −1
Original line number Diff line number Diff line
@@ -222,7 +222,7 @@ bool CSR< Real, Device, Index >::addElement( const IndexType row,

    IndexType elementPtr = this->rowPointers.getElement( row );
    const IndexType rowEnd = this->rowPointers.getElement( row + 1 );
    IndexType col;
    IndexType col = 0;
    while( elementPtr < rowEnd &&
           ( col = this->columnIndexes.getElement( elementPtr ) ) < column &&
           col != this->getPaddingIndex() ) elementPtr++;
Loading