lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200625141359.GL442307@lunn.ch>
Date:   Thu, 25 Jun 2020 16:13:59 +0200
From:   Andrew Lunn <andrew@...n.ch>
To:     Stephen Hemminger <stephen@...workplumber.org>
Cc:     Michal Kubecek <mkubecek@...e.cz>, netdev <netdev@...r.kernel.org>,
        Chris Healy <cphealy@...il.com>
Subject: Re: [ethtool v2 4/6] Add --json command line argument parsing

On Wed, Jun 24, 2020 at 10:32:58PM -0700, Stephen Hemminger wrote:
> On Thu, 25 Jun 2020 02:12:42 +0200
> Andrew Lunn <andrew@...n.ch> wrote:
> 
> > diff --git a/internal.h b/internal.h
> > index edb07bd..7135140 100644
> > --- a/internal.h
> > +++ b/internal.h
> > @@ -23,6 +23,8 @@
> >  #include <sys/ioctl.h>
> >  #include <net/if.h>
> >  
> > +#include "json_writer.h"
> > +
> >  #define maybe_unused __attribute__((__unused__))
> >  
> >  /* internal for netlink interface */
> > @@ -221,6 +223,8 @@ struct cmd_context {
> >  	int argc;		/* number of arguments to the sub-command */
> >  	char **argp;		/* arguments to the sub-command */
> >  	unsigned long debug;	/* debugging mask */
> > +	bool json;		/* Output JSON, if supported */
> > +	json_writer_t *jw;      /* JSON writer instance */
> 
> You can avoid the boolean by just checking for NULL jw variable.

Hi Stephen

It is a while since i wrote this code, but i think i considered
that. The problem is, only a few commands support json output. I could
call json_new() unconditional of if the command actually support json
or not, that is not a problem. But then json_destory() should also be
unconditionally called. And that does fputs("\n", self->out); So you
end up with an extra blank line.

Using the boolean allows me to defer json_new()/json_destroy() into
the actual commands which supports json.

       Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