diff options
author | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2012-02-06 11:20:17 +0530 |
---|---|---|
committer | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2012-03-05 20:00:31 +0530 |
commit | 63429b67c744562cb6f3467ff9393788650996d7 (patch) | |
tree | baedc99cc07f88eef49714b8f0dcfc7a3299560f | |
parent | 6f20d39a1c55c4f6b0fc0dce16c5f75e3bd84004 (diff) |
format: Don't assert on errors in getters
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.
-rw-r--r-- | 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 d37356d3d..4de6e8929 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; |