From: David Sterba <dsterba@suse.cz>
To: Anand Jain <anand.jain@oracle.com>
Cc: linux-btrfs@vger.kernel.org, David Sterba <dsterba@suse.com>,
Josef Bacik <josef@toxicpanda.com>
Subject: Re: [PATCH v10 1/3] btrfs: add btrfs_strmatch helper
Date: Thu, 29 Oct 2020 19:35:52 +0100 [thread overview]
Message-ID: <20201029183552.GR6756@twin.jikos.cz> (raw)
In-Reply-To: <d3cfa1d20e7e0a86bbef9e078d887e90d1755b29.1603884513.git.anand.jain@oracle.com>
On Wed, Oct 28, 2020 at 09:14:45PM +0800, Anand Jain wrote:
> Add a generic helper to match the golden-string in the given-string,
> and ignore the leading and trailing whitespaces if any.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> Suggested-by: David Sterba <dsterba@suse.com>
> Reviewed-by: Josef Bacik <josef@toxicpanda.com>
> ---
> v10: return bool instead of int.
> drop unnecessary local variable and ( ) with in if.
> v9: use Josef suggested C coding style, using single if statement.
> v5: born
> fs/btrfs/sysfs.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
> index fcd6c7a9bbd1..5955379d3d9e 100644
> --- a/fs/btrfs/sysfs.c
> +++ b/fs/btrfs/sysfs.c
> @@ -888,6 +888,24 @@ static ssize_t btrfs_generation_show(struct kobject *kobj,
> }
> BTRFS_ATTR(, generation, btrfs_generation_show);
>
> +/*
> + * Match the %golden in the %given. Ignore the leading and trailing whitespaces
> + * if any.
> + */
> +static bool btrfs_strmatch(const char *given, const char *golden)
> +{
> + size_t len = strlen(golden);
> +
> + /* skip leading whitespace */
Comments should start with uppercase unless it's an identifier.
> + given = skip_spaces(given);
> +
> + if (strncmp(given, golden, len) == 0 &&
> + !strlen(skip_spaces(given + len)))
You had strlen() == 0 instead of !strlen in v9, the == 0 is better here.
I'll fix that locally and push to misc-next so we can proceed with the
actual policies.
next prev parent reply other threads:[~2020-10-29 18:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-28 13:14 [PATCH v10 resend 0/3] readmirror feature (read_policy sysfs and in-memory only approach) Anand Jain
2020-10-28 13:14 ` [PATCH v10 1/3] btrfs: add btrfs_strmatch helper Anand Jain
2020-10-29 18:35 ` David Sterba [this message]
2020-10-28 13:14 ` [PATCH v10 2/3] btrfs: create read policy framework Anand Jain
2020-10-29 18:53 ` David Sterba
2020-10-28 13:14 ` [PATCH v10 3/3] btrfs: create read policy sysfs attribute, pid Anand Jain
2020-10-29 16:45 ` David Sterba
2020-10-29 19:30 ` Anand Jain
2020-10-29 19:30 ` David Sterba
-- strict thread matches above, loose matches on Subject: below --
2020-10-28 4:25 [PATCH v10 0/3] readmirror feature (read_policy sysfs and in-memory only approach) Anand Jain
2020-10-28 4:25 ` [PATCH v10 1/3] btrfs: add btrfs_strmatch helper Anand Jain
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=20201029183552.GR6756@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=anand.jain@oracle.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox