Code

fix unused parameter warnings
[ncmpc.git] / src / screen_lyrics.c
index 2dd5e12b76ab43828fbab40f2acb66e4f1ecc991..59329694847d4fb00ef10c67441057e260fc361b 100644 (file)
@@ -31,6 +31,7 @@
 #include "easy_download.h"
 #include "strfsong.h"
 #include "src_lyrics.h"
+#include "gcc.h"
 
 #define _GNU_SOURCE
 #include <stdlib.h>
@@ -71,6 +72,8 @@ static int store_lyr_hd(void)
        char title[512];
        static char path[1024];
        FILE *lyr_file;
+       unsigned i;
+       char line_buf[1024];
 
        get_text_line(&lyr_text, 0, artist, 512);
        get_text_line(&lyr_text, 1, title, 512);
@@ -83,9 +86,6 @@ static int store_lyr_hd(void)
        if (lyr_file == NULL)
                return -1;
 
-       int i;
-       char line_buf[1024];
-
        for (i = 3; i <= lyr_text.text->len; i++) {
                if(get_text_line(&lyr_text, i, line_buf, 1024) == -1);
                fputs(line_buf, lyr_file);
@@ -106,6 +106,9 @@ static gpointer get_lyr(void *c)
 {
        mpd_Status *status = ((retrieval_spec*)c)->client->status;
        mpd_Song *cur = ((retrieval_spec*)c)->client->song;
+       char artist[MAX_SONGNAME_LENGTH];
+       char title[MAX_SONGNAME_LENGTH];
+
        //mpdclient_update((mpdclient_t*)c);
 
        if(!(IS_PAUSED(status->state)||IS_PLAYING(status->state))) {
@@ -114,8 +117,6 @@ static gpointer get_lyr(void *c)
        }
 
 
-       char artist[MAX_SONGNAME_LENGTH];
-       char title[MAX_SONGNAME_LENGTH];
        lock=2;
        result = 0;
 
@@ -152,29 +153,29 @@ static gpointer get_lyr(void *c)
 }
 
 static const char *
-list_callback(int index, int *highlight, void *data)
+list_callback(unsigned idx, int *highlight, mpd_unused void *data)
 {
        static char buf[512];
 
        //i think i'ts fine to write it into the 1st line...
-       if ((index == lyr_text.lines->len && lyr_text.lines->len > 4) ||
+       if ((idx == lyr_text.lines->len && lyr_text.lines->len > 4) ||
            ((lyr_text.lines->len == 0 || lyr_text.lines->len == 4) &&
-            index == 0)) {
-               *highlight=3;
+            idx == 0)) {
                src_lyr* selected = g_array_index(src_lyr_stack, src_lyr*, src_selection);
+               *highlight=3;
                if (selected != NULL)
                        return selected->description;
                return "";
        }
 
-       if (index < 2 && lyr_text.lines->len > 4)
+       if (idx < 2 && lyr_text.lines->len > 4)
                *highlight=3;
-       else if(index >= lyr_text.lines->len ||
-               (index < 4 && index != 0 && lyr_text.lines->len < 5)) {
+       else if(idx >= lyr_text.lines->len ||
+               (idx < 4 && idx != 0 && lyr_text.lines->len < 5)) {
                return "";
        }
 
-       get_text_line(&lyr_text, index, buf, 512);
+       get_text_line(&lyr_text, idx, buf, 512);
        return buf;
 }
 
@@ -205,7 +206,7 @@ lyrics_exit(void)
 
 
 static const char *
-lyrics_title(char *str, size_t size)
+lyrics_title(mpd_unused char *str, mpd_unused size_t size)
 {
        static GString *msg;
        if (msg == NULL)
@@ -214,7 +215,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);
@@ -244,7 +245,7 @@ lyrics_title(char *str, size_t size)
 }
 
 static void
-lyrics_paint(screen_t *screen, mpdclient_t *c)
+lyrics_paint(mpd_unused screen_t *screen, mpd_unused mpdclient_t *c)
 {
        lw->clear = 1;
        list_window_paint(lw, list_callback, NULL);
@@ -253,7 +254,7 @@ lyrics_paint(screen_t *screen, mpdclient_t *c)
 
 
 static void
-lyrics_update(screen_t *screen, mpdclient_t *c)
+lyrics_update(mpd_unused screen_t *screen, mpd_unused mpdclient_t *c)
 {
        if( lw->repaint ) {
                list_window_paint(lw, list_callback, NULL);
@@ -282,20 +283,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 +324,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 +338,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;
        }