]> git.proxmox.com Git - spiceterm.git/commitdiff
code cleanup - compile with -Wall
authorDietmar Maurer <dietmar@proxmox.com>
Tue, 10 Sep 2013 11:05:05 +0000 (13:05 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 10 Sep 2013 11:05:05 +0000 (13:05 +0200)
Makefile
basic_event_loop.c
glyphs.h
spiceterm.c
test_display_base.c
test_display_base.h

index a7a945d88fb185c6b93f6960c7403a9ce5a142f5..fb1a12ea740fc8ae1d4a6d247470e416f66ab7f1 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ SOURCES=test_display_base.c basic_event_loop.c
 all: ${PROGRAMS}
 
 spiceterm: ${SOURCES} ${HEADERS} spiceterm.c 
-       gcc ${SOURCES} spiceterm.c -o $@ -lutil $(shell pkg-config --cflags gdk-3.0) $(shell pkg-config --cflags --libs gthread-2.0,spice-protocol,spice-server)
+       gcc -Werror -Wall -Wtype-limits  ${SOURCES} spiceterm.c -o $@ -lutil $(shell pkg-config --cflags gdk-3.0) $(shell pkg-config --cflags --libs gthread-2.0,spice-protocol,spice-server)
 
 .PHONY: test
 test: spiceterm
index 39e42702f28f753dfe5e173868f1146919f59cb6..5affa34504ad91e74d8b1ac1512b22fc7f4a8f38 100644 (file)
@@ -179,7 +179,7 @@ static void watch_remove(SpiceWatch *watch)
 
 static void channel_event(int event, SpiceChannelEventInfo *info)
 {
-    DPRINTF(0, "channel event con, type, id, event: %ld, %d, %d, %d",
+    DPRINTF(0, "channel event con, type, id, event: %d, %d, %d, %d",
             info->connection_id, info->type, info->id, event);
 }
 
index 72038094308a9507aefa463a4bf0ac0c21255ca7..7a8253c7e1848ae248096f5d49805788ea73992d 100644 (file)
--- a/glyphs.h
+++ b/glyphs.h
@@ -1,6 +1,6 @@
-static int vt_font_size = 850;
+int vt_font_size = 850;
 
-static unsigned char vt_font_data[] = {
+unsigned char vt_font_data[] = {
        /* 0 0x00 */
        0x00, /* 00000000 */
        0x00, /* 00000000 */
@@ -15303,7 +15303,7 @@ static unsigned char vt_font_data[] = {
 
 };
 
-static unsigned short vt_fontmap[65536] = {
+unsigned short vt_fontmap[65536] = {
        /* 0x0000 => */ 0,
        /* 0x0001 => */ 0,
        /* 0x0002 => */ 0,
index 4113654a67bdae1e91e6b3b841f11df9677baca8..2798fa8e8c5bedb96620fa98fbf20660d1993127 100644 (file)
@@ -22,6 +22,8 @@
 
 */
 
+#define _GNU_SOURCE  
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -38,7 +40,7 @@
 #include <locale.h>
 
 #include "spiceterm.h"
-#include "glyphs.h"
+//#include "glyphs.h"
 
 #include <glib.h>
 #include <spice.h>
@@ -64,8 +66,6 @@
 
 /* these colours are from linux kernel drivers/char/vt.c */
 
-static int idle_timeout = 1;
-
 unsigned char color_table[] = { 0, 4, 2, 6, 1, 5, 3, 7,
                                8,12,10,14, 9,13,11,15 };
 
@@ -78,6 +78,7 @@ print_usage (const char *msg)
 }
 
 /* Convert UCS2 to UTF8 sequence, trailing zero */
+/*
 static int
 ucs2_to_utf8 (unicode c, char *out)
 {
@@ -100,7 +101,7 @@ ucs2_to_utf8 (unicode c, char *out)
 
   return 0;
 }
-
+*/
 
 static void
 draw_char_at (vncTerm *vt, int x, int y, unicode ch, TextAttributes attrib)
@@ -109,10 +110,7 @@ draw_char_at (vncTerm *vt, int x, int y, unicode ch, TextAttributes attrib)
         return;
     }
 
-
-    int ec = vt_fontmap[ch];
-
-    test_draw_update_char(vt->screen, x, y, ec, attrib);
+    test_draw_update_char(vt->screen, x, y, ch, attrib);
 }
 
 static void
@@ -1269,6 +1267,7 @@ vncterm_set_xcut_text (char* str, int len, struct _rfbClientRec* cl)
   vt->selection_len = len;
 }
 */
+/*
 static void
 mouse_report (vncTerm *vt, int butt, int mrx, int mry)
 {
@@ -1279,14 +1278,15 @@ mouse_report (vncTerm *vt, int butt, int mrx, int mry)
 
   vncterm_respond_esc (vt, buf);
 }
+*/
 
 void
 vncterm_toggle_marked_cell (vncTerm *vt, int pos)
 {
-  int x= (pos%vt->width)*8;
-  int y= (pos/vt->width)*16;
 
 /* fixme:
+  int x= (pos%vt->width)*8;
+  int y= (pos/vt->width)*16;
 
   int i,j;
   rfbScreenInfoPtr s=vt->screen;
@@ -1437,14 +1437,9 @@ vncterm_pointer_event (int buttonMask, int x, int y, rfbClientPtr cl)
 }
 */
 
-static int client_count = 0;
-static int client_connected = 0;
-static int last_client = 1;
-static time_t last_time = 0;
-
 static void my_kbd_push_key(SpiceKbdInstance *sin, uint8_t frag)
 {
-    vncTerm *vt = SPICE_CONTAINEROF(sin, vncTerm, keyboard_sin);
+    // vncTerm *vt = SPICE_CONTAINEROF(sin, vncTerm, keyboard_sin);
 
     /* we no not need this */
 
@@ -1741,9 +1736,6 @@ main (int argc, char** argv)
   int pid;
   int master;
   char ptyname[1024];
-  fd_set fs, fs1;
-  struct timeval tv, tv1;
-  time_t elapsed, cur_time;
   struct winsize dimensions;
 
   g_thread_init(NULL);
@@ -1758,6 +1750,8 @@ main (int argc, char** argv)
     }
   }
 
+  if (0) print_usage(NULL); // fixme:
+
   vncTerm *vt = create_vncterm (argc, argv, 745, 400);
 
   setlocale(LC_ALL, ""); // set from environment
index e6c91fe866b1255c0891a3d60a722e1643ed2dfa..7551d127bff7f99004912d72e13020d4e40f7f98 100644 (file)
@@ -56,11 +56,11 @@ static void test_spice_destroy_update(SimpleSpiceUpdate *update)
 #define DEFAULT_WIDTH 640
 #define DEFAULT_HEIGHT 320
 
-#define SINGLE_PART 4
-static const int angle_parts = 64 / SINGLE_PART;
+//#define SINGLE_PART 4
+//static const int angle_parts = 64 / SINGLE_PART;
 static int unique = 1;
-static int color = -1;
-static int c_i = 0;
+//static int color = -1;
+//static int c_i = 0;
 
 __attribute__((noreturn))
 static void sigchld_handler(int signal_num) // wait for the child process and exit
@@ -388,9 +388,9 @@ ret:
 
 static int req_cmd_notification(QXLInstance *qin)
 {
-    Test *test = SPICE_CONTAINEROF(qin, Test, qxl_instance);
-
+    //Test *test = SPICE_CONTAINEROF(qin, Test, qxl_instance);
     //test->core->timer_start(test->wakeup_timer, test->wakeup_ms);
+
     return TRUE;
 }
 
@@ -450,7 +450,6 @@ static void cursor_init()
 static int get_cursor_command(QXLInstance *qin, struct QXLCommandExt *ext)
 {
     Test *test = SPICE_CONTAINEROF(qin, Test, qxl_instance);
-    static int color = 0;
     static int set = 1;
     static int x = 0, y = 0;
     QXLCursorCmd *cursor_cmd;
@@ -553,7 +552,7 @@ static void client_disconnected(Test *test)
 
 static void do_conn_timeout(void *opaque)
 {
-    Test *test = opaque;
+    // Test *test = opaque;
 
     if (client_count <= 0) {
         printf("do_conn_timeout\n");
@@ -631,8 +630,6 @@ void test_add_agent_interface(SpiceServer *server)
     spice_server_add_interface(server, &vdagent_sin.base);
 }
 
-static int my_charcode = 65;
-static int my_posx = 0;
 static void kbd_push_key(SpiceKbdInstance *sin, uint8_t frag)
 {
     Test *test = SPICE_CONTAINEROF(sin, Test, keyboard_sin);
@@ -641,7 +638,7 @@ static void kbd_push_key(SpiceKbdInstance *sin, uint8_t frag)
 
 }
 
-void test_draw_update_char(Test *test, int x, int y, int c, TextAttributes attrib)
+void test_draw_update_char(Test *test, int x, int y, gunichar ch, TextAttributes attrib)
 {
     int fg, bg;
 
@@ -663,6 +660,8 @@ void test_draw_update_char(Test *test, int x, int y, int c, TextAttributes attri
     //rfbDrawLine (vt->screen, rx, ry + 14, rxe, ry + 14, fg);
     //}
 
+    int c = vt_fontmap[ch];
+
     SimpleSpiceUpdate *update;
     update = test_draw_char(test, x, y, c, fg, bg);
     push_command(test, &update->ext);
@@ -718,7 +717,6 @@ Test *test_new(SpiceCoreInterface *core)
     }
 
     cursor_init();
-    test->has_secondary = 0;
 
     int timeout = 10; // max time to wait for client connection
     test->conn_timeout_timer = core->timer_add(do_conn_timeout, test);
index a4f8ab12ac540a530edc1777eb9f2b62559abb79..4dde4d24c691528b6bf02d918b5a3ab4282ab950 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <glib.h>
 #include <spice.h>
+
 #include "basic_event_loop.h"
 
 
@@ -18,82 +19,13 @@ typedef struct TextAttributes {
 
 #define COUNT(x) ((sizeof(x)/sizeof(x[0])))
 
-/*
- * simple queue for commands.
- * each command can have up to two parameters (grow as needed)
- *
- * TODO: switch to gtk main loop. Then add gobject-introspection. then
- * write tests in python/guile/whatever.
- */
-typedef enum {
-    PATH_PROGRESS,
-    SIMPLE_CREATE_SURFACE,
-    SIMPLE_DRAW,
-    SIMPLE_DRAW_BITMAP,
-    SIMPLE_DRAW_SOLID,
-    SIMPLE_COPY_BITS,
-    SIMPLE_DESTROY_SURFACE,
-    SIMPLE_UPDATE,
-    DESTROY_PRIMARY,
-    CREATE_PRIMARY,
-    SLEEP
-} CommandType;
-
-typedef struct CommandCreatePrimary {
-    uint32_t width;
-    uint32_t height;
-} CommandCreatePrimary;
-
-typedef struct CommandCreateSurface {
-    uint32_t surface_id;
-    uint32_t format;
-    uint32_t width;
-    uint32_t height;
-    uint8_t *data;
-} CommandCreateSurface;
-
-typedef struct CommandDrawBitmap {
-    QXLRect bbox;
-    uint8_t *bitmap;
-    uint32_t surface_id;
-    uint32_t num_clip_rects;
-    QXLRect *clip_rects;
-} CommandDrawBitmap;
-
-typedef struct CommandDrawSolid {
-    QXLRect bbox;
-    uint32_t color;
-    uint32_t surface_id;
-} CommandDrawSolid;
-
-typedef struct CommandSleep {
-    uint32_t secs;
-} CommandSleep;
-
-typedef struct Command Command;
 typedef struct Test Test;
 
-struct Command {
-    CommandType command;
-    void (*cb)(Test *test, Command *command);
-    void *cb_opaque;
-    union {
-        CommandCreatePrimary create_primary;
-        CommandDrawBitmap bitmap;
-        CommandDrawSolid solid;
-        CommandSleep sleep;
-        CommandCreateSurface create_surface;
-    };
-};
-
 #define COMMANDS_SIZE 1024
 
 #define MAX_HEIGHT 2048
 #define MAX_WIDTH 2048
 
-#define SURF_WIDTH 320
-#define SURF_HEIGHT 240
-
 struct Test {
     SpiceCoreInterface *core;
     SpiceServer *server;
@@ -112,9 +44,6 @@ struct Test {
 
     int cursor_notify;
 
-    uint8_t secondary_surface[SURF_WIDTH * SURF_HEIGHT * 4];
-    int has_secondary;
-
     // Current mode (set by create_primary)
     int width;
     int height;
@@ -138,7 +67,7 @@ void test_add_agent_interface(SpiceServer *server); // TODO - Test *test
 void test_add_keyboard_interface(Test *test);
 Test* test_new(SpiceCoreInterface* core);
 
-void test_draw_update_char(Test *test, int x, int y, int c, TextAttributes attrib);
+void test_draw_update_char(Test *test, int x, int y, gunichar ch, TextAttributes attrib);
 void test_spice_scroll(Test *test, int x1, int y1, int x2, int y2, int src_x, int src_y);
 void test_spice_clear(Test *test, int x1, int y1, int x2, int y2);