| 948 | } |
| 949 | |
| 950 | int |
| 951 | cpfl_parser_create(struct cpfl_flow_js_parser **flow_parser, const char *filename) |
| 952 | { |
| 953 | struct cpfl_flow_js_parser *parser; |
| 954 | json_error_t json_error; |
| 955 | json_t *root; |
| 956 | int ret; |
| 957 | |
| 958 | parser = rte_zmalloc("flow_parser", sizeof(struct cpfl_flow_js_parser), 0); |
| 959 | if (!parser) { |
| 960 | PMD_DRV_LOG(ERR, "Not enough memory to create flow parser."); |
| 961 | return -ENOMEM; |
| 962 | } |
| 963 | root = json_load_file(filename, 0, &json_error); |
| 964 | if (!root) { |
| 965 | PMD_DRV_LOG(ERR, "Bad JSON file \"%s\": %s", filename, json_error.text); |
| 966 | goto free_parser; |
| 967 | } |
| 968 | ret = cpfl_parser_init(root, parser); |
| 969 | if (ret < 0) { |
| 970 | PMD_DRV_LOG(ERR, "parser init failed."); |
| 971 | goto free_parser; |
| 972 | } |
| 973 | *flow_parser = parser; |
| 974 | json_decref(root); |
| 975 | |
| 976 | return 0; |
| 977 | free_parser: |
| 978 | rte_free(parser); |
| 979 | return -EINVAL; |
| 980 | } |
| 981 | |
| 982 | static void |
| 983 | cpfl_parser_free_pr_action(struct cpfl_flow_js_pr_action *pr_act) |
no test coverage detected