[PATCH 2/7] format: Don't assert on errors in getters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This makes handling errors in getter functions more graceful, rather
than triggering warnings/asserts. Better to be less trigger-happy about
these things since this is now public-facing API.
---
 src/pulse/format.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/pulse/format.c b/src/pulse/format.c
index d37356d..4de6e89 100644
--- a/src/pulse/format.c
+++ b/src/pulse/format.c
@@ -308,9 +308,14 @@ int pa_format_info_get_prop_int(pa_format_info *f, const char *key, int *v) {
     pa_assert(key);
     pa_assert(v);
 
-    pa_return_val_if_fail(str = pa_proplist_gets(f->plist, key), -PA_ERR_NOENTITY);
+    str = pa_proplist_gets(f->plist, key);
+    if (!str)
+        return -PA_ERR_NOENTITY;
+
     o = json_tokener_parse(str);
-    pa_return_val_if_fail(!is_error(o), -PA_ERR_INVALID);
+    if (is_error(o))
+        return -PA_ERR_INVALID;
+
     if (json_object_get_type(o) != json_type_int) {
         json_object_put(o);
         return -PA_ERR_INVALID;
@@ -335,7 +340,9 @@ int pa_format_info_get_prop_string(pa_format_info *f, const char *key, char **v)
         return -PA_ERR_NOENTITY;
 
     o = json_tokener_parse(str);
-    pa_return_val_if_fail(!is_error(o), -PA_ERR_INVALID);
+    if (is_error(o))
+        return -PA_ERR_INVALID;
+
     if (json_object_get_type(o) != json_type_string) {
         json_object_put(o);
         return -PA_ERR_INVALID;
-- 
1.7.8.4



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux