Re: [PATCH 3/7] udf: create common function for changing freespace counter

From: Christoph Hellwig
Date: Mon Jan 07 2008 - 07:41:20 EST


On Sun, Jan 06, 2008 at 02:21:49AM +0100, marcin.slusarz@xxxxxxxxx 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;
}


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/