From 64f145a05135aefaac3e9e467be80869ffa276fe Mon Sep 17 00:00:00 2001 From: Cary Phillips Date: Thu, 24 Oct 2019 17:05:27 -0700 Subject: [PATCH] More SonarCloud-inspired fixes: - copy constructors and assignment operators declared = delete - use of ## is macro definition Signed-off-by: Cary Phillips --- OpenEXR/IlmImf/ImfStandardAttributes.cpp | 12 ++++++------ OpenEXR/IlmImf/ImfStandardAttributes.h | 12 ++++++++---- OpenEXR/IlmImf/ImfTiledOutputFile.cpp | 6 ++++++ OpenEXR/IlmImfUtil/ImfDeepImageChannel.h | 3 +++ OpenEXR/IlmImfUtil/ImfFlatImageChannel.h | 3 +++ 5 files changed, 26 insertions(+), 10 deletions(-) diff --git a/OpenEXR/IlmImf/ImfStandardAttributes.cpp b/OpenEXR/IlmImf/ImfStandardAttributes.cpp index df952c2574..98d719fa40 100644 --- a/OpenEXR/IlmImf/ImfStandardAttributes.cpp +++ b/OpenEXR/IlmImf/ImfStandardAttributes.cpp @@ -47,27 +47,27 @@ #define IMF_STD_ATTRIBUTE_IMP(name,suffix,type) \ \ void \ - add##suffix (Header &header, const type &value) \ + IMF_ADD_SUFFIX(suffix) (Header &header, const type &value) \ { \ header.insert (IMF_STRING (name), TypedAttribute (value)); \ } \ \ bool \ - has##suffix (const Header &header) \ + IMF_HAS_SUFFIX(suffix) (const Header &header) \ { \ return header.findTypedAttribute > \ (IMF_STRING (name)) != 0; \ } \ \ const TypedAttribute & \ - name##Attribute (const Header &header) \ + IMF_NAME_ATTRIBUTE(name) (const Header &header) \ { \ return header.typedAttribute > \ (IMF_STRING (name)); \ } \ \ TypedAttribute & \ - name##Attribute (Header &header) \ + IMF_NAME_ATTRIBUTE(name) (Header &header) \ { \ return header.typedAttribute > \ (IMF_STRING (name)); \ @@ -76,13 +76,13 @@ const type & \ name (const Header &header) \ { \ - return name##Attribute(header).value(); \ + return IMF_NAME_ATTRIBUTE(name) (header).value(); \ } \ \ type & \ name (Header &header) \ { \ - return name##Attribute(header).value(); \ + return IMF_NAME_ATTRIBUTE(name) (header).value(); \ } #include "ImfNamespace.h" diff --git a/OpenEXR/IlmImf/ImfStandardAttributes.h b/OpenEXR/IlmImf/ImfStandardAttributes.h index 4280ac4c1c..78fac68b09 100644 --- a/OpenEXR/IlmImf/ImfStandardAttributes.h +++ b/OpenEXR/IlmImf/ImfStandardAttributes.h @@ -70,15 +70,19 @@ #include "ImfNamespace.h" #include "ImfExport.h" +#define IMF_ADD_SUFFIX(suffix) add##suffix +#define IMF_HAS_SUFFIX(suffix) has##suffix +#define IMF_NAME_ATTRIBUTE(name) name##Attribute + #define IMF_STD_ATTRIBUTE_DEF(name,suffix,object) \ \ OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER \ - IMF_EXPORT void add##suffix (Header &header, const object &v); \ - IMF_EXPORT bool has##suffix (const Header &header); \ + IMF_EXPORT void IMF_ADD_SUFFIX(suffix) (Header &header, const object &v); \ + IMF_EXPORT bool IMF_HAS_SUFFIX(suffix) (const Header &header); \ IMF_EXPORT const TypedAttribute & \ - name##Attribute (const Header &header); \ + IMF_NAME_ATTRIBUTE(name) (const Header &header); \ IMF_EXPORT TypedAttribute & \ - name##Attribute (Header &header); \ + IMF_NAME_ATTRIBUTE(name) (Header &header); \ IMF_EXPORT const object & \ name (const Header &header); \ IMF_EXPORT object & name (Header &header); \ diff --git a/OpenEXR/IlmImf/ImfTiledOutputFile.cpp b/OpenEXR/IlmImf/ImfTiledOutputFile.cpp index c40cb90f3f..5a65c037d9 100644 --- a/OpenEXR/IlmImf/ImfTiledOutputFile.cpp +++ b/OpenEXR/IlmImf/ImfTiledOutputFile.cpp @@ -187,6 +187,9 @@ struct BufferedTile { delete [] pixelData; } + + BufferedTile (const BufferedTile& other) = delete; + const BufferedTile& operator = (const BufferedTile& other) = delete; }; @@ -278,6 +281,9 @@ struct TiledOutputFile::Data 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 // buffer coords into our diff --git a/OpenEXR/IlmImfUtil/ImfDeepImageChannel.h b/OpenEXR/IlmImfUtil/ImfDeepImageChannel.h index 9d2b008ca3..0dc60cf964 100644 --- a/OpenEXR/IlmImfUtil/ImfDeepImageChannel.h +++ b/OpenEXR/IlmImfUtil/ImfDeepImageChannel.h @@ -193,6 +193,9 @@ class TypedDeepImageChannel: public DeepImageChannel TypedDeepImageChannel (DeepImageLevel &level, bool pLinear); virtual ~TypedDeepImageChannel (); + TypedDeepImageChannel (const TypedDeepImageChannel& other) = delete; + const TypedDeepImageChannel& operator = (const TypedDeepImageChannel& other) = delete; + virtual void setSamplesToZero (size_t i, unsigned int oldNumSamples, diff --git a/OpenEXR/IlmImfUtil/ImfFlatImageChannel.h b/OpenEXR/IlmImfUtil/ImfFlatImageChannel.h index 67e8576218..8cafd6f081 100644 --- a/OpenEXR/IlmImfUtil/ImfFlatImageChannel.h +++ b/OpenEXR/IlmImfUtil/ImfFlatImageChannel.h @@ -177,6 +177,9 @@ class TypedFlatImageChannel: public FlatImageChannel virtual ~TypedFlatImageChannel (); + TypedFlatImageChannel (const TypedFlatImageChannel& other) = delete; + const TypedFlatImageChannel& operator = (const TypedFlatImageChannel& other) = delete; + virtual void resize (); virtual void resetBasePointer ();