Created
July 28, 2014 13:51
-
-
Save kaworu/cca412f43ea3fb45e5a8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/t_fttaglib.c b/t_fttaglib.c | |
index ca90766..c1535e6 100644 | |
--- a/t_fttaglib.c | |
+++ b/t_fttaglib.c | |
@@ -103,59 +103,63 @@ t_fttaglib_read(void *opaque) | |
return (NULL); | |
/* | |
- * we're abusing assert, mainly because TagLib does not document what | |
- * happen on error. There is a lot of duplication but it's ok because | |
- * it's very dumb code. | |
+ * There is a lot of duplication around here but it's ok because it's | |
+ * very dumb code. | |
*/ | |
- assert(val = taglib_tag_title(data->tag)); | |
+ if ((val = taglib_tag_title(data->tag)) == NULL) | |
+ goto error_label; | |
if (strlen(val) > 0 && t_taglist_insert(tlist, "title", val) == -1) | |
- goto error; | |
+ goto error_label; | |
taglib_free(val); | |
val = NULL; | |
- assert(val = taglib_tag_artist(data->tag)); | |
+ if ((val = taglib_tag_artist(data->tag)) == NULL) | |
+ goto error_label; | |
if (strlen(val) > 0 && t_taglist_insert(tlist, "artist", val) == -1) | |
- goto error; | |
+ goto error_label; | |
taglib_free(val); | |
val = NULL; | |
uintval = taglib_tag_year(data->tag); | |
if (uintval > 0 && uintval < 10000) { | |
if (sprintf(buf, "%04u", uintval) < 0) | |
- goto error; | |
+ goto error_label; | |
if (t_taglist_insert(tlist, "year", buf) == -1) | |
- goto error; | |
+ goto error_label; | |
} | |
- assert(val = taglib_tag_album(data->tag)); | |
+ if ((val = taglib_tag_album(data->tag)) == NULL) | |
+ goto error_label; | |
if (strlen(val) > 0 && t_taglist_insert(tlist, "album", val) == -1) | |
- goto error; | |
+ goto error_label; | |
taglib_free(val); | |
val = NULL; | |
uintval = taglib_tag_track(data->tag); | |
if (uintval > 0 && uintval < 10000) { | |
if (sprintf(buf, "%02u", uintval) < 0) | |
- goto error; | |
+ goto error_label; | |
if (t_taglist_insert(tlist, "track", buf) == -1) | |
- goto error; | |
+ goto error_label; | |
} | |
- assert(val = taglib_tag_genre(data->tag)); | |
+ if ((val = taglib_tag_genre(data->tag)) == NULL) | |
+ goto error_label; | |
if (strlen(val) > 0 && t_taglist_insert(tlist, "genre", val) == -1) | |
- goto error; | |
+ goto error_label; | |
taglib_free(val); | |
val = NULL; | |
- assert(val = taglib_tag_comment(data->tag)); | |
+ if ((val = taglib_tag_comment(data->tag)) == NULL) | |
+ goto error_label; | |
if (strlen(val) > 0 && t_taglist_insert(tlist, "comment", val) == -1) | |
- goto error; | |
+ goto error_label; | |
taglib_free(val); | |
val = NULL; | |
return (tlist); | |
-error: | |
+error_label: | |
/* NOTE: the documentation does not state if NULL is a valid argument | |
for tablib_free() */ | |
if (val != NULL) | |
diff --git a/tagutil.c b/tagutil.c | |
index 78edd86..04c1cb2 100644 | |
--- a/tagutil.c | |
+++ b/tagutil.c | |
@@ -48,9 +48,8 @@ main(int argc, char *argv[]) | |
errno = 0; /* this is a bug in malloc(3) */ | |
- /* we assert because only the build system ensure that tagutil is build | |
- against at least libyaml as format. */ | |
- assert(Fflag = TAILQ_FIRST(t_all_formats())); | |
+ Fflag = TAILQ_FIRST(t_all_formats()); | |
+ /* FIXME: check that FFlag != NULL */ | |
while ((i = getopt(argc, argv, "hpF:NY")) != -1) { | |
switch ((char)i) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment