All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ross Zwisler <ross.zwisler@linux.intel.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: linux-nvdimm <linux-nvdimm@lists.01.org>
Subject: Re: [ndctl PATCH 2/3] ndctl/list.c: simplify flags handling
Date: Fri, 29 Jun 2018 18:29:04 -0600	[thread overview]
Message-ID: <20180630002904.GA13491@linux.intel.com> (raw)
In-Reply-To: <CAPcyv4h+gtn-r6cVJS9wp+kbu9WGzWNFBBKQ0WjGpD7nJoo-cA@mail.gmail.com>

On Fri, Jun 29, 2018 at 04:57:29PM -0700, Dan Williams wrote:
> On Fri, Jun 29, 2018 at 4:39 PM, Ross Zwisler
> <ross.zwisler@linux.intel.com> wrote:
> > ndctl/list.c keeps track of a set of enum util_json_flags which are based
> > on the command line options passed in.  This handling is a little messy,
> > though.  We have an accessor function, listopts_to_flags(), which is used
> > multiple times.  We sometimes pass the flags around as function arguments,
> > and we also have a copy stashed in the local struct list_filter_arg called
> > "lfa".  In some functions we access the flags in multiple ways.
> >
> > These flags are local to ndctl/list.c, are set exactly once per invocation
> > and never change.  Create a variable local to that file, initialize it once
> > and use it everywhere.
> >
> > Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
> > ---
> >  ndctl/list.c  | 54 +++++++++++++++++++++++++++---------------------------
> >  util/filter.h |  1 -
> >  2 files changed, 27 insertions(+), 28 deletions(-)
> 
> I don't see the point of this thrash. It's not a win code size wise
> and I think it needlessly adds more dependence on global variables.

I disagree.  We currently have the flags value passed around as function
arguments, we have a version stashed in a data structure we pass around, and
we have one which is already essentially a global variable that is accessed
via an accessor function.  Having all three is complex and unnecessary,
especially considering that the flags never change.

Can we just choose one way of accessing the flags and use it everywhere?  If
not a global variable, which would you like to use?
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

  reply	other threads:[~2018-06-30  0:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-29 23:39 [ndctl PATCH 1/3] ndctl: simplify JSON print flag handling Ross Zwisler
2018-06-29 23:39 ` [ndctl PATCH 2/3] ndctl/list.c: simplify flags handling Ross Zwisler
2018-06-29 23:57   ` Dan Williams
2018-06-30  0:29     ` Ross Zwisler [this message]
2018-06-30  0:42       ` Dan Williams
2018-06-29 23:39 ` [ndctl PATCH 3/3] ndctl list: always output array without --human Ross Zwisler
2018-06-29 23:51 ` [ndctl PATCH 1/3] ndctl: simplify JSON print flag handling Dan Williams
2018-06-29 23:59   ` Verma, Vishal L

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180630002904.GA13491@linux.intel.com \
    --to=ross.zwisler@linux.intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=linux-nvdimm@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.