Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add yajl dependency, bt_value_from_json(), and tests #2

Open
wants to merge 101 commits into
base: plugin_system
Choose a base branch
from

Conversation

eepp
Copy link
Contributor

@eepp eepp commented Feb 25, 2016

This one adds a dependency on yajl, either 1.x or 2.x (2.x is preferred). The m4/ax_check_yajl.m4 macro is responsible for checking the available yajl versions.

A shim is added (include/babeltrace/yajl.h) to support both yajl 1.x and 2.x. There are minor differences between the two versions, in particular some integer types and some function names and parameters. All yajl functions should be used in the bt_ namespace.

This shim is used by the new lib/values-json.c to implement bt_value_from_json(), a function which converts a JSON string to a value object using yajl. Signed 64-bit integers are supported thanks to using sscanf() instead of using the yajl's integer callback, because the 1.x callback has a long parameter, which would be 32-bit on a 32-bit build. sscanf() is also used to parse double precision floating point numbers.

bt_value_from_json() is thoroughly tested (61 new tests) in tests/lib/test_bt_values.c.

I built Babeltrace and ran the tests successfully, including a Valgrind memcheck, with the following configurations:

  • yajl 2.1.0, 64-bit
  • yajl 1.0.12, 64-bit
  • yajl 1.0.12, 32-bit

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
This new header wraps yajl so that Babeltrace code can use
yajl 1.x or yajl 2.x transparently.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
@jgalar jgalar force-pushed the plugin_system branch 3 times, most recently from 9876044 to 87889f2 Compare July 28, 2016 20:32
jgalar pushed a commit that referenced this pull request Aug 29, 2017
Found by Coverity:

CID 1376200 (#2 of 2): Inferred misuse of enum (MIXED_ENUMS)
mixed_enums: Mixing enum types enum bt_ctf_field_type_id and enum
ctf_type_id for ctx_cur_field_type_id.

(audited whole file for similar pattern)

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants