All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Gao Xiang <gaoxiang25@huawei.com>, Chao Yu <yuchao0@huawei.com>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Christoph Hellwig <hch@infradead.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	devel@driverdev.osuosl.org
Cc: LKML <linux-kernel@vger.kernel.org>,
	linux-erofs@lists.ozlabs.org, Chao Yu <chao@kernel.org>,
	Miao Xie <miaoxie@huawei.com>,
	weidu.du@huawei.com, Fang Wei <fangwei1@huawei.com>
Subject: Re: [PATCH v2 2/7] erofs: some marcos are much more readable as a function
Date: Thu, 29 Aug 2019 20:16:27 -0700	[thread overview]
Message-ID: <5b2ecf5cec1a6aa3834e9af41886a7fcb18ae86a.camel@perches.com> (raw)
In-Reply-To: <20190830030040.10599-2-gaoxiang25@huawei.com>

On Fri, 2019-08-30 at 11:00 +0800, Gao Xiang wrote:
> As Christoph suggested [1], these marcos are much
> more readable as a function

s/marcos/macros/
.
[]
> diff --git a/fs/erofs/erofs_fs.h b/fs/erofs/erofs_fs.h
[]
> @@ -168,16 +168,24 @@ struct erofs_xattr_entry {
>  	char   e_name[0];       /* attribute name */
>  } __packed;
>  
> -#define ondisk_xattr_ibody_size(count)	({\
> -	u32 __count = le16_to_cpu(count); \
> -	((__count) == 0) ? 0 : \
> -	sizeof(struct erofs_xattr_ibody_header) + \
> -		sizeof(__u32) * ((__count) - 1); })
> +static inline unsigned int erofs_xattr_ibody_size(__le16 d_icount)
> +{
> +	unsigned int icount = le16_to_cpu(d_icount);
> +
> +	if (!icount)
> +		return 0;
> +
> +	return sizeof(struct erofs_xattr_ibody_header) +
> +		sizeof(__u32) * (icount - 1);

Maybe use struct_size()?

{
	struct erofs_xattr_ibody_header *ibh;
	unsigned int icount = le16_to_cpu(d_icount);

	if (!icount)
		return 0;

	return struct_size(ibh, h_shared_xattrs, icount - 1);
}


WARNING: multiple messages have this Message-ID (diff)
From: Joe Perches <joe@perches.com>
To: Gao Xiang <gaoxiang25@huawei.com>, Chao Yu <yuchao0@huawei.com>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Christoph Hellwig <hch@infradead.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	devel@driverdev.osuosl.org
Cc: linux-erofs@lists.ozlabs.org, LKML <linux-kernel@vger.kernel.org>,
	weidu.du@huawei.com, Miao Xie <miaoxie@huawei.com>
Subject: Re: [PATCH v2 2/7] erofs: some marcos are much more readable as a function
Date: Thu, 29 Aug 2019 20:16:27 -0700	[thread overview]
Message-ID: <5b2ecf5cec1a6aa3834e9af41886a7fcb18ae86a.camel@perches.com> (raw)
In-Reply-To: <20190830030040.10599-2-gaoxiang25@huawei.com>

On Fri, 2019-08-30 at 11:00 +0800, Gao Xiang wrote:
> As Christoph suggested [1], these marcos are much
> more readable as a function

s/marcos/macros/
.
[]
> diff --git a/fs/erofs/erofs_fs.h b/fs/erofs/erofs_fs.h
[]
> @@ -168,16 +168,24 @@ struct erofs_xattr_entry {
>  	char   e_name[0];       /* attribute name */
>  } __packed;
>  
> -#define ondisk_xattr_ibody_size(count)	({\
> -	u32 __count = le16_to_cpu(count); \
> -	((__count) == 0) ? 0 : \
> -	sizeof(struct erofs_xattr_ibody_header) + \
> -		sizeof(__u32) * ((__count) - 1); })
> +static inline unsigned int erofs_xattr_ibody_size(__le16 d_icount)
> +{
> +	unsigned int icount = le16_to_cpu(d_icount);
> +
> +	if (!icount)
> +		return 0;
> +
> +	return sizeof(struct erofs_xattr_ibody_header) +
> +		sizeof(__u32) * (icount - 1);

Maybe use struct_size()?

{
	struct erofs_xattr_ibody_header *ibh;
	unsigned int icount = le16_to_cpu(d_icount);

	if (!icount)
		return 0;

	return struct_size(ibh, h_shared_xattrs, icount - 1);
}


  reply	other threads:[~2019-08-30  3:19 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-30  3:00 [PATCH v2 1/7] erofs: on-disk format should have explicitly assigned numbers Gao Xiang
2019-08-30  3:00 ` Gao Xiang
2019-08-30  3:00 ` [PATCH v2 2/7] erofs: some marcos are much more readable as a function Gao Xiang
2019-08-30  3:00   ` Gao Xiang
2019-08-30  3:16   ` Joe Perches [this message]
2019-08-30  3:16     ` Joe Perches
2019-08-30  3:20     ` Gao Xiang
2019-08-30  3:20       ` Gao Xiang
2019-08-30  3:36       ` [PATCH v3 1/7] erofs: on-disk format should have explicitly assigned numbers Gao Xiang
2019-08-30  3:36         ` Gao Xiang
2019-08-30  3:36         ` [PATCH v3 2/7] erofs: some macros are much more readable as a function Gao Xiang
2019-08-30  3:36           ` Gao Xiang
2019-08-30  3:38           ` [PATCH v4 " Gao Xiang
2019-08-30  3:38             ` Gao Xiang
2019-08-30  6:11           ` [PATCH v3 " Chao Yu
2019-08-30  6:11             ` Chao Yu
2019-08-30  3:36         ` [PATCH v3 3/7] erofs: use a better form for complicated on-disk fields Gao Xiang
2019-08-30  3:36           ` Gao Xiang
2019-08-30  3:36         ` [PATCH v3 4/7] erofs: kill __packed for on-disk structures Gao Xiang
2019-08-30  3:36           ` Gao Xiang
2019-08-30  6:16           ` Chao Yu
2019-08-30  6:16             ` Chao Yu
2019-08-30  3:36         ` [PATCH v3 5/7] erofs: kill erofs_{init,exit}_inode_cache Gao Xiang
2019-08-30  3:36           ` Gao Xiang
2019-08-30  6:17           ` Chao Yu
2019-08-30  6:17             ` Chao Yu
2019-08-30  3:36         ` [PATCH v3 6/7] erofs: remove all likely/unlikely annotations Gao Xiang
2019-08-30  3:36           ` Gao Xiang
2019-08-30  6:25           ` Chao Yu
2019-08-30  6:25             ` Chao Yu
2019-08-30  6:31             ` Gao Xiang
2019-08-30  6:31               ` Gao Xiang
2019-08-30  6:43               ` Chao Yu
2019-08-30  6:43                 ` Chao Yu
2019-08-30 11:55             ` Dan Carpenter
2019-08-30 11:55               ` Dan Carpenter
2019-08-30 11:30           ` Dan Carpenter
2019-08-30 11:30             ` Dan Carpenter
2019-08-30 12:06             ` Gao Xiang
2019-08-30 12:06               ` Gao Xiang via Linux-erofs
2019-08-30 15:46           ` Christoph Hellwig
2019-08-30 15:46             ` Christoph Hellwig
2019-08-30 15:46             ` Christoph Hellwig
2019-08-30 16:04             ` Gao Xiang
2019-08-30 16:04               ` Gao Xiang
2019-08-30 16:04               ` Gao Xiang
2019-08-31 10:57               ` Dan Carpenter
2019-08-31 10:57                 ` Dan Carpenter
2019-08-31 10:57                 ` Dan Carpenter
2019-08-30  3:36         ` [PATCH v3 7/7] erofs: redundant assignment in __erofs_get_meta_page() Gao Xiang
2019-08-30  3:36           ` Gao Xiang
2019-08-30  6:25           ` Chao Yu
2019-08-30  6:25             ` Chao Yu
2019-08-30 16:28           ` Christoph Hellwig
2019-08-30 16:28             ` Christoph Hellwig
2019-08-30 16:28             ` Christoph Hellwig
2019-08-30 16:48             ` Gao Xiang
2019-08-30 16:48               ` Gao Xiang
2019-08-30 16:48               ` Gao Xiang
2019-08-30 15:25         ` [PATCH v3 1/7] erofs: on-disk format should have explicitly assigned numbers Gao Xiang
2019-08-30 15:25           ` Gao Xiang
2019-08-30 15:25           ` Gao Xiang
2019-08-30 15:45     ` [PATCH v2 2/7] erofs: some marcos are much more readable as a function Christoph Hellwig
2019-08-30 15:45       ` Christoph Hellwig
2019-08-30 15:45       ` Christoph Hellwig
2019-08-30 15:52       ` Gao Xiang
2019-08-30 15:52         ` Gao Xiang
2019-08-30 15:52         ` Gao Xiang
2019-08-30 15:56         ` Gao Xiang
2019-08-30 15:56           ` Gao Xiang
2019-08-30 15:56           ` Gao Xiang
2019-08-30  3:00 ` [PATCH v2 3/7] erofs: use a better form for complicated on-disk fields Gao Xiang
2019-08-30  3:00   ` Gao Xiang
2019-08-30  3:29   ` Chao Yu
2019-08-30  3:29     ` Chao Yu
2019-08-30  3:00 ` [PATCH v2 4/7] erofs: kill __packed for on-disk structures Gao Xiang
2019-08-30  3:00   ` Gao Xiang
2019-08-30  3:00 ` [PATCH v2 5/7] erofs: kill erofs_{init,exit}_inode_cache Gao Xiang
2019-08-30  3:00   ` Gao Xiang
2019-08-30  3:00 ` [PATCH v2 6/7] erofs: remove all likely/unlikely annotations Gao Xiang
2019-08-30  3:00   ` Gao Xiang
2019-08-30  3:00 ` [PATCH v2 7/7] erofs: reduntant assignment in __erofs_get_meta_page() Gao Xiang
2019-08-30  3:00   ` Gao Xiang
2019-08-30  3:28 ` [PATCH v2 1/7] erofs: on-disk format should have explicitly assigned numbers Chao Yu
2019-08-30  3:28   ` Chao Yu

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=5b2ecf5cec1a6aa3834e9af41886a7fcb18ae86a.camel@perches.com \
    --to=joe@perches.com \
    --cc=chao@kernel.org \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=fangwei1@huawei.com \
    --cc=gaoxiang25@huawei.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@infradead.org \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miaoxie@huawei.com \
    --cc=weidu.du@huawei.com \
    --cc=yuchao0@huawei.com \
    /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.