public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Cengiz Can <cengiz@kernel.wtf>
To: David Sterba <dsterba@suse.cz>
Cc: linux-btrfs@vger.kernel.org, Chris Mason <clm@fb.com>,
	Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>
Subject: Re: [PATCH] fs: btrfs: prevent unintentional int overflow
Date: Tue, 07 Jan 2020 22:44:43 +0300	[thread overview]
Message-ID: <41f24d3d838e66cd4d1746916905bcb6@kernel.wtf> (raw)
In-Reply-To: <20200107160124.GY3929@twin.jikos.cz>

Hello David!

On 2020-01-07 19:01, David Sterba wrote:
> It's not a runtime overhead but typecasts should not be needed in
> general and when there's one it should be there for a reason. Sometimes
> it's apparent and does not need a comment to explain why but otherwise 
> I
> see it as "overhead" when reading the code. Lots of calculations done 
> in
> btrfs fit perfectly to 32bit, eg. the b-tree node or page-related ones.
> Where it matters is eg. conversion from/to bio::bi_sector to/from btrfs
> logical addresses that are u64, where the interface type is unsigned
> long and not a fixed width.

Thanks for sharing that. As I said, I'm relatively new to btrfs 
internals.

> The size constraints of the variables used in the reported expression
> are known to developers so I tend to think the typecast is not
> necessary.

Agreed.

> Maybe the static checker tool could be improved to know the
> invariants, that are eg. verified in fs/btrfs/disk-io.c:validate_super.

That's something that I will do some research on.

We can ignore this patch.

Thank you!

-- 
Cengiz Can
@cengiz_io

      reply	other threads:[~2020-01-07 19:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-03 18:47 [PATCH] fs: btrfs: prevent unintentional int overflow Cengiz Can
2020-01-06 15:53 ` David Sterba
2020-01-07 15:23   ` Cengiz Can
2020-01-07 16:01     ` David Sterba
2020-01-07 19:44       ` Cengiz Can [this message]

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=41f24d3d838e66cd4d1746916905bcb6@kernel.wtf \
    --to=cengiz@kernel.wtf \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=dsterba@suse.cz \
    --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