Re: [PATCH][FAT] FAT dirent scan with hin take #2

Pekka Enberg
2005-08-30T08:51:57Z

Hi,

Some coding style nitpicks.

On 8/30/05, Machida, Hiroyuki <machida@sm.sony.co.jp> wrote:
> +inline
> +static int hint_allocate(struct inode *dir)
> +{
> + void *hints;
> + int err = 0;
> +
> + if (!MSDOS_I(dir)->scan_hints) {
> + hints = kmalloc(FAT_SCAN_NWAY*sizeof(loff_t),GFP_KERNEL);
> + if (hints)
> + memset(hints, 0, FAT_SCAN_NWAY*sizeof(loff_t));
> + else
> + err = -ENOMEM;

Please consider using kcalloc().

> +
> + down(&MSDOS_I(dir)->scan_lock);
> + if (MSDOS_I(dir)->scan_hints) err = -EINVAL;

Please put the statement after if clause to a separate line. The above
makes code very hard to read.

> + if (!err) MSDOS_I(dir)->scan_hints = hints;
> + up(&MSDOS_I(dir)->scan_lock);
> + if (err == -EINVAL) {
> + if (hints) kfree(hints);

kfree() can handle NULLs just fine so please drop the redundant check.

Pekka