From: Jaroslav Kysela Date: Mon, 14 Oct 2019 16:33:06 +0000 (+0200) Subject: api: fix the wrong negative error codes, fixes #5743 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c67ba3ce1ba445cf2aea28315bdf97477f43198b;p=thirdparty%2Ftvheadend.git api: fix the wrong negative error codes, fixes #5743 --- diff --git a/src/api/api_bouquet.c b/src/api/api_bouquet.c index 7177d8236..cbf196b73 100644 --- a/src/api/api_bouquet.c +++ b/src/api/api_bouquet.c @@ -88,7 +88,7 @@ bouquet_cb int r = 0; if (!(f = htsmsg_field_find(args, "uuid"))) - return -EINVAL; + return EINVAL; if ((uuids = htsmsg_field_get_list(f))) { HTSMSG_FOREACH(f, uuids) { if (!(uuid = htsmsg_field_get_str(f))) continue; @@ -101,7 +101,7 @@ bouquet_cb r = cb(uuid); tvh_mutex_unlock(&global_lock); } else { - return -EINVAL; + return EINVAL; } return r; @@ -114,7 +114,7 @@ static int bouquet_cb_scan(const char *uuid) bouquet_scan(bq); return 0; } - return -ENOENT; + return ENOENT; } static int @@ -131,7 +131,7 @@ static int bouquet_cb_detach(const char *uuid) bouquet_detach(ch); return 0; } - return -ENOENT; + return ENOENT; } static int diff --git a/src/api/api_caclient.c b/src/api/api_caclient.c index a9a81aa3b..ad24820d8 100644 --- a/src/api/api_caclient.c +++ b/src/api/api_caclient.c @@ -89,7 +89,7 @@ api_caclient_create if (cac) api_idnode_create(resp, &cac->cac_id); else - err = -EINVAL; + err = EINVAL; tvh_mutex_unlock(&global_lock); return err; diff --git a/src/api/api_channel.c b/src/api/api_channel.c index 98f6ca860..b67051da4 100644 --- a/src/api/api_channel.c +++ b/src/api/api_channel.c @@ -111,15 +111,15 @@ api_channel_rename { const char *from, *to; if (!(from = htsmsg_get_str(args, "from"))) - return -EINVAL; + return EINVAL; if (!(to = htsmsg_get_str(args, "to"))) - return -EINVAL; + return EINVAL; /* We need the lock since we are altering details */ tvh_mutex_lock(&global_lock); const int num_match = channel_rename_and_save(from, to); tvh_mutex_unlock(&global_lock); - return num_match > 0 ? 0 : -ENOENT; + return num_match > 0 ? 0 : ENOENT; } static int diff --git a/src/api/api_dvr.c b/src/api/api_dvr.c index 68829e277..a39009258 100644 --- a/src/api/api_dvr.c +++ b/src/api/api_dvr.c @@ -553,11 +553,11 @@ api_dvr_entry_file_moved { const char *src, *dst; if (!(src = htsmsg_get_str(args, "src"))) - return -EINVAL; + return EINVAL; if (!(dst = htsmsg_get_str(args, "dst"))) - return -EINVAL; + return EINVAL; if (dvr_entry_file_moved(src, dst)) - return -ENOENT; + return ENOENT; return 0; } diff --git a/src/api/api_epg.c b/src/api/api_epg.c index 61b9e77df..3cb8388d4 100644 --- a/src/api/api_epg.c +++ b/src/api/api_epg.c @@ -602,7 +602,7 @@ api_epg_alternative char *lang; if (htsmsg_get_u32(args, "eventId", &id)) - return -EINVAL; + return EINVAL; /* Main Job */ lang = access_get_lang(perm, htsmsg_get_str(args, "lang")); @@ -633,7 +633,7 @@ api_epg_related const char *title = NULL; if (htsmsg_get_u32(args, "eventId", &id)) - return -EINVAL; + return EINVAL; /* Main Job */ lang = access_get_lang(perm, htsmsg_get_str(args, "lang")); @@ -691,10 +691,10 @@ api_epg_load char *lang; if (!(f = htsmsg_field_find(args, "eventId"))) - return -EINVAL; + return EINVAL; if (!(ids = htsmsg_field_get_list(f))) if (htsmsg_field_get_u32(f, &id)) - return -EINVAL; + return EINVAL; /* Main Job */ tvh_mutex_lock(&global_lock); diff --git a/src/api/api_idnode.c b/src/api/api_idnode.c index 9715941c9..fe0bf40a6 100644 --- a/src/api/api_idnode.c +++ b/src/api/api_idnode.c @@ -264,7 +264,7 @@ api_idnode_load meta = htsmsg_get_s32_or_default(args, "meta", 0); grid = htsmsg_get_s32_or_default(args, "grid", 0); if (grid > 0 && meta > 0) - return -EINVAL; + return EINVAL; flist = api_idnode_flist_conf(args, "list"); diff --git a/src/api/api_input.c b/src/api/api_input.c index c224fc46a..55896819d 100644 --- a/src/api/api_input.c +++ b/src/api/api_input.c @@ -44,7 +44,7 @@ api_input_satip_discover int err = 0; if (op == NULL || strcmp(op, "all")) - return -EINVAL; + return EINVAL; tvhinfo(LS_SATIP, "Triggered new server discovery"); diff --git a/src/api/api_mpegts.c b/src/api/api_mpegts.c index d18d30a25..18caf10a5 100644 --- a/src/api/api_mpegts.c +++ b/src/api/api_mpegts.c @@ -141,7 +141,7 @@ api_mpegts_network_scan const char *uuid; if (!(f = htsmsg_field_find(args, "uuid"))) - return -EINVAL; + return EINVAL; if ((uuids = htsmsg_field_get_list(f))) { HTSMSG_FOREACH(f, uuids) { if (!(uuid = htsmsg_field_get_str(f))) continue; @@ -158,9 +158,9 @@ api_mpegts_network_scan mn->mn_scan(mn); tvh_mutex_unlock(&global_lock); if (!mn) - return -ENOENT; + return ENOENT; } else { - return -EINVAL; + return EINVAL; } return 0; @@ -371,11 +371,11 @@ api_dvb_scanfile_list scanfile_network_t *n; if (!type) - return -EINVAL; + return EINVAL; list = scanfile_find_region_list(type); if (!list) - return -EINVAL; + return EINVAL; l = htsmsg_create_list(); LIST_FOREACH(r, &list->srl_regions, sfr_link) { diff --git a/src/api/api_profile.c b/src/api/api_profile.c index f54fd16bd..e07968d84 100644 --- a/src/api/api_profile.c +++ b/src/api/api_profile.c @@ -121,7 +121,7 @@ api_profile_create if (pro) api_idnode_create(resp, &pro->pro_id); else - err = -EINVAL; + err = EINVAL; tvh_mutex_unlock(&global_lock); return err; diff --git a/src/webui/webui_api.c b/src/webui/webui_api.c index 72d6d359a..299c2f773 100644 --- a/src/webui/webui_api.c +++ b/src/webui/webui_api.c @@ -51,6 +51,10 @@ destroy_args: /* Convert error */ if (r) { + if (r < 0) { + tvherror(LS_HTTP, "negative error code %d for url '%s'", r, hc->hc_url); + r = ENOSYS; + } switch (r) { case EPERM: case EACCES: