Subject: Re: [PATCH iproute2-next v3 1/2] dcb: add new pcp-prio parameter to dcb app

From: Stephen Hemminger <[email-masked]>
Date: Sun, 4 Dec 2022 17:52:57 -0800

On Sun, 4 Dec 2022 22:27:40 +0000
<[email-masked]> wrote:

> > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> > 
> > On Fri, 2 Dec 2022 10:22:34 +0100
> > Daniel Machon <[email-masked]> wrote:
> >   
> > > +static int dcb_app_print_key_pcp(__u16 protocol)
> > > +{
> > > +     /* Print in numerical form, if protocol value is out-of-range */
> > > +     if (protocol > DCB_APP_PCP_MAX) {
> > > +             fprintf(stderr, "Unknown PCP key: %d\n", protocol);
> > > +             return print_uint(PRINT_ANY, NULL, "%d:", protocol);
> > > +     }
> > > +
> > > +     return print_string(PRINT_ANY, NULL, "%s:", pcp_names[protocol]);
> > > +}  
> > 
> > This is not an application friendly way to produce JSON output.
> > You need to put a key on each one, and value should not contain colon.  
> 
> Hi Stephen,
> 
> Trying to understand your comment.
> 
> Are you talking about not producing any JSON output with the symbolic
> PCP values? eg. ["1de", 1] -> [8, 1]. So basically print with PRINT_FP
> in case of printing in JSON context?
> 
> /Daniel

What does output look like in json and non-json versions?
My concern that the json version would be awkward and have colons in it, but looks
like it won't.

For the unknown key type is printing error necessary? Maybe just show it in numeric form.