Subject: Re: [ethtool v2 4/6] Add --json command line argument parsing

From: Stephen Hemminger <[email-masked]>
Date: Wed, 24 Jun 2020 22:32:58 -0700

On Thu, 25 Jun 2020 02:12:42 +0200
Andrew Lunn <[email-masked]> 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.