Mercurial > hg > orthanc
changeset 6377:debcddfb57f0
cppcheck: cstyleCast
| author | Alain Mazy <am@orthanc.team> |
|---|---|
| date | Mon, 10 Nov 2025 18:00:46 +0100 |
| parents | 37c4ce2438ac |
| children | 442b50f930ae |
| files | OrthancFramework/Sources/DicomNetworking/DicomAssociation.cpp OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp OrthancFramework/Sources/DicomNetworking/Internals/FindScp.cpp OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp OrthancFramework/UnitTestsSources/FrameworkTests.cpp OrthancFramework/UnitTestsSources/ImageTests.cpp OrthancServer/Resources/RunCppCheck.sh OrthancServer/Sources/OrthancGetRequestHandler.cpp |
| diffstat | 8 files changed, 28 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomNetworking/DicomAssociation.cpp Mon Nov 10 17:49:02 2025 +0100 +++ b/OrthancFramework/Sources/DicomNetworking/DicomAssociation.cpp Mon Nov 10 18:00:46 2025 +0100 @@ -388,8 +388,8 @@ LST_HEAD **l = ¶ms_->DULparams.acceptedPresentationContext; if (*l != NULL) { - DUL_PRESENTATIONCONTEXT* pc = (DUL_PRESENTATIONCONTEXT*) LST_Head(l); - LST_Position(l, (LST_NODE*)pc); + DUL_PRESENTATIONCONTEXT* pc = reinterpret_cast<DUL_PRESENTATIONCONTEXT*>(LST_Head(l)); + LST_Position(l, reinterpret_cast<LST_NODE*>(pc)); while (pc) { if (pc->result == ASC_P_ACCEPTANCE && strlen(pc->abstractSyntax) > 0) @@ -409,7 +409,7 @@ } } - pc = (DUL_PRESENTATIONCONTEXT*) LST_Next(l); + pc = reinterpret_cast<DUL_PRESENTATIONCONTEXT*>(LST_Next(l)); } }
--- a/OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp Mon Nov 10 17:49:02 2025 +0100 +++ b/OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp Mon Nov 10 18:00:46 2025 +0100 @@ -578,7 +578,7 @@ } T_DIMSE_Message msgGetRequest; - memset((char*)&msgGetRequest, 0, sizeof(msgGetRequest)); + memset(reinterpret_cast<void*>(&msgGetRequest), 0, sizeof(msgGetRequest)); msgGetRequest.CommandField = DIMSE_C_GET_RQ; T_DIMSE_C_GetRQ* request = &(msgGetRequest.msg.CGetRQ); @@ -617,7 +617,7 @@ { T_DIMSE_Message rsp; // Make sure everything is zeroed (especially options) - memset((char*)&rsp, 0, sizeof(rsp)); + memset(reinterpret_cast<void*>(&rsp), 0, sizeof(rsp)); // DcmDataset* statusDetail = NULL; T_ASC_PresentationContextID cmdPresId = 0; @@ -711,7 +711,7 @@ // send the Store response T_DIMSE_Message storeResponse; - memset((char*)&storeResponse, 0, sizeof(storeResponse)); + memset(reinterpret_cast<void*>(&storeResponse), 0, sizeof(storeResponse)); storeResponse.CommandField = DIMSE_C_STORE_RSP; T_DIMSE_C_StoreRSP& storeRsp = storeResponse.msg.CStoreRSP;
--- a/OrthancFramework/Sources/DicomNetworking/Internals/FindScp.cpp Mon Nov 10 17:49:02 2025 +0100 +++ b/OrthancFramework/Sources/DicomNetworking/Internals/FindScp.cpp Mon Nov 10 18:00:46 2025 +0100 @@ -112,13 +112,13 @@ // in case the sequence attribute contains exactly one item with an empty // ReferencedSOPClassUID and an empty ReferencedSOPInstanceUID, remove the item if( dataset->findAndGetElement( sequenceTagKey, sequenceAttribute ).good() && - ( (DcmSequenceOfItems*)sequenceAttribute )->card() == 1 && - ( (DcmSequenceOfItems*)sequenceAttribute )->getItem(0)->findAndGetElement( DCM_ReferencedSOPClassUID, referencedSOPClassUIDAttribute ).good() && + ( reinterpret_cast<DcmSequenceOfItems*>(sequenceAttribute) )->card() == 1 && + ( reinterpret_cast<DcmSequenceOfItems*>(sequenceAttribute) )->getItem(0)->findAndGetElement( DCM_ReferencedSOPClassUID, referencedSOPClassUIDAttribute ).good() && referencedSOPClassUIDAttribute->getLength() == 0 && - ( (DcmSequenceOfItems*)sequenceAttribute )->getItem(0)->findAndGetElement( DCM_ReferencedSOPInstanceUID, referencedSOPInstanceUIDAttribute, OFFalse ).good() && + ( reinterpret_cast<DcmSequenceOfItems*>(sequenceAttribute) )->getItem(0)->findAndGetElement( DCM_ReferencedSOPInstanceUID, referencedSOPInstanceUIDAttribute, OFFalse ).good() && referencedSOPInstanceUIDAttribute->getLength() == 0 ) { - DcmItem *item = ((DcmSequenceOfItems*)sequenceAttribute)->remove( ((DcmSequenceOfItems*)sequenceAttribute)->getItem(0) ); + DcmItem *item = (reinterpret_cast<DcmSequenceOfItems*>(sequenceAttribute))->remove( (reinterpret_cast<DcmSequenceOfItems*>(sequenceAttribute))->getItem(0) ); delete item; } }
--- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp Mon Nov 10 17:49:02 2025 +0100 +++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp Mon Nov 10 18:00:46 2025 +0100 @@ -2019,13 +2019,13 @@ } else { - ok = element.putUint16Array((const Uint16*) decoded->c_str(), decoded->size() / sizeof(Uint16)).good(); + ok = element.putUint16Array(reinterpret_cast<const Uint16*>(decoded->c_str()), decoded->size() / sizeof(Uint16)).good(); } break; default: - ok = element.putUint8Array((const Uint8*) decoded->c_str(), decoded->size()).good(); + ok = element.putUint8Array(reinterpret_cast<const Uint8*>(decoded->c_str()), decoded->size()).good(); break; }
--- a/OrthancFramework/UnitTestsSources/FrameworkTests.cpp Mon Nov 10 17:49:02 2025 +0100 +++ b/OrthancFramework/UnitTestsSources/FrameworkTests.cpp Mon Nov 10 18:00:46 2025 +0100 @@ -499,7 +499,7 @@ // This is a Latin-1 test string const unsigned char data[10] = { 0xe0, 0xe9, 0xea, 0xe7, 0x26, 0xc6, 0x61, 0x62, 0x63, 0x00 }; - std::string s((char*) &data[0], 10); + std::string s(reinterpret_cast<char*>(&data[0]), 10); ASSERT_EQ("&abc", Toolbox::ConvertToAscii(s)); // Open in Emacs, then save with UTF-8 encoding, then "hexdump -C" @@ -528,7 +528,7 @@ // This is a Latin-1 test string: "crane" with a circumflex accent const unsigned char latin1[] = { 0x63, 0x72, 0xe2, 0x6e, 0x65 }; - std::string s((char*) &latin1[0], sizeof(latin1) / sizeof(char)); + std::string s(reinterpret_cast<char*>(&latin1[0]), sizeof(latin1) / sizeof(char)); ASSERT_EQ(s, Toolbox::ConvertFromUtf8(Toolbox::ConvertToUtf8(s, Encoding_Latin1, false, false), Encoding_Latin1)); ASSERT_EQ("cre", Toolbox::ConvertToUtf8(s, Encoding_Utf8, false, false)); @@ -539,7 +539,7 @@ size_t size, size_t expectedLength) { - std::string s((char*) &data[0], size); + std::string s(reinterpret_cast<char*>(&data[0]), size); uint32_t unicode; size_t length; Toolbox::Utf8ToUnicodeCharacter(unicode, length, s, 0);
--- a/OrthancFramework/UnitTestsSources/ImageTests.cpp Mon Nov 10 17:49:02 2025 +0100 +++ b/OrthancFramework/UnitTestsSources/ImageTests.cpp Mon Nov 10 18:00:46 2025 +0100 @@ -252,7 +252,7 @@ v = 0; for (unsigned int y = 0; y < height; y++) { - const uint16_t *p = reinterpret_cast<const uint16_t*>((const uint8_t*) r.GetConstBuffer() + y * r.GetPitch()); + const uint16_t *p = reinterpret_cast<const uint16_t*>(reinterpret_cast<const uint8_t*>(r.GetConstBuffer()) + y * r.GetPitch()); ASSERT_EQ(p, r.GetConstRow(y)); for (unsigned int x = 0; x < width; x++, p++, v++) { @@ -276,7 +276,7 @@ v = 0; for (unsigned int y = 0; y < height; y++) { - const uint16_t *p = reinterpret_cast<const uint16_t*>((const uint8_t*) r2.GetConstBuffer() + y * r2.GetPitch()); + const uint16_t *p = reinterpret_cast<const uint16_t*>(reinterpret_cast<const uint8_t*>(r2.GetConstBuffer()) + y * r2.GetPitch()); ASSERT_EQ(p, r2.GetConstRow(y)); for (unsigned int x = 0; x < width; x++, p++, v++) { @@ -500,7 +500,7 @@ for (unsigned int y = 0; y < height; y++) { const uint16_t *p = reinterpret_cast<const uint16_t*> - ((const uint8_t*) r.GetConstBuffer() + y * r.GetPitch()); + (reinterpret_cast<const uint8_t*>(r.GetConstBuffer()) + y * r.GetPitch()); ASSERT_EQ(p, r.GetConstRow(y)); for (unsigned int x = 0; x < width; x++, p++, v++) { @@ -522,7 +522,7 @@ for (unsigned int y = 0; y < height; y++) { const uint16_t* p = reinterpret_cast<const uint16_t*> - ((const uint8_t*)r.GetConstBuffer() + y * r.GetPitch()); + (reinterpret_cast<const uint8_t*>(r.GetConstBuffer()) + y * r.GetPitch()); ASSERT_EQ(p, r.GetConstRow(y)); for (unsigned int x = 0; x < width; x++, p++, v++) { @@ -547,7 +547,7 @@ for (unsigned int y = 0; y < height; y++) { const uint16_t *p = reinterpret_cast<const uint16_t*> - ((const uint8_t*) r2.GetConstBuffer() + y * r2.GetPitch()); + (reinterpret_cast<const uint8_t*>(r2.GetConstBuffer()) + y * r2.GetPitch()); ASSERT_EQ(p, r2.GetConstRow(y)); for (unsigned int x = 0; x < width; x++, p++, v++) { @@ -574,7 +574,7 @@ for (unsigned int y = 0; y < height; y++) { const uint16_t* p = reinterpret_cast<const uint16_t*> - ((const uint8_t*)r2.GetConstBuffer() + y * r2.GetPitch()); + (reinterpret_cast<const uint8_t*>(r2.GetConstBuffer()) + y * r2.GetPitch()); ASSERT_EQ(p, r2.GetConstRow(y)); for (unsigned int x = 0; x < width; x++, p++, v++) {
--- a/OrthancServer/Resources/RunCppCheck.sh Mon Nov 10 17:49:02 2025 +0100 +++ b/OrthancServer/Resources/RunCppCheck.sh Mon Nov 10 18:00:46 2025 +0100 @@ -43,6 +43,10 @@ variableScope:../../OrthancServer/Sources/ServerJobs/OrthancPeerStoreJob.cpp:94 uselessOverride:../../OrthancFramework/Sources/MultiThreading/IRunnableBySteps.h:35 uselessOverride:../../OrthancFramework/Sources/JobsEngine/SetOfInstancesJob.h:76 +cstyleCast:../../OrthancServer/Plugins/Engine/PluginsManager.cpp:85 +cstyleCast:../../OrthancServer/Plugins/Engine/PluginsManager.cpp:108 +cstyleCast:../../OrthancServer/Plugins/Engine/PluginsManager.cpp:124 +cstyleCast:../../OrthancServer/Plugins/Engine/PluginsManager.cpp:140 EOF # TODO: re-enable nullPointerOutOfMemory
--- a/OrthancServer/Sources/OrthancGetRequestHandler.cpp Mon Nov 10 17:49:02 2025 +0100 +++ b/OrthancServer/Sources/OrthancGetRequestHandler.cpp Mon Nov 10 18:00:46 2025 +0100 @@ -133,8 +133,8 @@ LST_HEAD **l = &assoc->params->DULparams.acceptedPresentationContext; if (*l != NULL) { - DUL_PRESENTATIONCONTEXT* pc = (DUL_PRESENTATIONCONTEXT*) LST_Head(l); - LST_Position(l, (LST_NODE*)pc); + DUL_PRESENTATIONCONTEXT* pc = reinterpret_cast<DUL_PRESENTATIONCONTEXT*>(LST_Head(l)); + LST_Position(l, reinterpret_cast<LST_NODE*>(pc)); while (pc) { if (pc->result == ASC_P_ACCEPTANCE) @@ -157,7 +157,7 @@ } } - pc = (DUL_PRESENTATIONCONTEXT*) LST_Next(l); + pc = reinterpret_cast<DUL_PRESENTATIONCONTEXT*>(LST_Next(l)); } }
