diff options
author | Ron Diskin <rondi@mellanox.com> | 2020-01-23 12:32:30 +0200 |
---|---|---|
committer | Stephen Hemminger <stephen@networkplumber.org> | 2020-01-27 05:43:54 -0800 |
commit | 5a71671a94572af4c4092e2d91f8d6d384345e0c (patch) | |
tree | a02bbb78e724173bf84a008c60fd120b46d63f6a | |
parent | 3666eb0eb65ba0cac0121d9f6e373647cc144e1a (diff) | |
download | iproute2-5a71671a94572af4c4092e2d91f8d6d384345e0c.tar.gz |
devlink: Replace pr_#type_value wrapper functions with common functions
Replace calls for pr_bool/uint/uint64_value with direct calls for the
matching common json_print library function: print_bool(), print_uint()
and print_u64()
Signed-off-by: Ron Diskin <rondi@mellanox.com>
Reviewed-by: Moshe Shemesh <moshe@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
-rw-r--r-- | devlink/devlink.c | 37 |
1 files changed, 5 insertions, 32 deletions
diff --git a/devlink/devlink.c b/devlink/devlink.c index a25dd818f..231a2838e 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -1905,33 +1905,6 @@ static void pr_out_u64(struct dl *dl, const char *name, uint64_t val) pr_out("%s %"PRIu64, name, val); } -static void pr_out_bool_value(struct dl *dl, bool value) -{ - __pr_out_indent_newline(dl); - if (dl->json_output) - print_bool(PRINT_JSON, NULL, NULL, value); - else - pr_out("%s", value ? "true" : "false"); -} - -static void pr_out_uint_value(struct dl *dl, unsigned int value) -{ - __pr_out_indent_newline(dl); - if (dl->json_output) - print_uint(PRINT_JSON, NULL, NULL, value); - else - pr_out("%u", value); -} - -static void pr_out_uint64_value(struct dl *dl, uint64_t value) -{ - __pr_out_indent_newline(dl); - if (dl->json_output) - print_u64(PRINT_JSON, NULL, NULL, value); - else - pr_out("%"PRIu64, value); -} - static bool is_binary_eol(int i) { return !(i%16); @@ -6450,19 +6423,19 @@ static int fmsg_value_show(struct dl *dl, int type, struct nlattr *nl_data) check_indent_newline(dl); switch (type) { case MNL_TYPE_FLAG: - pr_out_bool_value(dl, mnl_attr_get_u8(nl_data)); + print_bool(PRINT_ANY, NULL, "%s", mnl_attr_get_u8(nl_data)); break; case MNL_TYPE_U8: - pr_out_uint_value(dl, mnl_attr_get_u8(nl_data)); + print_uint(PRINT_ANY, NULL, "%u", mnl_attr_get_u8(nl_data)); break; case MNL_TYPE_U16: - pr_out_uint_value(dl, mnl_attr_get_u16(nl_data)); + print_uint(PRINT_ANY, NULL, "%u", mnl_attr_get_u16(nl_data)); break; case MNL_TYPE_U32: - pr_out_uint_value(dl, mnl_attr_get_u32(nl_data)); + print_uint(PRINT_ANY, NULL, "%u", mnl_attr_get_u32(nl_data)); break; case MNL_TYPE_U64: - pr_out_uint64_value(dl, mnl_attr_get_u64(nl_data)); + print_u64(PRINT_ANY, NULL, "%"PRIu64, mnl_attr_get_u64(nl_data)); break; case MNL_TYPE_NUL_STRING: print_string(PRINT_ANY, NULL, "%s", mnl_attr_get_str(nl_data)); |