Skip to content

Commit

Permalink
SonarCloud-inspired fixes
Browse files Browse the repository at this point in the history
- Added =delete copy constructors and assignment operators
- Added =default destructors
- check for &other==this in assignment operator

Signed-off-by: Cary Phillips <cary@ilm.com>
  • Loading branch information
cary-ilm committed Nov 14, 2019
1 parent 8e7ba0f commit 5c985fc
Show file tree
Hide file tree
Showing 38 changed files with 124 additions and 56 deletions.
2 changes: 1 addition & 1 deletion IlmBase/Iex/IexBaseExc.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class BaseExc: public std::exception
IEX_EXPORT BaseExc (const BaseExc &be) throw();
IEX_EXPORT virtual ~BaseExc () throw ();

IEX_EXPORT BaseExc & operator = (const BaseExc& be) throw () = delete;
IEX_EXPORT const BaseExc & operator = (const BaseExc& be) throw () = delete;

//---------------------------------------------------
// what() method -- e.what() returns _message.c_str()
Expand Down
3 changes: 3 additions & 0 deletions IlmBase/IlmThread/IlmThreadPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ class ILMTHREAD_EXPORT TaskGroup
TaskGroup();
~TaskGroup();

TaskGroup (const TaskGroup& other) = delete;
const TaskGroup& operator = (const TaskGroup& other) = delete;

// marks one task as finished
// should be used by the thread pool provider to notify
// as it finishes tasks
Expand Down
8 changes: 4 additions & 4 deletions OpenEXR/IlmImf/ImfAcesFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ class AcesOutputFile

private:

AcesOutputFile (const AcesOutputFile &); // not implemented
AcesOutputFile & operator = (const AcesOutputFile &); // not implemented
AcesOutputFile (const AcesOutputFile &) = delete;
const AcesOutputFile & operator = (const AcesOutputFile &) = delete;

class Data;

Expand Down Expand Up @@ -343,8 +343,8 @@ class AcesInputFile

private:

AcesInputFile (const AcesInputFile &); // not implemented
AcesInputFile & operator = (const AcesInputFile &); // not implemented
AcesInputFile (const AcesInputFile &) = delete;
const AcesInputFile & operator = (const AcesInputFile &) = delete;

class Data;

Expand Down
8 changes: 4 additions & 4 deletions OpenEXR/IlmImf/ImfArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ class Array

private:

Array (const Array &); // Copying and assignment
Array & operator = (const Array &); // are not implemented
Array (const Array &) = delete;
const Array & operator = (const Array &) = delete;

long _size;
T * _data;
Expand Down Expand Up @@ -176,8 +176,8 @@ class Array2D

private:

Array2D (const Array2D &); // Copying and assignment
Array2D & operator = (const Array2D &); // are not implemented
Array2D (const Array2D &) = delete;
const Array2D & operator = (const Array2D &) = delete;

long _sizeX;
long _sizeY;
Expand Down
4 changes: 2 additions & 2 deletions OpenEXR/IlmImf/ImfCompositeDeepScanLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ class CompositeDeepScanLine
private :
struct Data *_Data;

CompositeDeepScanLine(const CompositeDeepScanLine &); // not implemented
const CompositeDeepScanLine & operator=(const CompositeDeepScanLine &); // not implemented
CompositeDeepScanLine(const CompositeDeepScanLine &) = delete;
const CompositeDeepScanLine & operator=(const CompositeDeepScanLine &) = delete;
};

OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Expand Down
4 changes: 2 additions & 2 deletions OpenEXR/IlmImf/ImfDeepScanLineOutputFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ class DeepScanLineOutputFile : public GenericOutputFile
//------------------------------------------------------------
DeepScanLineOutputFile (const OutputPartData* part);

DeepScanLineOutputFile (const DeepScanLineOutputFile &); // not implemented
DeepScanLineOutputFile & operator = (const DeepScanLineOutputFile &); // not implemented
DeepScanLineOutputFile (const DeepScanLineOutputFile &) = delete;
const DeepScanLineOutputFile & operator = (const DeepScanLineOutputFile &) = delete;

