All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: Andreas Gruenbacher <andreas.gruenbacher@gmail.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	Artem Bityutskiy <dedekind1@gmail.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	linux-mtd@lists.infradead.org,
	Richard Weinberger <richard@nod.at>,
	Eric Van Hensbergen <ericvh@gmail.com>,
	Ron Minnich <rminnich@sandia.gov>,
	Latchesar Ionkov <lucho@ionkov.net>,
	v9fs-developer@lists.sourceforge.net
Subject: Re: [PATCH 3/5] 9p: Simplify the xattr handlers
Date: Mon, 21 Sep 2015 13:00:57 +0530	[thread overview]
Message-ID: <87pp1cdya6.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <1441367842-25079-4-git-send-email-agruenba@redhat.com>

Andreas Gruenbacher <andreas.gruenbacher@gmail.com> writes:

> The generic_{get,set,remove}xattr inode operations use the xattr name prefix to
> decide which of the defined xattr handlers to call, then call the appropriate
> handler's get or set operation.  The name suffix is passed to the get or set
> operations, the prefix is still "there" in the name before the suffix though.
> There is no need to recompose the name in a temporary buffer.
>
> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
> ---
>  fs/9p/xattr_security.c | 34 ++++------------------------------
>  fs/9p/xattr_trusted.c  | 34 ++++------------------------------
>  fs/9p/xattr_user.c     | 34 ++++------------------------------
>  3 files changed, 12 insertions(+), 90 deletions(-)
>
> diff --git a/fs/9p/xattr_security.c b/fs/9p/xattr_security.c
> index cb247a1..2c9b394 100644
> --- a/fs/9p/xattr_security.c
> +++ b/fs/9p/xattr_security.c
> @@ -22,10 +22,7 @@
>  static int v9fs_xattr_security_get(struct dentry *dentry, const char *name,
>  			void *buffer, size_t size, int type)
>  {
> -	int retval;
> -	char *full_name;
> -	size_t name_len;
> -	size_t prefix_len = XATTR_SECURITY_PREFIX_LEN;
> +	const char *full_name = name - XATTR_SECURITY_PREFIX_LEN;
>  
>  	if (name == NULL)
>  		return -EINVAL;
> @@ -33,26 +30,13 @@ static int v9fs_xattr_security_get(struct dentry *dentry, const char *name,
>  	if (strcmp(name, "") == 0)
>  		return -EINVAL;
>  
> -	name_len = strlen(name);
> -	full_name = kmalloc(prefix_len + name_len + 1 , GFP_KERNEL);
> -	if (!full_name)
> -		return -ENOMEM;
> -	memcpy(full_name, XATTR_SECURITY_PREFIX, prefix_len);
> -	memcpy(full_name+prefix_len, name, name_len);
> -	full_name[prefix_len + name_len] = '\0';
> -
> -	retval = v9fs_xattr_get(dentry, full_name, buffer, size);
> -	kfree(full_name);
> -	return retval;
> +	return v9fs_xattr_get(dentry, full_name, buffer, size);
>  }
>  

I look strange, to expect that name argument passed to ->get() will have
the full name details. In any case this need more documentation and a
helper as Christoph suggested

-aneesh

WARNING: multiple messages have this Message-ID (diff)
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: Andreas Gruenbacher <andreas.gruenbacher@gmail.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	Artem Bityutskiy <dedekind1@gmail.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	linux-mtd@lists.infradead.org,
	Richard Weinberger <richard@nod.at>,
	Eric Van Hensbergen <ericvh@gmail.com>,
	Ron Minnich <rminnich@sandia.gov>,
	Latchesar Ionkov <lucho@ionkov.net>,
	v9fs-developer@lists.sourceforge.net
Subject: Re: [PATCH 3/5] 9p: Simplify the xattr handlers
Date: Mon, 21 Sep 2015 13:00:57 +0530	[thread overview]
Message-ID: <87pp1cdya6.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <1441367842-25079-4-git-send-email-agruenba@redhat.com>

Andreas Gruenbacher <andreas.gruenbacher@gmail.com> writes:

> The generic_{get,set,remove}xattr inode operations use the xattr name prefix to
> decide which of the defined xattr handlers to call, then call the appropriate
> handler's get or set operation.  The name suffix is passed to the get or set
> operations, the prefix is still "there" in the name before the suffix though.
> There is no need to recompose the name in a temporary buffer.
>
> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
> ---
>  fs/9p/xattr_security.c | 34 ++++------------------------------
>  fs/9p/xattr_trusted.c  | 34 ++++------------------------------
>  fs/9p/xattr_user.c     | 34 ++++------------------------------
>  3 files changed, 12 insertions(+), 90 deletions(-)
>
> diff --git a/fs/9p/xattr_security.c b/fs/9p/xattr_security.c
> index cb247a1..2c9b394 100644
> --- a/fs/9p/xattr_security.c
> +++ b/fs/9p/xattr_security.c
> @@ -22,10 +22,7 @@
>  static int v9fs_xattr_security_get(struct dentry *dentry, const char *name,
>  			void *buffer, size_t size, int type)
>  {
> -	int retval;
> -	char *full_name;
> -	size_t name_len;
> -	size_t prefix_len = XATTR_SECURITY_PREFIX_LEN;
> +	const char *full_name = name - XATTR_SECURITY_PREFIX_LEN;
>  
>  	if (name == NULL)
>  		return -EINVAL;
> @@ -33,26 +30,13 @@ static int v9fs_xattr_security_get(struct dentry *dentry, const char *name,
>  	if (strcmp(name, "") == 0)
>  		return -EINVAL;
>  
> -	name_len = strlen(name);
> -	full_name = kmalloc(prefix_len + name_len + 1 , GFP_KERNEL);
> -	if (!full_name)
> -		return -ENOMEM;
> -	memcpy(full_name, XATTR_SECURITY_PREFIX, prefix_len);
> -	memcpy(full_name+prefix_len, name, name_len);
> -	full_name[prefix_len + name_len] = '\0';
> -
> -	retval = v9fs_xattr_get(dentry, full_name, buffer, size);
> -	kfree(full_name);
> -	return retval;
> +	return v9fs_xattr_get(dentry, full_name, buffer, size);
>  }
>  

I look strange, to expect that name argument passed to ->get() will have
the full name details. In any case this need more documentation and a
helper as Christoph suggested

-aneesh




______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  parent reply	other threads:[~2015-09-21  7:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-04 11:57 [PATCH 0/5] Pass xattr handler to xattr handler operations Andreas Gruenbacher
2015-09-04 11:57 ` [PATCH 1/5] ubifs: Remove unused "security.*" xattr handler Andreas Gruenbacher
2015-09-04 11:57 ` [PATCH 2/5] hfsplus: Remove unused xattr handler list operations Andreas Gruenbacher
2015-09-04 11:57 ` [PATCH 3/5] 9p: Simplify the xattr handlers Andreas Gruenbacher
2015-09-16 14:14   ` Christoph Hellwig
2015-09-21  7:30   ` Aneesh Kumar K.V [this message]
2015-09-21  7:30     ` Aneesh Kumar K.V
2015-09-04 11:57 ` [PATCH 4/5] xattr handlers: Pass handler to operations instead of flags Andreas Gruenbacher
2015-09-16 14:16   ` Christoph Hellwig
2015-09-04 11:57 ` [PATCH 5/5] xattr handlers: Some simplifications Andreas Gruenbacher
2015-09-16 14:17   ` Christoph Hellwig

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=87pp1cdya6.fsf@linux.vnet.ibm.com \
    --to=aneesh.kumar@linux.vnet.ibm.com \
    --cc=adrian.hunter@intel.com \
    --cc=andreas.gruenbacher@gmail.com \
    --cc=dedekind1@gmail.com \
    --cc=ericvh@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=lucho@ionkov.net \
    --cc=richard@nod.at \
    --cc=rminnich@sandia.gov \
    --cc=v9fs-developer@lists.sourceforge.net \
    --cc=viro@zeniv.linux.org.uk \
    /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.