Messages in this thread | | | Date | Mon, 7 Jan 2008 12:41:05 +0000 | From | Christoph Hellwig <> | Subject | Re: [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; }
| |