Code

make several functions return void
authorMax Kellermann <max@duempel.org>
Wed, 17 Sep 2008 10:29:07 +0000 (12:29 +0200)
committerMax Kellermann <max@duempel.org>
Wed, 17 Sep 2008 10:29:07 +0000 (12:29 +0200)
src/list_window.c
src/list_window.h
src/main.c
src/mpdclient.c
src/mpdclient.h
src/screen.c
src/screen.h
src/screen_file.c
src/screen_play.c
src/screen_search.c

index ad671f0cf51ad1a36715e6e1623731d36cb1acc5..5ab8f9c9c125c5ecc628fd050a6de932de327fb8 100644 (file)
@@ -44,15 +44,13 @@ list_window_init(WINDOW *w, unsigned width, unsigned height)
        return lw;
 }
 
-struct list_window *
+void
 list_window_free(struct list_window *lw)
 {
        if (lw) {
                memset(lw, 0, sizeof(list_window_t));
                g_free(lw);
        }
-
-       return NULL;
 }
 
 void
@@ -148,7 +146,7 @@ list_window_next_page(struct list_window *lw, unsigned length)
        if (lw->selected + lw->rows < length)
                lw->selected += lw->rows - 1;
        else
-               return list_window_last(lw, length);
+               list_window_last(lw, length);
 }
 
 void
@@ -370,7 +368,7 @@ list_window_init_state(void)
        return g_malloc0(sizeof(list_window_state_t));
 }
 
-list_window_state_t *
+void
 list_window_free_state(list_window_state_t *state)
 {
        if (state) {
@@ -389,8 +387,6 @@ list_window_free_state(list_window_state_t *state)
 
                g_free(state);
        }
-
-       return NULL;
 }
 
 void
index 3a9fba4c313cb5bda9d3ea3d0e592f42c6eb952e..ca93971dde2aa5146242a1b1f9c2ed79a96a804e 100644 (file)
@@ -36,7 +36,7 @@ struct list_window *list_window_init(WINDOW *w,
                                     unsigned width, unsigned height);
 
 /* destroy a list window (returns NULL) */
-struct list_window *list_window_free(struct list_window *lw);
+void list_window_free(struct list_window *lw);
 
 /* reset a list window (selected=0, start=0, clear=1) */
 void list_window_reset(struct list_window *lw);
@@ -87,7 +87,7 @@ list_window_rfind(struct list_window *lw,
 
 /* list window states */
 list_window_state_t *list_window_init_state(void);
-list_window_state_t *list_window_free_state(list_window_state_t *state);
+void list_window_free_state(list_window_state_t *state);
 void list_window_push_state(list_window_state_t *state,
                            struct list_window *lw);
 bool list_window_pop_state(list_window_state_t *state, struct list_window *lw);
index d54fd37179f813504e3e5a9c5439879ce8689b90..c2d752ffbed5c03af0442ac87ed0ae3ec557ff04 100644 (file)
@@ -113,7 +113,7 @@ exit_and_cleanup(void)
   if( mpd )
     {
       mpdclient_disconnect(mpd);
-      mpd = mpdclient_free(mpd);
+      mpdclient_free(mpd);
     }
   g_free(options.host);
   g_free(options.password);
index ae4a7618faf8567d8589ee541936d635d11ebdf5..f67b09133949ff0efcb78eda00b384de699214c9 100644 (file)
@@ -168,7 +168,7 @@ mpdclient_new(void)
        return c;
 }
 
-mpdclient_t *
+void
 mpdclient_free(mpdclient_t *c)
 {
        mpdclient_disconnect(c);
@@ -179,8 +179,6 @@ mpdclient_free(mpdclient_t *c)
        g_list_free(c->playlist_callbacks);
        g_list_free(c->browse_callbacks);
        g_free(c);
-
-       return NULL;
 }
 
 gint
@@ -738,14 +736,14 @@ mpdclient_playlist_update_changes(mpdclient_t *c)
 /*** Filelist functions *****************************************************/
 /****************************************************************************/
 
