All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] mem/oom: call WEXITSTATUS() only if WIFEXITED() returned true
@ 2016-02-24 10:19 Han Pingtian
  2016-02-24 11:03 ` Jan Stancek
  0 siblings, 1 reply; 5+ messages in thread
From: Han Pingtian @ 2016-02-24 10:19 UTC (permalink / raw)
  To: ltp

Only when WIFEXITED() returned true that WEXITSTATUS() can return a
meanful result. So we should check WIFEXITED() first.

Signed-off-by: Han Pingtian <hanpt@linux.vnet.ibm.com>
---
 testcases/kernel/mem/lib/mem.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
index cedcf32..8327998 100644
--- a/testcases/kernel/mem/lib/mem.c
+++ b/testcases/kernel/mem/lib/mem.c
@@ -150,12 +150,16 @@ void oom(int testcase, int lite, int retcode, int allow_sigkill)
 				WTERMSIG(status),
 				tst_strsig(WTERMSIG(status)));
 		}
-	} else	if (WIFEXITED(status) && WEXITSTATUS(status) == retcode) {
-		tst_resm(TPASS, "victim retcode: (%d) %s",
+	} else if (WIFEXITED(status)) {
+		if (WEXITSTATUS(status) == retcode) {
+			tst_resm(TPASS, "victim retcode: (%d) %s",
 				retcode, strerror(retcode));
-	} else {
-		tst_resm(TFAIL, "victim unexpectedly ended with retcode: %d, "
+		} else {
+			tst_resm(TFAIL, "victim unexpectedly ended with retcode: %d, "
 				"expected: %d", WEXITSTATUS(status), retcode);
+		}
+	} else {
+		tst_resm(TFAIL, "victim unexpectedly ended");
 	}
 }
 
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [LTP] [PATCH] mem/oom: call WEXITSTATUS() only if WIFEXITED() returned true
  2016-02-24 10:19 [LTP] [PATCH] mem/oom: call WEXITSTATUS() only if WIFEXITED() returned true Han Pingtian
@ 2016-02-24 11:03 ` Jan Stancek
  2016-02-25  1:18   ` Han Pingtian
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Stancek @ 2016-02-24 11:03 UTC (permalink / raw)
  To: ltp





----- Original Message -----
> From: "Han Pingtian" <hanpt@linux.vnet.ibm.com>
> To: ltp@lists.linux.it
> Sent: Wednesday, 24 February, 2016 11:19:14 AM
> Subject: [LTP] [PATCH] mem/oom: call WEXITSTATUS() only if WIFEXITED()	returned true
> 
> Only when WIFEXITED() returned true that WEXITSTATUS() can return a
> meanful result. So we should check WIFEXITED() first.
> 
> Signed-off-by: Han Pingtian <hanpt@linux.vnet.ibm.com>

Looks good to me.

> ---
>  testcases/kernel/mem/lib/mem.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
> index cedcf32..8327998 100644
> --- a/testcases/kernel/mem/lib/mem.c
> +++ b/testcases/kernel/mem/lib/mem.c
> @@ -150,12 +150,16 @@ void oom(int testcase, int lite, int retcode, int
> allow_sigkill)
>  				WTERMSIG(status),
>  				tst_strsig(WTERMSIG(status)));
>  		}
> -	} else	if (WIFEXITED(status) && WEXITSTATUS(status) == retcode) {
> -		tst_resm(TPASS, "victim retcode: (%d) %s",
> +	} else if (WIFEXITED(status)) {
> +		if (WEXITSTATUS(status) == retcode) {
> +			tst_resm(TPASS, "victim retcode: (%d) %s",
>  				retcode, strerror(retcode));
> -	} else {
> -		tst_resm(TFAIL, "victim unexpectedly ended with retcode: %d, "
> +		} else {
> +			tst_resm(TFAIL, "victim unexpectedly ended with retcode: %d, "
>  				"expected: %d", WEXITSTATUS(status), retcode);
> +		}
> +	} else {
> +		tst_resm(TFAIL, "victim unexpectedly ended");

Is this only theoretical or did you actually run into this?
If so, what are the circumstances for this to happen?

Regards,
Jan

>  	}
>  }
>  
> --
> 1.9.3
> 
> 
> --
> Mailing list info: http://lists.linux.it/listinfo/ltp
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [LTP] [PATCH] mem/oom: call WEXITSTATUS() only if WIFEXITED() returned true
  2016-02-24 11:03 ` Jan Stancek
