diff --git a/applications/test/parallel-comm2/Test-parallel-comm2.C b/applications/test/parallel-comm2/Test-parallel-comm2.C index 660bc6fb94388ddeacec28e1e907401c81f46b87..7ccd11cf29b61c4a8e4ce38cc4ff758868e33f6b 100644 --- a/applications/test/parallel-comm2/Test-parallel-comm2.C +++ b/applications/test/parallel-comm2/Test-parallel-comm2.C @@ -261,11 +261,11 @@ int main(int argc, char *argv[]) } { - const SHA1Digest myHostDigest(SHA1(hostName()).digest()); + const SHA1Digest myDigest(SHA1(hostName()).digest()); UPstream::mpiGather ( - reinterpret_cast<const char*>(myHostDigest.cdata_bytes()), + myDigest.cdata_bytes(), // Send SHA1Digest::max_size(), // Num send per proc digests.data_bytes(), // Recv SHA1Digest::max_size(), // Num recv per proc diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C index 3d6dc38439b970000c711134ffdf2ea93205744e..ac967f1a1e8856a5000f49b80e37b31185e3db90 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C @@ -88,11 +88,9 @@ static List<int> getHostGroupIds(const label parentCommunicator) SHA1Digest myDigest(SHA1(hostName()).digest()); // The fixed-length digest allows use of MPI_Gather - // and avoids Pstream::gatherList() during setup... - UPstream::mpiGather ( - reinterpret_cast<const char*>(myDigest.cdata_bytes()), + myDigest.cdata_bytes(), // Send SHA1Digest::max_size(), // Num send per proc digests.data_bytes(), // Recv SHA1Digest::max_size(), // Num recv per proc diff --git a/src/OpenFOAM/primitives/hashes/SHA1/SHA1Digest.H b/src/OpenFOAM/primitives/hashes/SHA1/SHA1Digest.H index f3b3535f5b827b22003e4e635e7c2b1790e1e29c..77a065e11fc482564b2f6d2b703e6f097ecb75d8 100644 --- a/src/OpenFOAM/primitives/hashes/SHA1/SHA1Digest.H +++ b/src/OpenFOAM/primitives/hashes/SHA1/SHA1Digest.H @@ -128,16 +128,19 @@ public: //- Raw digest data (20 bytes) - const access const unsigned char* cdata() const noexcept { return dig_.data(); } - //- Raw digest data (20 bytes) - const access - const unsigned char* cdata_bytes() const noexcept + //- Raw digest char data (20 bytes) - const access. + //- For consistency with other objects, these are \em not unsigned. + const char* cdata_bytes() const noexcept { - return dig_.data(); + return reinterpret_cast<const char*>(dig_.data()); } - //- Raw digest data (20 bytes) - non-const access. Use with caution! - unsigned char* data_bytes() noexcept + //- Raw digest char data (20 bytes) - non-const access. + //- For consistency with other objects, these are \em not unsigned. + //- Use with caution - generally for broadcasting only. + char* data_bytes() noexcept { - return dig_.data(); + return reinterpret_cast<char*>(dig_.data()); } //- The number of bytes in digest (20)