From b86602969932747d0a20c6c6d3000132fee0361c Mon Sep 17 00:00:00 2001 From: Stephan Hilb <stephan.hilb@mathematik.uni-stuttgart.de> Date: Thu, 28 Mar 2019 11:20:44 +0100 Subject: [PATCH] fix warnings --- color_flow.cpp | 2 +- imageLib/Image.cpp | 8 ++++++-- imageLib/Image.h | 2 ++ imageLib/ImageIO.cpp | 8 ++++---- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/color_flow.cpp b/color_flow.cpp index 67c7524..9bae6fb 100644 --- a/color_flow.cpp +++ b/color_flow.cpp @@ -90,7 +90,7 @@ int main(int argc, char *argv[]) throw CError(usage, argv[0]); } catch (CError &err) { - fprintf(stderr, err.message); + fprintf(stderr, "%s", err.message); fprintf(stderr, "\n"); return -1; } diff --git a/imageLib/Image.cpp b/imageLib/Image.cpp index ec868a4..2b6c4ba 100644 --- a/imageLib/Image.cpp +++ b/imageLib/Image.cpp @@ -83,10 +83,14 @@ void CImage::ReAllocate(CShape s, const type_info& ti, int bandSize, void CImage::ReAllocate(CShape s, const type_info& ti, int bandSize, void *memory, bool deleteWhenDone, int rowSize) +{ ReAllocate(s, &ti, bandSize, memory, deleteWhenDone, rowSize); } + +void CImage::ReAllocate(CShape s, const type_info* ti, int bandSize, + void *memory, bool deleteWhenDone, int rowSize) { // Set up the type_id, shape, and size info m_shape = s; // image shape (dimensions) - m_pTI = &ti; // pointer to type_info class + m_pTI = ti; // pointer to type_info class m_bandSize = bandSize; // size of each band in bytes m_pixSize = m_bandSize * s.nBands; // stride between pixels in bytes @@ -107,7 +111,7 @@ void CImage::ReAllocate(CShape s, const type_info& ti, int bandSize, void CImage::DeAllocate() { // Release the memory & set to default values - ReAllocate(CShape(), *(const type_info *) 0, 0, 0, false, 0); + ReAllocate(CShape(), (const type_info *) 0, 0, 0, false, 0); SetDefaults(); } diff --git a/imageLib/Image.h b/imageLib/Image.h index 89746c9..6ed2db0 100644 --- a/imageLib/Image.h +++ b/imageLib/Image.h @@ -119,6 +119,8 @@ public: CImage(CShape s, const type_info& ti, int bandSize); // uses system-supplied copy constructor, assignment operator, and destructor + void ReAllocate(CShape s, const type_info* ti, int bandSize, + void *memory, bool deleteWhenDone, int rowSize); void ReAllocate(CShape s, const type_info& ti, int bandSize, void *memory, bool deleteWhenDone, int rowSize); void ReAllocate(CShape s, const type_info& ti, int bandSize, diff --git a/imageLib/ImageIO.cpp b/imageLib/ImageIO.cpp index 51aec0d..10299fe 100644 --- a/imageLib/ImageIO.cpp +++ b/imageLib/ImageIO.cpp @@ -74,11 +74,11 @@ const int TargaRawColormap = 1; const int TargaRawRGB = 2; const int TargaRawBW = 3; const int TargaRunColormap = 9; -const int TargaRunRGB = 10; +[[maybe_unused]] const int TargaRunRGB = 10; const int TargaRunBW = 11; // Descriptor fields -const int TargaAttrBits = 15; +[[maybe_unused]] const int TargaAttrBits = 15; const int TargaScreenOrigin = (1<<5); const int TargaCMapSize = 256; const int TargaCMapBands = 3; @@ -151,7 +151,7 @@ void ReadFileTGA(CByteImage& img, const char* filename) { char* tmp = new char[h.idLength]; int nread = (int)fread(tmp, sizeof(uchar), h.idLength, stream); - delete tmp; // throw away this data + delete[] tmp; // throw away this data if (nread != h.idLength) throw CError("ReadFileTGA(%s): file is too short", filename); } @@ -358,7 +358,7 @@ void ReadFilePGM(CByteImage& img, const char* filename) if (stream == 0) throw CError("ReadFilePGM: could not open %s", filename); - int width, height, nBands; + int width = 0, height = 0, nBands = 0; const char *dot = strrchr(filename, '.'); int isGray = 0, isFloat = 0; -- GitLab