public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Jan Stancek <jstancek@redhat.com>
To: Matus Marhefka <mmarhefk@redhat.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH v2] containers: semctl replaced with semop in	sysvipc/sem_comm.c
Date: Thu, 26 Feb 2015 08:22:24 -0500 (EST)	[thread overview]
Message-ID: <909321360.19304114.1424956944232.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <1424955461-21111-1-git-send-email-mmarhefk@redhat.com>





----- Original Message -----
> From: "Matus Marhefka" <mmarhefk@redhat.com>
> To: ltp-list@lists.sourceforge.net
> Sent: Thursday, 26 February, 2015 1:57:41 PM
> Subject: [LTP] [PATCH v2] containers: semctl replaced with semop in	sysvipc/sem_comm.c
> 
> semctl call replaced with semop call for setting up semaphores initial
> values because semctl needs non-standard type (not in sys/sem.h).
> 
> Signed-off-by: Matus Marhefka <mmarhefk@redhat.com>

Looks good to me.
Reviewed-by: Jan Stancek <jstancek@redhat.com>

Regards,
Jan

> ---
>  testcases/kernel/containers/sysvipc/sem_comm.c | 24 ++++++++++++++----------
>  1 file changed, 14 insertions(+), 10 deletions(-)
> 
> diff --git a/testcases/kernel/containers/sysvipc/sem_comm.c
> b/testcases/kernel/containers/sysvipc/sem_comm.c
> index b44be6d..fba6767 100644
> --- a/testcases/kernel/containers/sysvipc/sem_comm.c
> +++ b/testcases/kernel/containers/sysvipc/sem_comm.c
> @@ -59,14 +59,17 @@ int chld1_sem(void *arg)
>  	int id;
>  	struct sembuf sm;
>  
> -	id = semget(TESTKEY, 1, IPC_CREAT);
> +	id = semget(TESTKEY, 1, IPC_CREAT|S_IRUSR|S_IWUSR|IPC_EXCL);
>  	if (id == -1) {
>  		perror("semget");
>  		return 2;
>  	}
>  
> -	if (semctl(id, 0, SETVAL, 1) == -1) {
> -		perror("semctl");
> +	sm.sem_num = 0;
> +	sm.sem_op = 1;
> +	sm.sem_flg = IPC_NOWAIT;
> +	if (semop(id, &sm, 1) == -1) {
> +		perror("semop");
>  		semctl(id, 0, IPC_RMID);
>  		return 2;
>  	}
> @@ -74,9 +77,7 @@ int chld1_sem(void *arg)
>  	/* tell child2 to continue and wait for it to create the semaphore */
>  	TST_SAFE_CHECKPOINT_WAKE_AND_WAIT(NULL, 0);
>  
> -	sm.sem_num = 0;
>  	sm.sem_op = -1;
> -	sm.sem_flg = IPC_NOWAIT;
>  	if (semop(id, &sm, 1) == -1) {
>  		perror("semop");
>  		semctl(id, 0, IPC_RMID);
> @@ -101,14 +102,19 @@ int chld2_sem(void *arg)
>  	/* wait for child1 to create the semaphore */
>  	TST_SAFE_CHECKPOINT_WAIT(NULL, 0);
>  
> -	id = semget(TESTKEY, 1, IPC_CREAT);
> +	/* IPC_EXCL is excluded because we do not want semget call to fail
> +	 * if namespaces logic doesn't work correctly */
> +	id = semget(TESTKEY, 1, IPC_CREAT|S_IRUSR|S_IWUSR);
>  	if (id == -1) {
>  		perror("semget");
>  		return 2;
>  	}
>  
> -	if (semctl(id, 0, SETVAL, 1) == -1) {
> -		perror("semctl");
> +	sm.sem_num = 0;
> +	sm.sem_op = 1;
> +	sm.sem_flg = IPC_NOWAIT;
> +	if (semop(id, &sm, 1) == -1) {
> +		perror("semop");
>  		semctl(id, 0, IPC_RMID);
>  		return 2;
>  	}
> @@ -116,9 +122,7 @@ int chld2_sem(void *arg)
>  	/* tell child1 to continue and wait for it to lock the semaphore */
>  	TST_SAFE_CHECKPOINT_WAKE_AND_WAIT(NULL, 0);
>  
> -	sm.sem_num = 0;
>  	sm.sem_op = -1;
> -	sm.sem_flg = IPC_NOWAIT;
>  	if (semop(id, &sm, 1) == -1) {
>  		if (errno == EAGAIN) {
>  			rval = 1;
> --
> 1.8.3.1
> 
> 
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming The Go Parallel Website,
> sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for
> all
> things parallel software development, from weekly thought leadership blogs to
> news, videos, case studies, tutorials and more. Take a look and join the
> conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
> 

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

  reply	other threads:[~2015-02-26 13:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-24 17:52 [LTP] [PATCH] containers: semctl replaced with semop in sysvipc/sem_comm.c Matus Marhefka
2015-02-26  9:06 ` Cyril Hrubis
2015-02-26 12:57 ` [LTP] [PATCH v2] " Matus Marhefka
2015-02-26 13:22   ` Jan Stancek [this message]
2015-04-20 10:28     ` Matus Marhefka
2015-04-21  9:21       ` Stanislav Kholmanskikh
2015-04-21 10:12         ` Matus Marhefka

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=909321360.19304114.1424956944232.JavaMail.zimbra@redhat.com \
    --to=jstancek@redhat.com \
    --cc=ltp-list@lists.sourceforge.net \
    --cc=mmarhefk@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