void initialize (const Header &header);
void initializeLineBuffer();
Expand Down
4 changes: 2 additions & 2 deletions OpenEXR/IlmImf/ImfDeepTiledInputFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,8 @@ class DeepTiledInputFile : public GenericInputFile

DeepTiledInputFile (InputPartData* part);

DeepTiledInputFile (const DeepTiledInputFile &); // not implemented
DeepTiledInputFile & operator = (const DeepTiledInputFile &); // not implemented
DeepTiledInputFile (const DeepTiledInputFile &) = delete;
const DeepTiledInputFile & operator = (const DeepTiledInputFile &) = delete;

DeepTiledInputFile (const Header &header, OPENEXR_IMF_INTERNAL_NAMESPACE::IStream *is, int version,
int numThreads);
Expand Down
3 changes: 3 additions & 0 deletions OpenEXR/IlmImf/ImfDeepTiledOutputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ struct BufferedTile
delete [] pixelData;
delete [] sampleCountTableData;
}

BufferedTile (const BufferedTile& other) = delete;
const BufferedTile& operator = (const BufferedTile& other) = delete;
};


Expand Down
4 changes: 2 additions & 2 deletions OpenEXR/IlmImf/ImfDeepTiledOutputFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,8 @@ class DeepTiledOutputFile : public GenericOutputFile
// ----------------------------------------------------------------
DeepTiledOutputFile (const OutputPartData* part);

DeepTiledOutputFile (const DeepTiledOutputFile &); // not implemented
DeepTiledOutputFile & operator = (const DeepTiledOutputFile &); // not implemented
DeepTiledOutputFile (const DeepTiledOutputFile &) = delete;
const DeepTiledOutputFile & operator = (const DeepTiledOutputFile &) = delete;

void initialize (const Header &header);

Expand Down
1 change: 1 addition & 0 deletions OpenEXR/IlmImf/ImfDwaCompressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class DwaCompressor: public Compressor
IMF_EXPORT
virtual ~DwaCompressor ();

DwaCompressor (const DwaCompressor& other) = delete;
const DwaCompressor& operator = (const DwaCompressor& other) = delete;

IMF_EXPORT
Expand Down
8 changes: 4 additions & 4 deletions OpenEXR/IlmImf/ImfIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ class IStream

private:

IStream (const IStream &); // not implemented
IStream & operator = (const IStream &); // not implemented
IStream (const IStream &) = delete;
const IStream & operator = (const IStream &) = delete;

std::string _fileName;
};
Expand Down Expand Up @@ -213,8 +213,8 @@ class OStream

private:

OStream (const OStream &); // not implemented
OStream & operator = (const OStream &); // not implemented
OStream (const OStream &) = delete;
const OStream & operator = (const OStream &) = delete;

std::string _fileName;
};
Expand Down
4 changes: 2 additions & 2 deletions OpenEXR/IlmImf/ImfInputFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ class InputFile : public GenericInputFile
private:

InputFile (InputPartData* part);
InputFile (const InputFile &); // not implemented
InputFile & operator = (const InputFile &); // not implemented
InputFile (const InputFile &) = delete;
const InputFile & operator = (const InputFile &) = delete;

void initialize ();
void multiPartInitialize(InputPartData* part);
Expand Down
3 changes: 3 additions & 0 deletions OpenEXR/IlmImf/ImfMultiPartInputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ struct MultiPartInputFile::Data: public InputStreamMutex
delete parts[i];
}

Data (const Data& other) = delete;
const Data& operator = (const Data& other) = delete;

template <class T>
T* createInputPartT(int partNumber)
{
Expand Down
3 changes: 2 additions & 1 deletion OpenEXR/IlmImf/ImfMultiPartInputFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ class MultiPartInputFile : public GenericInputFile
private:
Data* _data;

MultiPartInputFile(const MultiPartInputFile &); // not implemented
MultiPartInputFile(const MultiPartInputFile &) = delete;
const MultiPartInputFile& operator = (const MultiPartInputFile &) = delete;


//
Expand Down
4 changes: 4 additions & 0 deletions OpenEXR/IlmImf/ImfMultiPartOutputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ struct MultiPartOutputFile::Data: public OutputStreamMutex
for (size_t i = 0; i < parts.size(); i++)
delete parts[i];
}

