From 50a0738fa0a5370734246997cfad6be33aa930a2 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 13 Sep 2009 12:25:17 +0200 Subject: [PATCH] screen_browser: browser_get_selected_X() returns const object No caller modifies these objects. It's safe to return const. --- src/screen_browser.c | 12 ++++++------ src/screen_file.c | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/screen_browser.c b/src/screen_browser.c index 5f6e048..501c875 100644 --- a/src/screen_browser.c +++ b/src/screen_browser.c @@ -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; diff --git a/src/screen_file.c b/src/screen_file.c index 00b505f..8393816 100644 --- a/src/screen_file.c +++ b/src/screen_file.c @@ -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; -- 2.30.2