[pulseaudio-discuss] [PATCH 4/4] format: Don't use deprecated json-c is_error() macro

Peter Meerwald pmeerw at pmeerw.net
Mon Aug 18 05:47:27 PDT 2014


From: Peter Meerwald <p.meerwald at bct-electronic.com>

json_tokener_parse() simply returns NULL on error these days

latest json-c (post 0.12) doesn't automatically include json-c/bits.h anymore
causing compilation errors

Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>
---
 src/pulse/format.c |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/pulse/format.c b/src/pulse/format.c
index 995e3df..e0a2d98 100644
--- a/src/pulse/format.c
+++ b/src/pulse/format.c
@@ -249,7 +249,7 @@ pa_prop_type_t pa_format_info_get_prop_type(const pa_format_info *f, const char
         return PA_PROP_TYPE_INVALID;
 
     o = json_tokener_parse(str);
-    if (is_error(o))
+    if (!o)
         return PA_PROP_TYPE_INVALID;
 
     switch (json_object_get_type(o)) {
@@ -289,7 +289,7 @@ pa_prop_type_t pa_format_info_get_prop_type(const pa_format_info *f, const char
                 break;
             }
 
-            if (!json_object_object_get_ex(o, PA_JSON_MAX_KEY, NULL) {
+            if (!json_object_object_get_ex(o, PA_JSON_MAX_KEY, NULL)) {
                 type = PA_PROP_TYPE_INVALID;
                 break;
             }
@@ -319,7 +319,7 @@ int pa_format_info_get_prop_int(const pa_format_info *f, const char *key, int *v
         return -PA_ERR_NOENTITY;
 
     o = json_tokener_parse(str);
-    if (is_error(o)) {
+    if (!o) {
         pa_log_debug("Failed to parse format info property '%s'.", key);
         return -PA_ERR_INVALID;
     }
@@ -351,7 +351,7 @@ int pa_format_info_get_prop_int_range(const pa_format_info *f, const char *key,
         return -PA_ERR_NOENTITY;
 
     o = json_tokener_parse(str);
-    if (is_error(o)) {
+    if (!o) {
         pa_log_debug("Failed to parse format info property '%s'.", key);
         return -PA_ERR_INVALID;
     }
@@ -394,7 +394,7 @@ int pa_format_info_get_prop_int_array(const pa_format_info *f, const char *key,
         return -PA_ERR_NOENTITY;
 
     o = json_tokener_parse(str);
-    if (is_error(o)) {
+    if (!o) {
         pa_log_debug("Failed to parse format info property '%s'.", key);
         return -PA_ERR_INVALID;
     }
@@ -440,7 +440,7 @@ int pa_format_info_get_prop_string(const pa_format_info *f, const char *key, cha
         return -PA_ERR_NOENTITY;
 
     o = json_tokener_parse(str);
-    if (is_error(o)) {
+    if (!o) {
         pa_log_debug("Failed to parse format info property '%s'.", key);
         return -PA_ERR_INVALID;
     }
@@ -472,7 +472,7 @@ int pa_format_info_get_prop_string_array(const pa_format_info *f, const char *ke
         return -PA_ERR_NOENTITY;
 
     o = json_tokener_parse(str);
-    if (is_error(o)) {
+    if (!o) {
         pa_log_debug("Failed to parse format info property '%s'.", key);
         return -PA_ERR_INVALID;
     }
@@ -631,11 +631,11 @@ static int pa_format_info_prop_compatible(const char *one, const char *two) {
     int i, ret = 0;
 
     o1 = json_tokener_parse(one);
-    if (is_error(o1))
+    if (!o1)
         goto out;
 
     o2 = json_tokener_parse(two);
-    if (is_error(o2))
+    if (!o2)
         goto out;
 
     /* We don't deal with both values being non-fixed - just because there is no immediate need (FIXME) */
-- 
1.7.9.5



More information about the pulseaudio-discuss mailing list