From: Jan Stancek <jstancek@redhat.com>
To: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH v2] pipeio/pipeio.c: cleanup
Date: Thu, 10 Apr 2014 07:27:36 -0400 (EDT) [thread overview]
Message-ID: <592669147.2947135.1397129256250.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <1397122484-29192-1-git-send-email-wangxg.fnst@cn.fujitsu.com>
----- Original Message -----
> From: "Xiaoguang Wang" <wangxg.fnst@cn.fujitsu.com>
> To: ltp-list@lists.sourceforge.net
> Sent: Thursday, 10 April, 2014 11:34:44 AM
> Subject: [LTP] [PATCH v2] pipeio/pipeio.c: cleanup
>
> Delete some useless comments and fix some.
>
> Use SAFE_* macros.
>
> Make a re-arrangement on original code: let parent process
> work in do_parent(), child process work in do_child(), and
> arguments parse and initialization work in setup().
>
> Delete several useless or pointless options:
> Option C: this option is not supported and has no effect to this test.
>
> Option B: if this option is specified, the parent process will always
> return 0, which won't reflect the correct test results. I think it does
> not make much sense and remove it.
>
> Option d: this option is used to specify a directory, where named pipe
> is created, other than the current directory. Since tst_tmpdir() will
> create a temporary directory, so I think "-d" option can be removed.
>
> printf() is not async-signal-safe, so use write(2) in signal handler
> directly.
>
> Some cleanup.
>
> Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
> ---
> testcases/kernel/ipc/pipeio/pipeio.c | 955
> ++++++++++++++++-------------------
> 1 file changed, 438 insertions(+), 517 deletions(-)
>
> diff --git a/testcases/kernel/ipc/pipeio/pipeio.c
> b/testcases/kernel/ipc/pipeio/pipeio.c
> index 7dfbe44..3b2964c 100644
> --- a/testcases/kernel/ipc/pipeio/pipeio.c
> +++ b/testcases/kernel/ipc/pipeio/pipeio.c
Hi,
<snip>
> +static int Nchildcomplete;
I'd suggest sig_atomic_t here.
> +
> +static int error;
> +static int count;
> +static int num_writers = 1; /* number of writers */
> +static int num_writes = 1; /* number of writes per child */
> +static int loop; /* loop indefinitely */
> +static int exit_error = 1; /* exit on error #, zero means no exit */
> +static int size = 327; /* default size */
> +static int unpipe; /* un-named pipe if non-zero */
> +static int verbose; /* verbose mode if set */
> +static int quiet; /* quiet mode if set */
> +static int num_rpt; /* ping number, how often to print message */
> +static int chld_wait; /* max time to wait between writes, 1 == no wait */
> +static int parent_wait; /* max time to wait between reads, 1 == no wait */
> +static int ndelay = O_NDELAY; /* additional flag to open */
> +static char *writebuf;
> +static char *readbuf;
> +static char pname[PATH_MAX]; /* contains the name of the unamed pipe */
> +static char *blk_type = NON_BLOCKING_IO; /* blocking i/o or not */
> +static char *pipe_type; /* type of pipe under test */
> +static int fds[2]; /* un-named pipe fds */
> +static int read_fd;
> +static int write_fd;
> +static int empty_read;
> +static int format = HEX;
> +static int format_size = -1;
> +static int iotype; /* sync io */
> +static int sem_id;
> +static struct sembuf sem_op;
Some of these variables could be local: "fds" only in setup(),
"sem_op" could be local in do_child() and do_parent().
I'd suggest to also split this list of global variables, so it's clear
which are modified as part of setup and which change value
also throughout the run.
Split of code into functions looked OK to me.
Regards,
Jan
------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2014-04-10 11:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-10 9:34 [LTP] [PATCH v2] pipeio/pipeio.c: cleanup Xiaoguang Wang
2014-04-10 11:27 ` Jan Stancek [this message]
2014-04-11 10:25 ` Xiaoguang Wang
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=592669147.2947135.1397129256250.JavaMail.zimbra@redhat.com \
--to=jstancek@redhat.com \
--cc=ltp-list@lists.sourceforge.net \
--cc=wangxg.fnst@cn.fujitsu.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