[Spice-commits] 3 commits - server/main_channel.c server/mjpeg_encoder.c

Alon Levy alon at kemper.freedesktop.org
Thu Nov 10 06:54:06 PST 2011


 server/main_channel.c  |   17 +++++++++++++----
 server/mjpeg_encoder.c |    4 ++--
 2 files changed, 15 insertions(+), 6 deletions(-)

New commits:
commit 2548cd713d1ec073e9c4fbae6264c5abb6f6c8f4
Author: Alon Levy <alevy at redhat.com>
Date:   Thu Nov 10 16:29:13 2011 +0200

    server/mjpeg_encoder: use size_t * consistently
    
    fix another 64 bit-ism. unsigned long != size_t in general.

diff --git a/server/mjpeg_encoder.c b/server/mjpeg_encoder.c
index 4b1023a..599d4f5 100644
--- a/server/mjpeg_encoder.c
+++ b/server/mjpeg_encoder.c
@@ -104,7 +104,7 @@ typedef struct {
   struct jpeg_destination_mgr pub; /* public fields */
 
   unsigned char ** outbuffer;	/* target buffer */
-  unsigned long * outsize;
+  size_t * outsize;
   unsigned char * newbuffer;	/* newly allocated buffer */
   uint8_t * buffer;		/* start of buffer */
   size_t bufsize;
@@ -164,7 +164,7 @@ static void term_mem_destination(j_compress_ptr cinfo)
 
 static void
 spice_jpeg_mem_dest(j_compress_ptr cinfo,
-                    unsigned char ** outbuffer, unsigned long * outsize)
+                    unsigned char ** outbuffer, size_t * outsize)
 {
   mem_destination_mgr *dest;
 #define OUTPUT_BUF_SIZE  4096	/* choose an efficiently fwrite'able size */
commit 6d89b2ba4c6e29a4e40cfb15073e92aa47955f5e
Author: Alon Levy <alevy at redhat.com>
Date:   Thu Nov 10 16:28:07 2011 +0200

    server/main_channel: fix pointer-to-int-cast error
    
    64 bit-ism removed.

diff --git a/server/main_channel.c b/server/main_channel.c
index 0ce3b48..4b5b669 100644
--- a/server/main_channel.c
+++ b/server/main_channel.c
@@ -213,13 +213,18 @@ static PipeItem *main_ping_item_new(MainChannelClient *mcc, int size)
     return &item->base;
 }
 
+typedef struct MainTokensItemInfo {
+    uint32_t num_tokens;
+} MainTokensItemInfo;
+
 static PipeItem *main_tokens_item_new(RedChannelClient *rcc, void *data, int num)
 {
     TokensPipeItem *item = spice_malloc(sizeof(TokensPipeItem));
+    MainTokensItemInfo *init = data;
 
     red_channel_pipe_item_init(rcc->channel, &item->base,
                                SPICE_MSG_MAIN_AGENT_TOKEN);
-    item->tokens = (uint64_t)data;
+    item->tokens = init->num_tokens;
     return &item->base;
 }
 
@@ -387,8 +392,10 @@ static void main_channel_marshall_agent_disconnected(SpiceMarshaller *m)
 // TODO: make this targeted (requires change to agent token accounting)
 void main_channel_push_tokens(MainChannel *main_chan, uint32_t num_tokens)
 {
+    MainTokensItemInfo init = {.num_tokens = num_tokens};
+
     red_channel_pipes_new_add_push(&main_chan->base,
-        main_tokens_item_new, (void*)(uint64_t)num_tokens);
+        main_tokens_item_new, &init);
 }
 
 static void main_channel_marshall_tokens(SpiceMarshaller *m, uint32_t num_tokens)
commit ebfa95cd4777ce3f0fcf3b6866bd30f643854809
Author: Alon Levy <alevy at redhat.com>
Date:   Thu Nov 10 16:25:18 2011 +0200

    server/main_channel: use PRIu64 where needed

diff --git a/server/main_channel.c b/server/main_channel.c
index 24cdaea..0ce3b48 100644
--- a/server/main_channel.c
+++ b/server/main_channel.c
@@ -19,6 +19,7 @@
 #include <config.h>
 #endif
 
+#include <inttypes.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -802,13 +803,14 @@ static int main_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, uint
                 if (roundtrip <= mcc->latency) {
                     // probably high load on client or server result with incorrect values
                     mcc->latency = 0;
-                    red_printf("net test: invalid values, latency %lu roundtrip %lu. assuming high"
+                    red_printf("net test: invalid values, latency %" PRIu64
+                               " roundtrip %" PRIu64 ". assuming high"
                                "bandwidth", mcc->latency, roundtrip);
                     break;
                 }
                 mcc->bitrate_per_sec = (uint64_t)(NET_TEST_BYTES * 8) * 1000000
                                         / (roundtrip - mcc->latency);
-                red_printf("net test: latency %f ms, bitrate %lu bps (%f Mbps)%s",
+                red_printf("net test: latency %f ms, bitrate %"PRIu64" bps (%f Mbps)%s",
                            (double)mcc->latency / 1000,
                            mcc->bitrate_per_sec,
                            (double)mcc->bitrate_per_sec / 1024 / 1024,


More information about the Spice-commits mailing list