aboutsummaryrefslogtreecommitdiffstats
path: root/common/rdr/RandomStream.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'common/rdr/RandomStream.cxx')
-rw-r--r--common/rdr/RandomStream.cxx14
1 files changed, 7 insertions, 7 deletions
diff --git a/common/rdr/RandomStream.cxx b/common/rdr/RandomStream.cxx
index e22da3d0..d5f1cc85 100644
--- a/common/rdr/RandomStream.cxx
+++ b/common/rdr/RandomStream.cxx
@@ -35,7 +35,7 @@ static rfb::LogWriter vlog("RandomStream");
using namespace rdr;
-const int DEFAULT_BUF_LEN = 256;
+const size_t DEFAULT_BUF_LEN = 256;
unsigned int RandomStream::seed;
@@ -86,11 +86,11 @@ RandomStream::~RandomStream() {
#endif
}
-int RandomStream::pos() {
+size_t RandomStream::pos() {
return offset + ptr - start;
}
-int RandomStream::overrun(int itemSize, int nItems, bool wait) {
+size_t RandomStream::overrun(size_t itemSize, size_t nItems, bool wait) {
if (itemSize > DEFAULT_BUF_LEN)
throw Exception("RandomStream overrun: max itemSize exceeded");
@@ -101,7 +101,7 @@ int RandomStream::overrun(int itemSize, int nItems, bool wait) {
offset += ptr - start;
ptr = start;
- int length = start + DEFAULT_BUF_LEN - end;
+ size_t length = start + DEFAULT_BUF_LEN - end;
#ifdef RFB_HAVE_WINCRYPT
if (provider) {
@@ -112,7 +112,7 @@ int RandomStream::overrun(int itemSize, int nItems, bool wait) {
#else
#ifndef WIN32
if (fp) {
- int n = fread((U8*)end, length, 1, fp);
+ size_t n = fread((U8*)end, length, 1, fp);
if (n != 1)
throw rdr::SystemException("reading /dev/urandom or /dev/random failed",
errno);
@@ -122,11 +122,11 @@ int RandomStream::overrun(int itemSize, int nItems, bool wait) {
{
#endif
#endif
- for (int i=0; i<length; i++)
+ for (size_t i=0; i<length; i++)
*(U8*)end++ = (int) (256.0*rand()/(RAND_MAX+1.0));
}
- if (itemSize * nItems > end - ptr)
+ if (itemSize * nItems > (size_t)(end - ptr))
nItems = (end - ptr) / itemSize;
return nItems;