From 9b66deea6385f02628d1a57ae3fef292e8e490dd Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 5 Dec 2008 09:33:54 +0100 Subject: [PATCH] sreen_play: fixed the g_completion_set_compare() callback type Passing strncmp to g_completion_set_compare() is incorrect, because the type of the third parameter (n) differs. This patch adds a wrapper function with the correct type. --- src/screen_play.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/screen_play.c b/src/screen_play.c index 7b94b80..feff1f7 100644 --- a/src/screen_play.c +++ b/src/screen_play.c @@ -178,6 +178,19 @@ save_post_completion_cb(G_GNUC_UNUSED GCompletion *gcmp, } #endif +#ifndef NCMPC_MINI +/** + * Wrapper for strncmp(). We are not allowed to pass &strncmp to + * g_completion_set_compare(), because strncmp() takes size_t where + * g_completion_set_compare passes a gsize value. + */ +static gint +completion_strncmp(const gchar *s1, const gchar *s2, gsize n) +{ + return strncmp(s1, s2, n); +} +#endif + int playlist_save(mpdclient_t *c, char *name, char *defaultname) { @@ -197,7 +210,7 @@ playlist_save(mpdclient_t *c, char *name, char *defaultname) if (name == NULL) { /* initialize completion support */ gcmp = g_completion_new(NULL); - g_completion_set_compare(gcmp, strncmp); + g_completion_set_compare(gcmp, completion_strncmp); data.list = &list; data.dir_list = NULL; data.c = c; @@ -335,7 +348,7 @@ handle_add_to_playlist(mpdclient_t *c) /* initialize completion support */ gcmp = g_completion_new(NULL); - g_completion_set_compare(gcmp, strncmp); + g_completion_set_compare(gcmp, completion_strncmp); data.list = &list; data.dir_list = &dir_list; data.c = c; -- 2.30.2