From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Subject: Re: [PATCH 2/3] hfsplus: implement attributes file's header node initialization code Date: Thu, 26 Sep 2013 01:07:25 +0100 Message-ID: <20130926000725.GC13318@ZenIV.linux.org.uk> References: <1379671449.2280.28.camel@slavad-ubuntu> <20130925155439.ace1e0c0573b181a35b28928@linux-foundation.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: slava@dubeyko.com, Linux FS devel list , Christoph Hellwig , Hin-Tak Leung To: Andrew Morton Return-path: Received: from zeniv.linux.org.uk ([195.92.253.2]:38484 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754982Ab3IZAH3 (ORCPT ); Wed, 25 Sep 2013 20:07:29 -0400 Content-Disposition: inline In-Reply-To: <20130925155439.ace1e0c0573b181a35b28928@linux-foundation.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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"...