Code

use size_t and unsigned integers
authorMax Kellermann <max@duempel.org>
Mon, 15 Sep 2008 11:27:30 +0000 (13:27 +0200)
committerMax Kellermann <max@duempel.org>
Mon, 15 Sep 2008 11:27:30 +0000 (13:27 +0200)
18 files changed:
src/conf.c
src/list_window.c
src/list_window.h
src/mpdclient.c
src/options.c
src/screen.c
src/screen_browse.h
src/screen_file.c
src/screen_help.c
src/screen_keydef.c
src/screen_lyrics.c
src/screen_play.c
src/screen_search.c
src/src_lyrics.c
src/src_lyrics.h
src/support.c
src/support.h
src/wreadln.c

index 5792dd22fd6f76e5070735cb17df8977545d0fb2..b49eeb2440ad4e920660252f7f63ff0d017470c4 100644 (file)
@@ -94,7 +94,8 @@ str2bool(char *str)
 static int
 parse_key_value(char *str, size_t len, char **end)
 {
-       int i, value;
+       size_t i;
+       int value;
        key_parser_state_t state;
 
        i=0;
@@ -164,8 +165,8 @@ parse_key_definition(char *str)
 {
        char buf[MAX_LINE_LENGTH];
        char *p, *end;
-       size_t len = strlen(str);
-       int i,j,key;
+       size_t len = strlen(str), i;
+       int j,key;
        int keys[MAX_COMMAND_KEYS];
        command_t cmd;
 
@@ -256,8 +257,8 @@ parse_color_definition(char *str)
 {
        char buf[MAX_LINE_LENGTH];
        char *p, *end, *name;
-       size_t len = strlen(str);
-       int i,j,value;
+       size_t len = strlen(str), i;
+       int j,value;
        short color, rgb[3];
 
        /* get the command name */
index 859652c1dcc8410d111c38ff680f7b532a883c30..af8abc9d4c07874b10077448618d05ac63401ae2 100644 (file)
@@ -32,7 +32,7 @@
 extern void screen_bell(void);
 
 list_window_t *
-list_window_init(WINDOW *w, int width, int height)
+list_window_init(WINDOW *w, unsigned width, unsigned height)
 {
        list_window_t *lw;
 
@@ -65,14 +65,11 @@ list_window_reset(list_window_t *lw)
 }
 
 void
-list_window_check_selected(list_window_t *lw, int length)
+list_window_check_selected(list_window_t *lw, unsigned length)
 {
-       while (lw->start && lw->start + lw->rows > length)
+       while (lw->start > 0 && lw->start + lw->rows > length)
                lw->start--;
 
-       if (lw->selected < 0)
-               lw->selected = 0;
-
        while (lw->selected < lw->start)
                lw->selected++;
 
@@ -81,22 +78,22 @@ list_window_check_selected(list_window_t *lw, int length)
 }
 
 void
-list_window_set_selected(list_window_t *lw, int n)
+list_window_set_selected(list_window_t *lw, unsigned n)
 {
        lw->selected = n;
 }
 
 void
-list_window_next(list_window_t *lw, int length)
+list_window_next(list_window_t *lw, unsigned length)
 {
-       if (lw->selected < length - 1)
+       if (lw->selected + 1 < length)
                lw->selected++;
        else if (options.list_wrap)
                lw->selected = 0;
 }
 
 void
-list_window_previous(list_window_t *lw, int length)
+list_window_previous(list_window_t *lw, unsigned length)
 {
        if (lw->selected > 0)
                lw->selected--;
@@ -112,20 +109,22 @@ list_window_first(list_window_t *lw)
 }
 
 void
-list_window_last(list_window_t *lw, int length)
+list_window_last(list_window_t *lw, unsigned length)
 {
        lw->xoffset = 0;
-       lw->selected = length - 1;
+       if (length > 0)
+               lw->selected = length - 1;
+       else
+               lw->selected = 0;
 }
 
 void
-list_window_next_page(list_window_t *lw, int length)
+list_window_next_page(list_window_t *lw, unsigned length)
 {
-       int step = lw->rows - 1;
-       if (step <= 0)
+       if (lw->rows < 2)
                return;
-       if (lw->selected + step < length - 1)
-               lw->selected += step;
+       if (lw->selected + lw->rows < length)
+               lw->selected += lw->rows - 1;
        else
                return list_window_last(lw, length);
 }
@@ -133,11 +132,10 @@ list_window_next_page(list_window_t *lw, int length)
 void
 list_window_previous_page(list_window_t *lw)
 {
-       int step = lw->rows - 1;
-       if (step <= 0)
+       if (lw->rows < 2)
                return;
-       if (lw->selected-step > 0)
-               lw->selected -= step;
+       if (lw->selected > lw->rows - 1)
+               lw->selected -= lw->rows - 1;
        else
                list_window_first(lw);
 }
@@ -148,7 +146,7 @@ list_window_paint(list_window_t *lw,
                  list_window_callback_fn_t callback,
                  void *callback_data)
 {
-       int i;
+       unsigned i;
        int fill = options.wide_cursor;
        int show_cursor = !(lw->flags & LW_HIDE_CURSOR);
 
@@ -206,7 +204,7 @@ list_window_find(list_window_t *lw,
                 int wrap)
 {
        int h;
-       int i = lw->selected + 1;
+       unsigned i = lw->selected + 1;
        const char *label;
 
        while (wrap || i == lw->selected + 1) {
@@ -236,22 +234,22 @@ list_window_rfind(list_window_t *lw,
                  void *callback_data,
                  const char *str,
                  int wrap,
-                 int rows)
+                 unsigned rows)
 {
        int h;
-       int i = lw->selected-1;
+       int i = lw->selected - 1;
        const char *label;
 
        if (rows == 0)
                return 1;
 
-       while (wrap || i == lw->selected - 1) {
+       while (wrap || i == (int)lw->selected - 1) {
                while (i >= 0 && (label = callback(i,&h,callback_data))) {
                        if( str && label && strcasestr(label, str) ) {
                                lw->selected = i;
                                return 0;
                        }
-                       if (wrap && i == lw->selected)
+                       if (wrap && i == (int)lw->selected)
                                return 1;
                        i--;
                }
@@ -265,7 +263,7 @@ list_window_rfind(list_window_t *lw,
 
 /* perform basic list window commands (movement) */
 int
-list_window_cmd(list_window_t *lw, int rows, command_t cmd)
+list_window_cmd(list_window_t *lw, unsigned rows, command_t cmd)
 {
        switch (cmd) {
        case CMD_LIST_PREVIOUS:
index ad66760bb9792bda3d106fd8383af9aaeddb63f5..2fadeebd123510c0450eaf374270aafc5b18ebe1 100644 (file)
 
 #define LW_HIDE_CURSOR    0x01
 
-typedef const char *(*list_window_callback_fn_t)(int index,
+typedef const char *(*list_window_callback_fn_t)(unsigned index,
                                                 int *highlight,
                                                 void *data);
 
 typedef struct {
        WINDOW *w;
-       int rows, cols;
+       unsigned rows, cols;
 
-       int start;
-       int selected;
-       int xoffset;
+       unsigned start;
+       unsigned selected;
+       unsigned xoffset;
        int clear;
        int repaint;
        int flags;
@@ -32,7 +32,7 @@ typedef struct {
 
 
 /* create a new list window */
-list_window_t *list_window_init(WINDOW *w, int width, int height);
+list_window_t *list_window_init(WINDOW *w, unsigned width, unsigned height);
 
 /* destroy a list window (returns NULL) */
 list_window_t *list_window_free(list_window_t *lw);
@@ -46,18 +46,18 @@ void list_window_paint(list_window_t *lw,
                       void *callback_data);
 
 /* perform basic list window commands (movement) */
-int list_window_cmd(list_window_t *lw, int rows, command_t cmd);
+int list_window_cmd(list_window_t *lw, unsigned rows, command_t cmd);
 
 
 /* select functions */
-void list_window_set_selected(list_window_t *lw, int n);
-void list_window_previous(list_window_t *lw, int length);
-void list_window_next(list_window_t *lw, int length);
+void list_window_set_selected(list_window_t *lw, unsigned n);
+void list_window_previous(list_window_t *lw, unsigned length);
+void list_window_next(list_window_t *lw, unsigned length);
 void list_window_first(list_window_t *lw);
-void list_window_last(list_window_t *lw, int length);
+void list_window_last(list_window_t *lw, unsigned length);
 void list_window_previous_page(list_window_t *lw);
-void list_window_next_page(list_window_t *lw, int length);
-void list_window_check_selected(list_window_t *lw, int length);
+void list_window_next_page(list_window_t *lw, unsigned length);
+void list_window_check_selected(list_window_t *lw, unsigned length);
 
 /* find a string in a list window */
 int  list_window_find(list_window_t *lw,
@@ -73,7 +73,7 @@ list_window_rfind(list_window_t *lw,
                  void *callback_data,
                  const char *str,
                  int wrap,
-                 int rows);
+                 unsigned rows);
 
 /* list window states */
 list_window_state_t *list_window_init_state(void);
index 0533cad95998684ee2d71edeff1e4802b39ff4f2..57b470681a82832af39143a22c8c8060988202bd 100644 (file)
@@ -490,7 +490,7 @@ mpdclient_cmd_move(mpdclient_t *c, gint old_index, gint new_index)
        mpd_Song *song1, *song2;
 
        if (old_index == new_index || new_index < 0 ||
-           new_index >= c->playlist.length)
+           (guint)new_index >= c->playlist.length)
                return -1;
 
        song1 = playlist_get_song(c, old_index);
@@ -739,7 +739,7 @@ mpdclient_playlist_update_changes(mpdclient_t *c)
        while ((entity = mpd_getNextInfoEntity(c->connection)) != NULL) {
                mpd_Song *song = entity->info.song;
 
-               if (song->pos < c->playlist.length) {
+               if (song->pos >= 0 && (guint)song->pos < c->playlist.length) {
                        GList *item = g_list_nth(c->playlist.list, song->pos);
 
                        /* update song */
@@ -756,7 +756,7 @@ mpdclient_playlist_update_changes(mpdclient_t *c)
        }
 
        /* remove trailing songs */
-       while (c->status->playlistLength < c->playlist.length) {
+       while ((guint)c->status->playlistLength < c->playlist.length) {
                GList *item = g_list_last(c->playlist.list);
 
                /* Remove the last playlist entry */
index 9b1aafe4f93c238326faafd043004bcbd542745c..7426a55caed471dcc240973488f07074992fb4ae 100644 (file)
@@ -275,7 +275,7 @@ options_parse(int argc, const char *argv[])
                }
                /* check for short options */
                else if (len>=2 && g_str_has_prefix(arg, "-")) {
-                       int j;
+                       size_t j;
 
                        for(j=1; j<len; j++) {
                                /* make shure we got an argument for the previous option */
index d952a1fe41b60a637f0572e4aa45122d3fad78ea..3db9730e8e54a47b0f7e2f24672fe1da534a9554 100644 (file)
@@ -258,7 +258,7 @@ static void
 paint_top_window(const char *header, mpdclient_t *c, int full_repaint)
 {
        static int prev_volume = -1;
-       static int prev_header_len = -1;
+       static size_t prev_header_len = -1;
        WINDOW *w = screen->top_window.w;
 
        if (prev_header_len!=my_strlen(header)) {
@@ -385,7 +385,7 @@ paint_status_window(mpdclient_t *c)
 
                colors_use(w, COLOR_STATUS);
                /* scroll if the song name is to long */
-               if (options.scroll && my_strlen(songname) > width) {
+               if (options.scroll && my_strlen(songname) > (size_t)width) {
                        static  scroll_state_t st = { 0, 0 };
                        char *tmp = strscroll(songname, options.scroll_sep, width, &st);
 
@@ -809,7 +809,7 @@ screen_get_mouse_event(mpdclient_t *c,
        }
 
        /* if the even occured below the list window move down */
-       if (*row >= lw->rows && lw) {
+       if ((unsigned)*row >= lw->rows && lw) {
                if (event.bstate & BUTTON3_CLICKED)
                        list_window_last(lw, lw_length);
                else
index c58867500028bf9af71b9a49ae82d1edcb5935b6..0726d0b35b971b38dd2877c24501cab8e0ad7e21 100644 (file)
@@ -6,7 +6,7 @@ void set_highlight(mpdclient_filelist_t *filelist,
                   int highlight);
 
 
-const char *browse_lw_callback(int index, int *highlight, void *filelist);
+const char *browse_lw_callback(unsigned index, int *highlight, void *filelist);
 
 int browse_handle_select(screen_t *screen, 
                         mpdclient_t *c,
index ab2af071321c506c03d55ff164a58e2f7a421f25..c00ccba44bdd5f0b68d89e0737344831f515733a 100644 (file)
@@ -147,7 +147,7 @@ playlist_changed_callback(mpdclient_t *c, int event, gpointer data)
 
 /* list_window callback */
 const char *
-browse_lw_callback(int idx, int *highlight, void *data)
+browse_lw_callback(unsigned idx, int *highlight, void *data)
 {
        static char buf[BUFSIZE];
        mpdclient_filelist_t *fl = (mpdclient_filelist_t *) data;
@@ -645,7 +645,7 @@ browse_handle_mouse_event(screen_t *screen,
                          mpdclient_filelist_t *fl)
 {
        int row;
-       int prev_selected = local_lw->selected;
+       unsigned prev_selected = local_lw->selected;
        unsigned long bstate;
        int length;
 
index 2b5dc1f162329ef7968e52f6dc242556afe28ed2..681bc6cfe5198d81ee65ee39630dfef28b3a54eb 100644 (file)
@@ -147,7 +147,7 @@ static list_window_t *lw = NULL;
 
 
 static const char *
-list_callback(int idx, int *highlight, void *data)
+list_callback(unsigned idx, int *highlight, void *data)
 {
        static char buf[512];
 
@@ -158,7 +158,7 @@ list_callback(int idx, int *highlight, void *data)
        }
 
        *highlight = 0;
-       if (idx < help_text_rows) {
+       if (idx < (unsigned)help_text_rows) {
                *highlight = help_text[idx].highlight > 0;
                if (help_text[idx].command == CMD_NONE) {
                        if (help_text[idx].text)
@@ -166,7 +166,7 @@ list_callback(int idx, int *highlight, void *data)
                        else if (help_text[idx].highlight == 2) {
                                int i;
 
-                               for (i = 3; i < COLS - 3 && i < sizeof(buf); i++)
+                               for (i = 3; i < COLS - 3 && i < (int)sizeof(buf); i++)
                                        buf[i] = '-';
                                buf[i] = '\0';
                        } else
@@ -243,7 +243,7 @@ help_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
        lw->clear=1;
        switch(cmd) {
        case CMD_LIST_NEXT:
-               if (lw->start + lw->rows < help_text_rows)
+               if (lw->start + lw->rows < (unsigned)help_text_rows)
                        lw->start++;
                return 1;
        case CMD_LIST_PREVIOUS:
@@ -254,20 +254,24 @@ help_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
                lw->start = 0;
                return 1;
        case CMD_LIST_LAST:
-               lw->start = help_text_rows - lw->rows;
-               if (lw->start < 0)
+               if ((unsigned)help_text_rows > lw->rows)
+                       lw->start = help_text_rows - lw->rows;
+               else
                        lw->start = 0;
                return 1;
        case CMD_LIST_NEXT_PAGE:
                lw->start = lw->start + lw->rows;
-               if (lw->start + lw->rows >= help_text_rows)
-                       lw->start = help_text_rows - lw->rows;
-               if (lw->start < 0)
-                       lw->start = 0;
+               if (lw->start + lw->rows >= (unsigned)help_text_rows) {
+                       if ((unsigned)help_text_rows > lw->rows)
+                               lw->start = help_text_rows - lw->rows;
+                       else
+                               lw->start = 0;
+               }
                return 1;
        case CMD_LIST_PREVIOUS_PAGE:
-               lw->start = lw->start - lw->rows;
-               if (lw->start < 0)
+               if (lw->start > lw->rows)
+                       lw->start -= lw->rows;
+               else
                        lw->start = 0;
                return 1;
        default:
@@ -279,11 +283,16 @@ help_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
                        lw,  help_text_rows,
                        cmd, list_callback, NULL)) {
                /* center the row */
-               lw->start = lw->selected - (lw->rows / 2);
-               if (lw->start + lw->rows > help_text_rows)
-                       lw->start = help_text_rows - lw->rows;
-               if (lw->start < 0)
+               if (lw->selected > lw->rows / 2)
+                       lw->start = lw->selected - lw->rows / 2;
+               else
                        lw->start = 0;
+               if (lw->start + lw->rows > (unsigned)help_text_rows) {
+                       if (lw->rows < (unsigned)help_text_rows)
+                               lw->start = help_text_rows - lw->rows;
+                       else
+                               lw->start = 0;
+               }
                return 1;
        }
 
index bc37f1af3edc2958452d73d8711cd5eb16c2b40a..54a234961b83ef9a683ea9e3f43b861d983ba099 100644 (file)
@@ -39,7 +39,7 @@
 #define STATIC_SUB_ITEMS  1
 #define BUFSIZE 256
 
-#define LIST_ITEM_APPLY()   (command_list_length)
+#define LIST_ITEM_APPLY()   ((unsigned)command_list_length)
 #define LIST_ITEM_SAVE()    (LIST_ITEM_APPLY()+1)
 #define LIST_LENGTH()       (LIST_ITEM_SAVE()+1)
 
 
 
 static list_window_t *lw = NULL;
-static int command_list_length = 0;
+static unsigned command_list_length = 0;
 static command_definition_t *cmds = NULL;
 
 static int subcmd = -1;
-static int subcmd_length = 0;
-static int subcmd_addpos = 0;
+static unsigned subcmd_length = 0;
+static unsigned subcmd_addpos = 0;
 
 static int
 keybindings_changed(void)
@@ -183,13 +183,13 @@ assign_new_key(WINDOW *w, int cmd_index, int key_index)
 }
 
 static const char *
-list_callback(int idx, int *highlight, void *data)
+list_callback(unsigned idx, int *highlight, void *data)
 {
        static char buf[BUFSIZE];
 
        *highlight = 0;
        if (subcmd < 0) {
-               if (idx < command_list_length) {
+               if (idx < (unsigned)command_list_length) {
                        if (cmds[idx].flags & COMMAND_KEY_CONFLICT)
                                *highlight = 1;
                        return cmds[idx].name;
@@ -338,7 +338,7 @@ keydef_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
                lw->clear = 1;
                return 1;
        case CMD_DELETE:
-               if (subcmd >= 0 && lw->selected - STATIC_SUB_ITEMS >= 0)
+               if (subcmd >= 0 && lw->selected >= STATIC_SUB_ITEMS)
                        delete_key(subcmd, lw->selected - STATIC_SUB_ITEMS);
                return 1;
                break;
index 2c770ff595cd874e541012625f9c2c67b6e6167b..fb45fd49da23c9945387b06f626ea8f29a45f0ff 100644 (file)
@@ -71,7 +71,7 @@ static int store_lyr_hd(void)
        char title[512];
        static char path[1024];
        FILE *lyr_file;
-       int i;
+       unsigned i;
        char line_buf[1024];
 
        get_text_line(&lyr_text, 0, artist, 512);
@@ -152,7 +152,7 @@ static gpointer get_lyr(void *c)
 }
 
 static const char *
-list_callback(int idx, int *highlight, void *data)
+list_callback(unsigned idx, int *highlight, void *data)
 {
        static char buf[512];
 
@@ -214,7 +214,7 @@ lyrics_title(char *str, size_t size)
 
        g_string_append (msg, "Lyrics  [");
 
-       if (src_selection > src_lyr_stack->len - 1)
+       if (src_selection > (int)src_lyr_stack->len - 1)
                g_string_append (msg, "No plugin available");
        else {
                src_lyr* selected =  g_array_index (src_lyr_stack, src_lyr*, src_selection);
@@ -282,20 +282,24 @@ lyrics_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
                lw->start = 0;
                return 1;
        case CMD_LIST_LAST:
-               lw->start = lyrics_text_rows-lw->rows;
-               if( lw->start<0 )
+               if ((unsigned)lyrics_text_rows > lw->rows)
+                       lw->start = lyrics_text_rows - lw->rows;
+               else
                        lw->start = 0;
                return 1;
        case CMD_LIST_NEXT_PAGE:
-               lw->start = lw->start + lw->rows-1;
-               if( lw->start+lw->rows >= lyr_text.lines->len+1 )
-                       lw->start = lyr_text.lines->len-lw->rows+1;
-               if( lw->start<0 )
-                       lw->start = 0;
+               lw->start = lw->start + lw->rows - 1;
+               if (lw->start + lw->rows >= (unsigned)lyrics_text_rows + 1) {
+                       if ((unsigned)lyrics_text_rows + 1 > lw->rows)
+                               lw->start = lyrics_text_rows + 1 - lw->rows;
+                       else
+                               lw->start = 0;
+               }
                return 1;
        case CMD_LIST_PREVIOUS_PAGE:
-               lw->start = lw->start - lw->rows;
-               if( lw->start<0 )
+               if (lw->start > lw->rows)
+                       lw->start -= lw->rows;
+               else
                        lw->start = 0;
                return 1;
        case CMD_SELECT:
@@ -319,7 +323,7 @@ lyrics_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
                return 1;
        case CMD_SEARCH_MODE:
                //while (0==0) fprintf (stderr, "%i", src_lyr_stack->len);
-               if (src_selection == src_lyr_stack->len - 1)
+               if (src_selection == (int)src_lyr_stack->len - 1)
                        src_selection = -1;
                src_selection++;
                return 1;
@@ -333,10 +337,12 @@ lyrics_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
                        cmd, list_callback, NULL)) {
                /* center the row */
                lw->start = lw->selected - (lw->rows / 2);
-               if (lw->start + lw->rows > lyrics_text_rows)
-                       lw->start = lyrics_text_rows - lw->rows;
-               if (lw->start < 0)
-                       lw->start = 0;
+               if (lw->start + lw->rows > (unsigned)lyrics_text_rows) {
+                       if (lw->rows < (unsigned)lyrics_text_rows)
+                               lw->start = lyrics_text_rows - lw->rows;
+                       else
+                               lw->start = 0;
+               }
                return 1;
        }
 
index a1bb369e66cb93e5c3f59e7417126b2701fb6919..6b68568eefc00cb8f88cf654e4897112415d40c7 100644 (file)
@@ -73,7 +73,7 @@ playlist_changed_callback(mpdclient_t *c, int event, gpointer data)
 }
 
 static const char *
-list_callback(int idx, int *highlight, void *data)
+list_callback(unsigned idx, int *highlight, void *data)
 {
        static char songname[MAX_SONG_LENGTH];
        mpdclient_t *c = (mpdclient_t *) data;
@@ -94,8 +94,8 @@ list_callback(int idx, int *highlight, void *data)
 static int
 center_playing_item(screen_t *screen, mpdclient_t *c)
 {
-       int length = c->playlist.length;
-       int offset = lw->selected - lw->start;
+       unsigned length = c->playlist.length;
+       unsigned offset = lw->selected - lw->start;
        int idx;
 
        if (!lw || !c->song || length<lw->rows ||
@@ -105,11 +105,12 @@ center_playing_item(screen_t *screen, mpdclient_t *c)
        /* try to center the song that are playing */
        idx = playlist_get_index(c, c->song);
        D("Autocenter song id:%d pos:%d index:%d\n", c->song->id,c->song->pos,idx);
-       lw->start = idx - (lw->rows / 2);
-       if (lw->start + lw->rows > length)
-               lw->start = length - lw->rows;
-       if (lw->start < 0)
-               lw->start = 0;
+       idx -= (lw->rows / 2);
+       if (idx + (int)lw->rows > (int)length)
+               idx = length - lw->rows;
+       if (idx < 0)
+               idx = 0;
+       lw->start = idx;
 
        /* make sure the cursor is in the window */
        lw->selected = lw->start+offset;
@@ -419,7 +420,7 @@ static int
 handle_mouse_event(screen_t *screen, mpdclient_t *c)
 {
        int row;
-       int selected;
+       unsigned selected;
        unsigned long bstate;
 
        if (screen_get_mouse_event(c, lw, c->playlist.length, &bstate, &row))
index dd2353c000f6fa4a8fdc00b2fc923f531fbc5f50..2161b7914935ec2784b8f8c308b4bb5b609a9fd4 100644 (file)
@@ -116,9 +116,9 @@ static gboolean advanced_search_mode = FALSE;
 
 /* search info */
 static const char *
-lw_search_help_callback(int idx, int *highlight, void *data)
+lw_search_help_callback(unsigned idx, int *highlight, void *data)
 {
-       int text_rows;
+       unsigned text_rows;
        static const char *text[] = {
                "Quick  - just enter a string and ncmpc will search according",
                "               to the current search mode (displayed above).",
index 448c301ad562f1ae04d955c0008dbcf706e931ff..6ac6cc3c5a102b710848543b81640820d5d8ae61 100644 (file)
@@ -26,7 +26,7 @@
 
 #define PLUGIN_DIR_USER "/.ncmpc/plugins"
 
-int get_text_line(formed_text *text, int num, char *dest, int len)
+int get_text_line(formed_text *text, unsigned num, char *dest, size_t len)
 {
        int linelen;
 
index 941c4b63ab8d9b7b15b5181eceafcbfca4c0fe98..b972e7af5f9a22180ea7da86626f45c2a6f70f15 100644 (file)
@@ -71,7 +71,7 @@ typedef int (*src_lyr_plugin_register) (src_lyr *source_descriptor);
 
 GArray *src_lyr_stack;
 
-int get_text_line(formed_text *text, int num, char *dest, int len);
+int get_text_line(formed_text *text, unsigned num, char *dest, size_t len);
 
 void src_lyr_stack_init(void);
 int src_lyr_init(void);
index 315c569f742424a721dfa6f7db0ac3fa1d458504..ae3381ef294e60f3996287c3d08e55ad18aa3cbb 100644 (file)
@@ -137,7 +137,7 @@ strscroll(char *str, char *separator, int width, scroll_state_t *st)
        } else {
                buf = g_malloc(size);
                g_strlcpy(buf, tmp+st->offset, size);
-               if (strlen(buf) < width)
+               if (strlen(buf) < (size_t)width)
                        g_strlcat(buf, tmp, size);
        }
        if( time(NULL)-st->t >= 1 ) {
index 8e868e7ff9170af9ab26686617be28710e85f866..b80b9c8a2600379e47df2072c9993998d8820699 100644 (file)
@@ -18,7 +18,7 @@ char *lowerstr(char *str);
 char *strcasestr(const char *haystack, const char *needle);
 
 typedef struct {
-       int offset;
+       gsize offset;
        GTime t; /* GTime is equivalent to time_t */
 } scroll_state_t;
 
index e6bc612378e4e73613d71a5ad1a5694c094cf8ed..ed8ad9a390230bd861ba8597296c7ba5bd83f557 100644 (file)
@@ -66,7 +66,8 @@ static inline void cursor_move_right(gint *cursor,
                                     gint x1,
                                     gchar *line)
 {
-       if (*cursor < strlen(line) && *cursor < wrln_max_line_size - 1) {
+       if (*cursor < (int)strlen(line) &&
+           *cursor < (int)wrln_max_line_size - 1) {
                (*cursor)++;
                if (*cursor + x0 >= x1 && *start < *cursor - width + 1)
                        (*start)++;
@@ -284,7 +285,7 @@ _wreadln(WINDOW *w,
                        break;
                case KEY_DC:            /* handle delete key. As above */
                case KEY_CTRL_D:
-                       if (cursor <= my_strlen(line) - 1) {
+                       if (cursor <= (gint)my_strlen(line) - 1) {
                                for (i = cursor; line[i] != 0; i++)
                                        line[i] = line[i + 1];
                        }