]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
devlink: Replace pr_#type_value wrapper functions with common functions
authorRon Diskin <rondi@mellanox.com>
Thu, 23 Jan 2020 10:32:30 +0000 (12:32 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Mon, 27 Jan 2020 13:43:54 +0000 (05:43 -0800)
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>
devlink/devlink.c

index a25dd818fdf9090401a596db686a16f51bb8e2f3..231a2838e86f417f2b5fe556c68d12970aa12567 100644 (file)
@@ -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));