Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warnings pass on comm #20204

Open
wants to merge 3 commits into
base: task/2025_01_warnings
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions src/common/comm/BufferConnection.C
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ BufferConnection::~BufferConnection()
{
}

int
size_t
BufferConnection::Fill()
{
return 0;
Expand All @@ -25,10 +25,10 @@ BufferConnection::Flush()
buffer.clear();
}

long
size_t
BufferConnection::Size()
{
return (long)(buffer.empty() ? 0 : buffer.size());
return buffer.empty() ? 0 : buffer.size();
}

void
Expand Down Expand Up @@ -58,10 +58,10 @@ BufferConnection::Read(unsigned char *address)
}

void
BufferConnection::Append(const unsigned char *buf, int count)
BufferConnection::Append(const unsigned char *buf, size_t count)
{
const unsigned char *temp = buf;
for(int i = 0; i < count; ++i)
for(size_t i = 0; i < count; ++i)
buffer.push_back(*temp++);
}

Expand All @@ -87,15 +87,17 @@ BufferConnection::Append(const unsigned char *buf, int count)
// Burlen Loring, Mon Aug 3 13:29:43 PDT 2015
// Fix a bug where this method did nothing.
//
// Cyrus Harrison, Tue Jan 28 09:55:51 PST 2025
// Convert to size_t for buffer sizes
// ****************************************************************************

long
BufferConnection::DirectRead(unsigned char *buf, long len)
size_t
BufferConnection::DirectRead(unsigned char *buf, size_t len)
{
if (!buf)
return 0;

long n = 0;
size_t n = 0;
while (buffer.size() && (n < len))
{
buf[n] = buffer.front();
Expand Down Expand Up @@ -124,11 +126,12 @@ BufferConnection::DirectRead(unsigned char *buf, long len)
// Creation: Mon Mar 25 14:20:11 PST 2002
//
// Modifications:
//
// Cyrus Harrison, Tue Jan 28 09:55:51 PST 2025
// Convert to size_t for buffer sizes
// ****************************************************************************

long
BufferConnection::DirectWrite(const unsigned char *buf, long len)
size_t
BufferConnection::DirectWrite(const unsigned char *buf, size_t len)
{
Append(buf, len);
return len;
Expand Down
23 changes: 13 additions & 10 deletions src/common/comm/BufferConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
// Modifications:
// Brad Whitlock, Wed Mar 20 17:23:43 PST 2002
// Added Fill, DirectWrite, DirectRead methods.
//
//
// Cyrus Harrison, Tue Jan 28 09:55:51 PST 2025
// Convert to size_t for buffer sizes
//
// ****************************************************************************

class COMM_API BufferConnection : public Connection
Expand All @@ -31,16 +34,16 @@ class COMM_API BufferConnection : public Connection
BufferConnection();
virtual ~BufferConnection();

virtual int Fill();
virtual void Flush();
virtual long Size();
virtual void Reset();
virtual size_t Fill();
virtual void Flush();
virtual size_t Size();
virtual void Reset();

virtual void Write(unsigned char value);
virtual void Read(unsigned char *address);
virtual void Append(const unsigned char *buf, int count);
virtual long DirectRead(unsigned char *buf, long len);
virtual long DirectWrite(const unsigned char *buf, long len);
virtual void Write(unsigned char value);
virtual void Read(unsigned char *address);
virtual void Append(const unsigned char *buf, size_t count);
virtual size_t DirectRead(unsigned char *buf, size_t len);
virtual size_t DirectWrite(const unsigned char *buf, size_t len);
private:
std::deque<unsigned char> buffer;
};
Expand Down
18 changes: 9 additions & 9 deletions src/common/comm/CommunicationHeader.C
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,16 @@ CommunicationHeader::WriteHeader(Connection *conn, const std::string &version,
// 3 : CouldNotConnectException
// 4 : CancelledConnectException
//
buffer[5] = (failCode >= 0 && failCode < 5) ? ((unsigned char)failCode) : 3;
buffer[5] = (failCode >= 0 && failCode < 5) ? static_cast<unsigned char>(failCode) : 3;

// The next 10 bytes are for a NULL terminated version string.
strncpy((char *)(buffer+6), version.c_str(), 10);
strncpy(reinterpret_cast<char *>(buffer+6), version.c_str(), 10);

// The next 21 bytes are for securityKey.
strncpy((char *)(buffer+6+10), securityKey.c_str(), 21);
strncpy(reinterpret_cast<char *>(buffer+6+10), securityKey.c_str(), 21);

// The next 21 bytes are for socketKey.
strncpy((char *)(buffer+6+10+21), socketKey.c_str(), 21);
strncpy(reinterpret_cast<char *>(buffer+6+10+21), socketKey.c_str(), 21);

#ifdef DEBUG_COMMUNICATION_HEADER
debug1 << "CommunicationHeader::WriteHeader: HEADER={";
Expand Down Expand Up @@ -229,7 +229,7 @@ CommunicationHeader::ReadHeader(Connection *conn, const std::string &version,
#endif

// Check to see if the version numbers are compatible.
if(!VisItVersionsCompatible((const char *)(buffer+6), version.c_str()))
if(!VisItVersionsCompatible(reinterpret_cast<const char *>(buffer+6), version.c_str()))
{
debug1 << "Versions are " << buffer << "(" << buffer+6 << "),"
<< version << endl;
Expand Down Expand Up @@ -258,14 +258,14 @@ CommunicationHeader::ReadHeader(Connection *conn, const std::string &version,
// the same as the keys that were sent to the client.
if(checkKeys)
{
if((strcmp((const char *)(buffer+6+10), securityKey.c_str()) != 0) ||
(strcmp((const char *)(buffer+6+10+21), socketKey.c_str()) != 0))
if((strcmp(reinterpret_cast<const char *>(buffer+6+10), securityKey.c_str()) != 0) ||
(strcmp(reinterpret_cast<const char *>(buffer+6+10+21), socketKey.c_str()) != 0))
{
EXCEPTION0(IncompatibleSecurityTokenException);
}
}
securityKey = std::string((const char *)(buffer+6+10));
socketKey = std::string((const char *)(buffer+6+10+21));
securityKey = std::string(reinterpret_cast<const char *>(buffer+6+10));
socketKey = std::string(reinterpret_cast<const char *>(buffer+6+10+21));

#ifdef DEBUG_COMMUNICATION_HEADER
debug1 << "CommunicationHeader::ReadHeader: securityKey=" << securityKey.c_str() << endl;
Expand Down
32 changes: 16 additions & 16 deletions src/common/comm/Connection.C
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
const bool Connection::SRC = false;
const bool Connection::DEST = true;

long Connection::ReadHeader(unsigned char *buf, long len)
long Connection::ReadHeader(unsigned char *buf, size_t len)
{
return DirectRead(buf,len);
}

long Connection::WriteHeader(const unsigned char *buf, long len)
long Connection::WriteHeader(const unsigned char *buf, size_t len)
{
return DirectWrite(buf,len);
}
Expand Down Expand Up @@ -77,11 +77,11 @@ Connection::WriteInt(int val)
if(doConversion)
{
unsigned char buffer[8];
int nbytes = IntConvert(val, buffer, IntFormat());
size_t nbytes = IntConvert(val, buffer, IntFormat());
Append(buffer, nbytes);
}
else
Append((unsigned char *)&val, SIZEOF_INT);
Append(static_cast<unsigned char *>(&val), SIZEOF_INT);
}

// *******************************************************************
Expand All @@ -106,11 +106,11 @@ Connection::WriteLong(long val)
if(doConversion)
{
unsigned char buffer[8];
int nbytes = LongConvert(val, buffer, LongFormat());
size_t nbytes = LongConvert(val, buffer, LongFormat());
Append(buffer, nbytes);
}
else
Append((unsigned char *)&val, SIZEOF_LONG);
Append(static_cast<unsigned char *>), SIZEOF_LONG);
}

// *******************************************************************
Expand All @@ -135,11 +135,11 @@ Connection::WriteFloat(float val)
if(doConversion)
{
unsigned char buffer[8];
int nbytes = FloatConvert(val, buffer, FloatFormat());
size_t nbytes = FloatConvert(val, buffer, FloatFormat());
Append(buffer, nbytes);
}
else
Append((unsigned char *)&val, SIZEOF_FLOAT);
Append(static_cast<unsigned char *>), SIZEOF_FLOAT);
}

// *******************************************************************
Expand All @@ -164,11 +164,11 @@ Connection::WriteDouble(double val)
if(doConversion)
{
unsigned char buffer[8];
int nbytes = DoubleConvert(val, buffer, DoubleFormat());
size_t nbytes = DoubleConvert(val, buffer, DoubleFormat());
Append(buffer, nbytes);
}
else
Append((unsigned char *)&val, SIZEOF_DOUBLE);
Append(static_cast<unsigned char *>), SIZEOF_DOUBLE);
}

// ****************************************************************************
Expand All @@ -190,7 +190,7 @@ Connection::WriteDouble(double val)
void
Connection::WriteString(const std::string &s)
{
Append((unsigned char *)s.c_str(), (int)s.size() + 1);
Append(s.c_str(),s.size() + 1);
}

// *******************************************************************
Expand All @@ -212,7 +212,7 @@ Connection::WriteString(const std::string &s)
void
Connection::ReadInt(int *i)
{
unsigned char *temp = (unsigned char *)i;
unsigned char *temp = static_cast<unsigned char *>(i);
#if(SIZEOF_INT == 4)
Read(temp);
Read(temp + 1);
Expand Down Expand Up @@ -251,7 +251,7 @@ Connection::ReadInt(int *i)
void
Connection::ReadLong(long *l)
{
unsigned char *temp = (unsigned char *)l;
unsigned char *temp = static_cast<unsigned char *>(l);

#if(SIZEOF_LONG == 4)
Read(temp);
Expand Down Expand Up @@ -291,7 +291,7 @@ Connection::ReadLong(long *l)
void
Connection::ReadFloat(float *f)
{
unsigned char *temp = (unsigned char *)f;
unsigned char *temp = static_cast<unsigned char *>(f);

#if(SIZEOF_FLOAT == 4)
Read(temp);
Expand Down Expand Up @@ -322,7 +322,7 @@ Connection::ReadFloat(float *f)
void
Connection::ReadDouble(double *d)
{
unsigned char *temp = (unsigned char *)d;
unsigned char *temp = static_cast<unsigned char *>(d);

#if(SIZEOF_DOUBLE == 8)
Read(temp);
Expand Down Expand Up @@ -361,7 +361,7 @@ Connection::ReadString(std::string &s)
char c;
do
{
ReadChar((unsigned char *)&c);
ReadChar(static_cast<unsigned char *>(&c));
if(c != '\0')
s += char(c);
}
Expand Down
Loading