All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: "Luis R. Rodriguez" <mcgrof@kernel.org>
Cc: Jan Tulak <jtulak@redhat.com>, linux-xfs@vger.kernel.org
Subject: Re: [xfsprogs] Do we need so many data types for user input?
Date: Wed, 5 Apr 2017 22:15:19 +1000	[thread overview]
Message-ID: <20170405121519.GR17542@dastard> (raw)
In-Reply-To: <20170404194825.GX28800@wotan.suse.de>

On Tue, Apr 04, 2017 at 09:48:25PM +0200, Luis R. Rodriguez wrote:
> On Tue, Apr 04, 2017 at 10:54:09AM +0200, Jan Tulak wrote:
> > Simply stated, signed values seem to be useless here. And at the end
> > of the day, we are converting all numbers into unsigned in one part of
> > the parsing anyway, so I don't see how such a change could change any
> > behaviour.
> > 
> > So what do you think, can I remove the other types in user-input part
> > of the code and save all numbers as uint64?
> 
> This seems reasonable to me, I could not find any valid use for negative values,
> yet we have int all over. No bueno.

Keep in mind you're looking at coding pattersn that were laid down
more than 20 years ago by people with different coding standards and
habits. e.g. lots of the values were originally ints because they
were set by calls to atoi() in command line parsing. the atoi()
calls are long gone, but the variables are still ints...

....

> FWIW since I had made the mkfs.xfs.conf RFCs I determined what the local variables
> of impact would be, they are (I added struct mkfs_xfs_opts to stuff them all on one
> data structure):
> 
> struct mkfs_xfs_opts {                                                          
>         int                     blocklog;                                       
>         int                     blflag;                                         
>         int                     bsflag;                                         

[....]

My intent when starting the table based config mods was that all
these intermediate values and flags would go away. i.e. they'd be
replace with a config table lookup for the option value because they
are redundant values and using the config table would remove the
confusion on what values should be used in the code.

And once everything is in the config option table, main() can be
more easily factored in sane, maintainable chunks....

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

      parent reply	other threads:[~2017-04-05 12:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-04  8:54 [xfsprogs] Do we need so many data types for user input? Jan Tulak
2017-04-04 19:48 ` Luis R. Rodriguez
2017-04-04 20:17   ` Eric Sandeen
2017-04-05  8:26     ` Jan Tulak
2017-04-05 14:08       ` Eric Sandeen
2017-04-05 14:24         ` Jan Tulak
2017-04-06 12:40           ` Luis R. Rodriguez
2017-04-06 13:03             ` Jan Tulak
2017-04-05 12:15   ` Dave Chinner [this message]

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=20170405121519.GR17542@dastard \
    --to=david@fromorbit.com \
    --cc=jtulak@redhat.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=mcgrof@kernel.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.