[Spice-devel] [PATCH 12/24] mingw32 build: fix signed/unsigned warnings as errors

Alon Levy alevy at redhat.com
Tue Dec 7 13:28:11 PST 2010


---
 client/application.cpp      |    4 ++--
 client/cmd_line_parser.cpp  |    2 +-
 client/display_channel.cpp  |    2 +-
 client/hot_keys.cpp         |    2 +-
 client/mjpeg_decoder.cpp    |    2 +-
 client/mjpeg_decoder.h      |    6 +++---
 client/process_loop.cpp     |    6 +++---
 client/process_loop.h       |    4 ++--
 client/red_client.cpp       |    4 ++--
 client/red_peer.cpp         |    2 +-
 client/tunnel_channel.h     |    2 +-
 client/windows/platform.cpp |   12 ++++++------
 common/canvas_base.c        |    8 ++++----
 common/lz.c                 |    2 +-
 common/sw_canvas.c          |    4 ++--
 15 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/client/application.cpp b/client/application.cpp
index a484bbc..3f1ae71 100644
--- a/client/application.cpp
+++ b/client/application.cpp
@@ -1233,7 +1233,7 @@ ModifierKey modifier_keys[] = {
 void Application::sync_keyboard_modifiers()
 {
     uint32_t modifiers = Platform::get_keyboard_modifiers();
-    for (int i = 0; i < sizeof(modifier_keys) / sizeof(modifier_keys[0]); i++) {
+    for (size_t i = 0; i < sizeof(modifier_keys) / sizeof(modifier_keys[0]); i++) {
         if (modifiers & modifier_keys[i].modifier) {
             on_key_down(modifier_keys[i].key);
         } else {
@@ -2012,7 +2012,7 @@ bool Application::set_host_cert_subject(const char* subject, const char* arg0)
     while (true) {
         if ((iter == subject_str.end()) || (*iter == ',')) {
             RedPeer::HostAuthOptions::CertFieldValuePair entry_pair;
-            int value_pos = entry.find_first_of('=');
+            size_t value_pos = entry.find_first_of('=');
             if ((value_pos == std::string::npos) || (value_pos == (entry.length() - 1))) {
                 Platform::term_printf("%s: host_subject bad format: assignment for %s is missing\n",
                                       arg0, entry.c_str());
diff --git a/client/cmd_line_parser.cpp b/client/cmd_line_parser.cpp
index a813629..963250b 100644
--- a/client/cmd_line_parser.cpp
+++ b/client/cmd_line_parser.cpp
@@ -436,7 +436,7 @@ char* CmdLineParser::next_argument()
 void CmdLineParser::show_help()
 {
     static const int HELP_START_POS = 30;
-    static const int HELP_WIDTH = 80 - HELP_START_POS;
+    static const unsigned HELP_WIDTH = 80 - HELP_START_POS;
     std::ostringstream os;
 
     os << _argv[0] << " - " << _description.c_str() << "\n\noptions:\n\n";
diff --git a/client/display_channel.cpp b/client/display_channel.cpp
index 1d5ebf3..5717834 100644
--- a/client/display_channel.cpp
+++ b/client/display_channel.cpp
@@ -363,7 +363,7 @@ void VideoStream::remove_dead_frames(uint32_t mm_time)
 void VideoStream::drop_one_frame()
 {
     ASSERT(MAX_VIDEO_FRAMES > 2 && (_frames_head - _frames_tail) == MAX_VIDEO_FRAMES);
-    int frame_index = _frames_head - _kill_mark++ % (MAX_VIDEO_FRAMES - 2) - 2;
+    unsigned frame_index = _frames_head - _kill_mark++ % (MAX_VIDEO_FRAMES - 2) - 2;
 
     free_frame(frame_index);
 
diff --git a/client/hot_keys.cpp b/client/hot_keys.cpp
index d6564b7..60b58a4 100644
--- a/client/hot_keys.cpp
+++ b/client/hot_keys.cpp
@@ -114,7 +114,7 @@ void HotKeysParser::add_key(HotkeySet& keys, const char* key)
         { "f12", REDKEY_F12, REDKEY_INVALID }
     };
 
-    for (int i = 0; i < (sizeof(keyboard) / sizeof(keyboard[0])); ++i) {
+    for (unsigned i = 0; i < (sizeof(keyboard) / sizeof(keyboard[0])); ++i) {
         if (strcasecmp(key, keyboard[i].name) == 0) {
             HotkeyKey hotkey;
             hotkey.main = keyboard[i].main;
diff --git a/client/mjpeg_decoder.cpp b/client/mjpeg_decoder.cpp
index f9cb603..bad90d4 100644
--- a/client/mjpeg_decoder.cpp
+++ b/client/mjpeg_decoder.cpp
@@ -108,7 +108,7 @@ void MJpegDecoder::convert_scanline(void)
     uint32_t *row;
     uint32_t c;
     uint8_t *s;
-    int x;
+    unsigned x;
 
     ASSERT(_width % 2 == 0);
     ASSERT(_height % 2 == 0);
diff --git a/client/mjpeg_decoder.h b/client/mjpeg_decoder.h
index ccafd37..8455e0d 100644
--- a/client/mjpeg_decoder.h
+++ b/client/mjpeg_decoder.h
@@ -59,13 +59,13 @@ private:
     size_t _data_end;
     size_t _extra_skip;
 
-    int _width;
-    int _height;
+    unsigned _width;
+    unsigned _height;
     int _stride;
     uint8_t *_frame;
     bool _back_compat;
 
-    int _y;
+    unsigned _y;
     uint8_t *_scanline;
 
     int _state;
diff --git a/client/process_loop.cpp b/client/process_loop.cpp
index ec9cdd2..d7e6744 100644
--- a/client/process_loop.cpp
+++ b/client/process_loop.cpp
@@ -221,7 +221,7 @@ void TimersQueue::deactivate_interval_timer(Timer* timer)
     }
 }
 
-int TimersQueue::get_soonest_timeout()
+unsigned int TimersQueue::get_soonest_timeout()
 {
     RecurciveLock lock(_timers_lock);
     TimersSet::iterator iter;
@@ -236,7 +236,7 @@ int TimersQueue::get_soonest_timeout()
     if (next_time <= now) {
         return 0;
     }
-    return (int)(next_time - now);
+    return (next_time - now);
 }
 
 
@@ -392,7 +392,7 @@ void ProcessLoop::deactivate_interval_timer(Timer* timer)
     _timers_queue.deactivate_interval_timer(timer);
 }
 
-int ProcessLoop::get_soonest_timeout()
+unsigned ProcessLoop::get_soonest_timeout()
 {
     return _timers_queue.get_soonest_timeout();
 }
diff --git a/client/process_loop.h b/client/process_loop.h
index 2d355f7..33ca2d1 100644
--- a/client/process_loop.h
+++ b/client/process_loop.h
@@ -165,7 +165,7 @@ public:
     void activate_interval_timer(Timer* timer, unsigned int millisec);
     void deactivate_interval_timer(Timer* timer);
 
-    int get_soonest_timeout();
+    unsigned int get_soonest_timeout();
     void timers_action();
 
 private:
@@ -207,7 +207,7 @@ public:
     void process_events_queue();
     /* can be used for handling timers in modal loop state in Windows (mainly,
        for updating the screen) */
-    int get_soonest_timeout();
+    unsigned int get_soonest_timeout();
     void timers_action();
 
     void* get_owner() { return _owner;}
diff --git a/client/red_client.cpp b/client/red_client.cpp
index e1f5a42..4923f29 100644
--- a/client/red_client.cpp
+++ b/client/red_client.cpp
@@ -770,8 +770,8 @@ void RedClient::calc_pixmap_cach_and_glz_window_size(uint32_t display_channels_h
 {
 #ifdef WIN32
     display_channels_hint = MAX(1, display_channels_hint);
-    int max_cache_size = display_channels_hint * MAX_DISPLAY_PIXMAP_CACHE;
-    int min_cache_size = display_channels_hint * MIN_DISPLAY_PIXMAP_CACHE;
+    uint64_t max_cache_size = display_channels_hint * MAX_DISPLAY_PIXMAP_CACHE;
+    uint64_t min_cache_size = display_channels_hint * MIN_DISPLAY_PIXMAP_CACHE;
 
     MEMORYSTATUSEX mem_status;
     mem_status.dwLength = sizeof(mem_status);
diff --git a/client/red_peer.cpp b/client/red_peer.cpp
index 88fc9ad..08176d0 100644
--- a/client/red_peer.cpp
+++ b/client/red_peer.cpp
@@ -364,7 +364,7 @@ bool RedPeer::verify_subject(X509* cert, const HostAuthOptions::CertFieldValueLi
         return false;
     }
 
-    if (X509_NAME_entry_count(cert_subject) != subject.size()) {
+    if ((size_t)X509_NAME_entry_count(cert_subject) != subject.size()) {
         DBG(0, "subject mismatch: #entries cert=%d, input=%d",
             X509_NAME_entry_count(cert_subject), subject.size());
         return false;
diff --git a/client/tunnel_channel.h b/client/tunnel_channel.h
index 553d49b..63174d8 100644
--- a/client/tunnel_channel.h
+++ b/client/tunnel_channel.h
@@ -133,7 +133,7 @@ private:
     int _in_msg_len;
 
     std::string _out_msg;  // <virtual ip>\n
-    int _out_msg_pos;
+    unsigned _out_msg_pos;
 };
 #endif
 
diff --git a/client/windows/platform.cpp b/client/windows/platform.cpp
index 1676000..06d5aa0 100644
--- a/client/windows/platform.cpp
+++ b/client/windows/platform.cpp
@@ -108,7 +108,7 @@ void Platform::send_quit_request()
 static uint32_t get_clipboard_type(uint32_t format) {
     uint32_t* types = NULL;
 
-    for (int i = 0; i < clipboard_formats_count && !types; i++) {
+    for (size_t i = 0; i < clipboard_formats_count && !types; i++) {
         if (clipboard_formats[i].format == format) {
             types = clipboard_formats[i].types;
         }
@@ -125,7 +125,7 @@ static uint32_t get_clipboard_type(uint32_t format) {
 }
 
 static uint32_t get_clipboard_format(uint32_t type) {
-    for (int i = 0; i < clipboard_formats_count; i++) {
+    for (size_t i = 0; i < clipboard_formats_count; i++) {
         for (uint32_t* ptype = clipboard_formats[i].types; *ptype; ptype++) {
             if (*ptype == type) {
                 return clipboard_formats[i].format; 
@@ -140,7 +140,7 @@ static int get_available_clipboard_types(uint32_t** types)
     int count = 0;
 
     *types = new uint32_t[clipboard_formats_count * CLIPBOARD_FORMAT_MAX_TYPES];
-    for (int i = 0; i < clipboard_formats_count; i++) {
+    for (size_t i = 0; i < clipboard_formats_count; i++) {
         if (IsClipboardFormatAvailable(clipboard_formats[i].format)) {
             for (uint32_t* ptype = clipboard_formats[i].types; *ptype; ptype++) {
                 (*types)[count++] = *ptype;
@@ -156,7 +156,7 @@ static int get_available_clipboard_types(uint32_t** types)
 
 static DWORD get_cximage_format(uint32_t type)
 {
-    for (int i = 0; i < sizeof(image_types) / sizeof(image_types[0]); i++) {
+    for (size_t i = 0; i < sizeof(image_types) / sizeof(image_types[0]); i++) {
         if (image_types[i].type == type) {
             return image_types[i].cximage_format;
         }
@@ -503,7 +503,7 @@ bool WinMonitor::best_display_setting(uint32_t width, uint32_t height, uint32_t
             }
         }
     }
-    if (mod_waste == ~0) {
+    if (mod_waste == ~0u) {
         return false;
     }
     mode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY;
@@ -882,7 +882,7 @@ void WinPlatform::enter_modal_loop()
 
 static bool set_modal_loop_timer()
 {
-    int timeout = main_loop->get_soonest_timeout();
+    unsigned timeout = main_loop->get_soonest_timeout();
     if (timeout == INFINITE) {
         timeout = MODAL_LOOP_DEFAULT_TIMEOUT; /* for cases timeouts are added after
                                                  the enterance to the loop*/
diff --git a/common/canvas_base.c b/common/canvas_base.c
index c2763bc..6d101f4 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -146,7 +146,7 @@ typedef struct QuicData {
     jmp_buf jmp_env;
     char message_buf[512];
     SpiceChunks *chunks;
-    int current_chunk;
+    uint32_t current_chunk;
 } QuicData;
 
 typedef struct CanvasBase {
@@ -809,8 +809,8 @@ static pixman_image_t *canvas_get_lz(CanvasBase *canvas, SpiceImage *image, int
         CANVAS_ERROR("unexpected LZ image type");
     }
 
-    ASSERT(width == image->descriptor.width);
-    ASSERT(height == image->descriptor.height);
+    ASSERT((unsigned)width == image->descriptor.width);
+    ASSERT((unsigned)height == image->descriptor.height);
 
     ASSERT((image->descriptor.type == SPICE_IMAGE_TYPE_LZ_PLT) || (n_comp_pixels == width * height));
 #ifdef WIN32
@@ -3309,7 +3309,7 @@ static void unimplemented_op(SpiceCanvas *canvas)
 inline static void canvas_base_init_ops(SpiceCanvasOps *ops)
 {
     void **ops_cast;
-    int i;
+    unsigned i;
 
     ops_cast = (void **)ops;
     for (i = 0; i < sizeof(SpiceCanvasOps) / sizeof(void *); i++) {
diff --git a/common/lz.c b/common/lz.c
index e563584..d0d9511 100644
--- a/common/lz.c
+++ b/common/lz.c
@@ -633,7 +633,7 @@ void lz_decode(LzContext *lz, LzImageType to_type, uint8_t *buf)
     Encoder *encoder = (Encoder *)lz;
     size_t out_size = 0;
     size_t alpha_size = 0;
-    int size = 0;
+    size_t size = 0;
     if (IS_IMAGE_TYPE_PLT[encoder->type]) {
         if (to_type == encoder->type) {
             size = encoder->height * encoder->stride;
diff --git a/common/sw_canvas.c b/common/sw_canvas.c
index f579b4c..37083df 100644
--- a/common/sw_canvas.c
+++ b/common/sw_canvas.c
@@ -976,8 +976,8 @@ static void canvas_put_image(SpiceCanvas *spice_canvas,
 {
     SwCanvas *canvas = (SwCanvas *)spice_canvas;
     pixman_image_t *src;
-    int dest_width;
-    int dest_height;
+    uint32_t dest_width;
+    uint32_t dest_height;
     double sx, sy;
     pixman_transform_t transform;
 
-- 
1.7.3.2



More information about the Spice-devel mailing list