aboutsummaryrefslogtreecommitdiffstats
path: root/src/player_control.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-10-08 20:45:38 +0200
committerMax Kellermann <max@duempel.org>2009-10-08 20:45:38 +0200
commit128a5fa4a599b72e6cb9c9f3954aec62dd3b3181 (patch)
tree5364277b05b9e98e636e76513e00dcf4015c2c3b /src/player_control.c
parenta5960c20cc679132e049fc6da0f3d7d6fa34e361 (diff)
downloadmpd-128a5fa4a599b72e6cb9c9f3954aec62dd3b3181.tar.gz
mpd-128a5fa4a599b72e6cb9c9f3954aec62dd3b3181.tar.xz
mpd-128a5fa4a599b72e6cb9c9f3954aec62dd3b3181.zip
player_control: allocate getPlayerErrorStr() result
This lets us eliminate the static fixed-size buffer.
Diffstat (limited to '')
-rw-r--r--src/player_control.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/src/player_control.c b/src/player_control.c
index df80ac4ff..bef19917f 100644
--- a/src/player_control.c
+++ b/src/player_control.c
@@ -167,46 +167,40 @@ pc_errored_song_uri(void)
char *getPlayerErrorStr(void)
{
- /* static OK here, only one user in main task */
- static char error[MPD_PATH_MAX + 64]; /* still too much */
- static const size_t errorlen = sizeof(error);
+ char *error;
char *uri;
- *error = '\0'; /* likely */
-
switch (pc.error) {
case PLAYER_ERROR_NOERROR:
- break;
+ return NULL;
case PLAYER_ERROR_FILENOTFOUND:
uri = pc_errored_song_uri();
- snprintf(error, errorlen,
- "file \"%s\" does not exist or is inaccessible", uri);
+ error = g_strdup_printf("file \"%s\" does not exist or is inaccessible", uri);
g_free(uri);
- break;
+ return error;
case PLAYER_ERROR_FILE:
uri = pc_errored_song_uri();
- snprintf(error, errorlen, "problems decoding \"%s\"", uri);
+ error = g_strdup_printf("problems decoding \"%s\"", uri);
g_free(uri);
- break;
+ return error;
case PLAYER_ERROR_AUDIO:
- strcpy(error, "problems opening audio device");
- break;
+ return g_strdup("problems opening audio device");
case PLAYER_ERROR_SYSTEM:
- strcpy(error, "system error occured");
- break;
+ return g_strdup("system error occured");
case PLAYER_ERROR_UNKTYPE:
uri = pc_errored_song_uri();
- snprintf(error, errorlen,
- "file type of \"%s\" is unknown", uri);
+ error = g_strdup_printf("file type of \"%s\" is unknown", uri);
g_free(uri);
- break;
+ return error;
}
- return *error ? error : NULL;
+
+ assert(false);
+ return NULL;
}
void