diff options
author | Pierre Ossman <ossman@cendio.se> | 2015-03-03 16:26:03 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2015-03-03 16:26:03 +0100 |
commit | 5c23b9ed7d55a2cd5f44b8ec3da2c8bdcac5c3a5 (patch) | |
tree | 8c3438ffdacb5188cae93df720219fb96c242505 | |
parent | a7bbe9c4a3b2090240173e45bebab86e5cba3b4b (diff) | |
download | tigervnc-5c23b9ed7d55a2cd5f44b8ec3da2c8bdcac5c3a5.tar.gz tigervnc-5c23b9ed7d55a2cd5f44b8ec3da2c8bdcac5c3a5.zip |
Fix bad signed/unsigned comparisons
Either by casting, or switching to a more appropriate type
for the variable.
-rw-r--r-- | common/rdr/FileInStream.cxx | 2 | ||||
-rw-r--r-- | common/rdr/RandomStream.cxx | 2 | ||||
-rw-r--r-- | common/rdr/TLSInStream.cxx | 2 | ||||
-rw-r--r-- | common/rfb/EncodeManager.cxx | 4 | ||||
-rw-r--r-- | common/rfb/TightEncoder.cxx | 2 | ||||
-rw-r--r-- | common/rfb/VNCServerST.cxx | 2 | ||||
-rw-r--r-- | tests/conv.cxx | 2 | ||||
-rw-r--r-- | tests/convperf.cxx | 8 | ||||
-rw-r--r-- | vncviewer/CConn.cxx | 2 | ||||
-rw-r--r-- | vncviewer/cocoa.mm | 4 | ||||
-rw-r--r-- | vncviewer/parameters.cxx | 12 | ||||
-rw-r--r-- | win/rfb_win32/CleanDesktop.cxx | 2 | ||||
-rw-r--r-- | win/rfb_win32/TsSessions.cxx | 4 | ||||
-rw-r--r-- | win/vncconfig/Connections.h | 6 |
14 files changed, 27 insertions, 27 deletions
diff --git a/common/rdr/FileInStream.cxx b/common/rdr/FileInStream.cxx index 6d23aa2c..8d5c22e0 100644 --- a/common/rdr/FileInStream.cxx +++ b/common/rdr/FileInStream.cxx @@ -58,7 +58,7 @@ int FileInStream::pos() int FileInStream::overrun(int itemSize, int nItems, bool wait) { - if (itemSize > sizeof(b)) + if (itemSize > (int)sizeof(b)) throw Exception("FileInStream overrun: max itemSize exceeded"); if (end - ptr != 0) diff --git a/common/rdr/RandomStream.cxx b/common/rdr/RandomStream.cxx index 7056c2cc..3fde18d1 100644 --- a/common/rdr/RandomStream.cxx +++ b/common/rdr/RandomStream.cxx @@ -44,7 +44,7 @@ RandomStream::RandomStream() #ifdef RFB_HAVE_WINCRYPT provider = 0; if (!CryptAcquireContext(&provider, 0, 0, PROV_RSA_FULL, 0)) { - if (GetLastError() == NTE_BAD_KEYSET) { + if (GetLastError() == (DWORD)NTE_BAD_KEYSET) { if (!CryptAcquireContext(&provider, 0, 0, PROV_RSA_FULL, CRYPT_NEWKEYSET)) { fprintf(stderr, "RandomStream: unable to create keyset\n"); provider = 0; diff --git a/common/rdr/TLSInStream.cxx b/common/rdr/TLSInStream.cxx index 4d2c9ecb..21b60565 100644 --- a/common/rdr/TLSInStream.cxx +++ b/common/rdr/TLSInStream.cxx @@ -44,7 +44,7 @@ ssize_t TLSInStream::pull(gnutls_transport_ptr str, void* data, size_t size) return -1; } - if (in->getend() - in->getptr() < size) + if (in->getend() - in->getptr() < (ptrdiff_t)size) size = in->getend() - in->getptr(); in->readBytes(data, size); diff --git a/common/rfb/EncodeManager.cxx b/common/rfb/EncodeManager.cxx index e6323870..4e133d31 100644 --- a/common/rfb/EncodeManager.cxx +++ b/common/rfb/EncodeManager.cxx @@ -152,7 +152,7 @@ EncodeManager::~EncodeManager() void EncodeManager::logStats() { - int i, j; + size_t i, j; unsigned rects; unsigned long long pixels, bytes, equivalent; @@ -603,7 +603,7 @@ void EncodeManager::writeSubRect(const Rect& rect, const PixelBuffer *pb) Encoder *encoder; struct RectInfo info; - int divisor, maxColours; + unsigned int divisor, maxColours; bool useRLE; EncoderType type; diff --git a/common/rfb/TightEncoder.cxx b/common/rfb/TightEncoder.cxx index ec19c2e0..fe2470b9 100644 --- a/common/rfb/TightEncoder.cxx +++ b/common/rfb/TightEncoder.cxx @@ -201,7 +201,7 @@ void TightEncoder::writePixels(const rdr::U8* buffer, const PixelFormat& pf, } while (count) { - int iter_count; + unsigned int iter_count; iter_count = sizeof(rgb)/3; if (iter_count > count) diff --git a/common/rfb/VNCServerST.cxx b/common/rfb/VNCServerST.cxx index 51cb86cf..199524ec 100644 --- a/common/rfb/VNCServerST.cxx +++ b/common/rfb/VNCServerST.cxx @@ -544,7 +544,7 @@ inline bool VNCServerST::checkDefer() if (!deferPending) return true; - if (msSince(&deferStart) >= deferUpdateTime) + if (msSince(&deferStart) >= (unsigned)deferUpdateTime) return true; return false; diff --git a/tests/conv.cxx b/tests/conv.cxx index 2ee523a5..840f18dc 100644 --- a/tests/conv.cxx +++ b/tests/conv.cxx @@ -266,7 +266,7 @@ struct TestEntry tests[] = { static void doTests(const rfb::PixelFormat &dstpf, const rfb::PixelFormat &srcpf) { - int i; + size_t i; char dstb[256], srcb[256]; dstpf.print(dstb, sizeof(dstb)); diff --git a/tests/convperf.cxx b/tests/convperf.cxx index c8381d54..e4a3fd52 100644 --- a/tests/convperf.cxx +++ b/tests/convperf.cxx @@ -100,7 +100,7 @@ struct TestEntry tests[] = { static void doTests(rfb::PixelFormat &dstpf, rfb::PixelFormat &srcpf) { - int i; + size_t i; char dstb[256], srcb[256]; dstpf.print(dstb, sizeof(dstb)); @@ -118,19 +118,19 @@ static void doTests(rfb::PixelFormat &dstpf, rfb::PixelFormat &srcpf) int main(int argc, char **argv) { - int bufsize; + size_t bufsize; time_t t; char datebuffer[256]; - int i; + size_t i; bufsize = fbsize * fbsize * 4; fb1 = new rdr::U8[bufsize]; fb2 = new rdr::U8[bufsize]; - for (int i = 0;i < bufsize;i++) { + for (i = 0;i < bufsize;i++) { fb1[i] = rand(); fb2[i] = rand(); } diff --git a/vncviewer/CConn.cxx b/vncviewer/CConn.cxx index cf4f31b9..5935c177 100644 --- a/vncviewer/CConn.cxx +++ b/vncviewer/CConn.cxx @@ -134,7 +134,7 @@ CConn::~CConn() { OptionsDialog::removeCallback(handleOptions); - for (int i = 0; i < sizeof(decoders)/sizeof(decoders[0]); i++) + for (size_t i = 0; i < sizeof(decoders)/sizeof(decoders[0]); i++) delete decoders[i]; if (desktop) diff --git a/vncviewer/cocoa.mm b/vncviewer/cocoa.mm index 09921000..e51cba9d 100644 --- a/vncviewer/cocoa.mm +++ b/vncviewer/cocoa.mm @@ -57,7 +57,7 @@ int cocoa_capture_display(Fl_Window *win, bool all_displays) if (CGGetActiveDisplayList(16, displays, &count) != kCGErrorSuccess) return 1; - if (count != Fl::screen_count()) + if (count != (unsigned)Fl::screen_count()) return 1; #ifdef HAVE_FLTK_FULLSCREEN_SCREENS @@ -424,7 +424,7 @@ int cocoa_event_keysym(const void *event) NSEvent *nsevent; UInt16 key_code; - int i; + size_t i; NSString *chars; UInt32 modifiers; diff --git a/vncviewer/parameters.cxx b/vncviewer/parameters.cxx index 184af08f..29a5397d 100644 --- a/vncviewer/parameters.cxx +++ b/vncviewer/parameters.cxx @@ -202,7 +202,7 @@ static bool encodeValue(const char* val, char* dest, size_t destSize) { } else { - for (int j = 0; j < sizeof(replaceMap)/sizeof(replaceMap[0]); j++) { + for (size_t j = 0; j < sizeof(replaceMap)/sizeof(replaceMap[0]); j++) { if (val[i] == replaceMap[j].first) { dest[pos] = '\\'; @@ -242,7 +242,7 @@ static bool decodeValue(const char* val, char* dest, size_t destSize) { // Check for escape sequences if (val[i] == '\\') { - for (int j = 0; j < sizeof(replaceMap)/sizeof(replaceMap[0]); j++) { + for (size_t j = 0; j < sizeof(replaceMap)/sizeof(replaceMap[0]); j++) { if (val[i+1] == replaceMap[j].second) { dest[pos] = replaceMap[j].first; escapedCharacter = true; @@ -413,7 +413,7 @@ static void saveToReg(const char* servername) { setKeyString("ServerName", servername, &hKey); - for (int i = 0; i < sizeof(parameterArray)/sizeof(VoidParameter*); i++) { + for (size_t i = 0; i < sizeof(parameterArray)/sizeof(VoidParameter*); i++) { if (dynamic_cast<StringParameter*>(parameterArray[i]) != NULL) { setKeyString(parameterArray[i]->getName(), *(StringParameter*)parameterArray[i], &hKey); } else if (dynamic_cast<IntParameter*>(parameterArray[i]) != NULL) { @@ -459,7 +459,7 @@ static char* loadFromReg() { int intValue = 0; char stringValue[buffersize]; - for (int i = 0; i < sizeof(parameterArray)/sizeof(VoidParameter*); i++) { + for (size_t i = 0; i < sizeof(parameterArray)/sizeof(VoidParameter*); i++) { if (dynamic_cast<StringParameter*>(parameterArray[i]) != NULL) { if (getKeyString(parameterArray[i]->getName(), stringValue, buffersize, &hKey)) parameterArray[i]->setParam(stringValue); @@ -523,7 +523,7 @@ void saveViewerParameters(const char *filename, const char *servername) { if (encodeValue(servername, encodingBuffer, buffersize)) fprintf(f, "ServerName=%s\n", encodingBuffer); - for (int i = 0; i < sizeof(parameterArray)/sizeof(VoidParameter*); i++) { + for (size_t i = 0; i < sizeof(parameterArray)/sizeof(VoidParameter*); i++) { if (dynamic_cast<StringParameter*>(parameterArray[i]) != NULL) { if (encodeValue(*(StringParameter*)parameterArray[i], encodingBuffer, buffersize)) fprintf(f, "%s=%s\n", ((StringParameter*)parameterArray[i])->getName(), encodingBuffer); @@ -635,7 +635,7 @@ char* loadViewerParameters(const char *filename) { } else { // Find and set the correct parameter - for (int i = 0; i < sizeof(parameterArray)/sizeof(VoidParameter*); i++) { + for (size_t i = 0; i < sizeof(parameterArray)/sizeof(VoidParameter*); i++) { if (dynamic_cast<StringParameter*>(parameterArray[i]) != NULL) { if (strcasecmp(line, ((StringParameter*)parameterArray[i])->getName()) == 0) { diff --git a/win/rfb_win32/CleanDesktop.cxx b/win/rfb_win32/CleanDesktop.cxx index 52dc6bd7..bad95f0a 100644 --- a/win/rfb_win32/CleanDesktop.cxx +++ b/win/rfb_win32/CleanDesktop.cxx @@ -129,7 +129,7 @@ struct ActiveDesktop { vlog.error("failed to get desktop item count: %ld", hr); return false; } - for (unsigned int i=0; i<itemCount; i++) { + for (int i=0; i<itemCount; i++) { if (enableItem(i, false)) restoreItems.insert(i); } diff --git a/win/rfb_win32/TsSessions.cxx b/win/rfb_win32/TsSessions.cxx index efe75640..a4fac2f9 100644 --- a/win/rfb_win32/TsSessions.cxx +++ b/win/rfb_win32/TsSessions.cxx @@ -48,7 +48,7 @@ namespace win32 { id = 0; if (!_ProcessIdToSessionId.isValid()) return; - if (processId == -1) + if (processId == (DWORD)-1) processId = GetCurrentProcessId(); if (!(*_ProcessIdToSessionId)(GetCurrentProcessId(), &id)) throw rdr::SystemException("ProcessIdToSessionId", GetLastError()); @@ -72,7 +72,7 @@ namespace win32 { #ifdef RFB_HAVE_WINSTATION_CONNECT if (!_WinStationConnect.isValid()) throw rdr::Exception("WinSta APIs missing"); - if (sessionId == -1) + if (sessionId == (DWORD)-1) sessionId = mySessionId.id; // Try to reconnect our session to the console diff --git a/win/vncconfig/Connections.h b/win/vncconfig/Connections.h index 209e4fd8..6176f3dc 100644 --- a/win/vncconfig/Connections.h +++ b/win/vncconfig/Connections.h @@ -117,11 +117,11 @@ namespace rfb { case IDC_HOSTS: { DWORD selected = SendMessage(GetDlgItem(handle, IDC_HOSTS), LB_GETCURSEL, 0, 0); - int count = SendMessage(GetDlgItem(handle, IDC_HOSTS), LB_GETCOUNT, 0, 0); - bool enable = selected != LB_ERR; + DWORD count = SendMessage(GetDlgItem(handle, IDC_HOSTS), LB_GETCOUNT, 0, 0); + bool enable = selected != (DWORD)LB_ERR; enableItem(IDC_HOST_REMOVE, enable); enableItem(IDC_HOST_UP, enable && (selected > 0)); - enableItem(IDC_HOST_DOWN, enable && (selected < count-1)); + enableItem(IDC_HOST_DOWN, enable && (selected+1 < count)); enableItem(IDC_HOST_EDIT, enable); setChanged(isChanged()); } |