The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Steven Whitehouse <swhiteho@redhat.com>
Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>,
	linux-kernel@vger.kernel.org,
	Russell Cattelan <cattelan@redhat.com>,
	David Teigland <teigland@redhat.com>,
	hch@infradead.org
Subject: Re: [PATCH 07/16] GFS2: Directory handling
Date: Tue, 5 Sep 2006 10:43:34 +0200	[thread overview]
Message-ID: <20060905084334.GA16788@elte.hu> (raw)
In-Reply-To: <1157445854.3384.965.camel@quoit.chygwyn.com>


* Steven Whitehouse <swhiteho@redhat.com> wrote:

> > >+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

actually, sizeof(*dent) != 1, so how can a non-casted memcmp be correct 
here?

> > >+	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

this one is not OK! Firstly, Jan, and i mentioned this before, please 
stop using 'if(', it is highly inconsistent and against basic taste. We 
only use this construct for function calls (and macros), not for C 
statements.

Secondly, whenever we have curly braces in the first block, we tend to 
do it in the second block too, for easier parsing. I.e.:

	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;
	}

Thirdly, the original code was quite fine as-is! What's the point of 
introducing random perturbations like this? It is an open invitation for 
the introduction of bugs... So unless there is a clear style reason to 
do a change, i'd suggest to not touch the code.

	Ingo

  reply	other threads:[~2006-09-05  8:50 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
2006-09-05  8:43     ` Ingo Molnar [this message]
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=20060905084334.GA16788@elte.hu \
    --to=mingo@elte.hu \
    --cc=cattelan@redhat.com \
    --cc=hch@infradead.org \
    --cc=jengelh@linux01.gwdg.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=swhiteho@redhat.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox