Message ID | 1595165763-13657-2-git-send-email-moshe@mellanox.com |
---|---|
State | Accepted |
Delegated to: | David Ahern |
Headers | show |
Series | devlink: Add devlink port health command | expand |
On 7/19/20 7:36 AM, Moshe Shemesh wrote: > From: Vladyslav Tarasiuk <vladyslavt@mellanox.com> > > Add a capability of printing port handles for arrays in non-JSON format > in devlink-health manner. > > Signed-off-by: Vladyslav Tarasiuk <vladyslavt@mellanox.com> > Reviewed-by: Jiri Pirko <jiri@mellanox.com> > --- > devlink/devlink.c | 14 +++++++++++++- > 1 files changed, 13 insertions(+), 1 deletions(-) > > diff --git a/devlink/devlink.c b/devlink/devlink.c > index 6768149..bb4588e 100644 > --- a/devlink/devlink.c > +++ b/devlink/devlink.c > @@ -2112,7 +2112,19 @@ static void __pr_out_port_handle_start(struct dl *dl, const char *bus_name, > open_json_object(buf); > } > } else { > - pr_out("%s:", buf); > + if (array) { > + if (should_arr_last_port_handle_end(dl, bus_name, dev_name, port_index)) > + __pr_out_indent_dec(); > + if (should_arr_last_port_handle_start(dl, bus_name, > + dev_name, port_index)) { > + pr_out("%s:", buf); > + __pr_out_newline(); > + __pr_out_indent_inc(); > + arr_last_port_handle_set(dl, bus_name, dev_name, port_index); > + } > + } else { > + pr_out("%s:", buf); > + } > } > } > > Why can't the 'if (dl->json_output) {' check be removed and this part be folded in with the context handled automatically by the print functions?
On 7/20/20 10:44 AM, David Ahern wrote: > Why can't the 'if (dl->json_output) {' check be removed and this part be > folded in with the context handled automatically by the print functions? never mind; I see now.
diff --git a/devlink/devlink.c b/devlink/devlink.c index 6768149..bb4588e 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -2112,7 +2112,19 @@ static void __pr_out_port_handle_start(struct dl *dl, const char *bus_name, open_json_object(buf); } } else { - pr_out("%s:", buf); + if (array) { + if (should_arr_last_port_handle_end(dl, bus_name, dev_name, port_index)) + __pr_out_indent_dec(); + if (should_arr_last_port_handle_start(dl, bus_name, + dev_name, port_index)) { + pr_out("%s:", buf); + __pr_out_newline(); + __pr_out_indent_inc(); + arr_last_port_handle_set(dl, bus_name, dev_name, port_index); + } + } else { + pr_out("%s:", buf); + } } }