All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiong Zhou <xzhou@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3] syscalls/fcntl36: add tests for OFD locks
Date: Wed, 23 Aug 2017 12:15:58 +0800	[thread overview]
Message-ID: <20170823041558.33vhtfsdswenhcfa@XZHOUW.usersys.redhat.com> (raw)
In-Reply-To: <20170822142356.GB23381@rei.lan>

On Tue, Aug 22, 2017 at 04:23:57PM +0200, Cyril Hrubis wrote:
> Hi!
> >  runtest/syscalls                          |   2 +
> >  testcases/kernel/syscalls/fcntl/Makefile  |   3 +
> >  testcases/kernel/syscalls/fcntl/fcntl36.c | 386 ++++++++++++++++++++++++++++++
> 
> Don't forget about .gitignore entry as well.

Ha, now i found the right one, :)

> 
> ...
> 
> > +#include <sys/types.h>
> > +#include <sys/stat.h>
...
> > +		SAFE_READ(1, fd, buf, pa->length);
> > +
> > +		/* Verifying data read */
> > +		for (i = 0; i < pa->length; i++) {
> > +
> > +			if (buf[i] < 1 || buf[i] > 254) {
> > +
> > +				tst_res(TFAIL, "Unexpected data "
> > +					"offset %ld value %d",
> > +					pa->offset + i, buf[i]);
> > +				break;
> > +			}
> > +
> > +			long tmp = pa->length / 2;
> 
> We can simplify this with:
> 			int j = i / (pa->length/2);
> 
> 			if (buf[i] != buf[j]) {
> 				...
> 			}

After checking, this is not what I meant to check here about
this data verifying.

We could read 4k data that first half 2k of it have the same
value and the another half 2k have a different value.

> 
> > +			if ((i < tmp && buf[i] != buf[0]) ||
> > +			    (i >= tmp && buf[i] != buf[tmp])) {
> > +
> > +				tst_res(TFAIL, "Unexpected data "
> > +					"offset %ld value %d",
> > +					pa->offset + i, buf[i]);
> > +				break;
> > +			}
> > +		}
> > +
...
> > +	if (tst_fill_file(fname, 1, write_size, thread_cnt)) {
> > +		tst_brk(TBROK, "Failed to create tst file");
> > +	}
> 
> No need for the curly braces around single line statement here.

I thought it's safer for a macro. Now it's one line function in
the macro, not hurting to remove the braces.

Thanks for reviewing!
Xiong

  reply	other threads:[~2017-08-23  4:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-11  3:14 [LTP] [PATCH] syscalls/fcntl36: add tests for OFD locks Xiong Zhou
2017-08-14 16:02 ` Cyril Hrubis
2017-08-21 11:17   ` [LTP] [PATCH v2] " Xiong Zhou
2017-08-21 16:00     ` Cyril Hrubis
2017-08-22  8:35       ` [LTP] [PATCH v3] " Xiong Zhou
2017-08-22 14:23         ` Cyril Hrubis
2017-08-23  4:15           ` Xiong Zhou [this message]
2017-08-23  8:40             ` Cyril Hrubis
2017-08-23  9:42               ` [LTP] [PATCH v4] " Xiong Zhou
2017-08-23  9:53             ` [LTP] [PATCH v3] " Cyril Hrubis
2017-08-23 13:15               ` [LTP] [PATCH v5] " Xiong Zhou
2017-08-23 13:35                 ` Cyril Hrubis
2017-08-24  7:48                   ` [LTP] [PATCH v6] " Xiong Zhou
2017-08-29 14:27                     ` Cyril Hrubis
2017-09-01  3:00                       ` [LTP] [PATCH v7] " Xiong Zhou
2017-09-05 12:06                         ` Cyril Hrubis
2017-09-05 13:13                           ` Xiong Zhou

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=20170823041558.33vhtfsdswenhcfa@XZHOUW.usersys.redhat.com \
    --to=xzhou@redhat.com \
    --cc=ltp@lists.linux.it \
    /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.