lkml.org 
[lkml]   [2023]   [Jul]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH][next] fs: omfs: Use flexible-array member in struct omfs_extent
On Mon, Jul 17, 2023 at 08:20:22AM -0700, Kees Cook wrote:
> > @@ -14,7 +14,7 @@ static u32 omfs_max_extents(struct omfs_sb_info *sbi, int offset)
> > {
> > return (sbi->s_sys_blocksize - offset -
> > sizeof(struct omfs_extent)) /
> > - sizeof(struct omfs_extent_entry) + 1;
> > + sizeof(struct omfs_extent_entry);
> > }
>
> I think the original calculation meant to do:
>
> return (sbi->s_sys_blocksize - offset -
> (sizeof(struct omfs_extent) - sizeof(struct omfs_extent_entry))) /
> sizeof(struct omfs_extent_entry);

I can confirm the intent. I also went back and looked at the usages just
to be sure.

In this case, there are two possible values for x = s_sys_blocksize - offset:
7728 or 8128, and both can be divided by 16 evenly so you have either:

f_old = (x - 32) / 16 + 1 or:
f_new = (x - 16) / 16

they both simplify to x/16 - 1 so they are equivalent for these inputs.

--
Bob Copeland %% https://bobcopeland.com/

\
 
 \ /
  Last update: 2023-07-19 15:03    [W:0.070 / U:0.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site