]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
api: fix the wrong negative error codes, fixes #5743
authorJaroslav Kysela <perex@perex.cz>
Mon, 14 Oct 2019 16:33:06 +0000 (18:33 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 14 Oct 2019 16:33:06 +0000 (18:33 +0200)
src/api/api_bouquet.c
src/api/api_caclient.c
src/api/api_channel.c
src/api/api_dvr.c
src/api/api_epg.c
src/api/api_idnode.c
src/api/api_input.c
src/api/api_mpegts.c
src/api/api_profile.c
src/webui/webui_api.c

index 7177d82365e02529ec7fe992b24e15f364417a38..cbf196b7314cba73131d0b8fc49fdafda9a6f09f 100644 (file)
@@ -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
index a9a81aa3beb2f25c485d59275a1422d81855c488..ad24820d825ca1dc825759ecd6ab686a02db3fe7 100644 (file)
@@ -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;
index 98f6ca8608c1d8a0d9042e56b9984759e1ae2905..b67051da4bfaafd383c966d667c19a1c2014479f 100644 (file)
@@ -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
index 68829e277107e8ca650c1d56bf4afdfc93188f24..a390092582bb0b29fbbaa771e78a334dfab5f957 100644 (file)
@@ -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;
 }
 
index 61b9e77dfabb28630f2810117361d862046168cc..3cb8388d47c5e432e65a35e2a646ef9eae12528b 100644 (file)
@@ -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);
index 9715941c9e0cf86e580cbcf1dbc023d0415849ab..fe0bf40a61fc774dace03118b9b701e6add0a00a 100644 (file)
@@ -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");
 
index c224fc46a02d8224935f65bafb8a1933d3847054..55896819d989a3a9b0913216b2f5d6fee054ecd8 100644 (file)
@@ -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");
 
index d18d30a25221bf8001203057d8e9edda9c86b542..18caf10a52f624f48f548d2ae492372808fe6c05 100644 (file)
@@ -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) {
index f54fd16bd32ebd747d7701d2b5fa3048ece4b829..e07968d844d7bb931b4386170eae7018906202fa 100644 (file)
@@ -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;
index 72d6d359a57a9b36ed977519d996d014ce3d802a..299c2f7734c81085ab652607b61cefca5b6a96ef 100644 (file)
@@ -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: