All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Huaisheng Ye <yehs2007@zoho.com>
Cc: linux-nvdimm@lists.01.org, chengnt@lenovo.com,
	linux-kernel@vger.kernel.org, willy@infradead.org,
	"\"Al Viro\"" <viro@ZenIV.linux.org.uk>,
	jack@suse.com, linux-ext4@vger.kernel.org
Subject: Re: [PATCH 2/3] fs/ext2/inode: Fix a type cast error for fsdax
Date: Mon, 2 Jul 2018 09:55:43 +0200	[thread overview]
Message-ID: <20180702075543.k7y73aj3s3gp4ptz@quack2.suse.cz> (raw)
In-Reply-To: <16459a9432e.10c419704327.5268154349116077352@zoho.com>

On Mon 02-07-18 14:23:42, Huaisheng Ye wrote:
>  ---- On Mon, 02 Jul 2018 03:26:00 +0800 Al Viro <viro@ZenIV.linux.org.uk> wrote ---- 
>  > On Sun, Jul 01, 2018 at 02:18:47PM +0800, Huaisheng Ye wrote: 
>  > > From: Huaisheng Ye <yehs1@lenovo.com> 
>  > >  
>  > > The type of offset within struct iomap is loff_t, which represents 
>  > > file offset of mapping. 
>  > >  
>  > > In ext2_iomap_begin, iomap->offset shall be given a type cast as 
>  > > loff_t instead of u64. 
>  >  
>  > Why is it an error?  loff_t is uniformly typedefed to long long. 
>  > In which case the second variant is different from the first one 
>  > *and* does not step into nasal demon territory?
> 
> Sorry for my inaccuracy.
> The type of iomap->offset is loff_t, is it better to cast first_block
> to loff_t, then do the left shift operation?

I think what Al meant is that in the kernel loff_t is 64-bit anyway and
furthermore it is signed which means most people have to look up C standard
to remember how right shift is (un)defined if it would overflow ;). So this
does not really make the code any more readable. Rather on contrary...

								Honza

>  
>  >  
>  > > -    iomap->offset = (u64)first_block << blkbits; 
>  > > +    iomap->offset = (loff_t)first_block << blkbits; 
>  > 
> 
> ---
> Cheers,
> Huaisheng
> 
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

WARNING: multiple messages have this Message-ID (diff)
From: Jan Kara <jack@suse.cz>
To: Huaisheng Ye <yehs2007@zoho.com>
Cc: "\"Al Viro\"" <viro@ZenIV.linux.org.uk>,
	dan.j.williams@intel.com, dave.jiang@intel.com,
	willy@infradead.org, ross.zwisler@linux.intel.com,
	vishal.l.verma@intel.com, jack@suse.com, chengnt@lenovo.com,
	linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org,
	linux-ext4@vger.kernel.org, "\"Huaisheng Ye\"" <yehs1@lenovo.com>
Subject: Re: [PATCH 2/3] fs/ext2/inode: Fix a type cast error for fsdax
Date: Mon, 2 Jul 2018 09:55:43 +0200	[thread overview]
Message-ID: <20180702075543.k7y73aj3s3gp4ptz@quack2.suse.cz> (raw)
In-Reply-To: <16459a9432e.10c419704327.5268154349116077352@zoho.com>

On Mon 02-07-18 14:23:42, Huaisheng Ye wrote:
>  ---- On Mon, 02 Jul 2018 03:26:00 +0800 Al Viro <viro@ZenIV.linux.org.uk> wrote ---- 
>  > On Sun, Jul 01, 2018 at 02:18:47PM +0800, Huaisheng Ye wrote: 
>  > > From: Huaisheng Ye <yehs1@lenovo.com> 
>  > >  
>  > > The type of offset within struct iomap is loff_t, which represents 
>  > > file offset of mapping. 
>  > >  
>  > > In ext2_iomap_begin, iomap->offset shall be given a type cast as 
>  > > loff_t instead of u64. 
>  >  
>  > Why is it an error?  loff_t is uniformly typedefed to long long. 
>  > In which case the second variant is different from the first one 
>  > *and* does not step into nasal demon territory?
> 
> Sorry for my inaccuracy.
> The type of iomap->offset is loff_t, is it better to cast first_block
> to loff_t, then do the left shift operation?

I think what Al meant is that in the kernel loff_t is 64-bit anyway and
furthermore it is signed which means most people have to look up C standard
to remember how right shift is (un)defined if it would overflow ;). So this
does not really make the code any more readable. Rather on contrary...

								Honza

>  
>  >  
>  > > -    iomap->offset = (u64)first_block << blkbits; 
>  > > +    iomap->offset = (loff_t)first_block << blkbits; 
>  > 
> 
> ---
> Cheers,
> Huaisheng
> 
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

WARNING: multiple messages have this Message-ID (diff)
From: Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org>
To: Huaisheng Ye <yehs2007-ytc+IHgoah0@public.gmane.org>
Cc: linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org,
	chengnt-6jq1YtArVR3QT0dZR+AlfA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	willy-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org,
	"\"Al Viro\""
	<viro-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>,
	jack-IBi9RG/b67k@public.gmane.org,
	linux-ext4-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 2/3] fs/ext2/inode: Fix a type cast error for fsdax
Date: Mon, 2 Jul 2018 09:55:43 +0200	[thread overview]
Message-ID: <20180702075543.k7y73aj3s3gp4ptz@quack2.suse.cz> (raw)
In-Reply-To: <16459a9432e.10c419704327.5268154349116077352-ytc+IHgoah0@public.gmane.org>

On Mon 02-07-18 14:23:42, Huaisheng Ye wrote:
>  ---- On Mon, 02 Jul 2018 03:26:00 +0800 Al Viro <viro-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org> wrote ---- 
>  > On Sun, Jul 01, 2018 at 02:18:47PM +0800, Huaisheng Ye wrote: 
>  > > From: Huaisheng Ye <yehs1-6jq1YtArVR3QT0dZR+AlfA@public.gmane.org> 
>  > >  
>  > > The type of offset within struct iomap is loff_t, which represents 
>  > > file offset of mapping. 
>  > >  
>  > > In ext2_iomap_begin, iomap->offset shall be given a type cast as 
>  > > loff_t instead of u64. 
>  >  
>  > Why is it an error?  loff_t is uniformly typedefed to long long. 
>  > In which case the second variant is different from the first one 
>  > *and* does not step into nasal demon territory?
> 
> Sorry for my inaccuracy.
> The type of iomap->offset is loff_t, is it better to cast first_block
> to loff_t, then do the left shift operation?

I think what Al meant is that in the kernel loff_t is 64-bit anyway and
furthermore it is signed which means most people have to look up C standard
to remember how right shift is (un)defined if it would overflow ;). So this
does not really make the code any more readable. Rather on contrary...

								Honza

>  
>  >  
>  > > -    iomap->offset = (u64)first_block << blkbits; 
>  > > +    iomap->offset = (loff_t)first_block << blkbits; 
>  > 
> 
> ---
> Cheers,
> Huaisheng
> 
> 
-- 
Jan Kara <jack-IBi9RG/b67k@public.gmane.org>
SUSE Labs, CR

  reply	other threads:[~2018-07-02  7:55 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-01  6:18 [PATCH 1/3] drivers/dax/super: Add annotation for ops in struct dax_device Huaisheng Ye
2018-07-01  6:18 ` Huaisheng Ye
2018-07-01  6:18 ` Huaisheng Ye
2018-07-01  6:18 ` [PATCH 2/3] fs/ext2/inode: Fix a type cast error for fsdax Huaisheng Ye
2018-07-01  6:18   ` Huaisheng Ye
2018-07-01  6:18   ` Huaisheng Ye
2018-07-01 19:26   ` Al Viro
2018-07-01 19:26     ` Al Viro
2018-07-01 19:26     ` Al Viro
2018-07-02  6:23     ` Huaisheng Ye
2018-07-02  6:23       ` Huaisheng Ye
2018-07-02  6:23       ` Huaisheng Ye
2018-07-02  7:55       ` Jan Kara [this message]
2018-07-02  7:55         ` Jan Kara
2018-07-02  7:55         ` Jan Kara
2018-07-01  6:18 ` [PATCH 3/3] fs/ext2/inode: Optimize the condition for iomap_begin Huaisheng Ye
2018-07-01  6:18   ` Huaisheng Ye
2018-07-01  6:18   ` Huaisheng Ye
2018-07-02  7:57   ` Jan Kara
2018-07-02  7:57     ` Jan Kara
2018-07-02  7:57     ` Jan Kara

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=20180702075543.k7y73aj3s3gp4ptz@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=chengnt@lenovo.com \
    --cc=jack@suse.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvdimm@lists.01.org \
    --cc=viro@ZenIV.linux.org.uk \
    --cc=willy@infradead.org \
    --cc=yehs2007@zoho.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.