ENH: remove sign from SHA1Digest cdata_bytes(), data_bytes()

- this refinement of commit 81807646ca makes these methods
  consistent with other objects/containers.

  The 'unsigned char' access is still available via cdata()
This commit is contained in:
Mark Olesen
2023-05-17 14:26:05 +02:00
parent 28ac15f933
commit bc51caac32
3 changed files with 12 additions and 11 deletions

View File

@ -261,11 +261,11 @@ int main(int argc, char *argv[])
} }
{ {
const SHA1Digest myHostDigest(SHA1(hostName()).digest()); const SHA1Digest myDigest(SHA1(hostName()).digest());
UPstream::mpiGather UPstream::mpiGather
( (
reinterpret_cast<const char*>(myHostDigest.cdata_bytes()), myDigest.cdata_bytes(), // Send
SHA1Digest::max_size(), // Num send per proc SHA1Digest::max_size(), // Num send per proc
digests.data_bytes(), // Recv digests.data_bytes(), // Recv
SHA1Digest::max_size(), // Num recv per proc SHA1Digest::max_size(), // Num recv per proc

View File

@ -88,11 +88,9 @@ static List<int> getHostGroupIds(const label parentCommunicator)
SHA1Digest myDigest(SHA1(hostName()).digest()); SHA1Digest myDigest(SHA1(hostName()).digest());
// The fixed-length digest allows use of MPI_Gather // The fixed-length digest allows use of MPI_Gather
// and avoids Pstream::gatherList() during setup...
UPstream::mpiGather UPstream::mpiGather
( (
reinterpret_cast<const char*>(myDigest.cdata_bytes()), myDigest.cdata_bytes(), // Send
SHA1Digest::max_size(), // Num send per proc SHA1Digest::max_size(), // Num send per proc
digests.data_bytes(), // Recv digests.data_bytes(), // Recv
SHA1Digest::max_size(), // Num recv per proc SHA1Digest::max_size(), // Num recv per proc

View File

@ -128,16 +128,19 @@ public:
//- Raw digest data (20 bytes) - const access //- Raw digest data (20 bytes) - const access
const unsigned char* cdata() const noexcept { return dig_.data(); } const unsigned char* cdata() const noexcept { return dig_.data(); }
//- Raw digest data (20 bytes) - const access //- Raw digest char data (20 bytes) - const access.
const unsigned char* cdata_bytes() const noexcept //- 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! //- Raw digest char data (20 bytes) - non-const access.
unsigned char* data_bytes() noexcept //- 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) //- The number of bytes in digest (20)