Re: [PATCH 2/3] hfsplus: implement attributes file's header node initialization code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Sep 25, 2013 at 03:54:39PM -0700, Andrew Morton wrote:

> > +#define SETOFFSET(buf, ndsiz, offset, rec) \
> > +	(*(u16 *)((u8 *)(buf) + (ndsiz) + (-2 * (rec))) = (cpu_to_be16(offset)))
> 
> This is pretty ghastly.  Can you take a look at reimplementing it in a C
> function?  Add any necessary comments to explain what's happening and I
> expect you will find that it produces a much nicer result.

Take a look at the callers - buf and ndsiz remain unchanged, rec runs from
1 to 4.  IOW, what should be done is

	/* last 8 bytes contain offsets */
	__be16 *offsets = (__be16 *)(buf + node_size);
	...
	offset = sizeof(struct hfs_bnode_desc);
	*--offsets = cpu_to_be16(offset);
	...
	offset += sizeof(struct hfs_btree_header_rec);
	*--offsets = cpu_to_be16(offset);
	offset += HFSPLUS_BTREE_HDR_USER_BYTES;
	*--offsets = cpu_to_be16(offset);
	...
	offset += hdr_node_map_rec_bits / 8;
	*--offsets = cpu_to_be16(offset);
and to hell with that macro.

Speaking of another thing in the patch, there's that useful function called
"memset"...
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux