Code

screen_browser: browser_get_selected_X() returns const object
authorMax Kellermann <max@duempel.org>
Sun, 13 Sep 2009 10:25:17 +0000 (12:25 +0200)
committerMax Kellermann <max@duempel.org>
Sun, 13 Sep 2009 10:25:17 +0000 (12:25 +0200)
No caller modifies these objects.  It's safe to return const.

src/screen_browser.c
src/screen_file.c

index 5f6e048810ab00a8a6b97efe72b4bb8961bdc7fa..501c875ea5352c4225123e10b598e29d7f4d7312 100644 (file)
@@ -148,7 +148,7 @@ browser_lw_callback(unsigned idx, bool *highlight, G_GNUC_UNUSED char **second_c
                g_free(directory);
                return buf;
        } else if( entity->type==MPD_INFO_ENTITY_TYPE_SONG ) {
-               mpd_Song *song = entity->info.song;
+               const mpd_Song *song = entity->info.song;
 
                strfsong(buf, BUFSIZE, options.list_format, song);
                return buf;
@@ -217,20 +217,20 @@ browser_get_selected_entry(const struct screen_browser *browser)
        return filelist_get(browser->filelist, browser->lw->selected);
 }
 
-static struct mpd_InfoEntity *
+static const struct mpd_InfoEntity *
 browser_get_selected_entity(const struct screen_browser *browser)
 {
-       struct filelist_entry *entry = browser_get_selected_entry(browser);
+       const struct filelist_entry *entry = browser_get_selected_entry(browser);
 
        return entry != NULL
                ? entry->entity
                : NULL;
 }
 
-static struct mpd_song *
+static const struct mpd_song *
 browser_get_selected_song(const struct screen_browser *browser)
 {
-       struct mpd_InfoEntity *entity = browser_get_selected_entity(browser);
+       const struct mpd_InfoEntity *entity = browser_get_selected_entity(browser);
 
        return entity != NULL && entity->type == MPD_INFO_ENTITY_TYPE_SONG
                ? entity->info.song
@@ -428,7 +428,7 @@ bool
 browser_cmd(struct screen_browser *browser,
            struct mpdclient *c, command_t cmd)
 {
-       struct mpd_song *song;
+       const struct mpd_song *song;
 
        if (browser->filelist == NULL)
                return false;
index 00b505f9b909cc82d3df6a8a08e8fe2ed38e71b0..8393816456a28d7cf2c65990bcc47bb2b66dd40e 100644 (file)
@@ -88,10 +88,10 @@ playlist_changed_callback(mpdclient_t *c, int event, gpointer data)
 #endif
 
 static bool
-file_change_directory(mpdclient_t *c, filelist_entry_t *entry,
+file_change_directory(mpdclient_t *c, const filelist_entry_t *entry,
                      const char *new_path)
 {
-       mpd_InfoEntity *entity = NULL;
+       const mpd_InfoEntity *entity = NULL;
        gchar *path = NULL;
        char *old_path;
        int idx;
@@ -148,8 +148,8 @@ file_change_directory(mpdclient_t *c, filelist_entry_t *entry,
 static bool
 file_handle_enter(struct mpdclient *c)
 {
-       struct filelist_entry *entry = browser_get_selected_entry(&browser);
-       struct mpd_InfoEntity *entity;
+       const struct filelist_entry *entry = browser_get_selected_entry(&browser);
+       const struct mpd_InfoEntity *entity;
 
        if (entry == NULL)
                return false;