diff mbox series

[ndctl,2/2] cxl/event-trace: use the wrapped util_json_new_u64()

Message ID 20230223-meson-build-fixes-v1-2-5fae3b606395@intel.com
State Accepted
Commit 21d9a08d886bcfb85870b5b01b49b61aca37e2d5
Headers show
Series fix a couple of meson issues with v76 | expand

Commit Message

Verma, Vishal L Feb. 24, 2023, 5:45 a.m. UTC
The json-c API json_object_new_uint64() is relatively new, and some distros
may not have it available. There is already a wrapped version in
util/json.h which falls back to the int64 API, based on meson's
determination of the availability of the uint64 version at compile time.
Replace the direct uint64 calls with this wrapped version.

Link: https://github.com/pmem/ndctl/issues/233
Fixes: 8dedc6cf5e85 ("cxl: add a helper to parse trace events into a json object")
Reported-by: Michal Suchánek <msuchanek@suse.de>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 cxl/event_trace.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Ira Weiny Feb. 24, 2023, 7:55 a.m. UTC | #1
Vishal Verma wrote:
> The json-c API json_object_new_uint64() is relatively new, and some distros
> may not have it available. There is already a wrapped version in
> util/json.h which falls back to the int64 API, based on meson's
> determination of the availability of the uint64 version at compile time.
> Replace the direct uint64 calls with this wrapped version.
> 
> Link: https://github.com/pmem/ndctl/issues/233
> Fixes: 8dedc6cf5e85 ("cxl: add a helper to parse trace events into a json object")
> Reported-by: Michal Suchánek <msuchanek@suse.de>
> Cc: Dave Jiang <dave.jiang@intel.com>
> Cc: Dan Williams <dan.j.williams@intel.com>

Reviewed-by: Ira Weiny <ira.weiny@intel.com>

> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
> ---
>  cxl/event_trace.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/cxl/event_trace.c b/cxl/event_trace.c
> index 926f446..db8cc85 100644
> --- a/cxl/event_trace.c
> +++ b/cxl/event_trace.c
> @@ -25,7 +25,7 @@ static struct json_object *num_to_json(void *num, int elem_size, unsigned long f
>  		if (sign)
>  			return json_object_new_int64(*(int64_t *)num);
>  		else
> -			return json_object_new_uint64(*(uint64_t *)num);
> +			return util_json_new_u64(*(uint64_t *)num);
>  	}
>  
>  	/* All others fit in a signed 64 bit */
> @@ -98,7 +98,7 @@ static int cxl_event_to_json(struct tep_event *event, struct tep_record *record,
>  	}
>  	json_object_object_add(jevent, "event", jobj);
>  
> -	jobj = json_object_new_uint64(record->ts);
> +	jobj = util_json_new_u64(record->ts);
>  	if (!jobj) {
>  		rc = -ENOMEM;
>  		goto err_jevent;
> 
> -- 
> 2.39.1
>
Dave Jiang Feb. 24, 2023, 3:29 p.m. UTC | #2
On 2/23/23 10:45 PM, Vishal Verma wrote:
> The json-c API json_object_new_uint64() is relatively new, and some distros
> may not have it available. There is already a wrapped version in
> util/json.h which falls back to the int64 API, based on meson's
> determination of the availability of the uint64 version at compile time.
> Replace the direct uint64 calls with this wrapped version.
> 
> Link: https://github.com/pmem/ndctl/issues/233
> Fixes: 8dedc6cf5e85 ("cxl: add a helper to parse trace events into a json object")
> Reported-by: Michal Suchánek <msuchanek@suse.de>
> Cc: Dave Jiang <dave.jiang@intel.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>

Reviewed-by: Dave Jiang <dave.jiang@intel.com>

> ---
>   cxl/event_trace.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/cxl/event_trace.c b/cxl/event_trace.c
> index 926f446..db8cc85 100644
> --- a/cxl/event_trace.c
> +++ b/cxl/event_trace.c
> @@ -25,7 +25,7 @@ static struct json_object *num_to_json(void *num, int elem_size, unsigned long f
>   		if (sign)
>   			return json_object_new_int64(*(int64_t *)num);
>   		else
> -			return json_object_new_uint64(*(uint64_t *)num);
> +			return util_json_new_u64(*(uint64_t *)num);
>   	}
>   
>   	/* All others fit in a signed 64 bit */
> @@ -98,7 +98,7 @@ static int cxl_event_to_json(struct tep_event *event, struct tep_record *record,
>   	}
>   	json_object_object_add(jevent, "event", jobj);
>   
> -	jobj = json_object_new_uint64(record->ts);
> +	jobj = util_json_new_u64(record->ts);
>   	if (!jobj) {
>   		rc = -ENOMEM;
>   		goto err_jevent;
>
diff mbox series

Patch

diff --git a/cxl/event_trace.c b/cxl/event_trace.c
index 926f446..db8cc85 100644
--- a/cxl/event_trace.c
+++ b/cxl/event_trace.c
@@ -25,7 +25,7 @@  static struct json_object *num_to_json(void *num, int elem_size, unsigned long f
 		if (sign)
 			return json_object_new_int64(*(int64_t *)num);
 		else
-			return json_object_new_uint64(*(uint64_t *)num);
+			return util_json_new_u64(*(uint64_t *)num);
 	}
 
 	/* All others fit in a signed 64 bit */
@@ -98,7 +98,7 @@  static int cxl_event_to_json(struct tep_event *event, struct tep_record *record,
 	}
 	json_object_object_add(jevent, "event", jobj);
 
-	jobj = json_object_new_uint64(record->ts);
+	jobj = util_json_new_u64(record->ts);
 	if (!jobj) {
 		rc = -ENOMEM;
 		goto err_jevent;