public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: chrubis@suse.cz
To: Jan Stancek <jstancek@redhat.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH] mremap: add new test mremap05
Date: Wed, 31 Oct 2012 11:31:20 +0100	[thread overview]
Message-ID: <20121031103119.GA18055@rei> (raw)
In-Reply-To: <17bab533f4f5e5c80a676158bfd75cfb1b361228.1351608161.git.jstancek@redhat.com>

Hi!
> +static void *test_mremap(void *old_address, size_t old_size, size_t new_size,
> +	int flags, void *new_address, const char *msg, void *exp_ret,
> +	int exp_errno)

Looking at the number of parameters it may be better to pass a structure
pointer here. And looking at the way it's called, most of the structure
could be statically initalized.

See for an example kernel/syscalls/sendto/sendto01.c

> +{
> +	void *ret;
> +
> +	ret = mremap(old_address, old_size, new_size, flags, new_address);
> +	if (ret == exp_ret)
> +		if (ret != MAP_FAILED)
> +			tst_resm(TPASS, "%s", msg);
> +		else
> +			if (errno == exp_errno)
> +				tst_resm(TPASS, "%s", msg);
> +			else
> +				tst_resm(TFAIL|TERRNO, "%s", msg);
> +	else
> +		tst_resm(TFAIL, "%s ret: %p, expected: %p", msg,
> +			ret, exp_ret);
> +	return ret;
> +}

There is too much if ... else ... without any curly brackets, the
indentation helps a lot but I would rather see blocks longer than
one line enclosed in them.

> +int main(int ac, char **av)
> +{
> +	char *msg;
> +	int lc;
> +
> +	msg = parse_opts(ac, av, NULL, NULL);
> +	if (msg != NULL)
> +		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
> +
> +	Tst_count = 0;

There is no need to zero the Tst_count here it's initialized to
zero in tst_res.c.

> +	setup();
> +	for (lc = 0; TEST_LOOPING(lc); lc++) {
> +		Tst_count = 0;
> +		test_fixed_require_maymove();
> +		test_new_addr_not_aligned();
> +		test_old_new_area_overlap();
> +		test_mremap_fixed_maymove();
> +	}
> +	cleanup();
> +	tst_exit();
> +}
> +
> +static void setup(void)
> +{
> +	pagesize = getpagesize();
> +}
> +
> +static void cleanup(void)
> +{
> +	TEST_CLEANUP;
> +}

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

      parent reply	other threads:[~2012-10-31 10:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-30 14:47 [LTP] [PATCH] mremap: add new test mremap05 Jan Stancek
2012-10-31 10:07 ` Wanlong Gao
2012-10-31 10:31 ` chrubis [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=20121031103119.GA18055@rei \
    --to=chrubis@suse.cz \
    --cc=jstancek@redhat.com \
    --cc=ltp-list@lists.sourceforge.net \
    /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