All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Tulak <jtulak@redhat.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 06/22] mkfs: add cross-section conflict checks
Date: Wed, 29 Mar 2017 16:57:59 +0200	[thread overview]
Message-ID: <CACj3i736jkFi-2G7jFVW4Q8iCOuPuuP-=s0rWCSL5egOWvS3qA@mail.gmail.com> (raw)
In-Reply-To: <7e15965f-1f31-9d3d-701f-cca982a871a8@sandeen.net>

On Sat, Mar 25, 2017 at 1:31 AM, Eric Sandeen <sandeen@sandeen.net> wrote:
> On 3/15/17 11:00 AM, Jan Tulak wrote:
>> Checks are modified to work with cross-section conflicts (data, metada, log, ...).
>
> More information in the changelog please; this doesn't
> tell us a whole lot about what this is actually doing.

Like this?

Checks are modified to work with cross-section conflicts (data,
metada, log, ...).
So, it is now possible to detect a conflict between -m foo and -d bar
options.

This patch only extends checks to test for conflicts across all
options instead of only the current one, the opts struct already can
declare it.

>
>> Signed-off-by: Jan Tulak <jtulak@redhat.com>
>> ---
>>  mkfs/xfs_mkfs.c | 43 ++++++++++++++++++++++++++++++++++---------
>>  1 file changed, 34 insertions(+), 9 deletions(-)
>>
>> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
>> index 7e0a4159..0877c196 100644
>> --- a/mkfs/xfs_mkfs.c
>> +++ b/mkfs/xfs_mkfs.c
>> @@ -744,6 +744,9 @@ struct opt_params {
>>       },
>>  };
>>
>> +static void conflict_struct(struct opt_params        *opt, struct subopt_param *subopt,
>
> weird tabs there
>
>> +                     struct subopt_conflict  *conflict);
>
> "conflict_struct" seems like a variable name, not a function name.  :)
>
> What does this function actually do?

See bellow at the definition of this function (your other comment).

>
>> +
>>  #define TERABYTES(count, blog)       ((__uint64_t)(count) << (40 - (blog)))
>>  #define GIGABYTES(count, blog)       ((__uint64_t)(count) << (30 - (blog)))
>>  #define MEGABYTES(count, blog)       ((__uint64_t)(count) << (20 - (blog)))
>> @@ -1351,10 +1354,9 @@ check_opt(
>>                       break;
>>               if (conflict_opt.test_values)
>>                       break;
>> -             if (opt->subopt_params[conflict_opt.subopt].seen ||
>> -                 opt->subopt_params[conflict_opt.subopt].str_seen) {
>> -                     conflict(opt->name, (char **)opt->subopts,
>> -                              conflict_opt.subopt, index);
>> +             if (opts[conflict_opt.opt].subopt_params[conflict_opt.subopt].seen ||
>> +                 opts[conflict_opt.opt].subopt_params[conflict_opt.subopt].str_seen) {
>> +                     conflict_struct(opt, sp, &conflict_opt);
>>               }
>>       }
>>  }
>> @@ -1379,13 +1381,12 @@ check_opt_value(
>>                       break;
>>               if (!conflict_opt.test_values)
>>                       break;
>> -             if ((opt->subopt_params[conflict_opt.subopt].seen ||
>> -                                 opt->subopt_params[conflict_opt.subopt].str_seen) &&
>> -                 opt->subopt_params[conflict_opt.subopt].value
>> +             if ((opts[conflict_opt.opt].subopt_params[conflict_opt.subopt].seen ||
>> +                  opts[conflict_opt.opt].subopt_params[conflict_opt.subopt].str_seen) &&
>> +                 opts[conflict_opt.opt].subopt_params[conflict_opt.subopt].value
>>                               == conflict_opt.invalid_value &&
>>                   value == conflict_opt.at_value) {
>> -                     conflict(opt->name, (char **)opt->subopts,
>> -                              conflict_opt.subopt, index);
>> +                     conflict_struct(opt, sp, &conflict_opt);
>>               }
>>       }
>>  }
>> @@ -3586,12 +3587,36 @@ conflict(
>>       char            *tab[],
>>       int             oldidx,
>>       int             newidx)
>> +
>
> that newline should not be here ...
>
>>  {
>>       fprintf(stderr, _("Cannot specify both -%c %s and -%c %s\n"),
>>               opt, tab[oldidx], opt, tab[newidx]);
>>       usage();
>>  }
>
> A comment about what this function actually /does/ would be good.
>
> All it really does is printf, I guess - so a function name more
> like show_conflict() might make more sense?  conflict_struct just
> isn't a good descriptive name.

Agreed, renamed to print_conflict_struct. The _struct is to
differentiate it from the conflict() function that has a different set
of arguments and can't print out the optional message conflicts
definitions can have.

