diff mbox series

[iproute2,5/6] devlink: Replace pr_#type_value wrapper functions with common functions

Message ID 1579775551-22659-6-git-send-email-rondi@mellanox.com
State Accepted
Delegated to: stephen hemminger
Headers show
Series devlink: Replace devlink print helper functions with common library functions | expand

Commit Message

Ron Diskin Jan. 23, 2020, 10:32 a.m. UTC
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>
---
 devlink/devlink.c | 37 +++++--------------------------------
 1 file changed, 5 insertions(+), 32 deletions(-)
diff mbox series

Patch

diff --git a/devlink/devlink.c b/devlink/devlink.c
index a25dd818..231a2838 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));