From: Andre Noll Date: Tue, 20 Feb 2007 19:14:12 +0000 (+0100) Subject: simplify get_atts() X-Git-Tag: v0.2.16~76^2~6 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=e427612b561782af169327d46ef4df4a398e0c38;p=paraslash.git simplify get_atts() remove pointless ret variable and clarify comment. --- diff --git a/mysql_selector.c b/mysql_selector.c index f50ac410..d4ccc868 100644 --- a/mysql_selector.c +++ b/mysql_selector.c @@ -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);