From: Jiri Pirko Date: Mon, 5 Dec 2022 12:21:57 +0000 (+0100) Subject: devlink: push common code to __pr_out_port_handle_start_tb() X-Git-Tag: v6.2.0~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18ff3ccbc8535fe3cb8319eebc097e50d326632d;p=thirdparty%2Fiproute2.git devlink: push common code to __pr_out_port_handle_start_tb() There is a common code in pr_out_port_handle_start() and pr_out_port_handle_start_arr(). As the next patch is going to extend it even more, push the code into common helper. Signed-off-by: Jiri Pirko Signed-off-by: David Ahern --- diff --git a/devlink/devlink.c b/devlink/devlink.c index af5f14039..93d83a079 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -2764,7 +2764,8 @@ static void __pr_out_port_handle_start(struct dl *dl, const char *bus_name, } } -static void pr_out_port_handle_start(struct dl *dl, struct nlattr **tb, bool try_nice) +static void __pr_out_port_handle_start_tb(struct dl *dl, struct nlattr **tb, + bool try_nice, bool array) { const char *bus_name; const char *dev_name; @@ -2773,19 +2774,17 @@ static void pr_out_port_handle_start(struct dl *dl, struct nlattr **tb, bool try bus_name = mnl_attr_get_str(tb[DEVLINK_ATTR_BUS_NAME]); dev_name = mnl_attr_get_str(tb[DEVLINK_ATTR_DEV_NAME]); port_index = mnl_attr_get_u32(tb[DEVLINK_ATTR_PORT_INDEX]); - __pr_out_port_handle_start(dl, bus_name, dev_name, port_index, try_nice, false); + __pr_out_port_handle_start(dl, bus_name, dev_name, port_index, try_nice, array); } -static void pr_out_port_handle_start_arr(struct dl *dl, struct nlattr **tb, bool try_nice) +static void pr_out_port_handle_start(struct dl *dl, struct nlattr **tb, bool try_nice) { - const char *bus_name; - const char *dev_name; - uint32_t port_index; + __pr_out_port_handle_start_tb(dl, tb, try_nice, false); +} - bus_name = mnl_attr_get_str(tb[DEVLINK_ATTR_BUS_NAME]); - dev_name = mnl_attr_get_str(tb[DEVLINK_ATTR_DEV_NAME]); - port_index = mnl_attr_get_u32(tb[DEVLINK_ATTR_PORT_INDEX]); - __pr_out_port_handle_start(dl, bus_name, dev_name, port_index, try_nice, true); +static void pr_out_port_handle_start_arr(struct dl *dl, struct nlattr **tb, bool try_nice) +{ + __pr_out_port_handle_start_tb(dl, tb, try_nice, true); } static void pr_out_port_handle_end(struct dl *dl)