diff --git a/curvefs/test/client/chunk_cache_manager_test.cpp b/curvefs/test/client/chunk_cache_manager_test.cpp index 4f87ba1781..75147f1ae1 100644 --- a/curvefs/test/client/chunk_cache_manager_test.cpp +++ b/curvefs/test/client/chunk_cache_manager_test.cpp @@ -84,7 +84,7 @@ TEST_F(ChunkCacheManagerTest, test_write_new_data) { chunkCacheManager_->WriteNewDataCache(s3ClientAdaptor_, offset, len, buf); ASSERT_EQ(65536, s3ClientAdaptor_->GetFsCacheManager()->GetDataCacheSize()); - delete buf; + delete[] buf; } TEST_F(ChunkCacheManagerTest, test_add_read_data_cache) { @@ -110,7 +110,7 @@ TEST_F(ChunkCacheManagerTest, test_add_read_data_cache) { chunkCacheManager_->AddReadDataCache(dataCache2); ASSERT_EQ(1.5 * 1024 * 1024, s3ClientAdaptor_->GetFsCacheManager()->GetLruByte()); - delete buf; + delete[] buf; } TEST_F(ChunkCacheManagerTest, test_find_writeable_datacache) { @@ -135,7 +135,7 @@ TEST_F(ChunkCacheManagerTest, test_find_writeable_datacache) { offset, len, &mergeDataCacheVer, inodeId)); ASSERT_EQ(1, mergeDataCacheVer.size()); - delete buf; + delete[] buf; } TEST_F(ChunkCacheManagerTest, test_read_by_write_cache) { @@ -172,8 +172,8 @@ TEST_F(ChunkCacheManagerTest, test_read_by_write_cache) { requests.clear(); len = 2048; - delete buf; - delete expectBuf; + delete[] buf; + delete[] expectBuf; buf = new char[len + 1]; expectBuf = new char[len + 1]; memset(buf, 'a', len); @@ -187,8 +187,8 @@ TEST_F(ChunkCacheManagerTest, test_read_by_write_cache) { requests.clear(); len = 512; - delete buf; - delete expectBuf; + delete[] buf; + delete[] expectBuf; buf = new char[len + 1]; expectBuf = new char[len + 1]; memset(buf, 'a', len - 1); @@ -202,8 +202,8 @@ TEST_F(ChunkCacheManagerTest, test_read_by_write_cache) { requests.clear(); len = 1024; - delete buf; - delete expectBuf; + delete[] buf; + delete[] expectBuf; buf = new char[len + 1]; expectBuf = new char[len + 1]; memset(buf, 'a', len); @@ -217,9 +217,9 @@ TEST_F(ChunkCacheManagerTest, test_read_by_write_cache) { ASSERT_EQ(1, requests.size()); requests.clear(); - delete buf; - delete expectBuf; - delete dataCacheBuf; + delete[] buf; + delete[] expectBuf; + delete[] dataCacheBuf; } TEST_F(ChunkCacheManagerTest, test_read_by_read_cache) { @@ -257,8 +257,8 @@ TEST_F(ChunkCacheManagerTest, test_read_by_read_cache) { requests.clear(); len = 2048; - delete buf; - delete expectBuf; + delete[] buf; + delete[] expectBuf; buf = new char[len + 1]; expectBuf = new char[len + 1]; memset(buf, 'a', len); @@ -272,8 +272,8 @@ TEST_F(ChunkCacheManagerTest, test_read_by_read_cache) { requests.clear(); len = 512; - delete buf; - delete expectBuf; + delete[] buf; + delete[] expectBuf; buf = new char[len + 1]; expectBuf = new char[len + 1]; memset(buf, 'a', len - 1); @@ -287,8 +287,8 @@ TEST_F(ChunkCacheManagerTest, test_read_by_read_cache) { requests.clear(); len = 1024; - delete buf; - delete expectBuf; + delete[] buf; + delete[] expectBuf; buf = new char[len + 1]; expectBuf = new char[len + 1]; memset(buf, 'a', len); @@ -302,9 +302,9 @@ TEST_F(ChunkCacheManagerTest, test_read_by_read_cache) { ASSERT_EQ(1, requests.size()); requests.clear(); - delete buf; - delete expectBuf; - delete dataCacheBuf; + delete[] buf; + delete[] expectBuf; + delete[] dataCacheBuf; } TEST_F(ChunkCacheManagerTest, test_flush) { @@ -335,7 +335,7 @@ TEST_F(ChunkCacheManagerTest, test_flush) { chunkCacheManager_->Flush(inodeId, true, true)); chunkCacheManager_->ReleaseCacheForTest(); - delete buf; + delete[] buf; } TEST_F(ChunkCacheManagerTest, test_release_read_dataCache) { @@ -348,7 +348,7 @@ TEST_F(ChunkCacheManagerTest, test_release_read_dataCache) { chunkCacheManager_->ReleaseReadDataCache(offset); ASSERT_EQ(true, chunkCacheManager_->IsEmpty()); - delete buf; + delete[] buf; } @@ -377,7 +377,7 @@ TEST_F(ChunkCacheManagerTest, test_truncate_cache) { ASSERT_EQ(true, chunkCacheManager_->IsEmpty()); chunkCacheManager_->ReleaseCacheForTest(); - delete buf; + delete[] buf; } } // namespace client diff --git a/curvefs/test/client/client_s3_adaptor_Integration.cpp b/curvefs/test/client/client_s3_adaptor_Integration.cpp index fc9e30dd97..204637965c 100644 --- a/curvefs/test/client/client_s3_adaptor_Integration.cpp +++ b/curvefs/test/client/client_s3_adaptor_Integration.cpp @@ -199,7 +199,7 @@ TEST_F(ClientS3IntegrationTest, test_first_write) { ASSERT_EQ(1, fsCacheManager->GetDataCacheNum()); ASSERT_EQ(len, ret); - delete buf; + delete[] buf; buf = NULL; } @@ -225,7 +225,7 @@ TEST_F(ClientS3IntegrationTest, test_overlap_write) { s3ClientAdaptor_->Write(inode->GetInodeId(), offset, len, buf); ASSERT_EQ(1, fsCacheManager->GetDataCacheNum()); - delete buf; + delete[] buf; buf = NULL; } @@ -244,7 +244,7 @@ TEST_F(ClientS3IntegrationTest, test_hole_write) { s3ClientAdaptor_->GetFsCacheManager(); ASSERT_EQ(2, fsCacheManager->GetDataCacheNum()); - delete buf; + delete[] buf; buf = NULL; } @@ -263,7 +263,7 @@ TEST_F(ClientS3IntegrationTest, test_append_write) { s3ClientAdaptor_->GetFsCacheManager(); ASSERT_EQ(1, fsCacheManager->GetDataCacheNum()); - delete buf; + delete[] buf; buf = NULL; } @@ -280,7 +280,7 @@ TEST_F(ClientS3IntegrationTest, test_write_more_chunk) { s3ClientAdaptor_->GetFsCacheManager(); ASSERT_EQ(2, fsCacheManager->GetDataCacheNum()); - delete buf; + delete[] buf; buf = NULL; } @@ -314,8 +314,8 @@ TEST_F(ClientS3IntegrationTest, test_write_merge_data1) { s3ClientAdaptor_->Write(inode->GetInodeId(), offset, len, buf1); ASSERT_EQ(1, fsCacheManager->GetDataCacheNum()); - delete buf; - delete buf1; + delete[] buf; + delete[] buf1; } /* @@ -348,8 +348,8 @@ TEST_F(ClientS3IntegrationTest, test_write_merge_data2) { s3ClientAdaptor_->Write(inode->GetInodeId(), offset, len, buf1); ASSERT_EQ(1, fsCacheManager->GetDataCacheNum()); - delete buf; - delete buf1; + delete[] buf; + delete[] buf1; } TEST_F(ClientS3IntegrationTest, test_read_one_chunk) { @@ -392,7 +392,7 @@ TEST_F(ClientS3IntegrationTest, test_read_one_chunk) { ret = s3ClientAdaptor_->Read(inode->GetInodeId(), offset, len, buf); ASSERT_EQ(-1, ret); - delete buf; + delete[] buf; buf = NULL; } @@ -431,9 +431,9 @@ TEST_F(ClientS3IntegrationTest, test_read_overlap_block1) { s3ClientAdaptor_->Read(inode->GetInodeId(), offset, len, readBuf); EXPECT_STREQ(expectBuf, readBuf); - delete readBuf; - delete buf; - delete expectBuf; + delete[] readBuf; + delete[] buf; + delete[] expectBuf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -477,9 +477,9 @@ TEST_F(ClientS3IntegrationTest, test_read_overlap_block2) { s3ClientAdaptor_->Read(inode->GetInodeId(), offset, len, readBuf); EXPECT_STREQ(expectBuf, readBuf); - delete readBuf; - delete buf; - delete expectBuf; + delete[] readBuf; + delete[] buf; + delete[] expectBuf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -532,9 +532,9 @@ TEST_F(ClientS3IntegrationTest, test_read_overlap_block3) { s3ClientAdaptor_->Read(inode->GetInodeId(), offset, len, readBuf); EXPECT_STREQ(expectBuf, readBuf); - delete readBuf; - delete buf; - delete expectBuf; + delete[] readBuf; + delete[] buf; + delete[] expectBuf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -590,9 +590,9 @@ TEST_F(ClientS3IntegrationTest, test_read_overlap_block4) { s3ClientAdaptor_->Read(inode->GetInodeId(), offset, len, readBuf); EXPECT_STREQ(expectBuf, readBuf); - delete readBuf; - delete buf; - delete expectBuf; + delete[] readBuf; + delete[] buf; + delete[] expectBuf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -648,9 +648,9 @@ TEST_F(ClientS3IntegrationTest, test_read_overlap_block5) { s3ClientAdaptor_->Read(inode->GetInodeId(), offset, len, readBuf); EXPECT_STREQ(expectBuf, readBuf); - // delete readBuf; - delete buf; - delete expectBuf; + // delete[] readBuf; + delete[] buf; + delete[] expectBuf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -697,9 +697,9 @@ TEST_F(ClientS3IntegrationTest, test_read_hole1) { EXPECT_STREQ(expectBuf, readBuf); // cleanup - delete buf; - delete readBuf; - delete expectBuf; + delete[] buf; + delete[] readBuf; + delete[] expectBuf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -739,9 +739,9 @@ TEST_F(ClientS3IntegrationTest, test_read_hole2) { EXPECT_STREQ(expectBuf, readBuf); // cleanup - delete buf; - delete readBuf; - delete expectBuf; + delete[] buf; + delete[] readBuf; + delete[] expectBuf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -780,9 +780,9 @@ TEST_F(ClientS3IntegrationTest, test_read_hole3) { EXPECT_STREQ(expectBuf, readBuf); // cleanup - delete buf; - delete readBuf; - delete expectBuf; + delete[] buf; + delete[] readBuf; + delete[] expectBuf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -829,9 +829,9 @@ TEST_F(ClientS3IntegrationTest, test_read_hole4) { EXPECT_STREQ(expectBuf, readBuf); // cleanup - delete buf; - delete readBuf; - delete expectBuf; + delete[] buf; + delete[] readBuf; + delete[] expectBuf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -880,9 +880,9 @@ TEST_F(ClientS3IntegrationTest, test_read_more_write) { EXPECT_STREQ(expectBuf, readBuf); // cleanup - delete buf; - delete readBuf; - delete expectBuf; + delete[] buf; + delete[] readBuf; + delete[] expectBuf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -930,9 +930,9 @@ TEST_F(ClientS3IntegrationTest, test_read_more_write2) { EXPECT_STREQ(expectBuf, readBuf); // cleanup - delete buf; - delete readBuf; - delete expectBuf; + delete[] buf; + delete[] readBuf; + delete[] expectBuf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -973,9 +973,9 @@ TEST_F(ClientS3IntegrationTest, test_read_more_chunks) { EXPECT_STREQ(expectBuf, readBuf); // cleanup - delete buf; - delete readBuf; - delete expectBuf; + delete[] buf; + delete[] readBuf; + delete[] expectBuf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -1004,7 +1004,7 @@ TEST_F(ClientS3IntegrationTest, test_truncate_small1) { ASSERT_EQ(len, s3ClientAdaptor_->GetFsCacheManager()->GetDataCacheSize()); // cleanup - delete buf; + delete[] buf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -1046,7 +1046,7 @@ TEST_F(ClientS3IntegrationTest, test_truncate_small2) { s3ClientAdaptor_->GetFsCacheManager()->GetDataCacheSize()); // cleanup - delete buf; + delete[] buf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -1118,7 +1118,7 @@ TEST_F(ClientS3IntegrationTest, test_truncate_small3) { ASSERT_EQ(len, s3ClientAdaptor_->GetFsCacheManager()->GetLruByte()); // cleanup - delete buf; + delete[] buf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -1160,8 +1160,8 @@ TEST_F(ClientS3IntegrationTest, test_truncate_big1) { EXPECT_STREQ(expectBuf, readBuf); // cleanup - delete readBuf; - delete expectBuf; + delete[] readBuf; + delete[] expectBuf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -1205,9 +1205,9 @@ TEST_F(ClientS3IntegrationTest, test_truncate_big2) { EXPECT_STREQ(expectBuf, readBuf); // cleanup - delete buf; - delete readBuf; - delete expectBuf; + delete[] buf; + delete[] readBuf; + delete[] expectBuf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -1286,12 +1286,12 @@ TEST_F(ClientS3IntegrationTest, test_truncate_big3) { EXPECT_STREQ(expectBuf2, readBuf2); // cleanup - delete readBuf; - delete expectBuf; - delete readBuf1; - delete expectBuf1; - delete readBuf2; - delete expectBuf2; + delete[] readBuf; + delete[] expectBuf; + delete[] readBuf1; + delete[] expectBuf1; + delete[] readBuf2; + delete[] expectBuf2; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { @@ -1323,7 +1323,7 @@ TEST_F(ClientS3IntegrationTest, test_releaseCache) { ASSERT_EQ(0, fsCacheManager->GetDataCacheNum()); // cleanup - delete buf; + delete[] buf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -1377,7 +1377,7 @@ TEST_F(ClientS3IntegrationTest, test_flush_first_write) { ASSERT_EQ(offset, tmp.offset()); // cleanup - delete buf; + delete[] buf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -1437,7 +1437,7 @@ TEST_F(ClientS3IntegrationTest, test_flush_overlap_write) { ASSERT_EQ(0, tmp.offset()); // cleanup - delete buf; + delete[] buf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -1495,7 +1495,7 @@ TEST_F(ClientS3IntegrationTest, test_flush_overlap_write2) { ASSERT_EQ(16748032, tmp.offset()); // cleanup - delete buf; + delete[] buf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -1555,7 +1555,7 @@ TEST_F(ClientS3IntegrationTest, test_flush_hole_write) { ASSERT_EQ(2 * 1024 * 1024, tmp.offset()); // cleanup - delete buf; + delete[] buf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -1615,7 +1615,7 @@ TEST_F(ClientS3IntegrationTest, test_flush_write_more_chunk) { ASSERT_EQ(4 * 1024 * 1024, tmp.offset()); // cleanup - delete buf; + delete[] buf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -1695,7 +1695,7 @@ TEST_F(ClientS3IntegrationTest, test_flush_write_and_read1) { EXPECT_STREQ(expectBuf, readBuf); // cleanup - delete buf; + delete[] buf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -1777,7 +1777,7 @@ TEST_F(ClientS3IntegrationTest, test_flush_write_and_read2) { s3ClientAdaptor_->Read(inode->GetInodeId(), offset, len, readBuf); EXPECT_STREQ(expectBuf, readBuf); // cleanup - delete buf; + delete[] buf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -1876,11 +1876,11 @@ TEST_F(ClientS3IntegrationTest, test_flush_write_and_read3) { EXPECT_STREQ(expectBuf2, readBuf2); // cleanup - delete buf; - delete readBuf; - delete expectBuf; - delete readBuf1; - delete expectBuf1; + delete[] buf; + delete[] readBuf; + delete[] expectBuf; + delete[] readBuf1; + delete[] expectBuf1; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -1963,9 +1963,9 @@ TEST_F(ClientS3IntegrationTest, test_flush_write_and_read4) { EXPECT_STREQ(expectBuf, readBuf); // cleanup - delete buf; - delete readBuf; - delete expectBuf; + delete[] buf; + delete[] readBuf; + delete[] expectBuf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -2051,9 +2051,9 @@ TEST_F(ClientS3IntegrationTest, test_flush_write_and_read5) { EXPECT_STREQ(expectBuf, readBuf); // cleanup - delete buf; - delete readBuf; - delete expectBuf; + delete[] buf; + delete[] readBuf; + delete[] expectBuf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -2142,9 +2142,9 @@ TEST_F(ClientS3IntegrationTest, test_flush_write_and_read6) { EXPECT_STREQ(expectBuf, readBuf); // cleanup - delete buf; - delete readBuf; - delete expectBuf; + delete[] buf; + delete[] readBuf; + delete[] expectBuf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -2241,9 +2241,9 @@ TEST_F(ClientS3IntegrationTest, test_flush_write_and_read7) { EXPECT_STREQ(expectBuf, readBuf); // cleanup - delete buf; - delete readBuf; - delete expectBuf; + delete[] buf; + delete[] readBuf; + delete[] expectBuf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -2333,9 +2333,9 @@ TEST_F(ClientS3IntegrationTest, test_flush_write_and_read8) { EXPECT_STREQ(expectBuf, readBuf); // cleanup - delete buf; - delete readBuf; - delete expectBuf; + delete[] buf; + delete[] readBuf; + delete[] expectBuf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -2428,9 +2428,9 @@ TEST_F(ClientS3IntegrationTest, test_flush_write_and_read9) { EXPECT_STREQ(expectBuf, readBuf); // cleanup - delete buf; - delete readBuf; - delete expectBuf; + delete[] buf; + delete[] readBuf; + delete[] expectBuf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -2551,9 +2551,9 @@ TEST_F(ClientS3IntegrationTest, test_flush_write_and_read10) { EXPECT_STREQ(expectBuf, readBuf); // cleanup - delete buf; - delete readBuf; - delete expectBuf; + delete[] buf; + delete[] readBuf; + delete[] expectBuf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -2635,9 +2635,9 @@ TEST_F(ClientS3IntegrationTest, test_flush_write_and_read11) { EXPECT_STREQ(expectBuf, readBuf); // cleanup - delete buf; - delete readBuf; - delete expectBuf; + delete[] buf; + delete[] readBuf; + delete[] expectBuf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -2719,9 +2719,9 @@ TEST_F(ClientS3IntegrationTest, test_flush_write_and_read12) { EXPECT_STREQ(expectBuf, readBuf); // cleanup - delete buf; - delete readBuf; - delete expectBuf; + delete[] buf; + delete[] readBuf; + delete[] expectBuf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -2783,7 +2783,7 @@ TEST_F(ClientS3IntegrationTest, test_fssync_success_and_fail) { ASSERT_EQ(CURVEFS_ERROR::OK, ret); // cleanup - delete buf; + delete[] buf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; @@ -2832,7 +2832,7 @@ TEST_F(ClientS3IntegrationTest, test_fssync_overlap_write) { ASSERT_EQ(0, fsCacheManager->GetDataCacheNum()); // cleanup - delete buf; + delete[] buf; std::map::iterator iter = gObjectDataMaps.begin(); for (; iter != gObjectDataMaps.end(); iter++) { delete iter->second.buf; diff --git a/curvefs/test/client/data_cache_test.cpp b/curvefs/test/client/data_cache_test.cpp index 5127b4170e..27c487de44 100644 --- a/curvefs/test/client/data_cache_test.cpp +++ b/curvefs/test/client/data_cache_test.cpp @@ -67,7 +67,7 @@ class DataCacheTest : public testing::Test { dataCache_ = std::make_shared(s3ClientAdaptor_, mockChunkCacheManager_, offset, len, buf, nullptr); - delete buf; + delete[] buf; } void TearDown() override {} @@ -85,7 +85,7 @@ TEST_F(DataCacheTest, test_write1) { dataCache_->Write(offset, len, buf, mergeDataCacheVer); ASSERT_EQ(0, dataCache_->GetChunkPos()); ASSERT_EQ(1536 * 1024, dataCache_->GetLen()); - delete buf; + delete[] buf; } TEST_F(DataCacheTest, test_write2) { @@ -96,7 +96,7 @@ TEST_F(DataCacheTest, test_write2) { dataCache_->Write(offset, len, buf, mergeDataCacheVer); ASSERT_EQ(0, dataCache_->GetChunkPos()); ASSERT_EQ(2048 * 1024, dataCache_->GetLen()); - delete buf; + delete[] buf; } TEST_F(DataCacheTest, test_write3) { @@ -111,7 +111,7 @@ TEST_F(DataCacheTest, test_write3) { dataCache_->Write(offset, len, buf, mergeDataCacheVer); ASSERT_EQ(0, dataCache_->GetChunkPos()); ASSERT_EQ(4096 * 1024, dataCache_->GetLen()); - delete buf; + delete[] buf; } TEST_F(DataCacheTest, test_write4) { @@ -122,7 +122,7 @@ TEST_F(DataCacheTest, test_write4) { dataCache_->Write(offset, len, buf, mergeDataCacheVer); ASSERT_EQ(512 * 1024, dataCache_->GetChunkPos()); ASSERT_EQ(1024 * 1024, dataCache_->GetLen()); - delete buf; + delete[] buf; } TEST_F(DataCacheTest, test_write5) { @@ -133,7 +133,7 @@ TEST_F(DataCacheTest, test_write5) { dataCache_->Write(offset, len, buf, mergeDataCacheVer); ASSERT_EQ(512 * 1024, dataCache_->GetChunkPos()); ASSERT_EQ(1536 * 1024, dataCache_->GetLen()); - delete buf; + delete[] buf; } TEST_F(DataCacheTest, test_write6) { @@ -148,7 +148,7 @@ TEST_F(DataCacheTest, test_write6) { dataCache_->Write(offset, len, buf, mergeDataCacheVer); ASSERT_EQ(512 * 1024, dataCache_->GetChunkPos()); ASSERT_EQ(2560 * 1024, dataCache_->GetLen()); - delete buf; + delete[] buf; } TEST_F(DataCacheTest, test_truncate1) { diff --git a/nebd/src/common/timeutility.h b/nebd/src/common/timeutility.h index da4ee68b71..a80afb61b5 100644 --- a/nebd/src/common/timeutility.h +++ b/nebd/src/common/timeutility.h @@ -28,6 +28,7 @@ #include #include #include +#include namespace nebd { namespace common { diff --git a/nebd/src/part2/metafile_manager.cpp b/nebd/src/part2/metafile_manager.cpp index 288fde68ce..23ce070f6e 100644 --- a/nebd/src/part2/metafile_manager.cpp +++ b/nebd/src/part2/metafile_manager.cpp @@ -245,7 +245,7 @@ Json::Value NebdMetaFileParser::ConvertFileMetasToJson( Json::Value volume; volume[kFileName] = meta.second.fileName; volume[kFd] = meta.second.fd; - for (const auto item : meta.second.xattr) { + for (const auto &item : meta.second.xattr) { volume[item.first] = item.second; } volumes.append(volume); diff --git a/nebd/test/part1/fake_file_service.cpp b/nebd/test/part1/fake_file_service.cpp index d48c043864..4e06cece4f 100644 --- a/nebd/test/part1/fake_file_service.cpp +++ b/nebd/test/part1/fake_file_service.cpp @@ -35,11 +35,6 @@ void FakeNebdFileService::OpenFile(::google::protobuf::RpcController* controller brpc::Controller* cntl = static_cast(controller); LOG(INFO) << "logid = " << cntl->log_id() << ", OpenFile."; - if (buffer == nullptr) { - response->set_retcode(RetCode::kNoOK); - response->set_retmsg("OpenFile FAIL"); - return; - } response->set_retcode(RetCode::kOK); response->set_retmsg("OpenFile OK"); diff --git a/src/chunkserver/raftlog/curve_segment.cpp b/src/chunkserver/raftlog/curve_segment.cpp index 0e144971b8..0d213ac499 100644 --- a/src/chunkserver/raftlog/curve_segment.cpp +++ b/src/chunkserver/raftlog/curve_segment.cpp @@ -66,7 +66,7 @@ int CurveSegment::create() { memset(metaPage, 0, _meta_page_size); memcpy(metaPage, &_meta.bytes, sizeof(_meta.bytes)); int res = _walFilePool->GetFile(path, metaPage); - delete metaPage; + delete[] metaPage; if (res != 0) { LOG(ERROR) << "Get segment from chunk file pool fail!"; return -1; @@ -232,11 +232,11 @@ int CurveSegment::_load_meta() { char* metaPage = new char[_meta_page_size]; int res = ::pread(_fd, metaPage, _meta_page_size, 0); if (res != static_cast(_meta_page_size)) { - delete metaPage; + delete[] metaPage; return -1; } memcpy(&_meta.bytes, metaPage, sizeof(_meta.bytes)); - delete metaPage; + delete[] metaPage; LOG(INFO) << "loaded bytes: " << _meta.bytes; return 0; } diff --git a/src/common/timeutility.h b/src/common/timeutility.h index c880f68473..1ba3483d34 100644 --- a/src/common/timeutility.h +++ b/src/common/timeutility.h @@ -27,6 +27,7 @@ #include #include #include +#include namespace curve { namespace common { diff --git a/src/tools/mds_client.cpp b/src/tools/mds_client.cpp index 21f9ded49d..22e807ea9e 100644 --- a/src/tools/mds_client.cpp +++ b/src/tools/mds_client.cpp @@ -912,7 +912,7 @@ int MDSClient::GetListenAddrFromDummyPort(const std::string& dummyAddr, void MDSClient::GetMdsOnlineStatus(std::map* onlineStatus) { assert(onlineStatus != nullptr); onlineStatus->clear(); - for (const auto item : dummyServerMap_) { + for (const auto &item : dummyServerMap_) { std::string listenAddr; int res = GetListenAddrFromDummyPort(item.second, &listenAddr); // 如果获取到的监听地址与记录的mds地址不一致,也认为不在线 @@ -972,7 +972,7 @@ bool MDSClient::ChangeMDServer() { std::vector MDSClient::GetCurrentMds() { std::vector leaderAddrs; - for (const auto item : dummyServerMap_) { + for (const auto &item : dummyServerMap_) { // 获取status来判断正在服务的地址 std::string status; MetricRet ret = metricClient_.GetMetric(item.second, diff --git a/src/tools/snapshot_clone_client.cpp b/src/tools/snapshot_clone_client.cpp index 745ea01326..2b8be3c739 100644 --- a/src/tools/snapshot_clone_client.cpp +++ b/src/tools/snapshot_clone_client.cpp @@ -76,7 +76,7 @@ int SnapshotCloneClient::InitDummyServerMap(const std::string& dummyPort) { std::vector SnapshotCloneClient::GetActiveAddrs() { std::vector activeAddrs; - for (const auto item : dummyServerMap_) { + for (const auto &item : dummyServerMap_) { // 获取status来判断正在服务的地址 std::string status; MetricRet ret = metricClient_->GetMetric(item.second, diff --git a/test/chunkserver/raftlog/common.cpp b/test/chunkserver/raftlog/common.cpp index f31eba12b4..b7abdbba02 100644 --- a/test/chunkserver/raftlog/common.cpp +++ b/test/chunkserver/raftlog/common.cpp @@ -42,7 +42,7 @@ int prepare_segment(const std::string& path) { LOG(ERROR) << "write failed"; return -1; } - delete data; + delete[] data; close(fd); return 0; } diff --git a/test/mds/topology/test_topology_service_manager.cpp b/test/mds/topology/test_topology_service_manager.cpp index caff173702..efc96de534 100644 --- a/test/mds/topology/test_topology_service_manager.cpp +++ b/test/mds/topology/test_topology_service_manager.cpp @@ -3573,7 +3573,7 @@ TEST_F(TestTopologyServiceManager, test_SetCopysetsAvailFlag) { } std::vector copysets = topology_->GetCopySetInfosInLogicalPool(logicalPoolId1); - for (const auto copyset : copysets) { + for (const auto ©set : copysets) { ASSERT_TRUE(copyset.IsAvailable()); } // success @@ -3592,7 +3592,7 @@ TEST_F(TestTopologyServiceManager, test_SetCopysetsAvailFlag) { serviceManager_->SetCopysetsAvailFlag(&request, &response); ASSERT_EQ(kTopoErrCodeSuccess, response.statuscode()); copysets = topology_->GetCopySetInfosInLogicalPool(logicalPoolId1); - for (const auto copyset : copysets) { + for (const auto ©set : copysets) { if (copyset.GetId() <= 10) { ASSERT_FALSE(copyset.IsAvailable()); } else { @@ -3606,7 +3606,7 @@ TEST_F(TestTopologyServiceManager, test_SetCopysetsAvailFlag) { serviceManager_->SetCopysetsAvailFlag(&request, &response); ASSERT_EQ(kTopoErrCodeSuccess, response.statuscode()); copysets = topology_->GetCopySetInfosInLogicalPool(logicalPoolId1); - for (const auto copyset : copysets) { + for (const auto ©set : copysets) { ASSERT_TRUE(copyset.IsAvailable()); } } diff --git a/tools/curvefsTool.cpp b/tools/curvefsTool.cpp index 869b73e36b..698e54d535 100644 --- a/tools/curvefsTool.cpp +++ b/tools/curvefsTool.cpp @@ -364,7 +364,7 @@ int CurvefsTools::InitServerData() { LOG(ERROR) << "No servers in cluster map"; return -1; } - for (const auto server : clusterMap_[kServers]) { + for (const auto &server : clusterMap_[kServers]) { CurveServerData serverData; if (!server[kName].isString()) { LOG(ERROR) << "server name must be string"; @@ -423,7 +423,7 @@ int CurvefsTools::InitLogicalPoolData() { LOG(ERROR) << "No servers in cluster map"; return -1; } - for (const auto lgPool : clusterMap_[kLogicalPools]) { + for (const auto &lgPool : clusterMap_[kLogicalPools]) { CurveLogicalPoolData lgPoolData; if (!lgPool[kName].isString()) { LOG(ERROR) << "logicalpool name must be string";