From 6b07e29bc75d6589d0af3a95ef88fcd584865d68 Mon Sep 17 00:00:00 2001 From: Austin Sanders <arsanders@usgs.gov> Date: Fri, 16 Sep 2022 10:00:17 -0600 Subject: [PATCH] Address compile warnings on ubuntu (#5050) * Addressed compiler warnings * Added missing iterator declaration * Initialize outputpoint * Updated changelog --- CHANGELOG.md | 1 + isis/src/base/apps/isisimport/CassiniImportUtils.h | 4 ++-- isis/src/mgs/apps/mocuncompress/image_io.cpp | 2 +- isis/src/mro/apps/hical/hical.cpp | 2 +- isis/tests/FunctionalTestsCkwriter.cpp | 8 ++++---- isis/tests/FunctionalTestsFootprintinit.cpp | 12 ++++++------ isis/tests/FunctionalTestsJigsaw.cpp | 6 +++--- isis/tests/FunctionalTestsSpkwriter.cpp | 8 ++------ isis/tests/PvlKeywordTests.cpp | 4 ++-- 9 files changed, 22 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f7eccafde..4ec9430b34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ release. - Fixed bugs in downloadIsisData script [#5024](https://github.com/USGS-Astrogeology/ISIS3/issues/5024) - Fixed shadow shifting image by 2 pixels to the upper left corner. [#5035](https://github.com/USGS-Astrogeology/ISIS3/issues/5035) +- Fixed compiler warnings on ubuntu [#4911](https://github.com/USGS-Astrogeology/ISIS3/issues/4911) ## [7.1.0] - 2022-07-27 diff --git a/isis/src/base/apps/isisimport/CassiniImportUtils.h b/isis/src/base/apps/isisimport/CassiniImportUtils.h index 6ef2800532..2173798035 100644 --- a/isis/src/base/apps/isisimport/CassiniImportUtils.h +++ b/isis/src/base/apps/isisimport/CassiniImportUtils.h @@ -39,7 +39,7 @@ namespace Isis { */ CassiniIssFixDnFunctor(PvlKeyword &stretchPairs, QString dataConversionType, int validMax) { m_stretch = Stretch(); - for (size_t i = 0; i < stretchPairs.size(); i+=2) { + for (size_t i = 0; i < (size_t)stretchPairs.size(); i+=2) { m_stretch.AddPair(toDouble(stretchPairs[i]), toDouble(stretchPairs[i + 1])); } @@ -192,7 +192,7 @@ namespace Isis { //Adjust Table-encoded values from 8 bit back to 12 bit. PvlKeyword stretchPairs = translation["stretchPairs"]; Stretch stretch; - for (size_t i = 0; i < stretchPairs.size(); i+=2) { + for (size_t i = 0; i < (size_t)stretchPairs.size(); i+=2) { stretch.AddPair(toDouble(stretchPairs[i]), toDouble(stretchPairs[i + 1])); } diff --git a/isis/src/mgs/apps/mocuncompress/image_io.cpp b/isis/src/mgs/apps/mocuncompress/image_io.cpp index 744459ec84..34ad7e36e5 100644 --- a/isis/src/mgs/apps/mocuncompress/image_io.cpp +++ b/isis/src/mgs/apps/mocuncompress/image_io.cpp @@ -100,7 +100,7 @@ void image_open(char *filename, struct image_header *header, char *mode) header->bpe = hdr_buf[3]; if(header->bpe == 0) header->bpe = 8; - text_ptr = (char *) malloc(strlen(((char *)hdr_buf) + IMAGE_LABEL_OFFSET)); + text_ptr = (char *) malloc(strlen(((char *)hdr_buf) + IMAGE_LABEL_OFFSET)+1); strcpy(text_ptr, (char *)(((char *)hdr_buf) + IMAGE_LABEL_OFFSET)); header->label = text_ptr; header->fd = fd; diff --git a/isis/src/mro/apps/hical/hical.cpp b/isis/src/mro/apps/hical/hical.cpp index 8a43d8e7ca..2e6444a947 100644 --- a/isis/src/mro/apps/hical/hical.cpp +++ b/isis/src/mro/apps/hical/hical.cpp @@ -207,7 +207,7 @@ namespace Isis { zdr.Dump(hiconf.getMatrixSource("DumpModuleFile",hiprof)); } } - catch(IException e){ + catch(IException &e){ if (hiprof.exists("Fallback") && IsTrueValue(hiprof, "Fallback")){ zdrFallback = true; calVars->add(hiconf.getProfileName(), HiVector(nsamps, 0.0)); diff --git a/isis/tests/FunctionalTestsCkwriter.cpp b/isis/tests/FunctionalTestsCkwriter.cpp index dea94624a3..248965dd6c 100644 --- a/isis/tests/FunctionalTestsCkwriter.cpp +++ b/isis/tests/FunctionalTestsCkwriter.cpp @@ -69,12 +69,12 @@ TEST_F(DefaultCube, FunctionalTestCkwriterDefault) { ASSERT_EQ(newKernelRotation->cacheSize(), originalRotation->cacheSize()); - for (int i = 0; i < newKernelRotation->TimeBasedMatrix().size(); i++) { + for (size_t i = 0; i < newKernelRotation->TimeBasedMatrix().size(); i++) { ASSERT_DOUBLE_EQ(newKernelRotation->TimeBasedMatrix()[i], originalRotation->TimeBasedMatrix()[i]); } - for (int i = 0; i < newKernelRotation->AngularVelocity().size(); i++) { + for (size_t i = 0; i < newKernelRotation->AngularVelocity().size(); i++) { ASSERT_DOUBLE_EQ(newKernelRotation->AngularVelocity()[i], originalRotation->AngularVelocity()[i]); } @@ -138,12 +138,12 @@ TEST_F(DefaultCube, FunctionalTestCkwriterFromlist) { ASSERT_EQ(newKernelRotation->cacheSize(), originalRotation->cacheSize()); - for (int i = 0; i < newKernelRotation->TimeBasedMatrix().size(); i++) { + for (size_t i = 0; i < newKernelRotation->TimeBasedMatrix().size(); i++) { ASSERT_DOUBLE_EQ(newKernelRotation->TimeBasedMatrix()[i], originalRotation->TimeBasedMatrix()[i]); } - for (int i = 0; i < newKernelRotation->AngularVelocity().size(); i++) { + for (size_t i = 0; i < newKernelRotation->AngularVelocity().size(); i++) { ASSERT_DOUBLE_EQ(newKernelRotation->AngularVelocity()[i], originalRotation->AngularVelocity()[i]); } diff --git a/isis/tests/FunctionalTestsFootprintinit.cpp b/isis/tests/FunctionalTestsFootprintinit.cpp index 1c23a050b7..bc218f54f1 100644 --- a/isis/tests/FunctionalTestsFootprintinit.cpp +++ b/isis/tests/FunctionalTestsFootprintinit.cpp @@ -38,7 +38,7 @@ TEST_F(DefaultCube, FunctionalTestFootprintinitDefault) { std::vector<double> lats = {9.928502, 9.928502, 10.434859, 10.434859, 9.928502}; geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(boundary->getCoordinates())); - for (int i = 0; i < coordArray.getSize(); i++) { + for (size_t i = 0; i < coordArray.getSize(); i++) { EXPECT_NEAR(lons[i], coordArray.getAt(i).x, 1e-6); EXPECT_NEAR(lats[i], coordArray.getAt(i).y, 1e-6); } @@ -60,7 +60,7 @@ TEST_F(DefaultCube, FunctionalTestFootprintinitLincSinc) { std::vector<double> lats = {9.928500, 9.928500, 10.434861, 10.434861, 9.928500}; geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(boundary->getCoordinates())); - for (int i = 0; i < coordArray.getSize(); i++) { + for (size_t i = 0; i < coordArray.getSize(); i++) { EXPECT_NEAR(lons[i], coordArray.getAt(i).x, 1e-6); EXPECT_NEAR(lats[i], coordArray.getAt(i).y, 1e-6); } @@ -82,7 +82,7 @@ TEST_F(DefaultCube, FunctionalTestFootprintinitVertices) { std::vector<double> lats = {9.928456, 9.928456, 10.434903, 10.434903, 9.928456}; geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(boundary->getCoordinates())); - for (int i = 0; i < coordArray.getSize(); i++) { + for (size_t i = 0; i < coordArray.getSize(); i++) { EXPECT_NEAR(lons[i], coordArray.getAt(i).x, 1e-6); EXPECT_NEAR(lats[i], coordArray.getAt(i).y, 1e-6); } @@ -104,7 +104,7 @@ TEST_F(DefaultCube, FunctionalTestFootprintinitCamera) { std::vector<double> lats = {9.924583, 9.924583, 10.329275, 10.329275, 9.924583}; geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(boundary->getCoordinates())); - for (int i = 0; i < coordArray.getSize(); i++) { + for (size_t i = 0; i < coordArray.getSize(); i++) { EXPECT_NEAR(lons[i], coordArray.getAt(i).x, 1e-6); EXPECT_NEAR(lats[i], coordArray.getAt(i).y, 1e-6); } @@ -126,7 +126,7 @@ TEST_F(DefaultCube, FunctionalTestFootprintinitTestXY) { std::vector<double> lats = {9.928502, 9.928502, 10.434859, 10.434859, 9.928502}; geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(boundary->getCoordinates())); - for (int i = 0; i < coordArray.getSize(); i++) { + for (size_t i = 0; i < coordArray.getSize(); i++) { EXPECT_NEAR(lons[i], coordArray.getAt(i).x, 1e-6); EXPECT_NEAR(lats[i], coordArray.getAt(i).y, 1e-6); } @@ -154,7 +154,7 @@ TEST_F(DefaultCube, FunctionalTestFootprintinitPrecision) { std::vector<double> lats = {9.928502, 9.928502, 10.434859, 10.434859, 9.928502}; geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(boundary->getCoordinates())); - for (int i = 0; i < coordArray.getSize(); i++) { + for (size_t i = 0; i < coordArray.getSize(); i++) { EXPECT_NEAR(lons[i], coordArray.getAt(i).x, 1e-6); EXPECT_NEAR(lats[i], coordArray.getAt(i).y, 1e-6); } diff --git a/isis/tests/FunctionalTestsJigsaw.cpp b/isis/tests/FunctionalTestsJigsaw.cpp index c2e47e561a..fbcecb66cd 100644 --- a/isis/tests/FunctionalTestsJigsaw.cpp +++ b/isis/tests/FunctionalTestsJigsaw.cpp @@ -82,7 +82,7 @@ TEST_F(ApolloNetwork, FunctionalTestJigsawApollo) { EXPECT_EQ(numRows-3, points.length()); - ControlPoint* outputPoint; + ControlPoint* outputPoint = nullptr; for (int i=3; i < numRows; i++) { csvLine = line.getRow(i); EXPECT_NO_THROW({ @@ -174,10 +174,10 @@ TEST_F(ApolloNetwork, FunctionalTestJigsawApollo) { ControlMeasure* measure; for (int i=3; i < numRows; i++) { csvLine = line.getRow(i); - EXPECT_NO_THROW({ + ASSERT_NO_THROW({ outputPoint = outputNet.GetPoint(csvLine[0]); }) << "Point in residuals.csv is not present in output network."; - EXPECT_NO_THROW({ + ASSERT_NO_THROW({ measure = outputPoint->GetMeasure(csvLine[2]); }) << "Point in residuals.csv is not present in output network."; // Compare sample, line, residuals diff --git a/isis/tests/FunctionalTestsSpkwriter.cpp b/isis/tests/FunctionalTestsSpkwriter.cpp index 859a15b508..e581ff21b1 100644 --- a/isis/tests/FunctionalTestsSpkwriter.cpp +++ b/isis/tests/FunctionalTestsSpkwriter.cpp @@ -52,10 +52,8 @@ TEST_F(DefaultCube, FunctionalTestSpkwriterDefault) { newKernelCube.reopen("rw"); - Camera *newCamera = nullptr; - try { - newCamera = newKernelCube.camera(); + newKernelCube.camera(); } catch(IException &e) { FAIL() << "Unable to generate camera with new spk kernel: " << e.toString().toStdString().c_str() << std::endl; } @@ -111,10 +109,8 @@ TEST_F(DefaultCube, FunctionalTestSpkwriterFromlist) { newKernelCube.reopen("rw"); - Camera *newCamera = nullptr; - try { - newCamera = newKernelCube.camera(); + newKernelCube.camera(); } catch(IException &e) { FAIL() << "Unable to generate camera with new spk kernel: " << e.toString().toStdString().c_str() << std::endl; } diff --git a/isis/tests/PvlKeywordTests.cpp b/isis/tests/PvlKeywordTests.cpp index d4d474e4c6..b06d5c16dd 100644 --- a/isis/tests/PvlKeywordTests.cpp +++ b/isis/tests/PvlKeywordTests.cpp @@ -431,13 +431,13 @@ void comparePvlKeywords(PvlKeyword pvlKeyword1, PvlKeyword pvlKeyword2) EXPECT_TRUE(PvlKeyword::stringEqual(pvlKeyword1.name(), pvlKeyword2.name())); ASSERT_EQ(pvlKeyword1.comments(), pvlKeyword2.comments()); - for (unsigned int comment = 0; comment < pvlKeyword1.comments(); comment++) + for (unsigned int comment = 0; comment < (unsigned int)pvlKeyword1.comments(); comment++) { EXPECT_TRUE(PvlKeyword::stringEqual(pvlKeyword1.comment(comment), pvlKeyword2.comment(comment))); } ASSERT_EQ(pvlKeyword1.size(), pvlKeyword2.size()); - for (unsigned int value = 0; value < pvlKeyword1.size(); value++) + for (unsigned int value = 0; value < (unsigned int)pvlKeyword1.size(); value++) { EXPECT_TRUE(PvlKeyword::stringEqual(pvlKeyword1[value], pvlKeyword2[value])); EXPECT_TRUE(PvlKeyword::stringEqual(pvlKeyword1.unit(value), pvlKeyword2.unit(value))); -- GitLab