# HG changeset patch # User Alain Mazy # Date 1762794046 -3600 # Node ID debcddfb57f0a2f4d1bd02d9110078db350a889d # Parent 37c4ce2438ace42796b0f0427c404b3e94ad1f07 cppcheck: cstyleCast diff -r 37c4ce2438ac -r debcddfb57f0 OrthancFramework/Sources/DicomNetworking/DicomAssociation.cpp --- 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(LST_Head(l)); + LST_Position(l, reinterpret_cast(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(LST_Next(l)); } } diff -r 37c4ce2438ac -r debcddfb57f0 OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp --- 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(&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(&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(&storeResponse), 0, sizeof(storeResponse)); storeResponse.CommandField = DIMSE_C_STORE_RSP; T_DIMSE_C_StoreRSP& storeRsp = storeResponse.msg.CStoreRSP; diff -r 37c4ce2438ac -r debcddfb57f0 OrthancFramework/Sources/DicomNetworking/Internals/FindScp.cpp --- 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(sequenceAttribute) )->card() == 1 && + ( reinterpret_cast(sequenceAttribute) )->getItem(0)->findAndGetElement( DCM_ReferencedSOPClassUID, referencedSOPClassUIDAttribute ).good() && referencedSOPClassUIDAttribute->getLength() == 0 && - ( (DcmSequenceOfItems*)sequenceAttribute )->getItem(0)->findAndGetElement( DCM_ReferencedSOPInstanceUID, referencedSOPInstanceUIDAttribute, OFFalse ).good() && + ( reinterpret_cast(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(sequenceAttribute))->remove( (reinterpret_cast(sequenceAttribute))->getItem(0) ); delete item; } } diff -r 37c4ce2438ac -r debcddfb57f0 OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp --- 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(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(decoded->c_str()), decoded->size()).good(); break; } diff -r 37c4ce2438ac -r debcddfb57f0 OrthancFramework/UnitTestsSources/FrameworkTests.cpp --- 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(&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(&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(&data[0]), size); uint32_t unicode; size_t length; Toolbox::Utf8ToUnicodeCharacter(unicode, length, s, 0); diff -r 37c4ce2438ac -r debcddfb57f0 OrthancFramework/UnitTestsSources/ImageTests.cpp --- 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 uint8_t*) r.GetConstBuffer() + y * r.GetPitch()); + const uint16_t *p = reinterpret_cast(reinterpret_cast(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 uint8_t*) r2.GetConstBuffer() + y * r2.GetPitch()); + const uint16_t *p = reinterpret_cast(reinterpret_cast(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 uint8_t*) r.GetConstBuffer() + y * r.GetPitch()); + (reinterpret_cast(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 uint8_t*)r.GetConstBuffer() + y * r.GetPitch()); + (reinterpret_cast(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 uint8_t*) r2.GetConstBuffer() + y * r2.GetPitch()); + (reinterpret_cast(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 uint8_t*)r2.GetConstBuffer() + y * r2.GetPitch()); + (reinterpret_cast(r2.GetConstBuffer()) + y * r2.GetPitch()); ASSERT_EQ(p, r2.GetConstRow(y)); for (unsigned int x = 0; x < width; x++, p++, v++) { diff -r 37c4ce2438ac -r debcddfb57f0 OrthancServer/Resources/RunCppCheck.sh --- 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 diff -r 37c4ce2438ac -r debcddfb57f0 OrthancServer/Sources/OrthancGetRequestHandler.cpp --- 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(LST_Head(l)); + LST_Position(l, reinterpret_cast(pc)); while (pc) { if (pc->result == ASC_P_ACCEPTANCE) @@ -157,7 +157,7 @@ } } - pc = (DUL_PRESENTATIONCONTEXT*) LST_Next(l); + pc = reinterpret_cast(LST_Next(l)); } }