lkml.org 
[lkml]   [2008]   [Jan]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/7] udf: create common function for changing free space counter
On Sun, Jan 06, 2008 at 02:21:49AM +0100, marcin.slusarz@gmail.com wrote:
> +static inline bool udf_inc_free_space(struct udf_sb_info *sbi,
> + u16 partition, u32 cnt)
> +{
> + if (sbi->s_lvid_bh) {
> + struct logicalVolIntegrityDesc *lvid =
> + (struct logicalVolIntegrityDesc *)
> + sbi->s_lvid_bh->b_data;
> + lvid->freeSpaceTable[partition] =
> + cpu_to_le32(le32_to_cpu(
> + lvid->freeSpaceTable[partition]) + cnt);
> + }
> + return sbi->s_lvid_bh != NULL;
> +}

No need to mark helpers like this inline, the compiler will take care
of it if nessecary. Also I'd add an early return for the sbi->s_lvid_bh
case and a local variable for the freespace to make the function better
readable:

static bool udf_inc_free_space(struct udf_sb_info *sbi, u16 partition,
u32 cnt)
{
struct logicalVolIntegrityDesc *lvid;

if (!sbi->s_lvid_bh)
return 0;

lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data;
free = le32_to_cpu(lvid->freeSpaceTable[partition]) + cnt;
lvid->freeSpaceTable[partition] = cpu_to_le32(free);
return 1;
}




\
 
 \ /
  Last update: 2008-01-07 13:43    [W:0.058 / U:0.624 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site