dvtm

dynamic virtual terminal manager - with my changes
git clone https://pi.duncano.de/git/dvtm.git
Log | Files | Refs | README | LICENSE

commit 60f402c3a145fc250b718827713da7e4709beaa1
parent d0de571c5040139bc360a12a6903fccb2065c0b1
Author: Marc Andre Tanner <mat@brain-dump.org>
Date:   Sat, 14 May 2011 14:52:31 +0200

Fix some signed/unsigned comparison problems

Signed-off-by: Marc Andre Tanner <mat@brain-dump.org>

Diffstat:
cmdfifo.c | 2+-
dvtm.c | 26+++++++++++++-------------
madtty.c | 4++--
mouse.c | 5++---
statusbar.c | 2+-
5 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/cmdfifo.c b/cmdfifo.c @@ -25,7 +25,7 @@ static char *get_realpath(const char *path) { static Cmd * get_cmd_by_name(const char *name) { - for (int i = 0; i < countof(commands); i++) { + for (unsigned int i = 0; i < countof(commands); i++) { if (!strcmp(name, commands[i].name)) return &commands[i]; } diff --git a/dvtm.c b/dvtm.c @@ -47,10 +47,10 @@ struct Client { #ifdef CONFIG_CMDFIFO unsigned short int id; #endif - short int x; - short int y; - short int w; - short int h; + unsigned short int x; + unsigned short int y; + unsigned short int w; + unsigned short int h; bool minimized; bool died; Client *next; @@ -487,7 +487,7 @@ draw_border(Client *c) { o = c->w - (4 + sstrlen(TITLE) - 5 + sstrlen(SEPARATOR)); if (o < 0) o = 0; - if (o < sizeof(c->title)) { + if ((size_t)o < sizeof(c->title)) { t = *(s = &c->title[o]); *s = '\0'; } @@ -520,8 +520,7 @@ draw(Client *c) { static void clear_workspace() { - unsigned int y; - for (y = 0; y < wah; y++) + for (unsigned int y = 0; y < wah; y++) mvhline(way + y, 0, ' ', waw); wnoutrefresh(stdscr); } @@ -575,7 +574,8 @@ escapekey(const char *args[]) { static void lock(const char *args[]) { size_t len = 0, i = 0; - char buf[16], *pass = buf, c; + char buf[16], *pass = buf; + int c; erase(); curs_set(0); @@ -849,7 +849,7 @@ resize_screen() { static void startup(const char *args[]) { - for (int i = 0; i < countof(actions); i++) + for (unsigned int i = 0; i < countof(actions); i++) actions[i].cmd(actions[i].args); } @@ -953,7 +953,7 @@ parse_args(int argc, char *argv[]) { char *mod = argv[++arg]; if (mod[0] == '^' && mod[1]) *mod = CTRL(mod[1]); - for (int i = 0; i < countof(keys); i++) + for (unsigned int i = 0; i < countof(keys); i++) keys[i].mod = *mod; break; } @@ -991,14 +991,14 @@ parse_args(int argc, char *argv[]) { void keypress(int code) { Client *c; - int len = 1; + unsigned int len = 1; char buf[8] = { '\e' }; if (code == '\e') { /* pass characters following escape to the underlying app */ nodelay(stdscr, TRUE); - while (len < sizeof(buf) - 1 && (buf[len] = getch()) != ERR) - len++; + for (int t; len < sizeof(buf) - 1 && (t = getch()) != ERR; len++) + buf[len] = t; buf[len] = '\0'; nodelay(stdscr, FALSE); } diff --git a/madtty.c b/madtty.c @@ -53,7 +53,7 @@ #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) #define min(x, y) ((x) < (y) ? (x) : (y)) #define COLOR_PALETTE_START 1 -#define COLOR_PALETTE_END min(512, COLOR_PAIRS) +#define COLOR_PALETTE_END (unsigned)(min(512, COLOR_PAIRS)) static bool is_utf8, has_default_colors, use_color_palette; static short *color2palette; @@ -1542,7 +1542,7 @@ static void init_colors(void) use_color_palette = true; color2palette = calloc((COLORS+1)*(COLORS+1), sizeof(short)); int bg = 0, fg = 0; - for (int i = COLOR_PALETTE_START; i < COLOR_PALETTE_END; i++) { + for (unsigned int i = COLOR_PALETTE_START; i < COLOR_PALETTE_END; i++) { init_pair(i, fg, bg); color2palette[color_hash(fg, bg)] = i; if (++fg == COLORS) { diff --git a/mouse.c b/mouse.c @@ -30,7 +30,7 @@ mouse_zoom(const char *args[]) { } static Client* -get_client_by_coord(int x, int y) { +get_client_by_coord(unsigned int x, unsigned int y) { Client *c; if (y < way || y >= wah) return NULL; @@ -72,9 +72,8 @@ handle_mouse() { static void mouse_setup() { - int i; mmask_t mask = BUTTON1_CLICKED | BUTTON2_CLICKED; - for (i = 0; i < countof(buttons); i++) + for (unsigned int i = 0; i < countof(buttons); i++) mask |= buttons[i].mask; mousemask(mask, NULL); } diff --git a/statusbar.c b/statusbar.c @@ -30,7 +30,7 @@ drawbar() { attrset(BAR_ATTR); madtty_color_set(stdscr, BAR_FG, BAR_BG); mvaddch(by, 0, '['); - if (mbstowcs(wbuf, stext, sizeof stext) == -1) + if (mbstowcs(wbuf, stext, sizeof stext) == (size_t)-1) return; if ((w = wcswidth(wbuf, maxwidth)) == -1) return;