From 31d75df7c516c5e767e6b8219c2c08a39159d699 Mon Sep 17 00:00:00 2001
From: Matheus Teixeira <matheus.mtxr@gmail.com>
Date: Sun, 30 Jun 2019 08:39:18 +0000
Subject: [PATCH] Update rsensor.c: drop is_error macro definition. New json-c
 13.1 removed bits.h inclusion, deprecating de facto all the definitions
 inside. is_error is defined as "#define is_error(ptr) (ptr == NULL)"

in this case, double checking the same pointer is just useless, remove it.
Also simplify the double obj check in remote_psensor_update because obj can't change between the first and the second check

After writing the patch I discovered a new PR From: Matheus Teixeira <matheus.mtxr@gmail.com>, with really similar content, so I'm giving
credits for authorship to him.

Signed-off-by: Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
Signed-off-by: Gianfranco Costamagna <locutusofborg@debian.org>
---
 src/rsensor.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

Index: psensor-1.1.5/src/rsensor.c
===================================================================
--- psensor-1.1.5.orig/src/rsensor.c
+++ psensor-1.1.5/src/rsensor.c
@@ -125,7 +125,7 @@
 
 	obj = get_json_object(url);
 
-	if (obj && !is_error(obj)) {
+	if (obj) {
 		n = json_object_array_length(obj);
 		sensors = malloc((n + 1) * sizeof(struct psensor *));
 
@@ -160,24 +160,22 @@
 
 	obj = get_json_object(s->url);
 
-	if (obj && !is_error(obj)) {
+	if (obj) {
 		json_object *om;
 
 		json_object_object_get_ex(obj, "last_measure", &om);
 
-		if (!is_error(obj)) {
-			json_object *ov, *ot;
-			struct timeval tv;
+		json_object *ov, *ot;
+		struct timeval tv;
 
-			json_object_object_get_ex(om, "value", &ov);
-			json_object_object_get_ex(om, "time", &ot);
+		json_object_object_get_ex(om, "value", &ov);
+		json_object_object_get_ex(om, "time", &ot);
 
-			tv.tv_sec = json_object_get_int(ot);
-			tv.tv_usec = 0;
+		tv.tv_sec = json_object_get_int(ot);
+		tv.tv_usec = 0;
 
-			psensor_set_current_measure
-			    (s, json_object_get_double(ov), tv);
-		}
+		psensor_set_current_measure
+		    (s, json_object_get_double(ov), tv);
 
 		json_object_put(obj);
 	} else {
