simplify get_atts()
authorAndre Noll <maan@systemlinux.org>
Tue, 20 Feb 2007 19:14:12 +0000 (20:14 +0100)
committerAndre Noll <maan@systemlinux.org>
Tue, 20 Feb 2007 19:14:12 +0000 (20:14 +0100)
remove pointless ret variable and clarify comment.

mysql_selector.c

index f50ac410079615676268a0b0a5a2b7f546d744ce..d4ccc86845821d02f53edd5868a265ca6bd777f9 100644 (file)
@@ -578,40 +578,38 @@ out:
        return ret;
 }
 
-/* get attributes by name. If verbose is not 0, get_a writes a string
- * into atts of the form 'att1="0",att2="1"', which is used in com_cam
- * for contructing a mysql update query.
- * never returns NULL in *NON VERBOSE* mode
+/*
+ * get attributes by name. If verbose is not 0, this function returns a string
+ * of the form 'att1="0",att2="1"'... which is used in com_cam() for
+ * constructing a mysql update query. Otherwise the space-separated list of all
+ * attributes which are set in the audio file given by name is returned.  Never
+ * returns NULL in *NON VERBOSE* mode.
  */
 static char *get_atts(char *name, int verbose)
 {
        char *atts = NULL, *buf, *ebn;
        void *result = NULL, *result2 = NULL;
        MYSQL_ROW row, row2;
-       int i, ret;
-       unsigned int num_fields;
+       int i;
+       unsigned num_fields;
 
-       ret = -E_NOATTS;
        result2 = get_all_attributes();
        if (!result2)
                goto out;
-       ret = -E_ESCAPE;
-       if (!(ebn = escaped_basename(name)))
+       ebn = escaped_basename(name);
+       if (!ebn)
                goto out;
        buf = make_message("select * from data where name='%s'", ebn);
        free(ebn);
-       ret = -E_NORESULT;
        result = get_result(buf);
        free(buf);
        if (!result)
                goto out;
-       ret = -E_EMPTY_RESULT;
        num_fields = mysql_num_fields(result);
        if (num_fields < 5)
                goto out;
        mysql_data_seek(result2, 4); /* skip Lastplayed, Numplayed... */
        row = mysql_fetch_row(result);
-       ret = -E_NOROW;
        if (!row)
                goto out;
        for (i = 4; i < num_fields; i++) {
@@ -626,7 +624,6 @@ static char *get_atts(char *name, int verbose)
                if (verbose)
                        atts = para_strcat(atts, is_set? "=\"1\"" : "=\"0\"");
        }
-       ret = 1;
 out:
        if (result2)
                mysql_free_result(result2);