Re: Subject: [PATCH 01/16] Squashfs: inode operations

From: Geert Uytterhoeven
Date: Wed Oct 22 2008 - 13:13:35 EST


On Fri, 17 Oct 2008, Phillip Lougher wrote:
> --- /dev/null
> +++ b/fs/squashfs/inode.c

> + case SQUASHFS_BLKDEV_TYPE:
> + case SQUASHFS_CHRDEV_TYPE: {
> + struct squashfs_dev_inode *inodep = &id.dev;
> + unsigned int rdev;
> +
> + if (!squashfs_read_metadata(s, inodep, block, offset,
> + sizeof(*inodep), &next_block, &next_offset))
> + goto failed_read;
> +
> + i->i_nlink = le32_to_cpu(inodep->nlink);
> + i->i_mode |= (type == SQUASHFS_CHRDEV_TYPE) ? S_IFCHR : S_IFBLK;
> + rdev = le32_to_cpu(inodep->rdev);
> + init_special_inode(i, le16_to_cpu(i->i_mode),
^^^^^^^^^^^
> + new_decode_dev(rdev));
> +
> + TRACE("Device inode %x:%x, rdev %x\n",
> + SQUASHFS_INODE_BLK(inode), offset, rdev);
> + break;
> + }
> + case SQUASHFS_FIFO_TYPE:
> + case SQUASHFS_SOCKET_TYPE: {
> + struct squashfs_ipc_inode *inodep = &id.ipc;
> +
> + if (!squashfs_read_metadata(s, inodep, block, offset,
> + sizeof(*inodep), &next_block, &next_offset))
> + goto failed_read;
> +
> + i->i_nlink = le32_to_cpu(inodep->nlink);
> + i->i_mode |= (type == SQUASHFS_FIFO_TYPE) ? S_IFIFO : S_IFSOCK;
> + init_special_inode(i, le16_to_cpu(i->i_mode), 0);
^^^^^^^^^^^
> + break;

Sparse with endian checking (make C=2 CHECKFLAGS="-D__CHECK_ENDIAN__") complains
about these:

| fs/squashfs/inode.c:306:25: warning: cast to restricted __le16
| fs/squashfs/inode.c:324:25: warning: cast to restricted __le16

and it seems to be right, as inode.i_mode is not __le16. I think the le16_to_cpu()
should be removed.

BTW, there are also a few sparse warnings about different signednesses, so you
probably want to run sparse yourself, too.

With kind regards,

Geert Uytterhoeven
Software Architect

Sony Techsoft Centre Europe
The Corporate Village  Da Vincilaan 7-D1  B-1935 Zaventem  Belgium

Phone: +32 (0)2 700 8453
Fax: +32 (0)2 700 8622
E-mail: Geert.Uytterhoeven@xxxxxxxxxxx
Internet: http://www.sony-europe.com/

A division of Sony Europe (Belgium) N.V.
VAT BE 0413.825.160 Â RPR Brussels
Fortis  BIC GEBABEBB  IBAN BE41293037680010