path, tag: don't allocate GError for charset conversion
Pass NULL instead of &error to g_convert(). We're not interested in the error object.
This commit is contained in:
parent
da69382273
commit
530f0b71de
14
src/path.c
14
src/path.c
@ -32,16 +32,13 @@ static char *fs_charset;
|
|||||||
char *fs_charset_to_utf8(char *dst, const char *str)
|
char *fs_charset_to_utf8(char *dst, const char *str)
|
||||||
{
|
{
|
||||||
gchar *p;
|
gchar *p;
|
||||||
GError *error = NULL;
|
|
||||||
|
|
||||||
p = g_convert(str, -1,
|
p = g_convert(str, -1,
|
||||||
"utf-8", fs_charset,
|
"utf-8", fs_charset,
|
||||||
NULL, NULL, &error);
|
NULL, NULL, NULL);
|
||||||
if (p == NULL) {
|
if (p == NULL)
|
||||||
/* no fallback */
|
/* no fallback */
|
||||||
g_error_free(error);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
g_strlcpy(dst, p, MPD_PATH_MAX);
|
g_strlcpy(dst, p, MPD_PATH_MAX);
|
||||||
g_free(p);
|
g_free(p);
|
||||||
@ -51,16 +48,13 @@ char *fs_charset_to_utf8(char *dst, const char *str)
|
|||||||
char *utf8_to_fs_charset(char *dst, const char *str)
|
char *utf8_to_fs_charset(char *dst, const char *str)
|
||||||
{
|
{
|
||||||
gchar *p;
|
gchar *p;
|
||||||
GError *error = NULL;
|
|
||||||
|
|
||||||
p = g_convert(str, -1,
|
p = g_convert(str, -1,
|
||||||
fs_charset, "utf-8",
|
fs_charset, "utf-8",
|
||||||
NULL, NULL, &error);
|
NULL, NULL, NULL);
|
||||||
if (p == NULL) {
|
if (p == NULL)
|
||||||
/* fall back to UTF-8 */
|
/* fall back to UTF-8 */
|
||||||
g_error_free(error);
|
|
||||||
return strcpy(dst, str);
|
return strcpy(dst, str);
|
||||||
}
|
|
||||||
|
|
||||||
g_strlcpy(dst, p, MPD_PATH_MAX);
|
g_strlcpy(dst, p, MPD_PATH_MAX);
|
||||||
g_free(p);
|
g_free(p);
|
||||||
|
@ -406,7 +406,6 @@ static char *
|
|||||||
fix_utf8(const char *str, size_t length)
|
fix_utf8(const char *str, size_t length)
|
||||||
{
|
{
|
||||||
char *temp;
|
char *temp;
|
||||||
GError *error = NULL;
|
|
||||||
gsize written;
|
gsize written;
|
||||||
|
|
||||||
assert(str != NULL);
|
assert(str != NULL);
|
||||||
@ -416,11 +415,9 @@ fix_utf8(const char *str, size_t length)
|
|||||||
|
|
||||||
DEBUG("not valid utf8 in tag: %s\n",str);
|
DEBUG("not valid utf8 in tag: %s\n",str);
|
||||||
temp = g_convert(str, length, "utf-8", "iso-8859-1",
|
temp = g_convert(str, length, "utf-8", "iso-8859-1",
|
||||||
NULL, &written, &error);
|
NULL, &written, NULL);
|
||||||
if (temp == NULL) {
|
if (temp == NULL)
|
||||||
g_error_free(error);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
@ -54,8 +54,6 @@ static id3_utf8_t * processID3FieldString (int is_id3v1, const id3_ucs4_t *ucs4,
|
|||||||
/* use encoding field here? */
|
/* use encoding field here? */
|
||||||
if (is_id3v1 &&
|
if (is_id3v1 &&
|
||||||
(encoding = getConfigParamValue(CONF_ID3V1_ENCODING))) {
|
(encoding = getConfigParamValue(CONF_ID3V1_ENCODING))) {
|
||||||
GError *error = NULL;
|
|
||||||
|
|
||||||
isostr = id3_ucs4_latin1duplicate(ucs4);
|
isostr = id3_ucs4_latin1duplicate(ucs4);
|
||||||
if (G_UNLIKELY(!isostr)) {
|
if (G_UNLIKELY(!isostr)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -64,11 +62,10 @@ static id3_utf8_t * processID3FieldString (int is_id3v1, const id3_ucs4_t *ucs4,
|
|||||||
utf8 = (id3_utf8_t *)
|
utf8 = (id3_utf8_t *)
|
||||||
g_convert_with_fallback((const char*)isostr, -1,
|
g_convert_with_fallback((const char*)isostr, -1,
|
||||||
encoding, "utf-8",
|
encoding, "utf-8",
|
||||||
NULL, NULL, NULL, &error);
|
NULL, NULL, NULL, NULL);
|
||||||
if (utf8 == NULL) {
|
if (utf8 == NULL) {
|
||||||
g_debug("Unable to convert %s string to UTF-8: '%s'",
|
g_debug("Unable to convert %s string to UTF-8: '%s'",
|
||||||
encoding, isostr);
|
encoding, isostr);
|
||||||
g_error_free(error);
|
|
||||||
g_free(isostr);
|
g_free(isostr);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user