Data (const Data& other) = delete;
const Data& operator = (const Data& other) = delete;

};

void
Expand Down
5 changes: 3 additions & 2 deletions OpenEXR/IlmImf/ImfMultiPartOutputFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,14 @@ class MultiPartOutputFile : public GenericOutputFile
IMF_EXPORT
~MultiPartOutputFile();

MultiPartOutputFile(const MultiPartOutputFile& other) = delete;
const MultiPartOutputFile& operator = (const MultiPartOutputFile& other) = delete;

struct Data;

private:
Data* _data;

MultiPartOutputFile(const MultiPartOutputFile &); // not implemented

template<class T> T* getOutputPart(int partNumber);


Expand Down
4 changes: 3 additions & 1 deletion OpenEXR/IlmImf/ImfOutputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ struct OutputFile::Data
Data (int numThreads);
~Data ();


Data (const Data& other) = delete;
const Data& operator = (const Data& other) = delete;

inline LineBuffer * getLineBuffer (int number); // hash function from line
// buffer indices into our
// vector of line buffers
Expand Down
4 changes: 2 additions & 2 deletions OpenEXR/IlmImf/ImfOutputFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ class OutputFile : public GenericOutputFile
//------------------------------------------------------------
OutputFile (const OutputPartData* part);

OutputFile (const OutputFile &); // not implemented
OutputFile & operator = (const OutputFile &); // not implemented
OutputFile (const OutputFile &) = delete;
const OutputFile & operator = (const OutputFile &) = delete;

void initialize (const Header &header);

Expand Down
3 changes: 3 additions & 0 deletions OpenEXR/IlmImf/ImfPizCompressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class PizCompressor: public Compressor
IMF_EXPORT
virtual ~PizCompressor ();

PizCompressor (const PizCompressor& other) = delete;
const PizCompressor& operator = (const PizCompressor& other) = delete;

IMF_EXPORT
virtual int numScanLines () const;

Expand Down
17 changes: 10 additions & 7 deletions OpenEXR/IlmImf/ImfPreviewImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,18 @@ PreviewImage::~PreviewImage ()
PreviewImage &
PreviewImage::operator = (const PreviewImage &other)
{
delete [] _pixels;

_width = other._width;
_height = other._height;
_pixels = new PreviewRgba [other._width * other._height];
if (this != &other)
{
delete [] _pixels;

for (unsigned int i = 0; i < _width * _height; ++i)
_pixels[i] = other._pixels[i];
_width = other._width;
_height = other._height;
_pixels = new PreviewRgba [other._width * other._height];

for (unsigned int i = 0; i < _width * _height; ++i)
_pixels[i] = other._pixels[i];
}

return *this;
}

Expand Down
3 changes: 3 additions & 0 deletions OpenEXR/IlmImf/ImfPxr24Compressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class Pxr24Compressor: public Compressor
IMF_EXPORT
virtual ~Pxr24Compressor ();

Pxr24Compressor (const Pxr24Compressor& other) = delete;
const Pxr24Compressor& operator = (const Pxr24Compressor& other) = delete;

IMF_EXPORT
virtual int numScanLines () const;

Expand Down
6 changes: 6 additions & 0 deletions OpenEXR/IlmImf/ImfRgbaFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ class RgbaOutputFile::ToYca: public Mutex
ToYca (OutputFile &outputFile, RgbaChannels rgbaChannels);
~ToYca ();

ToYca (const ToYca& other) = delete;
const ToYca& operator = (const ToYca& other) = delete;

void setYCRounding (unsigned int roundY,
unsigned int roundC);

Expand Down Expand Up @@ -812,6 +815,9 @@ class RgbaInputFile::FromYca: public Mutex
FromYca (InputFile &inputFile, RgbaChannels rgbaChannels);
~FromYca ();

FromYca (const FromYca& other) = delete;
const FromYca& operator = (const FromYca& other) = delete;

void setFrameBuffer (Rgba *base,
size_t xStride,
size_t yStride,
Expand Down
8 changes: 4 additions & 4 deletions OpenEXR/IlmImf/ImfRgbaFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ class RgbaOutputFile
char c);
private:

