linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: slava@dubeyko.com,
	Linux FS devel list <linux-fsdevel@vger.kernel.org>,
	Christoph Hellwig <hch@infradead.org>,
	Hin-Tak Leung <htl10@users.sourceforge.net>
Subject: Re: [PATCH 2/3] hfsplus: implement attributes file's header node initialization code
Date: Thu, 26 Sep 2013 01:07:25 +0100	[thread overview]
Message-ID: <20130926000725.GC13318@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20130925155439.ace1e0c0573b181a35b28928@linux-foundation.org>

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"...

      reply	other threads:[~2013-09-26  0:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-20 10:04 [PATCH 2/3] hfsplus: implement attributes file's header node initialization code Vyacheslav Dubeyko
2013-09-25 22:54 ` Andrew Morton
2013-09-26  0:07   ` Al Viro [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130926000725.GC13318@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=akpm@linux-foundation.org \
    --cc=hch@infradead.org \
    --cc=htl10@users.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=slava@dubeyko.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).