Core/SSH: ssize_t/size_t to int casts are made explicit to make compilers happy.

git-svn-id: svn://ultimatepp.org/upp/trunk@15443 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
oblivion 2020-11-17 23:09:53 +00:00
parent 6047777265
commit d4cd9a866f
4 changed files with 27 additions and 11 deletions

View file

@ -268,7 +268,10 @@ int SshChannel::Read(void *ptr, int size, int sid)
{
int sz = min(size - done, ssh->chunk_size);
int rc = libssh2_channel_read_ex(*channel, sid, (char*) ptr + done, sz);
int rc = static_cast<int>(
libssh2_channel_read_ex(*channel, sid, (char*) ptr + done, size_t(sz))
);
if(rc < 0 && !WouldBlock(rc))
SetError(rc);
if(rc > 0) {
@ -290,7 +293,10 @@ int SshChannel::Write(const void *ptr, int size, int sid)
{
int sz = min(size - done, ssh->chunk_size);
int rc = libssh2_channel_write_ex(*channel, sid, (const char*) ptr + done, sz);
int rc = static_cast<int>(
libssh2_channel_write_ex(*channel, sid, (const char*) ptr + done, size_t(sz))
);
if(!WouldBlock(rc) && rc < 0)
SetError(rc);
if(rc > 0) {

View file

@ -135,7 +135,10 @@ int SFtp::Read(SFtpHandle handle, void* ptr, int size)
{
int sz = min(size - done, ssh->chunk_size);
int rc = libssh2_sftp_read(handle, (char*) ptr + done, sz);
int rc = static_cast<int>(
libssh2_sftp_read(handle, (char*) ptr + done, size_t(sz))
);
if(!WouldBlock(rc) && rc < 0)
SetError(rc);
if(rc > 0) {
@ -152,7 +155,10 @@ int SFtp::Write(SFtpHandle handle, const void* ptr, int size)
{
int sz = min(size - done, ssh->chunk_size);
int rc = libssh2_sftp_write(handle, (const char*) ptr + done, sz);
int rc = static_cast<int>(
libssh2_sftp_write(handle, (const char*) ptr + done, size_t(sz))
);
if(!WouldBlock(rc) && rc < 0)
SetError(rc);
if(rc > 0) {

View file

@ -57,7 +57,7 @@ bool Scp::Load(Stream& s, ScpAttrs a, int64 maxsize)
done_ += n;
s.Put(chunk, n);
if((nowait = WhenProgress(done_, size))) {
msg = "File transfer aborted.";
msg = "File transfer is aborted.";
break;
}
}
@ -82,7 +82,7 @@ bool Scp::Save(Stream& s)
if(n < l)
s.Seek(n);
if((nowait = WhenProgress(done_, size))) {
msg = "File transfer aborted.";;
msg = "File transfer is aborted.";;
break;
}
}

View file

@ -158,7 +158,7 @@ void SshShell::ConsoleRead()
if(!EventWait(STDIN_FILENO, WAIT_READ, 0))
return;
Buffer<char> buffer(ssh->chunk_size);
auto n = read(STDIN_FILENO, buffer, ssh->chunk_size);
auto n = read(STDIN_FILENO, buffer, size_t(ssh->chunk_size));
if(n > 0)
Send(String(buffer, n));
else
@ -170,7 +170,7 @@ void SshShell::ConsoleWrite(const void* buffer, int len)
{
if(!EventWait(STDOUT_FILENO, WAIT_WRITE, 0))
return;
auto n = write(STDOUT_FILENO, buffer, len);
auto n = write(STDOUT_FILENO, buffer, size_t(len));
if(n == -1 && errno != EAGAIN)
SetError(-1, "Couldn't write output to console.");
}
@ -287,16 +287,20 @@ void SshShell::X11Loop()
SOCKET sock = xrequests[i].b;
if(EventWait(sock, WAIT_WRITE, 0)) {
int rc = libssh2_channel_read(xhandle, xbuffer, xbuflen);
int rc = static_cast<int>(
libssh2_channel_read(xhandle, xbuffer, size_t(xbuflen))
);
if(!WouldBlock(rc) && rc < 0)
SetError(-1, "[X11]: Read failed.");
if(rc > 0)
write(sock, xbuffer, rc);
}
if(EventWait(sock, WAIT_READ, 0)) {
int rc = read(sock, xbuffer, xbuflen);
int rc = static_cast<int>(
read(sock, xbuffer, size_t(xbuflen))
);
if(rc > 0)
libssh2_channel_write(xhandle, (const char*) xbuffer, rc);
libssh2_channel_write(xhandle, (const char*) xbuffer, size_t(rc));
}
if(libssh2_channel_eof(xhandle) == 1) {
LLOG("[X11] EOF received.");