@ 2016-02-25  1:18   ` Han Pingtian
  2016-02-25  7:46     ` Jan Stancek
  0 siblings, 1 reply; 5+ messages in thread
From: Han Pingtian @ 2016-02-25  1:18 UTC (permalink / raw)
  To: ltp

On Wed, Feb 24, 2016 at 06:03:26AM -0500, Jan Stancek wrote:
> Is this only theoretical or did you actually run into this?
> If so, what are the circumstances for this to happen?

It is only theoretical. I composed this only based on code reading.

Thanks.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [LTP] [PATCH] mem/oom: call WEXITSTATUS() only if WIFEXITED() returned true
  2016-02-25  1:18   ` Han Pingtian
@ 2016-02-25  7:46     ` Jan Stancek
  2016-02-26  2:25       ` Han Pingtian
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Stancek @ 2016-02-25  7:46 UTC (permalink / raw)
  To: ltp



----- Original Message -----
> From: "Han Pingtian" <hanpt@linux.vnet.ibm.com>
> To: "Jan Stancek" <jstancek@redhat.com>
> Cc: ltp@lists.linux.it
> Sent: Thursday, 25 February, 2016 2:18:19 AM
> Subject: Re: [LTP] [PATCH] mem/oom: call WEXITSTATUS() only if WIFEXITED() returned true
> 
> On Wed, Feb 24, 2016 at 06:03:26AM -0500, Jan Stancek wrote:
> > Is this only theoretical or did you actually run into this?
> > If so, what are the circumstances for this to happen?
> 
> It is only theoretical. I composed this only based on code reading.
> 
> Thanks.

I fixed one line going over 80 characters and pushed it.

Regards,
Jan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [LTP] [PATCH] mem/oom: call WEXITSTATUS() only if WIFEXITED() returned true
  2016-02-25  7:46     ` Jan Stancek
@ 2016-02-26  2:25       ` Han Pingtian
  0 siblings, 0 replies; 5+ messages in thread
From: Han Pingtian @ 2016-02-26  2:25 UTC (permalink / raw)
  To: ltp

On Thu, Feb 25, 2016 at 02:46:33AM -0500, Jan Stancek wrote:
> 
> 
> ----- Original Message -----
> > From: "Han Pingtian" <hanpt@linux.vnet.ibm.com>
> > To: "Jan Stancek" <jstancek@redhat.com>
> > Cc: ltp@lists.linux.it
> > Sent: Thursday, 25 February, 2016 2:18:19 AM
> > Subject: Re: [LTP] [PATCH] mem/oom: call WEXITSTATUS() only if WIFEXITED() returned true
> > 
> > On Wed, Feb 24, 2016 at 06:03:26AM -0500, Jan Stancek wrote:
> > > Is this only theoretical or did you actually run into this?
> > > If so, what are the circumstances for this to happen?
> > 
> > It is only theoretical. I composed this only based on code reading.
> > 
> > Thanks.
> 
> I fixed one line going over 80 characters and pushed it.
> 
Thanks!


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-02-26  2:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-24 10:19 [LTP] [PATCH] mem/oom: call WEXITSTATUS() only if WIFEXITED() returned true Han Pingtian
2016-02-24 11:03 ` Jan Stancek
2016-02-25  1:18   ` Han Pingtian
2016-02-25  7:46     ` Jan Stancek
2016-02-26  2:25       ` Han Pingtian

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.