All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Whitehouse <swhiteho@redhat.com>
To: Jan Engelhardt <jengelh@linux01.gwdg.de>
Cc: linux-kernel@vger.kernel.org,
	Russell Cattelan <cattelan@redhat.com>,
	David Teigland <teigland@redhat.com>, Ingo Molnar <mingo@elte.hu>,
	hch@infradead.org
Subject: Re: [PATCH 07/16] GFS2: Directory handling
Date: Tue, 05 Sep 2006 09:44:14 +0100	[thread overview]
Message-ID: <1157445854.3384.965.camel@quoit.chygwyn.com> (raw)
In-Reply-To: <Pine.LNX.4.61.0609041314470.21005@yvahk01.tjqt.qr>

Hi,

On Mon, 2006-09-04 at 13:35 +0200, Jan Engelhardt wrote:
> >+
> >+	return copied;
> >+fail:
> >+	return (copied) ? copied : error;
> >+}
> >+
> >+typedef int (*gfs2_dscan_t)(const struct gfs2_dirent *dent,
> >+			    const struct qstr *name,
> >+			    void *opaque);
> 
> Collect all the typedefs above all functions (applies to all .c files).
> 
ok

> >+static inline int __gfs2_dirent_find(const struct gfs2_dirent *dent,
> >+				     const struct qstr *name, int ret)
> >+{
> >+	if (dent->de_inum.no_addr != 0 &&
> >+	    be32_to_cpu(dent->de_hash) == name->hash &&
> >+	    be16_to_cpu(dent->de_name_len) == name->len &&
> >+	    memcmp((char *)(dent+1), name->name, name->len) == 0)
> 
> Nocast.
> 
ok

> >+static struct gfs2_dirent *gfs2_dirent_scan(struct inode *inode,
[lines snipped]
> >+	offset = ret;
> >+	prev = NULL;
> >+	dent = (struct gfs2_dirent *)(buf + offset);
> 
> Nocast.
> 
ok
> >+		dent = (struct gfs2_dirent *)(buf + offset);
> 
> 
> >+	if ((char *)cur + cur_rec_len >= bh_end) {
> >+		if ((char *)cur + cur_rec_len > bh_end) {
> >+			gfs2_consist_inode(dip);
> >+			return -EIO;
> >+		}
> >+		return -ENOENT;
> >+	}
> 
> if((char *)cur + cur_rec_len > bh_end) {
> 	gfs2_consist_inode(dip);
> 	return -EIO;
> } else if((char *)cur + cur_rec_len == bh_end)
> 	return -ENOENT;
> 
ok

> >+	tmp = (struct gfs2_dirent *)((char *)cur + cur_rec_len);
> >+
> >+	if ((char *)tmp + be16_to_cpu(tmp->de_rec_len) > bh_end) {
> 
> Aah, this makes my eyes hurt. Though, it is probably a task not too short to
> think of something that would do without casts.
> 
Well I've had a crack at this. I've got it down to one cast. Let me know
if you think thats ok now... I managed to factor out some common code at
the same time.

> >+	leaf->lf_depth = cpu_to_be16(depth);
> >+	leaf->lf_entries = cpu_to_be16(0);
> 
> 0 is said to be portable across all CPUs, therefore
> 
> 	leaf->lf_entries = 0;
> 
> should suffice.
> 
> >+	leaf->lf_next = cpu_to_be64(0);
> 
ok, both now fixed.

> 
> >+		for (x = sdp->sd_hash_ptrs; x--; from++) {
> >+			*to++ = *from;	/*  No endianess worries  */
> >+			*to++ = *from;
> >+		}
> 
> Add /* Hakuna Matata */ and there will never be worries :-)
> 
:-) I had to use google to understand the reference :-)

> >+static int compare_dents(const void *a, const void *b)
> >+{
> >+	struct gfs2_dirent *dent_a, *dent_b;
> >+	uint32_t hash_a, hash_b;
> >+	int ret = 0;
> >+
> >+	dent_a = *(struct gfs2_dirent **)a;
> 
> But in this function you can have it const! Or not?
> 
Yes, and now all converted to const
[lines snipped]
> 		ret = memcmp((char *)(dent_a + 1),
> >+				     (char *)(dent_b + 1),
> >+				     len_a);
> 
> Nocast.
> 
ok

> >+		error = filldir(opaque, (char *)(dent + 1),
> 
> If you case, then cast it directly, in this case, filldir takes "const char *"
> as 2nd type.
> 
ok

> >+	larr = vmalloc((leaves + entries) * sizeof(void*));
>                                                        ^
> Space, to go in line with all the other casts.
> 
fixed

> >+static inline uint32_t gfs2_disk_hash(const char *data, int len)
> >+{
> >+        return crc32_le(0xFFFFFFFF, data, len) ^ 0xFFFFFFFF;
> >+}
> 
> Mind using (uint32_t)-1 or (uint32_t)~0 for that?
> 
~0 is the variant I've chosen.

> >+	memcpy((char*)(dent+1), name->name, name->len);
> 
> Last but not least, nocast.
> 
ok.

The patch is:
http://www.kernel.org/git/?p=linux/kernel/git/steve/gfs2-2.6.git;a=commitdiff;h=2bdbc5d73961c040fdc9b30d985fab3047d697a0

Thanks for doing all this review work, btw. I'll be working on your more
recent emails today,

Steve.



  reply	other threads:[~2006-09-05  8:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-31 13:34 [PATCH 07/16] GFS2: Directory handling Steven Whitehouse
2006-09-04 11:35 ` Jan Engelhardt
2006-09-05  8:44   ` Steven Whitehouse [this message]
2006-09-05  8:43     ` Ingo Molnar
2006-09-05  8:58       ` Andreas Schwab
2006-09-05 10:58         ` Ingo Molnar
2006-09-05  9:22       ` Jan Engelhardt
2006-09-05 11:19         ` Ingo Molnar
2006-09-05 11:22         ` Ingo Molnar
2006-09-05 14:02       ` Steven Whitehouse
  -- strict thread matches above, loose matches on Subject: below --
2006-04-21 16:16 Steven Whitehouse
2006-04-21 16:16 ` Christoph Hellwig
2006-04-24  9:16   ` Steven Whitehouse

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=1157445854.3384.965.camel@quoit.chygwyn.com \
    --to=swhiteho@redhat.com \
    --cc=cattelan@redhat.com \
    --cc=hch@infradead.org \
    --cc=jengelh@linux01.gwdg.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=teigland@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.