-mpdclient_filelist_t *
+void
 mpdclient_filelist_free(mpdclient_filelist_t *filelist)
 {
        GList *list = g_list_first(filelist->list);
 
        D("mpdclient_filelist_free()\n");
        if (list == NULL)
-               return NULL;
+               return;
        while (list != NULL) {
                filelist_entry_t *entry = list->data;
 
@@ -760,8 +758,6 @@ mpdclient_filelist_free(mpdclient_filelist_t *filelist)
        filelist->list = NULL;
        filelist->length = 0;
        g_free(filelist);
-
-       return NULL;
 }
 
 
@@ -836,8 +832,10 @@ mpdclient_filelist_search_utf8(mpdclient_t *c,
                filelist->length++;
        }
 
-       if (mpdclient_finish_command(c))
-               return mpdclient_filelist_free(filelist);
+       if (mpdclient_finish_command(c)) {
+               mpdclient_filelist_free(filelist);
+               return NULL;
+       }
 
        filelist->updated = TRUE;
        return filelist;
@@ -868,7 +866,7 @@ mpdclient_filelist_update(mpdclient_t *c, mpdclient_filelist_t *filelist)
     {    
       gchar *path = g_strdup(filelist->path);
 
-      filelist = mpdclient_filelist_free(filelist);
+      mpdclient_filelist_free(filelist);
       filelist = mpdclient_filelist_get(c, path);
       g_free(path);
       return filelist;
index 2ce803e86f5f34c42f2717d1bb6d207fa6234cab..0698cbf452061511ae97699f827ff23b5e1f4823 100644 (file)
@@ -52,7 +52,7 @@ gint
 mpdclient_finish_command(mpdclient_t *c);
 
 mpdclient_t *mpdclient_new(void);
-mpdclient_t *mpdclient_free(mpdclient_t *c);
+void mpdclient_free(mpdclient_t *c);
 gint mpdclient_connect(mpdclient_t *c, gchar *host, gint port,
                       gfloat timeout, gchar *password);
 gint mpdclient_disconnect(mpdclient_t *c);
@@ -133,7 +133,7 @@ void mpdclient_playlist_callback(mpdclient_t *c, int event, gpointer data);
 
 
 /*** filelist functions  ***************************************************/
-mpdclient_filelist_t *mpdclient_filelist_free(mpdclient_filelist_t *filelist);
+void mpdclient_filelist_free(mpdclient_filelist_t *filelist);
 mpdclient_filelist_t *mpdclient_filelist_get(mpdclient_t *c, const gchar *path);
 mpdclient_filelist_t *mpdclient_filelist_search(mpdclient_t *c, 
                                                int exact_match,
index 0c59d6940ea36d82024c828885c443ac003aebea..276500bd4b57e31bcf600d3106e896d2e511cb78 100644 (file)
@@ -413,7 +413,7 @@ paint_status_window(mpdclient_t *c)
        wnoutrefresh(w);
 }
 
-int
+void
 screen_exit(void)
 {
        guint i;
@@ -434,8 +434,6 @@ screen_exit(void)
        string_list_free(screen.find_history);
        g_free(screen.buf);
        g_free(screen.findbuf);
-
-       return 0;
 }
 
 void
@@ -620,7 +618,7 @@ ncurses_init(void)
        refresh();
 }
 
-int
+void
 screen_init(mpdclient_t *c)
 {
        guint i;
@@ -641,8 +639,6 @@ screen_init(mpdclient_t *c)
        /* initialize wreadln */
        wrln_wgetch = my_wgetch;
        wrln_max_history_length = 16;
-
-       return 0;
 }
 
 void
index 3f335bf219893c6c021afc2d0dc6d3a03eeac9be..b9087e0ca3091248cd1eec7136b0e4cb533b1be5 100644 (file)
@@ -72,8 +72,8 @@ typedef struct screen_functions {
 void
 ncurses_init(void);
 
-int screen_init(mpdclient_t *c);
-int screen_exit(void);
+void screen_init(mpdclient_t *c);
+void screen_exit(void);
 void screen_resize(void);
 void screen_status_message(const char *msg);
 void screen_status_printf(const char *format, ...);
index 16f9352428def6157fa9c36ac244a4657462f338..d40c8edc9739094a1a6fcfaed2970a7a35d6c092 100644 (file)
@@ -232,7 +232,7 @@ change_directory(mpd_unused screen_t *screen, mpdclient_t *c,
        } else
                return -1;
 
-       filelist = mpdclient_filelist_free(filelist);
+       mpdclient_filelist_free(filelist);
        filelist = mpdclient_filelist_get(c, path);
        sync_highlights(c, filelist);
        list_window_check_selected(lw, filelist->length);
@@ -575,9 +575,9 @@ static void
 browse_exit(void)
 {
        if( filelist )
-               filelist = mpdclient_filelist_free(filelist);
-       lw = list_window_free(lw);
-       lw_state = list_window_free_state(lw_state);
+               mpdclient_filelist_free(filelist);
+       list_window_free(lw);
+       list_window_free_state(lw_state);
 }
 
 static void
index d257ec1dbabdb11bf9a42095879840e821d1d905..1f844f943956d1514dd685e76a743b016f977325 100644 (file)
@@ -92,7 +92,7 @@ list_callback(unsigned idx, int *highlight, void *data)
        return songname;
 }
 
-static int
+static void
 center_playing_item(mpdclient_t *c)
 {
        unsigned length = c->playlist.list->len;
@@ -101,13 +101,13 @@ center_playing_item(mpdclient_t *c)
 
        if (!lw || !c->song || length<lw->rows ||
            IS_STOPPED(c->status->state))
-               return 0;
+               return;
 
        /* 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);
        if (idx < 0)
-               return 0;
+               return;
 
        list_window_center(lw, length, idx);
 
@@ -115,7 +115,7 @@ center_playing_item(mpdclient_t *c)
        lw->selected = lw->start+offset;
        list_window_check_selected(lw, length);
 
-       return 0;
+       return;
 }
 
 static void
index e199bfb2b476ecd1f647f2256bf44ade991f88c3..ce23b9098880613994f8fdfb76591c2578bb2606 100644 (file)
@@ -181,7 +181,8 @@ search_clear(mpd_unused screen_t *screen, mpdclient_t *c,
 {
        if (filelist) {
                mpdclient_remove_playlist_callback(c, playlist_changed_callback);
-               filelist = mpdclient_filelist_free(filelist);
+               mpdclient_filelist_free(filelist);
+               filelist = NULL;
        }
        if (clear_pattern && pattern) {
                g_free(pattern);
@@ -309,7 +310,7 @@ search_advanced_query(char *query, mpdclient_t *c)
                }
 
                if (mpdclient_finish_command(c) && fl)
-                       fl = mpdclient_filelist_free(fl);
+                       mpdclient_filelist_free(fl);
 
                fl->updated = TRUE;
        }
@@ -373,7 +374,7 @@ quit(void)
        if (search_history)
                string_list_free(search_history);
        if (filelist)
-               filelist = mpdclient_filelist_free(filelist);
+               mpdclient_filelist_free(filelist);
        list_window_free(lw);
 
        if (pattern) {