Rework error handling where an oom variable was used

The oom-specific message was actually never used as it was hidden by
ret being < 0 and that condition was tested before oom.
This commit is contained in:
Julien BLACHE 2010-08-29 11:51:00 +02:00
parent 1eec8e1a7b
commit 471f750a8c

View File

@ -1336,7 +1336,6 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf,
int transcode; int transcode;
int want_mikd; int want_mikd;
int want_asdk; int want_asdk;
int oom;
int32_t val; int32_t val;
int i; int i;
int ret; int ret;
@ -1442,7 +1441,6 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf,
want_mikd = 0; want_mikd = 0;
want_asdk = 0; want_asdk = 0;
oom = 0;
nsongs = 0; nsongs = 0;
while (((ret = db_query_fetch_file(&qp, &dbmfi)) == 0) && (dbmfi.id)) while (((ret = db_query_fetch_file(&qp, &dbmfi)) == 0) && (dbmfi.id))
{ {
@ -1579,7 +1577,9 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf,
ret = evbuffer_add_buffer(songlist, song); ret = evbuffer_add_buffer(songlist, song);
if (ret < 0) if (ret < 0)
{ {
oom = 1; DPRINTF(E_LOG, L_DAAP, "Could not add song to song list for DAAP song list reply\n");
ret = -100;
break; break;
} }
} }
@ -1596,18 +1596,14 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf,
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_DAAP, "Error fetching results\n"); if (ret == -100)
dmap_send_error(req, tag, "Out of memory");
else
{
DPRINTF(E_LOG, L_DAAP, "Error fetching results\n");
dmap_send_error(req, tag, "Error fetching query results");
}
dmap_send_error(req, tag, "Error fetching query results");
db_query_end(&qp);
goto out_list_free;
}
if (oom)
{
DPRINTF(E_LOG, L_DAAP, "Could not add song to song list for DAAP song list reply\n");
dmap_send_error(req, tag, "Out of memory");
db_query_end(&qp); db_query_end(&qp);
goto out_list_free; goto out_list_free;
} }
@ -1698,7 +1694,6 @@ daap_reply_playlists(struct evhttp_request *req, struct evbuffer *evbuf, char **
uint32_t *meta; uint32_t *meta;
int nmeta; int nmeta;
int npls; int npls;
int oom;
int32_t val; int32_t val;
int i; int i;
int ret; int ret;
@ -1784,7 +1779,6 @@ daap_reply_playlists(struct evhttp_request *req, struct evbuffer *evbuf, char **
} }
npls = 0; npls = 0;
oom = 0;
while (((ret = db_query_fetch_pl(&qp, &dbpli)) == 0) && (dbpli.id)) while (((ret = db_query_fetch_pl(&qp, &dbpli)) == 0) && (dbpli.id))
{ {
npls++; npls++;
@ -1860,7 +1854,9 @@ daap_reply_playlists(struct evhttp_request *req, struct evbuffer *evbuf, char **
ret = evbuffer_add_buffer(playlistlist, playlist); ret = evbuffer_add_buffer(playlistlist, playlist);
if (ret < 0) if (ret < 0)
{ {
oom = 1; DPRINTF(E_LOG, L_DAAP, "Could not add playlist to playlist list for DAAP playlists reply\n");
ret = -100;
break; break;
} }
} }
@ -1875,18 +1871,14 @@ daap_reply_playlists(struct evhttp_request *req, struct evbuffer *evbuf, char **
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_DAAP, "Error fetching results\n"); if (ret == -100)
dmap_send_error(req, "aply", "Out of memory");
else
{
DPRINTF(E_LOG, L_DAAP, "Error fetching results\n");
dmap_send_error(req, "aply", "Error fetching query results");
}
dmap_send_error(req, "aply", "Error fetching query results");
db_query_end(&qp);
goto out_list_free;
}
if (oom)
{
DPRINTF(E_LOG, L_DAAP, "Could not add playlist to playlist list for DAAP playlists reply\n");
dmap_send_error(req, "aply", "Out of memory");
db_query_end(&qp); db_query_end(&qp);
goto out_list_free; goto out_list_free;
} }
@ -1941,7 +1933,6 @@ daap_reply_groups(struct evhttp_request *req, struct evbuffer *evbuf, char **uri
uint32_t *meta; uint32_t *meta;
int nmeta; int nmeta;
int ngrp; int ngrp;
int oom;
int32_t val; int32_t val;
int i; int i;
int ret; int ret;
@ -2031,7 +2022,6 @@ daap_reply_groups(struct evhttp_request *req, struct evbuffer *evbuf, char **uri
} }
ngrp = 0; ngrp = 0;
oom = 0;
while ((ret = db_query_fetch_group(&qp, &dbgri)) == 0) while ((ret = db_query_fetch_group(&qp, &dbgri)) == 0)
{ {
ngrp++; ngrp++;
@ -2084,7 +2074,9 @@ daap_reply_groups(struct evhttp_request *req, struct evbuffer *evbuf, char **uri
ret = evbuffer_add_buffer(grouplist, group); ret = evbuffer_add_buffer(grouplist, group);
if (ret < 0) if (ret < 0)
{ {
oom = 1; DPRINTF(E_LOG, L_DAAP, "Could not add group to group list for DAAP groups reply\n");
ret = -100;
break; break;
} }
} }
@ -2099,18 +2091,14 @@ daap_reply_groups(struct evhttp_request *req, struct evbuffer *evbuf, char **uri
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_DAAP, "Error fetching results\n"); if (ret == -100)
dmap_send_error(req, tag, "Out of memory");
else
{
DPRINTF(E_LOG, L_DAAP, "Error fetching results\n");
dmap_send_error(req, tag, "Error fetching query results");
}
dmap_send_error(req, tag, "Error fetching query results");
db_query_end(&qp);
goto out_list_free;
}
if (oom)
{
DPRINTF(E_LOG, L_DAAP, "Could not add group to group list for DAAP groups reply\n");
dmap_send_error(req, tag, "Out of memory");
db_query_end(&qp); db_query_end(&qp);
goto out_list_free; goto out_list_free;
} }