From: Mike Frysinger <vapier@gentoo.org>
To: ltp-list@lists.sourceforge.net
Cc: CAI Qian <caiqian@redhat.com>
Subject: Re: [LTP] [PATCH] mmap/munmap /dev/zero
Date: Tue, 12 Oct 2010 15:15:06 -0400 [thread overview]
Message-ID: <201010121515.07416.vapier@gentoo.org> (raw)
In-Reply-To: <63954223.194911286892436382.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>
[-- Attachment #1.1: Type: Text/Plain, Size: 1695 bytes --]
On Tuesday, October 12, 2010 10:07:16 CAI Qian wrote:
> +/* main setup function of test */
> +void setup();
> +/* cleanup function for the test */
> +void cleanup();
> +int mmapzero();
functins that take no args should be "(void)" and not "()"
> +int main(int ac, char **av)
use consistent style. this should be "int argc" and "char *argv[]".
> + if (msg != (char *)NULL) {
useless cast
> + if(TEST_RETURN != 0)
need a space before the "("
> + x = mmap("/dev/zero", SIZE+SIZE-4096, PROT_READ|PROT_WRITE,
> + MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
uhh, have you even checked this test ? this mmap() makes absolutely no sense
on so many levels.
> + if (x == MAP_FAILED) {
> + perror("error");
make this perror() slightly less useless by replacing "error" with "mmap".
although, i wonder why you cant use any of the ltp helper functions for error
reporting ... tests rarely (if ever) should be writing to stdout/stderr
themselves.
> + if (!fork()) {
> + munmap(x + SIZE+4096, SIZE-4096*2);
> + _exit(0);
> + }
> + if (!fork()) {
> + if (!fork()) {
> + munmap(x + SIZE+4096, SIZE-4096*2);
> + _exit(0);
> + }
> + munmap(x + SIZE+4096, SIZE-4096*2);
> + _exit(0);
> + }
> + munmap(x, SIZE+SIZE-4096);
fork() returns -1 on error which means this code misbehaves.
why are you using _exit() ?
munmap() returns a value you shouldbe checking. blindly calling funcs doesnt
accomplish much.
> + void cleanup()
> + {
> + /*
> + * remove the tmp directory and exit
> + */
> + TEST_CLEANUP;
> + tst_rmdir();
> + tst_exit();
> +
> + }
useless newline before the closing brace
-mike
[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 369 bytes --]
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
[-- Attachment #3: Type: text/plain, Size: 155 bytes --]
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2010-10-12 19:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-12 14:07 [LTP] [PATCH] mmap/munmap /dev/zero CAI Qian
2010-10-12 19:15 ` Mike Frysinger [this message]
2010-10-12 20:06 ` Garrett Cooper
2010-10-13 2:06 ` CAI Qian
2010-10-13 2:06 ` CAI Qian
2010-10-13 2:28 ` Mike Frysinger
2010-10-13 2:37 ` CAI Qian
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=201010121515.07416.vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=caiqian@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 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.