>
>> +static void
>> +conflict_struct(
>> +     struct opt_params       *opt,
>> +     struct subopt_param     *subopt,
>> +     struct subopt_conflict  *conflict)
>> +{
>> +     if(conflict->message) {
>> +             fprintf(stderr, _("Cannot specify both -%c %s and -%c %s: %s\n"),
>> +                     opt->name,
>> +                     opt->subopts[subopt->index],
>> +                     opts[conflict->opt].name,
>> +                     opts[conflict->opt].subopts[conflict->subopt],
>> +                     _(conflict->message));
>> +     } else {
>> +             fprintf(stderr, _("Cannot specify both -%c %s and -%c %s\n"),
>> +                     opt->name,
>> +                     opt->subopts[subopt->index],
>> +                     opts[conflict->opt].name,
>> +                     opts[conflict->opt].subopts[conflict->subopt]);
>> +     }
>
> I wonder if this can be done w/o the cut and paste?

Yes. After few minutes of thinking how to nicely concatenate strings
while avoiding allocs, I realised I can just print out the basic
error, conditionally print the conflict->message and then always print
"\n". I guess I overcomplicate things sometimes... :-/ Anyway, changed
for the next version of this patch.

>
>> +     usage();
>> +}
>> +
>>
>>  static void
>>  illegal(
>>



-- 
Jan Tulak
jtulak@redhat.com / jan@tulak.me

  reply	other threads:[~2017-03-29 14:58 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-15 15:59 [PATCH 00/22] mkfs.xfs: Make stronger conflict checks Jan Tulak
2017-03-15 15:59 ` [PATCH 01/22] mkfs: remove intermediate getstr followed by getnum Jan Tulak
2017-03-16 22:59   ` Eric Sandeen
2017-04-05 13:00     ` Jan Tulak
2017-04-05 14:05       ` Eric Sandeen
2017-03-15 15:59 ` [PATCH 02/22] mkfs: merge tables for opts parsing into one table Jan Tulak
2017-03-15 15:59 ` [PATCH 03/22] mkfs: extend opt_params with a value field Jan Tulak
2017-03-15 15:59 ` [PATCH 04/22] mkfs: change conflicts array into a table capable of cross-option addressing Jan Tulak
2017-03-16 17:02   ` Eric Sandeen
2017-03-16 17:21     ` Jan Tulak
2017-03-16 17:41       ` Eric Sandeen
2017-03-16 17:47         ` Jan Tulak
2017-03-15 16:00 ` [PATCH 05/22] mkfs: add a check for conflicting values Jan Tulak
2017-03-25  0:36   ` Eric Sandeen
2017-03-29 14:58     ` Jan Tulak
2017-03-15 16:00 ` [PATCH 06/22] mkfs: add cross-section conflict checks Jan Tulak
2017-03-25  0:31   ` Eric Sandeen
2017-03-29 14:57     ` Jan Tulak [this message]
2017-03-15 16:00 ` [PATCH 07/22] mkfs: Move opts related #define to one place Jan Tulak
2017-03-16 23:25   ` Luis R. Rodriguez
2017-03-17 12:11     ` Jan Tulak
2017-03-15 16:00 ` [PATCH 08/22] mkfs: move conflicts into the table Jan Tulak
2017-03-16 18:04   ` Eric Sandeen
2017-03-16 18:39   ` Eric Sandeen
2017-03-16 18:45     ` Darrick J. Wong
2017-03-24 23:53   ` Eric Sandeen
2017-03-29 14:57     ` Jan Tulak
2017-03-15 16:00 ` [PATCH 09/22] mkfs: change conflict checks to utilize the new conflict structure Jan Tulak
2017-03-15 16:00 ` [PATCH 10/22] mkfs: change when to mark an option as seen Jan Tulak
2017-03-15 16:00 ` [PATCH 11/22] mkfs: add test_default_value into conflict struct Jan Tulak
2017-03-25  0:09   ` Eric Sandeen
2017-03-29 14:57     ` Jan Tulak
2017-03-29 16:33       ` Jan Tulak
2017-03-31  1:40         ` Luis R. Rodriguez
2017-03-31  7:35           ` Jan Tulak
2017-03-15 16:00 ` [PATCH 12/22] mkfs: expand conflicts declarations to named declaration Jan Tulak
2017-03-15 16:00 ` [PATCH 13/22] mkfs: remove zeroed items from conflicts declaration Jan Tulak
2017-03-15 16:00 ` [PATCH 14/22] mkfs: rename defaultval to flagval in opts Jan Tulak
2017-03-16 23:20   ` Luis R. Rodriguez
2017-03-17 12:06     ` Jan Tulak
2017-03-15 16:00 ` [PATCH 15/22] mkfs: replace SUBOPT_NEEDS_VAL for a flag Jan Tulak
2017-03-15 16:00 ` [PATCH 16/22] mkfs: Change all value fields in opt structures into unions Jan Tulak
2017-03-15 16:00 ` [PATCH 17/22] mkfs: use old variables as pointers to the new opts struct values Jan Tulak
2017-03-17  0:48   ` Eric Sandeen
2017-03-15 16:00 ` [PATCH 18/22] mkfs: prevent sector/blocksize to be specified as a number of blocks Jan Tulak
2017-03-15 16:00 ` [PATCH 19/22] mkfs: subopt flags should be saved as bool Jan Tulak
2017-03-15 16:00 ` [PATCH 20/22] mkfs: move uuid empty string test to getstr() Jan Tulak
2017-03-15 16:00 ` [PATCH 21/22] mkfs: remove duplicit checks Jan Tulak
2017-03-15 16:00 ` [PATCH 22/22] mkfs: prevent multiple specifications of a single option Jan Tulak
2017-03-16 17:19 ` [PATCH 00/22] mkfs.xfs: Make stronger conflict checks Eric Sandeen
2017-03-16 17:23   ` Jan Tulak
2017-03-16 23:38 ` Luis R. Rodriguez
2017-03-16 23:47   ` Eric Sandeen
2017-03-17 12:57     ` Jan Tulak
2017-03-18  7:08       ` Dave Chinner
2017-03-17 12:20   ` Jan Tulak
  -- strict thread matches above, loose matches on Subject: below --
2016-12-07 13:27 [RFC PATCH " Jan Tulak
2016-12-07 13:27 ` [PATCH 06/22] mkfs: add cross-section " Jan Tulak
2017-01-13 21:18   ` Bill O'Donnell

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='CACj3i736jkFi-2G7jFVW4Q8iCOuPuuP-=s0rWCSL5egOWvS3qA@mail.gmail.com' \
    --to=jtulak@redhat.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@sandeen.net \
    /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.