RgbaOutputFile (const RgbaOutputFile &); // not implemented
RgbaOutputFile & operator = (const RgbaOutputFile &); // not implemented
RgbaOutputFile (const RgbaOutputFile &) = delete;
const RgbaOutputFile & operator = (const RgbaOutputFile &) = delete;

class ToYca;

Expand Down Expand Up @@ -428,8 +428,8 @@ class RgbaInputFile

private:

RgbaInputFile (const RgbaInputFile &); // not implemented
RgbaInputFile & operator = (const RgbaInputFile &); // not implemented
RgbaInputFile (const RgbaInputFile &) = delete;
const RgbaInputFile & operator = (const RgbaInputFile &) = delete;

class FromYca;

Expand Down
3 changes: 3 additions & 0 deletions OpenEXR/IlmImf/ImfRleCompressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class RleCompressor: public Compressor
IMF_EXPORT
virtual ~RleCompressor ();

RleCompressor (const RleCompressor& other) = delete;
const RleCompressor& operator = (const RleCompressor& other) = delete;

IMF_EXPORT
virtual int numScanLines () const;

Expand Down
3 changes: 3 additions & 0 deletions OpenEXR/IlmImf/ImfScanLineInputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ struct LineBuffer
LineBuffer (Compressor * const comp);
~LineBuffer ();

LineBuffer (const LineBuffer& other) = delete;
const LineBuffer& operator = (const LineBuffer& other) = delete;

inline void wait () {_sem.wait();}
inline void post () {_sem.post();}

Expand Down
3 changes: 3 additions & 0 deletions OpenEXR/IlmImf/ImfScanLineInputFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class ScanLineInputFile : public GenericInputFile
IMF_EXPORT
virtual ~ScanLineInputFile ();

ScanLineInputFile (const ScanLineInputFile& other) = delete;
const ScanLineInputFile& operator = (const ScanLineInputFile& other) = delete;


//------------------------
// Access to the file name
Expand Down
6 changes: 6 additions & 0 deletions OpenEXR/IlmImf/ImfTiledInputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ struct TileBuffer
TileBuffer (Compressor * const comp);
~TileBuffer ();

TileBuffer (const TileBuffer& other) = delete;
const TileBuffer& operator = (const TileBuffer& other) = delete;

inline void wait () {_sem.wait();}
inline void post () {_sem.post();}

Expand Down Expand Up @@ -243,6 +246,9 @@ struct TiledInputFile::Data: public Mutex
Data (int numThreads);
~Data ();

Data (const Data& other) = delete;
const Data& operator = (const Data& other) = delete;

inline TileBuffer * getTileBuffer (int number);
// hash function from tile indices
// into our vector of tile buffers
Expand Down
6 changes: 3 additions & 3 deletions OpenEXR/IlmImf/ImfTiledInputFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ class TiledInputFile : public GenericInputFile
IMF_EXPORT
virtual ~TiledInputFile ();

TiledInputFile (const TiledInputFile& other) = delete;
const TiledInputFile& operator = (const TiledInputFile& other) = delete;


//------------------------
// Access to the file name
Expand Down Expand Up @@ -399,9 +402,6 @@ class TiledInputFile : public GenericInputFile

TiledInputFile (InputPartData* part);

TiledInputFile (const TiledInputFile &); // not implemented
TiledInputFile & operator = (const TiledInputFile &); // not implemented

TiledInputFile (const Header &header, OPENEXR_IMF_INTERNAL_NAMESPACE::IStream *is, int version,
int numThreads);

Expand Down
4 changes: 2 additions & 2 deletions OpenEXR/IlmImf/ImfTiledOutputFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,8 @@ class TiledOutputFile : public GenericOutputFile
// ----------------------------------------------------------------
TiledOutputFile (const OutputPartData* part);

TiledOutputFile (const TiledOutputFile &); // not implemented
TiledOutputFile & operator = (const TiledOutputFile &); // not implemented
TiledOutputFile (const TiledOutputFile &) = delete;
const TiledOutputFile & operator = (const TiledOutputFile &) = delete;

void initialize (const Header &header);

Expand Down
Loading

0 comments on commit 5c985fc

Please sign in to comment.